cancel
Showing results for 
Search instead for 
Did you mean: 

Can't we use MOVE-CORRESPONDING ITAB TO ITAB in the function?

yalcin_mete
Participant
0 Kudos

Hi Masters,

I want to transfer the internal table in the code to the function table using move-corresponding, but this is not allowed.I made many tryings. Where am I making a mistake?


Scenario 1 : 

yalcin_mete_0-1716290725948.png

yalcin_mete_1-1716290738211.png

 

yalcin_mete_2-1716290778439.png

 

Scenario 2 :

yalcin_mete_3-1716291049194.png

yalcin_mete_4-1716291227225.png

yalcin_mete_5-1716291240080.png

 

Thanks

 

 

Accepted Solutions (1)

Accepted Solutions (1)

Sandra_Rossi
Active Contributor

You are using the obsolete TABLES word in the function module to declare ET_RESULT, so ET_RESULT alone is considered as being the obsolete header line (error prone).

Instead, use:

 

MOVE-CORRESPONDING gt_temp TO et_result[].

 

But prefer using ABAP Objects instead of function module, or prefer using EXPORTING over TABLES. 

Reference documentation:

yalcin_mete
Participant
0 Kudos

Thank you @Sandra_Rossi.

Since using the TABLE tab in the function module is an old method, we had to use [ ].
What are the ABAP objects you mentioned as the new method? Inside the function "DATA ITAB TYPE TABLE OF XXX." Are you talking about? Because when I use this method I don't have to use "[ ]".

When you said "...or prefer using EXPORTING over TABLES.", did you mean to mention the EXPORT tab in the function module you wanted to talk about?

yalcin_mete
Participant
0 Kudos
If returning the "table result" with the help of a function is an old method, how can we do this in another way? I think it is very useful 🙂
Sandra_Rossi
Active Contributor
0 Kudos
ABAP Objects is the "marketing name" of object-oriented ABAP (classes, interfaces, etc.) Create a class pool and method instead of function module. Yes, you are using TABLES in your function module, don't use it, it's obsolete, it declares an obsolete header line too.

Answers (1)

Answers (1)

ANKA
Explorer

If you using an Internal table to copy pls use like this.

It will automatically copy all the entries form one table to another.

table1[] =  table2[]

Sandra_Rossi
Active Contributor
You come a little bit late. The question was about move-corresponding, so your solution may not work. It would work only if the lines of the two internal tables have the same structure.