cancel
Showing results for 
Search instead for 
Did you mean: 

Message mapping multiple files from one source based on content

elizabeth_stapleton
Participant
0 Kudos

Hi, Hopefully someone can help. I am working on PI7.1 SP20. I have a need to generate multiple files from a single source message based on the content of contractorCode. ECC->PI->Outbound to server location. The location and the communication component (system) for all these files is the same. So I only have a single set of ID, RD etc. I have worked through various blogs. My message mapping target is 1:unbounded. My operation mapping target is 1:unbounded. I have tried both receiver rules and local rules in my receiver determination - these fail with "no receiver could be determined". I have investigated the extended button in RD, but get "no suitable data found" when I try to attach the associated operation mapping. I have modified my mapping to contractorCode->SplitByValue(ValueChange)-> ns0:messages (ns0:messages being the extra root node that appeared when I changed my MM target to 1:unbounded). I would be grateful if someone could point me in the right direction. Many thanks, Elizabeth

View Entire Topic
Ryan-Crosby
Active Contributor

Hi Elizabeth,

Based on the payload sample you have supplied I see two issues that I have highlighted in this image. The first is that the source root XML node for the message does not match your message mapping and the second potential problem would be the existence of the ContractorCode with quotes included. I think those can be kept but the XPath condition would have to reflect that in the routing definition.

Regards,

Ryan Crosby

elizabeth_stapleton
Participant
0 Kudos

Hello Ryan,

Thank you for your input.

I tried ContractorCode both with and without quotes, neither made a difference 🙂

Root xml node - ok....I am an xml newbie I guess, so perhaps the next questions show that...

Before the requirement to split the output message into multiple files, the xml root matched the mapping (CONFPMActualsInformation). As soon as I modified the Signature tab to make it 1:unbounded, the nodes Messages and Message1 wrapped themselves around what I already had.

Question1 : So do I have to regenerate my target xml and import, with nodes Messages and Message1 included?

Question2: If so, am I still pointing my ContractorCode SplitbyValue & RemoveContext to CONFPMActualsInformation, or to Messages (or Message1)

Thanks in advance.

Elizabeth

Ryan-Crosby
Active Contributor
0 Kudos

Hi Elizabeth,

I wouldn't worry about the answers to your two questions just yet. The problem as I see it is that your message mapping has a source MessageType of "CONFPMActualsInformationOut" but the payload you have sent has "CONFPMActualsInformation" so you are missing the last three characters "Out". When the system attempts to determine what to do with the message the exact name of the root element must be exact and it is also case sensitive along with the fact that the proper namespace must be set for the root element. The result in your case is that the system is not able to match your source message up with any configuration in the system where it has an appropriate receiver which happens before any message mapping. A simple way to verify is to open the test tab of your message mapping in the ESR and copy/paste your payload into the frame and run it - if things are matching properly you will get a target message or otherwise you will observe a failure or no target message.

Regards,

Ryan Crosby

elizabeth_stapleton
Participant
0 Kudos

Hello Ryan,

After a bit of messing about, I have changed the source message name to match the payload. The other way round lead to the need to change the sproxy, which I want to avoid at this time.

Message mapping signature is still 1:unbounded

Source and Target Message type names match the payload - see attached

Context value still set up, receiver rules still in RD in integration builder (no double quotes)

Result is still a single file out, from the "If no receiver found" criteria

I tried loading my payload into the test tab in mapping, as you suggested, but I couldn't get past the message

The processing instruction target matching "[xX][mM][lL]" is not allowed

Which I've had on other occasions and managed to resolve somehow, so assume wasn't part of the issue I have now. Though I may be wrong.


I've tried changing the mapping to have the ContractorCode-SplitByValue-RemoveContext against the root Messages, Messages1 and CONFPMActualsInformation - individually. Just to remove that from my list of questions.

Oh and going from NW71 SP20 to NW71 SP21 made no difference.

Any further advice would be gratefully received.
Many thanks

Elizabeth

revisedmessagetype.png

Ryan-Crosby
Active Contributor
0 Kudos

Hi Elizabeth,

