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
 

 

Split File in multiple and attaching Header and Trailer
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
puneetvirmani143

New User


Joined: 24 Jul 2007
Posts: 55
Location: noida

PostPosted: Wed Feb 29, 2012 11:02 am    Post subject: Split File in multiple and attaching Header and Trailer
Reply with quote

Hi,

I have a file containing records along with Header and trailer. Header and Trailer both contain count of records in file excluding Header and Trailer and is always equal.

Each detail record has 2 byte code appeaing at the end which will form the basis for spilitting into several file. Ex A1 , A2 , A3. No of codes appearing at the end of each detail record are fixed set of codes which i already know..

my requirement is to :

Ex.
Code:
HEADER 02/02/2012 FILENAME  <<COUNT>>
123456788888A1
676575756757A1
678967867867A1
898989896757A2
TRAILER <<COUNT>>

COUNT here is 0004

Output required

File - A1
Code:
HEADER 02/02/2012 FILENAME  <<COUNT>>
123456788888A1
676575756757A1
678967867867A1
TRAILER <<COUNT>>


Count for A1 = 3

File - A2
Code:
HEADER 02/02/2012 FILENAME  <<COUNT>>
898989896757A2
TRAILER <<COUNT>>


Coutn for A1 = 1


1. Spilt the file to various files based on 2 byte code appearing at end of each record.
2. attach Header and trailer to each output file having same info as in Combined file with COUNT field having the actual no of records written to each broken file.

Please help !!

Regards
Puneet
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Feb 29, 2012 11:24 am    Post subject:
Reply with quote

how many different codes (output files can there be).
had you bothered to search the forum,
the kind of question that you are posing is repeated weekly,
you would know that the potential number of output files is handy to have.

other tidbits of handy info are:
actual column positions for fields within records,
record length.

the date in the header record is to be copied as is?

and why do you want the count in both header and trailer?
of course it is doable,
but why incur the extra resources necessary to generate the header count?

oh yeah last but not least, learn to use BBCode
Back to top
View user's profile Send private message
puneetvirmani143

New User


Joined: 24 Jul 2007
Posts: 55
Location: noida

PostPosted: Wed Feb 29, 2012 12:11 pm    Post subject:
Reply with quote

Hi,

Input file will be 80 Bytes in length and Output files also required as 80 bytes.

1) there can be max 50 different codes and hence 50 output files.
2) Code for splitting the file is appearing at 79,80th byte position (2 char)
3) All info in header will be written to each output file, but COUNT having value equal to no of records written in file.
4) Header and Trailer will both contain COUNT of records in file excluding Header and Trailer.
4) In header, count field starts at 25th pos and length 8 bytes
5) Trailer has Count start at 8th position and length 8 bytes.

Regards
manoj
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Wed Feb 29, 2012 10:51 pm    Post subject:
Reply with quote

Puneetvirmani143,

Use the following DFSORT JCL which will give you the desired results

Code:

//STEP0100 EXEC PGM=SORT                                       
//SYSOUT   DD SYSOUT=*                                         
//INA      DD DSN=your input file Fb 80 byte file,DISP=SHR
//INB      DD DSN=same input file Fb 80 byte file,DISP=SHR
//A1       DD SYSOUT=*                                         
//A2       DD SYSOUT=*                                         
//A3       DD SYSOUT=*                                         
.... all 50 output files you want
//SYSIN    DD *                                               
  OPTION COPY                                                 
  JOINKEYS F1=INA,FIELDS=(79,2,A)                             
  JOINKEYS F2=INB,FIELDS=(79,2,A)                             
  REFORMAT FIELDS=(F1:1,80,F2:1,88)                           
  INREC OVERLAY=(105:161,8)
                                   
  OUTFIL FNAMES=A1,REMOVECC,INCLUDE=(79,2,CH,EQ,C'A1'),BUILD=(1,80),       
  HEADER1=(81,80),TRAILER1=('TRAILER',161,8)                   

  OUTFIL FNAMES=A2,REMOVECC,INCLUDE=(79,2,CH,EQ,C'A2'),BUILD=(1,80),       
  HEADER1=(81,80),TRAILER1=('TRAILER',161,8)                   
 
  .. repeat the same outfil for all the 50 files

//*
//JNF1CNTL DD *                                               
  OMIT COND=(1,1,SS,EQ,C'H,T')                                 
//*
//JNF2CNTL DD *                                               
  OMIT COND=(1,1,CH,EQ,C'T')                                   
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:7C'0',C'1')),           
  IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'H'),PUSH=(1,78))       
  SUM FIELDS=(81,8,ZD)                                         
