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

Including a linefeed in every write statement


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

Active Member


Joined: 23 Aug 2005
Posts: 677
Location: NJ

PostPosted: Wed Jun 14, 2006 2:27 pm
Reply with quote

Hi all,
Please view the below code , Question stated below the code :

Code:
 IDENTIFICATION DIVISION.
        PROGRAM-ID. FILEKEY.
        ENVIRONMENT DIVISION.
        INPUT-OUTPUT SECTION.
        FILE-CONTROL.
            SELECT EMP-FILE
               ASSIGN TO "sample.dat"
               ORGANIZATION IS RELATIVE
               ACCESS MODE IS RANDOM
               RELATIVE KEY IS EMPNO
               FILE STATUS IS FS.
        DATA DIVISION.
        FILE SECTION.
        FD EMP-FILE.
        01 EMP-DET.
           05 EMPNO PIC 999.
           05 EMPNAME PIC X(30).
           05 EMPADD PIC X(10).
        WORKING-STORAGE SECTION.
        01 FS PIC X(2).
        01 CHO PIC X.
        PROCEDURE DIVISION.
        PARA1.
            OPEN I-O EMP-FILE.
            PERFORM WRT UNTIL CHO = 'N'.
            STOP RUN.
        WRT.

            DISPLAY "ENTER EMPLOYEE NO : ".
            ACCEPT EMPNO.
            DISPLAY "ENTER EMPLOYEE NAME : ".
            ACCEPT EMPNAME.
            DISPLAY "ENTER EMPLOYEE ADDRESS : ".
            ACCEPT EMPADD.
            WRITE EMP-DET
               INVALID KEY DISPLAY "FILE STATUS : " FS
            END-WRITE.
            DISPLAY "DO YOU WANT TO CONTINUE (Y/N)? ".
            ACCEPT CHO.


output should be :
Eno Ename Location
------------------------------------------
002BABU CHENNAI
003PATSE UKL
004KUMAR CBE


Question :

When i enter the values in the Prompt it is written in a single line.
ie.,002 BABU CHENNAI 003 PATSE UKL ,,,,,,

like this. So i need in the above format.. ie., simply one linefeed should be included in every write statement. I cannot find out the reson. plz gothru the code and let me know the answer for my query....
Back to top
View user's profile Send private message
prasadvrk

Active User


Joined: 31 May 2006
Posts: 200
Location: Netherlands

PostPosted: Thu Jun 15, 2006 3:41 pm
Reply with quote

After each record you should have a line break but I do not know which ascii char could be used to achieve this.
Back to top
View user's profile Send private message
parikshit123

Active User


Joined: 01 Jul 2005
Posts: 269
Location: India

PostPosted: Thu Jun 15, 2006 4:19 pm
Reply with quote

Hi,

Your logic seems fine. Only thing that since you are using relative file,
Secondly, you seems to be using DOS/WINDOWS. right?
So, when you open your file using notepad or other editor, you won't find the linefeed.

Had it been a line sequential file, you would have got the linefeed.

[/code][/quote]
Back to top
View user's profile Send private message
khamarutheen

Active Member


Joined: 23 Aug 2005
Posts: 677
Location: NJ

PostPosted: Thu Jun 15, 2006 9:43 pm
Reply with quote

Parikshit,

Thank you for your clarification , Yes i m using DOS type compilation only. It's a small program with files. just i checked that's it. but i found the difference i need to insert line feed. but i can't... If you have any more idea on the same file format plz let me know.
Back to top
View user's profile Send private message
nema_gourav
Currently Banned

New User


Joined: 17 Nov 2005
Posts: 1
Location: pune

PostPosted: Tue Jan 23, 2007 10:53 am
Reply with quote

IS COBOL allows an statement before IDENTIFICATION DIVISION and if Yes what type of Statements are those, and how they can be implemented.

Please i need this query to be answer..

Give some suggestions on this.

Gourav
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: Tue Jan 23, 2007 7:19 pm
Reply with quote

Hello,

Try "writing" the output as a print file (i.e. BEFORE ADVANCING 1 LINE).
Back to top
View user's profile Send private message
William Thompson

Global Moderator


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

PostPosted: Tue Jan 23, 2007 7:23 pm
Reply with quote

nema_gourav wrote:
IS COBOL allows an statement before IDENTIFICATION DIVISION and if Yes what type of Statements are those
Quote:
CBL (PROCESS) statement
*CONTROL (*CBL) statement
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: Tue Jan 23, 2007 7:23 pm
Reply with quote

Hello again,

You could also embed the hex value as the last character in the data written - it will be a value less than ascii hex'20' - if memory serves it will be x'0a', x'0d', or x'09' - one of those is the tab char and i believe the others are CR and LF - you should be able to check in your Fine Manuals.
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 Write line by line from two files DFSORT/ICETOOL 7
This topic is locked: you cannot edit posts or make replies. How To Write, Compile and Execute Cob... COBOL Programming 5
No new posts Compare two files with a key and writ... SYNCSORT 3
No new posts JOIN STATEMENT PERFORMANCE. DFSORT/ICETOOL 12
No new posts JCL to write the log on to a PDS file JCL & VSAM 10
Search our Forums:

Back to Top