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

Populate dynamic table fields from internal table

Former Member
0 Likes
370

Hi,

Im trying to populate an dynamic table , but it's giving me a few errors witch i can't solve ...

Basically i have an internal table with te following types :



DATA: BEGIN OF tab_docs41 OCCURS 0,
      conta TYPE bsis-hkont,
      banco TYPE t012t-text1,
      ano_3 TYPE i,
      ano_2 TYPE i,
      ano_1 TYPE i,
      jan TYPE  i,
      fev TYPE  i,
      mar TYPE  i,
      abr TYPE  i,
      mai TYPE  i,
      jun TYPE  i,
      jul TYPE  i,
      ago TYPE  i,
      set TYPE  i,
      out TYPE  i,
      nov TYPE  i,
      dez TYPE  i,
      total TYPE i,
      montante TYPE betrag11,
END OF tab_docs41.

and the following fieldcatalog , for the dynamic table :



 DATA : ls_fieldcat TYPE lvc_s_fcat.
  DATA: lv_period TYPE i.
  DATA str_period TYPE string.

  SUBTRACT 3 FROM ano.
  MOVE ano TO str_period.

  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname = 'CONTA'.
  ls_fieldcat-seltext = 'Conta do Razão'.
  ls_fieldcat-datatype = 'HKONT'.
*  ls_fieldcat-intlen = '10'.

  APPEND ls_fieldcat TO p_fieldcat.
  .....

Since the internal table, tab_docs41 it's allready filled how can i pass the tab_docs41 values to the corresponding fields of the dynamic table (the move-corresponding it's not working..)



  ASSIGN fs_data->* TO <fs_1>.
  CREATE DATA new_line LIKE LINE OF <fs_1>.

*  ASSIGN new_line->*  TO <fs_2>.

*** Next step is to create a work area for our dynamic internal table.

  LOOP AT tab_docs41.

   ASSIGN COMPONENT 'CONTA' OF STRUCTURE  tab_docs41 TO <fs2>.

...

But this last step it's not working ...

Can anyone help me please ?

Point's will be rewarded

Best Regards

Thanks in advance

João Martins

1 ACCEPTED SOLUTION
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
329

Looks like you have used the method CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE to create the dynamic internal table.

You have to change the last part of the code:

FIELD-SYMBOLS:
<itab> TYPE STANDARD TABLE,
<wa> TYPE ANY,
<val> TYPE ANY .

ASSIGN fs_data->* TO <itab>.

CREATE DATA new_line LIKE LINE OF <itab>.
ASSIGN new_line->*  TO <wa>.


LOOP AT tab_docs41.

  ASSIGN COMPONENT 'CONTA' OF STRUCTURE <wa> TO <val>.
  <val> = tab_docs41-conta.

  ASSIGN COMPONENT 'BANCO' OF STRUCTURE <wa> TO <val>.
  <val> = tab_docs41-banco.

  APPEND <wa> to <itab>.

ENDLOOP.

BR,

Suhas

1 REPLY 1
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
330

Looks like you have used the method CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE to create the dynamic internal table.

You have to change the last part of the code:

FIELD-SYMBOLS:
<itab> TYPE STANDARD TABLE,
<wa> TYPE ANY,
<val> TYPE ANY .

ASSIGN fs_data->* TO <itab>.

CREATE DATA new_line LIKE LINE OF <itab>.
ASSIGN new_line->*  TO <wa>.


LOOP AT tab_docs41.

  ASSIGN COMPONENT 'CONTA' OF STRUCTURE <wa> TO <val>.
  <val> = tab_docs41-conta.

  ASSIGN COMPONENT 'BANCO' OF STRUCTURE <wa> TO <val>.
  <val> = tab_docs41-banco.

  APPEND <wa> to <itab>.

ENDLOOP.

BR,

Suhas