Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8644

Re: Shortway to create a dynamic table

$
0
0

I don't think there is any way....and why would you really want to do it?

 

But, if you really wanted to you could create a local class with a static method

*----------------------------------------------------------------------*
*       CLASS lcl_DYNAMIC DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_DYNAMIC DEFINITION.

  PUBLIC SECTION.

    CLASS-METHODS:

    MAKE_TABLE
            IMPORTING I_STRUCTURE TYPE TABNAME
            exporting e_TABLE TYPE TABLE
.

  PRIVATE SECTION.

ENDCLASS.                    "lcl_DYNAMIC DEFINITION

*----------------------------------------------------------------------*
*       CLASS lcl_DYNAMIC  IMPLEMENTATION
*----------------------------------------------------------------------*
CLASS lcl_DYNAMIC IMPLEMENTATION.

  METHOD MAKE_TABLE.
    data: l_dref type ref to data.
    field-symbols <tab> type table.

    create data L_DREF type standard table of (I_STRUCTURE).
    assign L_DREF->* to <TAB>.

    E_TABLE = <TAB>.


  ENDMETHOD.                    "
ENDCLASS.                    "lcl_DYNAMIC IMPLEMENTATION

 

and then use it in your code:

  data: l_dref type ref to data.
  field-symbols <tab> type table.

 

  LCL_DYNAMIC=>MAKE_TABLE( exporting i_structure = 'MARA'
                           importing e_table = <tab> ).


Viewing all articles
Browse latest Browse all 8644

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>