View previous topic :: View next topic
|
Author |
Message |
HARIBHARAT
New User
Joined: 05 Jul 2006 Posts: 65 Location: pune
|
|
|
|
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 |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
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 |
|
|
HARIBHARAT
New User
Joined: 05 Jul 2006 Posts: 65 Location: pune
|
|
|
|
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 |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
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 |
|
|
HARIBHARAT
New User
Joined: 05 Jul 2006 Posts: 65 Location: pune
|
|
|
|
Thanks Ekta
sorry spell wrongly.i got all the points. |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
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 |
|
|
valeti_sashi
New User
Joined: 23 Jun 2006 Posts: 7
|
|
|
|
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 |
|
|
wangrui
New User
Joined: 23 Sep 2006 Posts: 1
|
|
|
|
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 |
|
|
|