sponsored links

Collapse

Announcement

Collapse
No announcement yet.

Need help with multiple overriding - OVRDBF

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

  • Need help with multiple overriding - OVRDBF

    My RPGLE program call stack is as follows -


    RPGLE PGM1 calls RPGLE PGM2 which calls RPGLE PGM3

    Pgm1 overrides a file to library1
    Pgm3 uses the same override

    Now, in my Pgm2, I want to override the same file to library2, and then delete the override after Pgm3 call is completed from Pgm2. Upon completion of my call in Pgm2, override will revert back to library1 (basically, I want to do overriding on top of another overriding)

    Current call stack in pgm2:

    Call pgm3 // Pgm3 uses override defined in Pgm1 which is based on library1

    Expected call stack in pgm2:

    OVRDBF ***********
    Call Pgm3 // Pgm3 should use override based on library2 rather than library1 that was specified in pgm1 pgm1
    DLTOVR *********** // After this is completed, the only override that should remain, is the initial one based on library1

    I defined OVRDBF as below (called by QCMDEXC) but doesn't seem to work.
    OVRDBF FILE(FILE1) TOFILE(LIBRARY2/FILE1) SHARE(*YES) OVRSCOPE(*CALLLVL)

  • #2
    1) Are the programs ILE (I.e. DftActGrp(*no) or fake OPM programs (i.e. DftActGrp(*Yes) ?

    2) Are any/all of the files USROPN

    3) Can library2 be hardcoded ?

    Comment


    • #3
      Hi JonBoy,

      1. All are ILE
      2. USROPN is defined in PGM1. (Just noticed this. As PGM1 is the initial program, the file is manually opened here to library1, and when control returns back to PGM1, the file is closed).
      3. No. Actually i select this library from a screen. (Think of it this way - A screen is displayed asking user to input a library. That particular library will be passed in OVRDBF command)

      CL PGM1 (sorry for specifying this as RPGLE earlier).
      OVRDBF FILE(FILE1) TOFILE(LIBRARY1/FILE1) SECURE(*YES) OVRSCOPE(*CALLLVL) SHARE(*NO)
      OPNDBF FILE(FILE1) OPTION(*ALL) OPNSCOPE(*JOB)
      Call Pgm2
      CLOF OPNID(FILE1)
      DLTOVR FILE(*ALL) LVL(*)

      RPGLE PGM2
      This is the logic i am looking for. I need to override the file1 to library2, call PGM3, and cancel existing overrides so that it gets back the earlier overrides

      RPGLE PGM3
      Reads file1 and performs some operations. As per current behavior, file1 of library1 is read. And i need to ensure that this reads file1 of library2. No USROPN is specified here.

      Comment


      • #4
        Use the SECURE(*YES) parameter for the OVRDBF executed in PGM2. This will override the override (so to speak) in PGM1. If the override in PGM2 is also specified as OVRSCOPE(*CALLLVL), then merely exiting PGM2 will automatically delete the override from PGM2.

        Comment


        • #5
          Thanks a lot Brian. That actually helped solve the issue.

          Comment


          • #6
            To see what overrides are in effect when PGM3 is called, execute the command DSPOVR FILE(FILE1) just before calling PGM3. When I tried your example and used the SECURE(*YES) parameter for the override in PGM2, FILE1 was overridden to LIBRARY2 at the start of PGM3 so it worked for me.

            Comment


            • #7
              Thank you Brian. SECURE(*YES) worked. I have another query, just to confirm my understanding.

              For the same case, if i have to do override on top of override in same program, how should i define the OVRDBF command?

              That is, PGM1 calls PGM2. When control is in PGM2, the file is already open and overridden to library1. Now, in same PGM2 program, I want to override the file to library2, do a CHAIN operation to validate the record, and then delete override to library2. Can you tell me how to do this?

              Should i close the file, override to library2, and then open the file again? (If i do this, I lose the override performed on library1). Or any better way to do it?

              Comment


              • #8
                Yes, in that scenario you need to close the file, execute the override to LIBRARY2 (with the SECURE(*YES) parameter), and reopen the file. An override is only used at file open time, so executing an override on an already open file will have no effect until the file is closed and reopened. You won't lose the override of the file to LIBRARY1 if that override was issued in PGM1. If that's the case, then reestablish pointing the file to LIBRARY1 by closing the file, deleting the override to LIBRARY2 [DLTOVR FILE(name) LVL(*) ], and reopening the file.

                Comment


                • #9
                  Thanks Brian for clarifying.

                  Comment

                  Working...
                  X