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

delete statement is not working.

Former Member
0 Likes
2,807

Hi,

find the code. Here the delete statement is not working and i am getting sy-subrc = 4. although ,

xe1edp10-idnkd = 34596 and dint_edidd -sdata = 34596.

please help me ...

loop at dekek_x.

loop at dint_edidd where segnam = 'E1EDP10'.

if dekek_x-stpin = 1 .

CLEAR xe1edp10.

MOVE dint_edidd-sdata TO xe1edp10.

delete dint_edidd where sdata = xe1edp10-idnkd.

endif.

endloop.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,567

>

> MOVE dint_edidd-sdata TO xe1edp10.

> delete dint_edidd where sdata = xe1edp10-idnkd.

>

you are moving the value directly to the structure and comparing with field of structure???

this is wrong.

sdata is a char 1000 and xe1edp10-idnkd is only char 35.

how can it match these two values?

compare proper values...

8 REPLIES 8
Read only

Former Member
0 Likes
1,567

Hi,

Are you sure the inner loop or if statement provides the condition?

Read only

Former Member
0 Likes
1,568

>

> MOVE dint_edidd-sdata TO xe1edp10.

> delete dint_edidd where sdata = xe1edp10-idnkd.

>

you are moving the value directly to the structure and comparing with field of structure???

this is wrong.

sdata is a char 1000 and xe1edp10-idnkd is only char 35.

how can it match these two values?

compare proper values...

Read only

VXLozano
Active Contributor
0 Likes
1,567

Wow, what a mess... (I think "mess" is not an offensive word; if it is, please, excuse me).

Your loops are not related in any way. It means you will do the inner loop as many times as rows will have the outter one. And once you'll get the relationship between both loops, try to filter the outter one out of the inner one (move your IF stpin = 1 check to a WHERE clause in your initial LOOP).

Anyways, from the sy-subrc the system provides you (4), the DELETE is working fine. BUT there is no data to delete.

Read only

Former Member
0 Likes
1,567

And check your data types. Be careful from zeros. Are you sure there are no zeros before the idnkd and sdata => xe1edp10-idnkd = 34596 and dint_edidd -sdata = 34596.

Maybe xe1edp10-idnkd = 000034596 and dint_edidd -sdata = 34596....

Read only

Former Member
0 Likes
1,567

Hi,

thanks for reply..

but here no leading zero mismatcj=hing happening.only here in debugging mode

the int. table dint_edidd where sdata showing 315934 EA 017

i dont know why it is showing like this in debugging mode only ..where 017 = plant and ea = measuremnt field.

but when ever i am writting dint_edidd -sdata then it is giving only 315934.

please help me where is the probleam for deletion?

Thanks

Read only

0 Likes
1,567

1st thing..

i tried this :

tables: edidd, e1edp10.
edidd-sdata = '315934 EA 017'.
WRITE edidd-sdata.
move edidd-sdata to e1edp10.
IF edidd-sdata = e1edp10-idnkd.
WRITE: e1edp10-idnkd.
else.
  WRITE: 'nothing'.
ENDIF.

output

>315934 EA 017

>315934 EA 017

2nd thing,.

your loop inside loop doesnt make any sense as they are not related any where.

3rd thing:

the fields are not type compatible.. this might be the reason for wrong delete statement..

and 1 more clarification:

TABLES: edidd, e1edp10.
DATA :it TYPE TABLE OF edidd WITH HEADER LINE.
edidd-sdata = '315934 EA 017'.
WRITE edidd-sdata.
APPEND edidd TO it.
edidd-sdata = '315934 EA 018'.
APPEND edidd TO it.

LOOP AT it." where segnam = 'E1EDP10'.
  CLEAR e1edp10.
  MOVE it-sdata TO e1edp10.
  DELETE it WHERE sdata = e1edp10-idnkd.
ENDLOOP.

in this also delete is working perfectly fine... you run and check..

Read only

0 Likes
1,567

Hi asissahu12 ,

Please check ur clear statement because u r using dat with delete syntax.

Regards,

Praveen

Read only

Former Member
0 Likes
1,567

You can directly delete the record by using index of record.

Get index in second loop by using system variable sy-index.

You use delete with index option to delete the record.

Hope you get it.