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

How to get the string between two commas in a VB file


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

New User


Joined: 23 Jan 2009
Posts: 32
Location: Tamil nadu

PostPosted: Fri Mar 12, 2010 6:30 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri Mar 12, 2010 10:59 pm
Reply with quote

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
View user's profile Send private message
Jasand

New User


Joined: 23 Jan 2009
Posts: 32
Location: Tamil nadu

PostPosted: Mon Mar 15, 2010 10:00 am
Reply with quote

Got the expected output. Thanks for your help and quick response. icon_smile.gif
Back to top
View user's profile Send private message
Jasand

New User


Joined: 23 Jan 2009
Posts: 32
Location: Tamil nadu

PostPosted: Mon Mar 15, 2010 3:33 pm
Reply with quote

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
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Mon Mar 15, 2010 3:59 pm
Reply with quote

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
View user's profile Send private message
Jasand

New User


Joined: 23 Jan 2009
Posts: 32
Location: Tamil nadu

PostPosted: Mon Mar 15, 2010 4:20 pm
Reply with quote

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
View user's profile Send private message
Jasand

New User


Joined: 23 Jan 2009
Posts: 32
Location: Tamil nadu

PostPosted: Mon Mar 15, 2010 4:24 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Mon Mar 15, 2010 11:06 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Mon Mar 15, 2010 11:41 pm
Reply with quote

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
View user's profile Send private message
Jasand

New User


Joined: 23 Jan 2009
Posts: 32
Location: Tamil nadu

PostPosted: Wed Mar 17, 2010 10:53 am
Reply with quote

It worked fine. Thanks a lot.
Back to top
View user's profile Send private message
Jasand

New User


Joined: 23 Jan 2009
Posts: 32
Location: Tamil nadu

PostPosted: Wed Mar 17, 2010 6:44 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Mar 17, 2010 10:30 pm
Reply with quote

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.

Quote:
//OPTION COPY
...


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
View user's profile Send private message
Jasand

New User


Joined: 23 Jan 2009
Posts: 32
Location: Tamil nadu

PostPosted: Thu Mar 18, 2010 12:06 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Mar 18, 2010 10:59 pm
Reply with quote

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
View user's profile Send private message
Jasand

New User


Joined: 23 Jan 2009
Posts: 32
Location: Tamil nadu

PostPosted: Fri Mar 19, 2010 9:29 am
Reply with quote

Thanks a lot. Got the expected result.
Back to top
View user's profile Send private message
Jasand

New User


Joined: 23 Jan 2009
Posts: 32
Location: Tamil nadu

PostPosted: Mon Mar 22, 2010 5:37 pm
Reply with quote

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
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Mon Mar 22, 2010 9:04 pm
Reply with quote

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
View user's profile Send private message
Jasand

New User


Joined: 23 Jan 2009
Posts: 32
Location: Tamil nadu

PostPosted: Tue Mar 23, 2010 10:29 am
Reply with quote

Many thanks Skolusu.. Got the output.
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Replace each space in cobol string wi... COBOL Programming 3
Search our Forums:

Back to Top