‎2007 Dec 26 3:56 AM
Hi All,
Can someone help me with the code for this problem. I would like to check for a given vendor, if there is any PO placed in a financial year (i.e. 1st Jan to 31st Dec) & if any PO is open.
Link: LFM1-LIFNR <=> EKKO-LIFNR
Criteria for PO Placed:
1.Read system date & extract only the year part into 'S_Year' from the system date.
2.Read only the year part of EKKO-BEDAT into 'E_Year' & match with system year. (i.e. 'E_Year' same as 'S_Year').
3.Loop until we find a document (EKKO-EBELN) which matches the above condition
4.Once the document is selected check if deletion indicator (EKPO-LOEKZ) is not 'L'for all lines (EKPO-EBELP) -> If this condition fails, repeat step 3.
->If all condition checks are ok, display text 'Active'.
->If not display text 'Not-Active'
Criteria for PO Open: for the given vendor
1. Loop & find a PO for the vendor for which EKPO-LOEKZ & EKPO-ELIKZ is initial irrespecive of the year.
-> If the 2 conditions are ok, display text 'PO Active'
-> If not display ' '
Eg: The output which i am looking for is something like as shown below
Query Output:
Vendor | PO Status | Vendor Status
123 | Active | Active
245 | | Active
545 | Active | Not-Active
Hope my problem is clear, await inputs.
Vivek
‎2007 Dec 26 4:23 AM
wk_year = sy-datum+0(4).
concatenate '%' '%' '%' '%' wk_year into wk_year.
i guess u may be fetching the vendor details first based on a plant.
"instead of * give the appropriate field names.
select * from ekko into table itab
for all entries in it_vendor
where bedat like wk_year
and lifnr = it_vendor-lifnr.
if sy-subrc = 0.
sort itab ascending.
endif.
select * from ekko into table itab2
for all entries in it_vendor
and lifnr = it_vendor-lifnr.
if sy-subrc = 0.
sort itab2 ascending.
endif.
select * into itab3 from ekpo
for all entries in itab
where ebeln = itab-ebeln
and ebelp = itab-ebelp.
if sy-subrc = 0.
sort itab3 ascending.
loop at itab3.
if loekz <> 'L'.
itab3-vstatus = 'Active'.
else.
itab3-vstatus = 'Not Active'.
endif.
modify itab3 transporting status.
clear itab3.
endloop.
endif.
select * from ekpo into table iatb4
for all entries in itab2
where ebeln = itab2-ebeln
and ebelp = itab2-ebelp.
if sy-subrc = 0.
sort itab4 ascending.
loop at itab4.
if itab4-loekz = space and itab4-elikz = space.
itab4-status = 'PO active'.
modify itab4 transporting status.
clear itab4.
endif.
endif.
last read the tables and move it to final itab.This is just like a logical pseudocode...try the rest
Please Try to do it ur self...the forum is for solving the problems not to do the entire requirement.
Reward if useful.
regards.
‎2007 Dec 26 4:23 AM
wk_year = sy-datum+0(4).
concatenate '%' '%' '%' '%' wk_year into wk_year.
i guess u may be fetching the vendor details first based on a plant.
"instead of * give the appropriate field names.
select * from ekko into table itab
for all entries in it_vendor
where bedat like wk_year
and lifnr = it_vendor-lifnr.
if sy-subrc = 0.
sort itab ascending.
endif.
select * from ekko into table itab2
for all entries in it_vendor
and lifnr = it_vendor-lifnr.
if sy-subrc = 0.
sort itab2 ascending.
endif.
select * into itab3 from ekpo
for all entries in itab
where ebeln = itab-ebeln
and ebelp = itab-ebelp.
if sy-subrc = 0.
sort itab3 ascending.
loop at itab3.
if loekz <> 'L'.
itab3-vstatus = 'Active'.
else.
itab3-vstatus = 'Not Active'.
endif.
modify itab3 transporting status.
clear itab3.
endloop.
endif.
select * from ekpo into table iatb4
for all entries in itab2
where ebeln = itab2-ebeln
and ebelp = itab2-ebelp.
if sy-subrc = 0.
sort itab4 ascending.
loop at itab4.
if itab4-loekz = space and itab4-elikz = space.
itab4-status = 'PO active'.
modify itab4 transporting status.
clear itab4.
endif.
endif.
last read the tables and move it to final itab.This is just like a logical pseudocode...try the rest
Please Try to do it ur self...the forum is for solving the problems not to do the entire requirement.
Reward if useful.
regards.
‎2007 Dec 26 5:06 AM
Mr. Keshu,
Thank you ver much for your inputs & apologies for having posted the entire problem.
Regards,
Vivek
‎2007 Dec 26 5:09 AM