Author |
Message
|
nheng |
Posted: Mon Aug 17, 2009 2:55 am Post subject: Substring fixlength msg error.Why? |
|
|
 Apprentice
Joined: 07 Dec 2007 Posts: 39
|
Messageflow description:------------------------------
InputNode: No fix format message domain
ResetContent Desciptor:Set blob format
Compute node:Substring of Fixmsg and propagate it each row.
Example Msg.---------------------------------------------------
82276920000077135933W FOUR P'S CLOTHING CO.,LTD.
COTTMCP09072184100345 I'M CURIO CO.,LTD.
82276920000077135933W PLz help me.
**Shotcut message
esql:---------------------------------------------------
DECLARE STR BLOB InputRoot.BLOB.BLOB;
DECLARE TMP BLOB InputRoot.BLOB.BLOB;
DECLARE CNT INTEGER 0;
DECLARE MAXINT INTEGER;
IF LENGTH(STR) > 200 THEN
SET MAXINT = LENGTH(STR) / 202;
IF MOD(LENGTH(STR),202) = 200 THEN
SET MAXINT = MAXINT + 1;-- Do on the last line
END IF;
ELSE
SET MAXINT = 0;
IF LENGTH(STR) = 200 THEN
SET MAXINT = 1;
END IF;
END IF;
WHILE CNT < MAXINT DO -- If it has EOL at the end of line use this method
CALL CopyMessageHeaders();
SET TMP = SUBSTRING(STR FROM (CNT*200) + (CNT*2) + 1 FOR 200);
SET OutputRoot.BLOB.BLOB = TMP;
PROPAGATE;
SET CNT = CNT + 1;
END WHILE;
RETURN FALSE;
---------------------------------------------------
Result:I will got only third line in output node
Please help me. |
|
Back to top |
|
 |
Luke |
Posted: Mon Aug 17, 2009 6:19 am Post subject: |
|
|
Centurion
Joined: 10 Nov 2008 Posts: 128 Location: UK
|
I'm struggling to determine exactly what your code is trying to do here.
Are these 200 byte records, separated by carriage return/line feed?
Why do you need to use the MOD function? The code seems over complicated to start with, so I'd try and simplify it if I were you. Get the length of the input, use a pointer for your FROM in the substring and increment it each time you loop until your pointer >= length of input.
Alternatively, maybe build a very simple TDS model with CR/LF as delimeter? Or even a CWF model?
If you have to do it manually, I'd re-write the code, then use trace or debug if you still have problems to see what's happening with your values.
Cheers |
|
Back to top |
|
 |
kimbert |
Posted: Mon Aug 17, 2009 10:34 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Please describe the format of your input message. |
|
Back to top |
|
 |
nheng |
Posted: Mon Aug 17, 2009 6:25 pm Post subject: hi |
|
|
 Apprentice
Joined: 07 Dec 2007 Posts: 39
|
kimbert wrote: |
Please describe the format of your input message. |
82276920000077135933W FOUR P'S CLOTHING CO.,LTD.
COTTMCP09072184100345 I'M CURIO CO.,LTD.
82276920000077135933W PLz help me.
This is input msg.Length of row equal 200 and plus 2( For enter charactor) |
|
Back to top |
|
 |
nheng |
Posted: Mon Aug 17, 2009 6:32 pm Post subject: |
|
|
 Apprentice
Joined: 07 Dec 2007 Posts: 39
|
Luke wrote: |
I'm struggling to determine exactly what your code is trying to do here.
Are these 200 byte records, separated by carriage return/line feed?
Why do you need to use the MOD function? The code seems over complicated to start with, so I'd try and simplify it if I were you. Get the length of the input, use a pointer for your FROM in the substring and increment it each time you loop until your pointer >= length of input.
Alternatively, maybe build a very simple TDS model with CR/LF as delimeter? Or even a CWF model?
If you have to do it manually, I'd re-write the code, then use trace or debug if you still have problems to see what's happening with your values.
Cheers |
This code can work without problem when the message hasn't single quote.
I know what do u try to tell mee about what do u think.But your answer not help anything.
Thank for help. |
|
Back to top |
|
 |
sebastianhirt |
Posted: Mon Aug 17, 2009 11:30 pm Post subject: Re: Substring fixlength msg error.Why? |
|
|
Yatiri
Joined: 07 Jun 2004 Posts: 620 Location: Germany
|
nheng wrote: |
Messageflow description:------------------------------
InputNode: No fix format message domain
ResetContent Desciptor:Set blob format
Compute node:Substring of Fixmsg and propagate it each row.
Example Msg.---------------------------------------------------
82276920000077135933W FOUR P'S CLOTHING CO.,LTD.
COTTMCP09072184100345 I'M CURIO CO.,LTD.
82276920000077135933W PLz help me.
|
The MRM (TDS) parser is your friend. Should make things somewhat easier. |
|
Back to top |
|
 |
kimbert |
Posted: Tue Aug 18, 2009 1:21 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
I know what do u try to tell mee about what do u think.But your answer not help anything. |
I think Luke's answer was very good. Either fix your code ( we are not going to do that for you ), or let the TDS parser take the strain. |
|
Back to top |
|
 |
|