AboutDavid Nelson Expertise I specialize in IBM z/OS COBOL and MicroFocus OCDS and Server Express
non-OOP. Design, coding and performance oriented questions. Also linking to
IBM Assembler from COBOL. Because the rules change with version, please
state language level, version and platform environment. See CICS for questions about CICS.
Experience
Past/Present clients Major Financial Institutions, State of NC (DHHS), Manufacturing, Financial services, Warehousing, Software developer and others.
Expert: David Nelson Date: 7/2/2008 Subject: line feed and carriage returns
Question QUESTION: I had a question about line feeds and carriage returns. I am trying to code a fixed length output file of 235 characters. Cobol automatically puts in a carriage return and line feed and I need my output file to be just a line feed. It needs to be in the unix format which excludes the carriage return. I put in PIC X VALUE '0A', but the only way this worked was to put it in char 235, but I need my file to be 235 not 236. Can you help me out?
ANSWER: COBOL is defined as automaticly being implementation compatible. This creates the problem you describe. You can change the file to not be a printer file and manually added the x'0A' at location 235. Remember, in COBOL, that the first position is 01 not 00. It will write fixed length records with your delimiter.
David
---------- FOLLOW-UP ----------
QUESTION: I tried that but my file needs to be 235 plus the LF. How do I manually add the x'0A'? My FD section looks like this:
FD MAILING-LABELS
RECORD CONTAINS 133 CHARACTERS.
01 MAILING-LABELS-REC PIC X(133).
My working storage section looks like this, but it doesn't work:
01 MAILING-LABELS-DETAIL.
05 PIC X(05) VALUE 'START'.
05 MLD-CONTRACT PIC X(10) VALUE SPACES.
05 MLD-FIRST PIC X(14) VALUE SPACES.
05 PIC X(93) VALUE SPACES.
05 PIC X(11) VALUE 'NEXT IS LR'.
05 LINE-FEED PIC X VALUE X'0A'.
It doesn't read LINE-FEED because it's the 134 character. Any help would be appreciated. Thanks.
Answer You need to define the file large enough to hold all the data you need to write. If you need to have the x'0a' as 236 you need to define the file that length and MOVE X'0A' to the 236th position.
You can not use literals in a FD record.
What you show is only 133 characters. That needs to be expanded.