Skip to Content
0
Former Member
Jun 13, 2016 at 11:21 AM

SAPSQL_IN_ITAB_ILL_STRUCTURE - Dump

253 Views

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