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
 

 

Splitting the file by the records from control file

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

New User


Joined: 10 Jan 2008
Posts: 22
Location: Belarus

PostPosted: Wed Jan 16, 2008 10:52 pm    Post subject: Splitting the file by the records from control file
Reply with quote

Hello

There are two files (VB) - source file and control file, which record length could be different for every run of required job. The position of the key for every file is known and permanent (source file - 4 chars in position 28 + 3 chars in position 46, control file - 7 chars in position 1). Both files can contain duplicate keys.

Example of source file:
Code:

01.........................AAAA..............AAA....
02.........................BBBB..............BBB...........
03.........................AAAA..............AAA........
04.........................CCCC..............CCC.........
05.........................DDDD..............DDD..


Example of control file:
Code:

AAAAAAA...............
CCCCCCC...............


The requirement is to split the first file for two parts according to the contents of control file - with matching and non-matching records.

So the output should be:

output file1:
Code:

01.........................AAAA..............AAA....
03.........................AAAA..............AAA........
04.........................CCCC..............CCC.........

output file2:
Code:

02.........................BBBB..............BBB...........
05.........................DDDD..............DDD..


<job deleted>
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 16, 2008 11:21 pm    Post subject:
Reply with quote

You don't need 9 passes over the data to do what you want.

I've removed your job so nobody will try to copy it.

You can do what you want in 3 passes with a DFSORT/ICETOOL job like the following. I assumed your input file2 has LRECL=100, but the job can be changed appropriately for different LRECLs.

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN1 DD DSN=...  input file1 (VB)
//IN2 DD DSN=...  input file2 (VB/100)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS),
// LRECL=102
//OUT1 DD DSN=...  output file1 (VB/100)
//OUT2 DD DSN=...  output file2 (VB/100)
//TOOLIN DD *
COPY FROM(IN2) TO(T1) USING(CTL1)
COPY FROM(IN1) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(OUT1) ON(34,4,CH) ON(52,3,CH) -
  KEEPNODUPS KEEPBASE VLENOVLY -
  WITHALL WITH(6,101) USING(CTL3)
