MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Cobol queries (Case conversion)

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
Prayank
Beginner


Joined: 13 May 2003
Posts: 18
Topics: 9
Location: Indore,India

PostPosted: Mon Dec 15, 2003 8:28 am    Post subject: Cobol queries (Case conversion) Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12370
Topics: 75
Location: San Jose

PostPosted: Mon Dec 15, 2003 9:43 am    Post subject: Reply with quote

Prayank,

The Assign clause for the old cobol compilers had to contain specific device specifications. In that was a Symbolic-Device this was to assign a specific number to each device (ie. SYS001-255) and with it was a Device Class (UR,UT,DA).

UR stands for unit-record devices like card readders, card punches..

UT stands for Unit Transfer devices like tape drives and sequential disks.

DA stands for Direct Access Disk.

Now all these features are obsolete and not required. So go ahead and remove that clause from your program.

2. Very simple.Cobol has now intrinsic functions that can be used to convert lower case to upper case and vice-versa.

check this link for a detailed explanation of the LOWER-CASE function

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IGY3LR10/7.1.24?DT=20020920180651

check this link for a detailed explanation of the UPPER-CASE function.

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IGY3LR10/7.1.48?DT=20020920180651

Another alternative is use Special-Names for specifying the collating sequence.check this link for an example.

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/igy3pg10/1.1.2.2.1?SHELF=&DT=20020923143836&CASE=

Quote:

Or more generally the code to add to HEX values in COBOL


Can you explain in detail?

Hope this helps...

cheers

kolusu
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Prayank
Beginner


Joined: 13 May 2003
Posts: 18
Topics: 9
Location: Indore,India

PostPosted: Tue Dec 16, 2003 6:46 am    Post subject: Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12370
Topics: 75
Location: San Jose

PostPosted: Tue Dec 16, 2003 7:26 am    Post subject: Reply with quote

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 - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Prayank
Beginner


Joined: 13 May 2003
Posts: 18
Topics: 9
Location: Indore,India

PostPosted: Tue Dec 16, 2003 8:04 am    Post subject: Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12370
Topics: 75
Location: San Jose

PostPosted: Tue Dec 16, 2003 2:59 pm    Post subject: Reply with quote

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 - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Mike Chantrey
Intermediate


Joined: 10 Sep 2003
Posts: 234
Topics: 1
Location: Wansford

PostPosted: Thu Dec 18, 2003 9:02 am    Post subject: Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12370
Topics: 75
Location: San Jose

PostPosted: Thu Dec 18, 2003 9:45 am    Post subject: Reply with quote

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 - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group