2010 Jan 06 7:58 AM
Hi experts,
I have a req. in which there is an internal table it_tab with 4 fields A, B, C, D.
After the data in the internal table is appended, I need to delete the field D from it.
For ex:
ITAB has following entries:
A B C D
1 2 3 4
5 6 7 8
I need to delete the D column totally.
How can this be achieved?
Thanks,
Ajay.
2010 Jan 06 8:06 AM
Hi ajay,
In case you want to CLEAR the contents of column D (and not delete column d), then one way is
Loop at itab.
clear itab-d.
modify d.
endloop.
Regards,
Amit Mittal.
2010 Jan 06 8:02 AM
How about not to consider column D for further processing/Calculation/Printing and keep it Idle to avoid your next question like "How to get back column D?"
2010 Jan 06 8:05 AM
I am using this internal table in a FM, where I do need this field... The place where I am calling this FM in the main report, I don't need this field. So I need a logic to delete the field in the main report.
2010 Jan 06 8:12 AM
Hi Ajay,
I dont see any possibility of deleting a column from internal table. Instead, you have to take another internal table with required fields, Loop at first table and populate the second table fields.
If you don't want the data in column D, you already got the solution from our friends.
May be if you can go in to the details, we can think of alternative approaches.
Thanks,
Vinod.
2010 Jan 06 8:13 AM
>
> I am using this internal table in a FM, where I do need this field... The place where I am calling this FM in the main report, I don't need this field.
As a result I said, just keep this field into your internal table but do not use it anywhere in report within loop and keep it Idle. Thatu2019s it
Cheers
2010 Jan 06 8:06 AM
Hi ajay,
In case you want to CLEAR the contents of column D (and not delete column d), then one way is
Loop at itab.
clear itab-d.
modify d.
endloop.
Regards,
Amit Mittal.
2021 Apr 10 1:26 PM
modify itab. "instead of modify d.
Or you can use a field symbol to clear the column in the header line and modify table in one step:
LOOP AT itab ASSIGNING FIELD-SYMBOL(<fs>).
CLEAR <fs>-d.
ENDLOOP.
2010 Jan 06 8:13 AM
Hi you can take another internal table with 3 fields A B C,
Now loop the ist internal table ITAB1 and assign append values into 2nd internal table ITAB2
loop at itab1 into wa1
WA2-A = WA1-A
WA2-B = WA1-B
WA2-C = WA1-C
append wa2 to itab2.
endloop.
You will get only 3 columns in your 2nd internal table
Please let me know if you need further info
Regards
Satish Boguda
2015 Sep 29 12:33 PM
If you need to erase column, good way is using: MODIFY, statement.
Using following code you can erase a column (col1) from internal table (lt_data):
Data:
ls_data LIKE LINE OF lt_data.
ls_data-col1 = ''.
MODIFY lt_data FROM ls_data
TRANSPORTING col1
WHERE col1 IS NOT INITIAL.
It is not difficult but it could help some beginners.