Skip to Content
0

Message mapping multiple files from one source based on content

Feb 20, 2017 at 10:25 AM

399

avatar image

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

9 Answers

Best Answer
Ryan Crosby Mar 01, 2017 at 02:41 PM
1

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


capture.png (8.8 kB)
Show 12 Share
10 |10000 characters needed characters left characters exceeded

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

0

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

0

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

0

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

0

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

0

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

0

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

0

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

0

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

Regards,

Ryan Crosby

0

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

source.txt (628 B)
target.txt (637 B)
capture.png (28.2 kB)
0

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

0

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

0
Evgeniy Kolmakov Feb 20, 2017 at 10:31 AM
0

Hi Elizabeth!

Let's start with providing us your source structure and condition for receiver determination.

Regards, Evgeniy.

Share
10 |10000 characters needed characters left characters exceeded
Elizabeth Stapleton Feb 22, 2017 at 01:58 PM
0

Hello Evgeniy, I attach screen shots. The receiver rules do not work individually, the data comes out in a single file as per "if no receiver found, process as follows" Many thanks Elizabeth source.png receiverrules.png messagemapping.png


source.png (27.3 kB)
receiverrules.png (50.3 kB)
messagemapping.png (155.1 kB)
Share
10 |10000 characters needed characters left characters exceeded
Evgeniy Kolmakov Feb 22, 2017 at 02:18 PM
0

Hi Elizabeth!

First, if you want multiple messages to be produced at mapping output, map your ContractorCode element to your target message root node, not to Messages or Message1.

Second, use RemoveContexts function or change context of your ContractorCode elements to put it all in one context without context changes.

Regards, Evgeniy.

Share
10 |10000 characters needed characters left characters exceeded
Elizabeth Stapleton Feb 22, 2017 at 03:06 PM
0

Hi Evgeniy,
I have done that but it has made no difference
If the field contents are in quotes would that make a different to the receiver rule?

59601853,"AR","20160107967260001"

59601856,"SLS","20160107967261001"

the conditions are without quotes. Though I have tried it without

(ContractorCode = SLS)

I also attach a new screenshot of my mapping change you suggested. messgemapping2.png

Thanks in advance, Elizabeth


messgemapping2.png (34.0 kB)
Show 2 Share
10 |10000 characters needed characters left characters exceeded

Hi Elizabeth!

This sounds strange.

Wouldn't you please provide your source XML message?

Regards, Evgeniy.

0

pi-sample-output.txt
Hello Evgeniy,
I attach the payload from my most recent attempt out of PI sxmb_moni.

Thank you

Elizabeth

0
avatar image
Former Member Feb 22, 2017 at 04:36 PM
0

You can create Multi mapping to achieve this. Don't need to make any change at RD or Channel level.


Regards,

Nabendu.

Show 3 Share
10 |10000 characters needed characters left characters exceeded

Hello Nabendu,
I have 1 to unbounded in my message mapping. It didn't help
Thank you

Elizabeth

0
Former Member
Elizabeth Stapleton

Not in Message Mapping but at the "Signature" tab.

Regards,

Nabendu.

0

Hello Nabendu,

Yes Signature tab....within the mappingsignature.png

Regards

Elizabeth

signature.png (17.8 kB)
0
avatar image
Former Member Mar 01, 2017 at 02:21 PM
0

Hi Elizabeth,

Have you ever done 1:n mapping scenario complete end to end in this version before, if not could you please try it with some simple interface without any complex mapping and routing conditions.

I believe it is some patch issue for 1:n mapping .

Thanks,

Avinash

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Hello Avinash,

I have never done 1:n mapping in this way before. Since I raised this query, we have moved from NW7.1 SP20, to NW7.1 SP21. Perhaps that will make a difference. I have another message coming out similar to the one described. I'll try that 1:n without routing conditions and complex mapping, as you suggest. Though, I admit, I'm not sure what I expect it to do in that case.

Thank you

Elizabeth

0

Hello Avinash,

I have just tried doing 1:n mapping without any routing conditions. I borrowed another communication component. It looked like it would have done a second copy, but needed a new receiver agreement to work fully. Is that what you would expect? Using only the original communication component, even multiple times within the RD still only produces one copy. Seems a bit of a long winded way round to use multiple CComponents. Unless, as you say we have a patch issue.

Thanks for your input.

Elizabeth

0
avatar image
Former Member Mar 22, 2017 at 05:30 PM
0

Hi Elizabeth,

You are getting the error as "No Receiver could be determined", so you need to test your RD conditions with one line item first and then go for multiple items.

Place a file with 1 line item and don't change the MM or OM from 0-Unbound.

Please open the RD condition and show the XPATH exactly for both the conditions.

With Regards,

Nazeer

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Thanks Nazeer,

I have tried with XPATH and with Context Object
I have tried with single value, both expected values and also with a single line saying "where not equal to XX" (XX is not an expected value), including with and without quotes for each, and with ORs when I did a group statement (I did ANDs too, but got my logic sorted after that).

Attached screenshot is latest attempt with XPATH, where not equal XXxpath-example.png

This attempt is flagged to error if no receiver found - it doesn't error. A file comes out...but it is still the original single file, with the old file name, derived via ABAP rather than split and renamed within the mapping.

To be honest, we are now looking at doing this task in the abap program. Perhaps we don't have a compatible version for this function.

Thanks Elizabeth

0
Elizabeth Stapleton Mar 22, 2017 at 05:11 PM
0

Hi Ryan,

Yes, I've got that, I can see my sortbyKey working for the extra fields - great.

We do have variable substitution for the file names already. But I can see via the payload that the FileName tag is retaining the old version of the file name JobCosts..... (from the ABAP program) rather than taking the new version SomeFileNameAR that I derive from the mapping you suggested. The new file name IS WORKING when I run in test mode via the mapping/test tab. Any suggestions for that please?

I am not sure how that can be, because my mapping no longer maps source to target for FileNode/FileName.

I attach screen shots. So near and yet so far.... It's driving me mad. Its obviously something stupid. Is there a cache I can refresh to make sure I am using the latest mapping? Thanksfilename-variablesubstitution.png


Show 2 Share
10 |10000 characters needed characters left characters exceeded

Hi Elizabeth,

The payload is going to show the message payload before mapping by default - at least it does in our version of the system and I believe it did also when we were on dual stack 7.11. In order to show the values of the payload after your mapping you would have to alter the configuration to show either that message mapping or that version in addition to the default version.

Regards,

Ryan Crosby

0

Thanks Ryan for your assistance. Most useful

0