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
 

 

Including a linefeed in every write statement

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

Active Member


Joined: 23 Aug 2005
Posts: 680
Location: NJ

PostPosted: Wed Jun 14, 2006 2:27 pm    Post subject: Including a linefeed in every write statement
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    Post subject:
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    Post subject:
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: 680
Location: NJ

PostPosted: Thu Jun 15, 2006 9:43 pm    Post subject: Cobol Program Doubt
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    Post subject:
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

Site Director


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

PostPosted: Tue Jan 23, 2007 7:19 pm    Post subject:
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: 3158
Location: Tucson AZ

PostPosted: Tue Jan 23, 2007 7:23 pm    Post subject:
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

Site Director


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

PostPosted: Tue Jan 23, 2007 7:23 pm    Post subject:
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    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 Write R1 and R2 to OP1 and R1 to OP2 bhaskar_kanteti DFSORT/ICETOOL 10 Fri Mar 03, 2017 11:18 am
No new posts Can you write 2 recs on SORTOUT when ... Sysaron DFSORT/ICETOOL 6 Thu Feb 23, 2017 12:07 am
No new posts ROUNDED Problem with COMPUTE statement shalem COBOL Programming 11 Thu Feb 09, 2017 8:16 pm
No new posts VALIDATE NULL VALUE IN DB2 CASE STATE... useit DB2 5 Thu Feb 09, 2017 4:34 pm
No new posts -913/-911 Deadlock during UPDATE stat... NoSleep319 DB2 5 Fri Nov 18, 2016 12:37 am


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