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
 

 

Initializing in cobol

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

New User


Joined: 05 Jul 2006
Posts: 65
Location: pune

PostPosted: Wed Sep 06, 2006 12:48 pm    Post subject: Initializing in cobol
Reply with quote

If not initializing cobol item, what will happen, we need to initialize each and every filed?how can we initialize all the things, give me brief explain?
Back to top
View user's profile Send private message

guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Wed Sep 06, 2006 1:02 pm    Post subject:
Reply with quote

Hi HARIBHARAT,

Initialize verb we used to put intial value in variable . It move space to alpha numeric & alphabetic field . Move 0 to numeric field . FIller is untouched.

It is required othervise ur variable will be having Junk values that will give u an error if u do some Arthematic operation or some time it will
resultant to unpredictable data in o/p.

Eg suppose in ur program u r reading a file & producing some output file..
so suggestion is to just initialize ur record layout befor reading.

Hope it will helpful
Back to top
View user's profile Send private message
HARIBHARAT

New User


Joined: 05 Jul 2006
Posts: 65
Location: pune

PostPosted: Wed Sep 06, 2006 2:17 pm    Post subject: Re: what is Initializing in cobol?
Reply with quote

Thanks Ekatha.

still I have confuse, my program have lot of fields, each one do different

operation, i have to do all field initializing. some time i have more than

700 fields.
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Wed Sep 06, 2006 2:58 pm    Post subject:
Reply with quote

HARIBHARAT,

Thanks Ekatha.

Its Ekta not ekatha...
well Come to ur question i dont think u have delared all the fields at 01 or 77 level...
so just initaize all the group level item.

eg
01 var1.
05 ws-a1 pic 9(8).
05 ws-a2 pic X(8).
05 ws-a3 pic 9(1).
05 ws-a4 pic A(6).
05 ws-a5 pic 9(8).
01 var2.
05...
10....


Just do...
INITIALIZE var1, var2.
Back to top
View user's profile Send private message
HARIBHARAT

New User


Joined: 05 Jul 2006
Posts: 65
Location: pune

PostPosted: Wed Sep 06, 2006 3:09 pm    Post subject: Re: what is Initializing in cobol?
Reply with quote

Thanks Ekta

sorry spell wrongly.i got all the points.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1232
Location: Israel

PostPosted: Wed Sep 06, 2006 7:00 pm    Post subject:
Reply with quote

You could also give an initial value when defining the fields:
01 var1.
05 ws-a1 pic 9(8) VALUE 0.
05 ws-a2 pic X(8) VALUE SPACE.
05 ws-a3 pic 9(1) VALUE 9.
05 ws-a4 pic A(6) VALUE ALL '*'.
05 ws-a5 pic 9(8) VALUE 0.
01 var2.
05...
05....
Back to top
View user's profile Send private message
valeti_sashi

New User


Joined: 23 Jun 2006
Posts: 7

PostPosted: Wed Sep 13, 2006 5:08 pm    Post subject:
Reply with quote

Intialization do have some limitataions:

1. when u initializa a Filler, there will be no effect on that.
2. When u initialize a Array also there will be no effect, i mean it won't be intialized
Back to top
View user's profile Send private message
wangrui

New User


Joined: 23 Sep 2006
Posts: 1

PostPosted: Sat Sep 23, 2006 11:21 am    Post subject:
Reply with quote

hello everyboday

I THINK Intialization WILL DO A SLOW SPEED, I THINK YOU CAN WRITE FOLLOW SOURCE
Code:

1.MOVE  SPACE   TO   PIC X()
2.MOVE  ZERO     TO  PIC 9()
3.MOVE  HIGH-VALUE  TO  TABLE


IN MY RECENT PROJECT

THE CLIENT DON'T PERMIT US TO use initialization. they would like us to MOVE SPACES and ZEROS at the 01 level in working storage and keep this "initialized" version aside and use it whenever we need to INITIALIZE the same 01 level again in the program instead of using INITIALIZE again and again.

SO WE USE TWO WAY TO DEAL WITH THIS PROBLEM
1. DATE DIVISION
03 NOTE-NUM-AREA.
05 NOTE-NUM PIC 9(05) COMP3
OCCURS 5 TIMES.

WAY ONE:
MOVE 1 TO C-NUM-CTR.
PERFORM UNTIL (C-NUM-CTR > 5)
MOVE ZERO NOTE-NUM(C-NUM-CTR)
ADD 1 TO C-NUM-CTR
END-PERFORM.

WAY TWO
1. TO MAKE A WORK-AREA STURCTS LIKE THAT FILE.

Intialization WK-FILENAME.
MOVE WK-FILENAME-REC TO O1AFILENAME-REC.
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 XML Parse for COBOL 5.2 Bhanu Praveen COBOL Programming 1 Sat Jul 08, 2017 8:58 pm
No new posts Dynamic output file creation in cobol... smileheal COBOL Programming 7 Thu Jun 15, 2017 10:53 pm
No new posts Search utility(3.14) using JCl and Cobol RKS3 COBOL Programming 12 Sat Jun 10, 2017 10:24 pm
No new posts COBOL DB2 program - zIIP eligible vasanthz COBOL Programming 7 Wed May 31, 2017 5:12 am
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm


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