We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

Call QSYS.QCDEXC from C#

coecho
coecho asked
on
Medium Priority
2,158 Views
Last Modified: 2012-05-06
I was able to run this successfully in the past  -

CALL QSYS.QCMDEXC('SBMJOB CMD(CALL PGM(J09110Z) PARM(P09110Z FORECAST)) JOB(BDFORECAST) JOBQ(QPGMR) USER(FORECAST) INLLIBL(*JOBD)', 000000110.00000)

but now I'm getting the following error:

Error opening connectionERROR [HY000] [IBM][iSeries Access ODBC Driver][DB2 UDB]CPF1338 - Errors occurred on SBMJOB command.

Any ideas what could cause this error message when it worked before?  Is this a type of permissions issue on DB2?  Or a configuration issue?  What port is DB2 going over for its connection?  They closed down a bunch of ports here recently.  I'm using the i5 Series ODBC client driver.  Or - this there something wrong with the command I'm sending?  

thanks for your help!



string postCommand = @"CALL QSYS.QCMDEXC('SBMJOB CMD(CALL PGM(J09110Z) PARM(P09110Z FORECAST)) JOB(BDFORECAST) JOBQ(QPGMR) USER(FORECAST) INLLIBL(*JOBD)', 000000110.00000)";
  try
   {
        using (OdbcCommand myCommand2 = new OdbcCommand(postCommand, myConnection))
                {
                    if (myConnection.State == System.Data.ConnectionState.Closed)
                    {
                        myConnection.Open();
                    }
                    
                    int iRows = myCommand2.ExecuteNonQuery();
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Error opening connection" + ex.Message);
                return false;
            }

Open in new window

Comment
Watch Question

Gary PattersonVP Technology / Senior Consultant
CERTIFIED EXPERT

Commented:
That message means that the command made it to the command server job on the AS/400, but for some reason the command failed.  The easiest thing to do:

Sign onto the AS/400 in a green-screen session, preferably using the same profile that you use to submit the command.  Manually submit the command.  When the command failes, you can look at the detailed help (cursor on the error message, press F1) for a detailed explanation of the problem.  It could be lots of things:
  • Program J09110Z could be missing, deleted, moved, or renamed,
  • The library list could have changed for the user profile that the SBMJOB is being run under, and the system could be having trouble finding a required object.
  • User profile FORECAST could be deleted, disabled, or authority to a required object (program, jobd) revoked.
- Gary Patterson
VP Technology / Senior Consultant
CERTIFIED EXPERT
Commented:
As to the rest of your questions:

Q: Is this a type of permissions issue on DB2?

A: You need to se the detailed error messages to determine if it is a permissions issue.  The profile that you use to make the connection must have adequate rights to the FORECAST user profile on ther AS/400, and to the CALL command, the SBMJOB command, and the qcmdexec program.  The FORECAST profile needs to have rights to the program (and it's dependent objects unless it uses adopted authority), and the QPGMR job queue.

Q: Or a configuration issue?  
A: Probably not.  Looks like the command is making it to the AS/400 and attempting execution.  The command is just failing for some reason.

Q: What port is DB2 going over for its connection?
A: Ports are configurable.  Here's a good article:  http://www.mcpressonline.com/security/i5/os/iseries-access-through-a-firewall.html

Q:  Or - this there something wrong with the command I'm sending?  
A:  The command appears to be properly formed and syntactically valid.  Since the program name is not qualified with a library name, the program J09110Z needs to be found in a library in the job's library list.  This will be the job description associated with the user profile FORECAST.  

- Gary Patterson

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Hi Gary -

I was able to run the command on the green screen under a different account than I was trying to run the code under.  It turns out, that the JDE User I was using on the ODBC connection string, had the user permissions changed so that it no longer has permissions to run the DB2 CMD.  

Problem solved.  Thanks for your help.

Lisa
Gary PattersonVP Technology / Senior Consultant
CERTIFIED EXPERT

Commented:
It sounded like something had changed.  Glad you could track it down.

- Gary Patterson
Theo KouwenhovenApplication Consultant
CERTIFIED EXPERT

Commented:
Hi coecho,

I'm almost sure that the comma between the command and the command length is not alowed, parameters in a as400 call are seperated by a space, not by a comma.

Regards,
Murph
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.