ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Problem passing numeric parameters to STRQMQRY

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem passing numeric parameters to STRQMQRY

    I have inheirited a situation where there is lots of old code and lots of Query/400 reports.
    I am trying to convert the ones that need a date changed each month. I have converted the query400 and I have confirmed the year and month fields are two digit numeric in the original query400.


    I set up a CL program to run STRQMQRY but I am having trouble passing the parameters. When I try to pass numeric, that is not allowed. When I try to pass alpha, I get "the first character is not alphabetic". So I'm damned if I do and damned if I don't.


    The variables


    DCL VAR(&YEAR) TYPE(*CHAR) LEN(2)
    DCL VAR(&MONTH) TYPE(*CHAR) LEN(2)
    CHGVAR &YEAR '18'
    CHGVAR &MONTH '02'

    The query

    STRQMQRY QMQRY(AS400LIB/FLINVCOM) OUTPUT(*OUTFILE) +
    OUTFILE(QTEMP/FLINVCOM) SETVAR((TAGDTY) +
    (&YEAR) (TAGDTM) (&MONTH))


    the error:

    CALL FLINVCOM
    1900 - RTVJOBA JOB(&WRKSTN)
    2400 - SNDRCVF DEV(*FILE) RCDFMT(WELLMAN1) WAIT(*YES) OPNID(*NONE)
    /* File name is SHREV90FM. */
    2700 - STRQMQRY QMQRY(AS400LIB/FLINVCOM) OUTPUT(*OUTFILE)
    OUTFILE(QTEMP/FLINVCOM) SETVAR((TAGDTY) ('18') (TAGDTM) ('02'))
    18 is not a valid Query Management variable.
    Error found on STRQMQRY command.
    Message ID . . . . . . : QWM1937 Severity . . . . . . . : 40
    Message type . . . . . : Diagnostic
    Date sent . . . . . . : 03/09/18 Time sent . . . . . . : 10:58:21

    Message . . . . : 18 is not a valid Query Management variable.
    Cause . . . . . : The 18 variable entered on the SETVAR parameter contains a
    value which is not valid. The return code is 1.
    The following return codes are possible:

    1 - The first character is not alphabetic.
    2 - One of the remaining characters is not alphanumeric or an '_'.
    3 - The variable begins with 'DSQ'. A variable that begins with 'DSQ'
    cannot be used from the SETVAR parameter.

    And just for fun, here is the converted query400

    H QM4 05 Q 01 E V W E R 01 03 18/03/09 10:40
    V 1001 050 Mthly Frtlr Inv for TW - Shipped
    V 5001 004 *HEX
    SELECT
    ALL A.NEWPRTNO, A.INVNO, A.CUST, A.TAGDTM, A.TAGDTD, A.TAGDTY,
    (A.INVSLS), COMPCT*100 AS CALCCOM, (((INVSLS*COMPCT))),
    SUBSTR(LNCMT4,35,25) AS PC_PRICE, O.LPRICE
    FROM QS36F/LIBMIR A CROSS JOIN
    AS400LIB/LSPPTCM P CROSS JOIN
    QS36F/LIBOCO O
    WHERE A.NEWPRTNO = P.PARTNO
    AND A.ORDNUM = O.ORDNUM
    AND A.RECSEQ = O.RECSEQ
    AND( A.DELTAG = ' '
    AND INVWGT > 0
    AND TAGDTY = &YEAR
    AND TAGDTM = &MONTH
    AND INVSLS >= .01
    AND A.CUST IN (01439, 01695, 03252, 03680, 03681, 03682, 03683, 03684,
    03685, 03686, 03687, 03688, 03689, 03690, 03691, 03692, 03693,
    03694, 03695, 03696, 03697, 03698, 03699, 03700, 03701, 03702,
    03703, 03704, 03705, 03706, 03707, 03708, 03709, 03710, 03711,
    03712, 03713, 05928, 05929, 05933, 09505, 09506, 09507, 09508,
    09509, 09510, 09511, 03714, 03715))
    ORDER BY 001 ASC, 008 ASC, 002 ASC, 003 ASC






Working...
X