× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: Re: Building a CL command in a RPG Program (Help!)
  • From: booth@xxxxxxxxxxxx
  • Date: Tue, 8 May 2001 06:33:55 -0400


Here's what I do just for the reasons that are troubling Mike.  (I'd agree with Scot about skipping the call to CL btw.)

   C                   If        ErrCod > 0                            
    * Send  error Message:                                              
   C                   Eval      Tmpxx =
   C                             'SNDPGMMSG' + ' ' + ERRMSG
   C                   Call  (E) 'QCMDEXC'          
   C                   Parm                    Tmpxx          1024
   C                   Parm      1024          parm2            15 5
   C                   End                                              
                                                                         

I've used this bit of code over and over because i can construct Tmpxx anyway I like, and see the actual command in debug.




_______________________
Booth Martin
Booth@MartinVT.com
http://www.MartinVT.com
_______________________



Scott Klement <klemscot@klements.com>
Sent by: owner-rpg400-l@midrange.com

05/07/2001 11:10 PM
Please respond to RPG400-L

       
        To:        "'RPG400-L@midrange.com'" <RPG400-L@midrange.com>
        cc:        
        Subject:        Re: Building a CL command in a RPG Program (Help!)




Hello!

On Mon, 7 May 2001, Wills, Mike N. (TC) wrote:
>
> I am trying to build a CL call command within a RPG program with four
> parameters. I cannot get the command to work. I am modifying a program and
> for some reason unable to debug it to verify the command is right. What is
> the proper syntax for putting quotes around parameters?
>
> This is the command I want to call:
> SBMJOB CMD(CALL PGM(PGMNAME) PARM('PARM1' 'PARM2' 'PARM3' 'PARM4'))
> JOB(JOBNAME)
>
> This is the code I have to build it:
> EVAL                                  CMD = 'SBMJOB CMD(CALL PGM(PGMNAME) ' +
>                                   'PARM("' + Parm1 + '" ' +                
>                                   '"' + Parm2 + '" ' +                      
>                                   '"' + Parm3 + '" ' +                      
>                                   '"' + Parm4 + '"))' +                      
>                                   ' JOB(JOBNAME)'                            

The call command doesn't understand double-quotes.  You need to use
single quotes!   To make a single quote work, you need to double it up.
I.e. when RPG sees quotes like 'Mike''s'  It'll put a single quote in
the string so that the result is: Mike's

Now lets try that with your (somewhat more complex) example:

C                   eval      Cmd = 'SBMJOB CMD(CALL PGM(PGMNAME) ' +  
C                               'PARM(''PARM1'' ''PARM2'' ''PARM3'' ' +
C                               ' ''PARM4'')) JOB(JOBNAME)'

Note that I put an extra space between PARM3 and PARM4 to make it a bit
more clear what I'm doing.  (The extra space wont matter to SBMJOB)

>
> The command is being passed to a CL where is then uses QCMDEXC to execute
> the command.

Why?  QCMDEXC can be called from an RPG program just as easily as it can
from a CL program....   why make the extra call to CL?

c                   call      'QCMDEXC'
c                   parm                    Cmd             200
c                   parm                    Length           15 5


Or... if you want to be a bit more modern, you could use a prototyped
call (this is really slick):

D Cmd             PR                  ExtPgm('QCMDEXC')
D    Command                   200A   const
D    Length                     15P 5 const

C                   callp     Cmd('SBMJOB CMD(CALL PGM(PGMNAME) ' +  
C                               'PARM(''PARM1'' ''PARM2'' ''PARM3'' ' +
C                               ' ''PARM4'')) JOB(JOBNAME)': 200)

> My program gets a data decimal error because on some of the
> parameters, it picks up the double quotes as part of the parameter (ex. A
> date field would look like "0501200).

Yes, like I said, it doesn't understand double quotes... it thinks its
part of the data that you're trying to pass.

Decimal Data Error?   You aren't trying to read this data directly into a
numeric parm are you?   Either pass it as character, then convert it to
numeric, or if you want to use numeric, leave out the quotes and make
your parms be "15P 5".

>
> Thanks for any help!
>
> Mike

Your welcome.. I hope it helped.   I use these techniques constantly,
couldn't live without them :)



+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---




As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.