Page 1 of 2

COBOL - Date format to Binary ASCCII

Posted: Wed Apr 16, 2014 6:14 pm
by Attack1988
Hi ,

I need to convert Date format to Binary ASCII format in cobol . Please

someone help . If I found the answer , will share too :) .

Posted: Wed Apr 16, 2014 7:58 pm
by William Collins
What, exactly, with references to the manuals and example data definitions, do you mean by "Date format" and "Binary ASCII format"?

Posted: Thu Apr 17, 2014 8:29 am
by Attack1988
William Collins,

Thanks for asking . I have a date say I have converted to ..Integer using Function Of Integer .. now its in 9(08) ;
now I want this Integer to be in Binary (like 1010101) and In ASCII too
Is there any data item like s9(09) Binary ASCII ? where we can simply move and convert intoo Binary and Ascii or we have to perform calculation ? OR is there any separate calling programs for this .. ? like
CEECBLDY—convert date to COBOL integer format
http://publib.boulder.ibm.com/infocente ... psrv03.htm
Please make it clear .. i have recently seen some variable like
s9(09) Binary ! I dunno what it does too

Posted: Thu Apr 17, 2014 11:25 am
by William Collins
If you need anything in binary, there are one of four things you can specify as the USAGE on the data definition.

Code: Select all

COMP
COMP-4
BINARY 

COMP-5
COMP/COMP-4/BINARY are all identical. You should use whichever is used at your site. These definitions hold a value in binary with its maximum and minimum defined by the PICture. So, PIC 9(4) has a minimum value of zero, maximum value of 9999. PIC S9(3) has a minimum value of -999 and a maximum value of +999.

For COMP-5, the PICture defines the size of storage, and the binary value is only limited by the size of that storage. PIC 9(4) has a maximum of (2^16)-1 (two bytes of 8-bit storage) and a minimum of zero.

On the Mainframe, EBCDIC is the standard byte-encoding system. Outside, generally ASCII is the standard. Binary fields, which are not single bytes anyway, have bit patterns which are the same, though Endianness has to be catered for.

So, a binary field is no problem. Now you need to explain the ASCII aspect of it. What do you mean by needing the ASCII value? Show some sample data, and what that should be understood to mean.

Posted: Fri Apr 18, 2014 11:20 am
by Attack1988
William Collins,

YEA got a idea from u and from various sites i browsed .....

comp-binary-computational ,comp-4 comp-5 are in binary

comp-3 in bcd format ,

I dunno about comp-1 comp-2

when we use USAGE IS DISPLAY It is stored in EBCIDIC in Mainframe .. can be viewed as ASCII in Windows ..

I got mor info about COMP
here ..
I thought it is used for reducing the size .. but never thought it s actually used for computation s to increase performance ..
http://www.csis.ul.ie/cobol/course/Usage.htm
I want to have more information about COMP ,, and its effect on computation .. where can i get that link ?

Posted: Fri Apr 18, 2014 12:43 pm
by William Collins
That seems to be quite a poor document that you have provided a link for.

Instead, use the Enterprise COBOL manuals. In fact, take your link, look up all of those things in the Enterprise COBOL manuals, then you'll know more and see how inaccurate the link is.

Posted: Fri Apr 18, 2014 3:17 pm
by Attack1988
I dont think so .. it taught me the basic good

U call it poor ? in the sense .. explain somethin wrong in that ^^ Keeping things simple doesnt mean its wrong ..

Posted: Fri Apr 18, 2014 3:41 pm
by William Collins
Well, the link is both wrong and poor. You may have found it helpful, but it won't genuinely help you, because it means there are things you will misunderstand yet think that you understand.

However, you are fully free to think what you like. You will always have trouble explaining yourself to other people, but that will be your problem.

I don't mind explaining things three times to the same person. More requested, and I give up. You've used up two with this so far.

Posted: Sat Apr 19, 2014 12:19 am
by DikDude
Hello,
it taught me the basic good
Believing something does not make it true . . .

The way the material you linked IS rather easy to read, but it is not as useful as it could be.

I believe you have rather well understood what you read there, but it has not provided you with complete information. So what you know may be a bit short.

Posted: Mon Apr 21, 2014 9:39 am
by Attack1988
DikDude,

Hi , ok accept that .. But information i collect .. i will make sure its right ..

Then only share dont worry ^_^ .. I m kinda new to mainframe .. only three months studied .. but yea i like to solve other problems .. ^^

For my question ..
Yea this is the answer .. .. Usage is DISPLAY for EBCIDIC /ASCII

Usage is COMP for Binary

USage is COMP-3 for bcd format ^_^
anyway Thanks Williams .. ^^

Posted: Mon Apr 21, 2014 12:48 pm
by William Collins
There's an example. COMP-3/PACKED-DECIMAL is NOT BCD.

This is not the first time I've seen this false assertion recently. Perhaps that incorrect page is too easy to locate.

PIC X can contain any of the 256 possible bit-patterns, and need not be either ASCII or EBCDIC. PIC 9 is conventionally a limited sub-set of values, but be aware that in practice the compiler does not limit them. If you put rubbish in there, nothing except your own code will stop you garbling bad data to good, unless you get an Abend.

BINARY/COMP/COMP-4 and COMP-5 are all binary. The first three are identical to each other (they are synonyms to the compiler). The last is different.

I'm not sure of your method of knowing what is correct, but you need to improve on it.

Posted: Mon Apr 21, 2014 1:57 pm
by Attack1988
William Collins, so you are saying comp-3 is bcd format only if its variable is

9 type and not X type ?

Posted: Mon Apr 21, 2014 2:56 pm
by William Collins
No, I'm saying several different things at the same time.

COMP-3/PACKED-DECIMAL is not, not, not, not, not, BCD. OK? Not.

Look for a definition of BCD. If that definition says it is packed-decimal, discard it and look for another. Repeat until you know what BCD is and what packed-decimal is. Treat anything which says that BCD is packed-decimal, or vice-versa, with great suspicion, as they are NOT.

Find out, reliably, what ASCII and EBCDIC actually are. Realise that a PIC X(n) field has nothing to do directly with either ASCII or EBCDIC.

Realise that even a field defined as PIC 9 (USAGE DISPLAY by default) can actually contain any of the 256 bit patterns for an 8-bit byte.

There are two types of binary in Enterprise COBOL. You need to know the different between them.

So, that's four different things. Unconnected to each other, but which despite your commendable efforts so far you have some confusions about.

Posted: Mon Apr 21, 2014 4:02 pm
by Attack1988
William Collins,

ok ok i understand what you are trying to say ..


Will do this later ..

then will talk about it .. not now ..

Posted: Mon Apr 21, 2014 4:34 pm
by William Collins
OK. Do you mean "what you are trying to say" or "what you are saying". If it is the former, you don't :-)