Conversion of hex value to EBCDIC Format

131 views
Skip to first unread message

Karimullah Syed

unread,
Aug 2, 2017, 2:43:06 AM8/2/17
to jPOS Users

Hi All,


Data Elements
===============================
1100 2 :  
 3 :  004000
 4 :  000000001000
 11 :  000001
 12 :  010818004699
 14 :  
 19 :  356
 22 :  101150600120
 24 :  180
 25 :  1234
 26 :  5399
 42 :  200000000019
 49 :  356
=======================================
 
Hexa dump
====================================
1100703425c000408000164862698906428354004000000000001000000001010817262975130103561011506001200180123453993230303030303030303031392020200003333536

So we have required converting to EBCDIC Format

Ex:
(Bank Expecting) the below format
The Auth request packet should be in HEX EBCDIC format and would like –
AuthorizationRequestParam=F1F1F0F0703424C128E08200F1F5F3F7F4F2F4F5F0F0F1F7F4F1F0F0F7F0F0F4F0F0F0F0F0F0F0F0F0F0F0F3F0F0F0F3F5F0F0F0F2F1F7F0F7F0F3F1F6F0F5F2F0F2F1F0F3F3F5F6F5F1F0F1F0F1F5F1F1F1F4C3F1F9F0F0F7F0F1F1F1F1F1F0F0F0F0F0F0F0F1F6F2F3F7F3F7F4F2F4F5F0F0F1F7F4F1F0F0F7C4F2F1F0F3F2F0F1F1F5F0F4F1F2F3F4F5F0F0F0F0F0F7F1F8F4F1F0F3F5F0F0F0F2FXFXFXFXFXF0F7F1FXFXFXFXFXFXFXFXF8F54040404040F4F9XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXD4E0F5XXXXXXXXXXXXXXXXXXXXXXXXXXF6F0F5F7C1C7D5E20001F34BC16BC1AC7C7D0706020103A4200224FC27EA0069000000800017070300000000003000035603563C000000000000000080


After Parsing the above
(Bank Excepting) the below format

F1F1F0F0
703424C128E08200
F1F5 F3F7F4F2F4F5F0F0F1F7F4F1F0F0F7
F0F0F4F0F0F0
F0F0F0F0F0F0F0F0F3F0F0F0
F3F5F0F0F0F2
F1F7F0F7F0F3F1F6F0F5F2F0
F2F1F0F3
F3F5F6
F5F1F0F1F0F1F5F1F1F1F4C3
F1F9F0
F0F7F0F1
F1F1F1F1
F0F0F0F0F0F0F0F1F6F2F3F7
F3F7F4
F2F4F5F0F0F1F7F4F1F0F0F7C4F2F1F0F3F2F0F1F1F5F0F4F1F2F3F4F5F0F0F0F0F0F7F1F8F4F1F0F3F5F0F0F0F2FXFXFXFXFXF0F7F1FXFXFXFXFXFXFXFXF8F54040404040F4F9XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXD4E0F5XXXXXXXXXXXXXXXXXXXXXXXXXXF6F0F5F7C1C7D5E20001F34BC16BC1AC7C7D0706020103A4200224FC27EA0069000000800017070300000000003000035603563C000000000000000080
=========================
Snippet code :
=========================
Below are the step we use to follow
Packing the Data Elements
byte[] a2 = getIsoMessage().pack();

