Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
translation table in cobol (?)

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: translation table in cobol (?)
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    Post subject:
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    Post subject: Re: translation table in cobol (?)
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts IEW2456E error when link-editing a C ... Senthilraj JCL & VSAM 0 Fri Oct 13, 2017 3:12 pm
No new posts Update table without cursor Ron Klop DB2 3 Wed Oct 11, 2017 1:06 pm
No new posts Table(Unicode(Graphic) table) loading... muralikrishnan_new DB2 0 Thu Oct 05, 2017 5:10 pm
No new posts Assembler Macro Copybook converted to... Ziquilix PL/I & Assembler 4 Tue Sep 26, 2017 3:07 am
No new posts Insert a Row_number into table useit DB2 2 Tue Sep 19, 2017 1:07 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us