Author |
Message
|
Sboing |
Posted: Thu Jul 28, 2005 12:49 am Post subject: [newbe] problem in a esql loop |
|
|
Newbie
Joined: 28 Jul 2005 Posts: 2
|
Hello gurus,
I am trying to parse some specific xml structure to a copybook cobol. I have a problem when running this loop :
Code: |
SET A = 1 ;
WHILE (A <= CARDINALITY(InputBody.AutoTrieveREQ.PartyID[]))
DO
if ("InputBody"."AutoTrieveREQ".PartyID[A]."Tag" = 'BeneBank') THEN SET thePath = 'BEN_BNK_BIC'; end if;
if ("InputBody"."AutoTrieveREQ".PartyID[A]."Tag" = 'Sender') THEN SET thePath = 'SND_BIC'; end if;
if ("InputBody"."AutoTrieveREQ".PartyID[A]."Tag" = 'Ordering') THEN SET thePath = 'OBK_BIC'; end if;
if ("InputBody"."AutoTrieveREQ".PartyID[A]."Tag" = 'Originator') THEN SET thePath = 'ORP_BIC'; end if;
if ("InputBody"."AutoTrieveREQ".PartyID[A]."Tag" = 'Debit') THEN SET thePath = 'DB_PTY_BIC'; end if;
if ("InputBody"."AutoTrieveREQ".PartyID[A]."Tag" = 'Instructing') THEN SET thePath = 'INST_PTY_BIC'; end if;
if ( thePath IS NOT NULL )
then EVAL('SET OutputRoot.MRM.IN_PXER01.'|| thePath ||' = InputBody.AutoTrieveREQ.PartyID[A]');
end if;
SET thePath = NULL;
SET A=A+1;
END WHILE;
|
the problem I have is when I send a message with the xml tags :
Code: |
<PartyID Tag="Sender" Type="S">GEBADEFF</PartyID>
<PartyID Tag="BeneBank" Type="S">GEBAESMM</PartyID>
|
Only the tag Sender is parsed and writen to the copybook cobol output.
When I send the same but in reverse order like this :
Code: |
<PartyID Tag="BeneBank" Type="S">GEBAESMM</PartyID>
<PartyID Tag="Sender" Type="S">GEBADEFF</PartyID>
|
then I get the two elements well writen to the output.
anybody can help me ? |
|
Back to top |
|
 |
Sboing |
Posted: Thu Jul 28, 2005 1:09 am Post subject: |
|
|
Newbie
Joined: 28 Jul 2005 Posts: 2
|
hello, sorry for the previous message I have posted the wrong code , all the rest of what I have wroten is correct.
here is the correct code :
Code: |
SET A = 1 ;
SET thePath= NULL;
WHILE (A <= CARDINALITY(InputBody.AutoTrieveREQ.PartyID[]))
DO
SET thePath =
CASE
WHEN "InputBody"."AutoTrieveREQ".PartyID[A]."Tag" = 'BeneBank' THEN 'BEN_BNK_BIC'
WHEN "InputBody"."AutoTrieveREQ".PartyID[A]."Tag" = 'Sender' THEN 'SND_BIC'
WHEN "InputBody"."AutoTrieveREQ".PartyID[A]."Tag" = 'Ordering' THEN 'OBK_BIC'
WHEN "InputBody"."AutoTrieveREQ".PartyID[A]."Tag" = 'Originator' THEN 'ORP_BIC'
WHEN "InputBody"."AutoTrieveREQ".PartyID[A]."Tag" = 'Debit' THEN 'DB_PTY_BIC'
WHEN "InputBody"."AutoTrieveREQ".PartyID[A]."Tag" = 'Instructing' THEN 'INST_PTY_BIC'
END;
if ( thePath IS NOT NULL )
then EVAL('SET OutputRoot.MRM.IN_PXER01.'|| thePath ||' = InputBody.AutoTrieveREQ.PartyID[A]');
end if;
SET thePath = NULL;
SET A=A+1;
END WHILE;
|
|
|
Back to top |
|
 |
