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
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: How to split a record based on No of OCCURences of a field
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Fri Jun 10, 2005 9:37 pm    Post subject:
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    Post subject:
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    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 SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts IMS DB-How to update a record (a sing... Nic Clouston IMS DB/DC 9 Thu Mar 09, 2017 4:38 pm
No new posts outrec field outside range Danielle.Filteau SYNCSORT 10 Sat Mar 04, 2017 2:37 am
No new posts Inserting records based on conditions vickey_dw DFSORT/ICETOOL 9 Wed Feb 22, 2017 1:33 pm


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