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

Spilt file based on specific condition


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
shr_amar
Warnings : 2

Active User


Joined: 02 May 2005
Posts: 128
Location: UK

PostPosted: Sat May 08, 2010 6:06 pm
Reply with quote

Dear Members,

I wish to do the following , I have a transaction file which is having very high volume.The file attributes of the input file are mentioned below :-

1) Fixed length (100Bytes)
2) File structure are as follows

Code:

HEADER RECORD
DETAIL RECORD 1
DETAIL RECORD 2
DETAIL RECORD 3
DETAIL RECORD 4
12345678B123456789123456789123456789123456789123456789123456789123456789123BCH0000001
DETAIL RECORD 5
DETAIL RECORD 6
12345678B123456789123456789123456789123456789123456789123456789123456789123BCH0000002
DETAIL RECORD 7
DETAIL RECORD 8
DETAIL RECORD 9
DETAIL RECORD 10
12345678B123456789123456789123456789123456789123456789123456789123456789123BCH0000001
FILE TRAILER


Batch can be identifiied only (if ninth character of the file is = 'B' and starting from 76 position(Upto 3 Bytes) is equal to BCH).Starting from 79 to 85 (7 Bytes) is the batch number.
All the transactions coming before that batch trailer belongs to that batch.So in current situation there are two batch(BCH0000001 have repeated again)
Batches are :-
BCH0000001
BCH0000002

Now let us come to the requirement .

Depending on the number of batches i have to create output files DYNAMICALLY.For the above sample data i have to create two output files.The attributes of the output file will be same as of the input file.

Naming convention of the output file created should contain batch information(Batch identifier + Batc sequence number) .e.g FILE.BCH0000001 & FILE.BCH0000002
All the data which are present on top of the Batch trailer belongs to that batch.I have to split the file on per batch basis.My output files should contain as follows

FILE.BCH0000001 should contain ==>

Code:

DETAIL RECORD 1
DETAIL RECORD 2
DETAIL RECORD 3
DETAIL RECORD 4
DETAIL RECORD 7
DETAIL RECORD 8
DETAIL RECORD 9
DETAIL RECORD 10


FILE.BCH0000002 should contain ==>
Code:

DETAIL RECORD 5
DETAIL RECORD 6


Please let me know in case i have missed some thing.
Cheers
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Sat May 08, 2010 11:36 pm
Reply with quote

Will you be having batch numbers 0000001 and 0000002 in every file?
If not what will be maximum batch numbers come in one file?

In input file you have shown HEADER RECORD\TRAILER RECORD but omitted in output. How they are identified?
Back to top
View user's profile Send private message
shr_amar
Warnings : 2

Active User


Joined: 02 May 2005
Posts: 128
Location: UK

PostPosted: Sat May 08, 2010 11:49 pm
Reply with quote

Hello Sambhaji ,

As its a transaction file there is not limit of the batches.File Header,Batch trailer , Batch Trailer need to be omitted.

They all can be identified by the unique value at position '9' . E.g Header should have 'H' and Trailer should have 'T' at the 9th position.


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

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Sat May 08, 2010 11:57 pm
Reply with quote

shr_amar wrote:
Hello Sambhaji ,

As its a transaction file there is not limit of the batches.
Regards

I am asking about unique count of batch numbers..

If there is no maximum limit for that..
Basic truth you need to understand about JCL: You can not dynamically decide number of datasets to be allocated in JCL once it is submitted.

I think, You might have to look back at your design.
Back to top
View user's profile Send private message
shr_amar
Warnings : 2

Active User


Joined: 02 May 2005
Posts: 128
Location: UK

PostPosted: Sun May 09, 2010 12:32 am
Reply with quote

Unique count batch number will present in all the files .If it helps I can make change in the design that there will be one more input file(FILE1) which will contain the Batch trailer information.So if there are 2 batch entry in the FILE1.Two output files (same attribute as of transaction file and having batch trailer information in the DSN) will be created and if corresponding batch trailer found in the transaction file all record above the batch trailer need to be extracted to the new output file created. Here is the example.

Input file 1(RL=40)

Record Present in the this file
Code:

BCH0000001
BCH0000003


Input file2(RL=100)
Record Present in the this file
Code:

HEADER RHCORD
DETAIL RECORD 1
DETAIL RECORD 2
DETAIL RECORD 3
DETAIL RECORD 4
12345678B123456789123456789123456789123456789123456789123456789123456789123BCH0000001
DETAIL RECORD 5
DETAIL RECORD 6
12345678B123456789123456789123456789123456789123456789123456789123456789123BCH0000002
DETAIL RECORD 7
DETAIL RECORD 8
DETAIL RECORD 9
DETAIL RECORD 10
12345678B123456789123456789123456789123456789123456789123456789123456789123BCH0000001
DETAIL RECORD 11
DETAIL RECORD 12
DETAIL RECORD 13
DETAIL RECORD 14
12345678B123456789123456789123456789123456789123456789123456789123456789123BCH0000003

FILE TRATLER

There will be two output file which will have same attribute as of file2

FILE.BCH0000001 should contain ==>

Code:

DETAIL RECORD 1
DETAIL RECORD 2
DETAIL RECORD 3
DETAIL RECORD 4
DETAIL RECORD 7
DETAIL RECORD 8
DETAIL RECORD 9
DETAIL RECORD 10


FILE.BCH0000003 should contain ==>
Code:

DETAIL RECORD 11
DETAIL RECORD 12
DETAIL RECORD 13
DETAIL RECORD 14


Note - As BCH0000002 is not present in File1 . This need to be skipped.
Hope this make sense
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Sun May 09, 2010 4:58 am
Reply with quote

Quote:
Naming convention of the output file created should contain batch information(Batch identifier + Batc sequence number) .e.g FILE.BCH0000001 & FILE.BCH0000002


Those are not valid file names.
Back to top
View user's profile Send private message
shr_amar
Warnings : 2

Active User


Joined: 02 May 2005
Posts: 128
Location: UK

PostPosted: Sun May 09, 2010 2:40 pm
Reply with quote

I just had a look again and found that file name are invalid(as Its going beyond max number) .We can remove leading zeroes to have file name as

FILE.BCH0001
FILE.BCH0003
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Tue May 11, 2010 1:14 am
Reply with quote

shr_amar,

Use the following DFSORT JCL . This job will read in your 40 byte file and create dynamic split control cards and submit the job to intrdr. Verify the output from step0200 in the below JCL and once everything looks like ok change the following statement in STEP0200
Code:

//SORTOUT  DD SYSOUT=*                                               


to
Code:

//SORTOUT  DD SYSOUT=(*,INTRDR)


Code:

//STEP0100 EXEC PGM=SORT                                       
//SYSOUT   DD SYSOUT=*                                         
//SORTIN   DD DSN=your 40 byte name file,DISP=SHR               
//CARDS    DD DSN=&&C,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)       
//DDNAME   DD DSN=&&D,DISP=(,PASS),SPACE=(CYL,(5,2),RLSE)       
//DDN      DD SYSOUT=*                                         
//SYSIN    DD *                                                 
  SORT FIELDS=COPY,STOPAFT=99                                   
  OUTFIL FNAMES=CARDS,                                         
  BUILD=(3:C'OUTFIL FNAMES=',1,3,6,5,C',BUILD=(1,100),',/,     
         3:C'INCLUDE=(101,10,CH,EQ,C''',1,10,C'''',             
           C',AND,76,3,CH,NE,C''',C'BCH''',C')',/,80:X)         
  OUTFIL FNAMES=DDNAME,                                         
  BUILD=(C'//',1,3,6,5,X,C'DD DSN=USERID.FILE.',1,3,6,5,C',',/,
         C'//',12X,C'DISP=(NEW,CATLG,DELETE),',/,               
         C'//',12X,C'UNIT=SYSDA,',/,                           
         C'//',12X,C'SPACE=(CYL,(1,1),RLSE)',/,               
         C'//*',80:X)                                           
//*                                                             
//STEP0200 EXEC  PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                               
//SYSIN    DD *                                                     
   OPTION COPY                                                       
