ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

API or Command

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

  • API or Command

    I have to put an edit routine in my RPG program that checks to see if a program exists upon entry. I can go out to a CL program and check with a wrkobj or dspobjd but I was wondering if someone had a neat API or routine in RPG that would do this. Later on I will post the code (RPG & DDS) for my over/under subfile maintenance program. I need to clean it up a little.

    Thanks,

    DAC

  • #2
    Re: API or Command

    Pls use
    Retrieve Object Description (QUSROBJD) API

    The Retrieve Object Description (QUSROBJD) API lets you retrieve object information about a specific object. This information is similar to the information returned using the Display Object Description (DSPOBJD) command or Retrieve Object Description (RTVOBJD) command.

    For more info on this API, pls visit publib.ibm.com
    Thanks,
    Giri

    Comment


    • #3
      Re: API or Command

      Just search the forum there are a bunch of examples
      PHP Code:
           D ErrorDs         DS                  INZ
           D  BytesProvd             1      4B 0
           D  BytesAvail             5      8B 0
           D  MessageId              9     15
           D  ERR
      ###                16     16
           
      D  MessageDta            17    116
           D  Receiver       S            100
           D  ReceivrLen     S              4B 0 INZ
      (100)
           
      D  Object         S             10
           D  ObjLibrary     S             10
           D  ObjType        S              8
           D  ExistYesNo     S              1
           D  FileLib        S             20
           D  FileFormat     S              8    INZ
      ('OBJD0100')

           
      C     *ENTRY        PLIST
           C                   PARM                    Object
           C                   PARM                    ObjLibrary
           C                   PARM                    ObjType
           C                   PARM                    ExistYesNo
           C     ObjLibrary    IFEQ      
      *BLANKS
           C                   
      EVAL      ObjLibrary 'LIBL'
           
      C                   ENDIF
           
      C                   EVAL      FileLib Object ObjLibrary
            
      *
            * 
      Attempt to retrieve object description
            
      *
           
      C                   CALL      'QUSROBJD'
           
      C                   PARM                    Receiver
           C                   PARM                    ReceivrLen
           C                   PARM                    FileFormat
           C                   PARM                    FileLib
           C                   PARM                    ObjType
           C                   PARM                    ErrorDs
           C                   
      EVAL      ExistYesNo 'Y'
           
      C     MessageId     IFNE      *BLANKS
           C                   
      EVAL      ExistYesNo 'N'
           
      C                   ENDIF
           
      C                   EVAL      *InLr = *ON 
      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


      • #4
        Re: API or Command

        When I run the program with the API. It works except when the program doesn't exist. I get a message "The call to *LIBL/QUSROBJD ended in error (C G D F). I throught it should return a N in the ExistYesNo PARM.

        DAC

        Comment


        • #5
          Re: API or Command

          Hey! Whatcha expect for free software
          put an (e) on the call and use %error


          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


          • #6
            Re: API or Command

            Can you clarify what you mean by the %error?

            Thanks,

            DAC

            Comment


            • #7
              Re: API or Command

              If you use CALL(E) then the %error is turned on if the call fails

              CALL(E) PROGRAM
              IF %ERROR
              ..... do something or not
              ENDIF

              Comment


              • #8
                Re: API or Command

                Have you considered the CHKOBJ command if you just want to check for a program's existence?
                Jonas Temple
                Got FROG?
                Got Tadpole? No, because it's not done yet! Stay tuned....

                01010111 01100001 01110011 01110011 01110101 01110000 00100000 01100100 01101111 01100111 00111111

                Comment


                • #9
                  Re: API or Command

                  As error "said"
                  PHP Code:
                   *                                                              
                   * 
                  Attempt to retrieve object description                       
                   
                  *                                                              
                  C                   CALL(e)   'QUSROBJD'                        
                  C                   PARM                    Receiver            
                  C                   PARM                    ReceivrLen          
                  C                   PARM                    FileFormat          
                  C                   PARM                    FileLib             
                  C                   PARM                    ObjType             
                  C                   PARM                    ErrorDs             
                  c                   select                                      
                  c                   when      
                  %error                            
                  C                   
                  EVAL      ExistYesNo 'N'                  
                  c                   when      MessageId = *blanks               
                  C                   
                  EVAL      ExistYesNo 'Y'                  
                  c                   endsl 
                  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

                  Working...
                  X