IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Merge data from record pairs


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ashokakash

New User


Joined: 15 Nov 2006
Posts: 21
Location: Chennai

PostPosted: Tue Oct 16, 2018 7:02 pm
Reply with quote

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
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Wed Oct 17, 2018 11:43 am
Reply with quote

@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
View user's profile Send private message
ashokakash

New User


Joined: 15 Nov 2006
Posts: 21
Location: Chennai

PostPosted: Wed Oct 17, 2018 12:12 pm
Reply with quote

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
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Wed Oct 17, 2018 12:19 pm
Reply with quote

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 icon_rolleyes.gif

However, until we see what you have already tried ...................................
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Wed Oct 17, 2018 1:54 pm
Reply with quote

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
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Wed Oct 17, 2018 6:58 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts How to save SYSLOG as text data via P... All Other Mainframe Topics 1
No new posts Store the data for fixed length COBOL Programming 1
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
Search our Forums:

Back to Top