ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » ASCII to EBDIC for IMS

Post new topic  Reply to topic
 ASCII to EBDIC for IMS « View previous topic :: View next topic » 
Author Message
sudhi132
PostPosted: Tue Dec 02, 2014 6:46 am    Post subject: ASCII to EBDIC for IMS Reply with quote

Newbie

Joined: 02 Dec 2014
Posts: 1

CREATE PROCEDURE CopyEntireMessage() BEGIN
-- Using copyMessageHeaders to copying all the headers instead of InputRoot
-- SET OutputRoot = InputRoot;
DECLARE MSGLEN CHARACTER;
DECLARE NUMBER INTEGER;
DECLARE NUM INTEGER;
DECLARE RESULT INTEGER;
DECLARE REM INTEGER;



-- Set MSGLEN to non NULL to avoid errors when concatenating the first time
SET MSGLEN = 'X';

DECLARE inputMessage CHARACTER;
DECLARE inputMessageWithTxCode CHARACTER;
DECLARE outputMessage BLOB;


SET inputMessage = CAST ("InputRoot"."BLOB"."BLOB" AS CHARACTER CCSID 437);
SET inputMessageWithTxCode = 'FXMC RECV' || inputMessage;

SET outputMessage = CAST (inputMessageWithTxCode AS BLOB CCSID 500);


SET NUM = LENGTH(inputMessageWithTxCode);
SET NUMBER = NUM + 6;
--
-- Convert NUMBER to hexadecimal. The remainder of dividing by 16 is calculated recursively.
--
WHILE NUMBER > 15 DO SET RESULT = NUMBER/16;
SET REM = NUMBER - RESULT*16;
SET MSGLEN =
CASE
WHEN REM < 10 THEN CAST(REM AS CHARACTER) || MSGLEN
WHEN REM = 10 THEN 'A' || MSGLEN
WHEN REM = 11 THEN 'B' || MSGLEN
WHEN REM = 12 THEN 'C' || MSGLEN
WHEN REM = 13 THEN 'D' || MSGLEN
WHEN REM = 14 THEN 'E' || MSGLEN
ELSE 'F' || MSGLEN
END;

SET NUMBER = RESULT;
END WHILE;

SET REM = NUMBER;
SET MSGLEN =
CASE
WHEN REM < 10 THEN CAST(REM AS CHARACTER) || MSGLEN
WHEN REM = 10 THEN 'A' || MSGLEN
WHEN REM = 11 THEN 'B' || MSGLEN
WHEN REM = 12 THEN 'C' || MSGLEN
WHEN REM = 13 THEN 'D' || MSGLEN
WHEN REM = 14 THEN 'E' || MSGLEN
ELSE 'F' || MSGLEN
END;
--
-- Add leading zeros up to a length of 9 to be able to cast as BLOB.
-- Remember it started with MSGLEN set to X (length 1)
--SET MSGLEN = '1F';

WHILE LENGTH(MSGLEN) < 5 DO
SET MSGLEN = '0' || MSGLEN;
END WHILE;
--
-- Change to appropriate endian (PLATFORM DEPENDANT)
-- If no endian swapping needed then remember to get rid of the last character as below --
DECLARE MSGLEN1 CHARACTER;
SET MSGLEN1 = SUBSTRING(MSGLEN FROM 1 FOR 4);
DECLARE LLZZ CHARACTER;
SET LLZZ = MSGLEN1 || '0000';

DECLARE trailer CHARACTER;
SET trailer = 'FEFF';

SET "OutputRoot"."BLOB"."BLOB" = CAST(LLZZ AS BLOB) || outputMessage || CAST(trailer AS BLOB);



this is code for converting data from ascii to ebdic for ims. i have been finding answers for two questions for a while now.

1. why is num set number+6, i see num is also set to number+12 somewer else
2. why is msglen concatenated with 0000 to form llzz bytes
Back to top
View user's profile Send private message
zpat
PostPosted: Tue Dec 02, 2014 7:35 am    Post subject: Reply with quote

Jedi Council

Joined: 19 May 2001
Posts: 5866
Location: UK

How does IMS differ from other EBCDIC?

I am sure you can find a way in ESQL to avoid manually generating hexadecimal characters...!
_________________
Well, I don't think there is any question about it. It can only be attributable to human error. This sort of thing has cropped up before, and it has always been due to human error.
Back to top
View user's profile Send private message
Vitor
PostPosted: Tue Dec 02, 2014 7:46 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

zpat wrote:
I am sure you can find a way in ESQL to avoid manually generating hexadecimal characters...!




Why can't you just let broker handle the code page differences?
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » ASCII to EBDIC for IMS
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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.