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

How to split a record based on No of OCCURences of a field


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

New User


Joined: 10 Jun 2005
Posts: 62

PostPosted: Fri Jun 10, 2005 11:52 am
Reply with quote

I want to split a record based on a particluar field which occurs 120 times.
1 record to 120 records .
Back to top
View user's profile Send private message
Alain Benveniste

New User


Joined: 14 Feb 2005
Posts: 88

PostPosted: Fri Jun 10, 2005 2:24 pm
Reply with quote

sangiah,

Could you give me a concret example.

Alain
Back to top
View user's profile Send private message
sangiah

New User


Joined: 10 Jun 2005
Posts: 62

PostPosted: Fri Jun 10, 2005 2:34 pm
Reply with quote

FILE - A copy book (COBOL)

ORG PIC X(03).
ACCOUNT PIC X(19).
INTEREST PIC 9(07)V99 OCCURS 120 TIMES.

I need an output file looks like below

ORG ACCOUNT INTEREST(001)
ORG ACCOUNT INTEREST(002)
ORG ACCOUNT INTEREST(003)
ORG ACCOUNT INTEREST(004)
:
:
ORG ACCOUNT INTEREST(120)
Back to top
View user's profile Send private message
Alain Benveniste

New User


Joined: 14 Feb 2005
Posts: 88

PostPosted: Fri Jun 10, 2005 3:15 pm
Reply with quote

sangiah,
Assuming you want to cut your record by 25. But 25 is not a multiple of 120...
You will need to customize the OUTREC according to your need.
Code:

//STEP0001 EXEC PGM=ICETOOL                                             
//DFSMSG   DD SYSOUT=*                                                 
//TOOLMSG  DD SYSOUT=*                                                 
//TOOLIN   DD *                                                         
  COPY FROM(IN) USING(ICE0)                                             
/*                                                                     
//IN       DD *                                                         
ORG ACCOUNT INTEREST(001)ORG ACCOUNT INTEREST(002)ORG ACCOUNT INTEREST(003)
/*                                                                     
//OUTX     DD SYSOUT=*                                                 
//ICE0CNTL DD *                                                         
  OUTFIL FNAMES=OUTX,                                                   
         OUTREC=(01,25,/,                                               
                 26,25,/,                                               
                 51,25)                                                 
/*

Does it answer to your need ?
Alain
Back to top
View user's profile Send private message
sangiah

New User


Joined: 10 Jun 2005
Posts: 62

PostPosted: Fri Jun 10, 2005 3:20 pm
Reply with quote

Alain,

Only interest is in multiples of 120 . example

My input will be like below
ORG ACCOUNT INTEREST(01) INTEREST(02) ...... INTEREST(120)
123 1234567890123456789 1234567.12 1234567.12 ..... 1234567.12

My output should be as below
ORG ACCOUNT INTEREST(01)
ORG ACCOUNT INTEREST(02)
:
:
ORG ACCOUNT INTEREST(120)

Thanks a lot alain
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 Jun 10, 2005 9:37 pm
Reply with quote

sangiah,

Here's a DFSORT job that will do what you want:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=...  output file
//SYSIN DD *
  OPTION COPY
  OUTFIL OUTREC=(1,22,00023,10,/,
                1,22,00033,10,/,
                1,22,00043,10,/,
                ...
                1,22,01203,10)
/*


However, it requires that you hardcode all 120 starting positions for INTEREST(1) to INTEREST(120).

Instead of doing that, you could generate the starting positions automatically using this DFSORT/ICETOOL job:

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//ONE DD *
DUMMY
//IN DD DSN=...  input file
//C1 DD DSN=&&C1,UNIT=SYSDA,SPACE=(TRK,(5,5)),DISP=(,PASS)
//OUT DD DSN=...  output file
//TOOLIN DD *
 COPY FROM(ONE) USING(CTL1)
 COPY FROM(IN) USING(CTL2)
/*
//CTL1CNTL DD *
  OUTFIL FNAMES=C1,REPEAT=118,
   OUTREC=(13:C'  1,22,',SEQNUM,5,ZD,START=23,INCR=10,C',10,/,',80:X)
/*
//CTL2CNTL DD *
   OPTION COPY
   OUTFIL FNAMES=OUT,
     OUTREC=(1,22,00023,10,/,
/*
//    DD DSN=*.C1,VOL=REF=*.C1,DISP=(OLD,PASS)
//    DD *
             1,22,01203,10)
/*
Back to top
View user's profile Send private message
julienloc

New User


Joined: 17 Aug 2007
Posts: 29
Location: Brussels

PostPosted: Mon Sep 24, 2007 6:19 pm
Reply with quote

Hi,

I have a kind of similar problem, except that I don't know the occurence number of the repetitive field.

Here an example of my input file. It always contains only one record and LRECL is 80. 4033 is fixed, the other fields are of length=3 but I don't know how many times they occur (In this case occurence number=4):

4033 002 004 006 010

What I would like to have as output is:

4033 002
4033 004
4033 006
4033 010

As a solution, I was thinking of declaring the REPEAT for the maximum of times the field could be repeated in a LRECL of 80. The first step would then have in our example a result of:

4033 002
4033 004
4033 006
4033 010
4033
......
4033
4033 <--Line (80-5)div4

And then add a filter step that would remove the lines which do not have data on position 6, so it would keep only the first 4 lines in this example.

Any better idea?

Thanks.

Julien
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 How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts To find whether record count are true... DFSORT/ICETOOL 6
Search our Forums:

Back to Top