IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

partially intializing values from a layout


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
mohitsaini
Warnings : 1

New User


Joined: 15 May 2006
Posts: 92

PostPosted: Thu Sep 11, 2014 9:23 am
Reply with quote

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

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Thu Sep 11, 2014 7:04 pm
Reply with quote

Elemetary FILLER data items are NOT initialized according to the Language Reference Manual.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3053
Location: NYC,USA

PostPosted: Thu Sep 11, 2014 8:04 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
No new posts Generate output lines (SYSIN card for... DFSORT/ICETOOL 4
Search our Forums:

Back to Top