10-16-2023 5:32 PM
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
10-16-2023 5:51 PM
It doesn't work?
DELETE <fs_tb_result> WHERE ('VBELN NE <fs2>-VBELN and POSNR NE <fs2>-POSNR').
10-16-2023 7:16 PM
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 ).
10-16-2023 7:17 PM
10-17-2023 7:23 AM
10-17-2023 8:20 AM
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 <> vbeln10-17-2023 9:05 AM
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. -
10-17-2023 12:51 PM
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.
10-17-2023 2:20 PM
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.
10-16-2023 7:21 PM
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.
10-16-2023 7:26 PM
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.
10-17-2023 7:53 AM
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
10-17-2023 1:48 PM
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.