Rakesh
Francois is right about Decimal 28 being %34.
I compiled and ran your sample, and it works.
There are some problems, like having to enter the full 7 digit number,
and some logic around ending the program, but the delimiters (1C) are in
the output file :)
Also, it didn't like LINE Sequential, so I took it out.
Regards
Neil
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLOWORLD.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT StudentFile ASSIGN TO "STUDENTS"
ORGANIZATION IS SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD StudentFile.
01 StudentDetails.
02 StudentId PIC 9(7).
02 DELIM1 PIC X.
02 StudentName.
03 Surname PIC X(8).
03 Initials PIC XX.
02 DELIM2 PIC X.
02 Gender PIC X.
WORKING-STORAGE SECTION.
01 MStudentDetails.
02 MStudentId PIC 9(7).
02 MDELIM1 PIC 9 VALUE %34.
02 MStudentName.
03 MSurname PIC X(8).
03 MInitials PIC XX.
02 MDELIM2 PIC 9 VALUE %34.
02 MGender PIC X.
PROCEDURE DIVISION.
BEGIN.
OPEN OUTPUT StudentFile
DISPLAY "Enter student details using temp below"
PERFORM GetStudentDetails
PERFORM UNTIL MStudentID = 0
MOVE MSTUDENTDETAILS TO STUDENTDETAILS
WRITE STUDENTDETAILS
PERFORM GetStudentDetails
END-PERFORM
CLOSE StudentFile
STOP RUN.
GetStudentDetails.
DISPLAY "ENTER STU ID ".
ACCEPT MSTUDENTID.
DISPLAY "ENTER STUDENT NAME."
ACCEPT MSTUDENTNAME.
DISPLAY "ENTER GENDER"
ACCEPT MGENDER.
/xeq delim.cobx
Enter student details using temp below
ENTER STU ID
0000001
ENTER STUDENT NAME.
Neil
ENTER GENDER
M
ENTER STU ID
0000002
ENTER STUDENT NAME.
Karin
ENTER GENDER
F
ENTER STU ID
0000000
ENTER STUDENT NAME.
ENTER GENDER
:listftemp STUDENTS,2
FILENAME CODE ------------LOGICAL RECORD----------- ----SPACE----
SIZE TYP EOF LIMIT R/B SECTORS #X MX
STUDENTS 20B FA 2 10000 12 256 1 *
(TEMP)
/hex students
STUDENTS RECORD 0 (%0, #0)
0000: 3030 3030 3030 311C 4E65 696C 0000 0000 0000001.Neil....
0008: 0000 1C4D ...M
STUDENTS RECORD 1 (%1, #1)
0000: 3030 3030 3030 321C 4B61 7269 6E00 0000 0000002.Karin...
0008: 0000 1C46 ...F
EOF FOUND IN FROMFILE AFTER RECORD 1
2 RECORDS PROCESSED *** 0 ERRORS
-----Original Message-----
From: HP-3000 Systems Discussion [mailto:[log in to unmask]] On
Behalf Of Francois Desrochers
Sent: 22 February 2006 15:54
To: [log in to unmask]
Subject: Re: Regarding decimal 28 as delimiter.
Rakesh,
Two things:
- I think you should define MDELIM1 and MDELIM2 as PIC X, not PIC 9.
- Decimal 28 is %34, not %35.
The Cobol compiler may be changing %34 to the decimal equivalent and =
then assigning it to the variables. This would be similar to
05 MDELIM1 PIC 9 VALUE 28.
You probably can see where this may lead to problems. I'm curious. What
= do you see in the current program. Would you happen to see the number
= "8" ("9" in your case since you incorrectly used %35) where you would
= expect the delimiter?
Fran=E7ois
-----Original Message-----
From: HP-3000 Systems Discussion [mailto:[log in to unmask]] On =
Behalf Of Rakesh Kumar Velchuri
Sent: Wednesday, February 22, 2006 8:34 AM
To: [log in to unmask]
Subject: [HP3000-L] Regarding decimal 28 as delimiter.
Please look at the code that we have written t =A0 Hello Sir/Madam,
Please look at the code that we have written to include decimal 28 as =
one of the delimiter that separates the data in a file. We were not able
= to get the character plugged in the output file (as was desired). Can
= you please look at the code and tell us as to where we are going
wrong.
Thanks in advance for your help.
We have have used %35 as deimal 28.
Sample Code
-------------------------------------------------------------------
=20
IDENTIFICATION DIVISION. =20
PROGRAM-ID. HELLOWORLD. =20
=20
=20
ENVIRONMENT DIVISION. =20
INPUT-OUTPUT SECTION. =20
FILE-CONTROL. =20
SELECT StudentFile ASSIGN TO "STUDENTS" =20
ORGANIZATION IS LINE SEQUENTIAL. =20
=20
DATA DIVISION. =20
FILE SECTION. =20
FD StudentFile. =20
01 StudentDetails. =20
02 StudentId PIC 9(7). =20
02 DELIM1 PIC X. =20
02 StudentName. =20
03 Surname PIC X(8). =20
03 Initials PIC XX. =20
02 DELIM2 PIC X. =20
02 Gender PIC X. =20
WORKING-STORAGE SECTION. =20
01 MStudentDetails. =20
02 MStudentId PIC 9(7). =20
02 MDELIM1 PIC 9 VALUE %35. =20
02 MStudentName. =20
03 MSurname PIC X(8). =20
03 MInitials PIC XX. =20
02 MDELIM2 PIC 9 VALUE %35. =20
02 MGender PIC X. =20
=20
=20
=20
PROCEDURE DIVISION. =20
BEGIN. =20
OPEN OUTPUT StudentFile =20
DISPLAY "Enter student details using temp below"=20
PERFORM GetStudentDetails =20
PERFORM UNTIL MStudentID =3D 0 =20
MOVE MSTUDENTDETAILS TO STUDENTDETAILS =20
WRITE STUDENTDETAILS =20
PERFORM GetStudentDetails =20
END-PERFORM =20
CLOSE StudentFile =20
STOP RUN. =20
GetStudentDetails. =20
DISPLAY "ENTER STU ID ". =20
ACCEPT MSTUDENTID. =20
DISPLAY "ENTER STUDENT NAME." =20
ACCEPT MSTUDENTNAME. =20
DISPLAY "ENTER GENDER" =20
ACCEPT MGENDER. =20
Rakesh Kumar Velchuri(Rox)
Assistant System Engineer (Trainee)
Tata Consultancy Serices
HP Centre,
Chennai,India.
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
|