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

Remove trailing spaces from each comma separated value.


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Pratap Kapse

New User


Joined: 14 Sep 2012
Posts: 9
Location: India

PostPosted: Mon Sep 17, 2012 1:23 pm
Reply with quote

Hi,

I am using the CSV file as input and the output file is also CSV file. My requirement is to remove the trailing spaces from each comma separated value.

e.g. Below is the record from I/P file:

"111111, John Parker ,48 STATE RD , ,02747"
Required O/p file record:

"111111, John Parker,48 STATE RD,,02747"

Is there any solution for this in JCL? If not then is there any function in COBOL for this?

I have one solution in COBOL where I will first map the record and then for each field perform below operation-
1. Find no of trailing spaces using INSPECT command
2. Using subscript (1: Length of field - No of trailing spaces) move the field to O/P record

But the issue with this approach is - there are 4 CSV files I am going process and each has its own record format.
Also there are 30 such a fields in each record and millions of records in each file so I need to consider optimization.
Quote:
Code:
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Mon Sep 17, 2012 1:44 pm
Reply with quote

Not in JCL as JCL does not do data manipulation - it works with Jobs - hence its name Job Control Language. To run your COBL solution you will need JCL. To run any other batch solution you would need JCL. Suggest you LOOK in the DFSORT section for similar solutions and search the forum - which you already did, didn't you? - for something like 'trailing blanks'
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Mon Sep 17, 2012 2:31 pm
Reply with quote

Quote:
But the issue with this approach is - there are 4 CSV files I am going process and each has its own record format.
Also there are 30 such a fields in each record and millions of records in each file so I need to consider optimization.
If this is the case, I'd believe that COBOL program is a better solution. Even if you write a SORT application for it - you need to tell SORT all the permutation/combuination you might want to take care about.

What release of zOS and COBOL you are working with? I sould not sound hyperbolic, however, with what you've posted - I'd say "optimization" should be the last thing to consider, at the moment.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Mon Sep 17, 2012 2:40 pm
Reply with quote

When you have leading spaces PARSE + Build should be used to achieve your solution
Back to top
View user's profile Send private message
Pratap Kapse

New User


Joined: 14 Sep 2012
Posts: 9
Location: India

PostPosted: Mon Sep 17, 2012 6:12 pm
Reply with quote

Thank you all for your immediate replies.

Nic,
I tried the squeeze option but PARAMETER 'FINDREP' IS UNIDENTIFIED (May be because the system which I use is not supporting it). Below is the sample CCLIB which I used:

Code:
  OPTION COPY
  INREC IFOUTLEN=51,
   IFTHEN=(WHEN=(3,1,CH,EQ,C','),
    BUILD=(1,7,8:8,40,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=42),
     50:48,4),HIT=NEXT),
   IFTHEN=(WHEN=(3,1,CH,EQ,C','),
     OVERLAY=(8:8,46,SQZ=(SHIFT=LEFT,PAIR=QUOTE)),HIT=NEXT),
   IFTHEN=(WHEN=(3,1,CH,EQ,C','),
     FINDREP=(IN=C'"',OUT=C''))


Is there any alternative for FINDREP?

Anuj,
As I am working in service based organization I don't have the access to System details. I was able find below information only... icon_sad.gif
z/OS 01.13.00
IBM Enterprise COBOL for z/OS 3.4.1

And yes If I found nothing I will use the COBOL for this.


Pandora-Box,
Can you please give me a example?

Code'd
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: Mon Sep 17, 2012 6:24 pm
Reply with quote

Which Sort product are you using? Can you post the sysout from a Sort step?

Where did you find those Sort control cards?

EDIT: OK, google was my friend.

You can't just pick up some Sort control cards and assume they're going to work for you.
Back to top
View user's profile Send private message
Pratap Kapse

New User


Joined: 14 Sep 2012
Posts: 9
Location: India

PostPosted: Tue Sep 18, 2012 10:26 am
Reply with quote

Hi Bill,

Sort product: SYNCSORT (DFSORT version - V1R14)

I found the control card from IBMMainframesforum site, below is the link where the similar question was asked:
ibmmainframeforum.com/viewtopic.php?f=28&t=2388

Below is the SYSOUT (Actually if I submit the JOB it is giving me 0 return code but the FINDREP is not working):

