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: 

How to create Dynamic internal table with columns also created dynamically.

Former Member
0 Kudos

Hi All,

Any info on how to create a dynamic internal table along with columns(fields) also to be created dynamically.

My requirement is ..On the selection screen I enter the number of fields to be in the internal table which gets created dynamically.

I had gone thru some posts on dynamic table creation,but could'nt find any on the dynamic field creation.

Any suggestions pls?

Thanks

Nara

3 REPLIES 3

FredericGirod
Active Contributor
0 Kudos

I don't understand ...

something like that ?



*----------------------------------------------------------------------*
*   Form P_MODIFY_HEADER.                                              *
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
form p_modify_header.


  data : is_fieldcatalog type lvc_s_fcat ,
         v_count(2)      type n ,
         v_date          type d ,
         v_buff(30).



* Update the fieldcatalog.
  loop at it_fieldcatalog into is_fieldcatalog.
    check is_fieldcatalog-fieldname+0(3) eq 'ABS' or
          is_fieldcatalog-fieldname+0(3) eq 'VAL' .
    move : is_fieldcatalog-fieldname+3(2) to v_count ,
           p_perb2+5(2)                   to v_date+4(2) ,
           p_perb2+0(4)                   to v_date+0(4) ,
           '01'                           to v_date+6(2) .
    v_count = v_count - 1.
    call function 'RE_ADD_MONTH_TO_DATE'
        exporting
          months        = v_count
          olddate       = v_date
        importing
          newdate       = v_date.
    if is_fieldcatalog-fieldname+0(3) eq 'ABS'.
      concatenate 'Quantité 0'
                  v_date+4(2)
                  '.'
                  v_date+0(4)
                  into v_buff.
    else.
      concatenate 'Montant 0'
                  v_date+4(2)
                  '.'
                  v_date+0(4)
                  into v_buff.
    endif.
    move : v_buff to is_fieldcatalog-scrtext_s ,
           v_buff to is_fieldcatalog-scrtext_m ,
           v_buff to is_fieldcatalog-scrtext_l ,
           v_buff to is_fieldcatalog-reptext .
    modify it_fieldcatalog from is_fieldcatalog.
  endloop.


* Modify the fieldcatalog.
  call method obj_grid->set_frontend_fieldcatalog
       exporting it_fieldcatalog = it_fieldcatalog.


* Refresh the display of the grid.
  call method obj_grid->refresh_table_display.



endform.                     " P_MODIFY_HEADER

0 Kudos

Hi Fred,

The requirement is like this...

I enter 110 or 200 on the selection screen and the internal table as below to be created dynamically.

Data: Begin of it_itaboccurs 0,

FIELD1(19),

FIELD2(19),

FIELD3(19),

FIELD4(19),

FIELD5(19),

FIELD6(19),

FIELD7(19),

FIELD8(19),

FIELD9(19),

and so on.... till field110 or may be FIELD9200,

end of it_itab.

Hope you are now clear of my requirement.

Thanks

Nara

0 Kudos

It's the code I give you. My code is to change the number of column depend of the number of month the user select.

You just have to create a good table it_fieldcatalog, with the 200 column dynamicly (depend of the number enter in your selection-screen).

Fred