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

Structure creation

Former Member
0 Likes
622

I guess I got a funny ques.. can someone answer this ?

I want to create a structure, with fields, a1,a2,a3...a10

is that possible I create some kind of counter, a(counter) and then keep on incrementing it without defining a1...a10

if it is possible, how do i acheive it ?

thanks.

4 REPLIES 4
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
595

You mean within a program? If so, then yes, you can create a dynamic internal table and then a dynamic work area. See this blog for an example.

/people/rich.heilman2/blog/2005/07/27/dynamic-internal-tables-and-structures--abap

Regards,

RIch Heilman

Read only

0 Likes
595

So using what is in the blog, you code would be something like this. Run the program and check <dyn_wa> to see that it has your structure.



type-pools : abap.

field-symbols: <dyn_table> type standard table,
               <dyn_wa>,
               <dyn_field>.

data: dy_table type ref to data,
      dy_line  type ref to data,
      xfc type lvc_s_fcat,
      ifc type lvc_t_fcat.

data: index(2) type c.

start-of-selection.


  do 10 times.
    clear xfc.
    index = sy-index.
    concatenate 'A' index into xfc-fieldname.
    xfc-datatype = 'C'.
    xfc-inttype = 'C'.
    xfc-intlen = '10'.
    append xfc to ifc.
  enddo.



* Create dynamic internal table and assign to FS
  call method cl_alv_table_create=>create_dynamic_table
               exporting
                  it_fieldcatalog = ifc
               importing
                  ep_table        = dy_table.

  assign dy_table->* to <dyn_table>.

* Create dynamic work area and assign to FS
  create data dy_line like line of <dyn_table>.
  assign dy_line->* to <dyn_wa>.

  check sy-subrc  = 0.

Regards,

RIch Heilman

Read only

0 Likes
595

oh this is great stuff... yeah saw your blog and code and it runs neat while creation of dyn. internal table withdyn. fileds ..

just another aspect to my question, can we this couter arrangement while creating a sturcture in se11 or no ?

Read only

0 Likes
595

Nop, you can't do this in SE11.

Please be sure to award points for any helpful answer and mark as solved when answered completely. Thanks.

Regards,

RIch Heilman