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

Dump in copying the internal table data

Former Member
0 Likes
432

Hi Experts,

i need to get the data from DB table T005 to t_t005.

And i want to copy the t_t005 data to created dynamic table <dyn_table>.

Please refer the below code.

i am getting dump at statement of below code APPEND <dyn_wa> TO <dyn_table>.

could you pleaes help to resolve the issue. it will appriciated.

Please correct the below code.

Thanks,

Chand

REPORT ytest_itab.

DATA: fp_struct TYPE swotddic-tabname VALUE 'T005'.

DATA: new_table TYPE REF TO data.

FIELD-SYMBOLS:

<dyn_table> TYPE STANDARD TABLE,

<dyn_wa> type any.

DATA: new_line TYPE REF TO data.

DATA: it_dy_table TYPE TABLE OF swotddic,

w_dy_table TYPE swotddic,

it_fldcat TYPE lvc_t_fcat,

w_t_fldcat TYPE LINE OF lvc_t_fcat.

CALL FUNCTION 'SWC_DDIC_QUERY_TABLE_FIELDS'

EXPORTING

language = sy-langu

tabname = fp_struct

  • text = 'Table'

TABLES

nametab = it_dy_table.

SORT it_dy_table BY position.

*

REFRESH : it_fldcat.

LOOP AT it_dy_table INTO w_dy_table.

w_t_fldcat-fieldname = w_dy_table-fieldname.

w_t_fldcat-datatype = w_dy_table-datatype.

w_t_fldcat-outputlen = w_dy_table-outlength.

w_t_fldcat-intlen = w_dy_table-intlength.

w_t_fldcat-inttype = w_dy_table-intatype.

w_t_fldcat-decimals = w_dy_table-decimals.

APPEND w_t_fldcat TO it_fldcat.

ENDLOOP.

*

  • Create dynamic internal table and assign to FS

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = it_fldcat

i_length_in_byte = 'X'

IMPORTING

ep_table = new_table.

ASSIGN new_table->* TO <dyn_table>.

  • Create dynamic work area and assign to FS

CREATE DATA new_line LIKE LINE OF <dyn_table>.

ASSIGN new_line->* TO <dyn_wa>.

*----


DATA: t_t005 TYPE TABLE OF t005 WITH HEADER LINE,

lv_index TYPE i.

SELECT * FROM t005 INTO TABLE t_t005.

FIELD-SYMBOLS: <l_field> TYPE ANY.

FIELD-SYMBOLS:

<lfs1>,

<lfs2>,

<ldyn_field>,

<wa_too5>.

LOOP AT t_t005 assigning <dyn_wa>.

LOOP AT it_dy_table INTO w_dy_table.

ASSIGN COMPONENT w_dy_table-fieldname OF STRUCTURE

<dyn_wa> TO <lfs1>.

ENDLOOP.

APPEND <dyn_wa> TO <dyn_table>.

ENDLOOP.

Hi Experts,

i need to get the data from DB table T005 to t_t005.

And i want to copy the t_t005 data to created dynamic table <dyn_table>.

Please refer the below code.

i am getting dump at statement of below code APPEND <dyn_wa> TO <dyn_table>.

could you pleaes help to resolve the issue. it will appriciated.

Please correct the below code.

Thanks,

Chand

REPORT ytest_itab.

DATA: fp_struct TYPE swotddic-tabname VALUE 'T005'.

DATA: new_table TYPE REF TO data.

FIELD-SYMBOLS:

<dyn_table> TYPE STANDARD TABLE,

<dyn_wa> type any.

DATA: new_line TYPE REF TO data.

DATA: it_dy_table TYPE TABLE OF swotddic,

w_dy_table TYPE swotddic,

it_fldcat TYPE lvc_t_fcat,

w_t_fldcat TYPE LINE OF lvc_t_fcat.

CALL FUNCTION 'SWC_DDIC_QUERY_TABLE_FIELDS'

EXPORTING

language = sy-langu

tabname = fp_struct

  • text = 'Table'

TABLES

nametab = it_dy_table.

SORT it_dy_table BY position.

*

REFRESH : it_fldcat.

LOOP AT it_dy_table INTO w_dy_table.

w_t_fldcat-fieldname = w_dy_table-fieldname.

w_t_fldcat-datatype = w_dy_table-datatype.

w_t_fldcat-outputlen = w_dy_table-outlength.

w_t_fldcat-intlen = w_dy_table-intlength.

w_t_fldcat-inttype = w_dy_table-intatype.

w_t_fldcat-decimals = w_dy_table-decimals.

APPEND w_t_fldcat TO it_fldcat.

ENDLOOP.

*

  • Create dynamic internal table and assign to FS

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = it_fldcat

i_length_in_byte = 'X'

IMPORTING

ep_table = new_table.

ASSIGN new_table->* TO <dyn_table>.

  • Create dynamic work area and assign to FS

CREATE DATA new_line LIKE LINE OF <dyn_table>.

ASSIGN new_line->* TO <dyn_wa>.

*----


DATA: t_t005 TYPE TABLE OF t005 WITH HEADER LINE,

lv_index TYPE i.

SELECT * FROM t005 INTO TABLE t_t005.

FIELD-SYMBOLS: <l_field> TYPE ANY.

FIELD-SYMBOLS:

<lfs1>,

<lfs2>,

<ldyn_field>,

<wa_too5>.

LOOP AT t_t005 assigning <dyn_wa>.

LOOP AT it_dy_table INTO w_dy_table.

ASSIGN COMPONENT w_dy_table-fieldname OF STRUCTURE

<dyn_wa> TO <lfs1>.

ENDLOOP.

APPEND <dyn_wa> TO <dyn_table>.

ENDLOOP.

1 REPLY 1
Read only

raviprakash
Product and Topic Expert
Product and Topic Expert
0 Likes
397

Hi shiak chand,

This happens due to the unicode incompatiblity. The method cl_alv_table_create=>create_dynamic_table converts the CLIENT Field of length 3 to Char 6. Thus there is a mismatch in the length of the structure <dyn_wa> and line structure of <dyn_table>.

To correct this please replace the code:-



LOOP AT t_t005 assigning <dyn_wa>.
 
         LOOP AT it_dy_table INTO w_dy_table.
           ASSIGN COMPONENT w_dy_table-fieldname OF STRUCTURE
                                             <dyn_wa> TO  <lfs1>.
 
         ENDLOOP.
 
   APPEND <dyn_wa> TO <dyn_table>.
 ENDLOOP.

with:-

LOOP AT t_t005." ASSIGNING <dyn_wa>.

  LOOP AT it_dy_table INTO w_dy_table.
    ASSIGN COMPONENT w_dy_table-fieldname OF STRUCTURE
    <dyn_wa> TO <lfs1>.

  ENDLOOP.

  MOVE-CORRESPONDING t_t005 TO <dyn_wa>.
  APPEND <dyn_wa> TO <dyn_table>.
ENDLOOP.

Many Regards,

Ravi.