Page 1 of 1

Picking line nbr from last record and placing it in header

PostPosted: Fri Aug 19, 2011 1:27 pm
by Swati Gupta
Hi All,
I have to do the below through a single icetool step:-
The i/p file has line numbers and have to pick last line number (comma seperated file ) and place it in the header recort count which is on 5th line.
Please see the i/p file:-
-----------------------------------------------------
# ISSUER CODE: 2216317637
# JOB TYPE: ADDUPDEL
# CREATED ON: 20110817
# SEQUENCE NUMBER: 417
# RECORD COUNT: 3
# NUMBER OF FIELDS: 4
# FI ID: abscd
1,A,A,sdjsakjfkjdkfj,67
2,A,A,sdjsakjtitoire,76
3,A,A,sdjsakjyuyu,67
4,A,A,sdjsakj,4069
5,A,A,sdjsakj,38247328
6,A,sajdskdj,854385
7,A,sdjsakj,458475
--------------------------------------------
7 top lines are header info and data starts from 8th record with line number.
File has millions of record.
I need to put the last line number in record acount as it is coming incorrect through icetool step. Also file is in CSV format and have to change file in the same step.

o/p file should be like:-

-----------------------------------------------------
# ISSUER CODE: 2216317637
# JOB TYPE: ADDUPDEL
# CREATED ON: 20110817
# SEQUENCE NUMBER: 417
# RECORD COUNT: 7
# NUMBER OF FIELDS: 4
# FI ID: abscd
1,A,A,sdjsakjfkjdkfj,67
2,A,A,sdjsakjtitoire,76
3,A,A,sdjsakjyuyu,67
4,A,A,sdjsakj,4069
5,A,A,sdjsakj,38247328
6,A,sajdskdj,854385
7,A,sdjsakj,458475
--------------------------------------------
record count should be line number of last record.

I tried an icetool step to get last record in a temp file using below jcl but cant do further. Could you please help.

//JSTEP010 EXEC PGM=ICETOOL
//DFSMSG DD SYSOUT=*
//TOOLMSG DD SYSOUT=*
//IN DD DSN=i/p file
//OUT DD DSN=&&Temp
//TOOLIN DD *
SUBSET FROM(IN) TO(OUT) KEEP INPUT LAST
/*


Thanks,

Re: Picking line nbr from last record and placing it in head

PostPosted: Fri Aug 19, 2011 9:43 pm
by skolusu
Swati Gupta,

You haven't provided any details about the LRECL and RECFM of the input file. I assumed that your input is FB recfm and LRECL=80. The count will be updated on the 5th record at pos 16 with the leading zeroes suppressed.

//STEP0100 EXEC PGM=SORT         
//SYSOUT   DD SYSOUT=*           
//INA      DD DSN=your input 80 byte file,DISP=SHR
//INB      DD DSN=your same input 80 byte file,DISP=SHR
//SORTOUT  DD SYSOUT=*           
//SYSIN    DD *                                                   
  OPTION COPY                                                     
  JOINKEYS F1=INA,FIELDS=(81,08,A),SORTED                         
  JOINKEYS F2=INB,FIELDS=(01,8,A)                                 
  JOIN UNPAIRED,F1                                                 
  REFORMAT FIELDS=(F1:1,80,?,F2:9,8)                               
  INREC IFOUTLEN=80,                                               
  IFTHEN=(WHEN=(81,1,CH,EQ,C'B'),OVERLAY=(16:82,8,ZD,M10,LENGTH=8))
//JNF1CNTL DD *                                                   
  INREC OVERLAY=(81:SEQNUM,8,ZD)                                   
//JNF2CNTL DD *                                                   
  OPTION SKIPREC=7                                                 
  INREC BUILD=(C'00000005',C'00000001')                           
  SUM FIELDS=(9,8,ZD)                                             
//*

Re: Picking line nbr from last record and placing it in head

PostPosted: Mon Aug 22, 2011 2:47 pm
by Swati Gupta
Thanks Skolusu,
But my file is a variable length file and i need to update it thought the above. how would the above be modified.

Re: Picking line nbr from last record and placing it in head

PostPosted: Mon Aug 22, 2011 9:38 pm
by skolusu
Swati Gupta wrote:Thanks Skolusu,
But my file is a variable length file and i need to update it thought the above. how would the above be modified.


Swati Gupta,

Wouldn't it be easier if you had specified this vital piece of information in your first post itself? Use the following DFSORT Control cards

//SYSIN    DD *                                 
  OPTION COPY                                   
  JOINKEYS F1=INA,FIELDS=(05,08,A),SORTED       
  JOINKEYS F2=INB,FIELDS=(05,8,A)               
  JOIN UNPAIRED,F1                             
  REFORMAT FIELDS=(F1:1,4,F2:13,8,?,F1:13)     
  INREC IFTHEN=(WHEN=(13,1,CH,EQ,C'B'),         
  BUILD=(1,4,14,15,5,8,ZD,M10,LENGTH=8,37)),   
  IFTHEN=(WHEN=NONE,BUILD=(1,4,14))             
//JNF1CNTL DD *                                 
  INREC BUILD=(1,4,SEQNUM,8,ZD,5)               
//JNF2CNTL DD *                                 
  OPTION SKIPREC=7                             
  INREC BUILD=(1,4,C'00000005',C'00000001')     
  SUM FIELDS=(13,8,ZD)                         
//*

Re: Picking line nbr from last record and placing it in head

PostPosted: Mon Aug 22, 2011 10:05 pm
by Swati Gupta
My Apologies ... i understand that it has eventually took double the time for almost the same thing.. I really appreciate. Thank You. <wink>