View previous topic :: View next topic |
Author |
Message |
Prayank Beginner

Joined: 13 May 2003 Posts: 18 Topics: 9 Location: Indore,India
|
Posted: Mon Dec 15, 2003 8:28 am Post subject: Cobol queries (Case conversion) |
|
|
Hi all,
I have following small queries from COBOL:
1. I have a program which is reading a VSAM KSDS with following select clause:
SELECT CK4-MSTR ASSIGN TO SYS008-CK4MSTR
The DD name for this dataset in JCL is CK4MSTR. I would like to know what does SYS008 signify. The program works ok even if I remove this.
2. I want the COBOL code to convert Upper case to lower case . Or more generally the code to add to HEX values in COBOL |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12377 Topics: 75 Location: San Jose
|
|
Back to top |
|
 |
Prayank Beginner

Joined: 13 May 2003 Posts: 18 Topics: 9 Location: Indore,India
|
Posted: Tue Dec 16, 2003 6:46 am Post subject: |
|
|
Kolusu,
Thanks for the info on device class.
For my secong query, I want the logic to write case conversion routine in my cobol program. I want to write logic so that if Var1 contains X'81' and Var2 contains X'40' then I can add these two to get X'C1' in Var3.
Cheers!!
PRAYank |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12377 Topics: 75 Location: San Jose
|
Posted: Tue Dec 16, 2003 7:26 am Post subject: |
|
|
prayank,
Let us see if understand your question correctly.
A hex value of x'81' is 'a'
A hex value of x'40' is space
a hex value of '81' is 'A'
now you want a + space = A ? Is that right?
How did you come up with such a logic?
What exactly do you want to do. If your intention is just to convert the lowercase to upper case then you can use the intrinsic functions which I mentioned earlier.
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
Prayank Beginner

Joined: 13 May 2003 Posts: 18 Topics: 9 Location: Indore,India
|
Posted: Tue Dec 16, 2003 8:04 am Post subject: |
|
|
Kolusu,
I am not concerned about converting case. I don't say that adding X'40' is the logic for case conversion. I just want to add two pic X variables such that the HEX value stored in them gets added.
Cheers
PRAYank |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12377 Topics: 75 Location: San Jose
|
Posted: Tue Dec 16, 2003 2:59 pm Post subject: |
|
|
Prayank,
I still don't get as to what you are trying to do. But you can add 2 alphanumeric variables (PIC X(01)) by redefining them with Numeric items (PIC 9(01)) or move them to Numeric items and then perform the computation.
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
Mike Chantrey Intermediate
Joined: 10 Sep 2003 Posts: 234 Topics: 1 Location: Wansford
|
Posted: Thu Dec 18, 2003 9:02 am Post subject: |
|
|
kolusu, your suggestion does not add the hex values of two characters; it assumes the alphabetic items have display numeric values and adds these. I think what prayank wants is this:
working storage:
Code: |
01 V1-BIN COMP PIC S9(4).
01 V1-GRP REDEFINES V1-BIN.
05 V1-PAD PIC X.
05 V1-CHAR PIC X.
01 V2-BIN COMP PIC S9(4).
01 V2-GRP REDEFINES V2-BIN.
05 V2-PAD PIC X.
05 V2-CHAR PIC X.
01 V3-BIN COMP PIC S9(4).
01 V3-GRP REDEFINES V3-BIN.
05 V3-PAD PIC X.
05 V3-CHAR PIC X.
|
procedure division (assuming V1-CHAR and V2-CHAR contain the characters whose hex values are to be added):
Code: |
MOVE LOW-VALUES TO V1-PAD V2-PAD.
COMPUTE V3-BIN = V1-BIN + V2-BIN.
|
V3-CHAR now contains the character whose hex value is the sum of the hex values of the two original characters, asuming their total is less than or equal to x'FF'. If it is greater, then the result will overflow into V3-PAD. You may want to use COMP-5 or BINARY instead of COMP-4 depending on your compiler version and compilation truncation options.
However, you should not use this method for case conversion unless you are coding for CICS in OS/VS COBOL which does not support any other method (see 2/ below). In addition to kolusu's methods shown above there are the following:
1/ For COBOL versions later than OS/VS COBOL but not recent enough to support intrinsic functions:
Code: |
INSPECT variable-name
CONVERTING 'abcdefghijklmnopqrstuvwxyz'
TO 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
|
You might want to set up working storage variables called UPPER-CASE and LOWER-CASE instead and use these instead of literal alpahbets
.
2/ For OS/VS COBOL:
You can use the TRANSFORM statement. I can't remember the exact syntax but it's very similar to 1/ above. However, you must not use this in OS/VS COBOL CICS programs - in that case you may have to use the hex addition method (you also can't use the SPECIAL NAMES method in OS/VS COBOL CICS). |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12377 Topics: 75 Location: San Jose
|
Posted: Thu Dec 18, 2003 9:45 am Post subject: |
|
|
Mike thank you very much for explanation. As stated in my previous posts , I really did not understand as to what prayank is trying to do.
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
|
|