Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mainframe numeric formats

Status
Not open for further replies.

teqmem

Programmer
Nov 26, 2004
114
US
Hello,

I receive a stream of files from an IBM mainframe that contains a 5-character quantity field. My local database is Oracle 10g. I parse and load the contents of these files into Oracle.

Periodically, I receive files containing encoded quantity values, for examples:

}5000
{0004
0192M
0000q

I did some research and found that '{' indicates a positive sign for example. Can someone give a definite explanation on how to convert to ascii, given values like above?

Thank you.
 
This is how I convert an IBM character to a correct digit and sign:
. Conversion-Montant SECTION.
IF WS-mon-A = "}" OR "]" OR X"8A" OR (>= "J" AND <= "R")
MOVE "+" TO WS-mon-S
ELSE
MOVE "-" TO WS-mon-S
END-IF
EVALUATE WS-mon-A
WHEN "A" WHEN "J" MOVE "1" TO WS-mon-A
WHEN "B" WHEN "K" MOVE "2" TO WS-mon-A
WHEN "C" WHEN "L" MOVE "3" TO WS-mon-A
WHEN "D" WHEN "M" MOVE "4" TO WS-mon-A
WHEN "E" WHEN "N" MOVE "5" TO WS-mon-A
WHEN "F" WHEN "O" MOVE "6" TO WS-mon-A
WHEN "G" WHEN "P" MOVE "7" TO WS-mon-A
WHEN "H" WHEN "Q" MOVE "8" TO WS-mon-A
WHEN "I" WHEN "R" MOVE "9" TO WS-mon-A
WHEN "{" WHEN "}"
WHEN X"8A" WHEN X"82" *>Credit Agricole ...
WHEN "[" WHEN "]" MOVE "0" TO WS-mon-A
END-EVALUATE

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Does this mean that the corresponding values are:

}5000 = -5000
{0004 = +4 (so why is the sign still needed)
0192M = -1924
0000q = -8 (is this same as "}0008")

I don't use Cobol but I thought I post on a Cobol forum.

Thank you.
 
For me:
}5000 = 5000
{0004 = -4
0192M = 1924
0000q = -8 (not sure here ...)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I saw this site and conversion table. According to this site "}" is "-" thus "}5000" should be "-5000", "{0004" should be "+0004". Am I interpreting the table below because my answers don't match yours?

Value Character
+0 {
+1 A
+2 B
+3 C
+4 D
+5 E
+6 F
+7 G
+8 H
+9 I

-0 }
-1 J
-2 K
-3 L
-4 M
-5 N
-6 O
-7 P
-8 Q
-9 R
 
OOps, sorry, my routine inverts the sign (for internal use).
Your table link is great (and correct).

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
In Micro Focus COBOL, just use the following Code:
Code:
 $SET SIGN"EBCDIC"
   01  MAINFRAME-RECORD.
       05  FIELD-TYPE-1 PIC S9(5) SIGN IS LEADING.
       05  FIELD-TYPE-2 PIC S9(5).
       etc.
 $SET SIGN"ASCII"
The sign will then be correctly interpreted. Note that SIGN IS TRAILING is the default.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top