Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Help with code

Former Member
0 Likes
522

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

1 ACCEPTED SOLUTION
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
492

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.

3 REPLIES 3
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
493

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.

Read only

0 Likes
492

Mr. Keshu,

Thank you ver much for your inputs & apologies for having posted the entire problem.

Regards,

Vivek

Read only

0 Likes
492