ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Calling QUSRJOBI from .NET application

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Calling QUSRJOBI from .NET application

    Hi all,

    I am calling the IBM API QUSRJOBI from my .NET application, to retrieve the status of a job that is running on the AS400, and present a screen which the user can see the information and know when the job status is MSGW or some other conditions. I am using the code below, but know matter what I do, how hard I try, I always seem to come back to the error CPF3C59 (Internal identifier is not blanks and job name is not *INT). Normally, I can get a clue from the AS400 job log or something, but I can't find anything. The message data returned was also blank. Can anyone keep me from going completely insane?

    Thanks! Here is the code I'm working with:

    PHP Code:
    // Set up CWBX program call parameters

                
    cwbx.AS400System sys = new cwbx.AS400System();
                
    cwbx.Program pgm = new cwbx.Program();
                
    cwbx.StringConverter strCvt = new cwbx.StringConverter();
                
    cwbx.LongConverter longCvt = new cwbx.LongConverter();
                
    cwbx.Structure rcvVar = new cwbx.Structure();
                
    cwbx.Structure libVar = new cwbx.Structure();
                
    cwbx.Structure ERRC0100 = new cwbx.Structure();

                
    sys.Define(systemName);
                
    String jobName "ABC01".PadRight(10);
                
    String jobUser "USERNAME".PadRight(10);
                
    String jobNumber "876741".PadRight(6);
                
    pgm.system sys;
                
    pgm.system.UserID userName;
                
    pgm.system.Password userPassword;
                
    pgm.LibraryName "*LIBL";
                
    pgm.ProgramName "QUSRJOBI";

                
    // Build the structure for the receiver variable
                
    rcvVar.Fields.Append("BytesReturned"4);
                
    rcvVar.Fields.Append("BytesAvail"4);
                
    rcvVar.Fields.Append("JobName"10);
                
    rcvVar.Fields.Append("UserName"10);
                
    rcvVar.Fields.Append("JobNumber"6);
                
    rcvVar.Fields.Append("InternalNumber"16);
                
    rcvVar.Fields.Append("JobStatus"10);
                
    rcvVar.Fields.Append("JobType"1);
                
    rcvVar.Fields.Append("JobSubtype"1);
                
    rcvVar.Fields.Append("Reserved1"2);
                
    rcvVar.Fields.Append("OffsetToSysLibs"4);
                
    rcvVar.Fields.Append("NumberOfSysLibs"4);
                
    rcvVar.Fields.Append("OffsetToProdLibs"4);
                
    rcvVar.Fields.Append("NumberOfProdLibs"4);
                
    rcvVar.Fields.Append("OffsetToCurLibs"4);
                
    rcvVar.Fields.Append("NumberOfCurLibs"4);
                
    rcvVar.Fields.Append("OffsetToUsrLibs"4);
                
    rcvVar.Fields.Append("NumberOfUsrLibs"4);
                
    rcvVar.Fields.Append("LengthOfOneLib"4);
                
    rcvVar.Fields.Append("ArrayData"18750);

                
    // Build the structure for the library var
                
    libVar.Fields.Append("LibraryName"10);
                
    libVar.Fields.Append("LibraryDesc"50);
                
    libVar.Fields.Append("LibraryASP"4);
                
    libVar.Fields.Append("LibraryASPName"10);
                
    libVar.Fields.Append("Reserved2"1);

                
    // Standard error reporting structure
                
    ERRC0100.Fields.Append("BytesProvided"4);
                
    ERRC0100.Fields["BytesProvided"].Value longCvt.ToBytes(272);
                
    ERRC0100.Fields.Append("BytesAvail"4);
                
    ERRC0100.Fields["BytesAvail"].Value longCvt.ToBytes(0);
                
    ERRC0100.Fields.Append("ExceptionID"7);
                
    ERRC0100.Fields.Append("Reserved"1);
                
    ERRC0100.Fields.Append("ExceptionData"272);

                
    // Create the parm object for the call and add the parameters required
                
    cwbx.ProgramParameters parms = new cwbx.ProgramParameters();
                
    parms.Append("ReceiverVar"cwbx.cwbrcParameterTypeEnum.cwbrcOutputrcvVar.Length);
                
    parms.Append("ReceiverLen"cwbx.cwbrcParameterTypeEnum.cwbrcInput4);
                
    parms.Append("FormatName"cwbx.cwbrcParameterTypeEnum.cwbrcInput8);
                
    parms.Append("QualifiedJob"cwbx.cwbrcParameterTypeEnum.cwbrcInput26);
                
    parms.Append("InternalJob"cwbx.cwbrcParameterTypeEnum.cwbrcInput16);
                
    parms.Append("ERRC0100"cwbx.cwbrcParameterTypeEnum.cwbrcInoutERRC0100.Length);
                
                
    // Set the parameter values
                
    parms["ReceiverLen"].Value longCvt.ToBytes(rcvVar.Length);
                
    parms["FormatName"].Value strCvt.ToBytes("JOBI0100");
                
    parms["QualifiedJob"].Value strCvt.ToBytes(jobName jobUser jobNumber);
                
    I have tried the above parameter with blank valueshardcoded job informationetc.

                
    parms["InternalJob"].Value strCvt.ToBytes(" ");
                
    parms["ERRC0100"].Value ERRC0100.Bytes;
                
    int parmLength parms["QualifiedJob"].Length;
                
    String internalJob strCvt.FromBytes(parms["InternalJob"].Value);
                
    // Issue the call
                
    pgm.Call(parms);

                
    // Get the error code. Not doing anything with it here but in production it's a good idea
                // to check the message id returned in this structure.
                
                
    ERRC0100.Bytes parms["ERRC0100"].Value;
                
    rcvVar.Bytes parms["ReceiverVar"].Value;
                
    String errorCode strCvt.FromBytes(ERRC0100.Fields["ExceptionID"].Value);
                
    Error code is always "CPF3C59"!
                
    String errorData strCvt.FromBytes(ERRC0100.Fields["ExceptionData"].Value); 

  • #2
    Re: Calling QUSRJOBI from .NET application

    Well, usually when I post, I find out the issue shortly afterwards, and this case is no different. In case someone has the same issue down the road, here was the fix:

    In this line:
    parms["InternalJob"].Value = strCvt.ToBytes(" ");

    It had to look like this:
    parms["InternalJob"].Value = strCvt.ToBytes(" ".PadRight(16));

    Evidently, it needs to be right justified up to 16, as the converter doesn't know how long the fields should be I guess. Anyway, I tried this and it worked for me. Thanks!

    Comment

    Working...
    X