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: 

Manage Field Symbols

Pier_1973
Participant
0 Kudos

Hi all,

Can you help me with Field Symbols?

I have two Field Symbols declared type any table.

I would like to remove data from first field symbol where these items aren't in the second field symbol.

For Example: The Instruction:

DELETE <fs_tb_result> WHERE ('VBELN = space').

Runs ok

Now I want to delete data from <fs_tb_result> where VBELN NE <fs2>-VBELN and POSNR NE <fs2>-POSNR.

I don't want to loop but i would like to delete records without loop.

Thank you for your HELP

12 REPLIES 12

Sandra_Rossi
Active Contributor
0 Kudos

It doesn't work?

DELETE <fs_tb_result> WHERE ('VBELN NE <fs2>-VBELN and POSNR NE <fs2>-POSNR').

fprokopiuk
Active Participant
0 Kudos

You should be able to use FILTER statemet, documentation link. You can use primary or secondary keys if needed for performance.

For example:

DATA(filtered_tab) = FILTER #( <fs_tb_result> IN <fs2> WHERE VBELN <> VBELN
AND POSNR <> POSNR ).

0 Kudos

Gives back a dump.

0 Kudos

could you post your current code ?

0 Kudos

I tried to use filter but It give me back an error:

data(gt_filtered) = FILTER #( <fs_tb_result> IN <fs_tb_vbap> WHERE vbeln <> vbeln
AND posnr <> posnr ).
It gives back: Type or field "%_ANY_TABLE" is generic. You can only use the access types "ANY TABLE" or "INDEX TABLE" with parameters. -

0 Kudos

Hi Frederic, simply:

The two Field Symbols are declared type any table:

<Fs1> contains some items and has different fields and different columns like VBELN and POSNR (this comes from a parameter where declare the name of table) P_tabname that can change.

<Fs2> contains some other items and has different fields and different columns like VBELN and POSNR (basically it has structure of VBAP)

I want to filter data from <FS1> with data of <FS2>.

When I try to write:

DATA(filtered_tab) = FILTER #( <FS1> IN <FS2> WHERE VBELN <> VBELN

AND POSNR <> POSNR ).

I got the error: Type or field "%_ANY_TABLE" is generic. You can only use the access types "ANY TABLE" or "INDEX TABLE" with parameters. -

0 Kudos

It would be perfect if I could declare internal table without using of type ref to data.

For example.

Data: tb_int type standard table of MARA

But:

Dat tb_int type standard table of (P_TABLE).

Where P_table is Parameter declared type TABNAME.

0 Kudos

How do you declare it now? From what you wrote it should be field symbol of type ANY TABLE and it should work.

Unfortunately for dynamic declarations you need to use either references or field symbols in ABAP.

Sandra_Rossi
Active Contributor
0 Kudos

ANSWER is only to propose a solution, dixit SAP text at the right of the answer area.

Please use

EITHER hyperlink Actions > Edit to add the screenshot of short dump

OR the COMMENT button for comments, asking for complements, adding details, replying to a comment or a proposed solution or to the OP question, etc.

Sandra_Rossi
Active Contributor
0 Kudos

You didn't say, but I guess the problem is that you declared <fs2> of ANY type:

FIELD-SYMBOLS <fs2> TYPE ANY.

consequently <fs>-VBELN is invalid and you get DYN_WHERE_PARSE_ERROR.

(note that your problem description is incorrect because the short dump mentions <fs_tb_vbap> instead of <fs2>)

You must use:

ASSIGN COMPONENT 'VBELN' OF STRUCTURE <fs2> TO FIELD-SYMBOL(<fs2_vbeln>).
ASSIGN COMPONENT 'POSNR' OF STRUCTURE <fs2> TO FIELD-SYMBOL(<fs2_posnr>).

DELETE <fs_tb_result> WHERE ('VBELN NE <fs2_vbeln> and POSNR NE <fs2_posnr>').

or any modern alternative which will depend on your ABAP version.

0 Kudos

Hi Sandra,

I thought to use this code but doing so I will erase all records except for the current record.

Both field symbols are type any table and I want delete items in first field symbol <fs_tb_result> that don't match with items in the second field symbol.

I try to use filter but since both field symbol are type any table maybe I cannot to it.

I'll keep you posted

Fabio

0 Kudos

Thanks for the feedback. The important point to me was to provide an answer to future visitors who will look at your exact question + possibly the short dump you have shared. Your question wasn't mentioning clearly that your DELETE was inside a loop. Sure, FILTER is one possible way to do it.