‎2006 Jan 09 7:41 AM
Hi,
I want to delete some reocrds from the internal table where for a particular field there is not data.
SORT i_mara BY matnr.
LOOP AT i_final1 INTO is_final1.
READ TABLE i_mara INTO is_mara WITH KEY
matnr = is_final1-matnr BINARY SEARCH.
IF sy-subrc EQ 0.
CLEAR is_final1.
MOVE is_mara-normt TO is_final1-normt.
MODIFY i_final1 FROM is_final1 TRANSPORTING normt.
ENDIF.
ENDLOOP.
Say before entering the loop i have 3 records in the internal table i_final1.
After the loop is processed i will still have 3 records but the field normt is filled in only one record.
I want to delete the those records for which the field normrt is empty.
can I do that in the same loop or do I have to write one more loop
Can any one help me regarding this
‎2006 Jan 09 8:19 AM
Hi,
You just write this st. after the loop.
delete i_final where normrt = space.
KIndly reward points if it helps.
‎2006 Jan 09 7:46 AM
Hi Hema,
You can do it in the same loop as follows,
SORT i_mara BY matnr.
LOOP AT i_final1 INTO is_final1.
READ TABLE i_mara INTO is_mara WITH KEY
matnr = is_final1-matnr BINARY SEARCH.
IF sy-subrc EQ 0.
<b> IF is_mara-normt IS INITIAL.
DELETE i_final1.
CONTINUE.
ENDIF.</b>
CLEAR is_final1.
MOVE is_mara-normt TO is_final1-normt.
MODIFY i_final1 FROM is_final1 TRANSPORTING normt.
<b>ELSE.
DELETE i_final1.</b>
ENDIF.
ENDLOOP.
Hope this helps..
Sri
‎2006 Jan 09 7:48 AM
Hi,
Check this ...
instead of that you can do this way..
delete i_final1 where normrt = ' '.
Regards
vijay
‎2006 Jan 09 8:19 AM
Hi,
You just write this st. after the loop.
delete i_final where normrt = space.
KIndly reward points if it helps.
‎2006 Jan 09 8:50 AM
Hi Hema,
1. U want to delete record from internal table
( IN A LOOP)
2. Simply using
IF is_mara-normt IS INITIAL.
and DELETE
will do your work
3. BUT,
U MAY FACE PROBLEM BCOS OF LOOP.
(IN BETWEEN RECORDS ARE DELETED)
4. Hence, i suggest the following :
(i had also faced similar problem,
hence, this is one good approach
for such delete record problems)
*----
5. In your internal table,
declare one EXTRA Field (say FLAG)
type c.
6. Loop at your logic,
and if
IF is_mara-normt IS INITIAL
Mark FLAG = 'X'.
and modify the internal table.
6. Let the loop ENDLOOP.
*----
7. After this,
Loop at ITAB.
If itab-flag = 'X'.
DELETE ITAB.
ENDIF.
ENDLOOP.
8. Whenever we have to apply logic
for deleting records in internal table(in a loop)
, always follow this FLAG concept.
regards,
amit m.