Variable length field from a file using SORT
Moderators: Frank Yaeger, Moderator Group
Variable length field from a file using SORT
I have a requirement where I need to pick up a numeric value from a variable length field from a file. Is this possible using DFSORT? Like the in screenshot, the value 29 could be 329 or 2329 or 899033. There is no limit to the number.
"Loaded 29 rows into the database"
"Loaded 29 rows into the database"
- dbzTHEdinosauer
- Moderator
- Posts: 981
- Joined: Mon Oct 02, 2006 8:31 pm
- dbzTHEdinosauer
- Moderator
- Posts: 981
- Joined: Mon Oct 02, 2006 8:31 pm
other than not knowing the dcb attributes of the file,
we only need to know
we only need to know
what do you want to do with the numeric value?I need to pick up a numeric value from a variable length field from a file
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.
- dbzTHEdinosauer
- Moderator
- Posts: 981
- Joined: Mon Oct 02, 2006 8:31 pm
as I am off today, I don't mind this silliness, too much.I need this numeric value and replace this value in another file.
'replace'?
where, what? what are the dcb attributes of this 'other file'? (actually both files!)
what position do you want overlayed with this extract numeric value?
why don't you have the originator of the file containing the 'LOADED' also do this replacement?
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.
DFSPRT INCLUDE OUTREC FINDREP INOUT
Please check this sort card... i did not tested this card..
It will place required record into output file. by replacing the string
with spaces.
Input file
asdfdssfsfsdf
Loaded 47 rows into the database
asdfsfdssadf
Output file
47
Code: Select all
//SYSIN DD *
SORT FIELDS=COPY
INCLUDE COND=(1,6,CH,EQ,C'Loaded')
OUTREC FINDREP=(INOUT=(C'LOADED',C'',C'rows into the database',C''))
/*
It will place required record into output file. by replacing the string
with spaces.
Input file
asdfdssfsfsdf
Loaded 47 rows into the database
asdfsfdssadf
Output file
47
Natarajan
Chennai
Chennai
- Frank Yaeger
- Moderator
- Posts: 812
- Joined: Sat Feb 18, 2006 5:45 am
- Location: San Jose, CA
- Contact:
subasu,
You can use a DFSORT job like the following to write a record with the extracted number as 10 digits with leading zeros. I assumed your largest number is 10 digits but you can change that if appropriate.
For the example give, SORTOUT would have:
0000029123
For an input record of:
Loaded 29 rows into the database
SORTOUT would have:
0000000029
and so on.
You can change this job appropriately for what you want to do (which isn't clear).
You can use a DFSORT job like the following to write a record with the extracted number as 10 digits with leading zeros. I assumed your largest number is 10 digits but you can change that if appropriate.
Code: Select all
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
... record
... record
Loaded 29123 rows into the database
... record
... record
//SORTOUT DD DSN=... output file (FB/80)
//SYSIN DD *
OPTION COPY
INCLUDE COND=(1,6,CH,EQ,C'Loaded')
INREC PARSE=(%01=(ABSPOS=8,ENDBEFR=C' ',FIXLEN=10)),
BUILD=(%01,UFF,M11,LENGTH=10,80:X)
/*
0000029123
For an input record of:
Loaded 29 rows into the database
SORTOUT would have:
0000000029
and so on.
You can change this job appropriately for what you want to do (which isn't clear).
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
Thanks for your promt replies.... probably I should have stated my requirements more clearly for everyone's understnading...
One file of FB/133 has the line which details the record count.... this count has to be picked up and replaced in another file FB/80.
Input FIle: FB-133
.......
.........
Loaded 29 rows into the database
....
....
O/P file:
FILEID001 0000000
This 7 digit value of 0000000 has to be replaced from the count in the input file.
dbzTHEdinosauer - Sorry for not making the requirements clear. I hope now you have a clearer understanding.
Natarajan - The INREC record was giving an error
Frank - You are the champ... it worked!!!! I need to replace this value in another file, which contains only 1 record, in the first line from the position 11 to 17 in the output file.
One file of FB/133 has the line which details the record count.... this count has to be picked up and replaced in another file FB/80.
Input FIle: FB-133
.......
.........
Loaded 29 rows into the database
....
....
O/P file:
FILEID001 0000000
This 7 digit value of 0000000 has to be replaced from the count in the input file.
dbzTHEdinosauer - Sorry for not making the requirements clear. I hope now you have a clearer understanding.
Natarajan - The INREC record was giving an error
Frank - You are the champ... it worked!!!! I need to replace this value in another file, which contains only 1 record, in the first line from the position 11 to 17 in the output file.
- Frank Yaeger
- Moderator
- Posts: 812
- Joined: Sat Feb 18, 2006 5:45 am
- Location: San Jose, CA
- Contact:
subasu,
Here's a DFSORT job that will do what you asked for:
Here's a DFSORT job that will do what you asked for:
Code: Select all
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file1 (FB/133)
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN DD *
OPTION COPY
INCLUDE COND=(1,6,CH,EQ,C'Loaded')
INREC PARSE=(%01=(ABSPOS=8,ENDBEFR=C' ',FIXLEN=7)),
BUILD=(C'NEWCT,''',%01,UFF,M11,LENGTH=7,C'''',80:X)
/*
//S2 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=... input file2 (FB/80)
FILEID001 0000000
/*
//SORTOUT DD DSN=... output file (FB/80)
//SYSIN DD *
OPTION COPY
INREC OVERLAY=(11:NEWCT)
/*
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
FREE TUTORIALS
Tutorials
Free tutorials from mainframegurukul
- JCL Tutorial
Covers all important JCL concepts. - Cobol Tutorial
This tutorials covers all Cobol Topics from STRING to COMP-3. - DB2 Tutorial
DB2 Tutorial focuses on DB2 COBOL Programming. - SORT Tutorial
This Tutorial covers all important aspects of DFSORT with examples - CICS Tutorial
This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions
- Cobol Interview Questions
50+ Interview Questions - JCL Interview Questions
50+ Interview Questions - DB2 Interview Questions
100+ Interview Questions - CICS Interview Questions
70+ Interview Questions - VSAM Interview Questions
27 Interview Questions
Other References
Mainframe Tools and others
- XPEDITER Reference
Explains how we can debug a program - FILEAID Reference
Explains how to browse , edit and delete datasets - Change Man Reference
Quick Start tutorial on Changeman - Abend Reference
Important Abend codes explained - FaceBook Page
MainframeGurukul FaceBook Page - LinkedIn Page
MainframeGurkul Linkedin Page