Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Reading comma-delimited file in COBOL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
maddepusrikanth

New User


Joined: 29 Jul 2008
Posts: 4
Location: Bangalore ,INDIA

PostPosted: Thu Jul 31, 2008 5:07 pm    Post subject: Reading comma-delimited file in COBOL
Reply with quote

I want to read a comma-delimited file of length X(180) & write in into mainframs PS files ,so the Ps file will be input for other job .

Note :
1)the output PS file should consist of Header record &Trailer records

Trailer-ID, Number of records,total - debit amount, Total-credit amount for Trailer records.

2) in the O/PPS file there is a input

if a record is having 1100 in the file it should write as 183140 & soon

183140 comes from other input files .

thanks
Srikanth
Back to top
View user's profile Send private message

Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Thu Jul 31, 2008 5:24 pm    Post subject:
Reply with quote

It is possible to read a CSV file and reformat it to a fixed format file. It just takes a lot of scanning of the input file to find the field separators and moving an reformatting of the data to the desired format. I have done it many times. You just have to look at the input file and the desired output and work from there. NO I will not provide you with the code, my employer pays me for this work and doesn't like me giving it away.
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


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

PostPosted: Thu Jul 31, 2008 5:26 pm    Post subject:
Reply with quote

Hi,

So where are you stuck up and what does this mean:
Quote:
in the O/PPS file there is a input

if a record is having 1100 in the file it should write as 183140 & soon

183140 comes from other input files .
Show some example of input/output please.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Jul 31, 2008 5:29 pm    Post subject:
Reply with quote

i would utilize the UNSTRING instruction to identify each field, then as Craig said, work from there.
Back to top
View user's profile Send private message
maddepusrikanth

New User


Joined: 29 Jul 2008
Posts: 4
Location: Bangalore ,INDIA

PostPosted: Thu Jul 31, 2008 5:43 pm    Post subject: Reply to: Reading comma-delimited file in COBOL
Reply with quote

Hi,

i am looking for the code in COBOL for my release work.
Back to top
View user's profile Send private message
Suresh Ponnusamy

Active User


Joined: 22 Feb 2008
Posts: 107
Location: New York

PostPosted: Thu Jul 31, 2008 7:30 pm    Post subject:
Reply with quote

You can use either of the below method
1)
In a PERFORM UNTIL loop read the File record, you can read character by character from the File record and move the value to an array until you encounter a ',' , then move the array value to a variable.

or

2) As Dick mentioned, in PERFORM UNTIL LOOP read the File Record, use UNSTRING function on the File Record using ',' as a delimiter.

If you definitely know the size of the which holds the value of each comma separated then UNSTRING function is more effective. Otherwise you can use the first one.

Suggestions are Welcome as always.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Jul 31, 2008 8:39 pm    Post subject:
Reply with quote

Hello,

Quote:
i am looking for the code in COBOL for my release work.
You need to create some code and post back here when you have questons or problems. Someone will be able to help.

I'd suggest you try UNSTRING. If you are not familiar with UNSTRING, click on the "IBM Manuals" link at the top of the page and select the documentation for "your" version of COBOL.
Back to top
View user's profile Send private message
maddepusrikanth

New User


Joined: 29 Jul 2008
Posts: 4
Location: Bangalore ,INDIA

PostPosted: Sun Aug 10, 2008 4:17 pm    Post subject: Reply to: Reading comma-delimited file in COBOL
Reply with quote

Hi ,

Please let me know any updates

Sri
icon_cry.gif
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Sun Aug 10, 2008 4:40 pm    Post subject: Reply to: Reading comma-delimited file in COBOL
Reply with quote

there will not be any upates until You produce some code Yourself,
You got enough hints to start writing icon_smile.gif
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Aug 11, 2008 1:34 am    Post subject:
Reply with quote

Hello,

Quote:
Please let me know any updates
We are waiting for you to provide something for us to work with. . .

Quote:
i am looking for the code in COBOL for my release work.
When you provide what code you have written, someone should be able to answer any questions you have or explain why it does not work.

If you are not able to code everything yet, explain why not. If you clearly explain where there is confusion getting what you need to do, you will see that you have given yourself a start on the code. Describing a task usually helps with the solution.
Back to top
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 743
Location: Germany

PostPosted: Mon Aug 11, 2008 8:42 pm    Post subject:
Reply with quote

>> i am looking for the code in COBOL for my release work.


Ok, i am looking forward to receive the purchase for that.
Then you will receive the pre-release code.
Back to top
View user's profile Send private message
maddepusrikanth

New User


Joined: 29 Jul 2008
Posts: 4
Location: Bangalore ,INDIA

PostPosted: Sun Aug 17, 2008 11:10 am    Post subject:
Reply with quote

Hi All,

At last i completed the codeing.it has moved to production now & working fine

thanks for your help

Thanks
SK
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


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

PostPosted: Mon Aug 18, 2008 11:12 am    Post subject:
Reply with quote

Hi,

Nice to hear, hopefully we had been helpful.. icon_smile.gif

- Ad
Back to top
View user's profile Send private message
Escapa

Senior Member


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

PostPosted: Mon Aug 18, 2008 12:16 pm    Post subject:
Reply with quote

Hi,
Good to see that your problem has sorted out.

i can think of one more solution if this program is running in batch.

if you know you can submit jcl from cobol program by coding
//ddname DD SYSOUT=(*,INTRDR)
in the jcl which is calling your cobol program.


on ddname you can write jcl statements
which calls iceman
where
sortin tells how you want to parse the file
something like
//SYSIN DD *
SORT FIELDS=COPY
INREC PARSE=(FLD0=(FIXLEN=4,ENDBEFR=DELI),
FLD1=(FIXLEN=5,ENDBEFR=DELI),
FLD2=(FIXLEN=30,ENDBEFR=DELI),
FLD3=(FIXLEN=2,ENDBEFR=DELI),
FLD4=(FIXLEN=30,ENDBEFR=DELI),
FLD5=(FIXLEN=10,ENDBEFR=DELI)),
BUILD=(FLD0,FLD1,JFY=(SHIFT=LEFT),FLD2,FLD3,FLD4)
/*

sortin and sortout will be input and output dsns
symnames will be symbolic names
something like
//SYMNAMES DD *
FLD0,%00
FLD1,%01
FLD2,%02
FLD3,%03
FLD4,%04
FLD5,%05
DELI,','
/*
Back to top
View user's profile Send private message
Escapa

Senior Member


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

PostPosted: Mon Aug 18, 2008 12:18 pm    Post subject:
Reply with quote

also if you are calling this program only for parsing it then better option is to call iceman directly from jcl as prev step instead of doing it in cobol program it is more efficient.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us