Error calling QCMDEXC within an iseries QSQLSRC member.

Option 1:
CALL QCMDEXC('SBMJOB CMD(CALL PGM(T_SESLIBWL/CNSHPPUC)) JOB(PROCNEWEDI) JOBQ(QB
ATCH4) MSGQ(*NONE) INLLIBL(T_SESLIBWL)' 0000000103.00000) ;

Option 2:
 CALL PGM(QCMDEXC) PARM('SBMJOB CMD(CALL PGM(T_SESLIBWL/CNSHPPUC)) JOB(PROCNEWED
I) JOBQ(QBATCH4) MSGQ(*NONE) INLLIBL(T_SESLIBWL)' 0000000103.00000)
Within a SQL member on the iseries, I need to submit a job using a call to the QCMDEXC object.  Nothing I have tried has been successful.  The Option 1 code snippet I have attach produces an error that says string not delimited.  I know this command will not work from an iseries command line.  If I change the call to Option 2, which does work from a command line, I get Token QCMDEXC and Token PARM not valid.  What am I doing wrong?

Open in new window

DebeGProgrammerAsked:
Who is Participating?
 
Computer101Connect With a Mentor Commented:
PAQed with points refunded (300)

Computer101
EE Admin
0
 
Kent OlsenData Warehouse Architect / DBACommented:
Hi DebeG,

I believe that you need two parameters to this call, a string and a float.

Put a comma after the string terminator and before the 0000000103.00000.


Good Luck,
Kent
0
 
DebeGProgrammerAuthor Commented:
Kent, I have tried this command with the comma, and did just try again to confirm, but I still get the string constant not delimited error.  I can also tell you that if I change the command to the Option 3 code snippet, that the code works fine.  I need to add the other variables to the call though.  I have tried just adding one additional variable to the call and it is back to the issue with not being delimited.  
Thanks for the suggestion though.


Option 3:
CALL QCMDEXC('SBMJOB CMD(CALL PGM(T_SESLIBWL/CNSHPPUC))', 0000000041.00000)

Open in new window

0
[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

 
Kent OlsenData Warehouse Architect / DBACommented:
Hi Debe,

I'm not an AS/400 person, so I've got to guess a bit, but I'll gladly help.

QCMDEXC will pass the string to the operating system for execution.  (It appears that the string length is 41, so let's concentrate on the string.)

What will AS/400 do with the string:

  SBMJOB CMD(CALL PGM(T_SESLIBWL/CNSHPPUC))

If you try to run it?


0
 
daveslaterCommented:
Hi
first you need to identify what type of program you are using.
QSQLSRC is of the type of the source file, it can hold any type of member.

Against the source there will be a member type probably
cl
CLP
RPG
RPGLE
SQLRPGLE

etc.

once we know this we can tell you the syntax or the best way to issue the command.

Dave
0
 
DebeGProgrammerAuthor Commented:
It is:
Member      Type        Text
CMEICPP     SQL         INT Inbound ASN Dtl Stg   Physical file

SBMJOB CMD(CALL PGM(T_SESLIBWL/CNSHPPUC)) is a command that will submit a job to batch.  This job will call  the program CNSHPPUC to batch.  If I run this from the command line, it works fine.  
 
0
 
daveslaterCommented:
Hi
SQL is not a "Standard" type. Are you running the source file via the RUNSQLSTM command?

dave
0
 
DebeGProgrammerAuthor Commented:
yes
0
 
daveslaterCommented:
Hi
it is not easy to call qcmsexc from with-in SQL. The easiest way to do what you want is to create a cl program, you can call it
CNSHPPUCB in library T_SESLIBWL.
this will simply hold your command
pgm
SBMJOB CMD(CALL PGM(T_SESLIBWL/CNSHPPUC))
endpgm

then in you source file you can simply use
CALL T_SESLIBWL/CNSHPPUCB.

Ths will call the new program that will inturn submit the job.
Failing that you will have to regsiter qcmdexc as a stored procedre - not hard

Dave
0
 
DebeGProgrammerAuthor Commented:
Dave

I had already created the procedure using the following command:
CREATE PROCEDURE QSYS/QCMDEXC(IN :CMDSTR VARCHAR(1024),IN :CMDLENGTH DECIMAL(15,5)) EXTERNAL NAME QSYS/QCMDEXC LANGUAGE C GENERAL

That didn't make a difference with the command not working though.


 
0
 
daveslaterCommented:
Hi
to avoid confusion I woud drop the qcmdexc abd call it somthing like runcmd

CREATE PROCEDURE QGPL/RUNCMD(IN cmd CHAR (1024 ), IN cmdlen DEC
(15 , 5)) LANGUAGE C  EXTERNAL NAME QSYS/QCMDEXC PARAMETER STYLE GENERAL                            

The system may be trying to use the system object, not the storred procedure.

then simply enter
call qgpl/runcmd  ('SBMJOB CMD(CALL PGM(T_SESLIBWL/CNSHPPUC))' , 41) ;

Dave
0
 
daveslaterCommented:
if you want to use qsys/qcmdexc you must supply the length as
0000000041.00000

with the leading / trailing zeros

why - who knows !!!!!!!
0
 
DebeGProgrammerAuthor Commented:
Following is the commad I am trying to get to work.  It does have the length defined as the 2nd parm into QCMDEXC.  

CALL QCMDEXC('SBMJOB CMD(CALL PGM(T_SESLIBWL/CNSHPPUC)) JOB(PROCNEWEDI) JOBQ(QB
ATCH4) MSGQ(*NONE) INLLIBL(T_SESLIBWL)' 0000000103.00000) ;
0
 
daveslaterCommented:
it would be

call qsys/qcmdexc ('SBMJOB CMD(CALL PGM(T_SESLIBWL/CNSHPPUC)) JOB(PROCNEWEDI) JOBQ(QBATCH4) MSGQ(*NONE) INLLIBL(T_SESLIBWL)' , 0000000103.00000) ;

Note the comma and qulaified call
0
 
daveslaterCommented:
Hi
I think it is because the stetement is going of 2 lines

try
call qsys/qcmdexc (                                                          
'SBMJOB PROCNEWEDI cmd(CALL CNSHPPUC) JOBQ(qpgmr  ) INLLIBL(T_SESLIBWL)'      
 , 0000000070.00000) ;                                                        
0
 
DebeGProgrammerAuthor Commented:
I actually created the QSQLSRC source file as 240 because I thought the problem I had might have something to do with scanning across multiple lines. That didn't help.  When I qualify the QCMDEXC with QSYS/QCMDEXC, I get Qualified object name QCMDEXC not valid, and I still get the position 19 string constant beginning 'SBMJOB P' not delimited.
0
 
daveslaterCommented:
Hi
I too tried it with 240 and it only recognised the first 80.

I think the easiest way would be to create a separate CL program with the command and all the parms.

Sometimes we just have to code round limitations - its what we get paid for.

Someone else may have the answer you require, I have hit the same walls as you have
0
 
tliottaCommented:
Minor note... What error are you getting? Without knowing the problem, it's tricky coming up with a solution. At the moment, it _looks_ correct.

Tom
0
All Courses

From novice to tech pro — start learning today.