Skip to Content
author's profile photo Former Member
Former Member

FM to Retrun Itab structure

Hi experts,

Does anybody know some FM that returns a structure of a interntal table? I want to use it to make it easier to fill a fieldcatalog.

It'd be better wheter the FM return the type of the field, ex:

returns: | fieldname | type | reference table | reference field | ......

thanks in advance,

Alexandre

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Feb 28, 2007 at 02:55 PM

    Hi Alexandre,

    Take a look at the methods in class CL_ABAP_COMPLEXDESCR.

    Regards,

    John.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Feb 28, 2007 at 02:55 PM

    Check the FM 'GET_COMPONENT_LIST' in this example.

    
    REPORT  ZRICH_0001.
    
    types: begin of type_item,
           f1(3),
           f2(3),
           f3(3),
           f4(3),
           end of type_item.
    
    types: begin of type_data,
           data(800),
           end of type_data.
    
    data:  lineitems type table of type_item with header line,
           t_output type table of type_data with header line,
           fieldlist type table of rstrucinfo with header line,
           fieldsym  type table of rfieldlist with header line.
    
    data:  syrepid type sy-repid.
    
    data:  fieldname like fieldlist-compname,
           data_line type type_data.
    
    field-symbols : <fs1> type any,
                    <fs2> type any.
    
    lineitems-f1 = 'a1'.
    lineitems-f2 = 'a2'.
    lineitems-f3 = 'a3'.
    lineitems-f4 = 'a4'.
    append lineitems.
    
    lineitems-f1 = 'b1'.
    lineitems-f2 = 'b2'.
    lineitems-f3 = 'b3'.
    lineitems-f4 = 'b4'.
    append lineitems.
    
    lineitems-f1 = 'c1'.
    lineitems-f2 = 'c2'.
    lineitems-f3 = 'c3'.
    lineitems-f4 = 'c4'.
    append lineitems.
    
    lineitems-f1 = 'd1'.
    lineitems-f2 = 'd2'.
    lineitems-f3 = 'd3'.
    lineitems-f4 = 'd4'.
    append lineitems.
    
    syrepid = sy-repid.
    
    * Gets all of the global data types.
    call function 'GET_GLOBAL_SYMBOLS'
         exporting
              program   = syrepid
         tables
              fieldlist = fieldsym.
    
    * gets all of the components of a structure
    call function 'GET_COMPONENT_LIST'
         exporting
              program    = syrepid
              fieldname  = 'lineitems'
         tables
              components = fieldlist.
    
    format color 3.
    
    loop at lineitems assigning <fs2> .
    
      loop at fieldlist.
        fieldname = fieldlist-compname .
        assign component  fieldname  of structure <fs2> to <fs1>.
        concatenate data_line <fs1> into data_line .
      endloop.
      append data_line to t_output.
      clear data_line.
    endloop.
    
    loop at t_output.
      write:/ t_output.
    endloop.
    
    

    Regards,

    Rich Heilman

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.