REFRESH : gtd_out,gtd_prps.
gtd_prps = gtd_list.
LOOP AT gtd_list INTO gth_list WHERE flag = 'X'.
MOVE-CORRESPONDING gth_list TO gth_header.
SELECT SINGLE PRINTDATE INTO gth_header-PRINTDATE FROM ZTZRPS002_N1
WHERE RSNUM = gth_header-RSNUM AND AUFNR = gth_header-AUFNR AND VORNR = gth_header-VORNR AND PSPID = gth_header-PSPID AND POSID = gth_header-POSID .
"自定义表ZTZRPS002_N1读取是否上次存储过打印之后的数据
IF SY-SUBRC <> 0.
gth_header-PRINTDATE = SY-DATUM."没有被打印过,设置为当前日期
ENDIF.
DATA:v_output_info TYPE ssfcrescl,
v_output_options TYPE ssfcompop,
v_PRINT_COUNT(3) TYPE c.
v_output_options-tdiexit = 'X'."(这个参数一定要传,这样在smartform预览界面点后退按钮后,下面的传出参数v_output_info-outputdone不会被赋值)
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = 'ZPSF002_N1'
IMPORTING
FM_NAME = GWK_FNAME.
CALL FUNCTION GWK_FNAME
EXPORTING
OUTPUT_OPTIONS = v_output_options
IMPORTING
JOB_OUTPUT_INFO = v_output_info
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5.
IF SY-SUBRC = 0. "SMARTFORM执行之后,执行此处代码
IF v_output_info-outputdone = 'X'.“判断是否是真正的进行过打印,是的话将数据存储到数据表中
LOOP AT gtd_header INTO gth_header .
SELECT SINGLE PRINTDATE INTO gth_header-PRINTDATE FROM ZTZRPS002_N1
WHERE RSNUM = gth_header-RSNUM AND AUFNR = gth_header-AUFNR AND VORNR = gth_header-VORNR AND PSPID = gth_header-PSPID AND POSID = gth_header-POSID .
IF SY-SUBRC <> 0.
ITAB_WA-RSNUM = gth_header-RSNUM.
ITAB_WA-AUFNR = gth_header-AUFNR.
ITAB_WA-VORNR = gth_header-VORNR.
ITAB_WA-PSPID = gth_header-PSPID.
ITAB_WA-POSID = gth_header-POSID.
ITAB_WA-PRINTDATE = SY-DATUM.
MODIFY ZTZRPS002_N1 FROM ITAB_WA.
ENDIF.
ENDLOOP.