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

Dynamical SELECT on MARD

Former Member
0 Likes
1,144

Hi,

I use the program (see below) to copy tables. It works for many tables but not for large tables like MARD.

It generates a dump : SAPSQL_SELECT_TAB_TOO_SMALL

Can anyone help me ?

Thanks

Marie

TYPE-POOLS : abap.

TABLES : dd02l.

FIELD-SYMBOLS:

<dyn_table> TYPE ANY TABLE,

<dyn_wa>,

<dyn_field>,

<component> TYPE abap_compdescr.

DATA:

dy_table TYPE REF TO data,

dy_line TYPE REF TO data,

xfc TYPE lvc_s_fcat,

ifc TYPE lvc_t_fcat.

DATA : d_table LIKE dd02l-tabname.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.

SELECT-OPTIONS: s_table FOR dd02l-tabname NO INTERVALS.

SELECTION-SCREEN END OF BLOCK b1.

START-OF-SELECTION.

LOOP AT s_table.

IF NOT s_table-low IS INITIAL.

CONCATENATE 'ZDFI' s_table-low INTO d_table.

PERFORM f100_get_structure USING s_table-low.

PERFORM f200_create_dynamic_itab.

*********Creates a dyanamic internal table*********

PERFORM f300_get_data USING s_table-low.

PERFORM f400_write_out USING s_table-low.

ENDIF.

ENDLOOP.

----


  • FORM get_structure *

----


  • ........ *

----


FORM f100_get_structure USING p_table LIKE dd02l-tabname.

DATA : idetails TYPE abap_compdescr_tab,

xdetails TYPE abap_compdescr.

DATA : ref_table_des TYPE REF TO cl_abap_structdescr.

  • Get the structure of the table.

ref_table_des ?= cl_abap_typedescr=>describe_by_name( p_table ).

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.

----


  • FORM create_dynamic_itab *

----


  • ........ *

----


FORM f200_create_dynamic_itab.

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

ASSIGN dy_table->* TO <dyn_table>.

  • Create dynamic work area and assign to FS

CREATE DATA dy_line LIKE LINE OF <dyn_table>.

ASSIGN dy_line->* TO <dyn_wa>.

ENDFORM.

----


  • FORM create_dynamic_itab *

----


  • ........ *

----


FORM f210_create_dynamic_itab.

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

ENDFORM.

----


  • FORM get_data *

----


  • ........ *

----


FORM f300_get_data USING p_table LIKE dd02l-tabname.

  • Select Data from table.

SELECT * INTO TABLE <dyn_table>

FROM (p_table).

ENDFORM.

----


  • FORM write_out *

----


  • ........ *

----


  • Write out data from table.

FORM f400_write_out USING p_table LIKE dd02l-tabname.

DELETE FROM (d_table)

WHERE mandt = sy-mandt.

INSERT (d_table) FROM TABLE <dyn_table>.

ENDFORM.

Edited by: Marie VELAY on Apr 15, 2008 3:11 PM

Hi,

I use the program (see below) to copy tables. It works for many tables but not for large tables like MARD.

It generates a dump : SAPSQL_SELECT_TAB_TOO_SMALL

Can anyone help me ?

Thanks

Marie

TYPE-POOLS : abap.

TABLES : dd02l.

FIELD-SYMBOLS:

<dyn_table> TYPE ANY TABLE,

<dyn_wa>,

<dyn_field>,

<component> TYPE abap_compdescr.

DATA:

dy_table TYPE REF TO data,

dy_line TYPE REF TO data,

xfc TYPE lvc_s_fcat,

ifc TYPE lvc_t_fcat.

DATA : d_table LIKE dd02l-tabname.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.

SELECT-OPTIONS: s_table FOR dd02l-tabname NO INTERVALS.

SELECTION-SCREEN END OF BLOCK b1.

START-OF-SELECTION.

LOOP AT s_table.

IF NOT s_table-low IS INITIAL.

CONCATENATE 'ZDFI' s_table-low INTO d_table.

PERFORM f100_get_structure USING s_table-low.

PERFORM f200_create_dynamic_itab.

*********Creates a dyanamic internal table*********

PERFORM f300_get_data USING s_table-low.

PERFORM f400_write_out USING s_table-low.

