View previous topic :: View next topic
|
Author |
Message |
khamarutheen
Active Member
Joined: 23 Aug 2005 Posts: 677 Location: NJ
|
|
|
|
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 |
|
|
prasadvrk
Active User
Joined: 31 May 2006 Posts: 200 Location: Netherlands
|
|
|
|
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 |
|
|
parikshit123
Active User
Joined: 01 Jul 2005 Posts: 269 Location: India
|
|
|
|
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 |
|
|
khamarutheen
Active Member
Joined: 23 Aug 2005 Posts: 677 Location: NJ
|
|
|
|
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 |
|
|
nema_gourav Currently Banned New User
Joined: 17 Nov 2005 Posts: 1 Location: pune
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Try "writing" the output as a print file (i.e. BEFORE ADVANCING 1 LINE). |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
|