|
View previous topic :: View next topic
|
| Author |
Message |
Jasand
New User
Joined: 23 Jan 2009 Posts: 32 Location: Tamil nadu
|
|
|
|
I need to get the string between two commas (between the 10th and the 11th comma of a record) in a VB file
Record format . . . : VB
Record length . . . : 392
Block size . . . . : 27998
| Code: |
"AL",2,3,"JOSE",20090617,"AB","Y","N","F","L",000000,15
"BE",3,4,"KATHERINE",20100901,"AA","Y","F","G","V",100000,9,15
"CB",5,5,"CLIVE",20091011,"AA","Y","N","G","V",002500,31,21
"DB",7,6,"BRITTANY",19990826,"AA","Y","E","G","V",300000,9,0
"DE",1,7,"ROBERT",20091012,"AA","Y","N","G","V",000600,328
"DF",0,8,"SAMFRANCIS",20050926,"AA","Y","W","B","V",023400,26,
|
Expected output is:
000000
100000
002500
300000
000600
023400
Thanks.. |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Here's a DFSORT job that will do what you asked for:
| Code: |
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (VB)
//SORTOUT DD DSN=... output file (VB)
//SYSIN DD *
OPTION COPY
INREC PARSE=(%=(ENDBEFR=C','),
%=(ENDBEFR=C','),
%=(ENDBEFR=C','),
%=(ENDBEFR=C','),
%=(ENDBEFR=C','),
%=(ENDBEFR=C','),
%=(ENDBEFR=C','),
%=(ENDBEFR=C','),
%=(ENDBEFR=C','),
%=(ENDBEFR=C','),
%1=(ENDBEFR=C',',FIXLEN=6)),BUILD=(1,4,%1)
|
|
|
| Back to top |
|
 |
Jasand
New User
Joined: 23 Jan 2009 Posts: 32 Location: Tamil nadu
|
|
|
|
Got the expected output. Thanks for your help and quick response.  |
|
| Back to top |
|
 |
Jasand
New User
Joined: 23 Jan 2009 Posts: 32 Location: Tamil nadu
|
|
|
|
Hi Frank,
***************************** Top of Data ******************************
"AS",0,4,"BRITTANY COUNT",20030224,"AA","Y","L","G","V",000000,0,0.00,0.
"SE",0,5,"ROBERT LEE V",20030224,"AA","Y","L","G","V",000000,1,1
"BG",0,6,"SAM, L GEORGE",0,"**","Y","N","D","V",000000,5,3.00,0.000000,
"BT",0,7,"FRANK JEN",20030224,"AA","Y","N","D","V",000000,0,9
"VE",0,8,"MIOME BETH",20050905,"AA","Y","N","G","V",000000,41,-1771091
**************************** Bottom of Data ****************************
For the above input, I get the below one as the output..
0
1
000000
0
41
But the expected one is
0
1
5 -> instead of 5 , 000000 is picked here, as there is an extra comma in the third row SAM, L GEORGE
0
41
Is there a way in SORT to face such exceptions. The exception may occur in any filed other than the name field.
Also an additional requirement is to get the output sorted in ascending order with the count of no: of zero entries, no: of non-zero entries and total no: of records. For example the final output may look like
0
0
1
5
41
Zero entries: 2
Non-zero entries:3
Total records: 5 (Hope this will help for the total count..OUTFIL REMOVECC,NODETAIL,TRAILER1=(COUNT)
Thanks,
Jasand |
|
| Back to top |
|
 |
Escapa
Senior Member

Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
| Quote: |
For the above input, I get the below one as the output..
0
1
000000
0
41
But the expected one is
0
1
5 -> instead of 5 , 000000 is picked here, as there is an extra comma in the third row SAM, L GEORGE
0
41
|
Use PAIR=QUOTE for the fields where you expect , exception.
e.g.
| Code: |
//SYSIN DD *
OPTION COPY
INREC PARSE=(%=(ENDBEFR=C','),
%=(ENDBEFR=C','),
%=(ENDBEFR=C','),
%=(ENDBEFR=C',',PAIR=QUOTE),
%=(ENDBEFR=C','),
.
.
.
.
|
|
|
| Back to top |
|
 |
Jasand
New User
Joined: 23 Jan 2009 Posts: 32 Location: Tamil nadu
|
|
|
|
Got the result.. Thanks a lot
Also can you help me with the below,
An additional requirement is to get the output sorted in ascending order with the count of no: of zero entries, no: of non-zero entries and total no: of records. For example the final output may look like
0
0
1
5
41
No of zero entries: 2
No: of Non-zero entries:3
Total records: 5 (Hope this will help for the total count..OUTFIL REMOVECC,NODETAIL,TRAILER1=(COUNT)
Thanks,
Jasand |
|
| Back to top |
|
 |
Jasand
New User
Joined: 23 Jan 2009 Posts: 32 Location: Tamil nadu
|
|
|
|
Hi,
Great trick to use "PAIR=QUOTE" to squeeze out blanks between a PAIR.
And does it consider the text inbetween two apostrophes as a pair to squeeze with ?
It would be great if you could provide a small description on
=(%=(ENDBEFR=C','
what the % stands for ?
I tried to looking into User Guide for DFSORT but I am not able to figure it out. Pardon me if it is out there and I have missed it.
Thanks,
Jasand |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
| Quote: |
Great trick to use "PAIR=QUOTE" to squeeze out blanks between a PAIR.
And does it consider the text inbetween two apostrophes as a pair to squeeze with ? |
PAIR=QUOTE uses quote pairs. PAIR=APOST used apostrophe pairs.
| Quote: |
It would be great if you could provide a small description on
=(%=(ENDBEFR=C','
what the % stands for ?
I tried to looking into User Guide for DFSORT but I am not able to figure it out. Pardon me if it is out there and I have missed it. |
DFSORT's PARSE function is fully documented in "z/OS DFSORT Application Programming Guide". Start here:
publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CA40/3.13?DT=20090527161936
Then do a Find on PARSE=
Alternatively, the PARSE function is also documented at:
www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000086 |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
| Quote: |
| An additional requirement is to get the output sorted in ascending order with the count of no: of zero entries, no: of non-zero entries and total no: of records. |
Here's a DFSORT job that will do what you asked for:
| Code: |
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (VB)
//SORTOUT DD LRECL=50,DSN=... output file (VB/50)
//SYSIN DD *
INREC PARSE=(%=(ENDBEFR=C','),
%=(ENDBEFR=C','),
%=(ENDBEFR=C','),
%=(ENDBEFR=C',',PAIR=QUOTE),
%=(ENDBEFR=C','),
%=(ENDBEFR=C','),
%=(ENDBEFR=C','),
%=(ENDBEFR=C','),
%=(ENDBEFR=C','),
%=(ENDBEFR=C','),
%=(ENDBEFR=C','),
%1=(ENDBEFR=C',',FIXLEN=6)),BUILD=(1,4,%1)
SORT FIELDS=(5,6,UFF,A)
OUTREC IFTHEN=(WHEN=(1,6,UFF,EQ,0),OVERLAY=(11:C'101')),
IFTHEN=(WHEN=NONE,OVERLAY=(11:C'011'))
OUTFIL REMOVECC,
BUILD=(1,10),
TRAILER1=(/,'Zero entries: ',23:TOT=(11,1,ZD,M10,LENGTH=5),/,
'Non-zero entries: ',23:TOT=(12,1,ZD,M10,LENGTH=5),/,
'Total records: ',23:TOT=(13,1,ZD,M10,LENGTH=5))
/*
|
|
|
| Back to top |
|
 |
Jasand
New User
Joined: 23 Jan 2009 Posts: 32 Location: Tamil nadu
|
|
|
|
| It worked fine. Thanks a lot. |
|
| Back to top |
|
 |
Jasand
New User
Joined: 23 Jan 2009 Posts: 32 Location: Tamil nadu
|
|
|
|
I have got the output written into a FB file
Record format . . . : FB
Record length . . . : 40
Block size . . . . : 27960
But how to get the above counts "Zero entries, Non-zero entries and Total count" with the above suggested code. I tried modifying the character position by +4 and -4 (As the above code was written for VB file). But I get the error with the below code
//OPTION COPY
//TRAILER1=('ZERO ENTRIES :',
// 23:TOT=(11,1,ZD,M10,LENGTH=5),/,
// 'NON-SERO ENTRIES :',
// 23:TOT=(12,1,ZD,M10,LENGTH=5),/,
// 'TOTAL RECORDS :',
// 23:TOT=(13,1,ZD,M10,LENGTH=5))
/*
Thanks,
Jasand |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
| Quote: |
| It worked fine. Thanks a lot. |
| Quote: |
| I have got the output written into a FB file ... |
Are we talking about a different situation now? What exactly is the new situation? Are you starting with a VB file as input and creating an FB file as output or what?
| Quote: |
| But I get the error with the below code |
What error? You aren't showing any error message. I'm not a mindreader.
Why do you have // in these control statements - JCL statements start with // - DFSORT control statements start with a blank.
Please start over and explain clearly exactly what you're trying to do in this new situation. |
|
| Back to top |
|
 |
Jasand
New User
Joined: 23 Jan 2009 Posts: 32 Location: Tamil nadu
|
|
|
|
I am talking on the same situation. Sorry for not detailing the requirement. Let me brief it now.
I wanted the entire sort to be done on a FB file. So I wrote the initial VB file data into a FB file using
OPTION COPY
OUTFIL CONVERT,OUTREC=(5,200)
and then used the code given by Frank on March 15th. I slightly modified it as below with FIXLEN=10. The code works fine till sorting the data in ascending order.
//CTL1CNTL DD *
INREC PARSE=(%=(ENDBEFR=C','),
%=(ENDBEFR=C','),
%=(ENDBEFR=C','),
%=(ENDBEFR=C',',PAIR=QUOTE),
%=(ENDBEFR=C','),
%=(ENDBEFR=C','),
%=(ENDBEFR=C','),
%=(ENDBEFR=C','),
%=(ENDBEFR=C','),
%=(ENDBEFR=C','),
%=(ENDBEFR=C','),
%1=(ENDBEFR=C',',FIXLEN=10)),
BUILD=(%1)
SORT FIELDS=(1,10,UFF,A)
OUTFIL REMOVECC,
BUILD=(1,10)
/*
But I am not able to get the correct output with the Trailer section of the code(given below). Because the positions change for a FB file.
Since I couldnt understand the significance of the code OVERLAY=(11:C'101')), , I am not able to modify it as per my requirement.
OUTREC IFTHEN=(WHEN=(1,6,UFF,EQ,0),OVERLAY=(11:C'101')),
IFTHEN=(WHEN=NONE,OVERLAY=(11:C'011'))
OUTFIL REMOVECC,
BUILD=(1,10),
TRAILER1=(/,
'Zero entries: ',23:TOT=(11,1,ZD,M10,LENGTH=5),/,
'Non-zero entries: ',23:TOT=(12,1,ZD,M10,LENGTH=5),/,
'Total records: ',23:TOT=(13,1,ZD,M10,LENGTH=5))
Can you please explain it as I was not able to identify the exact pupose from the document too.
Also I need to get the trailer section in a seperate FB file.
Thanks,
Jasand
|
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Here's a DFSORT job that will do what I think you're asking for.
| Code: |
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (FB/200)
//SORTOUT DD DSN=... output file (FB/80)
//SYSIN DD *
INREC PARSE=(%=(ENDBEFR=C','),
%=(ENDBEFR=C','),
%=(ENDBEFR=C','),
%=(ENDBEFR=C',',PAIR=QUOTE),
%=(ENDBEFR=C','),
%=(ENDBEFR=C','),
%=(ENDBEFR=C','),
%=(ENDBEFR=C','),
%=(ENDBEFR=C','),
%=(ENDBEFR=C','),
%=(ENDBEFR=C','),
%1=(ENDBEFR=C',',FIXLEN=10)),BUILD=(%1)
SORT FIELDS=(1,10,UFF,A)
OUTREC IFTHEN=(WHEN=(1,10,UFF,EQ,0),BUILD=(1,80,81:C'101')),
IFTHEN=(WHEN=NONE,OVERLAY=(81:C'011'))
OUTFIL REMOVECC,
BUILD=(1,80),
TRAILER1=(/,'Zero entries: ',19:TOT=(81,1,ZD,M10,LENGTH=5),/,
'Non-zero entries: ',19:TOT=(82,1,ZD,M10,LENGTH=5),/,
'Total records: ',19:TOT=(83,1,ZD,M10,LENGTH=5))
/*
|
|
|
| Back to top |
|
 |
Jasand
New User
Joined: 23 Jan 2009 Posts: 32 Location: Tamil nadu
|
|
|
|
| Thanks a lot. Got the expected result. |
|
| Back to top |
|
 |
Jasand
New User
Joined: 23 Jan 2009 Posts: 32 Location: Tamil nadu
|
|
|
|
Hi,
Can you please help me to get the sum of the fields which were previously obtained through SORT FIELDS=(1,10,UFF,A) in the above code ?
How to get that SUM output display in the TRAILER section?
| Code: |
TRAILER1=(/,'Zero entries: ',19:TOT=(81,1,ZD,M10,LENGTH=5),/,
'Non-zero entries: ',19:TOT=(82,1,ZD,M10,LENGTH=5),/,
'Total records: ',19:TOT=(83,1,ZD,M10,LENGTH=5),/,
'Sum : ',19:................................) |
Thanks,
Jasand |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Jasand,
If you want the sum of all records then change your trailer1 to the following
| Code: |
TRAILER1=(/,'Zero entries: ',19:TOT=(81,1,ZD,M10,LENGTH=5),/,
'Non-zero entries: ',19:TOT=(82,1,ZD,M10,LENGTH=5),/,
'Total records: ',19:TOT=(83,1,ZD,M10,LENGTH=5),/,
'Sum : ',19:TOT=(1,10,UFF,M10,LENGTH=12))
|
|
|
| Back to top |
|
 |
Jasand
New User
Joined: 23 Jan 2009 Posts: 32 Location: Tamil nadu
|
|
|
|
| Many thanks Skolusu.. Got the output. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|