HI ABAP expert,
Sorry because i'm not expert in ABAP. I got this ABAP program for Open PO in SDN,
can anyone help me to change the
> PO Amount change to PO Value
> GR/SE Amount Change to GR Value
> IR AMount Change to IR Value
> Outstanding change to Value Outstanding
***************************************************************
report zaprropo message-id zm no standard page heading line-size 212
line-count 65.
TABLES------------------------------------------------------------*
tables:
ekko, " Purchasing Document Header
ekpo, " Purchasing Document Item
ekbe, " History of PurchasingDocument
essr. " Service Entry Sheet HeaderData
DATA--------------------------------------------------------------*
data : begin of it_ekko occurs 0,
ebeln like ekko-ebeln,
ernam like ekko-ernam,
ekgrp like ekko-ekgrp,
bedat like ekko-bedat,
end of it_ekko.
data : begin of it_ekbe_gr occurs 0,
ebeln like ekbe-ebeln,
ebelp like ekbe-ebelp,
bewtp like ekbe-bewtp,
dmbtr like ekbe-dmbtr,
end of it_ekbe_gr.
data : begin of it_ekbe_ir occurs 0,
ebeln like ekbe-ebeln,
ebelp like ekbe-ebelp,
bewtp LIKE ekbe-bewtp,
dmbtr like ekbe-dmbtr,
end of it_ekbe_ir.
data : begin of it_output occurs 0,
ekgrp like ekko-ekgrp,
ebeln like ekko-ebeln,
ebelp like ekpo-ebelp,
ernam like ekko-ernam,
afnam like ekpo-afnam,
bedat like ekko-bedat,
txz01 like ekpo-txz01,
bewtp LIKE ekbe-bewtp,
netwr like ekpo-netwr,
dmbtr like ekbe-dmbtr,
iramt like ekbe-dmbtr,
outst like ekpo-netwr,
eindt like eket-eindt,
effwr LIKE ekpo-effwr,
end of it_output.
data : begin of it_title occurs 0,
h11(5),
h0(5),
h1(13),
h2(7),
h3(15),
h4(15),
h5(10),
h6(40),
h7(20),
h8(20),
h9(20),
h10(20),
h12(10),
end of it_title.
data : flength.
data : s_no type i value 1.
---- Added by Gopi
Internal table for PO / WO Delivery Date
data : begin of it_eket occurs 0,
ebeln like eket-ebeln,
ebelp like eket-ebelp,
eindt like eket-eindt,
end of it_eket.
----
selections
******************************************************
selection-screen : skip.
selection-screen : begin of block block1 with frame title text-001.
parameters : s_bukrs like ekko-bukrs.
select-options : s_ebeln for ekko-ebeln,
s_bedat for ekko-bedat,
s_ekgrp for ekko-ekgrp.
s_hdg for ekko-ekgrp.
selection-screen : end of block block1.
selection-screen begin of block btch with frame title text-003.
parameters: excel as checkbox,
file(128) type c.
selection-screen end of block btch.
selection-screen begin of block block2 with frame title text-002.
parameters: asat as checkbox,
p_date like sy-datum.
selection-screen end of block block2.
--
at selection-screen.
at selection-screen on value-request for file.
perform get_file_name using file.
main program code**************************************************
start-of-selection.
it_title-h11 = 'S.No'.
it_title-h0 = 'Group'.
it_title-h1 = 'PO Number'.
it_title-h2 = 'PO Item'.
it_title-h3 = 'PO Creator'.
it_title-h4 = 'Requisitor'.
it_title-h5 = 'PO Date'.
it_title-h6 = 'PO Short Text'.
it_title-h7 = 'PO Amount'.
it_title-h8 = 'GR/SE Amount'.
it_title-h9 = 'IR Amount'.
it_title-h10 = 'Outstanding'.
it_title-h12 = 'Del. Date'.
append it_title.
perform extract_po_details_new. "20070814
perform extract_po_history_new. "20070814
perform calculate_outstanding_new. "20070814
end-of-selection.
perform display_report.
if excel = 'X'.
perform download.
endif.
---- Added by Gopi
top-of-page.
perform page_heading.
display_report ****************************
form display_report.
it_title-h11 = 'S.No'.
it_title-h0 = 'Group'.
it_title-h1 = 'PO Number'.
it_title-h2 = 'PO Item'.
it_title-h3 = 'PO Creator'.
it_title-h4 = 'Requisitor'.
it_title-h5 = 'PO Date'.
it_title-h6 = 'PO Short Text'.
it_title-h7 = 'PO Amount'.
it_title-h8 = 'GR/SE Amount'.
it_title-h9 = 'IR Amount'.
it_title-h10 = 'Outstanding'.
it_title-h12 = 'Del Date'.
APPEND it_title.
*
WRITE : / 'Outstanding PO Listing Report'.
ULINE.
FORMAT COLOR COL_HEADING.
WRITE : /1 it_title-h11,
7 it_title-h0,
14 it_title-h1,
29 it_title-h2,
38 it_title-h3,
53 it_title-h4,
68 it_title-h5,
79 it_title-h6,
122 it_title-h7,
142 it_title-h8,
162 it_title-h9,
182 it_title-h10,
202 it_title-h12.
FORMAT COLOR OFF.
ULINE.
If Output table is not empty
if not it_output[] is initial.
loop at it_output.
on change of it_output-ebeln.
uline.
write : /1(5) s_no, 6 sy-vline,
7 it_output-ekgrp,
14 it_output-ebeln,
29 it_output-ebelp,
38 it_output-ernam,
53 it_output-afnam,
68 it_output-bedat,
79 it_output-txz01,
122 it_output-netwr,
142 it_output-dmbtr,
162 it_output-iramt,
182 it_output-outst,
202 it_output-eindt.
s_no = s_no + 1.
else.
write :/6 sy-vline,
29 it_output-ebelp,
38 it_output-ernam,
53 it_output-afnam,
68 it_output-bedat,
79 it_output-txz01,
122 it_output-netwr,
142 it_output-dmbtr,
162 it_output-iramt,
182 it_output-outst,
202 it_output-eindt.
endon.
WRITE :/6 sy-vline.
clear : it_output.
endloop.
else.
If Output table is empty
format color 5 intensified on.
write : / 'No outstanding report generated for the purchasing group'
,s_ekgrp-low, 'to', s_ekgrp-high,'for the period'
,s_bedat-low, 'to', s_bedat-high.
format color off.
endif.
endform.
download*********************************
form download.
data: begin of it_download_header occurs 1,
h0(5),
h1(13),
h2(7),
h3(15),
h4(15),
h5(10),
h6(40),
h7(20),
h8(20),
h9(20),
h10(20),
h12(10).
data: end of it_download_header.
it_download_header-h0 = 'Group'.
it_download_header-h1 = 'PO Number'.
it_download_header-h2 = 'PO Item'.
it_download_header-h3 = 'PO Creator'.
it_download_header-h4 = 'Requisitor'.
it_download_header-h5 = 'PO Date'.
it_download_header-h6 = 'PO Short Text'.
it_download_header-h7 = 'PO Amount'.
it_download_header-h8 = 'GR/SE Amount'.
it_download_header-h9 = 'IR Amount'.
it_download_header-h10 = 'Outstanding'.
it_download_header-h12 = 'Del. Date'.
append it_download_header.
call function 'WS_DOWNLOAD'
exporting
codepage = 'IBM'
filename = file
filetype = 'DAT'
importing
filelength = flength
tables
data_tab = it_download_header
exceptions
file_open_error = 1
file_write_error = 2
invalid_filesize = 3
invalid_table_width = 4
invalid_type = 5.
call function 'WS_DOWNLOAD'
exporting
codepage = 'IBM'
filename = file
filetype = 'DAT'
mode = 'A'
importing
filelength = flength
tables
data_tab = it_output
exceptions
file_open_error = 1
file_write_error = 2
invalid_filesize = 3
invalid_table_width = 4
invalid_type = 5.
if sy-subrc ne 0.
message e999 with 'error downloading file :' file.
endif.
endform.
&----
*& Form get_file_name
&----
text
----
-->P_P_FNAME text
----
form get_file_name using p_fname.
call function 'WS_FILENAME_GET'
exporting
def_filename = p_fname
mask = ',.,..'
mode = 'S'
importing
filename = p_fname
exceptions
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
others = 5.
endform. " get_file_name
&----
*& Form page_heading
&----
text
----
--> p1 text
<-- p2 text
----
form page_heading.
*
it_title-h11 = 'S.No'.
it_title-h0 = 'Group'.
it_title-h1 = 'PO Number'.
it_title-h2 = 'PO Item'.
it_title-h3 = 'PO Creator'.
it_title-h4 = 'Requisitor'.
it_title-h5 = 'PO Date'.
it_title-h6 = 'PO Short Text'.
it_title-h7 = 'PO Amount'.
it_title-h8 = 'GR/SE Amount'.
it_title-h9 = 'IR Amount'.
it_title-h10 = 'Outstanding'.
it_title-h12 = 'Del. Date'.
APPEND it_title.
write : / 'Outstanding PO Listing Report'.
uline.
format color col_heading.
write : /1 it_title-h11,
7 it_title-h0,
14 it_title-h1,
29 it_title-h2,
38 it_title-h3,
53 it_title-h4,
68 it_title-h5,
79 it_title-h6,
122 it_title-h7,
142 it_title-h8,
162 it_title-h9,
182 it_title-h10,
202 it_title-h12.
format color off.
uline.
endform. " page_heading
&----
*& Form EXTRACT_PO_DETAILS_NEW
&----
text
----
--> p1 text
<-- p2 text
----
form extract_po_details_new.
data: begin of it_po occurs 0,
ebeln like ekko-ebeln,
ebelp like ekpo-ebelp,
ernam like ekko-ernam,
ekgrp like ekko-ekgrp,
bedat like ekko-bedat,
txz01 like ekpo-txz01,
netwr like ekpo-netwr,
afnam like ekpo-afnam,
effwr like ekpo-effwr.
data: end of it_po.
refresh it_output.
if not p_date is initial.
select aebeln bebelp aernam aekgrp abedat btxz01 b~netwr
bafnam beffwr
into corresponding fields of table it_po
from ekpo as b inner join ekko as a
on bebeln = aebeln
where a~bukrs = s_bukrs and
a~aedat le p_date and
a~ebeln in s_ebeln and
a~bedat in s_bedat and
a~ekgrp in s_ekgrp and
a~frgke ne 'E' and
b~loekz not in ('L', 'S', 'X').
else.
select aebeln bebelp aernam aekgrp abedat btxz01 b~netwr
bafnam beffwr
into corresponding fields of table it_po
from ekpo as b inner join ekko as a
on bebeln = aebeln
where a~bukrs = s_bukrs and
a~ebeln in s_ebeln and
a~bedat in s_bedat and
a~ekgrp in s_ekgrp and
a~frgke ne 'E' and
b~loekz not in ('L', 'S', 'X').
endif.
sort it_po by ebeln ebelp.
delete adjacent duplicates from it_po.
delete it_po where ekgrp eq 'HDB' and ebelp eq 10. "20070814
delete it_po where ebeln+0(1) eq '6'.
loop at it_po.
move-corresponding it_po to it_output.
append it_output.
clear it_output.
endloop.
refresh it_po.
free it_po.
endform. " EXTRACT_PO_DETAILS_NEW
&----
*& Form EXTRACT_PO_HISTORY_NEW
&----
text
----
--> p1 text
<-- p2 text
----
form extract_po_history_new.
data: begin of it_ekbe occurs 2000,
ebeln like ekbe-ebeln,
ebelp like ekbe-ebelp,
bewtp like ekbe-bewtp,
shkzg like ekbe-shkzg,
dmbtr like ekbe-dmbtr.
data: end of it_ekbe.
check not it_output[] is initial.
select * into corresponding fields of table it_ekbe
from ekbe for all entries in it_output
where ebeln = it_output-ebeln and
ebelp = it_output-ebelp and
bewtp in ('E', 'N', 'Q', 'R', 'X').
loop at it_ekbe.
if it_ekbe-bewtp = 'E'. "GET GR AMT
move it_ekbe-ebeln to it_ekbe_gr-ebeln.
move it_ekbe-ebelp to it_ekbe_gr-ebelp.
move it_ekbe-bewtp to it_ekbe_gr-bewtp.
if it_ekbe-shkzg = 'H'.
it_ekbe_gr-dmbtr = it_ekbe-dmbtr * ( -1 ).
else.
it_ekbe_gr-dmbtr = it_ekbe-dmbtr.
endif.
collect it_ekbe_gr.
else. "GET IR AMT
ELSEIF IT_EKBE-BEWTP = 'N' OR "GET IR AMT
IT_EKBE-BEWTP = 'Q' OR
IT_EKBE-BEWTP = 'R' OR
IT_EKBE-BEWTP = 'X'.
move it_ekbe-ebeln to it_ekbe_ir-ebeln.
move it_ekbe-ebelp to it_ekbe_ir-ebelp.
if it_ekbe-shkzg = 'H'.
it_ekbe_ir-dmbtr = it_ekbe-dmbtr * ( -1 ).
else.
it_ekbe_ir-dmbtr = it_ekbe-dmbtr.
endif.
collect it_ekbe_ir.
endif.
endloop.
refresh it_ekbe.
free it_ekbe.
endform. " EXTRACT_PO_HISTORY_NEW
&----
*& Form CALCULATE_OUTSTANDING_NEW
&----
text
----
--> p1 text
<-- p2 text
----
form calculate_outstanding_new.
DATA: BEGIN OF IT_EKET OCCURS 10000,
EBELN LIKE EKET-EBELN,
EBELP LIKE EKET-EBELP,
EINDT LIKE EKET-EINDT.
DATA: END OF IT_EKET.
sort: it_ekbe_gr, it_ekbe_ir.
sort it_output by ebeln ebelp.
loop at it_output.
read table it_ekbe_gr with key ebeln = it_output-ebeln
ebelp = it_output-ebelp.
if sy-subrc = 0.
move it_ekbe_gr-dmbtr to it_output-dmbtr.
endif.
read table it_ekbe_ir with key ebeln = it_output-ebeln
ebelp = it_output-ebelp.
if sy-subrc = 0.
move it_ekbe_ir-dmbtr to it_output-iramt.
endif.
if it_output-iramt gt it_output-netwr.
delete it_output. " where iramt gt it_output-netwr.
clear : it_output.
continue.
endif.
if it_output-ekgrp eq 'HDB'.
if it_output-netwr = it_output-iramt.
delete it_output.
clear it_output.
else.
it_output-outst = it_output-netwr - it_output-iramt.
modify it_output.
endif.
else.
if it_output-netwr = it_output-dmbtr.
if it_output-dmbtr = it_output-iramt.
delete it_output.
clear it_output.
else.
it_output-outst = it_output-netwr - it_output-iramt.
modify it_output.
endif.
else.
if it_output-netwr = it_output-iramt.
delete it_output.
clear it_output.
else.
it_output-outst = it_output-netwr - it_output-iramt.
modify it_output.
endif.
endif.
endif.
endloop.
sort it_output by ebeln ebelp.
check not it_output[] is initial.
select * into corresponding fields of table it_eket
from eket for all entries in it_output
where ebeln = it_output-ebeln and
ebelp = it_output-ebelp.
sort it_eket by ebeln ebelp.
loop at it_output.
read table it_eket with key ebeln = it_output-ebeln
ebelp = it_output-ebelp.
if sy-subrc = 0.
it_output-eindt = it_eket-eindt.
else.
clear it_output-eindt.
endif.
modify it_output.
endloop.
sort it_output by ekgrp ebeln ebelp.
endform. " CALCULATE_OUTSTANDING_NEW