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

How to delete data from dynamic internal table

Former Member
0 Likes
10,949

Hi,

I have dynamic internal table and I have some slection screen fields , using these selection screen fields

(select -options), I have to filter the data? assigning will work with READ , but I have select options not the parametre,

and also delete will not work for dynamic table..

as we cannot use assigning with delete..

So how to do this?

and one more thing is , I cannot filter the data while selection( in select, I cannot filter the data-> as it's not coming directly from table, it's coming from buffer),

so now after selection of data, I need to filter the data from dynamic table.

Is there any way to do this?

Regards,

Mrunal

Hi,

I have dynamic internal table and I have some slection screen fields , using these selection screen fields

(select -options), I have to filter the data? assigning will work with READ , but I have select options not the parametre,

and also delete will not work for dynamic table..

as we cannot use assigning with delete..

So how to do this?

and one more thing is , I cannot filter the data while selection( in select, I cannot filter the data-> as it's not coming directly from table, it's coming from buffer),

so now after selection of data, I need to filter the data from dynamic table.

Is there any way to do this?

Regards,

Mrunal

9 REPLIES 9
Read only

Former Member
0 Likes
4,724

HI,

DELETE <fs_table_jgm> INDEX g_index.

Refer to this link..

Edited by: Avinash Kodarapu on Mar 11, 2009 12:36 PM

Read only

0 Likes
4,724

Hi Avinash,

Thanks for the info.

But say , I have data in table <lt_data>, and now I have to delete the data according to my selection screen fields, say I have so_vbeln and so_erdat as select options,

and I have to filter the data from <lt_data> for so_vbeln and so_erdat.

then How to do that?

below statement won't work for dynamic internal table.

delete <lt_data> where vbeln not in so_vbeln and erdat not in so_erdat.

then How we will use delete for dynamic table? please guide.

Regards,

Mrunal

Read only

matt
Active Contributor
0 Likes
4,724
LOOP AT <lt_data> ASSIGNING <ls_data>.
  ASSIGN COMPONENT 'VBELN' OF STRUCTURE <ls_data> TO <l_vbeln>.
  IF <l_vbeln> NOT IN so_vbeln.
    DELETE <lt_data>.
  ENDIF.
ENDLOOP.

matt

Read only

0 Likes
4,724

>

> say I have so_vbeln and so_erdat as select options,

> and I have to filter the data from <lt_data> for so_vbeln and so_erdat.

> then How to do that?

>

Perhaps you can do this when selecting data from the database itself.


Select * from vbak into table gt_vbak where vbeln in so_vbeln and erdat in so_erdat.

regards,

Advait

Edited by: Advait Gode on Mar 11, 2009 10:54 AM

Read only

0 Likes
4,724

Hi,

Use

LOOP AT <it_data> INTO ls_data WHERE (Give you condition here).

DELETE <it_data> index sy-tabix. "This will delete the record that matches the condition

ENDLOOP.

Regards,

Sesh

Read only

matt
Active Contributor
0 Likes
4,724

>

> >

> > say I have so_vbeln and so_erdat as select options,

> > and I have to filter the data from <lt_data> for so_vbeln and so_erdat.

> > then How to do that?

> >

>

> Perhaps you can do this when selecting data from the database itself.

>

> Edited by: Advait Gode on Mar 11, 2009 10:54 AM

The original poster said:

and one more thing is , I cannot filter the data while selection( in select, I cannot filter the data-> as it's not coming directly from table, it's coming from buffer),

matt

Read only

0 Likes
4,724

Hi matt,

I tried with below code as you said. But I am getting dump. can you help?

here is my piece of code.

FIELD-SYMBOLS: <LS_DATA> type any,

<LT_DATA> TYPE table,

<L_FIELD> type any.

ASSIGN <l_buffer_entry>-dataptr->* TO <LS_DATA>.

ASSIGN <l_buffer_entry>-dataptr->* TO <LT_DATA>.

LOOP AT <LT_DATA> ASSIGNING <LS_DATA>.

ASSIGN COMPONENT 'BUKRS' OF STRUCTURE <LS_DATA> TO <L_FIELD>.

IF <L_FIELD> NOT IN SO_BUKRS.

DELETE <LT_DATA>.

ENDIF.

UNASSIGN <L_FIELD>.

ASSIGN COMPONENT 'BELNR' OF STRUCTURE <LS_DATA> TO <L_FIELD>.

IF <L_FIELD> NOT IN SO_BELNR.

DELETE <LT_DATA>.

ENDIF.

UNASSIGN <L_FIELD>.

ENDLOOP.

and here is the description of my dump:->>>

You attempted to access an unassigned field symbol

(data segment 32772).

This error may occur for any of the following reasons:

- You address a typed field symbol before it is set using ASSIGN

- You address a field symbol that points to a line in an internal table

that has been deleted

- You address a field symbol that had previously been reset using

UNASSIGN, or that pointed to a local field that no longer exists

- You address a global function interface parameter, even

though the relevant function module is not active,

that is it is not in the list of active calls. You can get the list

of active calls from the this short dump.

Read only

0 Likes
4,724

Hello Mrunal

It looks like that your dynamic itab does not contain either of the fields BUKRS or BELNR.

In order to avoid dumps due to unassigned field-symbols add the following checks:


LOOP AT <LT_DATA> ASSIGNING <LS_DATA>.
  ASSIGN COMPONENT 'BUKRS' OF STRUCTURE <LS_DATA> TO <L_FIELD>.

  IF ( <l_field> IS ASSIGNED ).
  IF <L_FIELD> NOT IN SO_BUKRS.
    DELETE <LT_DATA>.
  ENDIF.
  ENDIF.
  UNASSIGN <L_FIELD>.

  ASSIGN COMPONENT 'BELNR' OF STRUCTURE <LS_DATA> TO <L_FIELD>.
  IF ( <l_field> IS ASSIGNED ).
  IF <L_FIELD> NOT IN SO_BELNR.
    DELETE <LT_DATA>. 
  ENDIF.
  ENDIF.
  UNASSIGN <L_FIELD>.
ENDLOOP.

However, if neither BUKRS nor BELNR is within your data record (ASSIGN failed) then you probably should delete this record because it has no meaning for you.

Regards

Uwe

Regards

Uwe

Read only

Former Member
0 Likes
4,724

closed