Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to delete records from dynamic internal table.

Hi Experts,

Need urgent help!!!

Issue is with Dynamic internal tables.

Below is code written by me :

FORM select_query USING Lw_tabnam

TYPE t682i-kotabnr.

DATA : lw_line TYPE REF TO data,

lw_line1 TYPE REF TO data.

CREATE DATA Lw_line TYPE (lw_TABNAM).

ASSIGN Lw_line->* TO <WA_tbl>.

CREATE DATA LW_LINE TYPE STANDARD TABLE OF (Lw_tabnam)

WITH NON-UNIQUE DEFAULT KEY.

ASSIGN Lw_line->* TO <TBL>.

SELECT * FROM (Lw_tabnam)

INTO CORRESPONDING FIELDS OF TABLE <TBL>

WHERE (t_keys).

Endform.

code is working fine.

here even the table name and where condition are dynamic,everything is fine upto this point.

Now i have to delete some record from <TBL> based on some conditons.

for ex : ( here lc_fieldname is KUNNR)

loop at t_kunnr.

lw_tabix = sy-tabix.

Read table <tbl>

with key (lc_fieldname) = t_kunnr-kunnr ASSIGNING <wa_tbl>.

If sy-subrc = 0.

*Delete

delete <tbl> from <wa_tbl>

  • delete <tbl> index lw_tabix.

Endif.

Endloop.

The above delete statement doesn't work ,even we can't use index as it gives a syntax error " something related to "index is not allowed in standard table or hash table.

Can you help me ab't how to delete records in Dynamic internal table?

Other option that i am thinking of is to create a static table of type dynamic table.

means, data itab type standard table of <tbl> .I know the syntax is wrong ,however is there any way to do this?

Thanks in advance ,

If you have any suggestion ab't this then do let me know.

bye,

Gaurav.

Tags:
Former Member
Former Member replied

Hi

I wrote this code and it works fine:

DATA LW_TABNAM(10) VALUE 'LFA1'.

DATA : LW_LINES TYPE REF TO DATA,

LW_LINE TYPE REF TO DATA.

FIELD-SYMBOLS: <TABLE> TYPE TABLE,

<WA> TYPE ANY.

CREATE DATA LW_LINES TYPE TABLE OF (LW_TABNAM)

WITH NON-UNIQUE DEFAULT KEY.

ASSIGN LW_LINES->* TO <TABLE>.

CREATE DATA LW_LINE TYPE (LW_TABNAM).

ASSIGN LW_LINE->* TO <WA>.

DO 10 TIMES.

APPEND INITIAL LINE TO <TABLE>.

ENDDO.

SY-TABIX = 4.

DELETE <TABLE> INDEX SY-TABIX.

WRITE SY-SUBRC.

I hope it help you

Max

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question