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

Sort from input VB format to output VB format


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

Active User


Joined: 01 Feb 2007
Posts: 123
Location: Hyderabad

PostPosted: Fri Nov 16, 2007 6:09 pm
Reply with quote

Hi,

Here is the code.
Code:

//STEP010  EXEC PGM=ICETOOL                                       
//TOOLMSG  DD SYSOUT=*                                           
//DFSMSG   DD SYSOUT=*                                           
//SYSOUT   DD SYSOUT=*                                           
//SYSUDUMP DD SYSOUT=C                                           
//SYSPRINT DD SYSOUT=*                                           
//INPUTX   DD DSN=MY.INPUT1,DISP=SHR       
//              DD DSN=MY.INPUT2,DISP=SHR       
//              DD DSN=MY.INPUT3,DISP=SHR   
//TEMP     DD DSN=&&TEMP1,DISP=(MOD,PASS),                       
//             SPACE=(CYL,(100,500)),RECFM=VB,                   
//             UNIT=SYSDA                                         
//OUTPUT  DD DSN=MY.OUTPUT,         
//             DISP=(,CATLG,DELETE),DATACLAS=DSIZC100,           
//             RECFM=VB,LRECL=32756                               
//TOOLIN   DD *                                                   
 COPY FROM(INPUTX) TO(TEMP) USING(CNT1)                           
 COPY FROM(TEMP) TO(OUTPUT) USING(CNT2)                           
