report zrsd_pce_0165 no standard page heading message-id zs001.
include zrsd_pce_0165_top.
include zrsd_pce_0165_fm.
at selection-screen on value-request for filename.
perform. choose_input_file .
*---------------------------------------------------------------------*
* START-OF-SELECTION *
*---------------------------------------------------------------------*
start-of-selection.
repid = sy-repid.
perform. extract_document_data.
describe table out_tab_list_1 lines listline .
if listline > 0.
perform build_field.
perform display_data.
else.
message s003 with 'NO DATA FOUND!'. "No data found.
endif.
*----------------------------------------------------------------------*
* INCLUDE ZRSD_PCE_0165_FM *
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form extract_document_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* *----------------------------------------------------------------------*
form. extract_document_data .
select vbrk~vbeln vbrp~aubel as vbelna vbrp~vgbel as vbelnl
vbrk~fkart vbrk~kunag vbrk~vkorg vbrk~vtweg vbrk~spart vbrk~erdat
vbak~bstnk
into corresponding fields of table out_tab_list
from vbrk inner join vbrp
on vbrk~vbeln = vbrp~vbeln
inner join vbak
on vbak~vbeln = vbrp~aubel
where vbrk~vbeln in vbeln
and vbrp~aubel in vbelna
and vbrp~vgbel in vbelnl
and vbak~bstnk in bstnk
and vbrk~kunag in kunnr
and vbrk~vkorg in vkorg
and vbrk~vtweg in vtweg
and vbrk~spart in spart
and vbrk~fkart in fkart
and vbrk~erdat in erdat
and vbrk~vbeln not like '28%'.
**" 28 is cancel billing
sort out_tab_list by vbeln bstnk.
loop at out_tab_list.
clear:out_tab_list_1.
move-corresponding out_tab_list to out_tab_list_1.
***get cancell billing number
select single vbeln into out_tab_list_1-sfakn
from vbrk where sfakn = out_tab_list-vbeln.
***check DN if exist.
select single * from likp where vbeln = out_tab_list-vbelnl.
if sy-subrc <> 0.
if ( out_tab_list-fkart = 'ZPLA')
or ( out_tab_list-fkart = 'ZPLB')
or ( out_tab_list-fkart = 'ZPLC')
or ( out_tab_list-fkart = 'ZPLD')
or ( out_tab_list-fkart = 'ZPLE').
continue.
endif.
endif.
append out_tab_list_1.
endloop.
delete adjacent duplicates from out_tab_list_1 comparing all fields.
endform. " extract_document_data
*&---------------------------------------------------------------------*
*& Form build_field
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* *----------------------------------------------------------------------*
form. build_field.
perform. append_alv using:
'SELID' 'Selid' 'X' 'X',
'VBELN' 'Billing Document' '' '',
'BSTNK' 'Customer PO' '' '',
'VBELNA' 'Sales Order' '' '',
'VBELNL' 'Delivery Notes' '' '',
'SFAKN' 'Cancel Billing Number' '' '',
'FKART' 'Billing type' '' '',
'KUNAG' 'Sold to party' '' '',
'VKORG' 'Sales Org' '' '',
'VTWEG' 'Sales Channel' '' '',
'SPART' 'Divison' '' '',
'ERDAT' 'Billing Create Date' '' ''.
endform. " build_field
*&---------------------------------------------------------------------*
*& Form display_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* *----------------------------------------------------------------------*
form. display_data.
wa_layout-zebra = 'X'.
wa_layout-colwidth_optimize = 'X'.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = repid
i_callback_pf_status_set = 'ZSD_165_1000'
i_callback_user_command = 'USER_COMMAND'
i_grid_title = 'EMC invoice For EPDIII'
is_layout = wa_layout
it_fieldcat = fieldcat[]
tables
t_outtab = out_tab_list_1[].
endform. " display_data
*&---------------------------------------------------------------------*
*& Form append_alv
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_1805 text
* -->P_1806 text
* -->P_1807 text
* -->P_1808 text
*----------------------------------------------------------------------*
form. append_alv using fieldname fieldtext checkbox edit.
move:
fieldname to fieldcat-fieldname,
fieldtext to fieldcat-seltext_l,
checkbox to fieldcat-checkbox,
edit to fieldcat-edit.
append fieldcat to fieldcat.
clear fieldcat.
endform. " append_alv
*&---------------------------------------------------------------------*
*& Form Z165_1000
*&---------------------------------------------------------------------*
form. zsd_165_1000 using rt_extab type slis_t_extab.
set pf-status '1000'.
endform.
*&---------------------------------------------------------------------*
*& Form USER_COMMAND
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* *----------------------------------------------------------------------*
form. user_command using r_ucomm type sy-ucomm
rs_selfield type slis_selfield.
call function 'GET_GLOBALS_FROM_SLVC_FULLSCR'
importing
e_grid = gv_grid.
call method gv_grid->check_changed_data.
call method gv_grid->refresh_table_display.
case r_ucomm.
when 'BACK'.
leave to screen 0.
when 'EXIT'.
leave program.
when 'OUTPUT' .
perform. list_document .
when 'EXCEL'.
perform. excel_document .
when 'SELALL'.
perform mark_all using 'X' .
when 'DESELALL'.
perform. mark_all using 'N' .
endcase.
endform.
*&---------------------------------------------------------------------*
*& Form list_document
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* *----------------------------------------------------------------------*
form. list_document.
describe table out_tab_list_1 lines listline.
do listline times.
out_tab_list_1-selid = space.
clear: out_tab_list_1 .
read line sy-index field
value out_tab_list_1-selid out_tab_list_1-vbeln.
check sy-subrc eq 0.
if out_tab_list_1-selid ='X'.
modify out_tab_list_1 transporting selid
where vbeln = out_tab_list_1-vbeln.
elseif out_tab_list_1-selid eq ''.
modify out_tab_list_1 transporting selid
where vbeln = out_tab_list_1-vbeln.
endif.
read table out_tab_list_1 with key selid = 'X'.
if out_tab_list_1-selid ='X'.
modify out_tab_list_1 transporting selid
where vbeln = out_tab_list_1-vbeln.
elseif out_tab_list_1-selid eq ''.
modify out_tab_list_1 transporting selid
where vbeln = out_tab_list_1-vbeln.
endif.
enddo.
read table out_tab_list_1 with key selid = 'X'.
if sy-subrc ne 0.
message i000 with 'Please First Choose ItemNO.'.
exit.
else.
perform. output_pdf.
perform. call_smartforms.
endif.
endform. " list_document
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/14397246/viewspace-666220/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/14397246/viewspace-666220/