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

translation table in cobol (?)


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
assaf.el

New User


Joined: 22 Mar 2005
Posts: 6

PostPosted: Tue Mar 22, 2005 5:52 pm
Reply with quote

hello , i'm looking for a way to create a translation table in cobol that will be able to get a code and return a description (and the oposite as well) .
i've tried to use level 88 for it , but i didn't find a way .
doe's any of u has an idea how can i use cobol language to do so ?

examle of my need : i have 5 codes of operation , and the description of operation . if i'll declare a level 88 var with the 5 values , i could enter the value to the master var and the correct flag will be true .
i want to do the same , but insted of the flag to be lit , i want the description of the operation .
Back to top
View user's profile Send private message
ovreddy

Active User


Joined: 06 Dec 2004
Posts: 211
Location: Keane Inc., Minneapolis USA.

PostPosted: Tue Mar 22, 2005 8:47 pm
Reply with quote

Hi,

You better use TABLE HANDLING for this. If your input is number. You can do this in the following way...

1. Create a table by storing all the descriptions in a table as follows

a[1] = ONE
a[2] = TWO
a[3] = THREE
(and so on...)

2. Input the variable and use it as index to the table.

ACCEPT I.
DISPLAY a(I).

3. If Input is not 1,2,3,.... move 1,2,3,... to a variable based on input.

ACCEPT I.
IF I = 10
MOVE 1 TO I
ELSE
IF I = 20
MOVE 2 TO I
. .....................

DISPLAY a[I].

Thanks,
Reddy.
Back to top
View user's profile Send private message
assaf.el

New User


Joined: 22 Mar 2005
Posts: 6

PostPosted: Tue Mar 22, 2005 9:04 pm
Reply with quote

this is not what i was looking for . ur talking about creating a vector and hash key for it , and this is a nice solution , but i looked for a standard solusion inside the cobol language .
i've already solved the problem , but i'm looking for a nicer way to do so .

10X anyway .
Back to top
View user's profile Send private message
brahmanandareddy

New User


Joined: 16 Dec 2004
Posts: 44
Location: Hyderabad

PostPosted: Wed Mar 23, 2005 11:30 am
Reply with quote

Hi Assaf,

If u have solved the problem succesfully why don't u paste ur code here.....

Thank You
Back to top
View user's profile Send private message
assaf.el

New User


Joined: 22 Mar 2005
Posts: 6

PostPosted: Wed Mar 23, 2005 11:27 pm
Reply with quote

because my solution is not what i've asked for.
but if i'll find an answer to my question , i'll publish it here .
Back to top
View user's profile Send private message
somasundaran_k

Active User


Joined: 03 Jun 2003
Posts: 134

PostPosted: Thu Mar 24, 2005 1:10 am
Reply with quote

Assaf
Assuming you must be knowing before hand whether you are gettign a Code or Description as Input. I'm sure you must. icon_lol.gif

I would declare an array as follows.

Code:

01 WS-CODE1-IND.                                     
    05 FILLER      PIC X(46) VALUE                   
     'MY DESCRIPTION-1                             A'.
    05 FILLER      PIC X(46) VALUE                   
     'MY DESCRIPTION-2                             B'.
    05 FILLER      PIC X(46) VALUE                   
     'MY DESCRIPTION-3                             C'.
    05 FILLER      PIC X(46) VALUE                   
     'MY DESCRIPTION-4                             D'.
    05 FILLER      PIC X(46) VALUE                   
     'MY DESCRIPTION-5                             E'.

01 WS-CODE1-ARRAY REDEFINES WS-CODE1-IND.   
    05 WS-ERROR OCCURS 5 TIMES INDEXED BY X1.
       10 WS-ERROR-DESC PIC X(45).           
       10 WS-ERROR-CODE PIC X(01).   


And in my procedure division
Code:

SET X1 TO 1.

If search-item = code
*** your input is a code
  SEARCH WS-ERROR                                         
                                                       
     AT END                                             
     DISPLAY 'NOT FOUND IN TABLE '                                 
 
     WHEN your search code = WS-ERROR-CODE (X1)         
       do the processing for the code   
         
         
  END-SEARCH
Else
***your input is a description
   SEARCH WS-ERROR                                         
                                                           
        AT END                                             
        DISPLAY 'NOT FOUND IN TABLE '                                 
   
        WHEN your search desc = WS-ERROR-DESC PIC (X1)         
          do the processing for the description   
           
           
  END-SEARCH

End-if

Is this what you are looking for..?

Regds
-Som
Back to top
View user's profile Send private message
assaf.el

New User


Joined: 22 Mar 2005
Posts: 6

PostPosted: Thu Mar 24, 2005 5:34 pm
Reply with quote

this is nice , but not exactly what i've asked .
i don't want to scan the array any time i'm getting a code .
i want to enter the code to a var and to get the description (in the same way that i'm using level-88 var so i can enter my value and the specific flag that i needed is being lit

example :
01 day-of-week
88 sw-sunday values '1'
88 sw-monday values '2'
88 sw-tuesday values '3'
etc ..

move curr-day to day-of-week

** now the current day flag should be lit .

i want to find a way that insted of litting the flag , another var will get a specific value .
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Fri Mar 25, 2005 6:22 am
Reply with quote

You didn't say how many codes you have. but let's say you have 7, keeping w/your example.

Your table will look like this:
Code:

01  days-vals  pic x(021) value
      ?SunMonTueWedThuFriSat?.
01  days-tbl redefines days-vals.
     05  day   pic x(003) occurs 7.
01  ws-code    pic x(001).

In the PD code:
Code:

accept ws-code
display ?The code you entered >? ws-code '< '
        ? represents the DOW ? day(ws-code) '.'. 

This will display as:
Code:

The code you entered >1< represents the DOW Sun. 

P.S. Level 88s are not data. They can only be seen in the pgm listing.
Back to top
View user's profile Send private message
assaf.el

New User


Joined: 22 Mar 2005
Posts: 6

PostPosted: Tue Mar 29, 2005 3:30 pm
Reply with quote

if u'll look carefully , u just defined an array icon_rolleyes.gif
anyway , ur solution is not quite what i've asked for because u assume that my codes are in a sequence (but there not)
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Wed Mar 30, 2005 7:07 am
Reply with quote

I know what I defined, friend. Why don't you COMPLETELY define your problem? Then we won't have to guess.

What are/how many codes do you have, etc., etc.

And BTW, 88 level text does not exist outide the source listing once the pgm is compiled. You CAN'T access the text of an 88 level condition name.
Back to top
View user's profile Send private message
assaf.el

New User


Joined: 22 Mar 2005
Posts: 6

PostPosted: Wed Mar 30, 2005 10:04 pm
Reply with quote

i'm looking for a general solution for my problem (that i defined in my first post).

an array solotion is relevant when that codes are in some kind of a running sequence or when i can generate hash key on the codes .

i didn't fully understood ur BTW .
Back to top
View user's profile Send private message
somasundaran_k

Active User


Joined: 03 Jun 2003
Posts: 134

PostPosted: Thu Mar 31, 2005 1:13 am
Reply with quote

assaf
It is always better to give some examples. Like your input ,output etc..So that we don't have to make any assumtions. Your description is too vague and I'm not able infer it properly and it is a bit confusing. icon_lol.gif

Regds
-Som
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 Load new table with Old unload - DB2 DB2 6
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 Pulling a fixed number of records fro... DB2 2
Search our Forums:

Back to Top