Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

ECC 6.0 internal table dump

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

Tags:
replied
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 View this answer in context
Not what you were looking for? View more on this topic or Ask a question