/*
//CTL1CNTL DD *
  INREC BUILD=(1,4,5:C'BB',34:5,4,52:9,3)
/*
//CTL2CNTL DD *
  INREC BUILD=(1,4,5:C'VV',7:5)
/*
/CTL3CNTL DD *
 OUTFIL FNAMES=OUT1,INCLUDE=(5,2,CH,EQ,C'BV'),
   BUILD=(1,4,5:7)
 OUTFIL FNAMES=OUT2,INCLUDE=(5,2,CH,EQ,C'VV'),
   BUILD=(1,4,5:7)
/*
Back to top
View user's profile Send private message
Andrew Shinkarev

New User


Joined: 10 Jan 2008
Posts: 22
Location: Belarus

PostPosted: Thu Jan 17, 2008 5:48 pm    Post subject: Reply to: Splitting the file by the records from control fil
Reply with quote

Quite confusing.. icon_confused.gif

Please, correct me if I'm wrong:

1. I'm afraid that you mixed up IN1(source file) and IN2(control file) writing the COPY... Also there should be INREC BUILD=(1,4,5:C'BB',32:5,4,50:9,3) as the key starts at 28(len=4) and 46(len=3).

2. I'm getting

ICE218A 6 5 BYTE VARIABLE RECORD IS SHORTER THAN 11 BYTE MINIMUM FOR FIELDS

even if I add OPTION VLSCMP,VLSHRT. Just adding of INCLUDE CONDITION to CTL1CNTL lets to get out of this error. icon_sad.gif

3. This is the start of T1:

Code:

********************************* Top of Data **********************************
BB                         H QM              F 1                               
BB                         V  1              001                               
BB                         V  1              002                               
BB                         T  1              010                               
BB                         R  C                                                 
..............................................


source file:
Code:

********************************* Top of Data **********************************
H QMF 14 R 01 E V W E R 02 03 08/01/10 10:43                                   
V  1001 006 PERIOD                                                             
V  1002 003 016                                                                 
T  1010 018 006 1013 005 1014 006 1015 006 1016 006 1017 006 1012 008           
R  C     000001 000003 000009 000001                                           
..............................................


So the output files contains nothing valuable at all.
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 17, 2008 10:20 pm    Post subject:
Reply with quote

Sigh. You didn't say you had short records in input file1. I just went by your example which doesn't have short records. That makes a difference. It's not clear if you want these short records in OUT2. If you do, then adding OPTION VLSHRT to CTL3CNTL will take care of it. If you don't want the short records, then adding:

Code:

  INCLUDE COND=(1,2,BI,GE,+52) 


to CTL2CNTL will take care of it.

I assume you don't have any short records in input file2 ... right?

In the future, please show a more complete example of your input records.

1. No, I meant to have the input file2 records before the input file1 records in T1. The INRECs are correct too. We need to have the keys from both files in the same place.

3. For your original input example with the lengths I used for testing, T1 will have:

Code:

  Len |Data
   54 |BB                           AAAA              AAA
   54 |BB                           CCCC              CCC
   72 |VV01.........................AAAA..............AAA....
   67 |VV02.........................BBBB..............BBB...........
   70 |VV03.........................AAAA..............AAA........
   58 |VV04.........................CCCC..............CCC....
   57 |VV05.........................DDDD..............DDD..


Notice that the two parts of the key line up.

If you don't want the short records, the INCLUDE will remove them so they won't appear in T1.

If you do want the short records, they will appear in T1 and VLSHRT in CTL3CNTL will take care of sorting them so you won't get the error message.

If this isn't working for you, then show me a better example of the records in file1 and file2 including the RDW lengths.
Back to top
View user's profile Send private message
Andrew Shinkarev

New User


Joined: 10 Jan 2008
Posts: 22
Location: Belarus

PostPosted: Mon Jan 21, 2008 9:42 pm    Post subject: Reply to: Splitting the file by the records from control fil
Reply with quote

Thank you very much, Frank. I was confused, because I did not clearly understand what is input file1 and input file2 and mixed them up. The job works perfectly and three phases are better than nine for sure icon_smile.gif .

Wrt the short records in input file1. I haven't mentioned this case because for me the customer definition "file is VB" is equal to "the records could have any length" (it happens every time!) and I have to make my jobs more universal. Actually this file is not under our control, it is a report that comes to our system and it's possible to have absolutely anything inside. I have just one short copy as an example, but nobody can be firmly convinced that the short lines will not appear there in the future. Definitely I'll be more accurate with definitions on the forum from now.
Back to top
View user's profile Send private message
Andrew Shinkarev

New User


Joined: 10 Jan 2008
Posts: 22
Location: Belarus

PostPosted: Thu Jan 31, 2008 8:58 pm    Post subject:
Reply with quote

Just a quick question: is it possible to sort OUT1 and OUT2 without adding something like

Code:

//OUT3 DD DSN=...  output file3 (VB/100)
..........................
COPY FROM(OUT1) TO(OUT3) USING(CTL4)
..........................
//CTL4CNTL DD *
  SORT FIELDS=(10,16,CH,A)
/*

?

Looks like no, as "DFSORT Application Programming Guide" doc says:

<<The DFSORT control statements in xxxxCNTL are used if USING(xxxx) is specified.
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 31, 2008 10:31 pm    Post subject:
Reply with quote

I don't understand what you're asking. If you want to sort a file, you need to supply a SORT statement to indicate the field(s) you want to sort on. Otherwise, how would DFSORT know which fields those are (by reading your mind?).

You don't have to use ICETOOL to do a SORT - you can do it directly with DFSORT, e.g.

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=...  output file
//SYSIN    DD    *
  SORT FIELDS=(...)
/*


If I didn't answer your question, then please try to state it more clearly.
Back to top
View user's profile Send private message
Andrew Shinkarev

New User


Joined: 10 Jan 2008
Posts: 22
Location: Belarus

PostPosted: Thu Jan 31, 2008 11:25 pm    Post subject:
Reply with quote

I've asked taking into account a job above, in other case I would open another topic. There are 2 output files there - OUT1 and OUT2 as a result of SPLICE operation. As I understood from the doc it's not possible to use SORT FIELDS in xxxxCNTL card related to SPLICE, correct?
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 31, 2008 11:43 pm    Post subject:
Reply with quote

Yes, that's correct. SPLICE does a sort using the ON field(s). So if you have:

SPLICE FROM(T1) TO(OUT1) ON(34,4,CH) ...

SPLICE will do a sort on 34,4,CH,A. You can't override that with a SORT statement for 10,16,CH,A since that would put the records in the wrong order for splicing.
Back to top
View user's profile Send private message
Andrew Shinkarev

New User


Joined: 10 Jan 2008
Posts: 22
Location: Belarus

PostPosted: Thu Jan 31, 2008 11:47 pm    Post subject:
Reply with quote

Thank you, Frank
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 10 Tue May 16, 2017 2:20 pm
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
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