Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Accessing table values in nested deep structures

Former Member
0 Likes
9,676

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.


1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
4,941

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

16 REPLIES 16
Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
4,941

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.

Read only

0 Likes
4,941

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
Read only

0 Likes
4,941

Wilson

you have to use this way.

deep_structure1-deep_structure2-deep_structure3-n_table4

Read only

0 Likes
4,941

Hi Wilson

Can you please attach a screen shot of the nested structure and you sample code.

Nabheet

Read only

0 Likes
4,941

Nabheet,

Getting this error

Field is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement

Read only

0 Likes
4,941

Some data delcaration issue..Please share your sample code

Read only

0 Likes
4,940

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.

Read only

davis_raja
Active Participant
0 Likes
4,940

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.

Read only

0 Likes
4,940

Hello Davisraja,

I get the same error as with Nabheet.

Read only

Former Member
0 Likes
4,942

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

Read only

0 Likes
4,940

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.

Read only

0 Likes
4,940

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


Read only

0 Likes
4,940

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.

Read only

0 Likes
4,940

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

Read only

0 Likes
4,940

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

Read only

0 Likes
4,940

Bhaskar,

Your instructions were spot on. Thanks alot!

Thanks & Regards,

Wilson