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

The best way to split a field into several records?


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

New User


Joined: 19 Nov 2008
Posts: 98
Location: Spain

PostPosted: Wed Jul 06, 2011 6:04 pm
Reply with quote

Hello there. We have a request to split several fields in a record into different records. We already accomplished it, but I was wondering if this is the most efficient way since I'd had to perform two sort steps and two passes to accomplish it. The Steps we executed were those:

Code:
//SORT011  EXEC PGM=SORT,COND=(4,LT)                                 
//SYMNAMES DD DSN=BPSDCHG.FB.P.ASYSIPG(PMES3020),DISP=SHR           
//         DD DSN=BPSDLIB.EECC.KEOA.JCL.CORP.INTEREFE(HARCODES),     
//            DISP=SHR                                               
//         DD *                                                     
ERRORES,15,46,CH                                                     
CAMPO1,15,2,CH                                                       
CAMPO2,17,2,CH                                                       
CAMPO3,19,2,CH                                                       
CAMPO4,21,2,CH                                                       
CAMPO5,23,2,CH                                                       
CAMPO6,25,2,CH                                                       
CAMPO7,27,2,CH                                                       
CAMPO8,29,2,CH                                                       
CAMPO9,31,2,CH                                                       
CAMPO10,33,2,CH                                                     
CAMPO11,35,2,CH                                                     
CAMPO12,37,2,CH                                                     
CAMPO13,39,2,CH                                                     
CAMPO14,41,2,CH                                                     
CAMPO15,43,2,CH                                                     
CAMPO16,45,2,CH                                                     
CAMPO17,47,2,CH                                                     
CAMPO18,49,2,CH                                                     
CAMPO19,51,2,CH                                                     
CAMPO20,53,2,CH                                                     
CAMPO21,55,2,CH                                                     
CAMPO22,57,2,CH                                                     
CAMPO23,59,2,CH                                                     
//SYMNOUT  DD SYSOUT=*                                               
//SYSPRINT DD SYSOUT=*                                               
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD DSN=VBDKEOA.INPXD05X.CMP.XERRORES,DISP=SHR             
//SORTOUT  DD DSN=VBDKEOA.INPXD05X.CMP.XERRORE2,DISP=(,CATLG,DELETE),
//            SPACE=(CYL,(10,5),RLSE),UNIT=3390                     
//SYSIN    DD *                                                     
   SORT FIELDS=COPY                                                 
   OUTFIL BUILD=(1,12,1X,CAMPO1,80:X,/,                             
                 1,12,1X,CAMPO2,/,1,12,1X,CAMPO3,/,1,12,1X,CAMPO4,/,
                 1,12,1X,CAMPO5,/,1,12,1X,CAMPO6,/,1,12,1X,CAMPO7,/,
                 1,12,1X,CAMPO8,/,1,12,1X,CAMPO9,/,1,12,1X,CAMPO10,/,
                 1,12,1X,CAMPO11,/,1,12,1X,CAMPO12,/,               
                 1,12,1X,CAMPO13,/,1,12,1X,CAMPO14,/,               
                 1,12,1X,CAMPO15,/,1,12,1X,CAMPO16,/,               
                 1,12,1X,CAMPO17,/,1,12,1X,CAMPO18,/,               
                 1,12,1X,CAMPO19,/,1,12,1X,CAMPO20,/,               
                 1,12,1X,CAMPO21,/,1,12,1X,CAMPO22,/,1,12,1X,CAMPO23)
   OPTION SOLRF
//*--------------------------------
//SORT015  EXEC PGM=SORT,COND=(4,LT)                                 
//SYMNOUT  DD SYSOUT=*                                               
//SYSPRINT DD SYSOUT=*                                               
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD DSN=VBDKEOA.INPXD05X.CMP.XERRORE2,DISP=SHR             
//LISTADO  DD DSN=VBDKEOA.INPXD05X.CMP.XERRORE3,DISP=(,CATLG,DELETE),
//            SPACE=(CYL,(10,5),RLSE),UNIT=3390                     
//*IFTHEN=(WHEN=INIT,BUILD=(1,15,99:X)),                             
//SYSIN    DD *                                                     
   OMIT COND=(14,2,CH,EQ,C'  ')                 


the input record for this task was this:

