Solved

Error calling QCMDEXC within an iseries QSQLSRC member.

Posted on 2008-06-12
19
2,000 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:Kdo
Comment Utility
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
Comment Utility
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:Kdo
Comment Utility
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
 
LVL 14

Expert Comment

by:daveslater
Comment Utility
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
Comment Utility
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
Comment Utility
Hi
SQL is not a "Standard" type. Are you running the source file via the RUNSQLSTM command?

dave
0
 

Author Comment

by:DebeG
Comment Utility
yes
0
 
LVL 14

Expert Comment

by:daveslater
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 14

Expert Comment

by:daveslater
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
PAQed with points refunded (300)

Computer101
EE Admin
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Recursive SQL in UDB/LUW (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

743 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now