SAP标准界面实现打印功能(VA03/VL03N)标准打印调用自定义打印程序
以VA03为例
1.事务代码:NACE
VA03属于销售 选中V1 点击输出类型切换修改 创建新的输出类型 如图所示Z*命名的为 自定义输出类型
选中刚刚创建的自定义输出类型 点击处理程序
程序 填写 自定义打印的程序名 如: ZJRSD002
FORM子程序 填写 程序中的FORM 如 VA03_PRINT
表格 填写 自定义的Smartforms
FROM子程序参考代码如下
FORM va03_print USING cv_returncode TYPE sysubrc
uv_screen TYPE char1.
DATA: lt_seltab TYPE TABLE OF rsparams,
lw_seltab LIKE LINE OF lt_seltab.
DATA:ls_data TYPE REF TO data.
FIELD-SYMBOLS: <lt_data> TYPE table,
<l_data> TYPE data.
FIELD-SYMBOLS <fs_vbak> TYPE vbak .
ASSIGN ('(SAPMV45A)VBAK') TO <fs_vbak>.
IF sy-subrc EQ 0.
lw_seltab-selname = 'S_VKORG'.
lw_seltab-sign = 'I'.
lw_seltab-option = 'EQ'.
lw_seltab-low = <fs_vbak>-vkorg.
APPEND lw_seltab TO lt_seltab.
lw_seltab-selname = 'S_VBELN'.
lw_seltab-sign = 'I'.
lw_seltab-option = 'EQ'.
lw_seltab-low = <fs_vbak>-vbeln.
APPEND lw_seltab TO lt_seltab.
cl_salv_bs_runtime_info=>set( display = '' metadata = '' data = 'X' ).
SUBMIT zjrsd002 WITH SELECTION-TABLE lt_seltab WITH sy-batch = 'X'
WITH rb1 = 'X'
AND RETURN .
TRY.
cl_salv_bs_runtime_info=>get_data_ref( IMPORTING r_data = ls_data ).
ASSIGN ls_data->* TO <lt_data>.
CATCH cx_salv_bs_sc_runtime_info.
MESSAGE 'UNABLE TO RETRIEVE ALV DATA' TYPE 'E'.
ENDTRY.
cl_salv_bs_runtime_info=>clear_all( ).
rb1 = 'X'.
g_batch = 'X'.
LOOP AT <lt_data> ASSIGNING <l_data>.
MOVE-CORRESPONDING <l_data> TO gs_alv.
gs_alv-flag = 'X'.
APPEND gs_alv TO gt_alv.
ENDLOOP.
PERFORM frm_print USING '&ZPRN1'.
" BREAK-POINT .
CLEAR:cv_returncode, g_batch .
ENDIF.
ENDFORM .