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
 

 

Write VARIBLE BLOCK records but not getting expected format

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

New User


Joined: 18 Nov 2011
Posts: 3
Location: india

PostPosted: Fri Nov 18, 2011 9:28 pm    Post subject: Write VARIBLE BLOCK records but not getting expected format
Reply with quote

I have faced a problem reagading writing to a VARIBLE BLOCK file.
I have descrided the problem in details below.

This is a simple read and write program for a varible block but the output does not come at specified format.Indeed, I have not found any error.

The program is below mentioned and the output and input file is as below.

Code:
IDENTIFICATION DIVISION.                 
PROGRAM-ID.     FOLOWRT                 
AUTHOR.         PRAMIT.                 
DATE-WRITTEN.   NOV 2011.               
                                         
ENVIRONMENT DIVISION.                   
                                         
CONFIGURATION SECTION.                   
SOURCE-COMPUTER. IBM-3090.               
OBJECT-COMPUTER. IBM-3090.               
                                         
INPUT-OUTPUT SECTION.                   
FILE-CONTROL.                           
                                         
     SELECT INFILE                       
          ASSIGN           TO INFILE     
          ORGANIZATION     IS SEQUENTIAL
           ACCESS MODE      IS SEQUENTIAL.
      SELECT OUTFILE                       
           ASSIGN           TO OUTFILE     
           ORGANIZATION     IS SEQUENTIAL 
           ACCESS MODE      IS SEQUENTIAL.
                                           
*-----------------------------             
 DATA DIVISION.                           
 FILE SECTION.                             
                                           
                                           
 FD  INFILE                               
     RECORDING MODE IS V                   
     BLOCK CONTAINS 0 RECORDS             
     LABEL RECORDS STANDARD.               
 01  INFILE-RECORD.                       
    05 INFILE-TEXT       PIC   X(2204).   
FD  OUTFILE                                   
    RECORDING MODE IS V                       
    BLOCK CONTAINS 0 RECORDS                   
    LABEL RECORDS STANDARD.                   
01  OUTFILE-RECORD.                           
   05 OUTREC-TEXT       PIC   X(2204).         
                                               
WORKING-STORAGE SECTION.                       
01 I-EOF-TRUE           PIC 9(1)     VALUE 0. 
                                               
PROCEDURE DIVISION.                           
MAIN-LOGIC SECTION.                           
    OPEN INPUT INFILE.                         
    OPEN OUTPUT OUTFILE.                       
    PERFORM PROCESS-PARA THRU PROCESS-PARA-EXIT
                   UNTIL I-EOF-TRUE = 1.       
     CLOSE OUTFILE                             
    CLOSE INFILE.                             
     STOP RUN.                                 
 MAIN-LOGIC-EXIT.                             
     EXIT.                                     
 PROCESS-PARA.                                 
                 
     READ INFILE AT END MOVE 1 TO I-EOF-TRUE   
     END-READ.                                 
     IF I-EOF-TRUE = 0                         
        WRITE OUTFILE-RECORD FROM INFILE-RECORD
     END-IF.                                   
 PROCESS-PARA-EXIT.                           
     EXIT.     

The program sucessfully has complied and run but do not get the desired output .Please notice the problem.

Input read file:

Code:
    xyz       14/11/11       0965                                           
00500100000000217606#C#C#20100816#######000005#00581206800000000000#C#C#20020108#######000005#46##R#10000000#1#M#
OLG0004150020307#C#C#20030805#######000415

Output write file:
Code:

    xyz       14/11/11       0965  ] 00500100000000217606#C#C#20100
                                                                   
##000005#46##R#10000000#1#M#N#A##A#01482849342#Bruce##


Please notice that 00500100000000217606#C#C#20100816 is moving after the count(0965) but it should not be there.

For your kind reference i have defined both the files in JCL with the VB format.

Could you kindly suggest, how this issue can be resolved?
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Fri Nov 18, 2011 9:34 pm    Post subject:
Reply with quote

Quote:
Could you kindly suggest, how this issue can be resolved?
User education.

Specifically, you state in your post that these are VB files yet your COBOL code treats them as fixed length. I suspect you'll find 4 bytes between the 0965 and the 00500... and if you view those 4 bytes in hexadecimal, they will be an RDW.
Back to top
View user's profile Send private message
pramitmainframe2011

New User


Joined: 18 Nov 2011
Posts: 3
Location: india

