SELFIELD-REFRESH = 'X'. CASE UCOMM. WHEN 'PRINT'. DATA IT_HEAD TYPE TABLE OF ZSDS006_H WITH HEADER LINE. DATA IT_ITEM TYPE TABLE OF ZSDS006_I WITH HEADER LINE. DATA WA_HEAD LIKE LINE OF IT_HEAD. DATA WA_ITEM LIKE LINE OF IT_ITEM. DATA: LS_CONTROL_PARAM TYPE SSFCTRLOP . "打印参数" DATA: LS_COMPOSER_PARAM TYPE SSFCOMPOP . DATA: OUTOPT TYPE SSFCRESOP. DATA: FM_NAME TYPE RS38L_FNAM. DATA: I_JOB_OUTPUT_INFO TYPE SSFCRESCL. LS_CONTROL_PARAM-LANGU = '1'. LS_CONTROL_PARAM-NO_OPEN = 'X'. LS_CONTROL_PARAM-NO_CLOSE = 'X'. LS_CONTROL_PARAM-NO_DIALOG = ''. LS_CONTROL_PARAM-PREVIEW = 'X'. CALL FUNCTION 'SSF_OPEN' EXPORTING CONTROL_PARAMETERS = LS_CONTROL_PARAM * OUTPUT_OPTIONS = LS_COMPOSER_PARAM IMPORTING JOB_OUTPUT_OPTIONS = OUTOPT 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. EXIT. ENDIF. IF P_VBTYP = 'J'. CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME' EXPORTING FORMNAME = 'ZSDS006_FORM' * VARIANT = ' ' * DIRECT_CALL = ' ' IMPORTING FM_NAME = FM_NAME EXCEPTIONS NO_FORM = 1 NO_FUNCTION_MODULE = 2 OTHERS = 3. IF SY-SUBRC <> 0. * Implement suitable error handling here ENDIF. ENDIF. IF P_VBTYP = 'T'. CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME' EXPORTING FORMNAME = 'ZSDS006_FORM1' * VARIANT = ' ' * DIRECT_CALL = ' ' IMPORTING FM_NAME = FM_NAME EXCEPTIONS NO_FORM = 1 NO_FUNCTION_MODULE = 2 OTHERS = 3. IF SY-SUBRC <> 0. * Implement suitable error handling here ENDIF. ENDIF. LOOP AT IT_ALV2 INTO WA_ALV2 WHERE CBOX = 'X'. WA_HEAD-BUTXT = WA_ALV2-BUTXT. WA_HEAD-VBELN = WA_ALV2-VBELN. WA_HEAD-NAME1 = WA_ALV2-NAME1. WA_HEAD-WADAT = WA_ALV2-WADAT. WA_HEAD-ZHWMC = WA_ALV2-ZHWMC. APPEND WA_HEAD TO IT_HEAD. ENDLOOP. SORT IT_HEAD BY VBELN. DELETE ADJACENT DUPLICATES FROM IT_HEAD COMPARING VBELN. LOOP AT IT_HEAD INTO WA_HEAD. CLEAR WA_ITEM. CLEAR: IT_ITEM,IT_ITEM[]. LOOP AT IT_ALV2 INTO WA_ALV2 WHERE VBELN = WA_HEAD-VBELN. WA_ITEM-NAME = WA_ALV2-NAME. WA_ITEM-ZBZGG = WA_ALV2-ZBZGG. WA_ITEM-LFIMG = WA_ALV2-LFIMG1. WA_ITEM-MEINS = WA_ALV2-MEINS. WA_ITEM-CHARG = WA_ALV2-CPPC. WA_ITEM-BZSL = WA_ALV2-BZSL. WA_ITEM-WADAT = WA_ALV2-WADAT. WA_ITEM-VBTYP = WA_ALV2-VBTYP. APPEND WA_ITEM TO IT_ITEM. ENDLOOP. CALL FUNCTION FM_NAME EXPORTING * ARCHIVE_INDEX = * ARCHIVE_INDEX_TAB = * ARCHIVE_PARAMETERS = CONTROL_PARAMETERS = LS_CONTROL_PARAM WA_HEAD = WA_HEAD * MAIL_APPL_OBJ = * MAIL_RECIPIENT = * MAIL_SENDER = OUTPUT_OPTIONS = LS_COMPOSER_PARAM * USER_SETTINGS = 'X' * IMPORTING * DOCUMENT_OUTPUT_INFO = * JOB_OUTPUT_INFO = * JOB_OUTPUT_OPTIONS = TABLES IT_ITEM = IT_ITEM * EXCEPTIONS * FORMATTING_ERROR = 1 * INTERNAL_ERROR = 2 * SEND_ERROR = 3 * USER_CANCELED = 4 * OTHERS = 5 . IF SY-SUBRC <> 0. * Implement suitable error handling here ENDIF. ENDLOOP. CALL FUNCTION 'SSF_CLOSE' IMPORTING JOB_OUTPUT_INFO = I_JOB_OUTPUT_INFO EXCEPTIONS FORMATTING_ERROR = 1 INTERNAL_ERROR = 2 SEND_ERROR = 3 OTHERS = 4. IF SY-SUBRC <> 0. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. ENDCASE.
标签:SY,相同,WA,ALV2,打印,HEAD,PARAM,ITEM,单据 From: https://www.cnblogs.com/Anyohh233/p/17980568