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

Short Dump for Dynamic Select Query

former_member188001
Active Participant
0 Likes
1,426

Hello all,

I get a short dump for my dynamic select query at the end of the code. The error is "The types of operands "dbtab" and "itab" cannot be converted into one another."

My code looks like below.

FORM get_ccnum_2  USING    p_tabname TYPE dd03l-tabname.

DATA: p_table(30)  TYPE c.

  FIELD-SYMBOLS:  <dyn_wa>,
                               <t> TYPE table.
  DATA: it_fldcat    TYPE lvc_t_fcat.

  TYPE-POOLS : abap.

  DATA: it_details   TYPE abap_compdescr_tab,
        wa_details   TYPE abap_compdescr.

  DATA: ref_descr    TYPE REF TO cl_abap_structdescr.

  DATA: new_table    TYPE REF TO data,
        new_line     TYPE REF TO data,
        wa_it_fldcat TYPE lvc_s_fcat.


 p_table = p_tabname.

  ref_descr ?= cl_abap_typedescr=>describe_by_name( p_table ).
  it_details[] = ref_descr->components[].

  LOOP AT it_details INTO wa_details.
    CLEAR wa_it_fldcat.
    wa_it_fldcat-fieldname = wa_details-name .
    wa_it_fldcat-datatype  = wa_details-type_kind.
    wa_it_fldcat-intlen    = wa_details-length.
    wa_it_fldcat-decimals  = wa_details-decimals.

    APPEND wa_it_fldcat TO it_fldcat .
  ENDLOOP.


  CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
      it_fieldcatalog = it_fldcat
    IMPORTING
      ep_table        = new_table.

 ASSIGN new_table->* TO <t>.

 CREATE DATA new_line LIKE LINE OF <t>.
  ASSIGN new_line->* TO <dyn_wa>.

wa_cond = 'CCNUM <> '' '' '.
APPEND wa_cond TO tab_cond.

      SELECT * INTO TABLE <t>
               FROM     (p_table)
               WHERE    (tab_cond)
               ORDER BY (tab_ord).

ENDFORM.                    " GET_CCNUM_2

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,228

Hi,

I tried to execute the code using table BSEGC and it gave a short dump..

the actual exception that shows in ST22 IS ..UNICODE_TYPES_NOT_CONVERTIBLE..

I think there is something wrong in the internal table creation..

Instead of using the method cl_alv_table_create=>create_dynamic_table to create the dynamic table I used the following and it worked..

CREATE DATA new_table TYPE TABLE OF (p_table).

* Comment begin  " Naren
*  ref_descr ?= cl_abap_typedescr=>describe_by_name( p_table ).
*  it_details[] = ref_descr->components[].
*
*  LOOP AT it_details INTO wa_details.
*    CLEAR wa_it_fldcat.
*    wa_it_fldcat-fieldname = wa_details-name .
*    wa_it_fldcat-datatype  = wa_details-type_kind.
*    wa_it_fldcat-intlen    = wa_details-length.
*    wa_it_fldcat-decimals  = wa_details-decimals.
*
*    APPEND wa_it_fldcat TO it_fldcat .
*  ENDLOOP.
*
*
*  CALL METHOD cl_alv_table_create=>create_dynamic_table
*    EXPORTING
*      it_fieldcatalog = it_fldcat
*    IMPORTING
*      ep_table        = new_table.

* Comment End.  " Naren

 CREATE DATA new_table TYPE TABLE OF (p_table).   " New code by naren

Please Try this..

Thanks

Naren

Hi,

I tried to execute the code using table BSEGC and it gave a short dump..

the actual exception that shows in ST22 IS ..UNICODE_TYPES_NOT_CONVERTIBLE..

I think there is something wrong in the internal table creation..

Instead of using the method cl_alv_table_create=>create_dynamic_table to create the dynamic table I used the following and it worked..

CREATE DATA new_table TYPE TABLE OF (p_table).

