else.
invoiceheader-bstnk = out_tab_list_1-bstnk. "cpo
invoiceheader-vbeln = out_tab_list_1-vbelna. "so
invoiceheader-vbelnf = out_tab_list_1-vbeln ." BILLING
***GET SHIPPING DATE.
select single lfdat into invoiceheader-lfdat
from likp inner join lips
on likp~vbeln = lips~vbeln
where vgbel = out_tab_list_1-vbelna.
***sold to/billing to address
clear: vbpa, adrc, adrct, t005t.
select single * from vbpa where vbeln = out_tab_list_1-vbelna
and ( parvw = 'PY' or parvw = 'RG' ).
select single * from adrc where addrnumber = vbpa-adrnr .
select single * from kna1 where kunnr = vbpa-kunnr.
select single * from t005t
where land1 = adrc-country
and spras = 'E' .
invoiceheader-bill_to = vbpa-kunnr.
invoiceheader-adr2_name1 = adrc-name1.
invoiceheader-adr2_st = adrc-street.
invoiceheader-region = adrc-city1.
invoiceheader-adr2_supply = adrc-str_suppl1.
invoiceheader-adr2_post = adrc-post_code1.
invoiceheader-adr2_county = t005t-landx.
invoiceheader-stceg = kna1-stceg.
***get billing type
invoiceheader-fkart = out_tab_list_1-fkart.
***get HAWB
select single * from zpcesddninfo where vbeln =
out_tab_list_1-vbelnl.
invoiceheader-xblnr = zpcesddninfo-bol_no.
***ship to address
clear: vbpa, adrc, adrct, t005t.
select single * from vbpa
where vbeln = out_tab_list_1-vbelna and ( parvw = 'WE' or parvw
= 'SH' ) .
select single * from adrc where addrnumber = vbpa-adrnr.
select single * from adrct where addrnumber = vbpa-adrnr.
select single * from t005t
where land1 = adrc-country
and spras = 'E' .
invoiceheader-ship_to = adrc-name1.
invoiceheader-adr_name1 = adrc-name1.
invoiceheader-ship_adr = adrc-street.
invoiceheader-adr_adr1 = adrc-str_suppl1.
invoiceheader-adr_adr2 = adrc-str_suppl2.
invoiceheader-adr_adr3 = adrc-str_suppl3.
invoiceheader-adr_post = adrc-post_code1.
invoiceheader-adr_region = adrc-region.
invoiceheader-adr_county = t005t-landx.
invoiceheader-in_email = ''.
invoiceheader-telephone = adrc-tel_number.
invoiceheader-in_name = adrc-name1.
invoiceheader-in_fax = adrc-fax_number.
invoiceheader-in_city = adrc-city1.
append invoiceheader.
*********get invoice detail
clear: vbrp,zposnr,invoicedetail.
select vbeln posnr matnr fkimg as enmng
into corresponding fields of table invoicedetail
from vbrp where vbeln = out_tab_list_1-vbeln.
zposnr = 1.
loop at invoicedetail.
if ( out_tab_list_1-fkart = 'ZPLF' )
or ( out_tab_list_1-fkart = 'ZPLG' )
or ( out_tab_list_1-fkart = 'ZPLH' )
or ( out_tab_list_1-fkart = 'ZPLI' )
or ( out_tab_list_1-fkart = 'ZPLJ' )
or ( out_tab_list_1-fkart = 'ZPLK' ).
***GET MATERIAL DESCRIPTION
select single arktx into invoicedetail-maktx from vbrp
where vbeln = invoicedetail-vbeln
and posnr = invoicedetail-posnr.
***GET CUSTOMER PN& MATERIAL
invoicedetail-matnr = ''.
invoicedetail-bismt = ''.
else.
***GET MATERIAL DESCRIPTION
select single maktx into invoicedetail-maktx from makt
where matnr = invoicedetail-matnr and spras = 'EN'.
***GET CUSTOMER PN
select single bismt into invoicedetail-bismt from mara
where matnr = invoicedetail-matnr .
endif.
****GET PRICE
select single * from vbrk where vbeln = out_tab_list_1-vbeln.
select single * from konv where knumv = vbrk-knumv
and kposn = invoicedetail-posnr
and kschl = 'PR00'.
invoicedetail-kbetr = konv-kbetr .
if konv-waers = 'USD'.
invoicedetail-netpr = invoicedetail-kbetr * invoicedetail-enmng.
elseif konv-waers <> ''.
t_intval = invoicedetail-kbetr .
call function 'CURRENCY_AMOUNT_SAP_TO_DISPLAY'
exporting
currency = konv-waers
amount_internal = t_intval
importing
amount_display = t_disval
exceptions
internal_error = 1
others = 2.
p_disval = t_disval.
call function 'READ_EXCHANGE_RATE'
exporting
date = out_tab_list_1-erdat
foreign_currency = 'USD'
local_currency = konv-waers
type_of_rate =
'M' " SAP standard exchange rates
importing
exchange_rate = t_er " exchange rates
foreign_factor = t_ff " foreign factor
local_factor = t_lf " local factor
valid_from_date = t_vfd.
if sy-subrc eq 0.
ld_erate = t_er / ( t_ff / t_lf ).
if ld_erate > 0.
p_disval = p_disval / ld_erate * konv-kpein.
else.
ld_erate = ld_erate * -1.
p_disval = p_disval / ld_erate * konv-kpein.
endif.
invoicedetail-kbetr = p_disval.
invoicedetail-netpr = invoicedetail-kbetr * invoicedetail-enmng.
endif.
endif.
invoicedetail-posnr = zposnr.
modify invoicedetail.
zposnr = zposnr + 1.
clear:vbrk,konv,t_intval,t_disval,p_disval,invoicedetail.
endloop.
endif.
if invoicedetail2[] is initial.
invoicedetail2[] = invoicedetail[].
else.
loop at invoicedetail.
move-corresponding invoicedetail to invoicedetail2.
append invoicedetail2.
endloop.
free:invoicedetail[].
endif.
endloop.
endform. " output_PDF
*&---------------------------------------------------------------------*
*& Form EXCEL_document
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* *----------------------------------------------------------------------*
form. excel_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. output_excel.
endif.
endform. " EXCEL_document
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/14397246/viewspace-666223/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/14397246/viewspace-666223/