View previous topic :: View next topic
|
Author |
Message |
mohitsaini Warnings : 1 New User
Joined: 15 May 2006 Posts: 92
|
|
|
|
Hi there,
In my Cobol program, I am having a layout (copybook) for an output file. Now many fields in that copybook are hardcoded with some value as shown in the snippet below.
Now when I initialize the copybook then all the hardcoded fields are also intialized. However, what I require is that all the fields with VALUE should not be intialized and others should. Actually this output layout is very big and that's why individually intializing fields is quite a big task. Is there any COBOL syntax via which I can initialize the entire copybook except for fields with VALUE?
Code: |
03 PG-MC-CB-TEX5.
05 FILLER PIC X(06) VALUE ':TTYP='.
05 PG-MC-CB-TEXT5 PIC X(06) VALUE SPACES.
05 FILLER PIC X(60) VALUE SPACES.
03 PG-MC-CB-TEX6.
05 FILLER PIC X(05) VALUE ':TDT='.
05 PG-MC-CB-TEXT6 PIC X(09) VALUE SPACES.
05 FILLER PIC X(58) VALUE SPACES.
03 PG-MC-CB-TEX7.
05 FILLER PIC X(06) VALUE ':CPDT='.
05 PG-MC-CB-TEXT7 PIC X(09) VALUE SPACES. |
[/code] |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
Elemetary FILLER data items are NOT initialized according to the Language Reference Manual. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3053 Location: NYC,USA
|
|
|
|
Always keep an eye out for fields under a REDEFINES. INITIALIZE will not look at these fields when it initializes the underlying storage. It will use the original definition - not the REDEFINED definition.
e.g.
Code: |
IDENTIFICATION DIVISION.
PROGRAM-ID. STUFF.
* Test various cobol functions
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
DATA DIVISION.
WORKING-STORAGE SECTION.
*
01 REC-BUFF.
03 RB1 PIC X(04) VALUE “ABCD”.
03 PIC X(02) VALUE “ZZ”.
03 FILLER PIC X(03) VALUE “QQQ”.
03 RB2 PIC 9(04) VALUE 1234.
03 PIC 9(02) VALUE 99.
03 FILLER PIC 9(03) VALUE 777.
*
PROCEDURE DIVISION.
*
A1000-INIT.
DISPLAY ‘[‘ REC-BUFF ‘]’.
INITIALIZE REC-BUFF.
DISPLAY ‘[‘ REC-BUFF ‘]’.
MOVE SPACES TO REC-BUFF.
DISPLAY ‘[‘ REC-BUFF ‘]’.
INITIALIZE REC-BUFF.
DISPLAY ‘[‘ REC-BUFF ‘]’.
STOP RUN.
Output:
[ABCDZZQQQ123499777]
[ ZZQQQ000099777]
[ ]
[ 0000 ] |
|
|
Back to top |
|
|
|