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
 

 

modify COBOL code to write from FB to VB file

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

New User


Joined: 08 Oct 2006
Posts: 19
Location: Bangalore

PostPosted: Thu Nov 29, 2007 5:35 am    Post subject: modify COBOL code to write from FB to VB file
Reply with quote

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
View user's profile Send private message

murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1439
Location: Bangalore,India

PostPosted: Thu Nov 29, 2007 6:14 am    Post subject:
Reply with quote

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
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Thu Nov 29, 2007 7:48 am    Post subject:
Reply with quote

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
View user's profile Send private message
sudhirk63

New User


Joined: 08 Oct 2006
Posts: 19
Location: Bangalore

PostPosted: Thu Nov 29, 2007 8:04 am    Post subject: Reply to: modify COBOL code to write from FB to VB file
Reply with quote

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
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1439
Location: Bangalore,India

PostPosted: Thu Nov 29, 2007 8:49 am    Post subject:
Reply with quote

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
View user's profile Send private message
William Thompson

Global Moderator


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

PostPosted: Thu Nov 29, 2007 8:21 pm    Post subject: Re: Reply to: modify COBOL code to write from FB to VB file
Reply with quote

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
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Thu Nov 29, 2007 8:22 pm    Post subject:
Reply with quote

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
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Thu Nov 29, 2007 10:07 pm    Post subject:
Reply with quote

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
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Thu Nov 29, 2007 11:20 pm    Post subject:
Reply with quote

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
View user's profile Send private message
ajay_bhad

New User


Joined: 09 May 2007
Posts: 8
Location: Delhi

PostPosted: Sat Dec 01, 2007 9:38 pm    Post subject:
Reply with quote

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
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Sat Dec 01, 2007 9:42 pm    Post subject:
Reply with quote

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
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Wed Dec 05, 2007 1:24 am    Post subject:
Reply with quote

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
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
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm
No new posts Write out NODUPS but just from one file Jay Villaverde DFSORT/ICETOOL 8 Fri Jul 14, 2017 12:44 am
No new posts UNIT=AFF for Easytrieve code gandikk JCL & VSAM 7 Wed Jul 12, 2017 11:42 pm
No new posts XML Parse for COBOL 5.2 Bhanu Praveen COBOL Programming 1 Sat Jul 08, 2017 8:58 pm
No new posts How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm


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