PostPosted: Fri Nov 18, 2011 10:06 pm    Post subject:
Reply with quote

Robert Sample wrote:
Quote:
Could you kindly suggest, how this issue can be resolved?
User education.

Specifically, you state in your post that these are VB files yet your COBOL code treats them as fixed length. I suspect you'll find 4 bytes between the 0965 and the 00500... and if you view those 4 bytes in hexadecimal, they will be an RDW.


yes..so can you please tell what can i do if i want to treat them as variable length.Please give some sample codes.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Fri Nov 18, 2011 10:16 pm    Post subject:
Reply with quote

There's actually three ways that work:

1. add the RECORD IS VARYING clause to the FD, check the variable on input, and set it before output.
2. ensure the FD has an OCCURS DEPENDING ON (ODO) clause and set the ODO variable to the appropriate length.
3. have at least 2 01 levels under the FD with different lengths (many programmers use minimum and maximum length along with whatever is needed for the program being written).

Based upon what you show of the data, you should be using #1.
Back to top
View user's profile Send private message
pramitmainframe2011

New User


Joined: 18 Nov 2011
Posts: 3
Location: india

PostPosted: Fri Nov 18, 2011 10:25 pm    Post subject:
Reply with quote

Robert Sample wrote:
There's actually three ways that work:

1. add the RECORD IS VARYING clause to the FD, check the variable on input, and set it before output.
2. ensure the FD has an OCCURS DEPENDING ON (ODO) clause and set the ODO variable to the appropriate length.
3. have at least 2 01 levels under the FD with different lengths (many programmers use minimum and maximum length along with whatever is needed for the program being written).

Based upon what you show of the data, you should be using #1.


ok..thank u..I am now trying to implement it..
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Fri Nov 18, 2011 10:33 pm    Post subject: Reply to: Write VB records but not getting expected format
Reply with quote

Please review the following for FD enhancements -

http://www.ibmmainframes.com/viewtopic.php?p=127660&highlight=#127660

Although the above post is for READING, it can be easily adapted for both READING and WRITING as well.

Hint: You'll need WS length fields for both READING and WRITING, such as WS-IN-LGTH and WS-OUT-LGTH. Make sure they're UNSIGNED. When WRITING (after READING), move WS-IN-LGTH to WS-OUT-LGTH before issuing the WRITE.

Mr. Bill
Back to top
View user's profile Send private message
Elixir

Active User


Joined: 08 Feb 2009
Posts: 116
Location: CHENNAI/NEW JERSEY - INDIA/USA

PostPosted: Wed Dec 21, 2011 1:42 am    Post subject:
Reply with quote

its better not to use ORGANIZATION with a flat file in assign
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Wed Dec 21, 2011 4:16 pm    Post subject:
Reply with quote

What I know is that ORGANIZATION clause is an optional clause in the FILE-CONTROL paragraph and if you omit the ORGANIZATION clause, the compiler assumes ORGANIZATION IS SEQUENTIAL - I'm curious to know why do you say this:
Quote:
its better not to use ORGANIZATION with a flat file in assign
Back to top
View user's profile Send private message
Elixir

Active User


Joined: 08 Feb 2009
Posts: 116
Location: CHENNAI/NEW JERSEY - INDIA/USA

PostPosted: Wed Dec 21, 2011 9:22 pm    Post subject:
Reply with quote

Its a practice in our organization to avoid use of "ORGANIZATION IS" and "ACCESS MODE IS" clause for non-VSAM sequetial file, used only with VSAM files.

I never meant using these for a non-VSAM file is incorrect.

Was just a suggestion.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Wed Dec 21, 2011 9:46 pm    Post subject:
Reply with quote

Don't confuse the practice in YOUR organization with best practices. Unless you've worked for a number of different organizations, you may not even realize that what is done at your site is not standard. ORGANIZATION and ACCESS MODE IS may, in fact, be required for documentation purposes at some sites -- and for those sites, your advice would be completely and totally wrong.
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: Wed Dec 21, 2011 11:06 pm    Post subject:
Reply with quote

Hello,

Quote:
Its a practice in our organization
Which means it is probably not used most other places - making this not a good candidate for a "suggestion".

As that particular organization has beliefs that are contrary to the technical world elsewhere (i.e. from a different recent topic - x'00' is a NULL there), i have little faith in these suggestions.
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 Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Low values Results from VARCHAR FORMAT balaji81_k DB2 10 Thu Oct 20, 2016 1:18 am


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