Message Mapping - SUM a field per unique combination of 2 other fields?
I'm receiving a proxy with detail records, and I need to create a subtotals file. Here an example:
BEFORE MAPPING
<ROW>
<KOSTL>0000010300</KOSTL>
<POSID>DUMMY</POSID>
<FTE>0.51</FTE>
</ROW>
<ROW>
<KOSTL>0000010400</KOSTL>
<POSID>123</POSID>
<FTE>0.49</FTE>
</ROW>
<ROW>
<KOSTL>0000010400</KOSTL>
<POSID>DUMMY</POSID>
<FTE>0.72</FTE>
</ROW>
<ROW>
<KOSTL>0000010400</KOSTL>
<POSID>123</POSID>
<FTE>0.82</FTE>
</ROW>
<ROW>
<KOSTL>0000010300</KOSTL>
<POSID>DUMMY</POSID>
<FTE>0.18</FTE>
</ROW>
AFTER MAPPING:
<ROW>
<KOSTL>0000010300</KOSTL>
<POSID>DUMMY</POSID>
<FTE>0.59</FTE>
</ROW>
<ROW>
<KOSTL>0000010400</KOSTL>
<POSID>123</POSID>
<FTE>1.31</FTE>
</ROW>
<ROW>
<KOSTL>0000010400</KOSTL>
<POSID>DUMMY</POSID>
<FTE>0.72</FTE>
</ROW>
How do I create a new record for all unquie combinations of KOSTL and POSID? And total the FTE field for each line? Can this be done in a message mapping?
Hello,
How do I create a new record for all unquie combinations of KOSTL and POSID? And total the FTE field for each line? Can this be done in a message mapping?
Yes, very much possible with or without UDF. See sample mapping below without using UDF:
For ROW:
KOSTL(set context to row) -> concat: -> sort: case insensitive ascending -> splitByValue:valueChanged -> collapseContext -> ROW
POSID(set context to row) -> /
For KOSTL:
KOSTL(set context to row) -> concat: ----------------> sortByKey: case insensitive ascending -> formatByExample -> collapseContext -> splitByValue:eachValue -> KOSTL
POSID(set context to row) -> / KOSTL(set context to row) ->/ /
KOSTL(set context to row) -> concat: -> sort: case insensitive ascending -> splitByValue:valueChanged -> /
POSID(set context to row) -> /
For POSID:
KOSTL(set context to row) -> concat: ----------------> sortByKey: case insensitive ascending -> formatByExample -> collapseContext -> splitByValue:eachValue -> POSID
POSID(set context to row) -> / POSID(set context to row) ->/ /
KOSTL(set context to row) -> concat: -> sort: case insensitive ascending -> splitByValue:valueChanged -> /
POSID(set context to row) -> /
For FTE:
KOSTL(set context to row) -> concat: ----------------> sortByKey: case insensitive ascending -> formatByExample -> sum -> splitByValue:eachValue -> FTE
POSID(set context to row) -> / FTE(set context to row) ->/ /
KOSTL(set context to row) -> concat: -> sort: case insensitive ascending -> splitByValue:valueChanged -> /
POSID(set context to row) -> /
Hope this helps,
Mark
Similar Messages
-
Message Mapping - Sum of all Element1.Field1 where Element1.Field2 = X
Hi!
Has everyone an idee of how to do the following message mapping ?
My input message is :
E1EDP01
E1EDP26
QUALF = 001
BETRG = 5
E1EDP26
QUALF = 003
BETRG = 3
E1EDP26
QUALF = 002
BETRG = 5
E1EDP26
QUALF = 003
BETRG = 3
I want to get the sum of all E1EDP26.BETRG where E1EDP26.QUALF = "003". There can be more than one E1EDP26 with field QUALF = "003". So expected result is 6.
Thanks in advance,
LaurenceInput structure :
INVOIC02 1.1
IDOC 1.1
E1EDP01 0..999999
E1EDP26 0..20
QUALF 0..1
BETRG 0.11
Output structure :
root 1..1
GoodsDeclaration 1..1
Invoice 0..1
ExchangeRate 0..1
exchangeRate 0..1
currrency 1..1
exchangeDate 0..1
invoiceAmount 0..1
The target field root/GoodsDeclaration/Invoice/invoiceAmount must be mapped with the sum of fields BETRG belonging to nodes E1EDP26 with field QUALF = "003".
Sample :
<INVOIC02>
<IDOC>
<E1EDP01>
<E1EDP26>
<QUALF>001</QUALF>
<BETRG>5</BETRG>
</E1EDP26>
<E1EDP26>
<QUALF>003</QUALF>
<BETRG>1</BETRG>
</E1EDP26>
<E1EDP26>
<QUALF>002</QUALF>
<BETRG>5</BETRG>
</E1EDP26>
<E1EDP26>
<QUALF>003</QUALF>
<BETRG>2</BETRG>
</E1EDP26>
</E1EDP01>
</IDOC>
</INVOIC02>
In this case, target field root/GoodsDeclaration/Invoice/invoiceAmount must have the value 3 :
<root>
<GoodsDeclaration>
<Invoice>
<ExchangeRate>
<exchangeRate/>
<currrency/>
<exchangeDate/>
</ExchangeRate>
<invoiceAmount>3<invoiceAmount>
</Invoice>
</GoodsDeclaration>
</root>
Laurence -
How to check a field in Message mapping wether it is Non Numeric?
Hi XI Guru's
I am totally new to XI world, Kindly help hopw can I chexk a field while doing message mapping whether the field is non numeric or not.
I dont find any built in function for the same.
If it is using UDF can some body help me in providoing a UDF for this.
Many Thanks
ArunHi Arun,
In SAP PI, all the XML contents by default treated as STRINGS.
So if u want to check whether the incoming field is numeric or not... the only way is to write a UDF code for the same.
the UDF will be,
1. At first
import java.util.regex.Matcher;
import java.util.regex.Pattern;
in functions.
2.UDF content:
input: field,container
output:boolean
Code
boolean return_Value;
Pattern p = Pattern.compile("[0-9]*"); // If u are using the decimals please change the regular expression accordingly.
Matcher m = p.matcher(field);
if(m.matches())
retuen_Value = true;
else
return_Value = false;
return return_Value ;
I hope this will solve ur problem....
Babu -
Access current system or target system ID in message mapping
Hi.
I have a requirement to map three different constant values to Sales Org field, depending on whether the system is D, Q or Prod.
This needs to be done in the message mapping section of the Interface along with all the other mapping logic.
Is there any way how we can access the current system ID or the Target system ID (XI is communicating with target, in this case, ECC, using RFC receiver Communication channel)?
Please help.
Thanks.
Anuradha.Hi,
The key element would be :-
System.getProperty("SAPSYSTEMNAME");
Use this in UDF to get System Name ... and then on basis of systemname do whatever you want to perform.
Regards
Prabhat Sharma -
I have a File to IDOC Message Mapping Scenario:
Source Field Targefield
Communiication Address-(Email ID) E1EDK2 - TDLINE
Source Field length: 1/80 target Field length: Char\70
Mapping Condition:
Note: TDFORMAT = ‘=’ (Long Line), may need to create 2 TDLINE fields depending on length of text
So give the Solution for handling text Length exceed than target field lenght Using TDLNE and TDFORMAT......
Guide me and give Suggestions to achive this.Hi ,
Below is the generic sol for your problem .Graphical mappings wont workout for your problem while using sub string .
Input -->Input string
Length -->length of TDLINE
MESSAGE_V1,V2,V3,V4....depends on how many TDLINES you expect .Here I have taken 4 .
public void SplitbyLength(String[] Input, String[] Length, ResultList MESSAGE_V1, ResultList MESSAGE_V2, ResultList MESSAGE_V3, ResultList MESSAGE_V4, Container container) throws StreamTransformationException{
int lengthVal = Integer.parseInt(Length[0]);
int InpLenVal ;
for(int i=0;i<Input.length;i++)
InpLenVal =Input[i].length() ;
if (InpLenVal<=lengthVal)
MESSAGE_V1.addValue(Input[i].substring(0));
MESSAGE_V2.addValue(ResultList.SUPPRESS);
MESSAGE_V3.addValue(ResultList.SUPPRESS);
MESSAGE_V4.addValue(ResultList.SUPPRESS);
else if ((InpLenVal>lengthVal) && (InpLenVal <= (lengthVal*2)))
MESSAGE_V1.addValue(Input[i].substring(0,lengthVal));
MESSAGE_V2.addValue(Input[i].substring(lengthVal,InpLenVal));
MESSAGE_V3.addValue(ResultList.SUPPRESS);
MESSAGE_V4.addValue(ResultList.SUPPRESS);
else if ((InpLenVal>(lengthVal*2)) && (InpLenVal <= (lengthVal*3)))
MESSAGE_V1.addValue(Input[i].substring(0,lengthVal));
MESSAGE_V2.addValue(Input[i].substring(lengthVal,(lengthVal*2)));
MESSAGE_V3.addValue(Input[i].substring((lengthVal*2),InpLenVal));
MESSAGE_V4.addValue(ResultList.SUPPRESS);
else if (Input[i].length()>(lengthVal*3) && (InpLenVal <= (lengthVal*4)))
MESSAGE_V1.addValue(Input[i].substring(0,lengthVal));
MESSAGE_V2.addValue(Input[i].substring(lengthVal,(lengthVal*2)));
MESSAGE_V3.addValue(Input[i].substring((lengthVal*2),(lengthVal*3)));
MESSAGE_V4.addValue(Input[i].substring((lengthVal*3),InpLenVal));
else if (Input[i].length()>(lengthVal*4) )
MESSAGE_V1.addValue(Input[i].substring(0,lengthVal));
MESSAGE_V2.addValue(Input[i].substring(lengthVal,(lengthVal*2)));
MESSAGE_V3.addValue(Input[i].substring((lengthVal*2),(lengthVal*3)));
MESSAGE_V4.addValue(Input[i].substring((lengthVal*3),(lengthVal*4)));
Regards
Venkat -
Message Mapping - java.util.Map
Hi There
I would like to know if there is any way, using java.util.Map map; to get the "data type" field name in a UDF? Passing a constant with the field name would not be practical.. I'm looking for a object oriented process to use in all my mappings.
Also where could I look for the methods I can use in the map trace object?
Regards,
JanBut I'm still missing the field name..
Let say I have a message mapping going from Field ACB to Field QAZ and a UDF called CheckLen.
In my UDF I'm looking at the incoming field and if it's length is correct. if not I'm writing an entry into a table stating there was an incorrect field but what I can't get is the the field name so I can write to the table "Invalid length on field ACB" The only way to get this field name value is by passing a constant of "ACB" to the UDF and using that. But we have hundreds of MMs so implementing this would be much more difficult than a OOP way.. -
Accessing container variable of BPM in Message Mapping function
Hi,
I have a scenario in BPM where i have a container variable that is used as a loop counter.I want to access that counter defined , every time when i go around the loop and perform certain actions based on that counter. so how can i access that variable in my message Mapping function.Hi Sudharshan,
check these links, hope they give you the required information (i think there is some problem with SDN site, check these links after a while)
Re: How to use Container Variable across Maps
Container object in Message Mapping
Copy value of container (abstract interface) to an other container
Regards
Vishnu -
Message mapping - dependencies is disabled?
Hi,gurus:
In IR,message mapping ->dependencies,it was disabled.Can you tell me why?Thanks in advance.hi,
if ur message mapping tab is disable this is bcoz of the jdk version being install.chk if it is greater than 1.4.2.x say jdk 1.5 or jdk 1.6.if so reinstall jdk 1.4.2. bcoz version 1.4.2.x creates probms like disabling of the message mapping tab in IR.
Regards.
Siddhesh Naik -
Mapping challenge !! Generate target for unique combination of source field
Hi,
I/P:
<Segement1>
<Article>1</Article>
</Segement1>
<Segement1>
<Article>2</Article>
</Segement1>
<Segement2>
<StoreNum>12</StoreNum>
<StoreNum>13</StoreNum>
<StoreNum>14</StoreNum>
</Segement2>
and the output should be like for every unique combination of Article and StoreNum I have to create a target node and the corresponding values in that node: (So in this case the o/p node will come 6 times)
<Detail>
<Article>1</Article>
<StoreNum>12</StoreNum>
</Detail>
<Detail>
<Article>1</Article>
<StoreNum>13</StoreNum>
</Detail>
<Detail>
<Article>2</Article>
<StoreNum>14</StoreNum>
</Detail>
Can anybody please suggest a solution ?articleremovecontext-sortsplibyvalue(valuechange)-collapsecontext
UDF---details
storenumsort-splitbyvalue(valuechange)--collapsecontext
mapping of the elements inside details node can be achieved using UDF or standard function also.
UDF2
for(int i=0;i<var1.length;i++)
for(int j=0;j<var2.length;j++)
result.addValue(var1<i>);
result.addContextchange();
repeat the same mapping for Article(target filed) using udf2 as mentioned above for details...
UDF3:
for(int i=0;i<var1.length;i++)
for(int j=0;j<var2.length;j++)
result.addValue(var2<i>);
result.addContextchange();
repeat the same mapping for Storenum(target filed) using udf3 as mentioned above for details...
Note: check for syntax errors..... -
Doubt in fields - message mapping (file 2 idoc scenario)
while doing message mapping in file 2 idoc scenario, i could not able find the values for some field names
( i am following this wiki help
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/profile/2007/05/11/fileToIDOC& )
cremas04 idoc
vendorNo LIFNR
vendor name Name1
Pur_org ? ( I could not able locate field with the similar desc in idoc MT side)
Company code ?
Acc_Grp ?
Search term MCOD1
Address ADRNR
City ORT01
Pin_code PSLTZ
could you help me out with this?
Message was edited by: praba
prabahi,
I got the answer. -
Message Mapping - NewLine generation in the target field
Hi ,
This is a File to SOAP scenario, where text file is picked by XI and posted to target using webservice in the xml format.In the message mapping, I am supposed perform a logic where 3 fields in the source structured are to be concatenated and sent to the target structure. This fields at the target structure are to be displayed with a newline character.
So if I am sending : abc, 123 and xyz as input and the output should be in one field as follows :
<ns3:OutputField xmlns:ns3=abc
123
xyz</ns3:StreetAddressLine>
I have used this "
" as the seperator in the concat function, hoping this would produce a new line but was hopeless.
Any ideas are appreicated.
Thanks,
RagHi Raghav,
XML will never show new line or space characters.
Try to open the message in notepad or wordpad and then check if you can see the new line character.
-Supriya. -
Searching a Field In Source or Target Message in Message Mapping
Hey Guys,
I came accross this peculiar behaviour and it keeps bugging me , I could search any field in source or target message in message mapping in PI 7.0 by copying the path( /ns1:MaestroAcreedores/Acreedores/ClaveDeGrupo or any idoc field /FIDCCP02/IDOC/E1FIKPF/BUDAT ) but in PI 7.1 i cant , its giving me an error String /ns1:MaestroAcreedores/Acreedores/ClaveDeGrupo not found , i can only search the field independently.Can anyone please help me out in this.Hi
I am not sure whether it worked in 7.0 or not, but having checked myself i can confirm that it is not working in 7.1 in my system also.
For alternative, you can check by changing into source text view where it will display as xml. Here when you search the keyword, it would display you the hierarchy better than normal view.
I dont think there is any other alternative. although I would say in the worst case scenario you would not have more than 10-15 occurrences of same element in an idoc.
Regards
Krish -
Calling Message mapping Dynamically based on a field value
Hi gurus,
I have
1 source inteface
1 target interface
3 Message mapping programs based on the 1 source and 1 Target Interfaces
I need to decide Dynamically as which message mapping program should be called based on the Input provided by the source system.
For example:
If the souce side file sends a field value=1 then message mapping 1 should be called
If the source side file sends a field value=2 then message mapping 2 should be used...
Pls provide me help on this ASAP.As ur source and target structures are always same, u should have used same mapping with multiple conditions instead of using three different mappings.
Right now for ur requirement, in ID -> standard Interface Determination, u can use multiple interface mappings based on condition.
Check heading "Specifying Conditions (for Multiple Inbound Interfaces)" here
http://help.sap.com/saphelp_nw04s/helpdata/en/42/ea20e737f33ee9e10000000a1553f7/content.htm
Regards,
Prateek -
Multi-Message Mapping based on value of field - (Without BPM)
Hi.
I am having a bit of difficulty with multi-message mapping without BPM. I want to map to message1 & message2 based on a field in the rows of the source structure.
e.g.
row1-Source-Field1=> (if equal 0) => <b>Message1</b>-field1.
row2-Source-Field1=> (if equal 10) => <b>Message2</b>-field1.
To attempt to do this, I use the conditions in the graphical mapper:
if row-Source-Field1 = 0 => Map "Row to MessageType1".
if row-Source-Field1 = 10 => Map "Row to MessageType2".
However when I test this the mapping only seems to consider the first row value in row-Source-Field1 and ignores the fact that row two has a value of 10. I think this has something to do with contexts etc..
I would appreciate any help please.
Regards.
Mick.in that case try this out
row1-source-field1 (remove context) -- UDF -splitbyvalue-target
UDF1(for message 1)
for(int i=0;i<field1.length;i++)
if(field1<i>.equals("0"))
result.addValue(<field to be mapped><i>);
UDF2(for message 2)
for(int i=0;i<field1.length;i++)
if(field1<i>.equals("10"))
result.addValue(<field to be mapped><i>); -
Message Mapping, filling field with 0 (zeros) on left
I need to fill a field with values that has variable lenght adding 0 (zeros) on the left, how can I do it ?
I'm using the LENGHT in message mapping, with value returned by LENGHT I use FIXVALUES to map the quantity of 0 (zeros) that I need to add in the field.
Somebody can help me with this problem ?
Thank's.Hi Regis,
You can use the Arithmetic:FormatNum built-in function for this.
If you want to left-pad the number with zeros so that the length is always 10, then specify 10 zeros for the format, 0000000000.
This function takes formats based on java.text.DecimalFormat so you can see all of the possibilities at:
java.sun.com/j2se/1.4.2/docs/api/java/text/DecimalFormat.html
Thanks,
Jesse
Maybe you are looking for
-
Error while opening the XML file
Hi all, i'am trying to download data from internal table to XML file with root node and its corresponding child nodes.i have written the program in this way. tables: mara. include bcciixml_decl. include bcciixml_impl. parameters: p_matnr like mara-ma
-
How do I convert a word document to a pdf file?
-
Byte array exception in web dynpro
Hi all, I am developing a web dynpro application using a webservice model. The model expects a parameter in the form a byte array. But unfortunately when I get the following exception when i lauch the web dypro application. Anyone of you, plz help m
-
In the past I believe Itunes had a preference setting to play music videos, movies, etc., full screen by default; that is my preferred approach. Now, my videos will play a full screen but with the itunes menu at the top. I must hit the "double arrow
-
hi friends ı want to use two variant option in a screen.ı wrote this code, SELECTION-SCREEN BEGIN OF SCREEN 1060 AS SUBSCREEN . "emrah 1060 screen create PARAMETERS: P_VARI1 LIKE DISVARIANT-VARIANT . PARAMETERS: P_VARI2 LIKE DISVARIANT-VARIANT . SELE