Creating array to substitute the below cobol statment



Ask about System customization & performance, Workload management, I/O device configuration etc.

Creating array to substitute the below cobol statment

Postby anoopm7 » Thu May 08, 2008 11:40 am

Hi All,

Could any one guide me for creating array to substitute the below cobol statment's

When 1
Add +1 to choice-1
When 2
Add +2 to choice-2
.
.
.
.
When 140
Add +140 to choice-140


your help is deeply appreciated.
Thanks
anoopm7
 
Posts: 12
Joined: Sun Feb 10, 2008 12:55 am
Has thanked: 0 time
Been thanked: 0 time

Re: Array creation.

Postby arunprasad.k » Thu May 08, 2008 5:15 pm

Code something like.

WORKING-STORAGE SECTION.                                     
01 CHOICE-TABLE.                                             
     05 CHOICE                   PIC 9(08) OCCURS 140 TIMES.
PROCEDURE DIVISION.                                         
   IF NOT (N < 1 AND N > 140)                               
     ADD +1 TO CHOICE(N)                                     
   ELSE                                                     
     YOUR WHEN OTHERS CASE                                   
   END-IF.                                                   


Where n is the value in the evaluate class.

Post if you have any problems. Arun
arunprasad.k
 
Posts: 110
Joined: Thu Dec 27, 2007 5:18 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Array creation.

Postby dick scherrer » Thu May 08, 2008 6:23 pm

Hello,

Please note in the posted suggestion, there is no initial value in the counters. They should be set to zero before being used as accumulators. As is, invalid totals may result or an abend may occur.

I am also not sure about the requirement that adds 1 when the "value" is a 1 and adds 2 when the "value" is a 2 and so on. I believe that the suggested code (which is not the same as the request) is what is needed.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times


Return to System programming

 


  • Related topics
    Replies
    Views
    Last post