View previous topic :: View next topic
|
Author |
Message |
CarolynP
New User
Joined: 29 Dec 2021 Posts: 6 Location: United States
|
|
|
|
I'm trying to use Syncsort and need to insert a date from a control card file into the beginning of records in a second file. Not sure how to get this completed. I've created files for both so that the lrecl is the same.
First file has only julian date - 21356
Second file has data and is 150 characters long.
Want to move second file over and add the julian date from first file into every record - first 5 positions.
Do not want to use system date in case of reruns.
Cannot add attachments of actual data due to sensitivity of my position. |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2140 Location: USA
|
|
|
|
Code: |
//JOIN EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//DATE DD *
21356
//*
//INPUT DD *
xxxxx 111111
xxxxx 222222
xxxxx 333333
xxxxx 444444
xxxxx 555555
//*
//OUTPUT DD SYSOUT=*
//SYSIN DD *
JOINKEYS F1=DATE,FIELDS=(6,1,A)
JOINKEYS F2=INPUT,FIELDS=(6,1,A)
REFORMAT FIELDS=(F1:1,5,F2:6,74) change to the actual LRECL of F2
SORT FIELDS=COPY
OUTFIL FNAMES=OUTPUT
END
//* |
|
|
Back to top |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1334 Location: Bamberg, Germany
|
|
|
|
It also works with concatenating the datasets. However, the JOINKEYS solution looks more elegant.
Code: |
//WHATEVER EXEC PGM=SORT
//SORTIN DD DDNAME=DATE
// DD DDNAME=INPUT
//DATE DD *
21356
/*
//INPUT DD *
111111
222222
333333
444444
555555
/*
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=INIT,OVERLAY=(151:SEQNUM,10,ZD)),
IFTHEN=(WHEN=GROUP,BEGIN=(151,10,ZD,EQ,+1),PUSH=(161:1,5))
OUTFIL FNAMES=(SORTOUT),
INCLUDE=(151,10,ZD,NE,+1),
BUILD=(161,5,1,150)
END
/* |
|
|
Back to top |
|
|
CarolynP
New User
Joined: 29 Dec 2021 Posts: 6 Location: United States
|
|
|
|
I'm using the first suggestion of JOINKEYS but keep receiving an error of "REFORMAT FILE OUTSIDE RANGE".
The DATE file is FB.80 and the INPUT file is FB.150.
Tried to use input DATE file of FB.5 but that isn't working either.
Just not sure what I'm doing wrong. |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2140 Location: USA
|
|
|
|
CarolynP wrote: |
I'm using the first suggestion of JOINKEYS but keep receiving an error of "REFORMAT FILE OUTSIDE RANGE".
The DATE file is FB.80 and the INPUT file is FB.150.
Tried to use input DATE file of FB.5 but that isn't working either.
Just not sure what I'm doing wrong. |
Without your sample of code there is nothing to talk about.
Your message looks like:
Quote: |
I do everything right, but it is not working. Please tell me, why? |
If your INPUT dataset has LRECL=150, then you need
Code: |
REFORMAT FIELDS=(F1:1,5,F2:6,145) - total size = 5+145=150 |
Your problem is: you try to copy-and-paste the given suggestion without any attempt to understand: how it works?
Important: do you know how JOINKEYS works?
The training sample assumed that both input datasets have blank characters at their positions number 6. If it is not true in your practical case, then you MUST change your JOIN criteria accordingly. |
|
Back to top |
|
|
CarolynP
New User
Joined: 29 Dec 2021 Posts: 6 Location: United States
|
|
|
|
If I understood how it all works, I wouldn't be asking for help. |
|
Back to top |
|
|
CarolynP
New User
Joined: 29 Dec 2021 Posts: 6 Location: United States
|
|
|
|
My input date file is FB,5,0 and has '21365'.
My other input file is FB,150,0 and has data such as '1111122222', etc. Sometimes there is a header record such as 'SDO 333333'. So there are no 'keys' per se to match on.
I've been usinging the coding of:
JOINKEYS F1=DATE,FIELDS=(1,5,A)
JOINKEYS F2=INPUT,FIELDS=(1,5,A)
REFORMAT FIELDS=(F1:1,5,F2,1,145)
SORT FIELDS=COPY
I'm getting data but not as I need it. I need to have the output show '2136511111222222' or '21365SDO 33333'.
It comes out:
' 111112222'
' SDO 33333'
'12365 '
My apologies for not showing actual coding or data, but I'm doing the best I can with what I can. I'm not asking for someone to do it for me, but I'm unable to get either SORT or SYNCSORT to do what I need. Thank you. |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2140 Location: USA
|
|
|
|
It is not possible to understand your explanation.
Your
Code: |
JOINKEYS F1=DATE,FIELDS=(1,5,A)
JOINKEYS F2=INPUT,FIELDS=(1,5,A) |
doesn't make any sense; please, read about joining records in a SORT manual.
Give an example of your few input records. Hide critical info with XXXXXXX and YYYYYY; the only thing to clarify is: what is the formatting of your input????[/quote]
Before you start working with your production data, you MUST train yourself on simple examples, as in my first post. YOU NEED TO UNDERSTAND THE IDEA BEFORE GOING TO PRODUCTION!
Do not forget to use CODE tags for your code samples! |
|
Back to top |
|
|
dneufarth
Active User
Joined: 27 Apr 2005 Posts: 420 Location: Inside the SPEW (Southwest Ohio, USA)
|
|
|
|
Perhaps SYMNAMES used with BUILD might be an easier approach.
Sorry, been away from SORT for some time and too rusty to provide the details. |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2140 Location: USA
|
|
|
|
dneufarth wrote: |
Perhaps SYMNAMES used with BUILD might be an easier approach.
Sorry, been away from SORT for some time and too rusty to provide the details. |
SYMNAMES may work, but it requires a special format for this DATE "file" (e.g. dataset).
Even PARM for SORT can do the job, but the TS wants the single date to be taken from his "file", for no reason. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3076 Location: NYC,USA
|
|
Back to top |
|
|
CarolynP
New User
Joined: 29 Dec 2021 Posts: 6 Location: United States
|
|
|
|
Thank you everyone. I used Syncsort way back when and was unfamiliar with JOINKEYS. I did finally get everything to work the way I need it using the JOINKEYS example above. It was a matter of tweaking the file sizes and such.
I apologize again for not being able to paste actual code in here. I cannot use this forum from my work computer and that meant I had to type in what I was asking. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3076 Location: NYC,USA
|
|
|
|
It’s all right .. Glad it all worked for you. |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2140 Location: USA
|
|
|
|
The help forum is supposed to teach people thinking with their own mind, not to do their job for them, and for free.
Code: |
//JOIN EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//DATE DD *
21356
//*
//INPUT DD *
SDO 333
111111
222222
333333
444444
555555
//*
//OUTPUT DD SYSOUT=*
//JNF1CNTL DD *
INREC OVERLAY=(6:X) make sure the blank character to join
//*
//JNF2CNTL DD *
INREC OVERLAY=(151:X) append blank character to join
//*
//SYSIN DD *
JOINKEYS F1=DATE,FIELDS=(6,1,A) join on overlaid blank
JOINKEYS F2=INPUT,FIELDS=(151,1,A) join on appended blank
REFORMAT FIELDS=(F1:1,5, append the date in front
F2:1,150) truncate extra blank
SORT FIELDS=COPY
OUTFIL FNAMES=OUTPUT
END
//* |
|
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3076 Location: NYC,USA
|
|
|
|
Quote: |
The help forum is supposed to teach people thinking with their own mind, not to do their job for them, and for free. |
Locking it as TS was able to figure out the fix and acknowledged above. There is no expectations to post solutions if one don’t want to. So let us save time going forward. If you have concerns then pls PM me as I want to avoid arguments and discourage any new joiners posting here. |
|
Back to top |
|
|
|