ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Need to call a program if object is exist on system

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

  • Need to call a program if object is exist on system

    Hi All,

    I am checking object existance using following way in my existing CLLE program:

    CHKOBJ OBJ(TEST123) OBJTYPE(*PGM)

    If this object exist then I want to give a call to my new CLLE program which will set the authority on this object, but CHKOBJ will not return any message if object is exist then How I can do this?
    Cheers...
    Nil

  • #2
    Re: Need to call a program if object is exist on system

    It is ABC programming.

    PHP Code:
    CHKOBJ OBJ(TEST123OBJTYPE(*PGM)
    MONMSG MSGID(CPF9801EXEC(GOTO NXTLBL/* Pgm TEST123 does not exist in *LIBL */
    CALL PGM(TEST123PARM( ... )
        .
        .
        .
    RETURN
    NXTLBLSNDPGMMSG MSG('Pgm TEST123 does not exist in *LIBL')
    ENDPGM 
    Philippe

    Comment


    • #3
      Re: Need to call a program if object is exist on system

      I've sometimes used a RETRIEVE function to punch library names, object descriptions (or whatever) to the job log before doing something. This is no better or worse than the previous example but showing that there's a hundred different ways of skinning a cat...

      Code:
       
      DCL VAR(&LIBRARY) TYPE(*CHAR) LEN(10) 
       
      RTVOBJD OBJ(TEST123) OBJTYPE(*PGM) RTNLIB(&LIBRARY) 
       
      MONMSG MSGID(CPF0000) EXEC(CHGVAR VAR(&LIBRARY) VALUE(' ')) /* If the RETRIEVE OBJECT
      DESCRIPTION fails for any-reason then blank out the &LIBRARY value. Therefore -
      &Library will only be populated if everything looks good.. */ 
       
      IF COND(&LIBRARY *NE ' ') THEN(DO) 
        SNDPGMMSG MSG('Pgm' *BCAT &LIBRARY *TCAT '/TEST123 is about to run') 
        CALL PGM(&LIBRARY/TEST123) PARM( something ) 
        SNDPGMMSG MSG('He shoots... He Scores.... GOOOOAAAAAAALLLLLLLL') 
      ENDDO 
      ELSE CMD(DO) 
        SNDPGMMSG MSG('Pgm TEST123 was not called. Check joblog for more info.') 
      ENDDO
      dont ask me why you would want to skin that many... unless you were a very fat man with a fetish for catfur coats, maybe
      predictably positive, permanently punctilious, purposely proactive, potentially priceless, primarily professional : projex

      Comment


      • #4
        Re: Need to call a program if object is exist on system

        Why not simply calling the program and add a monmsg after that handles the if not found condition?

        Birgitta

        Comment


        • #5
          Re: Need to call a program if object is exist on system

          101 different ways... and only another several hundred to go.

          Miaow.
          predictably positive, permanently punctilious, purposely proactive, potentially priceless, primarily professional : projex

          Comment

          Working...
          X