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

Alternative Logic - Required !!!

Former Member
0 Likes
582

hi guys,

i have to write a function module for search the matching records in the table ekko.

field names : ebeln,bukrs,lifnr (3 fields).

the user will give any values from these three fields that may (all three fields or 1 field or 2 fields).

when he clicks execute it should come out the matching selection from the user.

My logic for the above requirment is :

*step-1 :

select ebeln bukrs lifnr from ekko into CORRESPONDING FIELDS OF TABLE lt_ekko1.

*step-2

if po_no is not initial.

delete lt_ekko1 where ebeln ne po_no.

endif.

*step-3

if co_code is not INITIAL.

delete lt_ekko1 where bukrs ne co_code.

endif.

*step-4

if vendor is not INITIAL.

delete lt_ekko1 where lifnr ne vendor.

endif.

*now my internal table contains the final output in lt_ekko1 internal table.

*this is perfecftly working for me.

But in the case of more fields i need to use more lines of code , instead of this , could you suggest

alternative logic to minimise the code for achieving this result.

regards,

Giri

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
555

Hi Giri,

Declare ranges for all your search fields and fill your input values in ranges. and use it in selct query.

for e.g. select lifnr from lfa1 into table it_lfa1 where lifnr in r_lifnr. similarly all other fields.

4 REPLIES 4
Read only

Former Member
0 Likes
555

in select query use Where ebeln ne PO_NO....for all the 3 fields

Read only

0 Likes
555

hi. thanks for your reply.

but it won't solve my problem. if if the user fills only bukrs and lifnr field alone and leaves the po_no FIELD as blank. then it will fetch wrong no of records.

Read only

Former Member
0 Likes
556

Hi Giri,

Declare ranges for all your search fields and fill your input values in ranges. and use it in selct query.

for e.g. select lifnr from lfa1 into table it_lfa1 where lifnr in r_lifnr. similarly all other fields.

Read only

0 Likes
555

Yes. This is what i wanted ... thank you ....very much....

if you have the code for this you please post it here, it could be helpful for the forum.

regards,

Giri