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

Access using field symbols : Different data type

Former Member
0 Likes
452

Hi,

I am trying to access data from a cluster. The type of data being retrieved is different. Therefore i use a field symbol to create the type and then import the data. Now the data retrived has got different structures and sometimes they are even deep structures.

I want to access a particular value from all these different structures (Object_id). Sometimes it is just located at the firsty level

<Filed_symbol>->object_id.

Sometimes the data is available as <Field_symbol>->structure->Object_id.

How can i retrieve the data(Object_id) from such structures irrespective of the type of data being fetched from IMPORT.

Regards,

Rishav

1 ACCEPTED SOLUTION
Read only

MarcinPciak
Active Contributor
0 Likes
422

Hi try this:


type-pools: abap.

data: r_struct type ref to cl_abap_structdescr.
data: it_components type abap_component_tab with header line.
data: component_addr type string.

field-symbols: <component> type any,   "component name i.e. OBJECT_ID
                     <component_adrr> type any.   "component absolute address i.e STRUCTURE-COMPONENT-OBJECT_ID

r_struct ?= cl_abap_typdescr=>DESCRIBE_BY_DATA( <field_symbol> ).  "get strcutre
it_components = r_struct->GET_COMPONENTS( ).       "get its components

loop at it_components.
   concatenate <field_symbol> it_components-name into component_addr   
                                                  separated by '-'.   "STRUCTURE-COMPONENT-OBJECT_ID
   assign component_addr to <component>. 
   <component> =  ...."give value here 
endloop.

Regards

Marcin

2 REPLIES 2
Read only

MarcinPciak
Active Contributor
0 Likes
423

Hi try this:


type-pools: abap.

data: r_struct type ref to cl_abap_structdescr.
data: it_components type abap_component_tab with header line.
data: component_addr type string.

field-symbols: <component> type any,   "component name i.e. OBJECT_ID
                     <component_adrr> type any.   "component absolute address i.e STRUCTURE-COMPONENT-OBJECT_ID

r_struct ?= cl_abap_typdescr=>DESCRIBE_BY_DATA( <field_symbol> ).  "get strcutre
it_components = r_struct->GET_COMPONENTS( ).       "get its components

loop at it_components.
   concatenate <field_symbol> it_components-name into component_addr   
                                                  separated by '-'.   "STRUCTURE-COMPONENT-OBJECT_ID
   assign component_addr to <component>. 
   <component> =  ...."give value here 
endloop.

Regards

Marcin

Read only

Former Member
0 Likes
422

The object type that you are importing is impotant to be known. Later you can import or export to the cluster