I am new with ABAP
. I asked a similar, but different, question to this one yesterday.
I duplicate a table (= table
) to a local table (= localTable
) and remove all duplicates in it, this works fine (first 3 code lines)
Now I want to loop over this local table and send all matching data into an structure with INTO CORRESPONDING FIELDS OF
- unfortunately I always get the following error:
Internal tables cannot be used as work areas.
INFO: I'm working inside of a method!
Here is my code where I'm working with:
DATA localTable TYPE STANDARD TABLE OF table.
SELECT columnName FROM table INTO TABLE localTable.
DELETE ADJACENT DUPLICATES FROM localTable COMPARING columnName.
LOOP AT localTable ASSIGNING FIELD-SYMBOL(<fs_table>).
SELECT * FROM anotherTable as p
WHERE p~CN1 = @localVariable
AND p~CN2 = @<fs_table>-columnName
INTO CORRESPONDING FIELDS OF @exportStructure "<-- Here I always get my error
ENDSELECT.
ENDLOOP.
CodePudding user response:
First: I've read that I have to sort my internal table
before using command DELETE ADJACENT DUPLICATES FROM localTable COMPARING columnName.
so I've added following code line in between:
SORT localTable BY columnName ASCENDING.
Second: Instead of using INTO CORRESPONDING FIELDS OF TABLE
I've used APPENDING CORRESPONDING FIELDS OF TABLE
because INTO overwrites every line with itself, so in total I have only one line in my exported structure.
APPENDING adds a new line every time my statements are true.