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: 

Exception CX_SY_OPEN_SQL_DB within Select statement with JOIN

Former Member
0 Kudos

Hi,

I have a problem with a select statement. The exception CX_SY_OPEN_SQL_DB" is raised.

Below you can see my coding. Within the range for the AWKEY I have only one single entry. Therefore there should not be too many values within the where condition. What else can be wrong?


TYPES: BEGIN OF mm_fi_inv_join,
    bukrs TYPE bukrs,
    belnr TYPE belnr,
    gjahr TYPE gjahr,
    koart TYPE koart,
    augdt TYPE augdt,
    augbl TYPE augbl,
    END OF mm_fi_inv_join.

 

 

  FIELD-SYMBOLS: <lt_mm_fi_inv>     TYPE ANY TABLE.

 

  DATA: lt_mm_fi_inv            TYPE REF TO data.


CREATE DATA lt_mm_fi_inv TYPE TABLE OF mm_fi_inv_join.
  ASSIGN lt_mm_fi_inv->* TO <lt_mm_fi_inv>.

  SELECT bkpf~bukrs bkpf~belnr bkpf~gjahr bsak~augdt bsak~augbl
    FROM bkpf
      INNER JOIN bsak
    ON bkpf~bukrs = bsak~bukrs
    AND bkpf~belnr = bsak~belnr
    AND bkpf~gjahr = bsak~gjahr
    INTO CORRESPONDING FIELDS OF TABLE <lt_mm_fi_inv>
    WHERE bkpf~awkey IN lr_awkey.


Thanks and Regards

Tom

4 REPLIES 4

Former Member
0 Kudos

Hi

The error is in the definition of your type MM_FI_INV_JOIN: the type BELNR is a structure, the data element of field BKPF-BELNR is BELNR_D

TYPES: BEGIN OF MM_FI_INV_JOIN,
    BUKRS TYPE BUKRS,
*    BELNR TYPE BELNR,
    BELNR TYPE BELNR_D,  "<------Right Definition
    GJAHR TYPE GJAHR,
    KOART TYPE KOART,
    AUGDT TYPE AUGDT,
    AUGBL TYPE AUGBL,
    END OF MM_FI_INV_JOIN..

Max

0 Kudos

Hi Tom,

yes, as max said. Just one small hint that never hurts:

You are always better of to use the table field reference when typing fields, i.e.

TYPES: 
    BEGIN OF MM_FI_INV_JOIN,
    BUKRS TYPE BKPF-BUKRS,
    BELNR TYPE BKPF-BELNR,
    GJAHR TYPE BKPF-GJAHR,
    KOART TYPE BSEG-KOART,
    AUGDT TYPE BSAK-AUGDT,
    AUGBL TYPE BSAK-AUGBL,
    END OF MM_FI_INV_JOIN.

If you do it this way, there is no danger at all and you gain some transparency.

Regards

Clemens

Former Member
0 Kudos

Thanks a lot for the hint. This was exactly my problem.

Regards

Thomas

0 Kudos

So close the post

Max