怎么样使用系统提供功能模块Function Module?

怎么样使用系统提供功能模块Function Module?

  1. 将负号放到数字的前面:CLOI_PUT_SIGN_IN_FRONT
    说明:Move the negative sign from the left hand side of a number, to the right hand side
    of the number. Note that The result will be left justified (like all character
    fields), not right justifed as numbers normally are.
  2. 转换日期格式:SLS_MISC_CONVERT_TO_DATE
    说明:
    CALL FUNCTION 'SLS_MISC_CONVERT_TO_DATE'
    EXPORTING
    p_date = sy-datum
    P_DATE_FORMAT
    = 'YYYY-MM-DD'
    IMPORTING
    P_DATE_STRING = G_DATE_STRING
    EXCEPTIONS
    ERROR_SELECTING_USER_DEFAULTS = 1
    OTHERS = 2
    .
  3. 读取用户地址:SUSR_USER_ADDRESS_READ
    说明:
    CALL FUNCTION 'SUSR_USER_ADDRESS_READ'
    EXPORTING
    USER_NAME = SY-UNAME
    READ_DB_DIRECTLY = ' '
    IMPORTING
    USER_ADDRESS = ADDR3_VAL
    USER_USR03 = USR03
    EXCEPTIONS
    USER_ADDRESS_NOT_FOUND = 1
    OTHERS = 2.
    IF SY-SUBRC = 0.

  4. 读取用户Email地址:ADDR_PERS_COMP_COMM_GET
    说明:
    CALL FUNCTION 'ADDR_PERS_COMP_COMM_GET'
    EXPORTING
    ADDRESS_NUMBER = ADDR3_VAL-ADDRNUMBER
    LANGUAGE = SY-LANGU
    PERSON_NUMBER = ADDR3_VAL-PERSNUMBER
    TABLE_TYPE = 'ADSMTP'
    TABLES
    COMM_TABLE = IN_EMAIL
    EXCEPTIONS
    OTHERS = 1.

  5. 读取domain(域)描述:DOMAIN_VALUE_GET
    说明:
    CALL FUNCTION 'DOMAIN_VALUE_GET'
    EXPORTING
    I_DOMNAME =
    I_DOMVALUE =
    * IMPORTING
    * E_DDTEXT =
    * EXCEPTIONS
    * NOT_EXIST = 1
    * OTHERS = 2

  6. 选择上传文件时,弹出文件浏览界面:F4_FILENAME
    说明:
    CALL FUNCTION 'F4_FILENAME'
    * EXPORTING
    * PROGRAM_NAME = SYST-CPROG
    * DYNPRO_NUMBER = SYST-DYNNR
    * FIELD_NAME = ' '
    * IMPORTING
    * FILE_NAME =

  7. 上载文件是否存在检查:WS_QUERY
    说明:
    CALL FUNCTION 'WS_QUERY'
    EXPORTING
    FILENAME = P_FILE
    QUERY = 'FE'
    IMPORTING
    RETURN = G_FLAG_RCODE
    EXCEPTIONS
    INV_QUERY = 01
    NO_BATCH = 02.

    IF G_FLAG_RCODE = '0'. " 文件不存在,给出相关提示信息。
    MESSAGE '您选择的文件不存在,请重新选择上载文件?' TYPE 'I'.
    EXIT.
    ENDIF.

  8. 将Excel表格的内容读入内表:ALSM_EXCEL_TO_INTERNAL_TABLE
    说明:
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
    EXPORTING
    FILENAME = P_FILE
    I_BEGIN_COL = G_COLUMN_BEGIN "从第1列读取
    I_BEGIN_ROW = G_ROW_BEGIN "从第2行读取
    I_END_COL = G_COLUMN_COUNT "共9列
    I_END_ROW = '65536'
    TABLES
    INTERN = TAB_INTERN.
    * EXCEPTIONS
    * INCONSISTENT_PARAMETERS = 1
    * UPLOAD_OLE = 2
    * OTHERS = 3

    IF SY-SUBRC <> 0.
    MESSAGE '您上传的文件是合法的EXCEL文件吗?' TYPE 'S'.
    ENDIF.

  9. 将金额转换为大写:ZFUN0001(应该是顾问开发的,今天又用到一次,收藏过来:)
    说明:
    CALL FUNCTION 'ZFUN0001'
    EXPORTING
    l_val = REC_MAINDATA-RMWWR
    IMPORTING
    l_word = G_UPPER.

    代码见另外一篇帖子:

  10.  
  11.  
  12.  
  13.