Code:
SYSIN :                                                               
  OPTION COPY                                                         
  INREC IFOUTLEN=482,                                                 
  IFTHEN=(WHEN=(8,1,CH,EQ,C','),                                     
    BUILD=(1,7,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=9),       
           10:8,1,                                                   
           11:9,7,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=9),     
           20:16,1,                                                   
           21:16,7,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=9),   
           30:24,1,                                                   
           31:25,30,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=32), 
           63:55,1,                                                   
           64:56,30,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=32), 
           96:86,1,                                                   
           97:87,30,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=32), 
           129:117,1,                                                 
           130:118,20,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=22),
           152:138,1,                                                 
           153:139,2,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=4), 
           157:141,1,                                                 
           158:142,5,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=7), 
           165:147,1,                                                 
           166:148,10,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=12),
           178:158,1,                                                 
           179:159,10,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=12),
           191:169,1,                                                 
           192:170,10,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=12),
           204:180,1,                                                 
           205:181,1,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=3), 
           208:182,1,                                                 
           209:183,20,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=22),
           231:203,1,                                                 
           232:204,8,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=10),
           242:212,1,                                                 
           243:213,2,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=4), 
           247:215,1,                                                 
           248:216,50,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=52),
           300:266,1,                                                 
           301:267,8,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=10),
           311:275,1,                                                 
           312:276,2,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=4), 
           316:278,1,                                                 
           317:279,50,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=52),
           369:329,1,                                                 
           370:330,8,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=10),
           380:338,1,                                                 
           381:339,20,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=22),
           403:359,1,                                                 
           404:360,2,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=4), 
           408:362,1,                                                 
           409:363,50,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=52),
           461:413,1,                                                 
           462:414,8,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=10),
           472:422,1,                                                 
           473:423,50,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=52),
           525:473,1,                                                 
           526:474,8,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=10),
           536:482,1),HIT=NEXT),                                     
   IFTHEN=(WHEN=(8,1,CH,EQ,C','),                                     
     OVERLAY=(1:1,537,SQZ=(SHIFT=LEFT,PAIR=QUOTE)),HIT=NEXT),         
   IFTHEN=(WHEN=(8,1,CH,EQ,C','),                                     
     FINDREP=(IN=C'"',OUT=C''))                                       
WER276B  SYSDIAG= 9255160, 14013467, 14013467, 8178900               
WER164B  6,896K BYTES OF VIRTUAL STORAGE AVAILABLE, MAX REQUESTED,   
WER164B     0 BYTES RESERVE REQUESTED, 2,420K BYTES USED             
WER146B  20K BYTES OF EMERGENCY SPACE ALLOCATED                       
WER108I  SORTIN   : RECFM=FB   ; LRECL=   482; BLKSIZE= 27956         
WER073I  SORTIN   : DSNAME=FILE1
WER257I  INREC RECORD LENGTH =   482                                   
WER110I  SORTOUT  : RECFM=FB   ; LRECL=   482; BLKSIZE= 27956           
WER074I  SORTOUT  : DSNAME=FILE2           
5,868K BYTES OF VIRTUAL STORAGE AVAILABLE ABOVE THE 16MEG LINE,
   0 BYTES RESERVE REQUESTED, 2,276K BYTES USED               
WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000
WER449I  SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE
WER416B  SORTIN   : EXCP'S=38,UNIT=3390,DEV=B057,CHP=(C2C37E96D3D47F99,1),VOL=BATNH1
WER416B  SORTOUT  : EXCP'S=38,UNIT=3390,DEV=3753,CHP=(251C4B5E8A,1),VOL=TSBNBM
WER416B  TOTAL OF 76 EXCP'S ISSUED FOR COPYING
WER054I  RCD IN      39419, OUT      39419   
WER169I  RELEASE 1.4 BATCH 0520 TPF LEVEL 0.1
WER052I  END SYNCSORT - H2567ADX,STEP01,,DIAG=8800,530C,A004,00EC,C0FA,6C83,A248,CEE0


The SYSIN card is modified as per my requirement.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Tue Sep 18, 2012 12:14 pm
Reply with quote

Quote:
Sort product: SYNCSORT (DFSORT version - V1R14)

That is utter garbage as SYNCSORT and DFSORT are two different, competeing, products.

You have SYNCSORT - messages begin WER. Now look in the SYNCSORT part of the forum for a solution.
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: Tue Sep 18, 2012 12:17 pm
Reply with quote

How about showing a representative sample of your input data, the output you are getting from that data and the expected output.
Back to top
View user's profile Send private message
Pratap Kapse

New User


Joined: 14 Sep 2012
Posts: 9
Location: India

PostPosted: Tue Sep 18, 2012 12:41 pm
Reply with quote

Below is the sample input data:

