Skip to Content

Question on type mismatch when using select query

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Apr 19, 2017 at 10: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

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 19, 2017 at 04: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.

    Add comment
    10|10000 characters needed 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

  • Apr 21, 2017 at 02: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

    Add comment
    10|10000 characters needed characters exceeded