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
606

Hi

I have appended 5 lines data in an internal table.

Now while appending 6th line, i want to do a validation.

If it fails, i have to delete those 5 lines.

How to do this..???

Can anyone give me the syntax..??

1 ACCEPTED SOLUTION
Read only

uwe_schieferstein
Active Contributor
0 Likes
577

Hello Pavan

Why don't you add a "marker" field to your internal itab?

All the itab entries that you possibly want to delete after a certain validation failed have field MARK = 'X'.

As soon as your validating entry is coming you add coding like this:

IF ( <validation> = 'X' ).  " 'X' = is valid, keep entries
  CLEAR: gs_entry-mark.
  MODIFY itab FROM gs_entry
    TRANSPORTING mark
    WHERE ( mark IS NOT INITIAL ).
ELSE.
  DELETE itab where ( mark = 'X' ).
ENDIF.

This solution is somewhat more flexible because you do not have to count lines and store indexes. Perhaps your validation is based on a certain combination of field values in an entry. Then this solution would be more suitable.

Regards

Uwe

7 REPLIES 7
Read only

Former Member
0 Likes
577

Before the append statement

IF a = b.

APPEND 6TH LINE.

ELSE.

DELETE ITAB.

ENDIF.

Regards,

Ravi

Note : Please mark all the helpful answers

Read only

0 Likes
577

One correction.




IF a = b.
APPEND 6TH LINE.
ELSE. 
<b>refresh</b> ITAB.
ENDIF.


Regards,

Rich Heilman

Read only

0 Likes
577

There is nothing wrong in using DELETE as well.

Regards,

Ravi

Read only

0 Likes
577

Friends,

I have 10 lines in internal Table.

Now at 11th line, i will carry out One validation.

If it fails, i have to delete 6th line onwards...

How to do it..???

Read only

0 Likes
577

You need to have condition for deletion. Else you will have to loop and delete.

LOOP AT ITAB.

IF SY-TABIX > 6.

DELETE ITAB.

ENDIF.

ENDLOOP.

Regards,

Ravi

Read only

Former Member
0 Likes
577

Hi,

data : l_flag type c.

Loop at itab into wa_tab.

if sy-tabix = 11.

  • Do the validation here

l_flag = `X`.

exit.

endif.

Endloop.

if l_flag = `X`.

delete itab from 6 to 11.

endif.

Best regards,

Prashant

Read only

uwe_schieferstein
Active Contributor
0 Likes
578

Hello Pavan

Why don't you add a "marker" field to your internal itab?

All the itab entries that you possibly want to delete after a certain validation failed have field MARK = 'X'.

As soon as your validating entry is coming you add coding like this:

IF ( <validation> = 'X' ).  " 'X' = is valid, keep entries
  CLEAR: gs_entry-mark.
  MODIFY itab FROM gs_entry
    TRANSPORTING mark
    WHERE ( mark IS NOT INITIAL ).
ELSE.
  DELETE itab where ( mark = 'X' ).
ENDIF.

This solution is somewhat more flexible because you do not have to count lines and store indexes. Perhaps your validation is based on a certain combination of field values in an entry. Then this solution would be more suitable.

Regards

Uwe