App Connect

App Connect

Join this online user group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  Creating 2D Array using ESQL

    Posted Tue May 12, 2020 11:06 AM
    Hi There,

    I was wondering if there is a way to output 2D array in message assembly through Compute node using ESQL ?

    I am able to find an example of append an element of 1D array in output but not 2D element.

    Thanks,
    Savita

    ------------------------------
    Savita Patil
    ------------------------------


  • 2.  RE: Creating 2D Array using ESQL

    Posted Tue May 12, 2020 11:26 AM
    Please could you paste the output message you are aiming for ... this would enable us to interpret precisely what you mean  by "2D array", and then advise on the required ESQL.

    ------------------------------
    Ben Thompson
    IBM UK
    ------------------------------



  • 3.  RE: Creating 2D Array using ESQL

    Posted Wed May 13, 2020 12:58 AM
    Edited by Savita Patil Wed May 13, 2020 02:43 AM
    Hi Ben,

    Thanks for your reply. 
    I want something like this-
    <Array civ:size="2"><Array civ:size="3" civ:index="0"> <Data civ:index="0">Hello 1</Data> <Data civ:index="1">Hello 2</Data> <Data civ:index="2">Hello 3</Data> </Array> <Array civ:size="3" civ:index="1"> <Data civ:index="0">String 1</Data> <Data civ:index="1">String 2</Data> <Data civ:index="2">String 3</Data> </Array></Array> 

    Thanks,
    Savita


    ------------------------------
    Savita Patil
    ------------------------------



  • 4.  RE: Creating 2D Array using ESQL

    Posted Wed May 13, 2020 05:10 AM

    Hello,

    The following could be used.
    Can you share the example that you found for the 1D and perhaps I might provide a similar example for the 2D.

    DECLARE ptrArray REFERENCE TO OutputRoot;
    CREATE LASTCHILD OF ptrArray AS ptrArray TYPE Name NAME 'Array';

    DECLARE ptrData REFERENCE TO OutputRoot;
    CREATE LASTCHILD OF ptrArray AS ptrData TYPE Name NAME 'Array';
    CREATE LASTCHILD OF ptrData TYPE NameValue NAME 'Data' VALUE 'String 1';
    ...

    CREATE LASTCHILD OF ptrArray AS ptrData TYPE Name NAME 'Array';
    CREATE LASTCHILD OF ptrData TYPE NameValue NAME 'Data' VALUE 'Hello 1';
    ...



    ------------------------------
    Pierre Richelle
    IBM Hybrid Cloud Integration Specialists
    IBM
    bruxelles
    0474681892
    ------------------------------



  • 5.  RE: Creating 2D Array using ESQL

    Posted Thu May 14, 2020 03:55 AM
    Hi,

    Thank you for your help. I am able to create the esql for 2-D array by taking hints from your response.

    Thanks and Regards,
    Savita

    ------------------------------
    Savita Patil
    ------------------------------



  • 6.  RE: Creating 2D Array using ESQL

    Posted Wed May 13, 2020 06:13 AM

    I think we need a complete input and output message to understand what you try to achieve.
    ESQL as usual the namespace civ may create additional work.



    ------------------------------
    Matthias Jungbauer
    ------------------------------



  • 7.  RE: Creating 2D Array using ESQL

    Posted Wed May 13, 2020 05:49 PM
    This may be helpful (similar to Pierre's suggestion but using a loop and showing how to do the namespaces)
    		CALL CopyMessageHeaders();
    		DECLARE civ NAMESPACE 'www.ibm.com';
    		DECLARE OuterArraySize INTEGER 2;
    		DECLARE InnerArraySize INTEGER 3;
    		CREATE LASTCHILD OF OutputRoot DOMAIN('XMLNSC');
    		DECLARE OuterCounter INTEGER 1;
    		DECLARE InnerCounter INTEGER 1;
    		SET OutputRoot.XMLNSC.Array.(XMLNSC.NamespaceDecl)xmlns:"civ" = 'www.ibm.com';   
    		SET OutputRoot.XMLNSC.Array.(XMLNSC.Attribute)civ:size = OuterArraySize;
    		WHILE OuterCounter <= OuterArraySize DO
    			SET OutputRoot.XMLNSC.Array.Array[OuterCounter].(XMLNSC.Attribute)civ:size = InnerArraySize;
    			SET OutputRoot.XMLNSC.Array.Array[OuterCounter].(XMLNSC.Attribute)civ:index = (OuterCounter-1); 			 
    			WHILE InnerCounter <= InnerArraySize DO
    				SET OutputRoot.XMLNSC.Array.Array[OuterCounter].Data[InnerCounter] = 'Hello ' || CAST(InnerCounter AS CHAR);
    				SET OutputRoot.XMLNSC.Array.Array[OuterCounter].Data[InnerCounter].(XMLNSC.Attribute)civ:index = CAST((InnerCounter-1) AS CHAR);				
    				SET InnerCounter = InnerCounter + 1;
    			END WHILE;
    			SET OuterCounter = OuterCounter + 1;
    			SET InnerCounter = 1;
    		END WHILE;​


    ------------------------------
    Ben Thompson
    IBM UK
    ------------------------------