ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

chkobj monmsg

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

  • chkobj monmsg

    hi

    i want to get monmsg when file is found

    chkobj OBJ(&lib/&file) OBJTYPE(*FILE)
    MONMSG MSGID(CPF9801)

    i get this message if the file not found,
    is there any way to know that without doing it this way:


    chkobj OBJ(&lib/&file) OBJTYPE(*FILE)
    MONMSG MSGID(CPF9801) do(goto next)

    thank's rachel

  • #2
    Re: chkobj monmsg

    rachel,

    The point of monitor message is that is there is an "error"
    a code is displayed. If the file is found then there will be no
    error code.

    so the code you have (at bottom) is fine.

    you could also use CHGPF &lib/&file
    you could then monitor for CPF326A for file changed
    --or-- CPF7304 file not changed... either its not found or its locked

    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


    • #3
      Re: chkobj monmsg

      hi

      i have to check about 20 objects,
      so the code i wrote is not very efficient
      i need to use 20 lables for the goto command.

      is there any way to write
      if not monmsg cpfxxxx?

      rachel

      Comment


      • #4
        Re: chkobj monmsg

        I know of no way other than checking messges

        well except API (change the member to '*FIRST')

        Code:
         The QUSRMBRD (Retrieve Member Description) API returns descriptive
        information about a member in a file.
        
        
        
             D szMsgText       S            255A
             **  Tells the APIs how long the buffers are that are being used.
             D nBufLen         S             10I 0
              ** The structure returned by the QusRMBRD API.
             D szMbrd0100      DS                  INZ
             D  nBytesRtn                    10I 0
             D  nBytesAval                   10I 0
             D  szFileName                   10A
             D  szLibName                    10A
             D  szMbrName                    10A
             D  szFileAttr                   10A
             D  szSrcType                    10A
             D  dtCrtDate                    13A
             D  dtLstChg                     13A
             D  szMbrText                    50A
             D  bIsSource                     1A
             D  RmtFile                       1A
             D  LglPhyFile                    1A
             D  ODPSharing                    1A
             D  filler2                       2A
             D  RecCount                     10I 0
             D  DltRecCnt                    10I 0
             D  DataSpaceSz                  10I 0
             D  AccpthSz                     10I 0
             D  NbrBasedOnMbr                10I 0
        
             **----------------------------------------------------------------
             ** Input Parameters for the program.
             **----------------------------------------------------------------
             ** Source file name
             D szSrcFile       S             10A
             D szSrcLib        S             10A
             D szSrcMbr        S             10A
        
             **----------------------------------------------------------------
             ** Input Parameters to the QUSRMBRD API
             **----------------------------------------------------------------
             ** Format to be returned
             D szFmt           S              8A   Inz('MBRD0200')
             ** Qualified source file and library name
             D szQualName      S             20A
             ** Whether or not to ignore overrides (0=Ignore, 1 = Apply)
             D bOvr            S              1A   Inz('0')
        
             **----------------------------------------------------------------
             **  Call this program with 3 parameters:
             **    Parm(QRPGLESRC myLibr  ORDENTRY)
             **         srcfile   srclib  srcmbr
             **----------------------------------------------------------------
             C     *ENTRY        PLIST
             C                   Parm                    szSrcFile
             C                   Parm                    szSrcLib
             C                   Parm                    szSrcMbr
        
             
             **----------------------------------------------------------------
             **  Call QusRMBRD to retrieve the specified source member's
             **----------------------------------------------------------------
             C                   Eval      szQualName = szSrcFile + szSrcLib
             C                   Eval      nBufLen = %size(szMbrD0100)
        
             **----------------------------------------------------------------
             C                   Call(E)   'QUSRMBRD'
             C                   Parm                    szMbrD0100
             C                   Parm                    nBufLen
             C                   Parm                    szFmt
             C                   Parm                    szQualName
             C                   Parm                    szSrcMbr
             C                   Parm                    bOvr
        
             **----------------------------------------------------------------
             **  If RTFMBRD failed, we tell the FTP client that it failed.
             **----------------------------------------------------------------
             C                   if        %Error
             C                   Eval      szMsgText = 'RTVMBRD Failed'
        
             C                   endif
        
        
        
             C                   return
        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


        • #5
          Re: chkobj monmsg

          You could put your MONMSG at the start of your CL to catch all occurances of the error throughout the pgm:

          PGM
          MONMSG MSGID(CPF9801) EXEC(GOTO CMDLBL(NOHIT))
          CHKOBJ OBJ(YOURLIB/FILE1) OBJTYPE(*FILE)
          CHKOBJ OBJ(YOURLIB/FILE2) OBJTYPE(*FILE)
          CHKOBJ OBJ(YOURLIB/FILE3) OBJTYPE(*FILE)
          SNDMSG MSG('Success!') TOUSR(QPGMR)
          GOTO CMDLBL(END)
          NOHIT: SNDMSG MSG('Failure!') TOUSR(QPGMR)
          END: ENDPGM

          That way you only need the one label.

          Pete

          Comment

          Working...
          X