Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Call QSYS.QCDEXC from C#

Posted on 2009-02-18
5
Medium Priority
?
1,900 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

0
Comment
Question by:coecho
  • 3
5 Comments
 
LVL 36

Expert Comment

by:Gary Patterson
ID: 23673108
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
0
 
LVL 36

Accepted Solution

by:
Gary Patterson earned 1500 total points
ID: 23673645
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

0
 

Author Comment

by:coecho
ID: 23674378
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
0
 
LVL 36

Expert Comment

by:Gary Patterson
ID: 23675420
It sounded like something had changed.  Glad you could track it down.

- Gary Patterson
0
 
LVL 16

Expert Comment

by:theo kouwenhoven
ID: 23711162
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
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…

569 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