‎2013 Mar 05 7:33 AM
Hi expert,
I have one workarea called ls_college contains field guid, collegename, city,state, university.
It contains value of guid and college,i have another workarea called ls_modify having same fields but it contains only the value of city.
so i want to fill this value to ls_college workarea.
In this scenario ls_modify can hold any value of the field its dynamic,so i want to transfer these values to ls_college workarea.
but one more thing is, i have one variable which hold the field name which i want to transfer it to ls_college.
Thank you in advance..
‎2013 Mar 05 9:06 AM
Hi Nikhil,
if the structures are typed you can do it like this:
ls_college-CITY = ls_modify-CITY.
If you can guarantee that no other fields of ls_collge could be overwritten you can also do a
move-corresponding ls_modify to ls_college.
If you want to move only the value of the component(fieldname) which is stored in your other variable do it like this.
FIELD-SYMBOLS: <field> type any,
<field2> type any.
ASSIGN COMPONENT field_name OF STRUCTURE LS_COLLEGE TO <field>.
IF SY-SUBRC = 0.
ASSIGN COMPONENT field_name OF STRUCTURE LS_MODIFY TO <field2>.
IF SY-SUBRC = 0.
<field> = <field2>.
ENDIF.
ENDIF.
Regards Jonas
‎2013 Mar 05 8:53 AM
Hi Nikhil,
Since both are workareas you can directly assign as workareas will carry only one entry.
Hence ls_college-city = ls_modify-city.
You can do the same to pass the variable value also.
ls_college-(fieldname to which the value should be passed) = variable.
Hope this helps!
‎2013 Mar 05 8:55 AM
Hi Nikhil,
if i understand you scenario properly you have two workareas
ls_college
ls_modify
depending on the field name in your variable you want to transfer the relevant value from ls_modify to ls_college.
CASE var.
WHEN 'GUID'.
ls_college-guid = ls_modify-guid.
WHEN 'COLLEGENAME'.
ls_college-collegename = ls_modify-collegename.
WHEN 'CITY'.
ls_college-city = ls_modify-city.
WHEN 'STATE'.
ls_college-state = ls_modify-state.
WHEN 'UNIVERSITY'.
ls_college-university = ls_modify-university.
WHEN OTHERS.
ENDCASE.
‎2013 Mar 05 9:06 AM
Hi Nikhil,
if the structures are typed you can do it like this:
ls_college-CITY = ls_modify-CITY.
If you can guarantee that no other fields of ls_collge could be overwritten you can also do a
move-corresponding ls_modify to ls_college.
If you want to move only the value of the component(fieldname) which is stored in your other variable do it like this.
FIELD-SYMBOLS: <field> type any,
<field2> type any.
ASSIGN COMPONENT field_name OF STRUCTURE LS_COLLEGE TO <field>.
IF SY-SUBRC = 0.
ASSIGN COMPONENT field_name OF STRUCTURE LS_MODIFY TO <field2>.
IF SY-SUBRC = 0.
<field> = <field2>.
ENDIF.
ENDIF.
Regards Jonas
‎2013 Mar 05 10:38 AM
‎2013 Mar 05 10:48 AM