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: 

SAPSQL_IN_ITAB_ILL_STRUCTURE - Dump

Former Member
0 Kudos

Hi All,


The idea is to get count of schedule lines and max schedule line(delivery date) from VBEP using VBAP Sales document and item.


What is the best possible way with out using inner join ( I know that, I don't like to use it ), Is possible can any pointer the error. Why it is saying structure difference.


Below Program is dumping with SAPSQL_IN_ITAB_ILL_STRUCTURE at select statement


**********************************************************************

REPORT  ZTRAIN_01.

tables: vbap,vbep.

types: begin of st_vbep,

        vbeln type vbeln,

        posnr type posnr,

        c type     i,

        edatu type EDATU,

        end of st_vbep.

types: begin of st_vbap,

        vbeln type vbeln,

        posnr type posnr,

        end of st_vbap.

types: begin of st_vbap_vbeln,

        vbeln type vbeln,

        end of st_vbap_vbeln.

types: begin of st_vbap_posnr,

        posnr type posnr,

        end of st_vbap_posnr.

data: t_vbep TYPE sorted TABLE OF st_vbep WITH non-UNIQUE key vbeln posnr,

t_vbap type HASHED TABLE OF st_vbap with UNIQUE key vbeln posnr,

t_vbap_vbeln type STANDARD TABLE OF st_vbap_vbeln ,

wa_vbap_vbeln type st_vbap_vbeln,

wa_vbap_posnr type st_vbap_posnr,

t_vbap_posnr type STANDARD TABLE OF st_vbap_posnr ,

t_vbap_vbeln_o type RANGE OF st_vbap_vbeln ,

wa_vbap_vbeln_o  LIKE LINE OF t_vbap_vbeln_o,

t_vbap_posnr_o type RANGE OF st_vbap_posnr,

wa_vbap_posnr_o like line of t_vbap_posnr_o.

FIELD-SYMBOLS<fs_vbep> type st_vbep.

* get all sd document and item

select vbeln posnr

into TABLE t_vbap

from vbap.

" where clause -> only for test system -> production which have where condition.

* get two separate tables for vbeln and posnr

append LINES OF t_vbap to t_vbap_vbeln.

APPEND LINES OF t_vbap to t_vbap_posnr.

* delete duplicates for select statement

DELETE ADJACENT DUPLICATES FROM t_vbap_vbeln.

DELETE ADJACENT DUPLICATES FROM t_vbap_posnr.

* make range of vbeln for select .. in clause

   loop at t_vbap_vbeln into wa_vbap_vbeln.

       wa_vbap_vbeln_o-sign = 'I'.

       wa_vbap_vbeln_o-option = 'EQ'.

       wa_vbap_vbeln_o-low = wa_vbap_vbeln-vbeln.

       APPEND wa_vbap_vbeln_o TO t_vbap_vbeln_o.

   endloop.

* make range of posnr for select .. in clause

   loop at t_vbap_posnr into wa_vbap_posnr.

       wa_vbap_posnr_o-sign = 'I'.

       wa_vbap_posnr_o-option = 'EQ'.

       wa_vbap_posnr_o-low = wa_vbap_posnr-posnr.

       APPEND wa_vbap_posnr_o TO t_vbap_posnr_o.

   endloop.

select vbeln posnr count( DISTINCT ETENR ) as c max( EDATU )

into table t_vbep

from vbep

where vbeln in t_vbap_vbeln_o

and posnr in t_vbap_posnr_o

GROUP BY vbeln posnr.

loop at t_vbep ASSIGNING <fs_vbep>.

   write:/ <fs_vbep>-vbeln,<fs_vbep>-posnr,<fs_vbep>-c,<fs_vbep>-edatu.

endloop.


*********************************************************************


Regards,

Sandeep

1 REPLY 1

Former Member
0 Kudos

solved by changing the range type.

t_vbap_vbeln_o type range of vbap-vbeln ,

wa_vbap_vbeln_o  like line of t_vbap_vbeln_o,

t_vbap_posnr_o type range of vbap-posnr,


But still it dumps


Runtime Errors         DBIF_RSQL_INVALID_RSQL

Except.                CX_SY_OPEN_SQL_DB

The SQL statement generated from the SAP Open SQL statement violates a

restriction imposed by the underlying database system of the ABAP

system.

Possible error causes:

o The maximum size of an SQL statement was exceeded.

o The statement contains too many input variables.

o The input data requires more space than is available.

any best solution to achieve this. I cannot use sub query as there "for all entries in" in select statement is not allowed.

any help will be appreciated.

Regards,

Sandeep