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

logic needed pls help

Former Member
0 Likes
996

Hi

i need to delete the records inthe following coding. pls help me

LOOP AT ITAB_ZFIFN_OP ASSIGNING <FS_ZFIFN>.

READ TABLE ITAB_TEMKSV WITH KEY OLDKEY = <FS_ZFIFN>-OPBEL.

IF SY-SUBRC = 0.

<FS_ZFIFN>-OPBEL = ITAB_TEMKSV-NEWKEY.

else.

  • delete ?????????

ENDIF.

ENDLOOP.

useful Answers will be reward

Thanks

1 ACCEPTED SOLUTION
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
979

LOOP AT ITAB_ZFIFN_OP ASSIGNING <FS_ZFIFN>.

READ TABLE ITAB_TEMKSV WITH KEY OLDKEY = <FS_ZFIFN>-OPBEL.

IF SY-SUBRC = 0.

<FS_ZFIFN>-OPBEL = ITAB_TEMKSV-NEWKEY.

else.

delete ITAB_ZFIFN_OP. "<----


ENDIF.

ENDLOOP.

12 REPLIES 12
Read only

Former Member
0 Likes
979

What do you want to delete?

Records from which table?

Regards,

Atish

Read only

0 Likes
979

i need to delete the records from ITAB_ZFIFN_OP table

Read only

0 Likes
979

Check below code.

data l_index type i.

LOOP AT ITAB_ZFIFN_OP ASSIGNING <FS_ZFIFN>.

l_index = sy-tabix.

READ TABLE ITAB_TEMKSV WITH KEY OLDKEY = <FS_ZFIFN>-OPBEL.

IF SY-SUBRC = 0.

<FS_ZFIFN>-OPBEL = ITAB_TEMKSV-NEWKEY.

else.

DELETE ITAB_ZFIFN_OP INDEX l_index.

ENDIF.

ENDLOOP.

Regards,

Atish

Read only

0 Likes
979

Hi Atish

how ro declare l_index?

i declare as data : l_index like sy-index.

its going to dump.

Read only

0 Likes
979

Declare l_index as I shown.

DATA l_index type i.

Regards,

Atish

Read only

0 Likes
979

its mandatory to declare it.. you can do as I said in my previous post as well.

Read only

former_member156446
Active Contributor
0 Likes
979

LOOP AT ITAB_ZFIFN_OP ASSIGNING <FS_ZFIFN>.
READ TABLE ITAB_TEMKSV WITH KEY OLDKEY = <FS_ZFIFN>-OPBEL.
IF SY-SUBRC = 0.
<FS_ZFIFN>-OPBEL = ITAB_TEMKSV-NEWKEY.
else.
delete itab_zfifn index sy-index.
ENDIF.
ENDLOOP.
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
980

LOOP AT ITAB_ZFIFN_OP ASSIGNING <FS_ZFIFN>.

READ TABLE ITAB_TEMKSV WITH KEY OLDKEY = <FS_ZFIFN>-OPBEL.

IF SY-SUBRC = 0.

<FS_ZFIFN>-OPBEL = ITAB_TEMKSV-NEWKEY.

else.

delete ITAB_ZFIFN_OP. "<----


ENDIF.

ENDLOOP.

Read only

0 Likes
979

LOOP AT ITAB_ZFIFN_OP ASSIGNING <FS_ZFIFN>.

READ TABLE ITAB_TEMKSV WITH KEY OLDKEY = <FS_ZFIFN>-OPBEL.

IF SY-SUBRC = 0.

<FS_ZFIFN>-OPBEL = ITAB_TEMKSV-NEWKEY.

else.

delete ITAB_ZFIFN_OP index sy-tabix <----include this.

ENDIF.

ENDLOOP.

Read only

0 Likes
979

Hi Keshu

its working fine. Can u tell me how to output the deleted records in WRITE statement

Read only

0 Likes
979
LOOP AT ITAB_ZFIFN_OP ASSIGNING <FS_ZFIFN>.
READ TABLE ITAB_TEMKSV WITH KEY OLDKEY = <FS_ZFIFN>-OPBEL.
IF SY-SUBRC = 0.
<FS_ZFIFN>-OPBEL = ITAB_TEMKSV-NEWKEY.
else.
write:/ 'deleted:'<FS_ZFIFN>-f1,<FS_ZFIFN>-f2.... "f1,f2 will be the field you want to display.
delete itab_zfifn index sy-index.
ENDIF.
ENDLOOP.
Read only

Former Member
0 Likes
979

Hello ,

LOOP AT ITAB_ZFIFN_OP ASSIGNING <FS_ZFIFN>.

READ TABLE ITAB_TEMKSV WITH KEY OLDKEY = <FS_ZFIFN>-OPBEL.

IF SY-SUBRC = 0.

<FS_ZFIFN>-OPBEL = ITAB_TEMKSV-NEWKEY.

else.

ITAB_ZFIFN_TMP = ITAB_ZFIFN_OP .

APPEND ITAB_ZFIFN_TMP

delete ITAB_ZFIFN_OP index sy-tabix .

ENDIF.

ENDLOOP.

Deleted Records.

clear : <FS_ZFIFN>..

loop at ITAB_ZFIFN_TMP ASSIGNING <FS_ZFIFN>..

write : ITAB_ZFIFN_TMP.

endloop.

Reward points if it is usefull ..

Girish