ABAP 最简单SMARFORMS

*&---------------------------------------------------------------------*
*& Report ZMMF_09_PRINT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZMMF_09_PRINT.

"先自定义结构,ZMM_S_09

DATA: GW_ITAB TYPE ZMM_S_09. "WORK AREA
DATA: GT_ITAB LIKE TABLE OF GW_ITAB. "取出数据放到此内表,然后再调用SMARTFORM传入

DATA FM_NAME TYPE RS38L_FNAM. "FIXED TYPE,装SMARTFORM 返回出来的 FUNCTION MODULE

INITIALIZATION.
  PERFORM GET_DATA. "GET DATA
  PERFORM SF_TO_FM. " SMARTFORM TO FUNCTION MODULE

START-OF-SELECTION.
  PERFORM SHOW_SMARTFORM. "SHOW SMARTFORM

END-OF-SELECTION.

*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM GET_DATA .
  SELECT
    *
    FROM ( ( EKPO AS A
      INNER JOIN EKKO AS B ON A~EBELN = B~EBELN )
      INNER JOIN MAKT AS C ON A~MATNR = C~MATNR )
    INTO CORRESPONDING FIELDS OF TABLE GT_ITAB
    WHERE A~EBELN = '4500000318'.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form SF_TO_FM
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM SF_TO_FM .

   "该FUNCTION 是把SMARTFORM变成一个FUNCTION MODULE
   CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
      EXPORTING
        FORMNAME                 = 'ZMM_FORM_PRINT_09' "THIS IS SMARTFORM'S NAME
     IMPORTING
       FM_NAME                  = FM_NAME "获取到返回出来的FUNCTION MODULE
     EXCEPTIONS
       NO_FORM                  = 1
       NO_FUNCTION_MODULE       = 2
       OTHERS                   = 3
              .
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form SHOW_SMARTFORM
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM SHOW_SMARTFORM .

    "调用获取到的FUNCTION MODULE
    CALL FUNCTION FM_NAME
    EXPORTING
*      OUTPUT_OPTIONS = ssfcomp
*      control_parameters   = control_parameters
**    MAIL_APPL_OBJ  = nast-objtype
*      MAIL_RECIPIENT = LVS_RECIPIENT
*      MAIL_SENDER    = LVS_SENDER
      USER_SETTINGS = SPACE
    TABLES
*     S_HEAD           = I_HEAD           "传入的内表
      GT_ITAB          = GT_ITAB
    EXCEPTIONS
      FORMATTING_ERROR = 1
      INTERNAL_ERROR   = 2
      SEND_ERROR       = 3
      USER_CANCELED    = 4
      OTHERS           = 5.
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

ENDFORM.

ABAP 最简单SMARFORMS
ABAP 最简单SMARFORMS
ABAP 最简单SMARFORMS
ABAP 最简单SMARFORMS
ABAP 最简单SMARFORMS

上一篇:【NOIP2013提高组】华容道


下一篇:【YBT高效进阶】1基础算法/5广度优先搜索/3立体推箱子