//*
Back to top
View user's profile Send private message
puneetvirmani143

New User


Joined: 24 Jul 2007
Posts: 55
Location: noida

PostPosted: Sat Oct 06, 2012 11:14 pm    Post subject:
Reply with quote

Hi,

One of my collegue has reported that when for a particualr code ex. A2 there is no record in input file. Header and trailer are not appearing properly in the file corresponding to A2.

Can you please help ?

Also INREC OVERLAY=(105:161,8)
how did you choose 105 ??

regards
Puneet
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Sun Oct 07, 2012 12:13 am    Post subject:
Reply with quote

thx for the timely feedback.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Sun Oct 07, 2012 1:00 am    Post subject: Reply to: Split File in multiple and attaching Header and Tr
Reply with quote

please, please tell Your colleague/friend to use his neuron ...
how is <somebody> supposed to manage/handle/carry_on_some_action based on something that is not there

if no record satisfying the condition
Code:
... INCLUDE=(79,2,CH,EQ,C'A2') ...

is found
the statement processing is <skipped>
and there is noo way to invent something to be written
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Sun Oct 07, 2012 3:42 am    Post subject: Reply to: Split File in multiple and attaching Header and Tr
Reply with quote

Did this take eight months to test?

As enrico indicates, with no data for A2 it is foolish to expect the header/trailer for the A2-file to contain anything at all based on A2 data.

You did not mention in your original requirement the possibility of any of the codes not have data associated with it.

Kolusu did not "choose" 105, you did. Look at the REFORMAT record definition: 80 bytes from file 1 record, 88 bytes from file 2. On file 2 there is a field that you want which starts at position 25. 80 + 25 = 105.

Now I suppose you have an updated requirement? Or you'll manage that yourself with the information already provided?
Back to top
View user's profile Send private message
puneetvirmani143

New User


Joined: 24 Jul 2007
Posts: 55
Location: noida

PostPosted: Sun Oct 07, 2012 11:32 pm    Post subject:
Reply with quote

Hi,

There is a possibility of No records present for a code ex. A2.
With current SORT condition, there are still 2 records appearing in Output file for A2 as:

Record 1 : Entire record with SPACES
Record 2: TRAILER

However , i want following should appear in case there is no records for A2 in Input file :

Original header record in input file with Count = 00000000 and trailer with COunt = 00000000 as there are no records coming in INPUT for code : A2.

HEADER 02/02/2012 FILENAME <<COUNT>>
TRAILER <<COUNT >>
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Mon Oct 08, 2012 11:29 pm    Post subject:
Reply with quote

puneetvirmani143 wrote:
Hi,

One of my collegue has reported that when for a particualr code ex. A2 there is no record in input file. Header and trailer are not appearing properly in the file corresponding to A2.

Can you please help ?

Also INREC OVERLAY=(105:161,8)
how did you choose 105 ??

regards
Puneet


puneetvirmani143,

Thank you for your timely feed back and I am extremely sorry that I canNOT help you create something that doesn't exist.
Back to top
View user's profile Send private message
puneetvirmani143

New User


Joined: 24 Jul 2007
Posts: 55
Location: noida

PostPosted: Tue Oct 09, 2012 11:19 pm    Post subject: Reply to: Split File in multiple and attaching Header and Tr
Reply with quote

Hi,

I tried changing the SYSIn statement for A2 from

OUTFIL FNAMES=A2,REMOVECC,INCLUDE=(79,2,CH,EQ,C'A2'),BUILD=(1,80),
HEADER1=(81,80),TRAILER1=('TRAILER',161,8)

This works fine if there is atleast 1 record for each code in input file. But does not produce a proper header/trailer file if for a particualr code there is no record in input file.

TO

OUTFIL FNAMES=A2,REMOVECC,
IFTHEN=(WHEN=(79,2,CH,EQ,C'A2'),BUILD=(1,78)),
HEADER1=(81,78),TRAILER1=('TRAILER',161,8)

ifthen=(WHEN=NONE,BUILD=(1,78)),HEADER1=(1,78),OVERLAY=(25:8x),TRAILER1=('TRAILER',8X)

BUT it is not giving desired output for A2 when there is no related records in input file.

I should get output file for A2 as below if there are no A2 records in input.

HEADER --> 1st 24 Bytes same as in Input file + 25th -32 Pos as 00000000

TRAILER --> TRAILER00000000

