7 Ответы Последний ответ: 09.03.2017 2:25, автор: pr921

    Calling Batch Job

    pr921

      How can I let the Events know that a particular load is initiated by a Batch Job?

       

      I am using Open Batch and have Event Specific code for a Batch Load.  Users may manually load or re-load an open batch formatted file.

       

      There's got to be a property somewhere that will know?

       

      Thanks,

      PR

        • 1. Re: Calling Batch Job
          SH_INT

          You can use the getBatchJobDetails Java API method to return a whole host of information about a batch job including LOADID which will allow to you validate whether your current job is a batch job or not.

           

          • 2. Re: Calling Batch Job
            pr921

            I saw that....couldn't quite get it working.

             

            Docs are too sparse...

             

            U have any example?  I get similar results as this...

             

            getBatchJobDetails

             

            Thanks,

            PR

            • 3. Re: Calling Batch Job
              pr921

              I saw this example...

               

              rs = fdmAPI.getLocationDetails(fdmContext["LOCKEY"])

              i = 1

              metaData = rs.getMetaData()

              while i <= metaData.getColumnCount():

                fdmAPI.logDebug(metaData.getColumnLabel(i))

                i +=1

               

              what property brings back the values for the getBatchJobDetails recordset?  It's not very well documented...

               

              Thanks,PR

              • 4. Re: Calling Batch Job
                SH_INT

                Yes, the documentation on the API methods isn't the best (nothing new there :-( ). However, the get methods do usually return a recordset as in the getLocationDetails example above. I haven't personally had the use the getBatchJobDetails and am not in a position to test it at the moment but I would try the following if you want to check whether the current execution is a batch job or a manual one:

                 

                import java.math.BigDecimal as BigDecimal # this import statement is required so you can convert the LOADID to the correct data type to be used in the get method call

                try:

                    rs = fdmAPI.getBatchJobDetails(BigDecimal(fdmContext["LOADID"]))

                    # If a recordset is returned i.e. its a batch job all code below the above line will be executed, if no recordset is returned then an exeception should be generated and and the code in the except block will be executed

                except Exception, err:

                    fdmAPI.logInfo("This is not a batch process")

                • 5. Re: Calling Batch Job
                  pr921

                  This returns nothing....it runs without any error. 

                   

                  rs = fdmAPI.getBatchJobDetails(fdmContext["LOADID"])

                      fdmAPI.logDebug("Get Details - " + str(rs.getColumnLabel("BATCH_NAME")))

                      while rs.next():

                     fdmAPI.logDebug("Get Details - " + str(rs.getColumnLabel("BATCH_NAME")))

                   

                   

                  This returns "TESTING Error: 'oracle.jdbc.driver.OracleResultSetImpl' object has no attribute 'getColumnLabel'"

                   

                   

                  rs = fdmAPI.getBatchJobDetails(fdmContext["LOADID"])

                   

                     fdmAPI.logDebug("Get Details - " + str(rs.getColumnLabel("BATCH_NAME")))

                   

                  That makes sense, you have to move onto the first record with .next()

                   

                  "getColumnLabel" and "next" are the only attributes of the rs,

                   

                  ...

                   

                  Thanks,

                  PR

                  • 6. Re: Calling Batch Job
                    SH_INT

                    When you passed the loadid in to the code i suggested was it for a valid batch job?

                    Your will always error as the LOADID parmameter passed to the getBatchJobDetails method must be of the type BigDecimal see my earlier code. Also its good practice to always embed your code in a try / except block for error handling. As I said I've not had chance to test my code snippet I thought that if no recordset was returned an exception might be generated but that looks like it is not the case so try the folllowing using a LOADID that is linked to a valid batch job:

                     

                    import java.math.BigDecimal as BigDecimal

                    try:

                        rs = fdmAPI.getBatchJobDetails(BigDecimal(fdmContext["LOADID"]))

                        while (rs.next()):

                            fdmAPI.logInfo("Batch name:- %s" % rs.getString("BATCH_NAME"))

                    except Exception, err:

                        fdmAPI.logInfo("An error occured - %s" str(err))

                    • 7. Re: Calling Batch Job
                      pr921

                      I get this error...

                       

                      An error occured - %sjava.math.BigDecimal(): 1st arg can't be coerced to double, int, long, java.math.BigInteger, char[], String

                       

                      Thanks,

                      PR