View previous topic :: View next topic
|
Author |
Message |
assaf.el
New User
Joined: 22 Mar 2005 Posts: 6
|
|
|
|
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 |
|
|
ovreddy
Active User
Joined: 06 Dec 2004 Posts: 211 Location: Keane Inc., Minneapolis USA.
|
|
|
|
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 |
|
|
assaf.el
New User
Joined: 22 Mar 2005 Posts: 6
|
|
|
|
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 |
|
|
brahmanandareddy
New User
Joined: 16 Dec 2004 Posts: 44 Location: Hyderabad
|
|
|
|
Hi Assaf,
If u have solved the problem succesfully why don't u paste ur code here.....
Thank You |
|
Back to top |
|
|
assaf.el
New User
Joined: 22 Mar 2005 Posts: 6
|
|
|
|
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 |
|
|
somasundaran_k
Active User
Joined: 03 Jun 2003 Posts: 134
|
|
|
|
Assaf
Assuming you must be knowing before hand whether you are gettign a Code or Description as Input. I'm sure you must.
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 |
|
|
assaf.el
New User
Joined: 22 Mar 2005 Posts: 6
|
|
|
|
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
assaf.el
New User
Joined: 22 Mar 2005 Posts: 6
|
|
|
|
if u'll look carefully , u just defined an array
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
assaf.el
New User
Joined: 22 Mar 2005 Posts: 6
|
|
|
|
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 |
|
|
somasundaran_k
Active User
Joined: 03 Jun 2003 Posts: 134
|
|
|
|
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.
Regds
-Som |
|
Back to top |
|
|
|