Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

INTERNAL TABLE

Former Member
0 Likes
915

Hi Experts,

How can I delete the values in a column of an Internal Table without using Loop Statement.

Thanks and Regards.

12 REPLIES 12
Read only

Former Member
0 Likes
895

Hi,

You can use a statement like this

Delete ITAB where....

Regards,

Satish

Read only

George_Lioumis
Active Participant
0 Likes
895

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

Read only

Former Member
0 Likes
895

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

Read only

0 Likes
895

I don't know why itab1 [] = itab [] is not getting displayed correctly in my response. !!

Read only

0 Likes
895

consider it as body of internal table

itab1 [ ] = itab [ ].

Read only

Former Member
0 Likes
895

Hi,

Use MODIFY itab [FROM wa] TRANSPORTING f1 ... fn WHERE cond.

Pass WA-field = ' ' and in where cond write where field <> ' '.

Regards,

pankaj

Read only

Former Member
0 Likes
895

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

Read only

Former Member
0 Likes
895

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.

Read only

Former Member
0 Likes
895

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.

Read only

Former Member
0 Likes
895

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.

Read only

Former Member
0 Likes
895

Hi,

You can use as below :

delete itan where column = 'some value'.

Thanks,

Sriram Ponna.

Read only

Former Member
0 Likes
895

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.