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: 

ECC 6.0 internal table dump

Former Member
0 Kudos

Hi,

I am passing a database table from selection screen(Eg T001) and build dynamic internal table and get the data from table and put into dynamic internal table.

I am getting dump in below code.

LOOP AT <dyn_table> INTO <dyn_wa>.

wa_result-line = <dyn_wa>.

APPEND wa_result TO i_result.

CLEAR wa_result.

ENDLOOP.

Can anybody please execute the below progra and try to help me to put data into normal internal table i_result from dynamic internal table.

Full points will be given to useful answer.

Thanks in advance for your help.

Thanks and Regards,

Suresh.

******************************************************************

REPORT Z_dynamic_internal_table.

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.

TYPES: BEGIN OF t_result,

line(1024) TYPE c,

END OF t_result.

DATA: i_result TYPE TABLE OF t_result,

wa_result TYPE t_result.

DATA: tablename(16) TYPE c.

DATA: cond(80) TYPE c.

PARAMETERS: tabnam(8) TYPE c.

tablename = tabnam.

PERFORM get_structure USING tablename.

PERFORM create_dynamic_itab USING tablename.

PERFORM get_data USING tablename cond.

PERFORM write_out USING tablename.

&----


*& Form get_structure

&----


  • text

----


FORM get_structure USING tablename.

DATA : idetails TYPE abap_compdescr_tab,

xdetails TYPE abap_compdescr.

DATA : ref_table_des TYPE REF TO cl_abap_structdescr.

ref_table_des ?=

cl_abap_typedescr=>describe_by_name( tablename ).

idetails[] = ref_table_des->components[].

LOOP AT idetails INTO xdetails.

CLEAR xfc.

xfc-fieldname = xdetails-name .

xfc-datatype = xdetails-type_kind.

xfc-inttype = xdetails-type_kind.

xfc-intlen = xdetails-length.

xfc-decimals = xdetails-decimals.

APPEND xfc TO ifc.

ENDLOOP.

ENDFORM. "get_structure

&----


*& Form create_dynamic_itab

&----


  • text

----


FORM create_dynamic_itab USING tablename.

*----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.

CREATE DATA dy_table TYPE STANDARD TABLE OF (tablename).

ASSIGN dy_table->* TO <dyn_table>.

*----Create dynamic work area and assign to fs

CREATE DATA dy_line TYPE (tablename).

ASSIGN dy_line->* TO <dyn_wa>.

ENDFORM. "create_dynamic_itab

&----


*& Form get_data

&----


  • text

----


FORM get_data USING tablename cond.

*----Select data from table. .

SELECT * INTO CORRESPONDING FIELDS OF TABLE <dyn_table>

FROM (tablename) WHERE (cond).

ENDFORM. "get_data

&----


*& Form WRITE_OUT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM write_out USING tablename .

LOOP AT <dyn_table> INTO <dyn_wa>.

wa_result-line = <dyn_wa>.

APPEND wa_result TO i_result.

CLEAR wa_result.

ENDLOOP.

ENDFORM. " WRITE_OUT

1 ACCEPTED SOLUTION

former_member188685
Active Contributor
0 Kudos
LOOP AT <dyn_table> INTO <dyn_wa>.
wa_result-line = <dyn_wa>.  "error is from this line
APPEND wa_result TO i_result.
CLEAR wa_result.
ENDLOOP.

if there is quantity /currency fields then you will get dump. if you have only character fields then it works.

to avoid that you may have to concatenate all the fields and move to line.

corrected code.

FORM write_out USING tablename .
field-symbols: <fs> type any.
data: text(20).
LOOP AT <dyn_table> INTO <dyn_wa>.
do.

assign component sy-index of structure <dyn_Wa> to <fs>.
if sy-subrc ne 0.
 exit.
endif.
write <fs> to text.
concatenate wa_result-line text into wa_result-line.
*move <dyn_wa> to wa_result-line.
enddo.
APPEND wa_result TO i_result.
CLEAR wa_result.
ENDLOOP.
ENDFORM. " WRITE_OUT

3 REPLIES 3

former_member188685
Active Contributor
0 Kudos
LOOP AT <dyn_table> INTO <dyn_wa>.
wa_result-line = <dyn_wa>.  "error is from this line
APPEND wa_result TO i_result.
CLEAR wa_result.
ENDLOOP.

if there is quantity /currency fields then you will get dump. if you have only character fields then it works.

to avoid that you may have to concatenate all the fields and move to line.

corrected code.

FORM write_out USING tablename .
field-symbols: <fs> type any.
data: text(20).
LOOP AT <dyn_table> INTO <dyn_wa>.
do.

assign component sy-index of structure <dyn_Wa> to <fs>.
if sy-subrc ne 0.
 exit.
endif.
write <fs> to text.
concatenate wa_result-line text into wa_result-line.
*move <dyn_wa> to wa_result-line.
enddo.
APPEND wa_result TO i_result.
CLEAR wa_result.
ENDLOOP.
ENDFORM. " WRITE_OUT

0 Kudos

Hi Vijay,

Thanks for your help. With your code I can populating data into internal table. Now I will check how to solve my problem.

As I promised I am giving full points to your answer.

Thanks again.

Thanks and Regards,

Suresh

Former Member
0 Kudos

Hi,

Check the below code, it may be useful.

data:it_grnchk TYPE TABLE OF ty_grnchk WITH NON-UNIQUE KEY mblnr_i bwart_i.

FIELD-SYMBOLS: <l_table> TYPE STANDARD TABLE,

<l_line> TYPE ANY,<wa_grn> TYPE ty_grnchk, <l_field> TYPE ANY,

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

  • I_STYLE_TABLE =

it_fieldcatalog = it_fcat

  • I_LENGTH_IN_BYTE =

IMPORTING

EP_TABLE = new_table

  • E_STYLE_FNAME =

  • EXCEPTIONS

  • GENERATE_SUBPOOL_DIR_FULL = 1

  • others = 2

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ASSIGN new_table->* TO <l_table>.

CREATE DATA new_line LIKE LINE OF <l_table>.

ASSIGN new_line->* TO <l_line>.

ASSIGN new_line->* TO <t_line>.

***********assigning dynamic Internal table vlaues to normal internal table

LOOP AT <l_table> INTO <l_line>.

ASSIGN COMPONENT sy-index OF STRUCTURE <l_line> TO <l_field>.

MOVE-CORRESPONDING <l_field> TO <wa_grn>.

APPEND <wa_grn> TO it_grnchk.

ENDLOOP.

IF useful.......................

Regards,

S.Senthil kumar