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

data of two files in one file


IBM Mainframe Forums -> FAQ & Basics
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Carloseven

New User


Joined: 01 Dec 2006
Posts: 4
Location: Portugal

PostPosted: Wed Jul 27, 2022 10:17 pm
Reply with quote

Hello


I have 2 data sets.
The input of my first data set is:
AAAAAAA

And the input of my second data set is:
111

And I want put that information in another data set, but the output dataset would look like this:
AAAAAAA111

Can help me. How I do that?
Thanks
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2023
Location: USA

PostPosted: Wed Jul 27, 2022 10:26 pm
Reply with quote

Since you have only one record in each of your datasets, I recommend to combine those two records manually, using available online tools.

The manual approach should take 100-1000 times less time, than any automation of this process.
Back to top
View user's profile Send private message
Carloseven

New User


Joined: 01 Dec 2006
Posts: 4
Location: Portugal

PostPosted: Wed Jul 27, 2022 10:31 pm
Reply with quote

I have more records. In example I only put the first record.
Back to top
View user's profile Send private message
dneufarth

Active User


Joined: 27 Apr 2005
Posts: 420
Location: Inside the SPEW (Southwest Ohio, USA)

PostPosted: Wed Jul 27, 2022 10:34 pm
Reply with quote

Will this be a one-to-one relationship or a one/many-to-whatever relationship?

www.ibm.com/docs/en/zos/2.1.0?topic=files-joinkeys-application-examples
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Wed Jul 27, 2022 10:38 pm
Reply with quote

