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

Deletion from internal table

Former Member
0 Likes
660

Hi,

My requirement is that I have to delete the duplicate values before doing any manupilation of data.. so for this I have written the code...

*Deleting all the duplicate entries comparing group code, GL *& GL Suffix

IT_INPUT_TEMP[] = IT_INPUT[].

SORT IT_INPUT_TEMP BY GRCODE GL GLSUF.

DELETE ADJACENT DUPLICATES

FROM IT_INPUT_TEMP COMPARING GRCODE GL GLSUF.

Now with the remaining values in the internal table I have to check the 3rd field i.e. GLSUF & if it = '00000' (5 zeros)... i have to delete those entries...

For this I have written...

  • Deleting enteries where the GL Suffix is zero.

IF IT_INPUT_TEMP-GLSUF = 00000.

DELETE IT_INPUT_TEMP.

ENDIF.

It gives me a dump saying "Invalid_Table_Index"...

Prior to this I have also checked up by using Index function.

  • Deleting enteries where the GL Suffix is zero.

IF IT_INPUT_TEMP-GLSUF = 00000.

DELETE IT_INPUT_TEMP index l_tabix.

ENDIF.

Can anyone tell me where I am wrong??..

Thank You & Regards,

-S.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
611

Hi S,

Your code extract


* Deleting enteries where the GL Suffix is zero.
IF IT_INPUT_TEMP-GLSUF = 00000. 
  DELETE IT_INPUT_TEMP. 
ENDIF.

Either this should be in a loop(which is unnecessary if all you are trying to achieve is deleting records), or you can try the option with 'WHERE' clause as mentioned in the above post.

DELETE FROM IT_INPUT_TEMP WHERE GLSUF = '00000'.

Regards,

Srinivas

Hi,

My requirement is that I have to delete the duplicate values before doing any manupilation of data.. so for this I have written the code...

*Deleting all the duplicate entries comparing group code, GL *& GL Suffix

IT_INPUT_TEMP[] = IT_INPUT[].

SORT IT_INPUT_TEMP BY GRCODE GL GLSUF.

DELETE ADJACENT DUPLICATES

FROM IT_INPUT_TEMP COMPARING GRCODE GL GLSUF.

Now with the remaining values in the internal table I have to check the 3rd field i.e. GLSUF & if it = '00000' (5 zeros)... i have to delete those entries...

For this I have written...

  • Deleting enteries where the GL Suffix is zero.

IF IT_INPUT_TEMP-GLSUF = 00000.

DELETE IT_INPUT_TEMP.

ENDIF.

It gives me a dump saying "Invalid_Table_Index"...

Prior to this I have also checked up by using Index function.

  • Deleting enteries where the GL Suffix is zero.

IF IT_INPUT_TEMP-GLSUF = 00000.

DELETE IT_INPUT_TEMP index l_tabix.

ENDIF.

Can anyone tell me where I am wrong??..

Thank You & Regards,

-S.

3 REPLIES 3
Read only

Former Member
0 Likes
611

Hello SAP,

you have two possibilities here. Either you use a delete command from all the entries that meet the criteria (e.g. Delete from itab where field = 00000) or you have to make sure your index field has a value (it might be initial)

Please let me know if this helps you.

Read only

Former Member
0 Likes
612

Hi S,

Your code extract


* Deleting enteries where the GL Suffix is zero.
IF IT_INPUT_TEMP-GLSUF = 00000. 
  DELETE IT_INPUT_TEMP. 
ENDIF.

Either this should be in a loop(which is unnecessary if all you are trying to achieve is deleting records), or you can try the option with 'WHERE' clause as mentioned in the above post.

DELETE FROM IT_INPUT_TEMP WHERE GLSUF = '00000'.

Regards,

Srinivas

Read only

Former Member
0 Likes
611

Hi,

The deletion is happeninn correctly now... I deleted the previous code & wrote..

DELETE IT_INPUT_TEMP WHERE GLSUF = 00000.

It's working fine now ... I hope it works the same way in production server...

Thank You,

-S.