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

Initializing in cobol


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 1208
Location: Bangalore,India

PostPosted: Wed Sep 06, 2006 1:02 pm
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
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: 1208
Location: Bangalore,India

PostPosted: Wed Sep 06, 2006 2:58 pm
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
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: 1353
Location: Israel

PostPosted: Wed Sep 06, 2006 7:00 pm
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top