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

get_component_list

Former Member
0 Likes
3,049

Hi there,

I'm using the FM 'GET_COMPONENT_LIST' to get the fields of a IT, but it's not working, I'm in 4.7

Not even in SE37 it's working.

there some restriction to use it in 4.7, or someone know another way to get the fields of a internal table?

Alexandre Nogueira

6 REPLIES 6
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,727

Here is a sample program. Implement it in your system. Does it work?



report zrich_0003.

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

Read only

0 Likes
1,727

Yeap Rich, your program worked Ok.

The FM 'GET_GLOBAL_SYMBOLS' have worked to MY program, but 'GET_COMPONENT_LIST' did not... In Se37.

The problem is my report, to other reports it works, but I don't Know what is the problem.

Alexandre Nogueira

Message was edited by: Alexandre Nogueira

Read only

0 Likes
1,727

Interesting, can you post your code and I can check it in my system? Or you can email it to me. My email is on my business card.

Regards,

Rich Heilman

Read only

0 Likes
1,727

Oh man, you won't believe what is the problem... I found it out.

I was trying the use the FM GET_COMPONENT_LIST passing a IT that does not have header line, and it does not work.

The IT HAVE TO have a header line.

Read only

0 Likes
1,727

Hmmm.. That's funny. Does it work if you pass a work area like the itab?

Thanks for telling us how you fixed it.

Regards,

Rich Heilman

Read only

0 Likes
1,727

If you pass only a work area, it works, but if you pass a itab that does't have header line, it, does not work.

Try it in that sample program that you sent me today.

Alexandre nogueira