Skip to Content
0
Jul 19, 2007 at 05:45 AM

save field symbol into dynamic itab.

28 Views

Hi experts,

I ve read this:

/people/subramanian.venkateswaran2/blog/2004/11/19/dynamic-internal-table

field-symbol

And now I want to save my field-symbol which has the structure of the dynamic internal table into the dynamic itab. I thought after my declaration and assignings the itab should be filled automaticly but i don't works.

Short: I need this:

APPEND <my_field_symbold> TO <itab>. Ofcourse we cannot do this with fieldsymbols...

here is my code:


DATA:

      gt_stxl_ext TYPE TABLE OF gs_stxl_ext,
      wa_stxl_ext TYPE          gs_stxl_ext,

      gt_text     TYPE TABLE OF tline,
      wa_text     TYPE tline,

      g_tdlines_max_loc   TYPE i,
      g_tdlines_max_all   TYPE i,

      gs_fcat_tdlines TYPE lvc_s_fcat,
      gt_fcat_tdlines TYPE lvc_t_fcat,

      gt_dyn_tdlines TYPE REF TO data,
      wa_dyn_table   TYPE REF TO data
      .

FIELD-SYMBOLS: <fs_stxl>     TYPE stxl,
               <fs_stxl_ext> TYPE gs_stxl_ext,
               <fs_dyn_tdlines> TYPE REF TO data,
               <fs_dyn_table>   TYPE ANY TABLE,
               <fs_dyn_newline>,
               <fs_dynnewline_field>
               .

  ASSIGN gt_dyn_tdlines TO <fs_dyn_tdlines>.
  CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING it_fieldcatalog  = gt_fcat_tdlines
    IMPORTING ep_table         = <fs_dyn_tdlines>
    .

IF sy-subrc <> 0.
  EXIT.
ENDIF.


ASSIGN <fs_dyn_tdlines>->* TO <fs_dyn_table>.

CREATE DATA wa_dyn_table LIKE LINE OF <fs_dyn_table>.

LOOP AT gt_stxl_ext ASSIGNING <fs_stxl_ext>.

  CALL FUNCTION 'READ_TEXT'
  EXPORTING
    client           = sy-mandt
    id               = <fs_stxl_ext>-tdid
    language         = <fs_stxl_ext>-tdspras
    name             = <fs_stxl_ext>-tdname
    object           = <fs_stxl_ext>-tdobject
  TABLES    lines    = gt_text
  .

  IF sy-subrc = 0.
    CLEAR: l_gttext_string, g_tdlines_max_loc.
    UNASSIGN <fs_dyn_newline>.
    ASSIGN wa_dyn_table->* TO <fs_dyn_newline>.

    MOVE-CORRESPONDING <fs_stxl_ext> TO <fs_dyn_newline>.


    LOOP AT gt_text INTO wa_text.

      l_dynnewline_field = 'TDLINE'.
      l_tabix_component = sy-tabix.
      SHIFT l_tabix_component LEFT DELETING LEADING '0'.
      CONCATENATE l_dynnewline_field l_tabix_component INTO l_dynnewline_field.

      ASSIGN COMPONENT l_dynnewline_field OF STRUCTURE <fs_dyn_newline> TO <fs_dynnewline_field>.
      <fs_dynnewline_field> = wa_text-tdline.

    ENDLOOP.

* all this below doesn't works... (ofcourse)
*    ASSIGN <fs_dyn_newline> TO <fs_dyn_table>.
*    MOVE <fs_dyn_newline> TO <fs_dyn_table>.
*    APPEND INITIAL LINE TO <fs_dyn_table> ASSIGNING <fs_dyn_newline>.

  ENDIF.


ENDLOOP.