Can you please help.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Tue Oct 09, 2012 11:43 pm    Post subject:
Reply with quote

Manoj, I note that you claim no mainframe skills in your profile. Perhaps this is an error, the more likely in that you seem to have entered a variant of your user name in the skills. To the left, perhaps this is a sign that you ought to turn this task over to a colleague who can write a bit of COBOL, PL/I, or Rexx to accomplish it, rather than attempt to blindly juggle hundreds of lines of JCL and DFSORT control cards.
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Tue Oct 09, 2012 11:50 pm    Post subject:
Reply with quote

Hello,

Also, please read (or re-read) what Kolusu posted:
Quote:
I am extremely sorry that I canNOT help you create something that doesn't exist.


As suggested, this would probably be better addressed in code as it will then be easier to expand as the requirement grows/changes.
Back to top
View user's profile Send private message
puneetvirmani143

New User


Joined: 24 Jul 2007
Posts: 55
Location: noida

PostPosted: Sun Oct 14, 2012 2:48 pm    Post subject: Reply to: Split File in multiple and attaching Header and Tr
Reply with quote

Hi Skolusu

One small point to your solution, If there are no records for A2, as JOINKEY is not able do any pairing.

Output file for A2 :
Record 1 : contains BLANK in header
Record 2: TRAILER

I modified the solution a bit to atleast get the TRailer record in the expected format.

OUTFIL FNAMES=A1,REMOVECC,INCLUDE=(79,2,CH,EQ,C'A1'),BUILD=(1,78),HEADER1=(81,78),TRAILER1=('TRAILER',COUNT=M11,LENGTH=8))

OUTFIL FNAMES=A2,REMOVECC,INCLUDE=(79,2,CH,EQ,C'A2'),BUILD=(1,78), HEADER1=(81,78),TRAILER1=('TRAILER',COUNT=(M11,LENGTH=8))

I am able to get the trailer record as TRAILER<<COunt>> accordingly.

But unable to get the header same as Input file, but with <<COUNT>> as ZEROES in header when there are no records for any code ex. A2.

Do you know anything which i can additonal add to get the Header in the required format when there are no records in Input file for A2 code ?

Please help . thanks
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Mon Oct 15, 2012 3:20 am    Post subject: Reply to: Split File in multiple and attaching Header and Tr
Reply with quote

The INB file, through the SUM, is reduced to (when all are present) 100 records with totals on. Each record is available, through the JOIN, for each data record on INA. Thus allowing the header and trailer to be based on the originals.

If you have a missing record-type, you only get 99 records on INB. If two missing, you only get 98, etc.

If you have a file with all your record-types on, you can use that in a new step to generate a file of 100 "dummy records". Concatenate that to the INB file.

You will have to adjust the record-count after the JOIN. Subtract one from it. This will get you zero for the "missing" record-types and actual-count-minus-one for the existing record-types.

Start with Kolusu's original code, you shouldn't need your changes.

Understand it fully this time. Test it fully this time. Don't come back in another eight months with more problems to do with the same thing, please.
Back to top
View user's profile Send private message
puneetvirmani143

New User


Joined: 24 Jul 2007
Posts: 55
Location: noida

PostPosted: Sun Oct 21, 2012 6:30 pm    Post subject: Reply to: Split File in multiple and attaching Header and Tr
Reply with quote

Hi,

I tried with above solution, creating a file containing all allowed codes with codes appearing at Pos79,80 and concantenating to INB.

However there is no change to output for those codes for which there are no records in INB they are still showing as

Output still showing :
record1 : BLANKS
Record2: TRAILER00000000

Additonally, other files for which there were some records in INA have now started getting one addtional record count. Not sure how should i reduce the count in Header by 1 (I know how to reduce TRAILER COUNT). But trailer count is appearing correctly.

Please suggest
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Mon Oct 22, 2012 4:12 am    Post subject: Reply to: Split File in multiple and attaching Header and Tr
Reply with quote

Please post the code you have, in the Code tags. We can't guess what you have and give a useful answer.
Back to top
View user's profile Send private message
puneetvirmani143

New User


Joined: 24 Jul 2007
Posts: 55
Location: noida

PostPosted: Thu Nov 01, 2012 2:24 pm    Post subject:
Reply with quote

Hi,
Apologize for being late. I was out on leave.

Below is the code i am using:

