smartform连续打印,并自动补充空行
生活随笔
收集整理的這篇文章主要介紹了
smartform连续打印,并自动补充空行
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
該報表打印銷售訂單,可以在報表里選中多個銷售單打印,對應的smartform實現了分頁,自動補充空行及顯示當前頁和總頁數等功能,smartform在資源里可以找到。
*&---------------------------------------------------------------------*
*&?Report??ZSDR003*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT?? zsdr003 .
TYPE-POOLS : slis .
TABLES : vbak ,? vbap ,? lips ,? makt ,? likp .
DATA :? it_head? TYPE? TABLE? OF? zsdr003_head? WITH? HEADER? LINE .
DATA :? it_head1? TYPE? TABLE? OF? zsdr003_head? WITH? HEADER? LINE .
DATA :? gt_sfhead? TYPE? TABLE? OF? zsdr003_head? WITH? HEADER? LINE .
DATA :? it_item? TYPE? TABLE? OF? zsdr003_item? WITH? HEADER? LINE .
DATA :?? c_form_name??????? TYPE? tdsfname? ,
???????c_form_title?????? TYPE? string .
DATA :? gv_title? TYPE? lvc_title .
DATA :? gs_layout? TYPE?? slis_layout_alv ,
??????gt_fields?? TYPE?? slis_t_fieldcat_alv ,
??????gs_fields?? TYPE?? LINE?? OF?? slis_t_fieldcat_alv .
SELECTION-SCREEN? BEGIN? OF?? BLOCK? block1? WITH? FRAME? TITLE? text - 001 .
SELECT-OPTIONS :? s_vkorg? FOR? vbak - vkorg .???? "銷售組織
SELECT-OPTIONS :? s_vtweg? FOR? vbak - vtweg .??? "分銷渠道
SELECT-OPTIONS :? s_kunnr? FOR? vbak - kunnr .????? "客戶編號
SELECT-OPTIONS :? s_vbeln? FOR? vbak - vbeln .??????? "銷售訂單號
SELECTION-SCREEN? END? OF? BLOCK? block1 .
START-OF-SELECTION .
?? PERFORM? getdata .
?? PERFORM? alvdata .
*&---------------------------------------------------------------------*
*&??????Form??getdata
*&---------------------------------------------------------------------*
*???????text
*----------------------------------------------------------------------*
FORM? getdata .
?? SELECT
????vbeln
????vkorg
????vtweg
????spart
????auart
????audat
????erdat
????kunnr
????bstnk
????vsnmr_v
????? INTO? CORRESPONDING? FIELDS? OF? TABLE? it_head? FROM? vbak?? WHERE? vkorg? IN? s_vkorg? AND? vtweg? IN? s_vtweg? AND? kunnr? IN? s_kunnr? AND? vbeln? IN? s_vbeln .
ENDFORM .???????????????????? "getdata
*&---------------------------------------------------------------------*
*&??????Form??getdetaildata
*&---------------------------------------------------------------------*
*???????text
*----------------------------------------------------------------------*
FORM? getheaddata .
?? IF? NOT? it_head[]? IS? INITIAL .
???? LOOP? AT? it_head? WHERE? che? EQ? 'X' .
??????it_head1? =? it_head .
?????? APPEND? it_head1 .
???? ENDLOOP .
?? ENDIF .
ENDFORM .???????????????????? "getdetaildata
*&---------------------------------------------------------------------*
*&??????Form??alvdata
*&---------------------------------------------------------------------*
*???????text
*----------------------------------------------------------------------*
FORM? alvdata .
??gs_layout - colwidth_optimize? =? 'X' .
??gs_layout - box_fieldname? =? 'CHE' .
??gs_layout - zebra? =? 'X' .
?? REFRESH? gt_fields .
?? CLEAR? gs_fields .
??gs_fields - fieldname?? =?? 'VKORG' .
??gs_fields - seltext_l?? =?? '銷售組織' .
?? APPEND?? gs_fields?? TO?? gt_fields .
?? CLEAR?? gs_fields .
??gs_fields - fieldname?? =?? 'VTWEG' .
??gs_fields - seltext_l?? =?? '分銷渠道' .
?? APPEND?? gs_fields?? TO?? gt_fields .
?? CLEAR?? gs_fields .
??gs_fields - fieldname?? =?? 'SPART' .
??gs_fields - seltext_l?? =?? '產品組' .
?? APPEND?? gs_fields?? TO?? gt_fields .
?? CLEAR?? gs_fields .
??gs_fields - fieldname?? =?? 'KUNNR' .
??gs_fields - seltext_l?? =?? '客戶編號' .
?? APPEND?? gs_fields?? TO?? gt_fields .
?? CLEAR?? gs_fields .
??gs_fields - fieldname?? =?? 'VBELN' .
??gs_fields - seltext_l?? =?? '銷售訂單號' .
?? APPEND?? gs_fields?? TO?? gt_fields .
?? CLEAR?? gs_fields .
??gs_fields - fieldname?? =?? 'AUDAT' .
??gs_fields - seltext_l?? =?? '憑證日期' .
?? APPEND?? gs_fields?? TO?? gt_fields .
?? CLEAR?? gs_fields .
?? CALL? FUNCTION? 'REUSE_ALV_GRID_DISPLAY'
???? EXPORTING
??????i_callback_program??????? =? sy - repid
??????i_callback_pf_status_set? =? 'SET_PF'
??????i_callback_user_command?? =? 'USER_COM'
??????i_grid_title????????????? =? gv_title
??????is_layout???????????????? =? gs_layout
??????it_fieldcat?????????????? =? gt_fields
??????i_save??????????????????? =? 'X'
???? TABLES
??????t_outtab????????????????? =? it_head
???? EXCEPTIONS
??????program_error???????????? =? 1
?????? OTHERS??????????????????? =? 2 .
ENDFORM .???????????????????? "alvdata
*&---------------------------------------------------------------------*
*&??????Form??set_pf
*&---------------------------------------------------------------------*
*???????text
*----------------------------------------------------------------------*
*??????-->EXTAB??????text
*----------------------------------------------------------------------*
FORM?? set_pf?? USING???? extab?? TYPE?? slis_t_extab .
?? SET?? PF-STATUS?? 'ZSDR003' .
ENDFORM .???????????????????? "set_pf
*&---------------------------------------------------------------------*
*&??????Form??user_com
*&---------------------------------------------------------------------*
*???????text
*----------------------------------------------------------------------*
*??????-->R_UCOMM??????text
*??????-->RS_SELFIELD??text
*----------------------------------------------------------------------*
FORM? user_com? USING? r_ucomm? LIKE? sy - ucomm
??????rs_selfield? TYPE? slis_selfield .
?? DATA :? lr_grid? TYPE? REF? TO? cl_gui_alv_grid ,
????????myindex? TYPE? sy - tabix .
?? CALL? FUNCTION? 'GET_GLOBALS_FROM_SLVC_FULLSCR'
???? IMPORTING
??????e_grid? =? lr_grid .
?? CALL? METHOD? lr_grid -> check_changed_data .
??rs_selfield - refresh? =? 'X' .
?? CASE? r_ucomm .
???? WHEN? '&PRSO' .
?????? DATA :? i? TYPE? i? VALUE? 0 .
?????? LOOP? AT? it_head? WHERE? che? EQ? 'X' .
???????? i? =? i? +? 1 .
?????? ENDLOOP .
?????? IF? i? =? 0 .
???????? MESSAGE : '請選擇需要打印的列'? TYPE? 'E' .
?????? ENDIF .
? ? ?? PERFORM?getheaddata.
?????? PERFORM? printdata .
?? ENDCASE .
?? CLEAR? r_ucomm .
ENDFORM .???????????????????? "user_com
*&---------------------------------------------------------------------*
*&??????Form??printdata
*&---------------------------------------------------------------------*
*???????text
*----------------------------------------------------------------------*
FORM? printdata .
?? DATA :? f_index? LIKE? sy - tabix .
?? DATA :? lines_len? TYPE? i .
?? DATA :? ls_control_parameters?? TYPE? ssfctrlop .
?? DATA :? ls_output_options?????? TYPE? ssfcompop .
?? DATA :? l_smf_name????????????? TYPE? rs38l_fnam .
??c_form_name? =? 'ZSDSF003' .?????????? "對應的smartform的名稱
??ls_output_options - tdimmed??????? =? 'X' .
??ls_output_options - tdcopies?????? =? '1' .
??ls_output_options - tdnoprint????? =? '' .
??ls_output_options - tddelete?????? =? 'X' .
??ls_control_parameters - no_dialog? =? '' .
??ls_control_parameters - preview??? =? 'X' .
??ls_control_parameters - langu????? =? '1' .
?? CALL? FUNCTION? 'SSF_FUNCTION_MODULE_NAME'
???? EXPORTING
??????formname? =? c_form_name
???? IMPORTING
??????fm_name?? =? l_smf_name .
?? SORT? it_head1? BY? vbeln .
?? LOOP? AT? it_head1 .
????ls_control_parameters - no_close? =? 'X' .
???? AT? LAST .
??????ls_control_parameters - no_close? =? space .
???? ENDAT .
????gt_sfhead? =? it_head1 .
???? APPEND? gt_sfhead .
???? SELECT
??vbeln
??posnr
??matnr
??kwmeng
??meins
?? INTO? CORRESPONDING? FIELDS? OF? TABLE? it_item? FROM?? vbap?? FOR? ALL? ENTRIES? IN? gt_sfhead? WHERE? vbeln? =? gt_sfhead - vbeln .
???? LOOP? AT? it_item .
?????? SELECT? SINGLE? maktx? INTO? it_item - maktx? FROM? makt? WHERE? matnr? =? it_item - matnr .
?????? SELECT? SUM (? lfimg? )? INTO? it_item - lfimg? FROM? lips? WHERE? vgbel? =? it_item - vbeln? AND? vgpos? =? it_item - posnr .
??????it_item - remainqty? =? it_item - kwmeng? -? it_item - lfimg .
?????? MODIFY? it_item .
???? ENDLOOP .
???? SORT? it_item? BY? vbeln?posnr .
???? CALL? FUNCTION? l_smf_name
?????? EXPORTING
????????control_parameters? =? ls_control_parameters
????????output_options????? =? ls_output_options
????????user_settings?????? =? 'X'
?????? TABLES
????????gt_head???????????? =? gt_sfhead[]
????????gt_item???????????? =? it_item[]
?????? 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 .
???? CLEAR? gt_sfhead .
???? REFRESH? gt_sfhead[] .
???? CLEAR? it_item .
???? REFRESH? it_item[] .
????ls_control_parameters - no_open? =? 'X' .
???? AT? LAST .
??????ls_control_parameters - no_open? =? space .
???? ENDAT .
?? ENDLOOP .
?? CLEAR? it_head1 .
?? REFRESH? it_head1[] .
ENDFORM .???????????????????? "printdata
總結
以上是生活随笔為你收集整理的smartform连续打印,并自动补充空行的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: WebService到底是什么?
- 下一篇: SAP FI FAGLFLEXT/FAG