473,624 Members | 2,575 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

COBOL file dump...

MPF
Alas, I surrender...

In a file from a COBOL dump, which is in ASCII, one of the fields is defined
as S9(9) V99 Value +0.
The value in this location is 0000018922D, which according to the author of
the source, translates to 00000189224.

How can this be translated via .Net? I've tried StreamReader and trying to
convert everything to bytes, but I end up with the same value (0000018922D).
Thanks In Advance.

Morgan
Nov 21 '05 #1
11 3752
Ger
This is the representation of a so called "packed decimal" field with the
sign (+ or -) in the last nibble. In Cobol terms a COMP-3 field. In a
packed decimal field each decimal digit is stored in a nibble (4-bits, half
byte). The sign is C or F if positive, D if negative.
So in your example the value in de field is -189.22.
Here is a URL with a fairly good explanation:
http://digilander.libero.it/foxes/Packed_Decimal.htm

Hope this helps,
/Ger
"MPF" <ab**@senditon. com> schreef in bericht
news:Ol******** ******@TK2MSFTN GP15.phx.gbl...
Alas, I surrender...

In a file from a COBOL dump, which is in ASCII, one of the fields is defined as S9(9) V99 Value +0.
The value in this location is 0000018922D, which according to the author of the source, translates to 00000189224.

How can this be translated via .Net? I've tried StreamReader and trying to
convert everything to bytes, but I end up with the same value (0000018922D).

Thanks In Advance.

Morgan

Nov 21 '05 #2
MPF,

This should be easy to translate, the only problem is to know the
representation that is used while converted to ASCII for +0 and -0

In this sequence is A +1 (which is punched card code 12 + 1) in EBCDIC
and J is -1 however what is -0. (which is punched card code 11 + 1) in
EBCDIC

With that last position is told that the whole field is plus or minus.

Therefore a routine is quiet easy however what is that +0 and -0 translated
to in your situation.

Cor
"MPF" <ab**@senditon. com> schreef in bericht
news:Ol******** ******@TK2MSFTN GP15.phx.gbl...
Alas, I surrender...

In a file from a COBOL dump, which is in ASCII, one of the fields is defined as S9(9) V99 Value +0.
The value in this location is 0000018922D, which according to the author of the source, translates to 00000189224.

How can this be translated via .Net? I've tried StreamReader and trying to
convert everything to bytes, but I end up with the same value (0000018922D).

Thanks In Advance.

Morgan

Nov 21 '05 #3
You are showing your age here Cor ( Punched Cards and EBCDIC - Extended
Binary-Coded Decimal Interchange Code / Mainframes / IBM Etc )
LOL

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Cor Ligthert" <no**********@p lanet.nl> wrote in message
news:uF******** ******@TK2MSFTN GP11.phx.gbl...
MPF,

This should be easy to translate, the only problem is to know the
representation that is used while converted to ASCII for +0 and -0

In this sequence is A +1 (which is punched card code 12 + 1) in EBCDIC
and J is -1 however what is -0. (which is punched card code 11 + 1) in
EBCDIC

With that last position is told that the whole field is plus or minus.

Therefore a routine is quiet easy however what is that +0 and -0 translated to in your situation.

Cor
"MPF" <ab**@senditon. com> schreef in bericht
news:Ol******** ******@TK2MSFTN GP15.phx.gbl...
Alas, I surrender...

In a file from a COBOL dump, which is in ASCII, one of the fields is

defined
as S9(9) V99 Value +0.
The value in this location is 0000018922D, which according to the author

of
the source, translates to 00000189224.

How can this be translated via .Net? I've tried StreamReader and trying to convert everything to bytes, but I end up with the same value

(0000018922D).


Thanks In Advance.

Morgan


Nov 21 '05 #4
Terry

Search for Ligthert on Google, than you can see me in the first and second
link, so why hiding it.

Cor
Nov 21 '05 #5
"MPF" <ab**@senditon. com> wrote in message news:<Ol******* *******@TK2MSFT NGP15.phx.gbl>. ..
Alas, I surrender...

