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

ABAP statement

Former Member
0 Likes
717

hi,

could you hepl me write a sql statement in abap.

internal table itt012 has 5 avlues.

i want to compare hkont of bseg table (BSEG_HKNOT) only starting 9 characters with starting 9 characters of internal table itt012 and delete unmatching.

my query is deleting even the matching records.

could you pls correct it.

LOOP AT itt012 INTO wa_itt012.

DELETE itbseg WHERE hkont0(9) <> wa_itt012-hkont0(9).

ENDLOOP.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
685

data : pat(10).

LOOP AT itt012 INTO wa_itt012.

concatenate wa_itt012-hkont+0(9) '%' into pat

select single * from bseg where hkont like pat.

if sy-subrc ne 0.

DELETE itbseg.

endif.

clear pat.

ENDLOOP.

regards

shiba dutta

5 REPLIES 5
Read only

former_member225631
Active Contributor
0 Likes
685

declare one (or 5) variable one pass the values of itt012 like variable = itt012+0(9).

Loop at itbseg.

if itbseg-hkont+0(9) ne variable.

delete itbseg.

endif.

endloop.

Read only

0 Likes
685

HI,

There can be 5 records in ITT012

and 100 in BSEG.

for every ITT012 i need to compare with bseg HKNOT+0(9) and delete un matching

Jeff

Read only

Former Member
0 Likes
685

Hi,

DATA : v_temp(9).

LOOP AT itt012 INTO wa_itt012.

clear v_temp.

MOVE : wa_itt012-hkont to v_temp.

DELETE itbseg WHERE hkont+0(9) NE v_temp.

ENDLOOP.

Don't forget to reward if useful...

Read only

Former Member
0 Likes
686

data : pat(10).

LOOP AT itt012 INTO wa_itt012.

concatenate wa_itt012-hkont+0(9) '%' into pat

select single * from bseg where hkont like pat.

if sy-subrc ne 0.

DELETE itbseg.

endif.

clear pat.

ENDLOOP.

regards

shiba dutta

Read only

Former Member
0 Likes
685

Hi,

Try this..



DATA: V_CHAR(9).

LOOP AT itt012 INTO wa_itt012.

V_CHAR = wa_itt012-hkont+0(9).

DELETE itbseg WHERE hkont <> V_CHAR.

ENDLOOP. 

Thanks

Naren