Topic
1 reply Latest Post - ‏2012-04-19T18:35:52Z by SystemAdmin
planetjones
planetjones
7 Posts
ACCEPTED ANSWER

Pinned topic How to structure batch application - WebSphere XD 6.1

‏2012-04-19T13:34:14Z |
Hi there,

Fundamental question on how to structure a batch program I think - any help is appreciated.

My batch application begins something like this:

  • run sql count query to get number of records in x status
  • if count > 0 read all records and write a file
  • sequentially process other steps

How should I structure this with regard to Job Steps and xJCL ?

Specifically:

If I create a single step of:

  • run sql count query to get number of records in x status
  • if count > 0 read all records and write a file

I think resources would be unnecessarily opened and read, as the batch streams for opening the file and reading the full table data would be opened when that step is created. I only want to open these resources if count > 0.

I did think of splitting it into two steps i.e:

Step 1: run sql count query to get number of records in x status
Step 2: conditionally read all records and write a file

However, I don't think the conditional Step 2 is a viable option as Step 1 is successful irrespective of the count. I do not see a suitable return code for Step 1, which could cause Step 2 to skip (using the xJCL).

How are conditional steps like this best addressed?

Thanks.
Updated on 2012-04-19T18:35:52Z at 2012-04-19T18:35:52Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    783 Posts
    ACCEPTED ANSWER

    Re: How to structure batch application - WebSphere XD 6.1

    ‏2012-04-19T18:35:52Z  in response to planetjones
    You can set different return codes for a job step that ends normally. For example, set rc=0 if step1 created an output file and rc=4 if it did not. You can then use these values to control whether or not subsequent steps run. You can set your step return code using the JobStepContext.setReturnCode(int) method.