In a file from a COBOL dump, which is in ASCII, one of the fields is defined
as S9(9) V99 Value +0.
The value in this location is 0000018922D, which according to the author of
the source, translates to 00000189224.

How can this be translated via .Net? I've tried StreamReader and trying to
convert everything to bytes, but I end up with the same value (0000018922D).


It's been a long time, but I seem to remember that COBOL stored a
signed display value with a sign by tuning the uppermost bit on on the
rightmost character if the value was negative. So from that point of
view it appears to me the value should be -189225. At any rate, there
should be someway you can do a bitwise OR to strip off the upper bit
on the last character.
Nov 21 '05 #6
Hmmmmmmmmmm ....

It seems that a few peoples have forgotten their COBOL Core skills :)

It's nothing to do with BCD or Packed Decimal.

It's to do with the declaration for the sign.

Because there is no sign declaraction on the field (S9(9)V99 VALUE 0), the
compiler (or the program) defaults come in to play. It would appear that the
compiler (or program) default is SIGN OVERPUNCHED TRAILING.

This means that the high nibble of the last byte has been 'overpunched' with
the sign indicator.

One option would be to ask the COBOL programmer to change the definition for
the 'dump' file so that the field is defined as S9(9)V99 SIGN SEPERATE
TRAILING VALUE 0. If he can do that for you then the output will be
00000189224+ or 00000189224- as appropriate.

If that is not an option then you need to read the value (11 characters) as
a string then change the last character and set the sign as per the
following:

If the last character is '{' or 'A' thru 'I' then the value is positive.

If the last character is '}' or 'J' thru 'R' then the value is negative.

If the last character is '{' or '}' then replace it with '0'.

If the last character is 'A' or 'J' then replace it with '1'.

If the last character is 'B' or 'K' then replace it with '2'.

If the last character is 'C' or 'L' then replace it with '3'.

If the last character is 'D' or 'M' then replace it with '4'.

If the last character is 'E' or 'N' then replace it with '5'.

If the last character is 'F' or 'O' then replace it with '6'.

If the last character is 'G' or 'P' then replace it with '7'.

If the last character is 'H' or 'Q' then replace it with '8'.

If the last character is 'I' or 'R' then replace it with '9'.

FYI,
the EDCDIC values for characters '0' thru '9' are 0xF0 thru 0xF9
respectively
the EDCDIC values for characters '{' thru 'I' are 0xC0 thru 0xC9
respectively
the EDCDIC values for characters '}' thru 'R' are 0xD0 thru 0xD9
respectively
Notice the correlation.
For overpunched signs (trailing) the last byte is overpunched with the
corresponding character from the 'C' column for a positive value or the 'D'
column for a negative value.
For overpunched signs (leading) it is the first byte that is overpunched.
If the sign was leading your value in the dumpfile would read '{0000189224'.
"MPF" <ab**@senditon. com> wrote in message
news:Ol******** ******@TK2MSFTN GP15.phx.gbl...
Alas, I surrender...

In a file from a COBOL dump, which is in ASCII, one of the fields is defined as S9(9) V99 Value +0.
The value in this location is 0000018922D, which according to the author of the source, translates to 00000189224.

How can this be translated via .Net? I've tried StreamReader and trying to
convert everything to bytes, but I end up with the same value (0000018922D).

Thanks In Advance.

Morgan

Nov 21 '05 #7
MPF
Thanks to all who offered suggestions.

Since I'm not dealing with a true EBCDIC file(sorry for not mentioning if
that played a role in your response), at least at this assumption, I'm
thinking Stephany's suggestion will apply for my scenario based on my review
of the data.

I'm sure if I hit a Comp-3 field, I'll be back to the drawing board and
bitwise OR'ing once and for all.

The following function in VB -should- handle the conversions, at least with
my data.

Thanks again to everyone!

Morgan

Function ConvertCharToIn t(ByVal Val As String) As Integer

Select Case Val

Case "{"

Return 0

Case "}"

Return -0

Case "A"

Return 1

Case "B"

Return 2

Case "C"

Return 3

Case "D"

Return 4

Case "E"

Return 5

Case "F"

Return 6

Case "G"

