‎2006 Aug 19 3:53 AM
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..??
‎2006 Aug 20 3:52 PM
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
‎2006 Aug 19 4:03 AM
Before the append statement
IF a = b.
APPEND 6TH LINE.
ELSE.
DELETE ITAB.
ENDIF.
Regards,
Ravi
Note : Please mark all the helpful answers
‎2006 Aug 19 4:05 AM
‎2006 Aug 19 4:06 AM
‎2006 Aug 19 4:11 AM
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..???
‎2006 Aug 19 4:16 AM
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
‎2006 Aug 19 5:44 AM
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
‎2006 Aug 20 3:52 PM
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