ENDIF.

ENDLOOP.

----


  • FORM get_structure *

----


  • ........ *

----


FORM f100_get_structure USING p_table LIKE dd02l-tabname.

DATA : idetails TYPE abap_compdescr_tab,

xdetails TYPE abap_compdescr.

DATA : ref_table_des TYPE REF TO cl_abap_structdescr.

  • Get the structure of the table.

ref_table_des ?= cl_abap_typedescr=>describe_by_name( p_table ).

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.

----


  • FORM create_dynamic_itab *

----


  • ........ *

----


FORM f200_create_dynamic_itab.

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

ASSIGN dy_table->* TO <dyn_table>.

  • Create dynamic work area and assign to FS

CREATE DATA dy_line LIKE LINE OF <dyn_table>.

ASSIGN dy_line->* TO <dyn_wa>.

ENDFORM.

----


  • FORM create_dynamic_itab *

----


  • ........ *

----


FORM f210_create_dynamic_itab.

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

ENDFORM.

----


  • FORM get_data *

----


  • ........ *

----


FORM f300_get_data USING p_table LIKE dd02l-tabname.

  • Select Data from table.

SELECT * INTO TABLE <dyn_table>

FROM (p_table).

ENDFORM.

----


  • FORM write_out *

----


  • ........ *

----


  • Write out data from table.

FORM f400_write_out USING p_table LIKE dd02l-tabname.

DELETE FROM (d_table)

WHERE mandt = sy-mandt.

INSERT (d_table) FROM TABLE <dyn_table>.

ENDFORM.

Edited by: Marie VELAY on Apr 15, 2008 3:11 PM

8 REPLIES 8
Read only

Former Member
0 Likes
1,034

Have a look at my posting in this thread:

Read only

0 Likes
1,034

The dump arrives when I try to fill the table. The Dump concern the SELECT statement.

And for declaration and creation, I cannot use this line :

gr_tabledescr ?= cl_abap_tabledescr=>create( gr_structdest ).

The class cl_abap_tabledescr doesn't have it.

Is there any other soution ?

Edited by: Marie VELAY on Apr 15, 2008 3:28 PM

Read only

0 Likes
1,034

You may also do it this way:


DATA:
  gr_dref_t TYPE REF TO data,
  gr_dref_w TYPE REF TO data.

FIELD-SYMBOLS:
  <gt_data> TYPE ANY TABLE,
  <gw_data> TYPE ANY.

PARAMETERS:
  p_tabn    TYPE tabname OBLIGATORY.


START-OF-SELECTION.

  CREATE DATA gr_dref_w TYPE (p_tabn).
  ASSIGN gr_dref_w->* TO <gw_data>.

  CREATE DATA gr_dref_t LIKE TABLE OF <gw_data>.
  ASSIGN gr_dref_t->* TO <gt_data>.

  SELECT *
    FROM (p_tabn)
    INTO TABLE <gt_data>.

<REMOVED BY MODERATOR>

Edited by: Alvaro Tejada Galindo on Apr 15, 2008 11:32 AM

Read only

0 Likes
1,034

Erf....

CREATE DATA gr_dref_t LIKE TABLE OF <gw_data>.

this line doesn't compile. I work on 4.6C version ; I think that's why some functions are missing...

Thanks for your help !

Read only

0 Likes
1,034

Unfortunately, i don´t have access to a system of release 4.6c, but try this instead:


CREATE DATA gr_dref_t TYPE STANDARD TABLE OF (p_tabn).

Read only

0 Likes
1,034

Not allowed again...

I think I'll find another solution

...... and begin waiting an upgrade !

Many thanks for your help !

Read only

0 Likes
1,034

hi,

try this

SELECT * INTO CORRESPONDING FIELDS OF TABLE <dyn_table>

FROM (p_table).

ENDFORM.

instead of

SELECT * INTO TABLE <dyn_table>

FROM (p_table).

ENDFORM.

Regards, Dieter

Read only

0 Likes
1,034

Thanks, it's solving a part of the problem : I can now execute the select statement for MARD.

But the dynamic table created is a table 280 octet long (origin of the problem, it seems that I cannot go higher than 280) , and MARD needs 288 octets long...

so I cannot do the INSERT at the end of the program...