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

FINDREP=(INOUT problem


IBM Mainframe Forums -> SYNCSORT
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Gary McDowell

Active User


Joined: 15 Oct 2012
Posts: 139
Location: USA

PostPosted: Sat Mar 21, 2015 1:34 am
Reply with quote

I'm trying to create an Excel comma-delimited file with SyncSort. The data also has commas in it so I needed to add double-quotes around the fields along with the comma. Now the issue I have is the output has no double-quote in col-1, and an extra quote at end.
Any help/suggestions would be appreciated (yes, I've been looking at the SyncSort manuals). Thanks.

Input:
Code:
1111~222~2015-02-28~
9999999999~JONES & ASSOCIATES, DDS, PA~P O BOX 123~~AAAAAAAAAA~

//SYSIN DD *
Code:
   SORT FIELDS=COPY
   OUTFIL FNAMES=SORTOUT,VTOF,OUTREC=(5,3000)
   OUTREC FINDREP=(INOUT=(C'~',C'","', 
                          C'"   ',C'    '))


Sample of what I am getting (no double-quote in col-1, and an extra quote at end):
Code:
1111","2222","2015-02-28","
9999999999","JONES & ASSOCIATES, DDS, PA","P O BOX 123","","AAAAAAAAAA","


Sample of what it should look like:
Code:
"1111","2222","2015-02-28",
"9999999999","JONES & ASSOCIATES, DDS, PA","P O BOX 123","","AAAAAAAAAA",
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Sat Mar 21, 2015 1:56 am
Reply with quote

Try using INREC FINDREP and then use OUTREC BUILD to do whatever formatting you want.

Something like this:
Code:
//SYSIN DD *                                                         
    SORT FIELDS=COPY                                                 
    OUTFIL FNAMES=SORTOUT,VTOF                                             
    INREC FINDREP=(INOUT=(C'~',C'","',                               
                           C'"   ',C'    '))                         
    OUTREC BUILD=(1:C'"',2:5,3000)                                     
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sat Mar 21, 2015 3:38 am
Reply with quote

Code:
   SORT FIELDS=COPY
   INREC IFTHEN=(WHEN=INIT,
               FINDREP=(INOUT=(C'~',C'","',))),
         IFTHEN=(WHEN=INIT,
               BUILD=(1,4,C'"',5)),
         IFTHEN=(WHEN=INIT,
               FINDREP=(INOUT=(C'"   ',C'    ')))

   OUTFIL VTOF,OUTREC=(5,3000)


The BUILD takes care of the first problem. You have to insert a character, because there is nothing to change.

Your other problem is that the output from one FINREP change cannot be further changed in the same FINDREP. So you need a second FINDREP.

It doesn't matter in what order you specify them, OUTFIL is always going to be done last. So specify it last anyway.
Back to top
View user's profile Send private message
Gary McDowell

Active User


Joined: 15 Oct 2012
Posts: 139
Location: USA

PostPosted: Wed Mar 25, 2015 2:17 am
Reply with quote

Thanks Bill and RahuG31.

Almost!

Only the last IFTHEN to change the double-quote with a space did not work and I think I know why.
The input is variable-length and the last double-quote has no spaces after it so it's never found.
Input in hex:
Code:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
1111~222~2015-02-28~                                             
FFFFAFFFAFFFF6FF6FFA
11111222120150020281
--------------------------------------------------------------------------------
9999999999~JONES & ASSOCIATES, DDS, PA~P O BOX 123~~AAAAAAAAAA~ 
FFFFFFFFFFADDDCE454CEEDCCCECE64CCE64DCAD4D4CDE4FFFAACCCCCCCCCCA
99999999991165520001226391352B0442B0711706026701231111111111111
--------------------------------------------------------------------------------

I tried replacing the last IFTHEN with the following but got the same double-quote at the end:
Code:
  OUTREC IFTHEN=(WHEN=INIT,                       
                 FINDREP=(INOUT=(C'"   ',C'    ')))

  OUTREC FINDREP=(INOUT=(C'"   ',C'    '))


I then tried googling for a way I could change the last input '~' or last output '"'. Nothing yey.
Any suggestions?
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Mar 25, 2015 4:30 am
Reply with quote

Your diagnosis is correct.

Sorry, I "tested" it with fixed input :-)

Change this:

Code:

         IFTHEN=(WHEN=INIT,
               FINDREP=(INOUT=(C'"   ',C'    ')))


To this:

Code:

         IFTHEN=(WHEN=INIT,
               OVERLAY=(3005:X)),
         IFTHEN=(WHEN=INIT,
               FINDREP=(INOUT=(C'"   ',C'    '),
                        DO=1))


At the moment you are extending any records shorter than 3000 in length of data on the OUTFIL, and they get padded with space. No problem (since there is no SORT) in doing it in INREC before the second FINDREP. Then there is only one change you need, so put the DO=1 to prevent the FINDREP searching the entire 3000 bytes (for a variable-length record, FINDREP starts at position five and is limited by the record-length in the RDW, which SORT will automatically increase after the OVERLAY).

If there were a SORT involved, you'd do this all in OUTREC, which would be after the SORT is complete, to limit the amount of data sorted.
Back to top
View user's profile Send private message
Gary McDowell

Active User


Joined: 15 Oct 2012
Posts: 139
Location: USA

PostPosted: Wed Mar 25, 2015 5:56 pm
Reply with quote

Perfect! Thank you Bill. I like how that DO=1 works.

Are there any links/books you would recommend for SYNCSORTs?

Thanks again.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Mar 25, 2015 6:55 pm
Reply with quote

SyncSort documentation is proprietary, but you can get copies easily if your site is licensed to use the product.

There is no SyncTool documentation. According to Dave Porcelan, SyncSort Support suggest using the DFSORT documentation for ICETOOL.

There are various DFSORT papers which will be useful and largely work on SyncSort, but be careful not to miss out on SyncSort-only stuff.

There is a new SyncSort available, 2.1. There are some papers at syncsort.com, but I've not looked at them yet.
Back to top
View user's profile Send private message
Gary McDowell

Active User


Joined: 15 Oct 2012
Posts: 139
Location: USA

PostPosted: Wed Mar 25, 2015 9:38 pm
Reply with quote

Bill Woodger wrote:
SyncSort documentation is proprietary, but you can get copies easily if your site is licensed to use the product.

There is no SyncTool documentation. According to Dave Porcelan, SyncSort Support suggest using the DFSORT documentation for ICETOOL.

There are various DFSORT papers which will be useful and largely work on SyncSort, but be careful not to miss out on SyncSort-only stuff.

There is a new SyncSort available, 2.1. There are some papers at syncsort.com, but I've not looked at them yet.

I'll take your suggestions. Thanks Bill.
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 -> SYNCSORT

 


Similar Topics
Topic Forum Replies
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts z/vm installation problem All Other Mainframe Topics 0
No new posts Job scheduling problem. JCL & VSAM 9
No new posts Problem with IFTHEN=(WHEN=GROUP,BEGIN... DFSORT/ICETOOL 5
Search our Forums:

Back to Top