Skip to Content
0

Question on type mismatch when using select query

Apr 19, 2017 at 08:25 AM

146

avatar image

Hi Experts,

I am fetching freight class (GTKLS) from TGAAR table based on material group as shown below

SELECT garvz gtart gtkls
FROM tgar
INTO TABLE i_tgar
FOR ALL ENTRIES IN xlips
WHERE gtart = xlips-matkl
AND garvz = 'NMFTC'.

The above query basically gives me a syntax error as type mismatch because XLIPS-MATKL has CHAR9 and TGAR gatrt has CHAR12.

The solution I am using to avoid type mismatch is as below.

TYPES: BEGIN OF t_lips_temp,
vbeln TYPE vbeln_vl,
posnr TYPE posnr_vl,
gtart TYPE gtart,
END OF t_lips_temp.

data: w_lips_temp TYPE t_lips_temp,

i_lips_temp TYPE STANDARD TABLE OF t_lips_temp.


* Loop the delivery table and create temp table
LOOP AT xlips.
w_lips_temp-vbeln = xlips-vbeln.
w_lips_temp-posnr = xlips-posnr.
w_lips_temp-gtart = xlips-matkl.
APPEND w_lips_temp TO i_lips_temp.
ENDLOOP.

SELECT garvz gtart gtkls
FROM tgar
INTO TABLE i_tgar
FOR ALL ENTRIES IN i_lips_temp
WHERE gtart = i_lips_temp-gtart
AND garvz = 'NMFTC'.

I am looking for the best way to avoid type mismatch .Can any one please suggest any other best alternative apart from this.

Thanks,

rg

10 |10000 characters needed characters left characters exceeded

Will there be any problem if we define xlips-matkl as 'char12'?

0
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
avatar image
Former Member Apr 19, 2017 at 10:01 AM
0

Hi Ramya

You can declare a range: RANGES r_gtart for gtart. then append data from field table xlips-matkl to the range.

SELECT garvz gtart gtkls
FROM tgar
INTO TABLE i_tgar
WHERE gtart in r_gtart " fiter be here.

AND garvz = 'NMFTC'.

Thanks,

John

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

if you use range table just make sure that data you are going to fill in the range table doesn't cause dump

https://blogs.sap.com/2012/03/26/the-answer-to-the-question-so-why-do-i-get-a-shortdump-when-i-enter-lots-of-select-options

0
Horst Keller
Apr 19, 2017 at 04:20 PM
1

Can't you use a join expression instead of FOR ALL ENTRIES? Opens up the possibility of ÇAST expressions (in recent releases), which can't be combined with FOR ALL ENTRIES.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Horst,

Thanks for your reply.

No I cant use join in this scenario, Because I am fetching entries from TGAR table based on entries in XLIPS and XLIPS is an internal table and this is filled dynamically when the delievry is getting created.

Please suggest alternative solution.

Thanks,

rg

0
Sathya Gunasekaran Apr 21, 2017 at 02:22 PM
0

Hi Ramya,

Though it is not a complete alternate, If you are on NetWeaer 7.4 or above, instead of looping at xlips, you can sue the below syntax

i_lips_temp = corresponding #(xlips) and proceed further.

Sathya

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Hi Sathya,

Thanks for your reply . We are at version 7.2 so we cannot use the solution mentioned by you .

Any how your answer looks interesting . Can you please elaborate your answer how you are filling I_LIPS_TEMP without using loop for XLIPS.

rg

0

Sorry for the delay. SAP have introduced lots of simplified syntaxes in version 7.4 and 7.5

i_lips_temp = corresponding #(xlips) will move the matching columns to the temp table :)

0