Code:
//WHATEVER EXEC PGM=ICEMAN                             
//F1       DD *                                         
AAAAAAA                                                 
/*                                                     
//F2       DD *                                         
111                                                     
/*                                                     
//SYSOUT   DD SYSOUT=*                                 
//SORTOUT  DD SYSOUT=*                                 
//SYSIN    DD *                                         
  OPTION COPY                                           
  JOINKEYS F1=F1,FIELDS=(81,1,A)                       
  JOINKEYS F2=F2,FIELDS=(81,1,A)                       
  REFORMAT FIELDS=(F1:1,80,F2:1,80)                     
  OUTFIL FNAMES=(SORTOUT),                             
    REMOVECC,                                           
    BUILD=(1,160,SQZ=(SHIFT=LEFT,LENGTH=80))           
  END                                                   
/*                                                     
//JNF1CNTL DD *                                         
  OPTION STOPAFT=1                                     
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:X))               
  END                                                   
/*                                                     
//JNF2CNTL DD *                                         
  OPTION STOPAFT=1                                     
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:X))               
  END                                                   
/*
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Wed Jul 27, 2022 10:40 pm
Reply with quote

Carloseven wrote:
I have more records. In example I only put the first record.

Why not providing real samples using the code tag button then?
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2023
Location: USA

PostPosted: Wed Jul 27, 2022 10:53 pm
Reply with quote

Carloseven wrote:
I have more records. In example I only put the first record.


Hint:
1) re-number the input records in each of input "files" = datasets
2) join each two records, - matching them on equal record numbers
3) decide what to do when the number of records is different in both inputs?
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Wed Jul 27, 2022 11:10 pm
Reply with quote

Honestly, we need to see better sample data. Most of us helping here are volunteers. We have other things to do in our spare time.
Back to top
View user's profile Send private message
Carloseven

New User


Joined: 01 Dec 2006
Posts: 4
Location: Portugal

PostPosted: Thu Jul 28, 2022 9:07 pm
Reply with quote

Hello first thank you about your answer.

Second I execute the JCL... (change f1 and f2 with my data sets...

//SORTRDJ1 JOB (SYST),'SORTTEST,25/06,12:32',
// CLASS=A,MSGCLASS=X,NOTIFY=&SYSUID
//*
//SORT EXEC PGM=SORT
//F1 DD DSN=GPCCMN.SORT1.TESTE.D260722,DISP=SHR - FB 80
/*
//F2 DD DSN=GPCCMN.SORT2.TESTE.D260722,DISP=SHR - FB 80
/*
//SYSOUT DD SYSOUT=*
//SORTOUT DD DSN=GPCCMN.SORT5.TESTE.D260722, - FB 80
// DISP=(NEW,CATLG,DELETE),
// SPACE=(TRK,(1,1),RLSE),
// DCB=(LRECL=80,RECFM=FB)
//SYSIN DD *
OPTION COPY
JOINKEYS F1=F1,FIELDS=(81,1,A)
JOINKEYS F2=F2,FIELDS=(81,1,A)
REFORMAT FIELDS=(F1:1,80,F2:1,80)
OUTFIL FNAMES=(SORTOUT),
BUILD=(1,160,SQZ=(SHIFT=LEFT,LENGTH=80))
END
/*
//JNF1CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:X))
END
/*
//JNF2CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:X))
END

But my output don't stay like I want. He stay like that:

AAAAAAA0000010011100000100
AAAAAAA0000010022200000200
AAAAAAA0000010033300000300
AAAAAAA0000010044400000400
BBBBBBB0000020011100000100
BBBBBBB0000020022200000200
BBBBBBB0000020033300000300
BBBBBBB0000020044400000400
CCCCCCC0000030011100000100
CCCCCCC0000030022200000200
CCCCCCC0000030033300000300
CCCCCCC0000030044400000400
DDDDDDD0000040011100000100
DDDDDDD0000040022200000200

Can you help me again?
And can you explain another questions:
why you use ,FIELDS=(81,1,A) for F1 and F2 ??
And why 160 in build (BUILD=(1,160) ??

Thank you
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2023
Location: USA

PostPosted: Thu Jul 28, 2022 11:08 pm
Reply with quote

Did you ever read my answer?
Did you understand something of it?

sergeyken wrote:
Carloseven wrote:
I have more records. In example I only put the first record.


Hint:
1) re-number the input records in each of input "files" = datasets
2) join each two records, - matching them on equal record numbers
3) decide what to do when the number of records is different in both inputs?


P.S.

1. You are not "running JCL program".
You are running SORT application program, and all 100% of your issues are related exclusively to SORT, not to JCL, or VSAM, or whatever else.

2. Please!!!!! Learn how to use the Code button when presenting your samples!

3. When presenting your testing, present also your input and output data, properly, using the Code button. Or you can present your test data under your // DD * statements

4. Finally, start reading at least basic manuals on the stuff you intend to use in your life, before asking at the forum.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Thu Jul 28, 2022 11:52 pm
Reply with quote


  1. Search for "smart dfsort tricks" using your favorite search engine.
  2. Download the PDF file (preferably from IBM site but not necessarily)
  3. Look at all the different things you can do with a sort
  4. Look at the chapter called "Join fields from two files record-by-record"
  5. If you have questions about ICETOOL, search for "ICETOOL Mini-User Guide"

Even the sample is almost like yours (and the answer is yes, btw)
The book wrote:
I want to merge two files laterally record by record. For example:
If FILE1 contains:
AAAAA
BBBBB
CCCCC
and FILE2 contains:
11111
22222
33333
then my output file should contain:
AAAAA11111
BBBBB22222
CCCCC33333
Can DFSORT do this?


The ICETOOL document was written by our friendly Frank L. Yaeger, now retired. Let's hope he is enjoying his time !
Back to top
View user's profile Send private message
Carloseven

New User


Joined: 01 Dec 2006
Posts: 4
Location: Portugal

PostPosted: Fri Jul 29, 2022 3:34 am
Reply with quote

4. Finally, start reading at least basic manuals on the stuff you intend to use in your life, before asking at the forum.[/quote]

???
sergeyken I read the manual and read before ask...If I ask was because it not works what I do...you don't need help or answer if you don't want. when I put the JCL and my result the question is not for you.

Thank you
Back to top
View user's profile Send private message
dneufarth

Active User


Joined: 27 Apr 2005
Posts: 420
Location: Inside the SPEW (Southwest Ohio, USA)

PostPosted: Fri Jul 29, 2022 5:51 am
Reply with quote

Adjust the BUILD start, length to appropriate values for your example.

I believe specified FIELDS gives you a one to one match.

Been quite a few years since I’ve used DFSORT.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Fri Jul 29, 2022 8:56 am
Reply with quote

Change
Code:
  JOINKEYS F1=F1,FIELDS=(81,1,A)                       
  JOINKEYS F2=F2,FIELDS=(81,1,A)                       

to
Code:
  JOINKEYS F1=F1,FIELDS=(81,8,A)                       
  JOINKEYS F2=F2,FIELDS=(81,8,A)                       

and the INREC each to
Code:
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD))
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


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

PostPosted: Sat Jul 30, 2022 3:05 am
Reply with quote

Let us not make a big deal about this and help without criticizing any further.

Please try the solution posted above and if it doesn’t work then provide us with sample input data in both the data sets.

Moved to beginners section of this forum.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Sat Jul 30, 2022 5:15 am
Reply with quote

Basically JOINKEYS is NOT for beginners.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Mon Aug 01, 2022 5:40 pm
Reply with quote

By luck (or lack of it), I have to do something more or less similar.

Maybe only DFSORT uses the JNF1CNTL and JNF2CNTL, SYNCSORT seems to ignore them.
Quote:
//SYSIN DD *
OPTION COPY
JOINKEYS F1=F1,FIELDS=(81,1,A)
JOINKEYS F2=F2,FIELDS=(81,1,A)
REFORMAT FIELDS=(F1:1,80,F2:1,80)
OUTFIL FNAMES=(SORTOUT),
BUILD=(1,160,SQZ=(SHIFT=LEFT,LENGTH=80))
END
/*
//JNF1CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:X))
END
/*
//JNF2CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:X))
END

But my output don't stay like I want. He stay like that:

AAAAAAA0000010011100000100
AAAAAAA0000010022200000200
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Mon Aug 01, 2022 6:38 pm
Reply with quote

SYNCSORT behaves also exactly as wanted.
Code:
//WHATEVER EXEC PGM=SORT,PARM='MSG=AP'               
//F1       DD *                                       
AAAAAAA                                               
BBBBBBBBBBBBBB                                       
C                                                     
/*                                                   
//F2       DD *                                       
111                                                   
2                                                     
3333333                                               
/*                                                   
//SYSOUT   DD SYSOUT=*                               
//SORTOUT  DD SYSOUT=*                               
//SYSIN    DD *                                       
  OPTION COPY                                         
  JOINKEYS F1=F1,FIELDS=(81,8,A)                     
  JOINKEYS F2=F2,FIELDS=(81,8,A)                     
  REFORMAT FIELDS=(F1:1,80,F2:1,80)                   
  OUTFIL FNAMES=(SORTOUT),                           
    REMOVECC,                                         
    BUILD=(1,160,SQZ=(SHIFT=LEFT,LENGTH=80))         
  END                                                 
/*                                                   
//JNF1CNTL DD *                                       
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD))   
  END                                                 
/*                                                   
//JNF2CNTL DD *                                       
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD))   
  END                                                 
/*

Output:
Code:
AAAAAAA111     
BBBBBBBBBBBBBB2
C3333333       

Tested right now using:
Code:
SYNCSORT FOR Z/OS  3.1.0.0N
Back to top
View user's profile Send private message
dneufarth

Active User


Joined: 27 Apr 2005
Posts: 420
Location: Inside the SPEW (Southwest Ohio, USA)

PostPosted: Mon Aug 01, 2022 6:38 pm
Reply with quote

Perhaps CTL1 CTL2
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Mon Aug 01, 2022 7:39 pm
Reply with quote

I don't think so. UNNUM in 3.4 could help.
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 -> FAQ & Basics

 


Similar Topics
Topic Forum Replies
No new posts How to save SYSLOG as text data via P... All Other Mainframe Topics 4
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Store the data for fixed length COBOL Programming 1
Search our Forums:

Back to Top