If you have your receiver determination setup to process values without quotes then you would also want to make sure the payload does not include double quotes for ContractorCode. In the message mapping tab you are not able to get the system to generate a target message? The one other question would be how many target messages you expect to get for a single ContractorCode value. From your example with value AR - if this value exists in the payload twice do you expect two unique target messages or only one?

Regards,

Ryan Crosby

elizabeth_stapleton
Participant
0 Kudos

Hi Ryan,

Ok from what you say, I'll try my latest version again with quotes in the RD rules, the data is ultimately comma separated and double quote delimited for text fields. I was assuming/hoping for one source message resulting in two target messages. One with all the ARs, and the other with all the SLSs. The resulting files will be getting (manually at this stage) loaded into another system. It may get a bit messy otherwise.

Correct, I failed to generate a test target message. I did a select-all in the payload, and pasted it into the target area under mapping/test but got the "processing instruction....not allowed" message when trying to run it. I've had this error before, but had thought that select-all fixed that, because it didn't pick up any white-space characters accidentally.

When is all said and done, I could have 2 message mappings, one for each - but I thought this would be a good learning curve, and be useful for other projects. I'll post my results when I've put quotes back round my RD rules.

Many thanks for your assistance

Elizabeth

Ryan-Crosby
Active Contributor
0 Kudos

Hi Elizabeth,

In the case of one message per ContractorCode then I would recommend something like the following for the mapping to the target message root node.

ContractorCode (Context at next highest level) -> sort -> CollapseContext -> Target Message Type

Regards,
Ryan Crosby

elizabeth_stapleton
Participant
0 Kudos

Hi Ryan,

I have updated the mapping as per your suggestion, with sort included.

I have also managed to manually create a small payload in the test tab, to try out the interface.

This has highlighted to me that logically, there is a problem with filenode/file name on the target structure. It caused an error (Values Missing in Queue Context) - which was only solved by me putting a constant to the target Filename, rather than mapping direct from source.

This issue was introduced by doing 1:unbounded under signature, as it worked in earlier versions.

I had hoped (!) that SAP would do something clever with the file name so that it could be used for all files, with a suffix number.

Anyway - I still have the problem of the whole lot coming out in one file. Sorry.

Elizabeth

messagemapping-10march.pngrd-10marchpng.png

Ryan-Crosby
Active Contributor
0 Kudos

Hi Elizabeth,

You could potentially use the useOneAsMany function to derive a number of file naming templates and then concat each template with a counter function result and then use splitByValue (each) on the target node assignment. Then, if you derive the file name from the variable substitution you would be able to create multiple specific file names as per your requirement.

Regards,

Ryan Crosby

Ryan-Crosby
Active Contributor
0 Kudos

FYI, I forgot to include the splitByValue (value change) after the sort so you would get one per unique ContractorCode.

Regards,

Ryan Crosby

Ryan-Crosby
Active Contributor
0 Kudos

Hi Elizabeth,

Here is a very simple example of what I was referring to - with all of the extra fields and stuff removed for simplicity.

source.txt

target.txt

elizabeth_stapleton
Participant
0 Kudos

Thanks for that Ryan,

that makes sense.

How would I put, for example, JobNumber back into that scenario, sorry to ask, but I've only done straight forward mappings before. I can see that where I have a source of 1 AR, 2 SLS, 3 AR, after the sorted example you provided they come out as 1 AR, 2 AR, 3 SLS. This is via the mapping test tab.

But even so, it isn't producing a file when I run it for real, its defaulting to the single file, unsorted, original file name.

I think we may be close to modifying the ABAP code, instead.

Again, many thanks for your help

Elizabeth

Ryan-Crosby
Active Contributor
0 Kudos

Hi Elizabeth,

For any fields at the same level as ContractorCode that you want to pass to the target you would have to use the sortByKey and give ContractorCode as the key while ensuring you have the sort parameters as the sort function. The file names should appear in the payload if you do something like what I have shared but the actual file writing would only work if you use variable substitution - you cannot use dynamic configuration for instance on a message split scenario.

Regards,

Ryan Crosby