2013 Nov 21 9:34 AM
Hi All,
I am relatively new to ABAP development. I have a requirement to enhance a method MAP_BACKEND_TO_XI in SRM badi /SAPSRM/BD_SOA_MAPPING.
The scenario I am facing is as follows: deep_structure-->deep_structure--deep_structure--n_table[1]--field_x
I need to be able to access and modify the value of field_x at run time.
Kindly assist or if a link already exists point me to it.
Thanks in advance.
2013 Nov 21 1:36 PM
Hi Wilson,
I think you are trying to access the reference variable. which means a variable points to a remote memory location.
create a field symbol which is type of the deep structure.
then perform your looping operation on the field symbol and do as instructed in above suggestions.
Let me know in case of any issues or difficluties in this case.
Thanks and Regards,
Bhaskar
2013 Nov 21 9:40 AM
Hi Wilson
If you have data as alredy filled you can directly use loop
data: lwa_table4 type xyz.
Loop at deep_structure1-->deep_structure2--deep_structure3--n_table4 into lwa_table4
lwa_table4-value = 'X'
modify deep_structure1-->deep_structure2--deep_structure3--n_table4 transport value index lv_tabix
Endloop.
2013 Nov 21 10:47 AM
Hello Nabheet,
Thanks for taking the time. When i try it that way i get the following error
| You cannot dereference (->) a generic reference in the current | |
| statement |
2013 Nov 21 10:53 AM
Wilson
you have to use this way.
deep_structure1-deep_structure2-deep_structure3-n_table4
2013 Nov 21 11:33 AM
Hi Wilson
Can you please attach a screen shot of the nested structure and you sample code.
Nabheet
2013 Nov 21 11:48 AM
Nabheet,
Getting this error
Field is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement
2013 Nov 21 12:11 PM
2013 Nov 21 12:38 PM
Nabheet,
Path to the table is CR_MSG_INTF_DATA->PURCHASE_ORDER_ERPREQUEST_V1-PURCHASE_ORDER-ITEM with the first three as deep structures and ITEM as table
Sample code as follows
FIELD-SYMBOLS : <FS_ITEM> TYPE ANY.
loop at CR_MSG_INTF_DATA-PURCHASE_ORDER_ERPREQUEST_V1-PURCHASE_ORDER-item ASSIGNING <FS_ITEM>. ENDLOOP.
2013 Nov 21 9:57 AM
Define Workarea for all the structures.
Use READ TABLE deep_structure1->deep_structure2.
Continue this until you reach the structure where you need to do the change.
MODIFY the structure with the new value.
2013 Nov 21 10:53 AM
2013 Nov 21 1:36 PM
Hi Wilson,
I think you are trying to access the reference variable. which means a variable points to a remote memory location.
create a field symbol which is type of the deep structure.
then perform your looping operation on the field symbol and do as instructed in above suggestions.
Let me know in case of any issues or difficluties in this case.
Thanks and Regards,
Bhaskar
2013 Nov 22 12:49 PM
Bhaksar,
Please see below code.
FIELD-SYMBOLS : <FS_DATA> TYPE ANY.
ASSIGN CR_MSG_INTF_DATA->* TO <FS_DATA>.
At run time all data in CR_MSG_INTF_DATA is copied to <FS_DATA>. CR_MSG_INTF_DATA is declared as TYPE REF TO DATA. Now I am having difficulty accessing table data within <FS_DATA> from program. Earlier in this thread you will see the ITEM table that I am trying to access.
Wilson.
2013 Dec 02 7:47 AM
Hello Wilson,
I have one doubt here, I can see the deep internal table name as CONTROLLAR but I am not able to find any internal table with name ITEM here....
Please clarify.
Thanks,
bhaskar
2013 Dec 02 11:46 AM
Hello Bhaskar,
Thanks for your time. I have made some headway and see below code
FIELD-SYMBOLS : <FS_DATA> TYPE ANY, <FS_DATA_1> TYPE ANY, <FS_DATA_2> TYPE any, <FS_DATA_3> TYPE any, <FS_DATA_4> TYPE any.
FIELD-SYMBOLS : <FS_ITEM> TYPE ANY TABLE.
ASSIGN CR_MSG_INTF_DATA->* TO <FS_DATA>.
ASSIGN COMPONENT 2 OF STRUCTURE <FS_DATA> to <FS_DATA_1>.
ASSIGN COMPONENT 3 OF STRUCTURE <FS_DATA_1> to <FS_DATA_2>.
ASSIGN COMPONENT 20 of STRUCTURE <FS_DATA_2> to <FS_DATA_3>.
The ITEM table is now in <FS_DATA_3>. The question now is this, there is a field in <FS_DATA_3> that I need to update. Unfortunately I can not reference it by name as the entire structure including the table is created at run time. So how can a value in this table be updated? In a loop?
For reference see below:
CR_MSG_INTF_DATA->PURCHASE_ORDER_ERPREQUEST_V1-PURCHASE_ORDER-ITEM
ITEM is the table and the first three are deep structures.
2013 Dec 02 12:48 PM
HI Wilson,
is below procedure not working for you ?
Field-symbols: <fs_data_wa> type any,
<fs_var1> type any.
loop at <FS_DATA_3> assigning <fs_data_wa>.
assign component <field number> of structure <fs_data_wa> to <fs_var1>.
(modify the <fs_var1> as per the requirement)
unassign <fs_var1>.
Endloop.
I dont know whether you tried this or not . If yes then please publish the error or problem you faced, I will try to help you.
Thanks and Regards,
Bhaskar
2013 Dec 02 12:51 PM
Hi Wilson
sorry for late reply. You have made a lot of progress. Simple way out in your case now is keep <FS_DATA_3> same as type of your compoonent of ITEM.
Or else start a loop at <FS_DATA_3> and use assign statement as mentioned above by Bhaskar
ASSIGN COMPONENT 20 of STRUCTURE <FS_DATA_2> to <FS_DATA_3>.
NAbheet
2013 Dec 03 7:55 AM
Bhaskar,
Your instructions were spot on. Thanks alot!
Thanks & Regards,
Wilson