2009 Apr 23 2:47 PM
Hi,
I have a simple block of code that reads rows from an internal table (already populated from a database table) and displays the data on the screen with a WRITE statement.
Just for practice I am trying to delete the rows from the internal table after I have displayed them.
Here is the code that I have so far, but this is not correct. Can someone please tell me how to code the DELETE statement?
Thank you!
Andy
LOOP AT it_zmember01 INTO wa_zmember01.
WRITE: / wa_zmember01-mnumber UNDER 'NUMBER',
wa_zmember01-mname UNDER 'NAME',
wa_zmember01-mdob UNDER 'DOB'.
WRITE / '----
'.
DELETE it_zmember01 FROM wa_zmember01.
ENDLOOP.
2009 Apr 23 2:57 PM
Use this code
data : l_tabix like sy-tabix.
LOOP AT it_zmember01 INTO wa_zmember01.
l_tabix = sy-tabix.
WRITE: / wa_zmember01-mnumber UNDER 'NUMBER',
wa_zmember01-mname UNDER 'NAME',
wa_zmember01-mdob UNDER 'DOB'.
WRITE / '----
'.
DELETE it_zmember01 index l_tabix.
ENDLOOP.
Hi,
I have a simple block of code that reads rows from an internal table (already populated from a database table) and displays the data on the screen with a WRITE statement.
Just for practice I am trying to delete the rows from the internal table after I have displayed them.
Here is the code that I have so far, but this is not correct. Can someone please tell me how to code the DELETE statement?
Thank you!
Andy
LOOP AT it_zmember01 INTO wa_zmember01.
WRITE: / wa_zmember01-mnumber UNDER 'NUMBER',
wa_zmember01-mname UNDER 'NAME',
wa_zmember01-mdob UNDER 'DOB'.
WRITE / '----
'.
DELETE it_zmember01 FROM wa_zmember01.
ENDLOOP.
2009 Apr 23 2:55 PM
Hi Andrew,
Use DELETE t_itab statement inside the loop.
I have modified your code. It is perfectly working.See bellow -
LOOP AT it_zmember01 INTO wa_zmember01.
WRITE: / wa_zmember01-mnumber UNDER 'NUMBER',
wa_zmember01-mname UNDER 'NAME',
wa_zmember01-mdob UNDER 'DOB'.
WRITE / '-----------------------------------------------------------------'.
DELETE it_zmember01. " Modified
ENDLOOP.DELETE it_zmember01. statement inside the loop will delete the current row of the table.
Regards
Pinaki
2009 Apr 23 3:41 PM
Pinaki,
One thing I did not mention is that this internal table does not have a header line, so your solution did not work in my case. But now I know that if I had a header line I could use your solution.
Thank you very much.
Andy
2009 Apr 23 2:57 PM
Use this code
data : l_tabix like sy-tabix.
LOOP AT it_zmember01 INTO wa_zmember01.
l_tabix = sy-tabix.
WRITE: / wa_zmember01-mnumber UNDER 'NUMBER',
wa_zmember01-mname UNDER 'NAME',
wa_zmember01-mdob UNDER 'DOB'.
WRITE / '----
'.
DELETE it_zmember01 index l_tabix.
ENDLOOP.
2009 Apr 23 3:44 PM
2009 Apr 23 3:02 PM
Hi,
Try this.
data: v_tabix type sy-tabix.
loop at itab
v_tabix = sy-tabix.
write: itab-field.
delete itab index sy-tabix.
endloop.
2009 Apr 23 3:43 PM
N Soumya
Your solution was exactly the same as Vijayakumar V
Thank you very much for the help. I appreciate it!
Andy
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |