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 » Parse a BLOB for 0d0a (CR/LR)

Post new topic  Reply to topic
 Parse a BLOB for 0d0a (CR/LR) « View previous topic :: View next topic » 
Author Message
shediiwork
PostPosted: Tue Jun 28, 2005 12:35 pm    Post subject: Parse a BLOB for 0d0a (CR/LR) Reply with quote

Acolyte

Joined: 07 Jun 2005
Posts: 52

I am trying to use a compute node to parse a BLOB and Propagate message bases on the parsing. I have a fixth width input(33) but '0d0a' is not consistantly in the same position. Does anyone see the obvious or have a better way of doing this?


----code---
CREATE COMPUTE MODULE difms_resp_SHOP_parser
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
CALL CopyMessageHeaders();

DECLARE record BLOB;
DECLARE reclength INTEGER;
DECLARE cursor INTEGER;

SET reclength = 35;
SET cursor = 0;

SET OutputLocalEnvironment.This.FirstRet = TRIM(SUBSTRINGInputRoot."BLOB"."BLOB" from 33 for 2));

SET record = TRIM(SUBSTRING(InputRoot."BLOB"."BLOB" FROM cursor FOR 33 ));

SET OutputRoot."BLOB"."BLOB" = record;
WHILE record <> '0d0a' DO
PROPAGATE;
CALL CopyMessageHeaders();
SET cursor = cursor + reclength ;
-- This OutputLocalEnvironment NEVER sits
SET OutputLocalEnvironment.This.SecRet = TRIM(SUBSTRING(InputRoot."BLOB"."BLOB" from 33 for 2));

--SET record = TRIM(SUBSTRING(InputRoot."BLOB"."BLOB" FROM cursor FOR 33 ));
SET record = '0d0a';
SET OutputRoot."BLOB"."BLOB" = record;
END WHILE;
CALL CopyMessageHeaders();
-- EOF 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' in HEX.
SET record = '585858585858585858585858585858585858585858585858585858585858585858';
SET OutputRoot."BLOB"."BLOB" = record;

RETURN TRUE;
END;
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue Jun 28, 2005 12:46 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

I think you want the POSITION function.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
shediiwork
PostPosted: Tue Jun 28, 2005 1:36 pm    Post subject: Reply with quote

Acolyte

Joined: 07 Jun 2005
Posts: 52

I think too but I don't know how to use it
Back to top
View user's profile Send private message
JT
PostPosted: Tue Jun 28, 2005 1:43 pm    Post subject: Reply with quote

Padawan

Joined: 27 Mar 2003
Posts: 1564
Location: Hartford, CT.

Have you reviewed the documentation on the POSITION function?

The samples provded are extremely clear on how to use the function.
Back to top
View user's profile Send private message
shediiwork
PostPosted: Sat Jul 23, 2005 12:39 pm    Post subject: My Final Answer Reply with quote

Acolyte

Joined: 07 Jun 2005
Posts: 52

CREATE COMPUTE MODULE difms_resp_SHOP_parser
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
CALL CopyMessageHeaders();

DECLARE record BLOB;
DECLARE reclength INTEGER;
DECLARE cursor INTEGER;
DECLARE BLOBLENGTH INTEGER;
DECLARE CRLR BLOB;
DECLARE RTN BOOLEAN;
DECLARE ncursor INTEGER;
DECLARE vreclength INTEGER;

SET CRLR = '0a';
SET reclength = 33;
SET cursor = 0;
SET ncursor = POSITION ( CRLR IN InputRoot."BLOB"."BLOB" from cursor) + 1;
SET BLOBLENGTH = LENGTH(InputRoot."BLOB"."BLOB");
SET record = TRIM(SUBSTRING(InputRoot."BLOB"."BLOB" FROM cursor FOR reclength ));
SET OutputRoot."BLOB"."BLOB" = record;
SET vreclength = (ncursor - cursor) - 1;
SET RTN = TRUE;
--verify each line size is correct
lsize: WHILE ncursor < BLOBLENGTH DO
IF vreclength <> 34 THEN
THROW USER EXCEPTION CATALOG 'LsizeException' MESSAGE 100 VALUES(
'Line Size Exception occurred during ', Environment.Variables.CURRENTNODE,'Message: <message>');
SET RTN = FALSE;
LEAVE lsize;
END IF;
SET cursor = POSITION ( CRLR IN InputRoot."BLOB"."BLOB" from cursor) + 1;
SET ncursor = POSITION ( CRLR IN InputRoot."BLOB"."BLOB" from cursor) + 1;
SET vreclength = ncursor - cursor;
END WHILE lsize;

SET cursor = 0;

-- First line of Defense
IF (RTN) THEN
WHILE cursor < BLOBLENGTH DO
-- Double Wrap Protection
IF RTN <> FALSE THEN
PROPAGATE;
END IF;
CALL CopyMessageHeaders();
SET cursor = POSITION ( CRLR IN InputRoot."BLOB"."BLOB" from cursor) + 1;
SET record = TRIM(SUBSTRING(InputRoot."BLOB"."BLOB" FROM cursor FOR 32 ));
SET OutputRoot."BLOB"."BLOB" = record;
END WHILE;

CALL CopyMessageHeaders();
--EOF 'XXXXXX' in HEX.
SET record = '585858585858';
SET OutputRoot."BLOB"."BLOB" = record;
END IF;


RETURN TRUE;

END;

END MODULE;
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 » Parse a BLOB for 0d0a (CR/LR)
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.