Creating array to substitute the below cobol statment

Ask about System customization & performance, Workload management, I/O device configuration etc.
anoopm7
Posts: 12
Joined: Sun Feb 10, 2008 12:55 am
Skillset: cobol,Db2,JCL,File-aid,CICS
Referer: BY google search

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

arunprasad.k
Posts: 110
Joined: Thu Dec 27, 2007 5:18 pm
Skillset: Known little stuffs to answer a few queries!!
Referer: Google
Contact:

Re: Array creation.

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

Code something like.

Code: Select all

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

User avatar
dick scherrer
Global moderator
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am

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.


  • Similar Topics
    Replies
    Views
    Last post