/*                                                                   
//SORTOUT  DD SYSOUT=*                                               
//SORTIN   DD DATA,DLM=$$                                           
//TIDXXXXA JOB 'COPY',                                               
//             CLASS=A,                                             
//             MSGCLASS=Y,                                           
//             MSGLEVEL=(1,1),                                       
//             NOTIFY=TID                                           
//*                                                                 
//STEP0100 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD DSN=YOUR INPUT 100 BYTE FILE,DISP=SHR                 
//SYSIN    DD *                                                     
  OMIT COND=(1,6,CH,EQ,C'HEADER',OR,1,12,CH,EQ,C'FILE TRAILER')     
  SORT FIELDS=(101,8,CH,A,109,1,CH,D),EQUALS                         
  INREC IFTHEN=(WHEN=GROUP,END=(76,3,CH,EQ,C'BCH'),PUSH=(101:ID=8)),
  IFTHEN=(WHEN=(76,3,CH,EQ,C'BCH'),OVERLAY=(109:C'1'))               
  OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(76,3,CH,EQ,C'BCH'),               
           PUSH=(101:76,10))                                         
                                                                     
$$                                                                   
//         DD DSN=&C,DISP=OLD                                       
//         DD DSN=&D,DISP=OLD                                       
//*
Back to top
View user's profile Send private message
shr_amar
Warnings : 2

Active User


Joined: 02 May 2005
Posts: 128
Location: UK

PostPosted: Tue May 11, 2010 2:25 am
Reply with quote

Thanks Kolusu ,

As i am off for the day . Will try tommorow and let you know about the outcomes.

Rgrds
Back to top
View user's profile Send private message
shr_amar
Warnings : 2

Active User


Joined: 02 May 2005
Posts: 128
Location: UK

PostPosted: Tue May 11, 2010 10:40 pm
Reply with quote

Kolusu ,

This is working .

Thanks again
Back to top
View user's profile Send private message
shr_amar
Warnings : 2

Active User


Joined: 02 May 2005
Posts: 128
Location: UK

PostPosted: Wed May 19, 2010 8:58 pm
Reply with quote

Kolusu ,

There is further enhancement required in the code .Which is as follows :-

Currently we extracted all the records which are coming before a specified trailer present in 40 bytes input file BCH0000001 & BCH0000003

Now i have to extract records which are coming before batch trailer and a dynamic value(fixed length =7 bytes),(Let us call it a tran-id) present at 20th position.

Now the 40 bytes file will contain data like

Code:

BCH0000001 5555555
BCH0000001 6666666
BCH0000003 4444444
BCH0000003 8888888


Basically the dynamic card we have created previously need to modify as below

Code:

OUTFIL FNAMES=BCH00154,BUILD=(1,100),                         
  INCLUDE=(101,10,CH,EQ,C'BCH0000001',AND,76,3,CH,NE,C'BCH',AND,
           (20,7,CH,EQ,C'5555555',OR,20,7,CH,EQ,C'5555555'))     
                                                                 
  OUTFIL FNAMES=BCH00155,BUILD=(1,100),                         
  INCLUDE=(101,10,CH,EQ,C'BCH0000003',AND,76,3,CH,NE,C'BCH',AND,
           (20,7,CH,EQ,C'4444444',OR,20,7,CH,EQ,C'8888888'))   


Single trailer value can have different tran-id and i have modifiy input 40 byte file to replicate which trailer is asscociated with tran-id.
Tried to modify the exixting code which work for one trailer - one tran-id combination .

Don't know how a multiple occurance can be handle in dfsort.

Need your help.

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

Senior Member


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

PostPosted: Wed May 19, 2010 9:33 pm
Reply with quote

shr_amar wrote:
Now the 40 bytes file will contain data like

Code:

BCH0000001 5555555
BCH0000001 6666666
BCH0000003 4444444
BCH0000003 8888888



What is the max num of dups you can have on the 10 byte key? i.e BCH0000001 is repeated twice and BCH0000003 is also repeated twice.
Back to top
View user's profile Send private message
shr_amar
Warnings : 2

Active User


Joined: 02 May 2005
Posts: 128
Location: UK

PostPosted: Wed May 19, 2010 9:40 pm
Reply with quote

There is no limit of duplicates . As one batch trailer can have n numbers of tran - id . But if there is restriction of the duplicated and you understand the whole idea we can modify the 40 byte input file . For e.g

we can have two input file which are as follows

File 1 ( 40 bytes )
Code:

BCH0000001 2
BCH0000003 3


File 2 (FB 10 bytes)
Code:

5555555
6666666
4444444
8888888
7777777


This means BCH0000001 will have first 2 tran-id from second file and
BCH0000003 will have next 3 tran id .

Hope this help and make sense.
Rgds
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Wed May 19, 2010 9:57 pm
Reply with quote

shr_amar wrote:
There is no limit of duplicates . As one batch trailer can have n numbers of tran - id . But if there is restriction of the duplicated and you understand the whole idea we can modify the 40 byte input file


shr_amar,

You ought to have a limit or else it is difficult to generate the include conditions. It would be an OK job if the generated include conditions are only dealing with 1 or 2 variables , but it gets complicated if the number varies. Time to sit down and write a program
Back to top
View user's profile Send private message
shr_amar
Warnings : 2

Active User


Joined: 02 May 2005
Posts: 128
Location: UK

PostPosted: Wed May 19, 2010 11:21 pm
Reply with quote

Skolusu,

Let us try to fix it and go to your previous question :-

Quote:

What is the max num of dups you can have on the 10 byte key? i.e BCH0000001 is repeated twice and BCH0000003 is also repeated twice.


I have flexibilty to split the file based on Tran-ID.As I can set maximum 5 tran-id per trailer in a file there will be maximum 5 duplicates.Can this be achieve?

Once i am ready with DFSORT for 5 duplicates, I will roll out to other TRAN_ID.

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

Senior Member


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

PostPosted: Thu May 20, 2010 12:08 am
Reply with quote

shr_amar wrote:
Skolusu, Let us try to fix it and go to your previous question :-


shr_amar,

*Sigh* What is so wrong about writing a program? Utilities make life easier but that doesn't mean you can try to nail everything with it.
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: Thu May 20, 2010 1:22 am
Reply with quote

Hi Kolusu,

Quote:
*Sigh* What is so wrong about writing a program?
Neither Kolusu nor Frank will write that code. . .

d
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 4
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top