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

Reading comma-delimited file in COBOL


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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

Superior Member


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

PostPosted: Thu Jul 31, 2008 5:26 pm
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
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
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
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

Moderator Emeritus


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

PostPosted: Thu Jul 31, 2008 8:39 pm
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Sun Aug 10, 2008 4:40 pm
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

Moderator Emeritus


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

PostPosted: Mon Aug 11, 2008 1:34 am
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: 771
Location: Germany

PostPosted: Mon Aug 11, 2008 8:42 pm
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
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

Superior Member


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

PostPosted: Mon Aug 18, 2008 11:12 am
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 7
No new posts Replace each space in cobol string wi... COBOL Programming 2
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top