2009 Feb 25 7:30 AM
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
2009 Feb 25 7:44 AM
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.
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.
2009 Feb 25 7:36 AM
in select query use Where ebeln ne PO_NO....for all the 3 fields
2009 Feb 25 7:40 AM
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.
2009 Feb 25 7:44 AM
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.
2009 Feb 25 7:50 AM
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
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |