Move-Corresponding
Hi,
I'm just interested to know what people make of this article:
https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/30c02051-852d-2c10-3c91-ba2bcf404510
Malcolm.
Funny noticing, though, what Matt wrote at the end of [this thread|Re: Move and "=" Difference; (MOVE vs =), on Apr 23.
>
Matt wrote:
> Not really - it's posted about once a month. Next month, you can watch the one about MOVE-CORRESPONDING.
This was more than a month and a half ago, so I guess these threads are appearing less often than they used to..
Similar Messages
-
Move-corresponding in table type Field-Symbols
Hi,
I have to use one statement in field-symbol similar to "move-corresponding" in normal internal table.Is it possible to use statement similar to "Move-corresponding in field-symbols".
For Eg:
Field-symbols <FA_IT> type standard table.
data:begin of wa_ekk,
f1 type i,
f2 type werks_d,
f4 type posnr,
end of wa_ekk,
it_ekk like standard table of wa_ekk.
begin of wa_final,
f1 type i,
f2 type werks_d,
f3 type i,
f4 type n,
end of wa_final,
it_final like standard table of wa_final.
assign it_ekk to <fs_it>.
Loop at <fs_it>.
*???????-i dont know how to move the value to it_final
*---I know I can use assign component statement
*-to move each field to the target field
but for that we need to know the field name or index position of the structure-
Endloop.
My requirment is now i want to move the content of <fs_it> into it_final internal table.
I know that In normal itab we can use "move-corresponding" to move the value from it_ekk to it_final.
In the same way how to use it in field-symbol concept.
Requirement:Real time Processing of Internal table
1) Content of it_ekk:
f1 f2 f4
12 1000 0023
23 2000 0037
2)After ASSIGN statement:
Content of <fs_it> is:
f1 f2 f4
12 1000 0023
23 2000 0037
3)Now I want to move the content of <fs_it> to it_final
Output of It_final:
F1 F2 F3 F4
12 1000 --- 0023
23 2000 --- 0037
Regards,
Vigneswaran SAndrey's code is going to work only if you are running it in a non-unicode system.
See code below for a Unicode system using similar effect to "Move-Corresponding" statement.
FIELD-SYMBOLS: <fs_ekk> LIKE wa_ekk,
<fs_final> LIKE wa_final.
ASSIGN it_ekk TO <fs_it> .
LOOP AT <fs_it> ASSIGNING <fs_ekk>.
ASSIGN <fs_ekk> TO <fs_final> CASTING.
CLEAR <fs_final>-f3.
APPEND <fs_final> TO it_final.
ENDLOOP.
Hope this solves your problem and please don't forget to reward points.
Cheers,
Sougata. -
Change "MOVE-CORRESPONDING" statement to MOVE statement in FM
Hello Guys,
I have created a datasource based on FM standard template RSAX_BIW_GET_DATA. In the source code in this template, there is a LOOP statement and below that there is a "MOVE-CORRESPONDING" statement.
LOOP AT g_t_select INTO l_s_select WHERE fieldnm = 'PGMID'.
MOVE-CORRESPONDING l_s_select TO l_r_pgmid.
APPEND l_r_pgmid.
ENDLOOP.
My customer does not allow MOVE-CORRESPONDING statement for performance reasons. Hence I need to change it to MOVE statement. But I do not know the structure of l_s_select and I am not well at ABAP. So How do I write MOVE statement here.
Can anybody help on this?
Regards
UtpalHi Tibollo,
Thanks for your prompt reply. Your suggestion has solved my problem. One input to this from my side. It will not accept FIELDNM because it is not present in l_r_pgmid. Remind you l_r_pgmid is declard as a range and ranges does not have FIELDNM.
Anyway, that portion I have modified and it worked. Thanks a lot. I am rewarding u points.
Regards
Utpal -
Conditional MOVE-CORRESPONDING
Hi, I need to write a piece of code to move records from one internal table to another table. I got to know about the MOVE-CORRESPONDING statement in ABAP. Now my question is: if I use the following, what will the system do:
MOVE-CORRESPONDING ITAB1 TO ITAB2.
Will all the contents of ITAB1 be moved to ITAB2? I want to add a condition to it. Is that possible?
Thanks.Hi,
Syntax:
MOVE-CORRESPONDING <sourcestruct> TO <destinationstruct>.
This statement assigns the contents of the components of structure <sourcestruct> to the components of the <destinationstruct> structure that have identical names.
If you want to add a condition to, it is better using MOVE statement instead.
Regards,
Ferry Lianto -
Hi
I would like to move fields from a structure that has the following fields
data Struc1 type table1.
Fields:
BUKRS
WAERS
MENGE....
(similarly another 50 such fields)
into another structure that has following fields,
data Struc2 type table2.
Fields:
ZZ_WAERS
ZZ_MENGE
ZZ_BUKRS
The data elements linked to the fields in both the structures would be the same. Move-Corresponding will not work as the field names do not match... also the order of the fields in both the structures do not match
What is the easiest way to do this task other than moving each field one at a time?
Can I apply any field symbols concept here... please let me knowHi Grame,
if you want to create a generic solution, you can use RTTI Runtime Type Information to determine the datatype of the components in both structures. Then you could create assignments for equal types in source and target structure.
This could work as long as you do not have more than one component of the same data type (data element) in the structures.
Something like
FIELD-SYMBOLS:
<data1> TYPE ANY,
<data2> TYPE ANY.
DATA:
lo_typedescr1 TYPE REF TO cl_abap_typedescr,
lo_typedescr2 TYPE REF TO cl_abap_typedescr.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE itab1 TO <data1>.
IF sy-subrc NE 0.
EXIT.
ELSE.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE itab2 TO <data2>.
IF sy-subrc NE 0.
EXIT.
ELSE.
lo_typedescr1 = cl_abap_typedescr=>describe_by_data( <data1> ).
lo_typedescr2 = cl_abap_typedescr=>describe_by_data( <data2> ).
IF lo_typedescr1 = lo_typedescr2.
<data2> = <data1>.
ENDIF.
ENDDO.
ENDIF.
ENDDO.
I have some doubts about performance if you do this for every table line. It will be better to do it once, keep the results in some kind of internal assignment table and use it in the loop. For this I don't write the code, thats your homework
Regards,.
Clemens -
Problem with move-corresponding
Hi,
I have these codes below:
TYPES: BEGIN OF t_employee1,
carrid LIKE spfli-carrid,
connid LIKE spfli-connid,
countryfr LIKE spfli-countryfr,
END OF t_employee1.
DATA: i_employee TYPE STANDARD TABLE OF spfli WITH HEADER LINE,
i_employee1 TYPE STANDARD TABLE OF t_employee1 WITH HEADER LINE.
SELECTION-SCREEN BEGIN OF BLOCK b1.
SELECT-OPTIONS: s_carrid FOR spfli-carrid.
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
SELECT * FROM spfli INTO TABLE i_employee
WHERE carrid IN s_carrid.
MOVE-CORRESPONDING i_employee TO i_employee1.
But when i debug the program, carrid, connid and countryfr of i_employee do not move to i_employee1...
is there somethig wrong with my codes???
Thanks a lot!Change ur code as shown below:
TYPES: BEGIN OF t_employee1,
carrid LIKE spfli-carrid,
connid LIKE spfli-connid,
countryfr LIKE spfli-countryfr,
END OF t_employee1.
DATA: i_employee TYPE STANDARD TABLE OF spfli WITH HEADER LINE,
i_employee1 TYPE STANDARD TABLE OF t_employee1 WITH HEADER LINE.
SELECTION-SCREEN BEGIN OF BLOCK b1.
SELECT-OPTIONS: s_carrid FOR spfli-carrid.
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
SELECT * FROM spfli INTO TABLE i_employee
WHERE carrid IN s_carrid.
if sy-subrc = 0.
loop at i_employee.
MOVE-CORRESPONDING i_employee TO i_employee1.
append i_employee1.
endloop. -
Statement not accesible : "MOVE-CORRESPONDING ebkn TO *ebkn."
hi guys,
(system upgraded from 4.6 to 6.0 and made unicode compatible)
thr r two problems........
1. "MOVE-CORRESPONDING ebkn TO *ebkn." is not accessible, is it something related to mirror image......... how to resolve this.
2. Refresh it_tab - "Refresh and clear statements are not accesible" .
These are present inside includes..... ( is it somewhere related to use of subroutines prior to the use of refresh or clear statement......)
Those tables are defined prior to the statement Refresh or Clear.......Hi Mohd,
please paste error message(s) in detail:
source name(s)
source line(1)
full error message including message class, type and number
If you get W messages (warnings), you may ignore them.
Regards,
Clemens -
hi
Can anyone give me the syntax of move corresponding.
I even want to know wat does this exactly do.
Can I have some sample sof move corresponding.
Its urgent.U'll get points.
Thanking you
Chandrika.hi,
MOVE-CORRESPONDING
Basic form
MOVE-CORRESPONDING struc1 TO struc2.
Effect
Interprets struc1 and struc2 as structures. If, for example, struc1 and struc2 are tables, it executes the statement for their header lines.
Searches for the sub-fields which occur both in struc1 and struc2 and then generates, for all relevant field pairs which correspond to the sub-fields ni, statements of the form
MOVE struc1-ni TO struc2-ni.
The other fields remain unchanged.
With complex structures, the full names of the corresponding field pairs must be identical.
Example
DATA: BEGIN OF INT_TABLE OCCURS 10,
WORD(10),
NUMBER TYPE I,
INDEX LIKE SY-INDEX,
END OF INT_TABLE,
BEGIN OF RECORD,
NAME(10) VALUE 'not WORD',
NUMBER TYPE I,
INDEX(20),
END OF RECORD.
MOVE-CORRESPONDING INT_TABLE TO RECORD.
This MOVE-CORRESPONDING statement is equivalent to both the following statements:
MOVE INT_TABLE-NUMBER TO RECORD-NUMBER.
MOVE INT_TABLE-INDEX TO RECORD-INDEX.
Example
TYPES: BEGIN OF ROW1_3,
CO1 TYPE I,
CO2 TYPE I,
CO3 TYPE I,
END OF ROW1_3.
TYPES: BEGIN OF ROW2_4,
CO2 TYPE I,
CO3 TYPE I,
CO4 TYPE I,
END OF ROW2_4.
TYPES: BEGIN OF MATRIX1,
R1 TYPE ROW1_3,
R2 TYPE ROW1_3,
R3 TYPE ROW1_3,
END OF MATRIX1.
TYPES: BEGIN OF MATRIX2,
R2 TYPE ROW2_4,
R3 TYPE ROW2_4,
R4 TYPE ROW2_4,
END OF MATRIX2.
DATA: ROW TYPE ROW1_3,
M1 TYPE MATRIX1,
M2 TYPE MATRIX2.
ROW-CO1 = 1. ROW-CO2 = 2. ROW-CO3 = 3.
MOVE: ROW TO M1-R1, ROW TO M1-R2, ROW TO M1-R3.
MOVE-CORRESPONDING M1 TO M2.
The last MOVE-CORRESPONDING statement is equivalent to the statements:
MOVE: M1-R2-CO2 TO M2-R2-CO2,
M1-R2-CO3 TO M2-R2-CO3,
M1-R3-CO2 TO M2-R3-CO2,
M1-R3-CO3 TO M2-R3-CO3.
Note
The same runtime errors may occur as with MOVE.
Note
This statement assigns values based on pairs of fields with identical names. To avoid unwanted assignments, you should consider all fields of the source and target structures. If either is defined with reference to an ABAP Dictionary type (for example, a database table), remember that any subsequent extension to the type could cause coincidental pairs of identically-named fields, which could lead to incorrect program logic.
Regards,
Sourabh -
4.6: Move-Corresponding vs Untyped Fuba Param
In release 4.6 Move-Corresponding is not able to work with untype argument. If e.g. a structure was passed as argument to a Fuba and the formal parameter is typed with any move-corresponding cant be used.
For such a case one may use the form in the sample below.
Regards
KlausREPORT ZMOVESMP .
start-of-Selection.
perform sub_Main.
type-pools:
Abap.
*============
form sub_Main.
*============
* data decl
data:
wa_Source type Tadir,
begin of wa_Target,
Pgmid type Tadir-Pgmid,
Obj_Name type syChar10,
Author type syUname,
GibsNet type syTitle,
end of wa_Target.
* fill sample data
select single * from Tadir into wa_Source
where
Pgmid = 'R3TR' and
Object = 'PROG' and
Obj_Name = sy-Repid.
* do the move
perform sub_Move_Corresponding
using wa_Source
changing wa_Target.
* sample output
write: / wa_Target.
endform.
*==========================
form sub_Move_Corresponding
*==========================
using
p_Src type any
changing
p_Dst type any.
* data decl
data:
wa_Comp type abap_compdescr,
cref_Rtti_Dst type ref to cl_Abap_StructDescr.
field-symbols:
<src_Comp> type any,
<dst_Comp> type any.
* get rtti handle of target
cref_Rtti_Dst ?= Cl_Abap_TypeDescr=>Describe_By_Data( p_Dst ).
loop at cref_Rtti_Dst->Components into wa_Comp.
assign component wa_Comp-Name of structure p_Src to <src_Comp>.
if ( 0 ne sy-SubRc ).
continue.
endif.
assign component wa_Comp-Name of structure p_Dst to <dst_Comp>.
<dst_Comp> = <src_Comp>.
endloop.
endform. -
Weird situation with MOVE-CORRESPONDING in standard SAP include!!
Hello Experts,
We have a standard_SAP_field_1 (attached to a standard_SAP_data_element_1) in standard_SAP_structure_1, but unfortunately its NOT there in KOMP structure!! Hence I added this standard_SAP_field_1 with in customer name space as 'ZZ_standard_SAP_field_1' by attaching the same standard_SAP_data_element_1.
The standard_SAP_data_element_1 attributes are as CHAR, 2.
Now, in one of the standard SAP include of VA42.....we have a statement as below,
MOVE-CORRESPONDING standard_SAP_structure_1 TO komp.
Then the value (say, AA) should transfer from standard_SAP_field_1 of standard_SAP_structure_1 to ZZ_standard_SAP_field_1 of KOMP, right? but, its not happening!! pls. let me know the reason and how to fix it?Okay...
Field one is called: FIELD1
Your own created field two is called ZZ_FIELD1.
And now... MOVE-CORRESPONDING. Do a F1 on that and tell me: do the two fieldnames correspond? -
Move Corresponding in AMDP Procedures
Hi,
Since Move Corresponding from internal table 1 to internal table 2 is not available in HANA SQL in AMDP, I can achieve the same using Selecting the respecting columns from the internal table 1 into internal table 2. Is there any other way through which we can achieve this?
Regards,
RameshHi Ramesh,
as alternative you could use the calculation engine function CE_PROJECTION to reach the same result. But I would not recommend to use the CE function because of the latest statement regarding the usage of CE functions in blog New SQLScript Features in SAP HANA 1.0 SPS9 (last paragraph). There it is (now!) recommended to use pure SQL instead of CE functions.
Best regards,
Florian -
Queyr about move-corresponding
Hi guys,
is move-corresponding capable of moving all entries of internal table w/o headerline to another internal table?
or is it only capable of moving one entry?
thanks a lot!Hi,
To move values between the components of structures, use the statement :
MOVE-CORRESPONDING <struct1> TO <struct2>.
This statement moves the contents of the components of structure <struct1> to the components of <struct2> that have identical names. The other fields remain unchanged.
When it is executed, it is broken down into a set of MOVE statements, one for each pair of fields with identical names, as follows:
MOVE STRUCT1-<ci> TO STRUCT2-<ci>.
Any necessary type conversions occur at this level. This process is different to that used when you assign a whole structure using the MOVE statement, where the conversion rules for structures apply.
Example :
DATA: BEGIN OF ADDRESS,
FIRSTNAME(20) VALUE 'Fred',
SURNAME(20) VALUE 'Flintstone',
INITIALS(4) VALUE 'FF',
STREET(20) VALUE 'Cave Avenue,
NUMBER TYPE I VALUE '11'.
POSTCODE TYPE N VALUE '98765'.
CITY(20) VALUE 'Bedrock',
END OF ADDRESS.
DATA: BEGIN OF NAME,
SURNAME(20),
FIRSTNAME(20),
INITIALS(4),
TITLE(10) VALUE 'Mister',
END OF NAME.
MOVE-CORRESPONDING ADDRESS TO NAME.
Yes all the values are moved to the corresponding fields.
Hope this will help you.
Plz reward if useful.
Thanks,
Dhanashri. -
QM15 - MOVE-CORRESPONDING is not working
Hi,
I am executing a standard transaction QM15, in which workcenter (ARBPL) is not getting populated in the list output display.
When I debugged the transaction, i found that there is a statement for moving ARBPL to the output table.
MOVE-CORRESPONDING RQMQMEL TO OBJECT_TAB.
After pressing F5 at this point, OBJECT_TAB remains the same.. its not getting appended with new value from RQMQMEL. Please help me out in understanding this. The Structure of RQMQMEL is same as OBJECT_TAB.
Thanks,
DhanaLakshmi M SModify internal table has been written somewhere else in the program, depending on QMFE table. ARBPL was updated only in QMEL table.
-
hello abap gurus,
in my requirement,
all the records in ITAB1 need to be moved to ITAB2 where
both have a common key field which should match.
Note: ITAB1 and ITAB2 have only few common fields. ITAB2 is completely empty.
can someone tell the best way of coding this.
thank you.check out this example.would be helpfull
DATA: BEGIN OF INT_TABLE OCCURS 10,
WORD(10),
NUMBER TYPE I,
INDEX LIKE SY-INDEX,
END OF INT_TABLE,
BEGIN OF RECORD,
NAME(10) VALUE 'not WORD',
NUMBER TYPE I,
INDEX(20),
END OF RECORD.
MOVE-CORRESPONDING INT_TABLE TO RECORD.
This MOVE-CORRESPONDING statement is equivalent to both the following statements:
MOVE INT_TABLE-NUMBER TO RECORD-NUMBER.
MOVE INT_TABLE-INDEX TO RECORD-INDEX. -
frends please provide me the detail document and scenarios where we use with examples about move and move corresponding statements?
Hi,
Please check this.
Assigning Values with MOVE:
To assign the value of a data object source to a variable destination, use the following statement:
MOVE source TO destination.
or the equivalent statement
destination = source.
The content of source remains unchanged, source does not therefore have to be a variable - it can also be a literal, a text symbol, or a constant. You must always specify decimal points with a period (.), regardless of the users personal settings.
Multiple assignments
f4 = f3 = f2 = f1.
are also possible. ABAP processes them from right to left as follows:
MOVE f1 TO f2.
MOVE f2 TO f3.
MOVE f3 TO f4.
Assigning Values Between Components of Structures (MOVE-CORRESPONDING):
The rules for value assignments between data objects also apply to structures. With the command
DATA: struct1 TYPE structure,
struct2 TYPE structure.
struct1 = struct2.
two structures of the same type can be assigned to one another without difficulty. Here, the entire source structure is seen as a unit and copied to the source structure. It is then possible to access the components individually again. If the structures in question are not compatible, see the conversion rules for structures.
In practice, however, you will often only need to assign certain components of a structure to be certain components of another structure. ABAP has a special statement for this purpose:
MOVE-CORRESPONDING sourcestruct TO destinationstruct.
This statement assigns the contents of the components of structure sourcestruct to the components of the destinationstruct structure that have identical names.
When it is executed, it is broken down into a set of MOVEstatements, one for each pair of fields with identical names, as follows:
MOVE sourcestruct-comp1 TO destinationstruct-comp1.
MOVE sourcestruct-comp2 TO destinationstruct-comp2.
Regards,
Ferry Lianto -
which is preferrable between move and move-corresponding based on performance issues?
the general performance recommendation is the following:
Never use move-corresponding with buffered tables, the overhead can be similar as the buffered access itself.
For database selects, the select itself is more expensive than the move corresponding. The decision come from the decision whether you want to use a fieldlist or a SELECT *. Fieldlists are recommended for very width tables, if the fieldlist reduces the width by a factor 2. Fieldlist must be used if your INTO structure is different from the table structure. In these 2 cases, you should use MOVE-CORRESPONDING.
Siegfried
Maybe you are looking for
-
How do I get the Bridge to work on my 9300?
I have been trying since April 2011 to get the BlackBerry Bridge to work on my Curve 9300. I'm using OS 6. I've spent hours and days on the phone with bewildered but friendly phone support agents. It's been working twice after a security wipe and
-
Burning Movies & Music & Music Video's The iMac is Making Noise?
Today I Wanted to Burn Movies & Music Video's & Music to a Blank DVD & it was from iTunes i bought & Downloaded & when i Burned Them it was Making a lot of Noise while i was Burning them, Why is that? it is My 2nd Time Burning Something, last time I
-
I can't seem to download music from sites that offer free downloads. I used to download for free with my previous torch 9800 but i can't anymore with the Z10. I used sites like Waptrick.com and toxicwap.com Please help
-
Dear experts, can you please guide me how to apply scaling on value axis in WAD. Requirement is we need to have 0, 20000, 40000, 60000 ..... on Y-axis (value axis) in WAD. Thanking you in advance. Regards, Ravi Kumar VR Garre
-
Using iDVD themes in Motion?
Has anyone ever figured out a way to make use of iDVD themes in Motion? There are several that would make nice elements for other projects.