|
View previous topic :: View next topic
|
| Author |
Message |
ashokakash
New User

Joined: 15 Nov 2006 Posts: 21 Location: Chennai
|
|
|
|
Hello all,
Suppose, I want some value from 2nd record being brought to 1st record, how could I do that? Can somebody help me in this? Thank you!
Input
| Code: |
XXXXXXXXXXXXXXXX 12/31/18 ABCD123
15:15:43
YYYYYYYYYYYYYYYYYY 12/31/18 ABCD123
15:16:33
ZZZZZZZZZZZZZZZZ 12/31/18 ABCD123
15:17:23
AAAAAAAAAAAAAAAA 12/31/18 ABCD123
15:18:13
|
Desired output
first 4 chars of 1st record, date of first record and time stamp of 2nd record are pushed to the right of first 2 records and this process should go on for every 2 records.
| Code: |
XXXXXXXXXXXXXXXX 12/31/18 ABCD123 XXXX 12/31/18 15:15:43
15:15:43 XXXX 12/31/18 15:15:43
YYYYYYYYYYYYYYYYYY 12/31/18 ABCD123 YYYY 12/31/18 15:16:33
15:16:33 YYYY 12/31/18 15:16:33
ZZZZZZZZZZZZZZZZ 12/31/18 ABCD123 ZZZZ 12/31/18 15:17:23
15:17:23 ZZZZ 12/31/18 15:17:23
AAAAAAAAAAAAAAAA 12/31/18 ABCD123 AAAA 12/31/18 15:18:13
15:18:13 AAAA 12/31/18 15:18:13
|
Edited Title |
|
| Back to top |
|
 |
expat
Global Moderator

Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
@ashokakash
Learn to use the code tags yourself, it saves myself and other moderators from having to do YOUR work for you.
| Code: |
[code]
Your stuff
goes in here
[/code] |
- Pretty easy isn't it.
Learn to start a new thread, posting on the back of a five year old thread which was totally unrelated is just plain idle laziness.
I have put this into the DFSORT section as your previous effort was tagged onto a SORT product question. But hey ho, as YOU HAVE NOT bothered to say which language you would like help in, how the hell can I possibly know, or anyone else that may wish to help you.
So, you need to tell us -
1) A lot more about your request.
2) Which languages or utilities you are looking for a solution with.
3) Some information regarding the RECFM / LRECL of your datasets.
4) Relative positions and lengths of field being manipulated.
5) Any other conditions / checks that may exist.
6) Most important What you have tried so far and the failing results.
Please, learn to help yourself and those that may want to help you, you have been a member of the forum for 12 years now. |
|
| Back to top |
|
 |
ashokakash
New User

Joined: 15 Nov 2006 Posts: 21 Location: Chennai
|
|
|
|
I regret the inconvenience. I refined the input/output below. The problem is date and time stamp is split and the date comes in first record and in the 2nd record same position comes the time stamp.
Input
| Code: |
XXXXXXXXXXXXXXXX 12/31/18 ABCD123
15:15:43
YYYYYYYYYYYYYYYY 12/31/18 ABCD123
15:16:33
ZZZZZZZZZZZZZZZZ 12/31/18 ABCD123
15:17:23
AAAAAAAAAAAAAAAA 12/31/18 ABCD123
15:18:13
|
Output
| Code: |
XXXXXXXXXXXXXXXX 12/31/18 ABCD123 XXXX 12/31/18 15:15:43
15:15:43 XXXX 12/31/18 15:15:43
YYYYYYYYYYYYYYYY 12/31/18 ABCD123 YYYY 12/31/18 15:16:33
15:16:33 YYYY 12/31/18 15:16:33
ZZZZZZZZZZZZZZZZ 12/31/18 ABCD123 ZZZZ 12/31/18 15:17:23
15:17:23 ZZZZ 12/31/18 15:17:23
AAAAAAAAAAAAAAAA 12/31/18 ABCD123 AAAA 12/31/18 15:18:13
15:18:13 AAAA 12/31/18 15:18:13
|
I need SORT utility to get the desired output. Every two records are related and the both must be affixed with first 4 characters of 1st record, 8 chars from position 18 of 1st record and 8 chars from position 18 of 2nd record.
I hope I made my requirement clear. If it is not sufficient, please let me know. Thank you! |
|
| Back to top |
|
 |
expat
Global Moderator

Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Which SORT product are you using - DFSORT or SYNCSORT - and it's release level.
RECFM / LRECL of the records - as requested above
Positions of the added output fields - as requested above
What you have tried yourself and the failing results
Not having used SORT for ages but you can create an intermediate record by appending the second record to the first, and then working with the newly created record - two passes of the data will be needed I think.
Or you could wait for a suggested possible one pass solution from "one of the better sorts" on the forum
However, until we see what you have already tried ................................... |
|
| Back to top |
|
 |
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1217 Location: Dublin, Ireland
|
|
|
|
There may be a better way but you could, in three passes:
Add sequence numbers (INREC) and, (OUTREC) for the the groups of 2 records, PUSH the fields from the 1st record into the required positions in both records of the pair.
Sort descending on the sequence numbers and PUSH the timestamp from what is now the first record of a group of two into both records of the pair.
Sort ascending on the sequence number dropping the sequence numbers.
Garry. |
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
Here is a version of expat's idea above assuming FB/LRECL=80 input/output data. Push the first record onto the second record and then use the 'merged' second record to write two output records with the required fields in OUTFIL
| Code: |
//SYSIN DD *
OPTION COPY
OUTREC IFTHEN=(WHEN=GROUP,RECORDS=2,PUSH=(81:SEQ=1,1,80))
OUTFIL INCLUDE=(81,1,CH,EQ,C'2'),
BUILD=(82,34,82,4,X,99,8,X,18,8,80:X,/,
01,34,82,4,X,99,8,X,18,8)
/* |
|
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|