View previous topic :: View next topic
|
Author |
Message |
sudhirk63
New User
Joined: 08 Oct 2006 Posts: 19 Location: Bangalore
|
|
|
|
Hello,
I have a very basic question.
I have an existing COBOL code which reads data from a VB file and writes the output to an FB file.
I have to modify the program to write to an VB file and not to an FB file.
I have changed the FD sections to indicate that the output file is VB.
The data is moved to the working storage varaible using MOVE and this variable is used to write to the output VB file.
The output VB file has unwanted spaces and I am not sure what else I am missing to resolve this issue.
Could some one suggest what am I missing in the code.
Thanks.
Sudhir |
|
Back to top |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
Sudhir,
Quote: |
I have changed the FD sections to indicate that the output file is VB.
The data is moved to the working storage varaible using MOVE and this variable is used to write to the output VB file. |
Post your FD (both I/P and O/P files) and Working storage declarations along with the MOVE statement.
Quote: |
The output VB file has unwanted spaces |
Did you check using HEX ON for 'spaces' (X'40')? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
If your FD has only one record layout and does not have an "occurs depending on" all of the records written will be "the length". There will be no variance in the record length.
If you post your code as suggested, we may be able to be more help. |
|
Back to top |
|
|
sudhirk63
New User
Joined: 08 Oct 2006 Posts: 19 Location: Bangalore
|
|
|
|
hi,
The FD section is as :
FD SPTNMSK-FILE
BLOCK CONTAINS 0 RECORDS
LABEL RECORDS ARE STANDARD
RECORDING MODE IS V
RECORD IS VARYING FROM 5 TO 4509 CHARACTERS
DEPENDING ON RECLENOUT1.
01 SPTNMSK-RECORD-AREA PIC X(4509).
01 SPTNMSK-RECORD-AREA-MIN PIC X(5).
In the code , the values are moves as :
MOVE RECORD-LENGTH-DS2-DS2-C3 TO RECLENOUT1
WRITE SPTNMSK-RECORD-AREA FROM NOTMASKEDREC
--
In the final output, I see spaces X'40' even after position as defined in variable RECORD-LENGTH-DS2-DS2-C3.
The variable RECORD-LENGTH-DS2-DS2-C3 is the length of the record. |
|
Back to top |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
Sudhir,
Is the posted FD for I/P or O/P file. Where is the other FD.
Quote: |
WRITE SPTNMSK-RECORD-AREA FROM NOTMASKEDREC |
What is NOTMASKEDREC? Whats it declaration?
Remeber we cant help you without proper details. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Code: |
FD SPTNMSK-FILE
BLOCK CONTAINS 0 RECORDS
LABEL RECORDS ARE STANDARD.
01 SPTNMSK-RECORD-AREA.
05 filler PIC X
occurs 4509 times
DEPENDING ON RECLENOUT1.
01 SPTNMSK-RECORD-AREA-MIN PIC X(5).
MOVE RECORD-LENGTH-DS2-DS2-C3 TO RECLENOUT1
WRITE SPTNMSK-RECORD-AREA FROM NOTMASKEDREC |
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Please re-read my previous reply.
The FD you posted does not contain an "OCCURS . . DEPENDING ON". To do what i believe you want, this will have to be in one or more of the level 01s. What the posted FD does will cause vb records to be created, but not the way you want them.
What you have defined will write either a 5-byte record or a 4509-byte record. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Sudhir,
How do you determine the value of RECORD-LENGTH-DS2-DS2-C3 ?
The code you provided should produce variable length recs if you filled RECORD-LENGTH-DS2-DS2-C3 properly.
You might want to put the ODO in the 01 as Bill suggested, but I think it will work w/o it.
Give it a try both ways and see what happens. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
I don't believe this will work:
Quote: |
RECORD IS VARYING FROM 5 TO 4509 CHARACTERS
DEPENDING ON RECLENOUT1.
01 SPTNMSK-RECORD-AREA PIC X(4509).
01 SPTNMSK-RECORD-AREA-MIN PIC X(5). |
The file will be vb but i believe the records will be the explicit length of the 01.
Using the ODO will produce the desired records. |
|
Back to top |
|
|
ajay_bhad
New User
Joined: 09 May 2007 Posts: 8 Location: Delhi
|
|
|
|
Quote: |
01 SPTNMSK-RECORD-AREA.
05 filler PIC X
occurs 4509 times
DEPENDING ON RECLENOUT1.
01 SPTNMSK-RECORD-AREA-MIN PIC X(5). |
If u code SPTNMSK-RECORD-AREA-MIN as level greater than 05 (eg 10 ) then i think it will be a VB. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
If u code SPTNMSK-RECORD-AREA-MIN as level greater than 05 (eg 10 ) then i think it will be a VB. |
This in incorrect. As coded, the file will be VB. Using a level of "greater than 05" makes no difference. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
In an earlier post I said that I didn't think that an ODO was required when defining an 01 level for a variable length record file:
Quote: |
You might want to put the ODO in the 01 as Bill suggested, but I think it will work w/o it. |
Well I finally got some time to test the theory and my hunch was correct: you don't need the ODO if you use the "DEPENDING ON" field of the VARYING clause in both the FDs. You can just WRITE the O/P FROM the I/P rec. this doesn't invalidate the ODO approach; it's just another way to do it.
I used FileAid to check the lengths of the records produced as O/P and they varied in length from 100 to 150 to 400 bytes as did the I/P file.
The code I tested with follows:
Code: |
IDENTIFICATION DIVISION.
PROGRAM-ID. VBTST.
*****************************************************************
*
* FUNCTION:
*
*****************************************************************
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT VBIN ASSIGN TO VBIN.
SELECT VBOT ASSIGN TO VBOT.
DATA DIVISION.
FILE SECTION.
*****************************************************************
FD VBIN
RECORD VARYING FROM 1 TO 400
DEPENDING ON WRK-LEN.
01 IN-REC PIC X(400).
FD VBOT
RECORD VARYING FROM 1 TO 400
DEPENDING ON WRK-LEN.
01 OT-REC PIC X(400).
*****************************************************************
WORKING-STORAGE SECTION.
*****************************************************************
01 WS-WORK-FIELDS.
05 WRK-LEN PIC 9(04).
05 IN-REC-CNT PIC 9(08) VALUE 0.
05 OT-REC-CNT PIC 9(08) VALUE 0.
05 IN-SW PIC X(01) VALUE 'N'.
88 IN-EOF VALUE 'E'.
1 /
*****************************************************************
PROCEDURE DIVISION.
*****************************************************************
0000-MAIN-ROUTINE.
*****************************************************************
PERFORM 8000-INIT
PERFORM 2000-PROC-IN 10 TIMES
DISPLAY ' '
DISPLAY 'VBTST - >' IN-REC-CNT '< RECS READ '
DISPLAY 'VBTST - >' OT-REC-CNT '< RECS WRITTEN'
CLOSE VBIN
VBOT
GOBACK
.
*****************************************************************
2000-PROC-IN.
*****************************************************************
PERFORM 7000-READ-IN
DISPLAY 'VBTST - IN REC LEN >' WRK-LEN '< '
PERFORM 7100-WRITE-OT
.
*****************************************************************
7000-READ-IN.
*****************************************************************
READ VBIN AT END
SET IN-EOF TO TRUE
NOT AT END
ADD +1 TO IN-REC-CNT
END-READ
.
*****************************************************************
7100-WRITE-OT.
*****************************************************************
WRITE OT-REC FROM IN-REC
ADD +1 TO OT-REC-CNT
.
*****************************************************************
8000-INIT.
*****************************************************************
OPEN INPUT VBIN
OPEN OUTPUT VBOT
.
*****************************************************************
************** END OF COBOL LISTING FOR VBTST **************
***************************************************************** |
|
|
Back to top |
|
|
|