Solved

Error calling QCMDEXC within an iseries QSQLSRC member.

Posted on 2008-06-12
19
2,025 Views
Last Modified: 2008-10-08
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

0
Comment
Question by:DebeG
  • 8
  • 6
  • 2
  • +2
19 Comments
 
LVL 45

Expert Comment

by:Kent Olsen
ID: 21772850
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
 

Author Comment

by:DebeG
ID: 21772969
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
 
LVL 45

Expert Comment

by:Kent Olsen
ID: 21773066
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
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
LVL 14

Expert Comment

by:daveslater
ID: 21776995
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
 

Author Comment

by:DebeG
ID: 21777990
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
 
LVL 14

Expert Comment

by:daveslater
ID: 21778080
Hi
SQL is not a "Standard" type. Are you running the source file via the RUNSQLSTM command?

dave
0
 

Author Comment

by:DebeG
ID: 21778129
yes
0
 
LVL 14

Expert Comment

by:daveslater
ID: 21778328
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
 

Author Comment

by:DebeG
ID: 21779081
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
 
LVL 14

Expert Comment

by:daveslater
ID: 21779424
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
 
LVL 14

Expert Comment

by:daveslater
ID: 21779536
if you want to use qsys/qcmdexc you must supply the length as
0000000041.00000

with the leading / trailing zeros

why - who knows !!!!!!!
0
 

Author Comment

by:DebeG
ID: 21779746
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
 
LVL 14

Expert Comment

by:daveslater
ID: 21779880
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
 
LVL 14

Expert Comment

by:daveslater
ID: 21780036
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
 

Author Comment

by:DebeG
ID: 21780598
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
 
LVL 14

Expert Comment

by:daveslater
ID: 21782296
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
 
LVL 27

Expert Comment

by:tliotta
ID: 21796792
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
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 22674759
PAQed with points refunded (300)

Computer101
EE Admin
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

November 2009 Recently, a question came up in the DB2 forum regarding the date format in DB2 UDB for AS/400.  Apparently in UDB LUW (Linux/Unix/Windows), the date format is a system-wide setting, and is not controlled at the session level.  I'm n…
Recursive SQL in UDB/LUW (it really isn't that hard to do) Recursive SQL is most often used to convert columns to rows or rows to columns.  A previous article described the process of converting rows to columns.  This article will build off of th…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question