‎2008 Jan 09 11:08 AM
Hi Experts,
How can I delete the values in a column of an Internal Table without using Loop Statement.
Thanks and Regards.
‎2008 Jan 09 11:13 AM
Hi,
You can use a statement like this
Delete ITAB where....
Regards,
Satish
‎2008 Jan 09 11:14 AM
Hi.
Check this example:
data: begin of i_data occurs 0,
field1(10),
box(1),
end of i_data,
wa_Data like i_Data.
CLEAR: wa_data.
wa_data-box = space.
MODIFY i_data FROM wa_data TRANSPORTING box WHERE box <> space.
Reward if it helps.
Regards,
George
‎2008 Jan 09 11:16 AM
That's interesting
you can try this if column is your last field.
define another internal table with same fieldnames as original except last field. (say original is itab and new one is itab1 with last field excluded)
then write
itab1[] = itab[].
I tried in sample code..
data : begin of itab occurs 0,
var1 type i,
var2 type char4,
var3 type char5,
end of itab.
data : begin of itab1 occurs 0,
var1 type i,
var2 type char4,
end of itab1.
itab-var1 = 1.
itab-var2 = 'HI'.
itab-var3 = 'HE'.
append itab.
itab-var1 = 1.
itab-var2 = 'BY'.
itab-var3 = 'HELLO'.
append itab.
itab1[] = itab[].
Regards,
Mohaiyuddin
‎2008 Jan 09 11:18 AM
I don't know why itab1 [] = itab [] is not getting displayed correctly in my response. !!
‎2008 Jan 09 11:20 AM
‎2008 Jan 09 11:18 AM
Hi,
Use MODIFY itab [FROM wa] TRANSPORTING f1 ... fn WHERE cond.
Pass WA-field = ' ' and in where cond write where field <> ' '.
Regards,
pankaj
‎2008 Jan 09 11:18 AM
Hi Shiva
we can achieve this through Read statement as :
read your internal table with key as condition
if sy-subrc = 0 .
delete
endif .
In case of any issue please revert back
Donot forgot to reward points
Shylaja
‎2008 Jan 09 11:18 AM
Hi,
The following are the ways you can delete records from an internal table.
- DELETE itab.
- DELETE TABLE itab WITH TABLE KEY k1 = v1 ... kn = vn.
- DELETE TABLE itab [FROM wa].
- DELETE itab INDEX idx.
- DELETE itab FROM idx1 TO idx2.
- DELETE itab WHERE logexp.
- DELETE ADJACENT DUPLICATES FROM itab.
Regards,
Renjith Michael.
‎2008 Jan 09 11:19 AM
data: begin of wach,
txt type STRING,
end of wach.
data: itabch like table of wach.
wach-txt ='ABC'.
append wach to itabch.
wach-txt ='CDE'.
append wach to itabch.
wach-txt ='DEF'.
append wach to itabch.
wach-txt = ''.
MODIFY itabch FROM wach TRANSPORTING txt where txt NE SPACE.
‎2008 Jan 09 11:19 AM
Hi shiva,
If you are creating a dynamic internal table than you can call LVC_FIELDCAT_MERGE and you can delete your coloumns as you want depending on your needs.
Reward is useful.
‎2008 Jan 09 11:22 AM
Hi,
You can use as below :
delete itan where column = 'some value'.
Thanks,
Sriram Ponna.
‎2008 Jan 09 11:27 AM
Hi,
if you have a common value for all the records in your internal table, then refer the below sample code.
data: begin of x_mara occurs 0,
matnr like mara-matnr,
maktx like makt-maktx,
end of x_mara.
parameters: p_matnr like mara-matnr.
select matnr
maktx from makt into table x_mara where matnr = p_matnr.
if sy-subrc = 0.
clear x_mara-maktx.
modify x_mara transporting maktx where matnr = p_matnr.
if sy-subrc = 0.
endif.
endif.
if you don't have common field, then add one flag variable in your internal table structure. follow the blow sample code.
clear itab-field1.
modify itab transporting field1 where flag = space.
Reward if useful.
Thanks,
Ashok.