Mishimas |
Posted: Thu Jul 28, 2005 5:22 am Post subject: |
|
|
Novice
Joined: 30 Jun 2005 Posts: 12
|
nobody can help ? I fell out of ideas ,...
I have tried to replace the "case" by a lot of "if",
and also I have replaced the set xxx=null by set xxx = "value"
and the two solutions have not succeded,... |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Jul 28, 2005 5:28 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
I guess I'm not too clear on what the exact problem is...
But I wouldn't use
Code: |
if ( thePath IS NOT NULL )
then EVAL('SET OutputRoot.MRM.IN_PXER01.'|| thePath ||' =InputBody.AutoTrieveREQ.PartyID[A]'); |
I would maybe use OutputRoot.MRM.IN_PXER01.{thePath}. But really, I'd use a reference instead, and then have the case statement do a MOVE.
Or collapse it even more, and have a specific SET inside each case. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
Mishimas |
Posted: Thu Jul 28, 2005 5:50 am Post subject: |
|
|
Novice
Joined: 30 Jun 2005 Posts: 12
|
hello,
thank's for the response .
I don't understand what you say about a "case move" (I am very new with ESQL ).
The problem I have is that some times the loop doesn't write to the output when there is a corresponding field in the input.
By exemple when I have in entry <PartyID Tag="BeneBank" Type="S">GEBAESMM</PartyID> I should have in the output field "Ben_BNK_BIC" the value GEBAESMM.
But sometimes for some entry fields it is done and for others it is not done ,...
I will now try what you propose for replacing the "eval" instruction |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Jul 28, 2005 5:56 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Mishimas wrote: |
I don't understand what you say about a "case move" (I am very new with ESQL ). |
Well, really, I didn't say "case move", I said "have the case do a MOVE".
But the move wouldn't work until the child field was created, so don't worry about it.
The simplest thing to do is have something like
Code: |
CASE
WHEN "InputBody"."AutoTrieveREQ".PartyID[A]."Tag" = 'BeneBank' THEN set OutputRoot.MRM.IN_PXER01.BEN_BNK_BIC = InputBody.AutoTrieveREQ.PartyID[A]; |
and etc. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
Mishimas |
Posted: Thu Jul 28, 2005 6:17 am Post subject: |
|
|
Novice
Joined: 30 Jun 2005 Posts: 12
|
hello,
I tried :
Code: |
CASE "InputBody"."AutoTrieveREQ".PartyID[A]."Tag"
WHEN 'BeneBank' THEN set OutputRoot.MRM.IN_PXER01.BEN_BNK_BIC = InputBody.AutoTrieveREQ.PartyID[A];
WHEN 'Sender' THEN set OutputRoot.MRM.IN_PXER01.SND_BIC = InputBody.AutoTrieveREQ.PartyID[A];
WHEN 'Ordering' THEN set OutputRoot.MRM.IN_PXER01.OBK_BIC = InputBody.AutoTrieveREQ.PartyID[A];
WHEN 'Originator' THEN set OutputRoot.MRM.IN_PXER01.ORP_BIC = InputBody.AutoTrieveREQ.PartyID[A];
WHEN 'Debit' THEN set OutputRoot.MRM.IN_PXER01.DB_PTY_BIC = InputBody.AutoTrieveREQ.PartyID[A];
WHEN 'Instructing' THEN set OutputRoot.MRM.IN_PXER01.INST_PTY_BIC = InputBody.AutoTrieveREQ.PartyID[A];
END;
|
But I got : Statement are not allowed in CASE Statement. |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Jul 28, 2005 6:23 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Mishimas wrote: |
But I got : Statement are not allowed in CASE Statement. |
What you tried is semantically different than what I posted.
You tried a "simple" case, I posted a "searched" case.
Code: |
CASE
WHEN "InputBody"."AutoTrieveREQ".PartyID[A]."Tag" ='BeneBank' THEN set OutputRoot.MRM.IN_PXER01.BEN_BNK_BIC = InputBody.AutoTrieveREQ.PartyID[A];
WHEN "InputBody"."AutoTrieveREQ".PartyID[A]."Tag" ='Sender' THEN set OutputRoot.MRM.IN_PXER01.SND_BIC = InputBody.AutoTrieveREQ.PartyID[A];
WHEN "InputBody"."AutoTrieveREQ".PartyID[A]."Tag" ='Ordering' THEN set OutputRoot.MRM.IN_PXER01.OBK_BIC = InputBody.AutoTrieveREQ.PartyID[A];
WHEN "InputBody"."AutoTrieveREQ".PartyID[A]."Tag" ='Originator' THEN set OutputRoot.MRM.IN_PXER01.ORP_BIC = InputBody.AutoTrieveREQ.PartyID[A];
WHEN "InputBody"."AutoTrieveREQ".PartyID[A]."Tag" ='Debit' THEN set OutputRoot.MRM.IN_PXER01.DB_PTY_BIC = InputBody.AutoTrieveREQ.PartyID[A];
WHEN "InputBody"."AutoTrieveREQ".PartyID[A]."Tag" ='Instructing' THEN set OutputRoot.MRM.IN_PXER01.INST_PTY_BIC = InputBody.AutoTrieveREQ.PartyID[A]; |
_________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
Mishimas |
Posted: Thu Jul 28, 2005 6:40 am Post subject: |
|
|
Novice
Joined: 30 Jun 2005 Posts: 12
|
yes you are right.
I have now tested :
Code: |
CASE
WHEN "InputBody"."AutoTrieveREQ".PartyID[A]."Tag" ='BeneBank' THEN set OutputRoot.MRM.IN_PXER01.BEN_BNK_BIC = InputBody.AutoTrieveREQ.PartyID[A];
WHEN "InputBody"."AutoTrieveREQ".PartyID[A]."Tag" ='Sender' THEN set OutputRoot.MRM.IN_PXER01.SND_BIC = InputBody.AutoTrieveREQ.PartyID[A];
WHEN "InputBody"."AutoTrieveREQ".PartyID[A]."Tag" ='Ordering' THEN set OutputRoot.MRM.IN_PXER01.OBK_BIC = InputBody.AutoTrieveREQ.PartyID[A];
WHEN "InputBody"."AutoTrieveREQ".PartyID[A]."Tag" ='Originator' THEN set OutputRoot.MRM.IN_PXER01.ORP_BIC = InputBody.AutoTrieveREQ.PartyID[A];
WHEN "InputBody"."AutoTrieveREQ".PartyID[A]."Tag" ='Debit' THEN set OutputRoot.MRM.IN_PXER01.DB_PTY_BIC = InputBody.AutoTrieveREQ.PartyID[A];
WHEN "InputBody"."AutoTrieveREQ".PartyID[A]."Tag" ='Instructing' THEN set OutputRoot.MRM.IN_PXER01.INST_PTY_BIC = InputBody.AutoTrieveREQ.PartyID[A];
END CASE;
|
but I got the error : Syntax error : expected 'END' but found 'keyword Case'.
I have replaced END CASE; by END; but it don't seem to work too.
Maybe it is because I use the control center and not WBIMB ? In this version maybe the esql suported has not the case statement but only the case function ? |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Jul 28, 2005 6:43 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Mishimas wrote: |
Maybe it is because I use the control center and not WBIMB ? In this version maybe the esql suported has not the case statement but only the case function ? |
I think they introduced the searched case in a late CSD of 2.1, but yes this could be the problem.
You might not be able to use { } with 2.1 either - again, depending on the CSD level.
I think you will have to use IF statements.
Using EVAL as you did is unnecessary and will slow things down. The code might look prettier, but I don't think it's worth it.
Your employer should be in at least the planning stages for conversion to 5.0. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
Mishimas |
Posted: Thu Jul 28, 2005 6:57 am Post subject: |
|
|
Novice
Joined: 30 Jun 2005 Posts: 12
|
Thanks jefflowrey
now my code is :
Code: |
SET A = 1 ;
WHILE (A <= CARDINALITY(InputBody.AutoTrieveREQ.PartyID[]))
DO
IF "InputBody"."AutoTrieveREQ".PartyID[A]."Tag" ='BeneBank' THEN set OutputRoot.MRM.IN_PXER01.BEN_BNK_BIC = InputBody.AutoTrieveREQ.PartyID[A]; end if;
IF "InputBody"."AutoTrieveREQ".PartyID[A]."Tag" ='Sender' THEN set OutputRoot.MRM.IN_PXER01.SND_BIC = InputBody.AutoTrieveREQ.PartyID[A]; end if;
IF "InputBody"."AutoTrieveREQ".PartyID[A]."Tag" ='Ordering' THEN set OutputRoot.MRM.IN_PXER01.OBK_BIC = InputBody.AutoTrieveREQ.PartyID[A]; end if;
IF "InputBody"."AutoTrieveREQ".PartyID[A]."Tag" ='Originator' THEN set OutputRoot.MRM.IN_PXER01.ORP_BIC = InputBody.AutoTrieveREQ.PartyID[A]; end if;
IF "InputBody"."AutoTrieveREQ".PartyID[A]."Tag" ='Debit' THEN set OutputRoot.MRM.IN_PXER01.DB_PTY_BIC = InputBody.AutoTrieveREQ.PartyID[A]; end if;
IF "InputBody"."AutoTrieveREQ".PartyID[A]."Tag" ='Instructing' THEN set OutputRoot.MRM.IN_PXER01.INST_PTY_BIC = InputBody.AutoTrieveREQ.PartyID[A]; end if;
--- D'après les forums, l'instruction EVAL utilisée avant, est plutot lente et donc à éviter.
SET A=A+1;
END WHILE;
|
it is more compact but my error is still here ,... It compile and run on the broker, but I have still fields that are not converted and wroten to the copybook cobol |
|
Back to top |
|
 |
|