Return 7

Case "H"

Return 8

Case "I"

Return 9

Case "J"

Return -1

Case "K"

Return -2

Case "L"

Return -3

Case "M"

Return -4

Case "N"

Return -5

Case "O"

Return -6

Case "P"

Return -7

Case "Q"

Return -8

Case "R"

Return -9

End Select

End Function
"MPF" <ab**@senditon. com> wrote in message
news:Ol******** ******@TK2MSFTN GP15.phx.gbl...
Alas, I surrender...

In a file from a COBOL dump, which is in ASCII, one of the fields is
defined as S9(9) V99 Value +0.
The value in this location is 0000018922D, which according to the author
of the source, translates to 00000189224.

How can this be translated via .Net? I've tried StreamReader and trying to
convert everything to bytes, but I end up with the same value
(0000018922D).
Thanks In Advance.

Morgan

Nov 21 '05 #8
MPF
Thanks , Stephany.

Early on I came to an uneducated guess of A=1, B=2, but wasn't comfortable
moving forward with that assumption. I'm thinking that when I went over this
with the author of the file, they mave have been insulted that it would be
that easy to translate. Alas ;).

Thanks Again.

"Stephany Young" <noone@localhos t> wrote in message
news:e0******** *****@tk2msftng p13.phx.gbl...
Hmmmmmmmmmm ....

It seems that a few peoples have forgotten their COBOL Core skills :)

It's nothing to do with BCD or Packed Decimal.

It's to do with the declaration for the sign.

Because there is no sign declaraction on the field (S9(9)V99 VALUE 0), the
compiler (or the program) defaults come in to play. It would appear that
the
compiler (or program) default is SIGN OVERPUNCHED TRAILING.

This means that the high nibble of the last byte has been 'overpunched'
with
the sign indicator.

One option would be to ask the COBOL programmer to change the definition
for
the 'dump' file so that the field is defined as S9(9)V99 SIGN SEPERATE
TRAILING VALUE 0. If he can do that for you then the output will be
00000189224+ or 00000189224- as appropriate.

If that is not an option then you need to read the value (11 characters)
as
a string then change the last character and set the sign as per the
following:

If the last character is '{' or 'A' thru 'I' then the value is positive.

If the last character is '}' or 'J' thru 'R' then the value is negative.

If the last character is '{' or '}' then replace it with '0'.

If the last character is 'A' or 'J' then replace it with '1'.

If the last character is 'B' or 'K' then replace it with '2'.

If the last character is 'C' or 'L' then replace it with '3'.

If the last character is 'D' or 'M' then replace it with '4'.

If the last character is 'E' or 'N' then replace it with '5'.

If the last character is 'F' or 'O' then replace it with '6'.

If the last character is 'G' or 'P' then replace it with '7'.

If the last character is 'H' or 'Q' then replace it with '8'.

If the last character is 'I' or 'R' then replace it with '9'.

FYI,
the EDCDIC values for characters '0' thru '9' are 0xF0 thru 0xF9
respectively
the EDCDIC values for characters '{' thru 'I' are 0xC0 thru 0xC9
respectively
the EDCDIC values for characters '}' thru 'R' are 0xD0 thru 0xD9
respectively
Notice the correlation.
For overpunched signs (trailing) the last byte is overpunched with the
corresponding character from the 'C' column for a positive value or the
'D'
column for a negative value.
For overpunched signs (leading) it is the first byte that is overpunched.
If the sign was leading your value in the dumpfile would read
'{0000189224'.
"MPF" <ab**@senditon. com> wrote in message
news:Ol******** ******@TK2MSFTN GP15.phx.gbl...
Alas, I surrender...

In a file from a COBOL dump, which is in ASCII, one of the fields is

defined
as S9(9) V99 Value +0.
The value in this location is 0000018922D, which according to the author

of
the source, translates to 00000189224.

How can this be translated via .Net? I've tried StreamReader and trying
to
convert everything to bytes, but I end up with the same value

(0000018922D).


Thanks In Advance.

Morgan


Nov 21 '05 #9

"Stephany Young"
Hmmmmmmmmmm .... It seems that a few peoples have forgotten their COBOL Core skills :)