Code:
//STEP010  EXEC PGM=SORT                                     
//SYSPRINT DD SYSOUT=*                                       
//INA      DD DSN=TTYA.SORT.TEST1,DISP=SHR                   
//INB      DD DSN=TTYA.SORT.TEST2,DISP=SHR                   
//          DD DSN=TTYA.SORT.CODES,DISP=SHR                 
//A1       DD DSN=TTYA.SORT.A1,DISP=(NEW,CATLG,DELETE),     
//            SPACE=(TRK,(2,2),RLSE),RECFM=FB,LRECL=78       
//A2       DD DSN=TTYA.SORT.A2,DISP=(NEW,CATLG,DELETE),     
//            SPACE=(TRK,(2,2),RLSE),RECFM=FB,LRECL=78       
//A3       DD DSN=TTYA.SORT.A3,DISP=(NEW,CATLG,DELETE),     
//            SPACE=(TRK,(2,2),RLSE),RECFM=FB,LRECL=78       
//SYSIN    DD *                                             
  OPTION COPY                                               
  JOINKEYS F1=INA,FIELDS=(79,2,A)                           
  JOINKEYS F2=INB,FIELDS=(79,2,A)                           
  REFORMAT FIELDS=(F1:1,80,F2:1,88)                                 
  INREC OVERLAY=(105:161,8)                                         
                                                                     
  OUTFIL FNAMES=A1,REMOVECC,INCLUDE=(79,2,CH,EQ,C'A1'),BUILD=(1,78),
  HEADER1=(81,78),TRAILER1=('TRAILER',COUNT=(M11,LENGTH=8))         
                                                                     
  OUTFIL FNAMES=A2,REMOVECC,INCLUDE=(79,2,CH,EQ,C'A2'),BUILD=(1,78),
  HEADER1=(81,78),TRAILER1=('TRAILER',COUNT=(M11,LENGTH=8))         
                                                                     
  OUTFIL FNAMES=A3,REMOVECC,INCLUDE=(79,2,CH,EQ,C'A3'),BUILD=(1,78),
  HEADER1=(81,78),TRAILER1=('TRAILER',COUNT=(M11,LENGTH=8))         
                                                                     
//*                                                                 
//JNF1CNTL DD *                                                     
   OMIT COND=(1,6,CH,EQ,C'HEADER',OR,1,7,CH,EQ,C'TRAILER')           
                                                                   
//*                                                               
//JNF2CNTL DD *                                                   
   OMIT COND=(1,7,CH,EQ,C'TRAILER')                               
   INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:7C'0',C'1')),               
   IFTHEN=(WHEN=GROUP,BEGIN=(1,6,CH,EQ,C'HEADER'),PUSH=(1,78))     
   SUM FIELDS=(81,8,ZD)                                           
//*                                                               
//SYSUDUMP DD SYSOUT=C                                             
//SYSOUT   DD SYSOUT=*                                             
//*                                                               
//*                                                               


here
TTYA.SORT.TEST1 --> actual input file which is to be broken to several outputs based on codes.

TTYA.SORT.TEST2 --> exact replica of TTYA.SORT.TEST1.
TTYA.SORT.CODES --> Contains all the allowed codes ex. A1, A2 etc .. at Pos 79, 80. Pos 1-78 are Blanks

When there is no record for a code . ex A3 ... below is the output file which is getting created.

record1 : Blanks
record2 : TRAILER00000000

expected is :
Record 1: Byte 1-24 (same as appearing in header record in TTYA.SORT.TEST1) + Count 8 bytes (00000000) as there are no records present for A3 in input file.

For rest of the files created for each Code Ex A1, A2. Detail records and Trailer are coming as expected, however header has started getting one extra count compare to trailer value. Trailer value is coming properly as expected. Now i am confused how to get rid of extra 1 count from header ?

Please help. Thanks

Code'd
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Thu Nov 01, 2012 7:33 pm    Post subject: Reply to: Split File in multiple and attaching Header and Tr
Reply with quote

Your "dummy" records need to have their record-code in the same position as a normal record, so 79 and 80, whatever.

You have to identify the dummy records, and set 0 for the value being SUMmed.
Back to top
View user's profile Send private message
puneetvirmani143

New User


Joined: 24 Jul 2007
Posts: 55
Location: noida

PostPosted: Fri Nov 16, 2012 1:20 am    Post subject: Reply to: Split File in multiple and attaching Header and Tr
Reply with quote

Hi,

Dummy records i.e all possible codes are already taken at pos 79,80.

How should I identify the codes for which there are no records, is also a problem area for me.

Please help

Thanks
Puneet
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
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm


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