I am using SORT to do a couple of functions within a single step. If I separate the two functions, they work fine. However, when entered together, the dataset is cleared out.
I understand why the dataset is cleared out (because the INCLUDE statement cannot locate a value of 0 in the field it's comparing). And when I run the functions separately, I have SORTOUT pointing to DD SYSOUT=*. So here is the JCL I'm trying to get to work
What I'm trying to accomplish is this
1. Subtract 1 from the field that contains a numeric value (could be 0 - 9)
2. Compare the resulting value in the numeric field (from step 1) to a value of 0. If it's 0 then rc=0 otherwise rc=4
I'm sure this can be done in one step, however I don't understand how to do the compare without using the INCLUDE. Would appreciate any assistance, thanks.
Coded for you
I am using SORT to do a couple of functions within a single step. If I separate the two functions, they work fine. However, when entered together, the dataset is cleared out.
I understand why the dataset is cleared out (because the INCLUDE statement cannot locate a value of 0 in the field it's comparing). And when I run the functions separately, I have SORTOUT pointing to DD SYSOUT=*. So here is the JCL I'm trying to get to work
What I'm trying to accomplish is this
1. Subtract 1 from the field that contains a numeric value (could be 0 - 9)
2. Compare the resulting value in the numeric field (from step 1) to a value of 0. If it's 0 then rc=0 otherwise rc=4
I'm sure this can be done in one step, however I don't understand how to do the compare without using the INCLUDE. Would appreciate any assistance, thanks.
RTFM:
The SORT statements are executed not in the order you typed them in your code, but in pre-defined order, as described in any SORT manual.
That is, INCLUDE is always applied before INREC!!!
Hint: instead of the INCLUDE COND= statement use the parameter of a subsequent statement, such as OUTFIL INCLUDE=
//SYSUDUMP DD may be used after a catastrophic failure within SORT module itself, but there is absolutely no chance that any developer, even the must experienced one, would be able to get any useful information from this terrible huge listing; especially - from the spool, via SYSOUT=*
Sergeyken, yes, I did RTFM, that's how I got as far as I did, although I'll admit I obviously did not comprehend all that I read, and I don't think you fully understand my goal.
Rohit, I appreciate your example. However, after completion of your the two functions listed, I still lose the data in the dataset. So I guess I wasn't clear in what I'm trying to accomplish. Let me try again. The input and output dataset are the same in my example. The only field in the dataset is a 10 byte character field consisting of a single value (could be 0 - 9). So it might look like this
7 space space space ....... and so on
What I am trying to do is have SORT subtract 1 from the value in the dataset and overlay that existing value with a new value. So based on the data above, the end result should be
6 space space space ...... and so on
This logic is working as written. It's actually the second part of the SORT that is causing the issue. The logic is to compare the new value to 0. If it matches, I should get a return code of 0. If it doesn't I should get a return code of 4. That works too, however, because I'm using an INCLUDE, and the value doesn't equate to 0, the record does not get written to the dataset and it's left with just blanks. I'm trying to understand how to do the compare without losing the data that's in the dataset.
Your example (and mine too) is clearing the data from the dataset. Basically leaving 10 spaces.
This logic is working as written. It's actually the second part of the SORT that is causing the issue. The logic is to compare the new value to 0. If it matches, I should get a return code of 0. If it doesn't I should get a return code of 4.
This repeats your initial post, and this was explained to you in all previous responses.
Jeff Kirsch wrote:
That works too, however, because I'm using an INCLUDE, and the value doesn't equate to 0, the record does not get written to the dataset and it's left with just blanks.
The record really does not go to the dataset, but nothing is left with just blanks. This your statement is completely wrong.
Jeff Kirsch wrote:
I'm trying to understand how to do the compare without losing the data that's in the dataset.
Your example (and mine too) is clearing the data from the dataset. Basically leaving 10 spaces.
1) No compare can loose the data in the dataset, ever.
2) All SORT samples suggested to you do exactly what you asked about. If you in fact need something else, please, describe it clearly.
Thank you, Joerg and Sergeyken. I'll change the sequence of the SORT statements.
The physical sequence of SORT statements would not change the utility behavior, not a bit. You just need to keep in mind the order, in which the statements are applied.
It would be a good tone (for clarity!) also to code the statements in the same order they are "executed".
And also: to use proper code alignment, splitting into separate lines, adding comments, etc. etc. etc. This is being said to the world at least since 1960-s, but with no result - the code continues to be a garbage of words, and characters...