* Comment begin  " Naren
*  ref_descr ?= cl_abap_typedescr=>describe_by_name( p_table ).
*  it_details[] = ref_descr->components[].
*
*  LOOP AT it_details INTO wa_details.
*    CLEAR wa_it_fldcat.
*    wa_it_fldcat-fieldname = wa_details-name .
*    wa_it_fldcat-datatype  = wa_details-type_kind.
*    wa_it_fldcat-intlen    = wa_details-length.
*    wa_it_fldcat-decimals  = wa_details-decimals.
*
*    APPEND wa_it_fldcat TO it_fldcat .
*  ENDLOOP.
*
*
*  CALL METHOD cl_alv_table_create=>create_dynamic_table
*    EXPORTING
*      it_fieldcatalog = it_fldcat
*    IMPORTING
*      ep_table        = new_table.

* Comment End.  " Naren

 CREATE DATA new_table TYPE TABLE OF (p_table).   " New code by naren

Please Try this..

Thanks

Naren

8 REPLIES 8
Read only

former_member194669
Active Contributor
0 Likes
1,228

Try to change the select


SELECT * INTO CORRESPONDING FIELDS OF TABLE <t>
               FROM     (p_table)
               WHERE    (tab_cond)
               ORDER BY (tab_ord).

Read only

0 Likes
1,228

still get the short dump.

Read only

0 Likes
1,228

I tried this using 2 different tables

1) The table with some records - The query worked perfectly

2) The table without any records - The query gave me shortdump.

The tables are dynamic, how can we know if the table are empty or not.

I inserted a vlaue in the empty table and executed the program again. I still get the shortdump.

Edited by: salil vaidya on Apr 1, 2009 4:07 PM

Read only

former_member194669
Active Contributor
0 Likes
1,228

May be try this way


       SELECT count(*) as v_cnt 
                FROM     (p_table)
                WHERE    (tab_cond)
                ORDER BY (tab_ord).
if v_cnt ne space.
  " Place your select dynamic select here
endif.

Read only

Former Member
0 Likes
1,229

Hi,

I tried to execute the code using table BSEGC and it gave a short dump..

the actual exception that shows in ST22 IS ..UNICODE_TYPES_NOT_CONVERTIBLE..

I think there is something wrong in the internal table creation..

Instead of using the method cl_alv_table_create=>create_dynamic_table to create the dynamic table I used the following and it worked..

CREATE DATA new_table TYPE TABLE OF (p_table).

* Comment begin  " Naren
*  ref_descr ?= cl_abap_typedescr=>describe_by_name( p_table ).
*  it_details[] = ref_descr->components[].
*
*  LOOP AT it_details INTO wa_details.
*    CLEAR wa_it_fldcat.
*    wa_it_fldcat-fieldname = wa_details-name .
*    wa_it_fldcat-datatype  = wa_details-type_kind.
*    wa_it_fldcat-intlen    = wa_details-length.
*    wa_it_fldcat-decimals  = wa_details-decimals.
*
*    APPEND wa_it_fldcat TO it_fldcat .
*  ENDLOOP.
*
*
*  CALL METHOD cl_alv_table_create=>create_dynamic_table
*    EXPORTING
*      it_fieldcatalog = it_fldcat
*    IMPORTING
*      ep_table        = new_table.

* Comment End.  " Naren

 CREATE DATA new_table TYPE TABLE OF (p_table).   " New code by naren

Please Try this..

Thanks

Naren

Read only

0 Likes
1,228

Perfect. It worked. Thanks a lot Naren.

Read only

0 Likes
1,228

Try as Naren mentioned or


  call function 'LVC_FIELDCATALOG_MERGE'
    exporting
      i_structure_name       = p_table
      i_client_never_display = 'X'
    changing
      ct_fieldcat            = it_fldcat[].

  CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
      it_fieldcatalog = it_fldcat
    IMPORTING
      ep_table        = new_table.
 
 ASSIGN new_table->* TO <t>.
 
 CREATE DATA new_line LIKE LINE OF <t>.
  ASSIGN new_line->* TO <dyn_wa>.

Read only

0 Likes
1,228

Thanks. This also works.