Code:
ABC1111,ABC2222,ABC3333,JOHN PARKER                   ,PO BOX 001                    ,CA LMF DEPT                   ,WARWICK             ,RI,00001,          ,0000000001,0000000001,A,SABASTIAN JOSEPH    ,000001 ,01,SUN DES GARY                                     ,0000001 ,01,MAC     Larry                                     ,0000001 ,NORTHEAST           ,01,MERRY JACK                                        ,0000008 ,CURTIS JOHN                                       ,0111111 ,


Output which I am getting after executing the mentioned SYSIN card:

Code:
"ABC1111","ABC2222","ABC3333","JOHN PARKER"                   ,"PO BOX 001"                    ,"CA LMF DEPT"                   ,"WARWICK"             ,"RI","00001",""          ,"0000000001","0000000001","A","SABASTIAN JOSEPH"    ,"000001" ,"01","SUN DES GARY"                                     ,"0000001" ,"01","MAC     Larry"                                     ,"0000001" ,"NORTHEAST"           ,"01","MERRY JACK"                                        ,"0000008" ,"CURTIS JO


Expected output:

Code:
ABC1111,ABC2222,ABC3333,JOHN PARKER,PO BOX 001,CA LMF DEPT,WARWICK,RI,00001,,0000000001,0000000001,A,SABASTIAN JOSEPH,000001,01,SUN DES GARY,0000001,01,MAC     Larry,0000001,NORTHEAST,01,MERRY JACK,0000008,CURTIS JOHN,0111111,


Thanks in advance for your help... icon_smile.gif
Back to top
View user's profile Send private message
Pratap Kapse

New User


Joined: 14 Sep 2012
Posts: 9
Location: India

PostPosted: Tue Sep 18, 2012 1:51 pm
Reply with quote

Hi Bill,

Sorry for wasting your time. The issue is resolved now.
Actually I did a silly mistake.

The mistake was in SYSIN card -

Code:
Wrong SYSIN card -

   IFTHEN=(WHEN=(8,1,CH,EQ,C','),                                     
     OVERLAY=(1:1,537,SQZ=(SHIFT=LEFT,PAIR=QUOTE)),HIT=NEXT),         
   IFTHEN=(WHEN=(8,1,CH,EQ,C','),                                     
     FINDREP=(IN=C'"',OUT=C''))                                       

Corrected SYSIN card -

   IFTHEN=(WHEN=(10,1,CH,EQ,C','),                                     
     OVERLAY=(1:1,537,SQZ=(SHIFT=LEFT,PAIR=QUOTE)),HIT=NEXT),         
   IFTHEN=(WHEN=(10,1,CH,EQ,C','),                                     
     FINDREP=(IN=C'"',OUT=C''))                                       


I forgot to add the extra double quotes length to starting position in when condition.

Thank you all for your replies.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Tue Sep 18, 2012 2:21 pm
Reply with quote

Silly mistakes are easily done - do 'em most days. Currently my silly mistakes are about 10 a day - cc/cc the lines I want to cut , forget to cut, paste the previous data. Duh!

Thanks for letting us know!
Back to top
View user's profile Send private message
Pratap Kapse

New User


Joined: 14 Sep 2012
Posts: 9
Location: India

PostPosted: Tue Sep 18, 2012 4:12 pm
Reply with quote

Hi Nic and Bill,

Everything is working fine but I am just curious about the JCL scan.

Why I am getting error - PARAMETER 'FINDREP' IS UNIDENTIFIED when I do Jclscan? And Job gets successfully executed and not giving JCL error?
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Tue Sep 18, 2012 4:23 pm
Reply with quote

Welcome to the holy-wolrd of "JCL-syntax-check-tools". JJ, JSCAN, JEM, JCK etc. all are different JCL-syntax check tools. Under the covers they do some 'checks' on JCL per the 'rules' written in them and at your shop FINDREP is not yet included in those rules.

Long story short -- JSCAN at your shop is not up-to-date to anticipate FINDREP yet. But when you SUBmit the Job, SORT knows the behavior of FINDREP and it does not complain you back.
Back to top
View user's profile Send private message
Pratap Kapse

New User


Joined: 14 Sep 2012
Posts: 9
Location: India

PostPosted: Tue Sep 18, 2012 4:55 pm
Reply with quote

Thank you Anuj.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Wed Sep 19, 2012 10:55 am
Reply with quote

You're welcome.
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts Remove leading zeroes SYNCSORT 4
No new posts leading spaces can be removed in trai... DFSORT/ICETOOL 1
No new posts Cobol program with sequence number ra... COBOL Programming 5
No new posts How to remove block of duplicates DFSORT/ICETOOL 8
Search our Forums:

Back to Top