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

Reg:function module

Former Member
0 Likes
793

Hi all,

I need one function module for catching field names in a structure.

i am calling that structure as an import parameter in a Function module.

I need to get field names of that structur. is there any function module exists?

Regards,

sarath

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
741

Hi,

You can use the structure descriptor class as well. See the code below


REPORT  z_struc_describe                        .

DATA  type_desc TYPE REF TO cl_abap_typedescr.

DATA : l_struc TYPE REF TO cl_abap_structdescr.

DATA : lt_comp TYPE abap_compdescr_tab,
       w_comp LIKE LINE OF lt_comp.

PARAMETERS : p_table TYPE tabname.

CALL METHOD cl_abap_complexdescr=>describe_by_name
  EXPORTING
    p_name         = p_table
  RECEIVING
    p_descr_ref    = type_desc
*  EXCEPTIONS
*    TYPE_NOT_FOUND = 1
*    others         = 2
        .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

l_struc ?= type_desc.

lt_comp = l_struc->components.
WRITE : 5 'Field',
        25 'Data type',
        40 'Length',
        50 'Decimals'.

LOOP AT lt_comp INTO w_comp.
  WRITE : /5 w_comp-name,
           30 w_comp-type_kind,
           35 w_comp-length RIGHT-JUSTIFIED ,
           45 w_comp-decimals RIGHT-JUSTIFIED .
  CLEAR w_comp.
ENDLOOP.

Remember with oops its much faster then using function modules. So go with the oops approach.

regards,

Advait

5 REPLIES 5
Read only

Former Member
0 Likes
741

Up date please

Read only

MarcinPciak
Active Contributor
0 Likes
741

Hi,

You can write that yourself using DD03L table, or use this FM F4_DD_STRUCTURE_FIELDS.

Regards

Marcin

Read only

Former Member
0 Likes
742

Hi,

You can use the structure descriptor class as well. See the code below


REPORT  z_struc_describe                        .

DATA  type_desc TYPE REF TO cl_abap_typedescr.

DATA : l_struc TYPE REF TO cl_abap_structdescr.

DATA : lt_comp TYPE abap_compdescr_tab,
       w_comp LIKE LINE OF lt_comp.

PARAMETERS : p_table TYPE tabname.

CALL METHOD cl_abap_complexdescr=>describe_by_name
  EXPORTING
    p_name         = p_table
  RECEIVING
    p_descr_ref    = type_desc
*  EXCEPTIONS
*    TYPE_NOT_FOUND = 1
*    others         = 2
        .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

l_struc ?= type_desc.

lt_comp = l_struc->components.
WRITE : 5 'Field',
        25 'Data type',
        40 'Length',
        50 'Decimals'.

LOOP AT lt_comp INTO w_comp.
  WRITE : /5 w_comp-name,
           30 w_comp-type_kind,
           35 w_comp-length RIGHT-JUSTIFIED ,
           45 w_comp-decimals RIGHT-JUSTIFIED .
  CLEAR w_comp.
ENDLOOP.

Remember with oops its much faster then using function modules. So go with the oops approach.

regards,

Advait

Read only

Former Member
0 Likes
741

Hello,

Use this FM 'CATSXT_GET_DDIC_FIELDINFO'.

Hope it helps.

Thanks,

Jayant

Read only

Former Member
0 Likes
741

THanks for u r help.