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

[Solved]Trying to put date from File1 into first 5 pos of file2


IBM Mainframe Forums -> SYNCSORT
Post new topic   This topic is locked: you cannot edit posts or make replies.
View previous topic :: View next topic  
Author Message
CarolynP

New User


Joined: 29 Dec 2021
Posts: 6
Location: United States

PostPosted: Thu Dec 30, 2021 12:45 am
Reply with quote

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
View user's profile Send private message
sergeyken
Warnings : 2

Senior Member


Joined: 29 Apr 2008
Posts: 1421

PostPosted: Thu Dec 30, 2021 4:39 am
Reply with quote

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

Active Member


Joined: 15 Aug 2015
Posts: 751
Location: Bamberg, Germany

PostPosted: Thu Dec 30, 2021 12:19 pm
Reply with quote

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

New User


Joined: 29 Dec 2021
Posts: 6
Location: United States

PostPosted: Thu Dec 30, 2021 6:19 pm
Reply with quote

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
View user's profile Send private message
sergeyken
Warnings : 2

Senior Member


Joined: 29 Apr 2008
Posts: 1421

PostPosted: Thu Dec 30, 2021 6:48 pm
Reply with quote

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

New User


Joined: 29 Dec 2021
Posts: 6
Location: United States

PostPosted: Thu Dec 30, 2021 7:22 pm
Reply with quote

If I understood how it all works, I wouldn't be asking for help.
Back to top
View user's profile Send private message
CarolynP

New User


Joined: 29 Dec 2021
Posts: 6
Location: United States

PostPosted: Thu Dec 30, 2021 8:25 pm
Reply with quote

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
View user's profile Send private message
sergeyken
Warnings : 2

Senior Member


Joined: 29 Apr 2008
Posts: 1421

PostPosted: Thu Dec 30, 2021 8:39 pm
Reply with quote

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

Active User


Joined: 27 Apr 2005
Posts: 356
Location: Inside the SPEW (Cincinnati OH USA)

PostPosted: Thu Dec 30, 2021 9:21 pm
Reply with quote

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
View user's profile Send private message
sergeyken
Warnings : 2

Senior Member


Joined: 29 Apr 2008
Posts: 1421

PostPosted: Thu Dec 30, 2021 9:37 pm
Reply with quote

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

Global Moderator


Joined: 21 Sep 2010
Posts: 2862
Location: NYC,USA

PostPosted: Thu Dec 30, 2021 10:01 pm
Reply with quote

Welcome !
All you need to do is search the forum using SEARCH button on the top before asking for help as that will enable your analysis and learning skills.
Besides you can try this as well from other two solutions provided above.
ibmmainframes.com/about45659.html
www.ibmmainframeforum.com/syncsort-synctool/topic10656.html
Back to top
View user's profile Send private message
CarolynP

New User


Joined: 29 Dec 2021
Posts: 6
Location: United States

PostPosted: Thu Dec 30, 2021 10:38 pm
Reply with quote

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

Global Moderator


Joined: 21 Sep 2010
Posts: 2862
Location: NYC,USA

PostPosted: Thu Dec 30, 2021 10:49 pm
Reply with quote

It’s all right .. Glad it all worked for you.
Back to top
View user's profile Send private message
sergeyken
Warnings : 2

Senior Member


Joined: 29 Apr 2008
Posts: 1421

PostPosted: Thu Dec 30, 2021 11:05 pm
Reply with quote

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

Global Moderator


Joined: 21 Sep 2010
Posts: 2862
Location: NYC,USA

PostPosted: Fri Dec 31, 2021 2:35 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies. View Bookmarks
All times are GMT + 6 Hours
Forum Index -> SYNCSORT

 


Similar Topics
Topic Forum Replies
No new posts How to OMIT Records older than the cu... DFSORT/ICETOOL 15
No new posts sort remove records with date > 7year DFSORT/ICETOOL 6
No new posts Removing date values lines/records fr... SYNCSORT 2
No new posts SORT for dynamic trailer record + CSV... DFSORT/ICETOOL 14
No new posts Date conversation DFSORT/ICETOOL 6
Search our Forums:

Back to Top