获取SAP标准函数的说明(含参数和异常)

report ZGET_FUNC_DES
TYPE-POOLS : slis.

PARAMETERS: p_func LIKE fupararef-funcname.     " Name of Function Module

DATA : BEGIN OF i_tab OCCURS 0,
        funcname      LIKE    fupararef-funcname,       " Name of Function Module
        paramtype     LIKE    fupararef-paramtype,      " Parameter type
        pposition     LIKE    fupararef-pposition,      " Internal Table, Current Line Index
        optional      LIKE    fupararef-optional,       " Optional parameters
        parameter     LIKE    fupararef-parameter,      " Parameter name
        defaultval    LIKE    fupararef-defaultval,     " Default value for import parameter
        structure     LIKE    fupararef-structure,      " Associated Type of an Interface Parameter
        stext         LIKE    funct-stext,              " Short text
    END OF i_tab.

DATA: BEGIN OF mtab_new_prog OCCURS 0,
        line(172) TYPE c,
      END OF mtab_new_prog.

DATA: funcdesc LIKE tftit-stext,     " Short text for function module
      mylen    TYPE i,
      myrc     TYPE i.

CONSTANTS: myhats(40) VALUE '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'.

TRANSLATE p_func TO UPPER CASE.

SELECT SINGLE
       tftit~stext     " Short text for function module
  INTO funcdesc
  FROM tftit
 WHERE tftit~funcname = p_func
   AND tftit~spras    = sy-langu.

TRANSLATE p_func TO LOWER CASE.

CONCATENATE  'CALL FUNCTION ' p_func  '   " ' funcdesc INTO mtab_new_prog-line.
APPEND mtab_new_prog.

TRANSLATE p_func TO UPPER CASE.

SELECT
       fupararef~funcname      " Name of Function Module
       fupararef~paramtype     " Parameter type
       fupararef~pposition     " Internal Table, Current Line Index
       fupararef~optional      " Optional parameters
       fupararef~parameter     " Parameter name
       fupararef~defaultval    " Default value for import parameter
       fupararef~structure     " Associated Type of an Interface Parameter
       funct~stext             " Short text
  INTO TABLE i_tab
  FROM fupararef
       INNER JOIN funct
       ON  fupararef~funcname  = funct~funcname
       AND fupararef~parameter = funct~parameter
       AND funct~spras = sy-langu
 WHERE fupararef~funcname = p_func
 AND fupararef~r3state = 'A'
 ORDER BY fupararef~paramtype
          fupararef~pposition.


LOOP AT i_tab.
  AT NEW paramtype.
    CASE i_tab-paramtype.
      WHEN 'C'.
        MOVE '  CHANGING' TO mtab_new_prog-line.
      WHEN 'E'.
        MOVE '  IMPORTING' TO mtab_new_prog-line.
      WHEN 'I'.
        MOVE '  EXPORTING' TO mtab_new_prog-line.
      WHEN 'T'.
        MOVE '  TABLES' TO mtab_new_prog-line.
      WHEN 'X'.
        MOVE '  EXCEPTIONS' TO mtab_new_prog-line.
    ENDCASE.
    APPEND mtab_new_prog.
  ENDAT.

  IF i_tab-optional = 'X'.
    mtab_new_prog-line = '*^^^'.
  ELSE.
    mtab_new_prog-line = '^^^^'.
  ENDIF.

  IF i_tab-paramtype = 'X'.
    MOVE i_tab-pposition TO i_tab-defaultval.
    CONDENSE i_tab-defaultval.
  ELSE.
    TRANSLATE i_tab-parameter TO LOWER CASE.
  ENDIF.

  CONCATENATE mtab_new_prog-line i_tab-parameter '^=^' INTO mtab_new_prog-line.

  IF i_tab-defaultval IS NOT INITIAL.
    CONCATENATE mtab_new_prog-line i_tab-defaultval  INTO mtab_new_prog-line.
  ENDIF.

  mylen = STRLEN( mtab_new_prog-line ).

  IF mylen < 31.
    COMPUTE mylen = 31 - mylen.
  ELSE.
    MOVE 1 TO mylen.
  ENDIF.

  TRANSLATE i_tab-structure TO LOWER CASE.

  CONCATENATE mtab_new_prog-line myhats+0(mylen) ' " ' i_tab-structure INTO mtab_new_prog-line.

  mylen = STRLEN( mtab_new_prog-line ).

  IF mylen < 47.
    COMPUTE mylen = 47 - mylen.
  ELSE.
    MOVE 1 TO mylen.
  ENDIF.

  CONCATENATE mtab_new_prog-line myhats+0(mylen) ' ' i_tab-stext INTO mtab_new_prog-line.

  APPEND  mtab_new_prog.
ENDLOOP.     " LOOP AT I_TAB

CONCATENATE  '    .  "  ' p_func INTO mtab_new_prog-line.
APPEND mtab_new_prog.

LOOP AT mtab_new_prog.
  TRANSLATE mtab_new_prog-line USING '^ '.
  MODIFY mtab_new_prog.

  IF mtab_new_prog = space.
    SKIP 1.
  ENDIF.
  WRITE: / mtab_new_prog.
ENDLOOP.         " LOOP AT MTAB_NEW_PROG

* Write the beautiful program code to ClipBoard from internal table
CALL METHOD cl_gui_frontend_services=>clipboard_export
  IMPORTING
    data = mtab_new_prog[]
  CHANGING
    rc   = myrc. 

posted on 2006-10-27 17:07  毛小娃  阅读(258)  评论(0编辑  收藏  举报

导航