/*                                                               
//CNT1CNTL DD *                                                   
 INCLUDE COND=((5,2,CH,NE,X'0000',AND,5,2,CH,NE,X'FFFF'))         
/*                                                               
//CNT2CNTL DD *                                                   
 SORT FIELDS=(5,2,CH,A,7,20,CH,A,27,20,CH,A,114,1,CH,A,47,3,CH,A,
              50,4,CH,A,54,20,CH,A,74,20,CH,A)                   
 OUTFIL FNAMES=OUTPUT,REMOVECC,                                   
     HEADER1=(5:X'0000',                                         
              DATENS=(DM4)),                                     
     TRAILER1=(5:X'FFFF',                                         
              COUNT=(M11,LENGTH=08)),                             
     OUTREC=(5:5,32752)                                           
/*                                                               



In the above code my input files are of VB format and RECL length is 32756. Even my output is of same VB format and RECl length is 32756.
All the 3 input files have header and trailer. So first i am removing the header and trailer from the input files and copying the date records to temp.
And later from temp to output file by creating header and trailer.
But it is throwing error as below.
Code:

- CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R5 - 12:28 ON FRI NOV
 SORT FIELDS=(5,2,CH,A,7,20,CH,A,27,20,CH,A,114,1,CH,A,47,3,CH,A,     
              50,4,CH,A,54,20,CH,A,74,20,CH,A)                       
 OUTFIL FNAMES=OUTPUT,REMOVECC,                                       
     HEADER1=(5:X'0000',                                             
              DATENS=(DM4)),                                         
     TRAILER1=(5:X'FFFF',                                             
              COUNT=(M11,LENGTH=08)),                                 
     OUTREC=(5:5,32752)                                               
                 £                                                   
REFORMATTING FIELD ERROR                                             
END OF STATEMENTS FROM CNT2CNTL - PARAMETER LIST STATEMENTS FOLLOW   
DEBUG NOABEND,ESTAE                                                   
OPTION MSGDDN=DFSMSG,LIST,MSGPRT=ALL,RESINV=0,SORTDD=CNT2,SORTIN=TEMP,
               ORTOUT=OUTPUT,DYNALLOC                                 
SORT FIELDS=COPY                                                     
C5-K90007 C6-K90007 C7-K90000 C8-K90007 E7-K11698                     
END OF DFSORT                                                         
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 Nov 16, 2007 9:55 pm
Reply with quote

Your OUTREC operand is invalid because it doesn't contain the RDW and specifies an input field that's beyond the end of the input file.

Since you're just copying the entire input record, you don't need the OUTREC operand. Note that you also don't need a separate COPY operator for the INCLUDE statement.

You can use this DFSORT/ICETOOL job:

Code:

//STEP010  EXEC PGM=ICETOOL
//TOOLMSG  DD SYSOUT=*
//DFSMSG   DD SYSOUT=*
//SYSUDUMP DD SYSOUT=C
//INPUTX   DD DSN=MY.INPUT1,DISP=SHR
//              DD DSN=MY.INPUT2,DISP=SHR
//              DD DSN=MY.INPUT3,DISP=SHR
//OUTPUT  DD DSN=MY.OUTPUT,
//             DISP=(,CATLG,DELETE),DATACLAS=DSIZC100
//TOOLIN   DD *
COPY FROM(INPUTX) TO(OUTPUT) USING(CNT1)
/*
//CNT1CNTL DD *
 INCLUDE COND=((5,2,CH,NE,X'0000',AND,5,2,CH,NE,X'FFFF'))
 SORT FIELDS=(5,2,CH,A,7,20,CH,A,27,20,CH,A,114,1,CH,A,47,3,CH,A,
              50,4,CH,A,54,20,CH,A,74,20,CH,A)
 OUTFIL FNAMES=OUTPUT,REMOVECC,
     HEADER1=(5:X'0000',
              DATENS=(DM4)),
     TRAILER1=(5:X'FFFF',
              COUNT=(M11,LENGTH=08))
/*
Back to top
View user's profile Send private message
bhaskar_kanteti

Active User


Joined: 01 Feb 2007
Posts: 123
Location: Hyderabad

PostPosted: Sat Nov 17, 2007 6:43 pm
Reply with quote

Hi Frank,

Thanks for explaining and providing the soluition.
Its working. Thank you so much.
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: Sun Nov 18, 2007 10:09 pm
Reply with quote

Glad I could help.
Back to top
View user's profile Send private message
bhaskar_kanteti

Active User


Joined: 01 Feb 2007
Posts: 123
Location: Hyderabad

PostPosted: Mon Nov 19, 2007 3:53 pm
Reply with quote

Hi,

For the above reqirement i am using DFSORT. The code is as below:

Code:

//STEP010  EXEC PGM=SORT                                           
//TOOLMSG  DD SYSOUT=*                                             
//DFSMSG   DD SYSOUT=*                                             
//SYSOUT   DD SYSOUT=*                                             
//SYSUDUMP DD SYSOUT=C                                             
//SYSPRINT DD SYSOUT=*                                             
//SORTIN1  DD DSN=MY.INPUT1,DISP=SHR         
//               DD DSN=MY.INPUT2,DISP=SHR         
//               DD DSN=MY.INPUT3,DISP=SHR   
//SORTOUT  DD DSN=MY.OUTPUT,         
//             DISP=(,CATLG,DELETE),DATACLAS=DSIZC100,             
//             RECFM=VB,LRECL=32756                               
//SYSIN    DD *                                                   
 OMIT COND=(5,2,CH,EQ,X'0000',OR,5,2,CH,EQ,X'FFFF')               
 SORT FIELDS=(5,2,CH,A,7,20,CH,A,27,20,CH,A,114,1,CH,A,47,3,CH,A, 
              50,4,CH,A,54,20,CH,A,74,20,CH,A)                     
 OUTFIL REMOVECC,                                                 
     HEADER1=(5:X'0000',DATENS=(DM4)),                             
     TRAILER1=(5:X'FFFF',                                         
              COUNT=(M11,LENGTH=08))                               
/*                                                                 


The code is working fine.
For all the 3 input files i had header and trailer.
While i am creating header in my putput file i am taking the current date. But i need the entire header of the first input file.
how can i take the entire header of my first input file and and populate as the header of my output file.
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Mon Nov 19, 2007 5:19 pm
Reply with quote

bhaskar_kanteti
Here is the SORT jCL for your requirement
Code:
//*******************************************************               
//STEP1    EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD DSN=i/p-1,DISP=SHR                               
//         DD DSN=i/p-2,DISP=SHR                               
//         DD DSN=i/p-3,DISP=SHR                               
//SYM      DD DSN=&&TEMP1,DISP=(MOD,PASS),SPACE=(TRK,(5,5)),UNIT=SYSDA 
//DETAIL   DD DSN=&&TEMP2,DISP=(MOD,PASS),SPACE=(TRK,(5,5)),UNIT=SYSDA 
//SYSIN    DD *                                                         
  SORT FIELDS=COPY                                                     
  OMIT COND=(5,2,CH,EQ,X'FFFF')                                         
  INREC IFTHEN=(WHEN=(5,2,CH,EQ,X'0000'),OVERLAY=(LRECL:SEQNUM,8,ZD))   
  OUTFIL FNAMES=SYM,INCLUDE=(LRECL,8,ZD,EQ,1),VTOF,                     
         BUILD=(C'HDRDATE,C''',7,10,C'''',80:X)                         
  OUTFIL FNAMES=DETAIL,INCLUDE=(5,2,CH,NE,X'0000'),REMOVECC             
/*                                                                     
//*******************************************************               
//STEP2    EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SYMNAMES DD DSN=&&TEMP1,DISP=(MOD,PASS)                               
//SORTIN   DD DSN=&&TEMP2,DISP=(MOD,PASS)                               
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                         
  SORT FIELDS=(5,2,CH,A,7,20,CH,A,27,20,CH,A,114,1,CH,A,47,3,CH,A,     
                50,4,CH,A,54,20,CH,A,74,20,CH,A)                       
  OUTFIL HEADER1=(5:X'0000',HDRDATE),
 TRAILER1=(5:X'FFFF',COUNT=(M11,LENGTH=08))                                           
/*                                                                     



Note: In STEP1 where ever i have mentioned as LRECL replace it with the LRECL of the i/p file
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: Mon Nov 19, 2007 10:56 pm
Reply with quote

Bhaskar,

Here's a DFSORT job that will keep the header record from the first input file and remove the header records from the other input files:

Code:

//STEP010  EXEC PGM=SORT
//SYSOUT  DD SYSOUT=*
//SORTIN  DD DSN=MY.INPUT1,DISP=SHR
//        DD DSN=MY.INPUT2,DISP=SHR
//        DD DSN=MY.INPUT3,DISP=SHR
//OUTPUT  DD DSN=MY.OUTPUT,
//             DISP=(,CATLG,DELETE),DATACLAS=DSIZC100,
//             RECFM=VB,LRECL=32756
//SYSIN DD *
  OMIT COND=(5,2,CH,EQ,X'FFFF')
  SORT FIELDS=(5,2,CH,A,7,20,CH,A,27,20,CH,A,114,1,CH,A,47,3,CH,A,
               50,4,CH,A,54,20,CH,A,74,20,CH,A)
  OUTREC BUILD=(1,4,5:SEQNUM,1,ZD,6:5)
  OUTFIL FNAMES=OUTPUT,REMOVECC,
      OMIT=(6,2,BI,EQ,X'0000',AND,5,1,ZD,GT,+1),
      BUILD=(1,4,5:6),
      TRAILER1=(5:X'FFFF',COUNT-1=(M11,LENGTH=08))
/*
Back to top
View user's profile Send private message
bhaskar_kanteti

Active User


Joined: 01 Feb 2007
Posts: 123
Location: Hyderabad

PostPosted: Tue Nov 20, 2007 10:29 am
Reply with quote

Hi Frank,

When i am trying the run tha above SORT it is abending. And the error is as follows.

Code:

  OMIT COND=(5,2,CH,EQ,X'FFFF')                                          00170
  SORT FIELDS=(5,2,CH,A,7,20,CH,A,27,20,CH,A,114,1,CH,A,47,3,CH,A,       00180
               50,4,CH,A,54,20,CH,A,74,20,CH,A)                          00190
  OUTREC BUILD=(1,4,5:SEQNUM,1,ZD,6:5)                                   00200
  OUTFIL FNAMES=OUTPUT,REMOVECC,                                        00210
      OMIT=(6,2,BI,EQ,X'0000',AND,5,1,ZD,GT,+1),                         00220
      BUILD=(1,4,5:6),                                                   00230
      TRAILER1=(5:X'FFFF',                                               00240
               COUNT-1=(M11,LENGTH=08))                                  00250
 RECORD TYPE IS V - DATA STARTS IN POSITION 5                                 
 VLSHRT NOT USED FOR SORT, MERGE, INCLUDE, OMIT OR SUM STATEMENT FIELDS       
 TTOI36N .STEP010 .        , INPUT LRECL = 32756, BLKSIZE = 32760, TYPE = VB 
 OPTIONS: NULLOUT=RC0                                                         
 EXCP ACCESS METHOD USED FOR SORTIN                                           
 14 BYTE VARIABLE RECORD IS SHORTER THAN 114 BYTE MINIMUM FOR          FIELDS
 END OF DFSORT                                                               


Can you tell me what the error is.
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: Tue Nov 20, 2007 9:20 pm
Reply with quote

As the error message indicates, you have records that do not have all of your sort fields. You're trying to sort on position 114, but you have a record that's only 14 bytes long. VLSHRT would normally take care of this, but it can't be used with the OUTREC statement. So you'll need to use two passes with a DFSORT/ICETOOL job like this:

Code:

//STEP010  EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN  DD DSN=MY.INPUT1,DISP=SHR
//        DD DSN=MY.INPUT2,DISP=SHR
//        DD DSN=MY.INPUT3,DISP=SHR
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUTPUT  DD DSN=MY.OUTPUT,
//             DISP=(,CATLG,DELETE),DATACLAS=DSIZC100,
//             RECFM=VB,LRECL=32756
//TOOLIN DD *
SORT FROM(IN) TO(T1) USING(CTL1)
COPY FROM(T1) USING(CTL2)
/*
//CTL1CNTL DD *
  OPTION VLSHRT
  OMIT COND=(5,2,CH,EQ,X'FFFF')
  SORT FIELDS=(5,2,CH,A,7,20,CH,A,27,20,CH,A,114,1,CH,A,47,3,CH,A,
               50,4,CH,A,54,20,CH,A,74,20,CH,A)
/*
//CTL2CNTL DD *
  OUTREC BUILD=(1,4,5:SEQNUM,1,ZD,6:5)
  OUTFIL FNAMES=OUTPUT,REMOVECC,
      OMIT=(6,2,BI,EQ,X'0000',AND,5,1,ZD,GT,+1),
      BUILD=(1,4,5:6),
      TRAILER1=(5:X'FFFF',
               COUNT-1=(M11,LENGTH=08))
/*
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 TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top