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

dynamic select statements

Rushikesh_Yeole
Contributor
0 Likes
889

PARAMETERS: p_table LIKE dd02t-tabname OBLIGATORY.

SELECT *

FROM (p_table) CLIENT SPECIFIED

INTO CORRESPONDING FIELDS OF TABLE <dyn_table>

WHERE mandt = '800'.

mandt is the system client number as 800.

dyn_table: dynamic internal table

p_table = mara.

runtime error occurs at this statement.

SQL error in the database when accessing a table.

Kindly guide.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
816

Hello

It is Basis Related Error.

Your code written without errors. It working fine for me (I have tested).

5 REPLIES 5
Read only

Rushikesh_Yeole
Contributor
0 Likes
816

Dump details:

Database error text........: "CLI0111E Numeric value out of range.

SQLSTATE=22003 row=1 col=30"

Internal call code.........: "[RSQL/FTCH/MARA ]"

"DBIF_RSQL_SQL_ERROR" "CX_SY_OPEN_SQL_DB"

Read only

Former Member
0 Likes
816

Hi,

can You also post a code for creation of <dyn_table>. There is probably an error in this internal table.

Regards,

Adrian

Read only

0 Likes
816

ref_table_des ?=

cl_abap_typedescr=>describe_by_name( p_table ).

idetails[] = ref_table_des->components[].

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.

DATA : idetails TYPE abap_compdescr_tab,

xdetails TYPE abap_compdescr.

DATA : ref_table_des TYPE REF TO cl_abap_structdescr.

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.

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 DATA dy_line LIKE LINE OF <dyn_table>.

ASSIGN dy_line->* TO <dyn_wa>.

Read only

0 Likes
816

Try

CASE xdetails-type_kind.
      WHEN 'C'.
        xfc-datatype = 'CHAR'.
      WHEN 'N'.
        xfc-datatype = 'NUMC'.
      WHEN 'D'.
        xfc-datatype = 'DATE'.
      WHEN 'P'.
        xfc-datatype = 'PACK'.
      WHEN OTHERS.
        xfc-datatype = xdetails-type_kind.
    ENDCASE.

instead of

xfc-datatype = xdetails-type_kind.

You can also check this link:

http://wiki.sdn.sap.com/wiki/display/ABAP/DynamicInternaltable

Or try to do it like this:

http://wiki.sdn.sap.com/wiki/display/Snippets/Howtocreateadinamicinternaltable

It means to use FM REUSE_ALV_FIELDCATALOG_MERGE instead of using cl_abap_typedescr.

Adrian

Read only

Former Member
0 Likes
817

Hello

It is Basis Related Error.

Your code written without errors. It working fine for me (I have tested).