View previous topic :: View next topic
|
Author |
Message |
pramitmainframe2011
New User
Joined: 18 Nov 2011 Posts: 3 Location: india
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
pramitmainframe2011
New User
Joined: 18 Nov 2011 Posts: 3 Location: india
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
pramitmainframe2011
New User
Joined: 18 Nov 2011 Posts: 3 Location: india
|
|
|
|
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 |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Please review the following for FD enhancements -
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 |
|
|
Elixir
Active User
Joined: 08 Feb 2009 Posts: 116 Location: CHENNAI/NEW JERSEY - INDIA/USA
|
|
|
|
its better not to use ORGANIZATION with a flat file in assign |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
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 |
|
|
Elixir
Active User
Joined: 08 Feb 2009 Posts: 116 Location: CHENNAI/NEW JERSEY - INDIA/USA
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
|