Pardon, I thought that I had given almost the same answer as you, the only
thing I was not sure of that MPF had to look for was the character for the
zeros, because than can be translatted in every EBCDIC to ASCII way in a
different way. That it is with you {} is not a default, maybe a lost of your
EBCDIC COBOL skills, because those signs are not the representant for the
same in EBCDIC place. That means Hex C0 and D0 in EBCDIC. Where C=zero plus
and D= zero minus.

With a one to one transaltion this would result in for the C0 the @ Sign
however that exist in EBCDIC as 7C and therefore there should be taken non
existing EBCDIC characters. What is in your case the {} however as far as I
know for sure not a default.

Therefore I asked to MDF was in what are the EBCDIC C0 (+0) and D0 (-0)
translated, because that depends on the converter.

Than the procedure is easy to do.

First copy the string except the last postiton,
If the last character not is the equivalent for -0 you can set the the
boolean IsMinus
For +0 and - 0 concatenate as a char "0" to the made string.
If not than for the values from A to R you can do a subtract in the byte
with 16 to get the last character which you can do for the J to R as well
with the value 25.
Concatenate that value as ASCW to the string.

Than when the it is minus subtract the string from an integer with the value
zero and otherwise make from it an integer.

That is all,

So what is this different from my previous message?

Cor
Nov 21 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
14809
by: Batista, Facundo | last post by:
People: I'm trying to convert my father from using COBOL to Python, :) One difficult thing we stuck into is how to read, from python, files written with COBOL. Do you know a module that allows me to do that? It should avoid us the work to write a COBOL program that open the COBOL
2
5120
by: Kalpana Shridhar | last post by:
I am on a project where I am converting COBOL to C++ on the mainframe. I am new to COBOL and have a lot of questions - any websites or any suggestions from experienced people will be really appreciated. My main issue is with the CALL routine - I have to call a external function which I believe is Assembly. Right now the call is made using 4 structures in COBOL. To convert to C++ - what should I be concerned about, should I pass 4...
3
2443
by: KLomax | last post by:
I work at a small company that has custom software written in cobol. This software performs financial payment processing. There are about 300 programs with I’m guessing 1M+ lines of code. The current platform is Liant RM cobol (16bit dos) We are interested in possibly porting this code base into “cobol.net” It looks like there are two major players in this market - Fujitsu NetCOBOL - Micro Focus Net Express Do you know of any...
2
4866
by: none | last post by:
Hi, Any one know of some code to read cobol data files.... thanks timb
5
2711
by: hpy_awad | last post by:
can cobol read binary data written by fprintf (C function) ?
6
3779
by: KevinD | last post by:
assumption: I am new to C and old to COBOL I have been reading a lot (self teaching) but something is not sinking in with respect to reading a simple file - one record at a time. Using C, I am trying to read a flatfile. In COBOL, my simple file layout and READ statement would look like below. Question: what is the standard, simple coding convention for reading in a flatfile - one record at a time?? SCANF does not work because of...
13
10226
by: EricJ | last post by:
hi i need to access cobol data files from .net, the files have no or .vix extention (i think thats a acucobol or something like that) (/me has completely no experience in cobol) i heard that there should be an odbc connection for that. Dous anyone have any ideas on how to do this?? --
0
1766
by: cobug | last post by:
Dear COBOL Users, Articles are being sought for the COBOL User Groups (COBUG) newsletters. Will you help us in our efforts to provide newsletters for the COBOL community at large? The COBUG newsletters will be an independent place to exchange information on any topic related to COBOL. This is an opportunity for
0
5799
by: pompeyoc | last post by:
I am trying to learn how to use stored procedures written in COBOL so I wrote 2 small programs to test it out: the stored procedure and the the calling program. I have no problems compiling them but when the calling program enters the SP, it either hangs or gives me sqlcode -1131. We are on AIX 5.2 (I think) running DB2 UDB ver 7.2 and MF COBOL 4.1. Below are the programs I wrote:
0
8249
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8179
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8685
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8493
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7176
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4187
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1797
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1493
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.