Page 1 of 1

Add to a variable length record

PostPosted: Tue Jul 24, 2012 1:52 am
by Kevin Jenkins
Please can you advise, if it Is possible using DFSORT to add a x'0d0a' sequence at the end of each record in a variable blocked file. The input file is ...

Organization . . . : PS
Record format . . . : VB
Record length . . . : 1500

Input records do contain embedded blanks.

Sort maint level is ...
ICE201I H RECORD TYPE IS F - DATA STARTS IN POSITION 1

Grateful, if you can post an example if this can be done.

Regards, Kevin

Re: Add to a variable length record

PostPosted: Tue Jul 24, 2012 4:32 am
by BillyBoyo
If this is for shipping data off the mainframe, the software you use for that can probably do it.

Re: Add to a variable length record

PostPosted: Tue Jul 24, 2012 5:17 am
by skolusu
Kevin Jenkins,

Currently DFSORT does not have any feature to append a character at the end of variable data. You want to append X'0D0A' which is CRLF which is only required by the windows OS. Unix just needs LF. If you are FTP'ing the data then as bill mentioned , then FTP/NDM software can insert the x'0D0A'. If you want to get it done via DFSORT then you can code a bunch of IFTHEN statements and validate the length in RDW and overlay the contents. But coding 1496 IFTHEN statements is tedious job. So I generated them. Use the following DFSORT JCL which will give you the desired results.
//STEP0100 EXEC PGM=SORT                                         
//SYSOUT   DD SYSOUT=*                                           
//SORTIN   DD *                                                   
Dummy record                                                           
//SORTOUT  DD DSN=&&C,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)         
//SYSIN    DD *                                                   
  SORT FIELDS=COPY                                               
  OUTFIL REPEAT=1497,IFOUTLEN=80,IFTHEN=(WHEN=INIT,               
  BUILD=(3:C'INREC IFTHEN=(WHEN=(1,2,BI,EQ,',SEQNUM,4,ZD,START=5,
           C'),OVERLAY=(',SEQNUM,4,ZD,START=6,                   
           C':X''',C'0D0A''',C')),',81:SEQNUM,4,ZD)),             
  IFTHEN=(WHEN=(81,4,ZD,GT,1),OVERLAY=(1:8X),HIT=NEXT),           
  IFTHEN=(WHEN=(81,4,ZD,EQ,1495),OVERLAY=(48:C'1499')),           
  IFTHEN=(WHEN=(81,4,ZD,EQ,1496),OVERLAY=(48:C'1499',62:X)),     
  IFTHEN=(WHEN=(81,4,ZD,EQ,1497),BUILD=(3:C'OPTION COPY'))       
//*               
//STEP0200 EXEC PGM=SORT         
//SYSOUT   DD SYSOUT=*           
//SORTIN   DD DSN=Your Input VB 1500 byte file,DISP=SHR 
//SORTOUT  DD SYSOUT=*           
//SYSIN    DD DSN=&&C,DISP=SHR   
//*

Re: Add to a variable length record

PostPosted: Tue Jul 24, 2012 2:33 pm
by Kevin Jenkins
Kolusu, Bill

Thanks to you both for your feedback. I'll explore your suggestion.

Regards, Kevin