‎2017 Apr 19 9:25 AM
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
‎2017 Apr 19 11:01 AM
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
‎2017 Apr 19 11:01 AM
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
‎2017 Apr 19 4:50 PM
if you use range table just make sure that data you are going to fill in the range table doesn't cause dump
‎2017 Apr 19 5:20 PM
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.
‎2017 Apr 21 1:14 PM
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
‎2017 Apr 21 3:22 PM
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
‎2017 Apr 22 9:31 AM
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
‎2017 Jul 07 9:47 AM
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 🙂
‎2017 Jul 07 9:57 AM
Will there be any problem if we define xlips-matkl as 'char12'?