ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Where can I find the status codes returned by a failing command?

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

  • Where can I find the status codes returned by a failing command?

    I have a program that is issuing a command string (qcmdexec) to CPYFRMIMPF...

    I need to monitor for specific errors that may or may not occur (with the Monitor and On-error op codes).

    Where can I get a "list" of these?
    Can I see them in debug or when the command is executed interactively?
    Do they correspond to anything (i.e. RNX1216 corresponds to 01216)??

    Specifically, I'm trying to monitor when a specific row is not imported.

  • #2
    Re: Where can I find the status codes returned by a failing command?

    Type the command at the Command Prompt

    Press to prompt the command.

    Cursor up to the Heading of the command and press (This gives you the Help Screen for the command)

    Go to the BOTTOM of that screen and you will see all associated Error Messages and their corresponding Error Codes.

    Comment


    • #3
      Re: Where can I find the status codes returned by a failing command?

      OK... that shows me CPFxxxx. What I'm looking for are the status codes (program-error, file-error) that are used in conjuntion with the on-error op code. Those codes are of the form 00100 - 09999.

      Comment


      • #4
        Re: Where can I find the status codes returned by a failing command?

        Setup a Program Status Data Structure and look for positions 40-46. This will provide the Exception type and Number (MSGID) of the error. Instead of using monitor use CallP with the E extender when calling QCMDEXEC and use the %Error BIF to trap the error. I generally avoid using the Monitor statement because it writes to the job log.

        Comment


        • #5
          Re: Where can I find the status codes returned by a failing command?

          The codes you want are in the ILE RPG Reference guide in the chapter for File and Program Exception/Errors.

          Comment


          • #6
            Re: Where can I find the status codes returned by a failing command?

            also on the index page of this site:



            jamie
            All my answers were extracted from the "Big Dummy's Guide to the As400"
            and I take no responsibility for any of them.

            www.code400.com

            Comment


            • #7
              Re: Where can I find the status codes returned by a failing command?

              Well, i'm not using CALLB... I wrote the pgm in free-format... this is a batch job, so a joblog is fine. I've seen the info you are referring to. However, I still can't see what Exception/Error code I am encountering.
              In the job log, I can see CPFxxxx and RNXxxxx - but I can't see which Exception/Error code is getting returned. Do I have to insert the PSDS just to see that information?
              Sorry to be so thick, but I have to fully understand something before I accept it.

              Comment


              • #8
                Re: Where can I find the status codes returned by a failing command?

                try messin with this
                PHP Code:
                 d reply           s              1                                      
                 d status          s              4  0                                   
                 d display         s             10                                      
                                                                                         
                 c                   call
                (e)   '@@@@X2'                                  
                 
                c                   eval      Status = %status()                        
                 
                c                   eval      display = %editc(status:'X')              
                 
                c     display       dsply                   reply                       
                 c                   
                eval      *INLR = *on 
                or this
                PHP Code:
                     d bigzero         s              5  0
                     D dividebyzero    c                   00102
                     d charfield       s              7
                     d count           s              1  0
                     d decimalfield    s              7  2
                     d mystatus        s              5  0

                      
                /free

                             
                for count 1 to 3;
                              
                select;
                               
                when count =1;
                                
                charfield '0001222';
                                
                monitor;
                                 
                decimalfield = %dec(charfield:7:2) ;
                                
                on-error;
                                 
                mystatus = %status;
                                 
                dsply %editc(mystatus:'X'' ';
                                
                endmon;
                               
                when count =2;
                                
                charfield '000ABCD';
                                
                monitor;
                                
                decimalfield = %dec(charfield:7:2) ;
                                
                on-error;
                                 
                mystatus = %status;
                                 
                dsply %editc(mystatus:'X'' ';
                                
                endmon;
                               
                when count =3;
                                
                charfield '12567';
                                
                monitor;
                                
                decimalfield = %dec(charfield:7:2) ;
                                
                decimalfield decimalfield/bigzero;
                                
                on-error;
                                 
                mystatus = %status;
                                 
                dsply %editc(mystatus:'X'' ';
                                
                endmon;
                              
                endsl;
                             endfor;


                          
                // monitor specifically for the devide by zeros code

                             
                monitor;
                             
                decimalfield decimalfield/bigzero;
                             
                on-error dividebyzero;
                              
                decimalfield = *zeros;
                              
                dsply 'Hey! ShortBus you cant do that' ' ' ;
                             
                endmon;

                             *
                inlr = *on;
                      /
                end-free

                All my answers were extracted from the "Big Dummy's Guide to the As400"
                and I take no responsibility for any of them.

                www.code400.com

                Comment


                • #9
                  Re: Where can I find the status codes returned by a failing command?

                  try this thread http://www.code400.com/forum/showthr...On-Error-Codes
                  I'm not anti-social, I just don't like people -Tommy Holden

                  Comment


                  • #10
                    Re: Where can I find the status codes returned by a failing command?

                    You are mixing up the error codes. The codes you use on the ON-Error statement (Program/File Status Code) is not the same as the XXXX part of the CPF of RNX error messages (Error Message File ID). If you want to be able to see what codes are being returned you need to include the PSDS. The subfield position *STATUS of the PSDS will show you the Error Status code, these are the codes the ON-Error statement refers to. Positions 40-46 of the PSDS will return the MSGID of the error message.

                    Since you are using QCMDEXEC you should use the E extender on the CALLP, CALLB or the CALLP op codes when calling it Then trap any errors by using the %Error BIF. This way you can retrieve the actual Error Message that occurs if QCMDEXEC Fails. The returned MSGID will tell you what exactly what happened were as the Error status codes are limited in number and don't report every condition. If I am using QCMDEXEC to run a CL command it is more useful to me to get the actual CPF error message if it fails.

                    As to where to find status codes or what are they. People have posted links and I already mentioned where to find them in the reference guide. I get the feeling you haven't even looked in those places yet.

                    Comment


                    • #11
                      Re: Where can I find the status codes returned by a failing command?

                      Thank you everyone... I get it now.

                      I guess there's no easy way to get the Message from PSDS or a simple read of the MSGF? This is an unattended (batch) application. I create printed output when an error occurs.

                      Comment


                      • #12
                        Re: Where can I find the status codes returned by a failing command?

                        No...not no way....you could use %status then write to the system log failing code and other info....
                        All my answers were extracted from the "Big Dummy's Guide to the As400"
                        and I take no responsibility for any of them.

                        www.code400.com

                        Comment


                        • #13
                          Re: Where can I find the status codes returned by a failing command?

                          No offense gwilburn, but have you even tried the examples that that have been posted. Are you telling us that you don't know how to pull the value out of a subfield of the PSDS which is just a data structure or like Jamie indicated just pull the value out of %Status.

                          Comment


                          • #14
                            Re: Where can I find the status codes returned by a failing command?

                            Originally posted by DAG0000 View Post
                            No offense gwilburn, but have you even tried the examples that that have been posted. Are you telling us that you don't know how to pull the value out of a subfield of the PSDS which is just a data structure or like Jamie indicated just pull the value out of %Status.
                            None taken... Sorry, I wasn't clear. I'm referring the the description and/or reason for the MSGID that is returned by PSDS. I actually implemented the error handling as you suggested. No more monitors... using CALLP(E) and checking for %ERROR, etc. I only defined 40-46 in my SDS to grab the MSGID (didn't see any part of the SDS that held the actual message).

                            Specifically, I'm getting the following error (which really isn't an "problem"):

                            Message ID . . . . . . : HTP160C Severity . . . . . . . : 40
                            Message type . . . . . : Diagnostic
                            Date sent . . . . . . : 10/13/10 Time sent . . . . . . : 11:07:01

                            Message . . . . : Request to create or append to a document list failed.
                            Reason GEN5056.
                            Cause . . . . . : The request to create or append to document list
                            /qsys.lib/asthhobj.lib/ifs_list.file/ifs_list.mbr failed for this reason:
                            There are no documents with the specified filter in the document directory.
                            Recovery . . . : Correct the error and try the request again.

                            I was hoping to easily output the "Cause" text above on my printed report - telling the user that no files were available to copy. Right now, I've just hardcoded my own output text for HTP160C (as this would be the most common error).

                            Comment


                            • #15
                              Re: Where can I find the status codes returned by a failing command?

                              And that's all you need. Have you ever heard of the Retrieve Message api QMHRTVM. Your next step should be obvious.

                              Comment

                              Working...
                              X