Mapping record to recordlist

Hi,
I am receiving a recordlist as input and then I am mapping it into another recordlist.
But, when input list contains only one record, I can not map the data with recordlist. If there are multiple line items mapping will work correctly.
I am mapping sales order line items.

Let me know ASAP.
Thanks,
Prasanna

Prasanna

you’ll need to determine if its a record or recordList.

read [url=“wmusers.com”]wmusers.com

in particular the use of pub.list:sizeOfList or pub.list:appendToRecordList.

If these don’t help you can always use a java frag that returns the type of the variable in your pipeline as a string description (ie. “Record” or “RecordList” in your case). Branch based on the result.
You would pass in the NAME of your variable to this java service and it would retrieve this named variable from the pipeline as follows:

String variableName = IDataUtil.getString(pipelineCursor, “variableName”);
Object object = IDataUtil.get(pipelineCursor, variableName);
if (object instanceof IData) type = “Record”;
else if (object instanceof IData) type = “RecordList”;

etc

regards

Hello
Thanks for ur immediate reply.But still theres a following problem.

We tried out giving the same but its not giving size of list.
In fact we are trying to map XML structure of Sales Order with BAPI structure of SALES ORDER.

For multiple records things r working fine and the material is getting mapped properly but when we r passing single line item its not mapping line item properly.

Waiting for ur reply.

Thanks And Regards

Prasanna Laddha

This depends on how you create the Sales Order record. When you create the record, you have to specfiy which are the items that you want as record lists.
Have you done this?
Thanks

Let me take a stab at this.
You’re probably using a loop to loop thru the list but when your flow returns a record the loop gets skipped because it’s not a list.

Try using this java code on your record.
Inputs:
— input (recordList)
Outputs:
— inputlist (recordList)

public static final void checkAndConvertToRecordList( IData pipeline ) throws ServiceException
{
IDataCursor idcPipeline = pipeline.getCursor();
IData inputList = IDataUtil.getIDataArray( idcPipeline, “input” );
if(inputList==null){
inputList = new IData[1];
inputList[0] = IDataUtil.getIData( idcPipeline, “input” );
}
IDataUtil.put(idcPipeline,“inputList”,inputList);
return;
}

HTH

But you dont have to write custom code if you have a record that has a record list in place. when you create the record using document to record, you can specify the record list name and this will automatically create a record list even if there is only one record.
Thats how this should work if you have a valid record structure.
If you are creating a record structure on the fly, Chris’s method is great.
Good Luck

Hello VR
This is our flow.

stringToDocument(Converting XML data to document)
documentToRecord
Map(Bound node contains Line Item record(not recordList))

If we pass one item record gets created in LineItem but when we pass multiple Line items record list is getting created.
But when we r checking sizeOfList both cases its giving 1

Again when bound node contains LineItem as record list it works fine for multiple line items but failing for single line item.

Any solution for this.How should we proceed?

Waiting for ur reply.

Thanks ANd Regards

Prasanna laddha

Hi, Prasanna.

Your problem may be in the mapping of the Bound Node, too. VR and Chris are making good points, but be sure to rule out the map of the Bound Node to a Record/Record List.

Search the Discussion Forums for “Bound Node” and see if anything matches your requirements. In [url=“wmusers.com”]wmusers.com, there is a good description of Bound Nodes, too.

Good luck.

This depends on how you might want to proceed.

  1. In future, would you guys be processing record lists?

If you guys will be processing record lists, we should go this way.
When you create the document to record, input value “false” in the makeArrays field and specify the recordName. If you have the correct record structure in your webMethods server, even if the xml has only one line item, the record is created as a record list. (If the actual record has record list in its structure). Map this bound node to the actual record list.
Then in your flow you should do
StringToDocument
DocumentToRecord (Here is where you should map the boundNode to the actual record structure and even drop the bound node)
loop over recordList (actual record, not bound node)

This is all given in the developers guide. Reading that should really help you in getting your flows in place.
Good Luck!

Hi
Yes we want to loop at Line items and map them to BAPI line items.
I tried what suggested by u but it could’nt find the record name(we created a new record which contains a record list but it could’nt find that record).We had given record name as record list name as well as record name.In both the cases its giving the same run time error.