Code:
----+----1----+----2----+----3----+----4----+----5----+---
********************************* Top of Data ************
000000019999                  070809      131415         
xxxxxx011231          030405  070809101112          181920
000000019999  01                                         
000000010008  01                                         
000000000053  01                                         
000000010006  01                                         
xxxxxx011231  01                                         
000000019999    02                                       
xxxxxx011231    02                                       
000000019999      22                                     
000000019999      22                                     
000000010009      22                                     
000000000053      22                                     
000000000051      22                                     
000000010008      22                                     
xxxxxx011231      22                                     
xxxxxx011231      22                                     
000000019999        23                                   
000000010006        23                                   
000000010014        23                                   
000000010015        23                                   
000000010001        23                                   
xxxxxx011231        23                                   
000000000053                                    21       
000000000053                                    21       
000000010009                                    21       
000000010009                                    21       


From column 15 through 60 we have pairs of bytes which has error codes. We need to generate records with the first 12 bytes (the ID) and the error code asociated to such record.

The thing is that we couldn't differentiate from blank fields, so we had to create "blank records", that is, records with no error code, before fitlering the results. The output from the first step was this:

Code:
000000019999   
000000019999   
000000019999   
000000019999   
000000019999   
000000019999   
000000019999   
000000019999   
000000019999 07
000000019999 08
000000019999 09
000000019999   
000000019999   
000000019999   
000000019999 13
000000019999 14
000000019999 15
000000019999   
000000019999   
000000019999   
000000019999   
000000019999   
000000019999   
xxxxxx011231   
xxxxxx011231   
xxxxxx011231   
xxxxxx011231   
xxxxxx011231 03
xxxxxx011231 04
xxxxxx011231 05
xxxxxx011231   
xxxxxx011231 07
xxxxxx011231 08
xxxxxx011231 09
xxxxxx011231 10
xxxxxx011231 11
xxxxxx011231 12
xxxxxx011231   
.... more records


And the final and desired result obtained in the second step was this:

Code:
=COLS> ----+----1----+
****** ***************
000001 000000019999 07
000002 000000019999 08
000003 000000019999 09
000004 000000019999 13
000005 000000019999 14
000006 000000019999 15
000007 xxxxxx011231 03
000008 xxxxxx011231 04
000009 xxxxxx011231 05
000010 xxxxxx011231 07
000011 xxxxxx011231 08
000012 xxxxxx011231 09
000013 xxxxxx011231 10
000014 xxxxxx011231 11
000015 xxxxxx011231 12
000016 xxxxxx011231 18
000017 xxxxxx011231 19
000018 xxxxxx011231 20
000019 000000019999 01
000020 000000010008 01
000021 000000000053 01
000022 000000010006 01
000023 xxxxxx011231 01
000024 000000019999 02
000025 xxxxxx011231 02
000026 000000019999 22
000027 000000019999 22
000028 000000010009 22
000029 000000000053 22
000030 000000000051 22
000031 000000010008 22
000032 xxxxxx011231 22
000033 xxxxxx011231 22
000034 000000019999 23
000035 000000010006 23
000036 000000010014 23
000037 000000010015 23


So, is there a more efficient way to do this? I found through the boards the code about using the '/' character in outfil to create line breaks. That was our only clue.

BTW, we are wroking right now in a shop with an outdated sort version:

Code:
ICE201I E RECORD TYPE IS F - DATA STARTS IN POSITION 1


Any help in this issue?
Back to top
View user's profile Send private message
Escapa

Senior Member


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

PostPosted: Wed Jul 06, 2011 6:32 pm
Reply with quote

Looks optimum to me...
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: Wed Jul 06, 2011 11:25 pm
Reply with quote

ojdiaz,

You could do it in one pass but it would require a lot of IFTHEN clauses, so you're probably better off doing it in two passes.
Back to top
View user's profile Send private message
ojdiaz

New User


Joined: 19 Nov 2008
Posts: 98
Location: Spain

PostPosted: Thu Jul 07, 2011 2:17 pm
Reply with quote

Frank Yaeger wrote:
ojdiaz,

You could do it in one pass but it would require a lot of IFTHEN clauses, so you're probably better off doing it in two passes.


Thanks Frank. That's what i though. I'd rather use two passes than let a very complicated to maintain step. Sometimes i think is preffereable to sacrifice a little bit of performance for maintain, especially if the files aren't that big.

Thanks again guys!
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
Search our Forums:

Back to Top