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

How to truncate spaces in a CSV PS file using JCL/COBOL


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

New User


Joined: 28 Mar 2011
Posts: 12
Location: india

PostPosted: Mon Mar 28, 2011 8:24 pm
Reply with quote

Hello team,

I have a CSV file in which certain fields are populated as SPACES.
The seperator here is ';'----> semicolon

Name;Age;Address
John;25;Chicago
Mike;27;Denver
Abby;18;Ohio

In this file I populate the field values using an external DB2 call.
However sometimes my datbase contains spaces for a lot of fields.
Hence, the resultant file looks like this:

Name;Age;Place;.........
John; ;Chicago;........
;27;Denver;.......
Abby;18; ;........

Is there any way to truncate the unnecessary spaces in betwen the seperator ';' and generate the file as follows:

Name;Age;Place;.........
John;;Chicago;........
;27;Denver;.......
Abby;18;;........

Kindly help.
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Mon Mar 28, 2011 8:29 pm
Reply with quote

DB2 cannot directly generate CSV files, so why don't you do it in the program that actually retrieves the data from DB2 and writes out the CSV file?

Or am I too stupid to understand such a trivial problem?
Back to top
View user's profile Send private message
superman

New User


Joined: 28 Mar 2011
Posts: 12
Location: india

PostPosted: Mon Mar 28, 2011 8:41 pm
Reply with quote

Yes I am using a COBOL program for this.It fetches the values from DB2 table then writes it into a file.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Mon Mar 28, 2011 8:47 pm
Reply with quote

So, then, as Mr. Prins suggests you will want to modify that program, won't you?
Back to top
View user's profile Send private message
superman

New User


Joined: 28 Mar 2011
Posts: 12
Location: india

PostPosted: Mon Mar 28, 2011 8:55 pm
Reply with quote

Yes I know I can modify the cobol program use INSPECT clause etc fro truncating the spaces etc. but can this be doen with SORT /utility?
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Mon Mar 28, 2011 9:58 pm
Reply with quote

Ah, so you deliberately misstated the requirement in your thread title. Do you have any notion of what utilities are available at your site?
Back to top
View user's profile Send private message
superman

New User


Joined: 28 Mar 2011
Posts: 12
Location: india

PostPosted: Mon Mar 28, 2011 10:16 pm
Reply with quote

We tried using the following:

OPTION COPY
INREC OVERLAY=(1:1,4502,SQZ=(SHIFT=LEFT,MID=C' '),
1:1,4502,TRAN=LTOU)

However we don't want to loose the any spaces between the data(JOHN**MILLER must remain as it is and not become JOHN*MILLER) i.e we just need to truncate spaces between seperators(;) for our csv file.
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 FTP VB File from Mainframe retaining ... JCL & VSAM 1
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
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top