Application Development 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: 

Table illegal statement

tanju_lise3
Participant
0 Kudos

Hello,

This is my BADI code.

 

METHOD /saptr/if_ex_vat_b~modify_forms.

break tlise.

DATA : p_itabbad TYPE /saptr/ty_vatbbad,

ls_itabbad TYPE /saptr/vatbbad.

DATA : wa_bseg TYPE bseg.

 

 

p_itabbad[] = itabbad[].

LOOP AT p_itabbad INTO ls_itabbad .

IF ls_itabbad-lifnr+0(2) = '45'.

SELECT SINGLE * FROM bseg INTO wa_bseg WHERE belnr EQ ls_itabbad-belnr

AND bschl EQ '25'

AND gjahr EQ ls_itabbad-budat+0(4).

IF sy-subrc EQ 0.

DELETE itabbad.

ENDIF.

ENDIF.

ENDLOOP.

itabbad[] = p_itabbad[].

 

ENDMETHOD.

When this code is running, I am receiving Table illegal statement error.

Because, it does not like 

DELETE itabbad.

But I want to delete wrong record. So I used this code.

If you say, this code is wrong, how can I change the code ?

Best Regards

Tanju

1 ACCEPTED SOLUTION

amy_king
Active Contributor
0 Kudos

Hi Tanju,

LOOP AT p_itabbad INTO ls_itabbad.

        ...

        DELETE p_tabbad. " deletes current loop index

ENDLOOP.

Read through the DELETE itab - itab_line keyword documentation for more information.

Cheers,

Amy

3 REPLIES 3

Former Member
0 Kudos

Use "DELETE TABLE ls_ittabbad."

amy_king
Active Contributor
0 Kudos

Hi Tanju,

LOOP AT p_itabbad INTO ls_itabbad.

        ...

        DELETE p_tabbad. " deletes current loop index

ENDLOOP.

Read through the DELETE itab - itab_line keyword documentation for more information.

Cheers,

Amy

0 Kudos

Dear Amy and Patsy,

Thank You ver much for your answers.

I am really appreciated.

Best Regards

Tanju