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: 

Run Time structure identification of a variable.

styrolution_accenture
Participant
0 Kudos

Hi Experts,

I have a requirement where i need to identify the structure type assigned to the variable at run time. i.e. if i have the variable name at run time i shold be able to find the structure type assigned in that program.

Please help. let me know if you need any further information.

BR,

Raj.

1 ACCEPTED SOLUTION

former_member320332
Contributor
0 Kudos

Hi Rajesh,

Please refer below link

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3034358411d1829f0000e829fbfe/frameset.htm

go to --> Determining the Attributes of Data Objects.

Regards,

Pawan

Edited by: PawanG on Oct 5, 2010 1:06 PM

7 REPLIES 7

former_member320332
Contributor
0 Kudos

Hi Rajesh,

Please refer below link

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3034358411d1829f0000e829fbfe/frameset.htm

go to --> Determining the Attributes of Data Objects.

Regards,

Pawan

Edited by: PawanG on Oct 5, 2010 1:06 PM

0 Kudos

Hello Pawan,

Thanks for the quick response.

The given link talks about the type like if it is an internal table or a structure so on...

but in my case the requirement is like i need to know the structure name for example..

DATA: temp_bapimara1 TYPE bapi_mara.

So if i pass the variable temp_bapimara1 to the code i should get the type name like bapi_mara in one variable.

Let me know if you need any further clarification.

BR,

Raj.

0 Kudos

Do like this.

DATA: gs_mara TYPE mara.

DATA: gt_fields TYPE TABLE OF rfieldlist,
      gwa_field TYPE rfieldlist.

CALL FUNCTION 'GET_GLOBAL_SYMBOLS'
  EXPORTING
    program   = sy-repid
  TABLES
    fieldlist = gt_fields.

READ TABLE gt_fields INTO gwa_field WITH KEY name = 'GS_MARA'.

WRITE:/ gwa_field-reftypenam.

0 Kudos

Thanks Asik,

But in this case we are hardcoding while reading the record but in my case it should be dynamic so these lines of code would be in a perform and we would be able to pass any structure to that perform and get the structure type.

like

DATA: gc_mara TYPE mara,

gc_marc type marc.

Perform check_struct using gc_mara.

it can also be like

perform check_struct using gc_marc.

Form check_struct using p_struct type any.

*here we should be able to find the structure type.*

ENDFORM.

0 Kudos

Check this:

TYPE-POOLS: abap.

DATA: gc_mara TYPE mara,
      gc_marc TYPE marc.

PERFORM check_struct USING gc_mara.

PERFORM check_struct USING gc_marc.

*&---------------------------------------------------------------------*
*&      Form  check_struct
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_STRUCT   text
*----------------------------------------------------------------------*
FORM check_struct USING p_struct TYPE any.

  DATA: lcl_struc TYPE REF TO cl_abap_structdescr,
        lv_struc_name TYPE abap_abstypename.

  lcl_struc ?= cl_abap_structdescr=>describe_by_data( p_struct ).

  CHECK lcl_struc IS BOUND.

  * Get the DDIC structure of the formal param P_STRUC
  lv_struc_name = lcl_struc->absolute_name. "\TYPE=<DDIC Structure>

  WRITE: / lv_struc_name.

ENDFORM.                    "check_struct

BR,

Suhas

0 Kudos

Thanks Suhas,

This has resolved my issue.

0 Kudos

Hello Rahesh,

I have an similar requirement can plz share with me, the fallowing is the requirement for me.

Get Billing Header information from SAP runtime structures, billing buffer and flex billing tables , where

GROUP ID number is to be passed instead of the debit memo request number

Thanks & Regards

Chandu.