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

Checking generic data types

gustavo_prado
Participant
0 Likes
1,666

Hi all,

In java, when we have a parameter/variable of a generic type, we can use the "type of" to check what is the correct type to make some attribution.

In abap, i have a function with generic table parameter, and in the function i want to check about what structure is the referencing parameter.

Somebody know how to check it?

Best regards,

Gustavo

1 ACCEPTED SOLUTION
Read only

gustavo_prado
Participant
0 Likes
1,499

Thanks to all, with the cl_abap_tabledescr i did it.

Regards,

Gustavo

6 REPLIES 6
Read only

Former Member
0 Likes
1,499

Hi Gustavo,

you can find out using Field symbols.

1. Declare variable field-symbols : <fs_struct> type any.

2. Get reference of the Table parameter and assign to field symbol declared above.

   ex: lt_table is table parameter then

ASSIGN lt_table->* TO <fs_struct>.

Now fs_struct will be pointing to structure of the Lt_table. Check structure in debug mode for more detail.

Regards,

Ravikiran.K

Read only

Former Member
0 Likes
1,500

This message was moderated.

Read only

gustavo_prado
Participant
0 Likes
1,500

Well,

The real situation is:

FM Table parameter:

IT_GEN TYPE STANDARD TABLE.

This IT_GEN can be structure ST_INVOICE or ST_SALESORD.

When the FM is called, i have to check about what structure is the parameter.

Thanks,

Gustavo

Read only

0 Likes
1,500

Hi Gustavo,

check this code:


DATA: lcl_typedescr     TYPE REF TO cl_abap_typedescr,

          lva_absolute_name TYPE abap_abstypename.

   lcl_typedescr            = cl_abap_typedescr=>describe_by_data( IT_GEN ).

   lva_absolute_name   = lcl_typedescr->absolute_name.

Regards,

Angelo.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,500

Look for RTTS class. (e.g. CL_ABAP_TABLEDESCR, CL_ABAP_STRUCTDESCR, etc.)

But with only two different structures available, coding (and maintenance) would be much easier with either two FMs (in same FG so sharing many code) or to optional parameters.

Regards,

Raymond

Read only

gustavo_prado
Participant
0 Likes
1,500

Thanks to all, with the cl_abap_tabledescr i did it.

Regards,

Gustavo