Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

overlaying output file from file1 first and then file2

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
bhavya_sha

New User


Joined: 16 Apr 2005
Posts: 33

PostPosted: Tue Jan 05, 2010 2:34 pm    Post subject: overlaying output file from file1 first and then file2
Reply with quote

Hi,

I have a requirement as.

I have 2 files
key's are first 12 bytes in both files
file1 of record length 150
file2 of record length 300
output record length 300

Code:
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(OUT) ON(1,12,CH) WITHALL WITH(151,300)-
USING(CTL3)


requirement is to write matching records i.e
300 bytes from file1 to output file and also have to fill many fields which are empty in file1 record from file2 field data(extracted bytes) in output file.

Code:
/*
//CTL1CNTL DD *
INREC OVERLAY=(1,150,300x,451C'11')
/*
//CTL2CNTL DD *
INREC OVERLAY=(151:1,300,451C'22')
/*


I have written control card as
Code:
//CTL3CNTL DD *
OUTFIL FNAMES=OUT,INCLUDE=(451,2,CH,EQ,C'21'),
BUILD=(1:151,300,47:23,2,65:43,6....')
/
*

iam getting error saying incorrect formatting.could u pls help me out.
Thanks
Bhavya M S
Back to top
View user's profile Send private message

Lijo

New User


Joined: 24 Aug 2008
Posts: 41
Location: Cochin

PostPosted: Tue Jan 05, 2010 3:16 pm    Post subject: Reply to: overlaying output file from file1 first and then f
Reply with quote

Hi Bhavya,

Code:
BUILD=(1:151,300,47:23,2,65:43,6....')


As per above code you're filling 300 bytes first and then again try to fill at 47th position.

I think you should use 151 to 46 bytes first and then fill 47 & 48th position with 23,2. Then start from 49th position with remaining data of 300 bytes. Like as follows:
Code:
BUILD=(1:151,46,47:23,2,49:199,15,65:43,6....')


Also, your SPLICE criteria is wrong, you should use 151 to 301 bytes for getting matched records with trailing '21':

Code:
SPLICE FROM(T1) TO(OUT) ON(1,12,CH) WITHALL WITH(151,301)-
USING(CTL3)


Also, some explanations are confusing:
Quote:
file1 of record length 150

Quote:
300 bytes from file1
Back to top
View user's profile Send private message
bhavya_sha

New User


Joined: 16 Apr 2005
Posts: 33

PostPosted: Wed Jan 20, 2010 12:21 pm    Post subject: Reply to: overlaying output file from file1 first and then f
Reply with quote

HI,

is it's not possible to write as per above requirement mentioned?

i want to write all 300 bytes from file2 to outputfile of length 300 first
later i have to overwrite few fields in outputfile from file1.

Thanks in advance
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


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

PostPosted: Wed Jan 20, 2010 11:11 pm    Post subject:
Reply with quote

Showing your job that didn't work without clearly explaining what you're trying to do makes it difficult to help you.

Please show an example of the records in each input file (relevant fields only) and what you expect for output. Explain the "rules" for getting from input to output. Give the starting position, length and format of each relevant field. Give the RECFM and LRECL of the input files. If file1 can have duplicates within it, show that in your example. If file2 can have duplicates within it, show that in your example.

Also, run the following DFSORT job and post the //SYSOUT messages so I can see what level of DFSORT you're at.

Code:

//S1    EXEC  PGM=SORT             
//SYSOUT    DD  SYSOUT=*           
//SORTIN DD *                       
RECORD                             
//SORTOUT DD DUMMY                 
//SYSIN    DD    *                 
  OPTION COPY                       
/*                                 
Back to top
View user's profile Send private message
bhavya_sha

New User


Joined: 16 Apr 2005
Posts: 33

PostPosted: Thu Jan 21, 2010 2:43 pm    Post subject: Reply to: overlaying output file from file1 first and then f
Reply with quote

File1
2010007D0D A0036297H 00080 5603
20101Z500A A0063117C 00000 5607
20101Z7001 A0036294A 00005 5602

File2
201001T210 36297H
201001T810 63117C
2010036D01 63117C
20101NA09A 63117C
20101NA30A 63117C
20101Z500A 63117C
20101Z7001 63117C
20101Z7001 63117C

Outputfile
20101Z500A 5603 A0063117C 63117C
20101Z7001 5602 A0036294A 63117C
20101Z7001 5602 A0036294A 63117C


Hi Frank,

here i have tried giving an example as above.

File1 length 150
File2 length 300
outputfile 300

File2 is having duplicates and duplicates are required in output file.
File1 is not having duplicates
both files r having keys @ 1-12 bytes

Requirement is to match both the files and for matching records
i have to write output file2 completely and many blank fields has to be written
picking data from file1.

As of now i calculated position and have got proper output i have to automate it
now.is there any way so that i can write file2 data and then overwrite some fields in outputfile.


My DFSORT Version is
ICE201I F RECORD TYPE ...
which indicates
The F indicates we have the July, 2008 DFSORT functions (FINDREP, WHEN=GROUP, DATASORT, SUBSET, etc) and all of the earlier functions
Back to top
View user's profile Send private message
bhavya_sha

New User


Joined: 16 Apr 2005
Posts: 33

PostPosted: Thu Jan 21, 2010 2:48 pm    Post subject: Reply to: overlaying output file from file1 first and then f
Reply with quote

The spaces are getting removed so iam attahing file data
Back to top
View user's profile Send private message
Lijo

New User


Joined: 24 Aug 2008
Posts: 41
Location: Cochin

PostPosted: Thu Jan 21, 2010 5:06 pm    Post subject: Reply to: overlaying output file from file1 first and then f
Reply with quote

Bhavya,

Your original control cards were good enough to achieve this output. Only thing is you need to format OUTREC/BUILD of match file according to your output criteria.

Quote:
is there any way so that i can write file2 data and then overwrite some fields in outputfile.


Why don't you want to write all 300bytes (file2 data) first, when you're not needing that? You can write only required fields to output. Isn't it?
Back to top
View user's profile Send private message
bhavya_sha

New User


Joined: 16 Apr 2005
Posts: 33

PostPosted: Thu Jan 21, 2010 6:18 pm    Post subject: Reply to: overlaying output file from file1 first and then f
Reply with quote

Hi Liju,

i have to write cobol program which generates this icetool job as output and input for this cobol program is another pgm which is of not related to mf.
in the i/p pgm they are writing the file first and then overwriting from file1 data .
If i have to calculate the positions(exact positions as coded in icetool) is quite tough to generalise in cobol pgm .

Thanks & Regards,
Bhavya M S
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Jan 22, 2010 11:14 pm    Post subject: Reply to: overlaying output file from file1 first and then f
Reply with quote

Bhavya_sha,

I am not sure what you meant by "first write file 2 record and then overlay file 1 record values." The following JCL will give you the desired results. The file 1 values(the entire 150 bytes) are starting from pos 311 in the output record. You can pick the fields you want from there.

Code:

//STEP0100 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD DSN=your input fb 150 byte file,DISP=SHR
//SORTOUT  DD DSN=&&TEMP,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)         
//HDR      DD DSN=&&FHDR,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)         
//SYSIN    DD *                                                       
  SORT FIELDS=COPY                                                   
  OUTREC OVERLAY=(300:X)                                             
  OUTFIL FNAMES=HDR,REMOVECC,NODETAIL,HEADER1=('$$$')                 
//*                                                                   
//STEP0200 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD DSN=&&FHDR,DISP=SHR,VOL=REF=*.STEP0100.HDR             
//         DD DSN=&&TEMP,DISP=SHR                                     
//         DD DSN=&&FHDR,DISP=SHR,VOL=REF=*.STEP0100.HDR             
//         DD DSN=your input fb 300 Byte file,DISP=SHR             
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD *                                                       
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'$$$'),PUSH=(301:ID=1)) 
  SORT FIELDS=(1,12,CH,A),EQUALS                                     
  OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(303:SEQNUM,8,ZD,RESTART=(1,12))),
  IFTHEN=(WHEN=GROUP,BEGIN=(303,8,ZD,EQ,1),PUSH=(302:301,1,311:1,150))
                                                                     
  OUTFIL INCLUDE=(301,2,ZD,EQ,21,AND,1,3,CH,NE,C'$$$')
//*
Back to top
View user's profile Send private message
bhavya_sha

New User


Joined: 16 Apr 2005
Posts: 33

PostPosted: Thu Jan 28, 2010 6:18 pm    Post subject: Reply to: overlaying output file from file1 first and then f
Reply with quote

With the JCL mentioned below I’m trying to move key values from both files (Both in position 1-12 & I don’t want to retain key @ 1-12 position) to 151-163 bytes and build data as per control3 card for matching records.
File1 is of length 150 and File2 is of length 300
File2 is having Duplicates and I need duplicates too in output file.

Can anyone help me to understand why does the output file is having key value from position 151-160 which was supposed to be data from file2.(file2 is having spaces in these position)

Code:

//TOOLIN DD *
   COPY    FROM(IN1) TO(T1) USING(CTL1)
   COPY    FROM(IN2) TO(T1) USING(CTL2)
   SPLICE  FROM(T1)  TO(OUT) ON(151,12,CH) WITHALL WITH(163,300)-
   WITH(463,1) USING(CTL3)
/*
//CTL1CNTL DD *
   INREC   BUILD=(1,150,151:1,12,463:C'11')
/*
//CTL2CNTL DD *
   INREC   OVERLAY=(151:1,12,163:1,300,463:C'22')
/*
//CTL3CNTL DD *
           OUTFIL FNAMES=OUT,INCLUDE=(463,2,CH,EQ,C'21'),
           BUILD=(001:163,046,
                  047:053,006,
                  053:215,037,
                  090:121,004,
                  094:256,027,
                  121:029,006,
                  127:035,018,
                  145:307,056,
                  201:363,077,
                  278:149,001,
                  279:150,001,
                  280:442,010,
                  290:024,005,
                  295:457,006)
/*
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


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

PostPosted: Thu Jan 28, 2010 11:49 pm    Post subject:
Reply with quote

I can't tell enough about what you're trying to do from your description to analyze it completely, but the INREC statement in CTL2CNTL looks suspicious to me

Code:

  INREC   OVERLAY=(151:1,12,163:1,300,463:C'22')


Since you're doing an OVERLAY, you are first moving positions 1-12 into 151-162. Then you're moving the "changed" positions 1-300 to 163-462.
The changed 151-162 is part of that 1-300 bytes you're moving. Not sure if this makes a difference or not, but perhaps you meant so use:

Code:

   INREC BUILD=(1,150,151:1,12,163:1,300,463:C'22')


which would move the original 1-300 input bytes to 163-462.

If that's not it, then you really need to do a better job of explaining what you're trying to do.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 11 Tue May 16, 2017 2:20 pm
No new posts find RACF group for access to spooled... jzhardy JCL & VSAM 1 Mon May 08, 2017 11:46 am
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts Issue with NDM process to transmit ES... chetanambi All Other Mainframe Topics 6 Wed May 03, 2017 10:52 am
No new posts File processing vishwakotin Mainframe Interview Questions 9 Fri Apr 28, 2017 11:38 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us