*&---------------------------------------------------------------------*
*& Report ZBBTEST1
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZBBTEST1.
DATA:gt_line TYPE tline OCCURS 0 WITH HEADER LINE.
DATA:gt_tab LIKE tline OCCURS 0 WITH HEADER LINE,
gs_tab TYPE tline.
DATA:g_job_output_info TYPE ssfcrescl.
START-OF-SELECTION.
PERFORM frm_get_data.
PERFORM frm_deal_data.
PERFORM frm_print_data.
END-OF-SELECTION.
*&---------------------------------------------------------------------*
*& Form FRM_GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_get_data .
CALL FUNCTION 'READ_TEXT'
EXPORTING
* CLIENT = SY-MANDT
id = 'SYST'
language = sy-langu
name = 'Z_PO_TERMS' "l_tdname
object = 'TEXT'
TABLES
lines = gt_line
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
ENDFORM. " FRM_GET_DATA
*&---------------------------------------------------------------------*
*& Form FRM_DEAL_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_deal_data .
DATA:l_i TYPE i.
CLEAR:gt_line.
l_i = 0.
LOOP AT gt_line.
l_i = l_i + 1.
IF gt_line-tdformat = '*'.
gt_tab-tdformat = l_i.
gt_tab-tdline = gt_line-tdline.
CONDENSE gt_tab-tdline.
APPEND gt_tab.
CLEAR gt_tab.
ELSE.
l_i = l_i - 1.
READ TABLE gt_tab WITH KEY tdformat = l_i.
IF sy-subrc = 0.
CONCATENATE gt_tab-tdline gt_line-tdline INTO gt_tab-tdline.
MODIFY gt_tab INDEX l_i.
ENDIF.
ENDIF.
ENDLOOP.
CLEAR gt_tab.
LOOP AT gt_tab.
* IF gt_tab-tdline+0(2) = ',,'.
* REPLACE ',,' WITH ' ' INTO gt_tab-tdline.
* MODIFY gt_tab.
* ELSEIF gt_tab-tdline+0(3) = ', ,'.
* REPLACE ', ,' WITH ' ' INTO gt_tab-tdline.
* MODIFY gt_tab.
* ENDIF.
IF gt_tab-tdline CS ',,'.
REPLACE ',,' WITH ' ' INTO gt_tab-tdline.
CONDENSE gt_tab-tdline.
MODIFY gt_tab.
ENDIF.
ENDLOOP.
ENDFORM. " FRM_DEAL_DATA
*&---------------------------------------------------------------------*
*& Form FRM_PRINT_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_print_data .
DATA: ls_output_options TYPE ssfcompop.
DATA: ls_control_parameters TYPE ssfctrlop.
DATA: l_fmname TYPE rs38l_fnam.
DATA: lt_errortab TYPE tsferror.
PERFORM start_sf USING 'ZSFDPF1'
CHANGING ls_output_options
ls_control_parameters
l_fmname.
CALL FUNCTION '/1BCDWB/SF00000067' "smartforms的名称
EXPORTING
control_parameters = ls_control_parameters
output_options = ls_output_options
TABLES
tab = gt_tab
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF sy-subrc <> 0.
* g_flag = '1'.
* g_message = '打印失败,请检查!'.
ELSE.
ENDIF.
PERFORM end_sf TABLES lt_errortab.
ENDFORM. " FRM_PRINT_DATA
*&---------------------------------------------------------------------*
*& Form START_SF
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_0051 text
* <--P_LW_OUTPUT_OPTIONS text
* <--P_LW_CONTROL_PARAMETERS text
* <--P_LV_FMNAME text
*----------------------------------------------------------------------*
FORM start_sf USING p_gc_sfname TYPE tdsfname
CHANGING p_ls_output_options TYPE ssfcompop
p_ls_control_parameters TYPE ssfctrlop
p_l_fmname TYPE rs38l_fnam.
CLEAR:p_ls_output_options,p_ls_control_parameters,p_l_fmname.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = p_gc_sfname
IMPORTING
fm_name = p_l_fmname.
p_ls_control_parameters-no_open = 'X'.
p_ls_control_parameters-no_close = 'X'.
* p_ls_control_parameters-no_dialog = 'X'.
* p_ls_control_parameters-getotf = 'X'.
* p_ls_output-tddest = 'LP01'.
* p_ls_output-tdprinter = 'Microsoft Office Document Image Writer'.
p_ls_output_options-rqposname = ''.
p_ls_output_options-tddataset = ''.
p_ls_output_options-tdsuffix1 = ''.
p_ls_output_options-tdsuffix2 = ''.
p_ls_output_options-tdimmed = 'X'.
p_ls_output_options-tddelete = 'X'.
* p_ls_output_options-tdnoprev = 'X'.
CALL FUNCTION 'SSF_OPEN'
EXPORTING
control_parameters = p_ls_control_parameters
output_options = p_ls_output_options
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
ENDFORM. " START_SF
*&---------------------------------------------------------------------*
*& Form END_SF
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LT_ERRORTAB text
*----------------------------------------------------------------------*
FORM end_sf TABLES p_lt_errortab TYPE tsferror.
DATA: otf TYPE tsfotf.
CALL FUNCTION 'SSF_CLOSE'
IMPORTING
job_output_info = g_job_output_info
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
OTHERS = 4.
CALL FUNCTION 'SSF_READ_ERRORS'
IMPORTING
errortab = p_lt_errortab[].
otf[] = g_job_output_info-otfdata[].
CALL FUNCTION 'SSFCOMP_PDF_PREVIEW'
EXPORTING
i_otf = otf
EXCEPTIONS
convert_otf_to_pdf_error = 1
cntl_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM. " END_SF
*& Report ZBBTEST1
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZBBTEST1.
DATA:gt_line TYPE tline OCCURS 0 WITH HEADER LINE.
DATA:gt_tab LIKE tline OCCURS 0 WITH HEADER LINE,
gs_tab TYPE tline.
DATA:g_job_output_info TYPE ssfcrescl.
START-OF-SELECTION.
PERFORM frm_get_data.
PERFORM frm_deal_data.
PERFORM frm_print_data.
END-OF-SELECTION.
*&---------------------------------------------------------------------*
*& Form FRM_GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_get_data .
CALL FUNCTION 'READ_TEXT'
EXPORTING
* CLIENT = SY-MANDT
id = 'SYST'
language = sy-langu
name = 'Z_PO_TERMS' "l_tdname
object = 'TEXT'
TABLES
lines = gt_line
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
ENDFORM. " FRM_GET_DATA
*&---------------------------------------------------------------------*
*& Form FRM_DEAL_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_deal_data .
DATA:l_i TYPE i.
CLEAR:gt_line.
l_i = 0.
LOOP AT gt_line.
l_i = l_i + 1.
IF gt_line-tdformat = '*'.
gt_tab-tdformat = l_i.
gt_tab-tdline = gt_line-tdline.
CONDENSE gt_tab-tdline.
APPEND gt_tab.
CLEAR gt_tab.
ELSE.
l_i = l_i - 1.
READ TABLE gt_tab WITH KEY tdformat = l_i.
IF sy-subrc = 0.
CONCATENATE gt_tab-tdline gt_line-tdline INTO gt_tab-tdline.
MODIFY gt_tab INDEX l_i.
ENDIF.
ENDIF.
ENDLOOP.
CLEAR gt_tab.
LOOP AT gt_tab.
* IF gt_tab-tdline+0(2) = ',,'.
* REPLACE ',,' WITH ' ' INTO gt_tab-tdline.
* MODIFY gt_tab.
* ELSEIF gt_tab-tdline+0(3) = ', ,'.
* REPLACE ', ,' WITH ' ' INTO gt_tab-tdline.
* MODIFY gt_tab.
* ENDIF.
IF gt_tab-tdline CS ',,'.
REPLACE ',,' WITH ' ' INTO gt_tab-tdline.
CONDENSE gt_tab-tdline.
MODIFY gt_tab.
ENDIF.
ENDLOOP.
ENDFORM. " FRM_DEAL_DATA
*&---------------------------------------------------------------------*
*& Form FRM_PRINT_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_print_data .
DATA: ls_output_options TYPE ssfcompop.
DATA: ls_control_parameters TYPE ssfctrlop.
DATA: l_fmname TYPE rs38l_fnam.
DATA: lt_errortab TYPE tsferror.
PERFORM start_sf USING 'ZSFDPF1'
CHANGING ls_output_options
ls_control_parameters
l_fmname.
CALL FUNCTION '/1BCDWB/SF00000067' "smartforms的名称
EXPORTING
control_parameters = ls_control_parameters
output_options = ls_output_options
TABLES
tab = gt_tab
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF sy-subrc <> 0.
* g_flag = '1'.
* g_message = '打印失败,请检查!'.
ELSE.
ENDIF.
PERFORM end_sf TABLES lt_errortab.
ENDFORM. " FRM_PRINT_DATA
*&---------------------------------------------------------------------*
*& Form START_SF
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_0051 text
* <--P_LW_OUTPUT_OPTIONS text
* <--P_LW_CONTROL_PARAMETERS text
* <--P_LV_FMNAME text
*----------------------------------------------------------------------*
FORM start_sf USING p_gc_sfname TYPE tdsfname
CHANGING p_ls_output_options TYPE ssfcompop
p_ls_control_parameters TYPE ssfctrlop
p_l_fmname TYPE rs38l_fnam.
CLEAR:p_ls_output_options,p_ls_control_parameters,p_l_fmname.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = p_gc_sfname
IMPORTING
fm_name = p_l_fmname.
p_ls_control_parameters-no_open = 'X'.
p_ls_control_parameters-no_close = 'X'.
* p_ls_control_parameters-no_dialog = 'X'.
* p_ls_control_parameters-getotf = 'X'.
* p_ls_output-tddest = 'LP01'.
* p_ls_output-tdprinter = 'Microsoft Office Document Image Writer'.
p_ls_output_options-rqposname = ''.
p_ls_output_options-tddataset = ''.
p_ls_output_options-tdsuffix1 = ''.
p_ls_output_options-tdsuffix2 = ''.
p_ls_output_options-tdimmed = 'X'.
p_ls_output_options-tddelete = 'X'.
* p_ls_output_options-tdnoprev = 'X'.
CALL FUNCTION 'SSF_OPEN'
EXPORTING
control_parameters = p_ls_control_parameters
output_options = p_ls_output_options
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
ENDFORM. " START_SF
*&---------------------------------------------------------------------*
*& Form END_SF
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LT_ERRORTAB text
*----------------------------------------------------------------------*
FORM end_sf TABLES p_lt_errortab TYPE tsferror.
DATA: otf TYPE tsfotf.
CALL FUNCTION 'SSF_CLOSE'
IMPORTING
job_output_info = g_job_output_info
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
OTHERS = 4.
CALL FUNCTION 'SSF_READ_ERRORS'
IMPORTING
errortab = p_lt_errortab[].
otf[] = g_job_output_info-otfdata[].
CALL FUNCTION 'SSFCOMP_PDF_PREVIEW'
EXPORTING
i_otf = otf
EXCEPTIONS
convert_otf_to_pdf_error = 1
cntl_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM. " END_SF