I am unable to write the syntax for condition for TRACE-NUMBER. The reason why I am using SORT is , I am extracting data from a file for validation with a report after production implementation.
Please help if SORT has any function/syntax for this. Let me know if I need to furnish more details.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
Rohit,
If you INCLUDE/OMIT COND= you can avoid the repeated record-type test. There's no point in a case like this of retaining data only to ignore it later.
However, there's not indication that there are other than 00101 records, so why bother?
There's no need for the WHEN=NONE if you are just going to BUILD the same record that already exists.
To use an edit mask to get rid of the leading zeros and then SQZ is a good idea, but I don't think you need to destroy the original data just to recreate it later. Extend the record. You can also use LENGTH=4 on the SQZ, as only four characters are wanted, and IFOUTLEN to limit the records (not no important for a COPY, but for a SORT you'd not need spurious extra data hanging around).
There's also no point, in this case, of recreating the first part of the record in the OUTFIL. It is just sitting there already as 1,6. You could OVERLAY with your second EDIT. However, having not destroyed the input, a simple BUILD to cut off the extension.
Thanks for the notes Bill. that makes me learn and improve my dfsort logic.
I assumed TS wanted onetime sort card so did try some quick sort but your tips certainly helps.
Quote:
However, there's not indication that there are other than 00101 records, so why bother?
TS say's
Quote:
Fetch records where
1. TRAN-CODE = 101 and
2. TRACE-NUMBER begins with 9954 OR 9568 (excluding the leading zeros)
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
Yes, I missed that. There are no other record-types in the sample data. A simple INCLUDE COND= as well, then.
For the actual task, with only two selections, and from a fairly short length of data, enrico's is the best solution. As the number of selections increase, and the length of the data increases, this one comes more into play.
Preserving the original data is not sacrosanct. There are many occasions where changing the data temporarily then setting it back are the best solution to a task. It need not matter if five zeros are removed and five zeros in the same position are added later. However, there is usually no point in doing it just for the sake of doing it.
Note: if dropping the leading zeros for spaces in the original position Abid's SS, with a leading blank for the value, becomes possible. The leading zeros have to be returned later. Although it works, it is likely more expensive.
Oh, and JFY for this is better than SQZ. I'll update my previous post for that.
I used Bill's trick as the requirement I have mentioned is part of a bigger selection condition and the data length is also larger. It served the purpose.
Thank you all for taking out your valuable time to propose different solutions. I learnt some new SORT tricks.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
If you already have something which you need to amend for new processing, it is always best to post what you already have. There can be different solutions which each are a better fit for one set of existing control cards or another.
If you can show what you have come up with, we will be able to make concrete suggestions for that context.