Application Development 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: 

class cl_abap_structdescr=describe_by_name

Former Member
0 Kudos

Hi ,

Iam using below code to read the fields in the particular structure.

select single rollname into lv_rollname from dd03l where fieldname = gw_allowed-infty

and tabname = gw_allowed-tabname

and tabletype = 'X'.

if sy-subrc eq 0.

lo_descr = cl_abap_structdescr=>describe_by_name( lv_rollname ) .

lo_table ?= lo_descr .

lt_components = lo_table->key.

But in the lt_components except element maintained with data element DEC is not fetching in the table .

Please give me the methid which fetches all the fields from the structure.

Thanks,

Pavan kk

Edited by: Rob Burbank on Sep 15, 2010 9:30 AM

1 ACCEPTED SOLUTION

kesavadas_thekkillath
Active Contributor
0 Kudos

Please give me the methid which fetches all the fields from the structure

Which structure ?

lv_rollname holds a data element and not a structure.

Edited by: Rob Burbank on Sep 15, 2010 9:30 AM

4 REPLIES 4

kesavadas_thekkillath
Active Contributor
0 Kudos

Please give me the methid which fetches all the fields from the structure

Which structure ?

lv_rollname holds a data element and not a structure.

Edited by: Rob Burbank on Sep 15, 2010 9:30 AM

MarcinPciak
Active Contributor
0 Kudos

As Keshav noticed lv_rollname is a data element not a structure, but for structure you can use the following.


data lr_structdescr type ref to cl_abap_structdescr.
data lt_components type table of cl_structdescr=>component_table.

lr_structdescr ?= cl_abap_typedescr=>describe_by_name( 'STRUCTURE_NAME' ) .
lt_components = lr_structdescr->get_components( ).  "holds structure components

Regards

Marcin

Edited by: Rob Burbank on Sep 15, 2010 9:31 AM

Former Member
0 Kudos

You can also use a structure data object if you have one in a memory.

data lr_structdescr type ref to cl_abap_structdescr.
data lt_components type table of cl_structdescr=>component_table.
data l_structure TYPE some_structure.
 
lr_structdescr ?= cl_abap_typedescr=>describe_by_data( l_structure ) .
lt_components = lr_structdescr->get_components( ).  "holds structure components

0 Kudos

Hello,

Not forgetting Krzysztof's fondness towards OO ABAP, if it is a DDIC structure i would use DDIF_FIELDINFO_GET / DDIF_NAMETAB_GET get the field info.

BR,

Suhas