‎2011 Jul 04 4:48 AM
Hi,
Unfortunately i've been almost a year out of abap,so its kinda rusty, so pls bear with my question. I've to develop this upload program, which would read from file, but the catchy part is that to filter out the records by either pernr, bukrs, subty or any of the criteria simultaneously. I'm using select-options for pernr, subty, bukrs, but the problem is how do i filter it out, what sort of logic/ algorithm should i be using, READ TABLE itab WITH KEY or a LOOP statement, could any 1 give any suggestions as to how i should be designing the logic. please advise
‎2011 Jul 04 8:00 AM
Hi
You want to upload data from a file on the basis of some criteria.
In this case I think you need to upload all the data from the file to an internal table.
Now the internal table contains all the data from the file.
then filter the data from that table on the basis of PERNR, BUKRS or SUBTY.
Like Below:
delete ITAB where PERNR not in S_PERNR (S_PERNR is your select option).
similarly for SUBTY or BUKRS.
Or if you want all these 3 fields together then use OR condition.
Like:
delete ITAB where PERNR not in S_PERNR OR
delete ITAB where PERNR not in S_SUBTY OR
delete ITAB where PERNR not in S_BUKRS.
the above code will delete all the data from ITAB where the data doesn't match with the entries in S_PERNR, S_SUBTY and S_BUKRS.
I hope this will work for you,
If you didn't get it then post your code.
Thanks
LG
‎2011 Jul 04 5:06 AM
Hi
go for read table itab with key pernr = itab-pernr..
if it is not solved ur program
next time send me code
bi
T Bharat Bhushan
‎2011 Jul 04 5:48 AM
read table<your internal table> into <work area> with key <key field> = sel_det-value.
(or)
read table<your internal table> into <work area> with key <key field> = <your required value>.
hope this is helpful.
Edited by: koolspy on Jul 4, 2011 10:18 AM
‎2011 Jul 04 6:08 AM
Hi,
for fast access to your internal table you should either use an internal table of type sorted table or use a SORT commend before access to be able to use option BINARY SEARCH.
Regards,
Klaus
‎2011 Jul 04 7:11 AM
Many ways to do it, depends on the format of the File you are uploading.
If you are uploading a File having no fixed length of fields and difficult to judge the length/position of fields then simply upload the whole file data in an itab and use delete therafter to filter the data.
DELETE itab WHERE pernr NOT IN s_pernr.
DELETE itab WHERE Field2 NOT IN s_field2.
IF you have a File which has a fixed lenth defined for each field, then you can filter the data while uploading itself.
READ DATASET p_filename INTO ls_struc.
if ls_struc-pernr in s_pernr and ls_struc-field2 in s_field2 ....
append ls_struc to itab.
else.
continue.
endif.
‎2011 Jul 04 8:00 AM
Hi
You want to upload data from a file on the basis of some criteria.
In this case I think you need to upload all the data from the file to an internal table.
Now the internal table contains all the data from the file.
then filter the data from that table on the basis of PERNR, BUKRS or SUBTY.
Like Below:
delete ITAB where PERNR not in S_PERNR (S_PERNR is your select option).
similarly for SUBTY or BUKRS.
Or if you want all these 3 fields together then use OR condition.
Like:
delete ITAB where PERNR not in S_PERNR OR
delete ITAB where PERNR not in S_SUBTY OR
delete ITAB where PERNR not in S_BUKRS.
the above code will delete all the data from ITAB where the data doesn't match with the entries in S_PERNR, S_SUBTY and S_BUKRS.
I hope this will work for you,
If you didn't get it then post your code.
Thanks
LG