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

How do we handle the carriage return in the cobol program


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
patriot

New User


Joined: 01 Dec 2006
Posts: 8
Location: chennai

PostPosted: Thu Feb 01, 2007 5:11 pm
Reply with quote

How do we handle the carriage return in the cobol program.
Ex: If we get a carriage return in the file, some functionality is being done.
what is the cobol equivalent value for carriage return. I should use this in an IF condition. How do we handle this?
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Thu Feb 01, 2007 5:21 pm
Reply with quote

patriot wrote:
How do we handle the carriage return in the cobol program.
Ex: If we get a carriage return in the file, some functionality is being done.
what is the cobol equivalent value for carriage return. I should use this in an IF condition. How do we handle this?
Are you parsing thru this file byte by byte or is there a field that you are inspecting?
Back to top
View user's profile Send private message
patriot

New User


Joined: 01 Dec 2006
Posts: 8
Location: chennai

PostPosted: Thu Feb 01, 2007 6:29 pm
Reply with quote

Carriage return comes in field and that has to be inspected.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Thu Feb 01, 2007 6:52 pm
Reply with quote

EBCDIC CR is usually a X'0D', does that help?
Back to top
View user's profile Send private message
Magna

New User


Joined: 30 Oct 2006
Posts: 24

PostPosted: Thu Feb 01, 2007 6:55 pm
Reply with quote

I was using something like
05 WS-LIT-ENTER-N PIC S9(9) COMP VALUE +3365.
05 FILLER REDEFINES WS-LIT-ENTER-N.
10 FILLER PIC XX.
10 WS-LIT-ENTER PIC XX.

for identifying the Carriage return. But couldn't use this WS-LIT-ENTER in INSPECT.
When I tried parsing that field byte by byte and comparing each byte with that WS-LIT-ENTER also am not able to make it.

Could some one suggest us how to fix this.
Me and patriot were working on this for a long time but couldn't fix it...

Thanks!!
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Thu Feb 01, 2007 7:35 pm
Reply with quote

Magna wrote:
I was using something like
Code:
05 WS-LIT-ENTER-N          PIC S9(9) COMP VALUE +3365.
05 FILLER  REDEFINES  WS-LIT-ENTER-N.
          10 FILLER            PIC XX.
          10 WS-LIT-ENTER      PIC XX.

for identifying the Carriage return. But couldn't use this WS-LIT-ENTER in INSPECT.
When I tried parsing that field byte by byte and comparing each byte with that WS-LIT-ENTER also am not able to make it.

Could some one suggest us how to fix this.
Me and patriot were working on this for a long time but couldn't fix it...
The 3365 is CR/LF, X'0D25'. what does the field in the file look like, what is its PIC?
Back to top
View user's profile Send private message
Magna

New User


Joined: 30 Oct 2006
Posts: 24

PostPosted: Thu Feb 01, 2007 8:13 pm
Reply with quote

The fileds PIC is x(40).
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Thu Feb 01, 2007 8:34 pm
Reply with quote

So you are trying to scan the 40 bytes looking for a CR/LF combination or just one or the other?
Once found, what are you going to do with it?
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 Feb 01, 2007 9:39 pm
Reply with quote

Hello,

How many fields follow the 40-byte field that has the cr/lf?

Open your file with the embedded cr/lf in tso/browse. Then set HEX ON. This will make the data easier for you to view.

If the last thing in a record is the cr/lf it can most likely be ignored. If there are fields after the cr/lf, you will need to decide what action is necessary.

What kind of data is this? Is it typed text or is it some number of fields that will line up and be an input file for some process? Please post a couple of your records indicating where the cr/lf combination is and what you want to do with the records on the mainframe.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Thu Feb 01, 2007 9:51 pm
Reply with quote

Some versions of COBOL support the definition:
Code:
01  WS-CR     PIC X    VALUE X'0D'.
Back to top
View user's profile Send private message
Magna

New User


Joined: 30 Oct 2006
Posts: 24

PostPosted: Thu Feb 01, 2007 10:01 pm
Reply with quote

Well, I'll be verifying for the CR/LF in my 40 bytes field.
In the file if there is a CR/LF the record continuing that field is moved to the next line.
So I need to find the carriage return in the 40 byte field and have to populate a space in that place and get the remaining records from the next line of the file and concatenate and populate it to my o/p file.
I'll be processing the o/p file for loading the table.
The 40 byte field is a Address field.
So I might have numbers or Characters or symbols like ',*,<,>,....
anything like this.

For an example the contents will be like this:
2, Broadway Th road 3/4 aaaaaa(CR and no more fields after this)
bbbbbbbbbbbbbbbbbbbb(rest of the record)
and when i checked the HEX equiv value in the file has the same value as space.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Thu Feb 01, 2007 10:22 pm
Reply with quote

Inspect 40byte converting x'0d25' to spaces
that will convert all x'0d's and all x'25's that occur in the record with blanks. Is that what you want?
Unstring 40byte into recievingarea delimited by x'0d25'
would also work.
This is your input?
Quote:
2, Broadway Th road 3/4 aaaaaa(CR and no more fields after this)bbbbbbbbbbbbbbbbbbbb(rest of the record)
And this is your output?
Quote:
2, Broadway Th road 3/4 aaaaaabbbbbbbbbbbbbbbbbbbbbb(rest of the record)
Back to top
View user's profile Send private message
Magna

New User


Joined: 30 Oct 2006
Posts: 24

PostPosted: Thu Feb 01, 2007 10:45 pm
Reply with quote

How should I code the INSPECT stmt if i also want to know the position where I actually find the CR/LF...
I'm asking this because i need to concatenate the remaining part of the record ( that is in the next line ) after that position to get the complete record.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Thu Feb 01, 2007 11:03 pm
Reply with quote

Not real easily, that would be more like inspect tallying all before initial CR/LF, and then you would replace it.
count=0
inspect 40byte tallying count for characters before initial x'0d'
move spaces to 40byte(count+1:2)
move next40 to 40byte(count+1+?:40)
I think that's what direction you are going....
Why not just string the multiple 40 byte records int your output?
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 Feb 01, 2007 11:34 pm
Reply with quote

Hello,

When you say
Quote:
For an example the contents will be like this:
2, Broadway Th road 3/4 aaaaaa(CR and no more fields after this)
bbbbbbbbbbbbbbbbbbbb(rest of the record)
and when i checked the HEX equiv value in the file has the same value as space.

are you saying that when you browse the record there is a hex'40' after the aaaaaa and that there is no more data in that record?

If so, where is the cr/lf? Keep in mind for an embedded cr/lf they will take up 2 bytes.

What should happen if there is a cr/lf after the bbbbbbbbbb data?

Please post a few records (in hex) showing the data you are working with. We will be much more able to help if we can better see the situation.
Back to top
View user's profile Send private message
Magna

New User


Joined: 30 Oct 2006
Posts: 24

PostPosted: Fri Feb 02, 2007 9:44 am
Reply with quote

File Record length : 250

This is how my file is

POLYESTER SLEEVING 3/4"
DDDECEECD4EDCCECDC4F6F744444444444444444444444444
7638523590235559570314F00000000000000000000000000

The below is the continuation of the above specified record

N 05/16/200305/16/2063ANIXTER KC
D4444444444444444444FF6FF6FFFFFF6FF6FFFFCDCEECD4DC44444444444444444444444444444444444
5000000000000000000005116120030511612063159735902300000000000000000000000000000000000

The 'ANIXTER KC' is the end of record actually. It got splitted into two.

What I need is After the POLYESTER SLEVING 3/4", one space, and the next line should continue.
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: Fri Feb 02, 2007 10:02 am
Reply with quote

Hello,

I shifted your posted data into "code" so it would line up (see below). Please note that the lines are not in sync. In browse, the system would not display the second "line" the way it is here - the bytes do not line up. You posted that the length is 250, but what we have here is far less.

Code:

POLYESTER SLEEVING 3/4"
DDDECEECD4EDCCECDC4F6F744444444444444444444444444
7638523590235559570314F00000000000000000000000000


Code:

N 05/16/200305/16/2063ANIXTER KC
D4444444444444444444FF6FF6FFFFFF6FF6FFFFCDCEECD4DC44444444444444444444444444444444444
5000000000000000000005116120030511612063159735902300000000000000000000000000000000000


Looking at the data provided, i do not see any cr/lf.

How did this data get to your mainframe? Is it now in a qsam file? Please look at the file in tso 3.2 and post the file attributes.

If you can get a few records (copy the 2 records before these and the 2 after to another file) downloaded and attach them as a text file i can look at that. I'll upload them to my system to look at.
Back to top
View user's profile Send private message
Magna

New User


Joined: 30 Oct 2006
Posts: 24

PostPosted: Fri Feb 02, 2007 11:00 pm
Reply with quote

Hi friends Thanks.. It worked.
The issue is fixed. But there is one more value which we found in the file which had a hexa value of '25' what is it?
It is displayed a dark vertical thick line when we download it to a text file.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Sat Feb 03, 2007 1:06 am
Reply with quote

Magna wrote:
Hi friends Thanks.. It worked.
The issue is fixed. But there is one more value which we found in the file which had a hexa value of '25' what is it?
It is displayed a dark vertical thick line when we download it to a text file.
the hex 25 is the LF or Line Feed....
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Sat Feb 03, 2007 1:42 am
Reply with quote

I've been following this post since its inception, and I must admit that the original concept of what was asked has had me stumped from the beginning. I'm not aware of any such concept as a "carriage-return" in the world of EBCDIC data, and, looking at the final postings, wasn't this just a simple case of multiple data records that needed to be spliced together into a single record (something that DFSORT could've easily handled)?
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: Sat Feb 03, 2007 1:52 am
Reply with quote

Possibly. . . .

From the lack of data, i was never sure i knew where the "break" was or if one eventual record could be "broken" in multiple places in the input.

Be interesting to learn what actually "fixed" this. icon_confused.gif
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Sat Feb 03, 2007 2:06 am
Reply with quote

The first couple of times I read the post, I thought it was talking about handling "carriage control", and I couldn't for the life of me figure out why that would pose a problem.
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: Sat Feb 03, 2007 2:18 am
Reply with quote

Yup,

My first thought reading the initial post was that the cr/lf was coming in as data and the new output needed to be positioned accordingly by the program.
Back to top
View user's profile Send private message
rahul_krg

New User


Joined: 08 Aug 2007
Posts: 7
Location: India

PostPosted: Fri Mar 14, 2008 6:28 pm
Reply with quote

Hi All,

After searching for the handling of CR/LF characters in EBCDIC characters, I came through this thread. I'm facing the same problem of getting the output record splitting in number of records depending upon the occurances of CR code (X'0D') in the file. This CR character will not be there in the final output in the file, but it was part of the record written to file. I've observed that if there are 3 CRs in the record, it gets splitted in 3 individual records.

Please help in decoding this problem of handling CR in Mainframe. I'm using ZFile to generate MVS datasets through JAVA program. My record contains some COMP field.

RG
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: Fri Mar 14, 2008 10:28 pm
Reply with quote

Hello,

Quote:
I'm using ZFile to generate MVS datasets through JAVA program. My record contains some COMP field.
What are the definition & attributes for the "MVS datasets"? Please post a few examples of these "COMP" fields.

Quote:
I've observed that if there are 3 CRs in the record, it gets splitted in 3 individual records
This is normal. I'd suggest correcting the process that creates the file to only create 1 CR per record.
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 Goto page 1, 2  Next

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 2
No new posts Using API Gateway from CICS program CICS 0
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
Search our Forums:

Back to Top