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

Copying Data from 2 files into one file


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ajaikumar andy robert
Warnings : 1

New User


Joined: 01 Dec 2006
Posts: 23
Location: India

PostPosted: Thu Feb 08, 2007 8:52 pm
Reply with quote

hi

i need to copy data from 2 files of various lengths, into one file.
say one file has data of length 19 and the second one has length 2.
i need to copy both of these into one output file side by side.
i.e if the first file contains time and second file contains count, then

the output should be

TIME= (value from first file) COUNT=(value from second file)

where TIME and COUNT are strings included in the output file manually.
can some tell me whether this could be done using SORT pgm?
pls provide the syntax here.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Feb 08, 2007 9:40 pm
Reply with quote

Here's a DFSORT/ICETOOL job that will do what you asked for:

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN1 DD DSN=...  input file1 (FB/19)
//IN2 DD DSN=...  input file2 (FB/2)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD DSN=...  output file (FB/33)
//TOOLIN   DD    *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(OUT) ON(34,8,ZD) -
  WITH(32,2) USING(CTL3)
/*
//CTL1CNTL DD *
  INREC BUILD=(C'TIME=',6:1,19,26:C'COUNT=',34:SEQNUM,8,ZD)
/*
//CTL2CNTL DD *
  INREC BUILD=(32:1,2,34:SEQNUM,8,ZD)
/*
//CTL3CNTL DD *
  OUTFIL FNAMES=OUT,BUILD=(1,33)
/*


For more information on this type of "join", see the "Join fields from two files record-by-record" Smart DFSORT Trick at:

www.ibm.com/servers/storage/support/software/sort/mvs/tricks/
Back to top
View user's profile Send private message
ajaikumar andy robert
Warnings : 1

New User


Joined: 01 Dec 2006
Posts: 23
Location: India

PostPosted: Thu Feb 08, 2007 10:11 pm
Reply with quote

hi frank..

thnks for the reply..
i tried to run your code, and it gives me this error.
can you pls help me out with this?


CTL1CNTL :
INREC BUILD=(C'TIME=',6:1,19,26:C'COUNT=',34:SEQNUM,8,ZD)
PARMLIST :
OPTION RESINV=0,ARESINV=0,MSGDDN=DFSMSG,SORTIN=SORTIN1,SORTOUT=TEMP,SORTDD=CTL
COPY
WER428I CALLER-PROVIDED IDENTIFIER IS "0001"
WER276B SYSDIAG= 46453, 437238, 437238, 1598304
WER164B 8,960K BYTES OF VIRTUAL STORAGE AVAILABLE, MAX REQUESTED,
WER164B 0 BYTES RESERVE REQUESTED, 3,138,144 BYTES USED
WER146B 4K BYTES OF EMERGENCY SPACE ALLOCATED
WER108I SORTIN1 : RECFM=FB ; LRECL= 34; BLKSIZE= 27982
WER257I INREC RECORD LENGTH = 41
WER238I POTENTIALLY INEFFICIENT USE OF INREC
WER110I TEMP : RECFM=FB ; LRECL= 41; BLKSIZE= 27962
WER416B SORTIN1 : EXCP'S=1,UNIT=3390,DEV=8D48,CHP=(A1A5A9ADC1C5C9CD,1),VOL=G
WER416B TEMP : EXCP'S=1,UNIT=3390,DEV=8B74,CHP=(9195999DB1B5B9BD,2),VOL=G
WER416B TOTAL OF 2 EXCP'S ISSUED FOR COPYING
WER054I RCD IN 1, OUT 1
WER169I RELEASE 1.2 BATCH 0427 TPF LEVEL 1.0



ajai
Back to top
View user's profile Send private message
ajaikumar andy robert
Warnings : 1

New User


Joined: 01 Dec 2006
Posts: 23
Location: India

PostPosted: Thu Feb 08, 2007 10:42 pm
Reply with quote

HI FRANK

IS IT POSSIBLE TO OBTAIN TIMESTAMP IN THE SORT ITSELF, BECAUSE THIS WILL SOLVE MY PROBLEM EASLIY. RIGHT NOW I M ABLE TO GET THE CURRENT DATE FROM THE SORT ITSELF BY THIS SYNTAX,

SORT FIELDS=COPY
OUTREC FIELDS=(C'START TIME= ',DATE,C' NUM REC IN FILE= ',1,16)


I WANT TO KNOW WHETHER ANY SUCH COMMAND IS PRESENT TO RETRIEVE TIME ALSO IN THIS WAY. THEN THER WILL BE NO NEED FOR ME TO COPY DATA FROM 2 FILES.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Thu Feb 08, 2007 11:50 pm
Reply with quote

Ajai,

Good news, Bad news......You have Syncsort........Synsort does have date and time available in outrec (trailers?)..........In the listing given, it seems that it ran but with little or no input? No major errors pointing to the control statements......
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri Feb 09, 2007 2:04 am
Reply with quote

Ajai,

You can use TIME1 (or variations) to get the current time.

Note: I'm a DFSORT developer. DFSORT and Syncsort are competitive products. I'm happy to answer questions on DFSORT and DFSORT's ICETOOL, but I don't answer questions on Syncsort.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Feb 09, 2007 3:09 am
Reply with quote

Hi Ajai,

How did these 2 files get created?

What do you want to happen if ever one file has a different number of records than the other?
Back to top
View user's profile Send private message
ajaikumar andy robert
Warnings : 1

New User


Joined: 01 Dec 2006
Posts: 23
Location: India

PostPosted: Fri Feb 09, 2007 9:49 am
Reply with quote

hi guys

thanks for all the help. i was able to solve it finally using ICETOOL pgm itself. the way frank suggested icon_smile.gif . i get these 2 files from previous steps of the jcl. these 2 files always have one record only.. one containing timestamp and another oen the record count. If some one needs the syntax pls let me know.
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 7
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Access to non cataloged VSAM file JCL & VSAM 18
Search our Forums:

Back to Top