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

Question on type mismatch when using select query

Former Member
0 Likes
3,250

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,472

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

8 REPLIES 8
Read only

Former Member
0 Likes
2,473

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

Read only

0 Likes
2,472

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...

Read only

retired_member
Product and Topic Expert
Product and Topic Expert
2,472

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.

Read only

0 Likes
2,472

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

Read only

Sathya_Gunasekaran
Contributor
0 Likes
2,472

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

Read only

0 Likes
2,472

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

Read only

0 Likes
2,472

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 🙂

Read only

satyapriyanka_vana
Active Participant
0 Likes
2,472

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