cancel
Showing results for 
Search instead for 
Did you mean: 

Message Mapping Create message only when condition is met??

Former Member
0 Kudos

Hello Experts,

Source Message

HDR

Name

MainMeasure

DTL

Measure

Serial

Target Message

Message1

Name_target

Serial_target

Mapping

Name maps directly to Name_target

If MainMeasure = Measure then Map Serial to Serial_target

File that comes in is a flatfile

HDR001 ProdName1 EA 000001

DTL001 ProdName1 CS 000002

DTL002 ProdName1 EA 000003

DTL003 ProdName1 EA 000004

When I map i only want it to map DTL002 and DTL003 because that is the only instance where MainMeasure = Measure. So it should only create if the condition is met for serial.

Currently I get both

Just the CS one has no serial.

Any help is appreciated.

Chirag

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Source Message

HDR 1

Name

MainMeasure

DTL ---1..unbounded

Measure

Serial

Target Message

Message1

Name_target

Serial_target

MainMeasure--


equals
createIf
-Message1

Measure--removeContext

MainMeasure--


equals
IfWithoutElse
----

/ then map Name to Name_Target

Measure--removeContext

for Serial source node also same as above intead of name map Serial source to target fields accordingly

Thanks and Regards,

Kubra fatima

Former Member
0 Kudos

Thanks Everyone for the responses.. i tried all the methods explained above but still have a problems

Rita - Tired this before, Get an error because the first DTL is CS. Works if the first DTL is EA.. but that means it never looks at 2nd DTL.

Sweta - Is this the same as doing it graphical. Basically instead of checking MainMeasure = Measure.. you are storing it in a variable? Also It wont look at DTL until it already has mapped 'Name' If it Maps name then I will get data without Serials.

Pavan - I already have in place.

Kubra - I tried this method but i am getting a mapping exception error when DTL is CS first.

Error - <SAP:P3>RuntimeException in Message-Mapping transformatio~</SAP:P3>

Former Member
0 Kudos

So I am still struggling with the problem.

Since CS is the first DTL it fails in Graphical test mode and also when i run it through entirely in XI.

I think I can do this with XSLT but I really want to avoid going that route.

Thanks in advance.

former_member581827
Participant
0 Kudos

Hi Chirag,

Have you used if main measure equals function(Text) to measure then serial should be mapped to serial_target else send blank to serial_target.

we need to use if function under boolean function.

Regards,

Chandra

Former Member
0 Kudos

Chandra thanks for the reply,

I dont want to map a blank field to it. I dont want it to create the message if the HDR mainmeasure doesnt = DTL measure.

Thanks

Chirag

Former Member
0 Kudos

So what i explained was a narrowed down version of this

First Image is Graphical Mappin

http://i9.photobucket.com/albums/a68/tkc204/mapping_details.png

Image 2

Is the Mapping at the Message. This is the part that is causing the issue when the HDR Measure isnt the same as the DTL Measure.

http://i9.photobucket.com/albums/a68/tkc204/message.png

Image 3

Mapping of serial number

http://i9.photobucket.com/albums/a68/tkc204/gtin.png

I tried going with XSLT but i ran into a problem comparing two elements.

Former Member
0 Kudos

Hi,

As per your source and target structure screen shot you should do the mapping like below.

1.MT_MaterialIn_custom structure is (1-Unbounded). Because depending up on the detail record you are creating the target.

Mapping:

1.MainUOMUseOneAsManyEqualsS-RemovecontextCreateIf---MT_MaterialIn_custom

DETAIL -- UOM--

UOM --

2.ProductUseOneAsMany-Product

Detail --

UOM --

What are the header field you having you should map the target with UseOneAsMany function.

3.GTN--GTN.

For Detail Records directly map to the target.No need of any conditions.

Regards,

Prakasu.M

Former Member
0 Kudos

Prakasu.. after further investigation I got your method to work.. Inside Test mode in the IR. but once its run through XI it fails.

Then i review it and made a few tweaks, and it works, thanks so much for the help

Much Apperciated.. Only been developing in XI for 2 months. And I'm the primary develop/support for it

Answers (4)

Answers (4)

vijay_b4
Active Contributor
0 Kudos

Hi Chirag,

Try this......

Add 2 variables(var1 and var2) under target node.

right click on the target node - select add variable.

In var1, save the output of the Mainmeasure.(direct mapping Mainmeasure to var1)

In var2,save the output of the Measure(direct mapping Measure to var2)

Now if var1 = var2 then map serial to serial_target.

if serial_target occurence is 1.1, if the above mapping fails,it will throw an error.else it wont.

to solve that error, you can map else mapwithdefault() in the nodefunctions.

Please let me know if want any more details.

Thanks & Regards,

Pragathi.

Former Member
0 Kudos

I don't think I can do that I don't have that functionality. I am running XI 3.0

former_member581827
Participant
0 Kudos

Hi Chirag,

Can you change the context of UOM and MainUOM to General Info or MT_Materialin and test.

Please do let me know whether it helped.

Regards,

Chandra.

Former Member
0 Kudos

Chandra.. Tried changing the context and that failed to work. Got the same error.

Prakasu - Thanks for the effort, I tried your method but now im getting an error for all messages.

This is the error.

<SAP:Stack>During the application mapping com/sap/xi/tf/_MM_Turkey_MaterialInCustom_BPM_ a com.sap.aii.utilxi.misc.api.BaseRuntimeException was thrown: RuntimeException in Message-Mapping transformatio~</SAP:Stack>

former_member183908
Active Contributor
0 Kudos

Hi

You can use the Standard function available in graphical mapping.

main mesure-->equals(under text function)->

Measure--


> equals(under text function)>if without else(under boolean function)----


>serial_target.

Thanks

Former Member
0 Kudos

Hi,

Try this:

1. When you are mapping Name to Name_target then save the 'MainMeasure' Value in a global Container Variable using UDF.

Code to store Global container Value:

public String setGlobalContainer(String globalContainerName,String globalContainerValue,Container container){

AbstractTrace trace = container.getTrace();

GlobalContainer gc = container.getGlobalContainer();

gc.setParameter(globalContainerName,globalContainerValue);

return globalContainerValue;

2. When you are mapping serial to Serial_target then get the 'Main'Measure' Value you stored above using UDF and compare it with current DTL- Measure. If it is same then create the Serial_traget.

Code to get the global container Value

public String getGlobalContainer(String globalContainer,Container container){

AbstractTrace trace = container.getTrace();

String gctmp;

GlobalContainer gc = container.getGlobalContainer();

gctmp = (String) gc.getParameter(globalContainer);

return gctmp;

}

Regards,

Shweta.

Former Member
0 Kudos

Hi!

1) You can easily achive this by using node Functions like If else conditions functions

2) If still if it is complex go for UDF's

3) Or else just try to give condition in the Routing Steps giving condition in the X path I mean Receiver determination Condition Step then only it will process to Receiver other wise leave it

4) simply achive in BPM using Correlation Conept but it may issue performance issues but as the above fields are less I think it wont make any issue and hence u can easily go for BPM also no issues.

Regards::

Amar Srinivas ELi

former_member518917
Participant
0 Kudos

Hi Chrag,

Map your target message root node (say "TargetMessage") with the condition "If MainMeasure = Measure"

Try:

MainMeasure =(equals) Measure -> createIf -> TargetMessage

Br,

Ritu