public static String toHexString (byte[] b)  { 
StringBuilder sb = new StringBuilder( b.length * 2 ); 
for ( int i=0 ; i<b.length ; i++ ) {  
//look up high nibble char 
sb.append( hexChar [ ( b[ i] & 0xf0 ) >>> 4  ] ) ; 
//look up low nibble char 
sb.append( hexChar [ b[ i] & 0x0f ] ) ; 
return sb.toString() ; 
}
==================================
After packing the data converting to hex value
====================================
String msg = FormatUtils.toHexString(args);
Ex : 1100703425c000408000164862698906428354004000000000001000000001010817262975130103561011506001200180123453993230303030303030303031392020200003333536

After Parsing Hexa dump value
1100
703425c00040800016
4862698906428354
004000
000000001000
000001
010817262975
1301
0356  
101150600120
0180  
1234
5399
32 30303030303030303031392020200003  
33 35 36 
==========================
Converting the Hex value to EBCDIC Format
========================
byte[] bytes = msg.getBytes("CP1047");
int i;
for (i = 0; i < bytes.length; i++) {
formattedString += String.format("%X", bytes[i]);
logger.info(formattedString);
}

after converting to EBCDIC Format
below is the result

F1F1F0F0
F7F0F3F4F2F583F0F0F0F4F0F8F0F0F0F1F6
F4F8F6F2F6F9F8F9F0F6F4F2F8F3F5F4
F0F0F4F0F0F0F0F0F0F0F0F0F0F0F1F0F0F0F0F0F0F0F0F1F0F2F0F8F1F2F0F1F3F7F1F9F1F3F0F1F0F3F5F6F1F0F1F1F5F0F6F0F0F1F2F0F0F1F8F0F1F2F3F4F5F3F9F9F3F2F3F0F3F0F3F0F3F0F3F0F3F0F3F0F3F0F3F0F3F1F3F9F2F0F2F0F2F0F0F0F0F3F3F3F3F5F3F6

So my concern is even bit map is appended with 'F' which should not happened,may be what i'm converting is also not correct, it should be the above behaviour what Bank Expecting,Please guide me in the conversion if possible provide me the code snippet for the same.



Thanks,
Karimullah Syed.

Karimullah Syed

unread,
Aug 2, 2017, 7:20:41 AM8/2/17
to jPOS Users
Please Suggest

chhil

unread,
Aug 2, 2017, 10:42:37 AM8/2/17
to jpos-...@googlegroups.com
You should define your field packager to have fields of type IFE* (look at the packagers available at https://github.com/jpos/jPOS/tree/master/jpos/src/main/java/org/jpos/iso)

This will pack (to ebcidic bytes) and unpack (from ebcdic bytes).

-chhil

--
--
jPOS is licensed under AGPL - free for community usage for your open-source project. Licenses are also available for commercial usage. Please support jPOS, contact: sa...@jpos.org
---
You received this message because you are subscribed to the Google Groups "jPOS Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jpos-users+unsubscribe@googlegroups.com.
To post to this group, send email to jpos-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/ba9e2e31-435a-4027-8a1a-ec0f30d5c170%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mark Salter

unread,
Aug 3, 2017, 1:34:32 AM8/3/17
to jpos-...@googlegroups.com
On 02/08/17 12:20, Karimullah Syed wrote:
> Please Suggest
Please don't feel the need to 'chase' an answer on a mailing list; it is
very likely to have the opposite effect you wanted.

--
Mark

karim.co...@innoviti.com

unread,
Aug 4, 2017, 12:58:01 PM8/4/17
to jPOS Users
Thanks Chill it works for me.
To unsubscribe from this group and stop receiving emails from it, send an email to jpos-users+...@googlegroups.com.

To post to this group, send email to jpos-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/ba9e2e31-435a-4027-8a1a-ec0f30d5c170%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Disclaimer: This e-mail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you are not the intended addressee, or the person responsible for delivering it to them, you may not copy, forward disclose or otherwise use it or any part of it in any way. To do so may be unlawful. If you receive this e-mail by mistake, please advise the sender immediately.

karim.co...@innoviti.com

unread,
Aug 4, 2017, 12:58:16 PM8/4/17
to jPOS Users
Thanks Chill it works for me.

On Wednesday, August 2, 2017 at 8:12:37 PM UTC+5:30, chhil wrote:
To unsubscribe from this group and stop receiving emails from it, send an email to jpos-users+...@googlegroups.com.

To post to this group, send email to jpos-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/ba9e2e31-435a-4027-8a1a-ec0f30d5c170%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages