Problem with parameters from RPGIV to CL - IBM AS400

This is a discussion on Problem with parameters from RPGIV to CL - IBM AS400 ; Hi, I've got a problem that has me stumped and has done now for about 2 days. I have an RPG IV program which calls a CL program which then submits a job to retrieve a PDF from a server ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Problem with parameters from RPGIV to CL

  1. Problem with parameters from RPGIV to CL

    Hi,

    I've got a problem that has me stumped and has done now for about 2
    days.

    I have an RPG IV program which calls a CL program which then submits a
    job to retrieve a PDF from a server and email it.

    Passing parameters from the RPG IV to the 1st CL is ok, BUT the using
    the SBMJOB and calling the 2nd CL program the parameters in that the
    2nd CL retrieve are corrupted.

    RPGIV parameter list

    d SendEmail PR extpgm('SNDEMLCL')
    D PolicyType 2
    D EPolicyNo 8
    D Subject 50
    D EmailText 32767
    D Attachment 40
    D Sender 40
    D Recipient 40
    D Att_Year 4
    D Att_Month 2
    D MsgID 10

    1st CL Program SNDEMLCL

    PGM PARM(&TYPE &QUOTE &SUBJ &TEXT &FILE &SENDER &RECIP &YR &MON
    &MSGID)

    SBMJOB CMD(CALL PGM(SNDEMLCL2) PARM(&SENDER &RECIP &TYPE &QUOTE
    &FILE &SUBJ &YR &MON &MSGID &TEXT)) JOB(SNDEMAIL) JOBD(*LIBL/
    RETDOCJOBD)


    2nd CL Program SNDEMLCL2

    PGM PARM(&SENDER &RECIP &TYPE &QUOTE &FILE &SUBJ &YR &MON &MSGID
    &TEXT)

    I've got a SNDMSG in each CL

    1st CL output

    From . . . : STEVES 05/09/08 09:35:20
    custserv@xxxxx.co.uk
    From . . . : STEVES 05/09/08 09:35:20
    sjs@xxxxx.co.uk

    2nd CL output

    From . . . : STEVES 05/09/08 09:35:46
    custserv@xxxxx.co.uk sjs@ean
    From . . . : STEVES 05/09/08 09:35:46
    sjs@xxxxx.co.uk EZ


    Here's the CALL command from the joblog;

    Message . . . . : -CALL PGM(SNDEMLCL2)
    PARM('custserv@xxxxx.co.uk'
    'sjs@xxxxx.co.uk' 'EZ' ' ' ' ' 'Policy: EZ/00000011' ' ' ' '
    'E01000187' '

    ')


    Can anybody offer any help?

    Thanks in advance

    Steve



  2. Re: Problem with parameters from RPGIV to CL

    On Sep 5, 9:40*am, Steve wrote:
    > Hi,
    >
    > I've got a problem that has me stumped and has done now for about 2
    > days.
    >
    > I have an RPG IV program which calls a CL program which then submits a
    > job to retrieve a PDF from a server and email it.
    >
    > Passing parameters from the RPG IV to the 1st CL is ok, BUT the using
    > the SBMJOB and calling the 2nd CL program the parameters in that the
    > 2nd CL retrieve are corrupted.
    >
    > RPGIV parameter list
    >
    > *d SendEmail * * * PR * * * * * * * * *extpgm('SNDEMLCL')
    > *D * PolicyType * * * * * * * * * 2
    > *D * EPolicyNo * * * * * * * * * *8
    > *D * Subject * * * * * * * * * * 50
    > *D * EmailText * * * * * * * *32767
    > *D * Attachment * * * * * * * * *40
    > *D * Sender * * * * * * * * * * *40
    > *D * Recipient * * * * * * * * * 40
    > *D * Att_Year * * * * * * * * * * 4
    > *D * Att_Month * * * * * * * * * *2
    > *D * MsgID * * * * * * * * * * * 10
    >
    > 1st CL Program SNDEMLCL
    >
    > * * *PGM PARM(&TYPE &QUOTE &SUBJ &TEXT &FILE &SENDER &RECIP &YR &MON
    > &MSGID)
    >
    > * * *SBMJOB CMD(CALL PGM(SNDEMLCL2) PARM(&SENDER &RECIP &TYPE &QUOTE
    > &FILE &SUBJ &YR &MON &MSGID &TEXT)) JOB(SNDEMAIL) JOBD(*LIBL/
    > RETDOCJOBD)
    >
    > 2nd CL Program SNDEMLCL2
    >
    > PGM PARM(&SENDER &RECIP &TYPE &QUOTE *&FILE &SUBJ &YR &MON &MSGID
    > &TEXT)
    >
    > I've got a SNDMSG in each CL
    >
    > 1st CL output
    >
    > From *. . . : * STEVES * * * * 05/09/08 * 09:35:20
    > custs...@xxxxx.co.uk
    > From *. . . : * STEVES * * * * 05/09/08 * 09:35:20
    > s...@xxxxx.co.uk
    >
    > 2nd CL output
    >
    > *From *. . . : * STEVES * * * * 05/09/08 * 09:35:46
    > *custs...@xxxxx.co.uk * * * * * * sjs@ean
    > *From *. . . : * STEVES * * * * 05/09/08 * 09:35:46
    > *s...@xxxxx.co.uk * * * * * * * * *EZ
    >
    > Here's the CALL command from the joblog;
    >
    > Message . . . . : *-CALL PGM(SNDEMLCL2)
    > PARM('custs...@xxxxx.co.uk'
    > * '...@xxxxx.co.uk' 'EZ' ' ' ' ' 'Policy: EZ/00000011' ' ' ' '
    > 'E01000187' '
    >
    > ')
    >
    > Can anybody offer any help?
    >
    > Thanks in advance
    >
    > Steve


    I think what might be happening is that the call passes pointers to
    the start of each bit of data so when you create you progs with the
    same data lengths nothing overlaps. SBMJOB only passes as much param
    info as is required, just the bits upto the last blank so the &SENDER
    is sent as say char(20) & the Receiver is then immediately added.
    These are received into your last program & the sender looks like
    20chars then 10 from the receiver? One way to solve this is to make
    the parameters be copied into parms 1 longer than you want just before
    SBMJOB then have the last char set to say X. This should force SBMJOB
    to send 41 for both the sender & receiver but the called program only
    sees the 1st 40 of each. One limitation of SBMJOB at the version I
    have is the CMD parameter is limited to 20000 chars, obviously
    including the CALL & all the quotes etc. so you would have to trim
    that 32kb text down a touch. Alternatively save the data in a db file
    with a generated next number & just pass the number.

    HTH
    Jonathan.

  3. Re: Problem with parameters from RPGIV to CL

    Steve wrote:
    > <>
    >
    > I have an RPG IV program which calls a CL program which then submits
    > a job to retrieve a PDF from a server and email it.
    >
    > Passing parameters from the RPG IV to the 1st CL is ok, BUT the
    > using the SBMJOB and calling the 2nd CL program the parameters in
    > that the 2nd CL retrieve are corrupted. <>


    There are probably dozens of FAQ documents about this issue that
    could be found on the web... given the correct searches could be formed.
    :-) There should be something in the CL Programming Gd as well. I
    posted some links at the bottom of my reply.

    The issue is due in part, to the 32 byte parameter size default for
    reserved storage of any one parameter in CL processing. The second
    issue is that the CALL in the submit job is much like a command line
    invocation, but those strings as character variables, will be truncated
    to the last non-blank, irrespective of the declared length. See code
    example below with inline /* comments */.

    At a command line the issue is prevented by explicitly including all
    of the blanks, to pad the quoted string to match the full length of the
    declared variable. In the CLP which uses SBMJOB with a CALL command
    request in the CMD() parameter, versus a direct CALL to the program, the
    same manner as what is done from a command line [using literals] can
    prevent the issue. However variables have the aforementioned issue with
    truncation. For variables the resolution is to mimic the literals.
    That is done using a CL variable into which the full command string is
    generated, including the apostrophes and the blanks for pad. One of the
    FAQ entries included below, suggests that an extra character must be
    included, beyond the maximum character variable length for the
    parameters, but I do not think that is required; see the code below...
    although it is untested.

    However IMO the most appropriate and best way to resolve any such
    issues, is to encapsulate the CALL in a *CMD definition; i.e. replace
    the CALL PGM(PgmName) PARM('string-1' 'string-2') with CMDNAME
    PARM1('string-1') PARM2('string-2') which requires having first created
    that command using CRTCMD CMD(CMDNAME). The CL Programming Gd has
    information on how to create command objects, and how to define the source.


    pgm (&sender) /* pgm EFROM */
    dcl &sender *char 35
    dmpclpgm
    endpgm

    /* scale for PARM: ....+....1....+....3....+ */
    call pgm(EFROM) PARM('incorrect@tooshort.sfx')
    /* the above fails to pass the full 35 bytes */
    call pgm(EFROM) PARM('this.is@correct.sfx ')
    /* this request passes all 35 bytes */

    pgm (&xsend) /* pgm TEST_EFROM */
    dcl &xsend *char 35 value('too@short.val')
    dcl &cmdstring *char 200
    sbmjob cmd(call pgm(EFROM) PARM(&xsend)
    /* the above effects at runtime: +
    call pgm(EFROM) PARM('too@short.val') */
    chgvar %sst(&xsend 1 3) value('pad')
    chgvar &cmdstring 'call pgm(EFROM) +
    PARM(''' *tcat &xsend *cat ''')'
    sbmjob rqsdta(&cmdstring)
    /* scale for below PARM: ....+....1....+....3....+ */
    /* the above code effects at runtime: +
    sbmjob rqsdta('call pgm(EFROM) PARM('pad@short.val ') */
    /* rqsdta used because I think CMD() does not allow variable.? */
    endpgm


    http://publib.boulder.ibm.com/infoce...bam6/ucall.htm
    http://publib.boulder.ibm.com/infoce...ic/cl/call.htm
    http://faq.midrange.com/index.pl?_re...file=1#file_57
    http://faq.midrange.com/index.pl?_re...ile=15#file_70
    http://faq.midrange.com/index.pl?_re...ile=15#file_73

    Regards, Chuck

+ Reply to Thread