sponsored links

Collapse

Announcement

Collapse
No announcement yet.

How to get a list of duplicate jobs and select the most recent one

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

  • How to get a list of duplicate jobs and select the most recent one

    Hello,


    I am trying to use CPYSPLF to copy a spooled report that is produced each night, to a database file - I only want the most recent occurrence.

    However I get the "A duplicate job name xxxxxxxxxxxxxxxx was found" for each job.

    Anyone got any ideas how I could copy the most recent version of a specific report for a job that runs daily? I was thinking print out a list of jobs and then select the most recent one but I get the same error withing wrkjob/dspjob...


    Thanks,
    Ryan

  • #2
    Show us the command you are using.
    Regards

    Kit
    http://www.ecofitonline.com
    DeskfIT - ChangefIT - XrefIT
    ___________________________________
    There are only 3 kinds of people -
    Those that can count and those that can't.

    Comment


    • #3
      CPYSPLF FILE(AA0102P) TOFILE(XRDK/RK0102WF) JOB(REPORTJOB) SPLNBR(*LAST)

      The issue being that there is a REPORTJOB each day that produces an AA0102P report so it comes up with a duplicates error.

      Comment


      • #4
        I think my title is wrong really - apologies.

        I want to copy a spooled report file to a database file each day but when trying to I get "duplicate jobs" error which is fine, so my initial thought was to maybe print out a list of jobs, take the job information and use it in the program as variables to populate the relevant fields (hence the title) but I guess my actual question is how to copy a spooled report that's produced daily to a database file within a program.

        Comment


        • #5
          If you have access to change the program that runs the report, you could simply add the copy after the report is produced, specifying special value * for the job parameter.

          Otherwise, you'll need to specify the fully qualified name of the job (include job number and user).

          Cheers,

          Emmanuel

          Comment


          • #6
            You could use the QGYOLJOB API using format OLJB0200 and a selection key of 401 (date/time job became active) to get a list of jobs and locate the one with the latest run date.

            Comment


            • #7
              Thanks for the responses.

              I had a quick look at the program to ascertain if it was worth a change it and it transpires that it builds a work file that doesn't get cleared until its next run - so I can just hijack that! Didn't think of checking there initially (oops).

              I will take a look at the QGYOLJOB API though because I'm sure it will come in handy in the future.

              Thanks again

              Comment


              • #8
                The work file wasn't what I needed in the end.

                If anyone is interested; I had a bit of a google and found RCVMSG - after a bit of experimenting and looking at other examples I came up with the below.

                The reason I look for CPF3303 as well is because the report runs weekly on some machines, whilst it runs daily on others - yet the job in question runs everyday, so the most recent job might not always contain the report I am looking for.

                Probably not the most elegant way of doing things, but it works as I need it to.

                Code:
                CPYSPLF    FILE(&SPF) TOFILE(&LIB/&FLE) JOB(&JOB)
                MONMSG     MSGID(CPF0906 CPF3343) EXEC(DO)                
                
                RCVMSG     MSGTYPE(*LAST) MSGDTA(&MSGDTA) MSGID(&MSGID)      
                IF         COND(&MSGID *EQ ' ') THEN(GOTO CMDLBL(END))       
                IF         COND(&MSGID *NE 'CPF0906') THEN(GOTO CMDLBL(LOOP))
                ENDDO                                                        
                
                IF         COND(&MSGDTA = ' ') THEN(GOTO CMDLBL(END))
                CHGVAR     VAR(&USR) VALUE(%SST(&MSGDTA 11 10))
                CHGVAR     VAR(&NBR) VALUE(%SST(&MSGDTA 21 6)) 
                
                CPYSPLF    FILE(&SPF) TOFILE(&LIB/&FLE) + 
                             JOB(&NBR/&USR/&JOB)                 
                MONMSG     MSGID(CPF3303) EXEC(GOTO CMDLBL(LOOP))
                MONMSG     MSGID(CPF0000) EXEC(GOTO CMDLBL(END))
                Cheers,
                Ryan

                Comment

                sponsored links

                Collapse

                Working...
                X