Urgent Plz nested arrays in XML

I have a temp record list having two records with structure like
tmp2
–text
–amt
my xml is having nested array structure like

<parent1>
–<parent2>
–text
–amt
–vat
–subtot

so i’m trying to loop at /tmp2 (in-array)
(out-array = /parent1/parent2)
inside a map i’m mapping those text and amount fields but it’s not creating parent2 node at all

Kindly shower ur valuable inputs…
awaiting ur replies…
-SK

Sreedhar,

The loop you set will not work.since parent2 will not seen as a record inside the loop and ultimately parent2 node will not be created as expected.

But if parent1 is a record and parent2 is a Array then your loop will definetely work.

So you have to use appendToRecordList since the parent1 and parent2 both are nested record lists.

I believe you know before how to use this append service.

HTH,
RMG

Sreedhar,

Another way to do this would be to delete your references to parent 1 and parent 2 (including within the loop). Then create a temporary record structure for parent1 and parent 2 and set some dummy values for text and amt. Make sure define more than 2 values for parent 2 to ensure that webMethods treats this as record list. This step should exist before your loop. Then specify your loop, in array and out array and then map the values. After you have done this, delete the step where you have assigned temp values for parent 1 and parent 2. Then it will work.

The reason you are getting the error is that, simply by putting parent 2 in the out array will not mean that wM will treat this as a list. So all this work around of first defining the temp values.

-Rajesh Rao

Thanks RMG. It worked

Rajesh - I couldn’t understand you. Could you pls explain further ? though i got it worked thru’ RMG’s input, i just want to know ur input aswell…

Thanks
Sreedhar Kurella

Sreedhar,

Like what I already have explained,

Delete all references to parent 1 and parent 2 record structures. This means delete all the steps which refer to this record structure.

Add a map step (Step 1). Create a record structure for parent1 and parent 2 and set some (dummy) values for text and amt.

Then add the loop step after the previous map step.

Specify the in array and out array.

Add a map step within the loop. In this map step map the appropriate variables. (From tmp2 to Parent 2)

Then delete the map step 1, where you have specified dummy values for parent 2.

Hope it is more clearer now.

-Rajesh Rao

Sreedhar,

Glad it worked…

Regards,

hey,

appendToRecordlist worked fine and after that i’m trying to convert to XML through recordToDocument with following parameters :

Incoming invoice structure to boundnode
addHeader – false
encode – true
recordName – Record.XMLSchemas:Invoice (correct path)
generateReqTags – true

and after this i’m concatenating the XML header manually with header as <?xml> , just to include that encoding ISO stuff.

but in the xmldata hasn’t got lineitems which are in boundNode and Invoice structure aswell…! Could you please tell me why those line items are getting stripped off…?

Thanks
Sreedhar Kurella

Sreedhar,

Looks like your recordReference mapped from the boundNode is messing up,please check whether the Record.XMLSchemas:Invoice structure is matching with the boundNode in the pipeline.

Also try unsetting generateReqTags = true and step thru the recordToDocument.

And there is some easier way to include XML header with encoding other than concatenating.(create the @encoding in the Document Namespace properly.You must add in the same level as root element of your document. So you can set @encoding in a map of your service, before convert document boundNode to xmldata. This you do like any other element of your document namespace)

let us know the difference and if possible upload a screen shot of the the recordToDocument Step.

HTH,
RMG

RMG,

As you advised, i deleted the SET VALUE for generateReqTags … and following are the line items :

  &#60;invbody&#62; 
    &#60;details&#62; 
      &#60;linedata/&#62; 
      &#60;linedata/&#62; 
    &#60;/details&#62; 
  &#60;/invbody&#62; 

but when I set it to TRUE implicity, the same line items are as follows :

  &#60;invbody&#62; 
    &#60;details&#62; 
      &#60;linedata&#62; 
        &#60;text&#62;&#60;/text&#62; 
        &#60;amount&#62;&#60;/amount&#62; 
      &#60;/linedata&#62; 
      &#60;linedata&#62; 
        &#60;text&#62;&#60;/text&#62; 
        &#60;amount&#62;&#60;/amount&#62; 
      &#60;/linedata&#62; 
      &#60;vatperc&#62;&#60;/vatperc&#62; 
      &#60;vatamt&#62;&#60;/vatamt&#62; 
      &#60;subtot&#62;&#60;/subtot&#62; 
    &#60;/details&#62; 
  &#60;/invbody&#62; 

I have screenshots of recordtoDocument and contents of boundNode after the execution of recordToDocument service.
Couldn’t upload those doc as it 's exceeding 70 kb…

RMG - i’m sending it to your email id. Hope you don’t mind…

Pls let me know your views…

Thanks
Sreedhar Kurella

Sreedhar,

The behaviour of generateReqTags is if you want to include empty tags in the xmldata say <vatamt></vatamt> etc… which are mandatory in the document structure then you set to True,otherwise set False.Its upto your target requirement.

And i have noticed in your screen shot (uploaddoc1) that Roottag of boundNode/Billing but it should be boundNode/Invoice right?

This might be the reason that it is not showing line details in the xmldata.So the recordName(Record.XMLSchemas:Invoice) you have set is not matching with the boundNode and ultimately xmldata is messing up.

Please

RMG,

the record name is ‘Invoice’ but the root tag of that record is ‘Billing’ only.

i.e. when i generated the record from XML Schema, i named the record as ‘Invoice’ but the root tag as per the schema is ‘Billing’.

Need further inputs…pls
thakns
Sreedhar K

So you mean record structure is Invoice/Billing and this is mapping to boundNode.

still wondering what could be the reason of not showing line details in the output xmldata,since everything looks fine in the mapping recordToDocument step as per your clarification.

If possible mail me ur package i have to look into it.

Sorry for this delay resolution.

HTH,
RMG

Hi all,

Just to let you all know that i’m still stuck with this problem… i’ve been trying to debug and find out but invain …
any inputs would be very very helpful.
Thanks in advance
Sreedhar K

Guys,
it worked…
guess what change i did ?
I removed the ‘recordName’ value for recordToDocument service… Proving MURPHY’s law

donno why it’s working, but it is…

COULD YOU TELL ME HOW RELIABLE TO USE THIS SERVICE IN THIS WAY ?? ANY DOWNSIDES PLS???

Thanks once again
Sreedhar K

Sreedhar,

Its wierd that removing recordName worked as expected,since setting this recordName helps for wellformat,structuring the xmldata based on the record layout.

I believe there should be some extra stuff coming in the mapping of Invoice struture which is breaking detail structure and that could be missing in the record structure which recordToDocument parses referencing with recordName.

Anyways it worked go a head with further processing.

Regards,
RMG