‎2007 Oct 24 7:07 PM
hi experts,
I have a situation regarding internal tables. I have different records with the same order no in a internal table. There is a filed for completion which has possible values X or ' '. The values will be different for this field for the records with the same oredr no. I need to move only those records which does not have 'an X' at all in the completion field for any of the record with the order no. I am not able figure out the logic. Plz help me in this regard,
thanks
‎2007 Oct 24 9:19 PM
Hi anirvesh,
Assuming that the original internal table is ITAB1 and the fields are ORDNR, XFELD. Your intention is to get ITAB3 loaded.
The solution could look like -
ITAB2[] = ITAB1[].
SORT ITAB2 BY ORDNR.
DELETE ADJACENT DUPLICATES FROM ITAB2 COMPARING ORDNR.
LOOP AT ITAB2.
LORDNR = ITAB2-ORDNR.
LOOP AT ITAB1 WHERE ORDNR = LORDNR AND XFELD = ' '.
ITAB3 = ITAB1.
APPEND ITAB3.
ENDLOOP. " ITAB1.
ENDLOOP. " ITAB2.
More inputs would be helpful to clearly understand your requirements.
Thanks,
Chaps.
‎2007 Oct 24 9:23 PM
Hi,
Try this.
* Create another internal table which is the same structure your original internal
* table..Let's assume your original internal table is ITAB
DATA: ITAB_FINAL LIKE TABLE OF ITAB.
* Move the values to the itab_final from itab.
itab_final[] = itab[].
* Delete the records that are not X
delete itab_final where completion_field <> 'X'.
* Now the itab_final will have the records that do not have X
Thanks
Naren
‎2007 Oct 24 11:32 PM