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
892

Hi Gurus,

I had a select option s_vbeln and an internal table.I should delete records based on this select-option.

i have done in following way...

READ TABLE T_CDHDR INTO W_CDHDR WITH KEY OBJECTID = S_VBELN.

IF SY-SUBRC NE 0.

DELETE T_CDHDR INDEX SY-TABIX.

ENDIF.

but it is not working....

in the read stmt objectid and s_vbeln are compatible..

Can anyone suggest me??

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
864

Hi,

You can do as below:


delete itab where vbeln not in S_VBELN.

Thanks,

Sriram Ponna.

10 REPLIES 10
Read only

Former Member
0 Likes
865

Hi,

You can do as below:


delete itab where vbeln not in S_VBELN.

Thanks,

Sriram Ponna.

Read only

rainer_hbenthal
Active Contributor
0 Likes
864

select options are always of type ranges. Go to the debuger and inspect your select option.

To use the select option use operator "in" instead of "=".

Read only

Former Member
0 Likes
864

do this way.

delete itab where OBJECTID in S_VBELN. "To delete whichever matched the s_vbeln

delete itab where OBJECTID not in s_vbeln."To delete whichever did not match the s_vbeln

Regards,

Ravi Kanth Talagana

Read only

0 Likes
864

can u give me clear code??

shud i use read table or not??

Read only

Former Member
0 Likes
864

Hi,

Have you checked in table via SE11, if it is expecting leading zeros for Invoice no i.e. s)vbeln.

I hope this helps

Regards

Raju Chitale

Read only

Former Member
0 Likes
864

you can use this directly...

DELETE T_CDHDR where OBJECTID not in S_VBELN.

Read only

Former Member
0 Likes
864

hi madan

i think u have to delete records from internaltable which r not in s_vbeln

u can not delete directly. do one thing first fetch the data using select option from main table into one internal table

select vbeln

from table

into i_vbeln

where vbeln in s_vbeln.

u can get the data into i_vbeln.

then process the table t_cdhdr and delete records which r not in i_vbeln.

loop at t_cdhdr into wa_cdhdr.

read table i_vbeln with vbeln= wa_cdhdr-vbeln.

if sy-subrc ne 0

delete wa_cdhdr from t_cdhdr.

endif.

endloop.

check this one

Read only

Former Member
0 Likes
864

Hello Madan-

Select-option is an internal table but in your read statement you are comparing directly with select-option this was it will not work.Ways to achieve your requirement.

1) Instead of select-option use parameter or

2) Loop the internal table with BT condition.

Cheers,

~Srini....

Read only

Former Member
0 Likes
864

Hi,

Follow this Code.

loop at itab where vbeln Between Low anh High

Delete

Endloop.

Reward if it is Helpfull,

Naresh.

Read only

Former Member
0 Likes
864

hi do like this

Data it_T_CDHDR tmp .type standart table of TCDHDR .

wa_CDHDR tmp type TCDHDR

READ TABLE T_CDHDR INTO W_CDHDR WITH KEY OBJECTID = S_VBELN.

if sy-subrc = 0

w_tabix = sy-tabix.

move T_CDHDR to wa_CDHDR tmp index wtabix

Append T_CDHDR tmp to itT_CDHDR _tmp .

endif.

refresh T_CDHDR .

T_CDHDR [] = it_T_CDHDR _tmp []

this wil giv u the desired values,

Reward points if helpful.

Ronak