Waiting for ur reply.

Thanks And Regards

Prasanna

Hi,
This is a bit confusing.
Are you using SAP Business Connector?
Thanks

Hi Parsana
Venkat is right.Give the record name in documentToRecord service. Give it like foldername:recordname. If you dont have the record structure then you can use the Arrays element of documentToRecord service.In this element pass whatever you want to be a recordlist like Item Detail.
Hope this will help
Ajay Arora

Hi v,
I am using SAP Business Connector. u r right.
But, I hope things must be quite similar as it is also developed by webMethods.

Let me know if u have an idea ASAP.
PRASANNA

Hi Ajay,
I had one main record, which contains 2 more records and a recordlist in it.

I am facing problem with recordlist.
So as per you do I need to create a record in a folder which will have same name as recordlist and will contain a recordlist inside with same name as record created?

Please check this and help to come out of this cycle of problems.
Waiting…
Prasanna

Hi Ajay/venkat,
In bound node I had main record. This main record contains a recordlist inside it.
So, in recordname property-

  1. do I need to give folder name:name of my record which i am inserting as bound node.
    Or
  2. do I need to give folder name:name of recordlist present inside my main record.

I mean what should be the record name property value? should it be repearing record name or main record name which inside it contains recordlist.

Please let me know urgently.
Thanks,
Prasanna.

In the SAP business connector, there is a conformsTo parameter where you should give the record name. You have to give the name of the IDOC structure here.

Perhaps walking through an example will help clarify things. Assuming the following record definition:

MyFolder:MyRecord
…SubRec1 (record)
…Fld1.1
…Fld1.2
…SubRec2 (record)
…Fld2.1
…Fld2.2
…SubRecList1 (record list)
…Fld3.1
…Fld3.2

When you receive an XML doc that supposedly conforms to the definition of MyFolder:MyRecord, you invoke:

pub.web:stringToDocument
…receivedString –> xmldata
…do not set/map to $filedata
…do not set/map to $filestream
…set encoding if desired
…do not set/map to expandDTD
…set isXML to ‘true’

Map the output variable named node to any pipeline variable or just let it default to being in the pipeline as ‘node’.

Then invoke:

pub.web:documentToRecord
…output node from stringToDocument –> node
…do not set/map to attrPrefix
…do not set/map to arrays
…set makeArrays to false
…do not set/map to collect
…do not set/map to nsDecls
…do not set/map to records
…set recordName to MyFolder:MyRecord
…do not set/map to mixedModel

Map the output variable named boundNode to a variable that is a record reference to MyFolder:MyRecord and drop boundNode. The pipeline will now have a properly structured record, with a record list even when only one record is present in the XML string SubRecList1 list.

Note that the recordName parameter for documentToRecord is the fully-qualified name of your full record. Do not use the name of any sub-records.

If this doesn’t help, perhaps you can post the fully-qualified name of your record definition, a snippet of the XML that you’re trying to process, and the parameters you’re passing to documentToRecord and we can figure what’s happening.

Hello Everybody

Thanks for ur co-operation.
We tried out making makeArray as False and giving recordName.
Atleast its creating the ArrayList also with one record and not giving any kinds of exception.

But when we r checking the sizeofList its always giving as 0 no matter how many items we r passing.

Even we tried to loop on the list but it was not going inside the loop.
What can be the possible reason 4 the same?

Desperately Waiting for reply.

Thanks And Regards

Prasanna Laddha
Software Engineer

Prasanna,

Another stab in the dark.
If you made changes to the record or the loop but you mapping links remained untouched during this process, unmap and remap within the loop.

wm has some peculiarites if you make changes and the links in the map are already in place. It will look right visuall but will not execute. Unmap, click another statement, go back to map and remap.

Good Luck!

>Even we tried to loop on the list but it was not going inside >the loop. What can be the possible reason 4 the same?

This could be becoz the record structure is not being mapped correctly. Are you trying to create an IDoc record? Just check the data that you pass to the flow and make sure that you are trying to loop over the record list (check that the in-array name matches the record name)

And try not to worry, As a last step I have a flow that does an IDoc mapping. I will send the sample flow if nothing else works.

Hope you crack this. Have a great day!