Adding Zeros infront of a field in Message Mapping
Hi,
I need to add zeros infront of my target field (eg Target Field length is fixed (10). If incoming field is having only 3 digits (123), I need to add 7 (10-3) zeros infront of my target field (0000000123). How to go about it. Is there any standard functions to do this ?
Thanks in advance,
Jose Augastine
Try using this UDF
double d = Double.parseDouble(a);
DecimalFormat df=new DecimalFormat("0000000000");
StringBuffer sb=new StringBuffer();
df.format(d,sb,new
FieldPosition(NumberFormat.INTEGER_FIELD));
return(sb.toString());
Regards,
Jai Shankar.
Message was edited by: Jai Shankar
Similar Messages
-
Send Multiple field values to Single Target field in Message Mapping
Hi,
My Requirement is to Map Multiple fields to Single field in Target side.I have to send all the values concatenated and pass the same to target Field in Message Mapping.
We can use Concat function,but more that 15 fields are there.If using concat,the mapping will be complex.
Is there any way to simplify this requirement or we can use any UDF for this,kindly suggest.
Regards,
Madhu>>>We can use Concat function,but more that 15 fields are there.If using concat,the mapping will be complex.
I don't think it's complex but just that it occupies more mapping area
Just write a simple UDF - a one line code and pass all your input variables.
return var1+var2+var3+var4+...+var15; -
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 -
Display queue for Target field in Message Mapping
Hi Folks,
If i check my Target Field (DT_Req) (Display queue) in Message Mapping, I am getting 2 values like ie [] that means ....in my test result in MM, i should get 2 times DT_Req field.
Is it right?
Plz give some idea how this display queue works on each field?
Thanks
Prabaharan
Edited by: Prabaharan on Sep 10, 2008 12:22 AM
Edited by: Prabaharan on Sep 10, 2008 12:24 AMHi,
In my scenario occurrence of that
target field is 0...unbounded
and in my display queue.. Initially it is
suppress, [], suppress, suppress, suppress,suppress,suppress,suppress,suppress,suppress, [],suppress
in my result i could get only one DT_req field.
Plz throw some idea on this?
thanks -
Splitting XML string as separate fields in message mapping
Hi Experts,
I am getting XML string in one field from source message, i need to separate those fields and map it to target fields.
Sorce message:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:test_source xmlns:ns0="urn:gp:prototype">
<Document>
<store>3021</store>
<date>2011-03-24</date>
<type>3002</type>
<till>32</till>
<transaction>1478</transaction>
<data><![CDATA[<buy><merchantID>006001007031992</merchantID><laneID>29</laneID><referenceID>PP0323095107</referenceID><localDate>2011-03-2302:00</localDate><localTime>09:51:0702:00</localTime></buy>]]></data>
</Document>
</ns0:test_source>
Target Message:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:test_target xmlns:ns0="urn:gp:prototype">
<item>
<storeID>3021</storeID>
<businessdate>2011-03-24</businessdate>
<Typecode>3002</Typecode>
<workstation>32</workstation>
<SeqNum>1478</SeqNum>
<XX>006001007031992</XX>
<YY>29</YY>
<PP>PP0323095107</PP>
<QQ>2011-03-23+02:00</QQ>
<RR>09:51:07+02:00</RR>
</item>
</ns0:test_target>
Can anyone please suggest me how can we do this???You can easily do both using standard function or simple udf
Use indexOf and substring to achieve this...
Simple UDF
String var1="><![CDATA<buy><merchantID>006001007031992</merchantID><laneID>29</laneID><referenceID>PP0323095107</referenceID><localDate>2011-03-23+02:00</localDate><localTime>09:51:07+02:00</localTime></buy>]>";
String search = "<merchantID>";
if(var1.indexOf(search) != -1){
int pointer = var1.indexOf(search);
return var1.substring(pointer+12, pointer+27);
}else{
return "";
similarly for laneid
search ="<laneID>";
if(var1.indexOf(search)!= -1){
int pointer = var1.indexOf(search);
return var1.substring(pointer+8,pointer+10);
}else{
return "";
Same way you can do for all the elements creating seperate method for each element or just use standard function to achieve this.
Edited by: Baskar Gopal on Mar 24, 2011 10:13 AM -
Hello everyone,
I have a BPM that executes an ABAP Proxy, my problem is that I need to send in the ABAP Proxy strcuture the Unique Message Id that the BPM has in XI, I don't know if I can obtain this field in Message Mapping and map it to the ABAP Proxy structure, can anyone help me? thanks in advance for your answers.
Regards,
Julio CesarHi Julio,
You can get the message id through java UDF. Here is the code
String headerField;
java.util.Map map;
// get runtime constant map
map = container.getTransformationParameters();
// get value of header field by using variable key
headerField = (String) map.get(StreamTransformationConstants.MESSAGE_ID);
return headerField;
Thanks
-Kulwant
If helpful, assign score please -
Message mapping: Passing data at the node level
Hi,
I have a question/requirement, XI Message Mapping program need to read the incoming xml and map to a diffrerent target structure. Incoming xml has a parent node called Description and it has a value "Frauen Hemd Shoes", we need to map this value to target LongText Field but message mapping is ignoring this data while mapping.
A parent node can't hold the value/data while a child node is present. So is there any workaround to read this data to target str?
<Description>
<ShortName>Shoes</ShortName>
Frauen Hemd Shoes
</Description>
Expected result:
<Comments>
<ShortText>Shoes</ShortText>
<LongText>Frauen Hemd Shoes</LongText>
</Comments>
Please let me any clues to resolve the issue.
thanks,
LaxmanI agree , the soruce structure is not a valid one..
The source structure should look like the below:
<Description ShortName='Shoes'>
Frauen Hemd Shoes
</Description>
where ShortName is attribute for the Element "Description".
You add attribute to the element the same way you add subElement, Just choose attribute instead of subelement.
In this case the Mapping would be
Descriprion -
> LongText (target)
ShortName -
> ShortText (target)
This Should work.
Regards.
Jeet. -
Need help on message mapping screen
Hi folks,
I am working on file to idoc scenario. I Imported the IDOC to my scenario. In Messaga Mapping IDOC structure displaying fields as a documention. but i need techincal names of those fields.
for Example: In my IDOC 1 field is showing companycode but I want to see that field as a BUKRS.
How to see the technical names of IDOC fields in Message Mapping.
Your help is highly appreciaHi,
I dont think we would be able to see the data element names of the IDOC in XI. Even the imported XSD of Idoc doesnot contain data element name.
We would be only dealing with the field names/ structure of the IDOC for field message mappings. The field names are internally mapped to the data element names in SAP R3 system.
To view the internal mapping between field names and data element names of the Idoc fields, you can go to the transaction 'WE30'. Give the basic type of the Idoc and go to the segment editor. You can find the data element names for each field name there.
Thank you.
Regards,
Subbu -
Hi folks,
I am working on file to idoc scenario. I Imported the IDOC to my scenario. In Messaga Mapping IDOC structure displaying fields as a documention. but i need techincal names of those fields.
for Example: In my IDOC 1 field is showing companycode but I want to see that field as a BUKRS.
How to see the technical names of IDOC fields in Message Mapping.
Your help is highly appreciated.
Thanks,
Anitha.Hi bavesh...
thank you so much for very your quick responses..
i got xsd as source..based on xsd i created external definition for source xsd and i created outbound interface based on source external deifinition <b>MI_OUT_WearUnits</b>.
and i imported Idoc and exported as xsd and changed occurance to unbounded and again imported as external definition.
i did mapping between these two external definitions.
and i selected standard idoc for source and target interface for interface mapping and given message mapping of previous step.
In ID
sender agreement :
sender service :BS_external
sender interface :<b>MI_OUT_WearUnits</b>
receiver agreement:
receiver service :R/3
receiver interface : standard Idoc
Interface determination:
sender service :BS_external
sender interface :<b>MI_OUT_WearUnits</b>
reciever service :R/3
and clicked create
inbound interface : Standard IDOc
i am not getting Interface mapping which i created in IR.
i tried Enhance interface determination also..
please guide me....
waiting for your help.
regards
ram -
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 -
Adding zeros before field.
HI Experts,
I have one requirement, which i need to add zeros before filed, if field length is less than 6 characters.
Ex: 1005--> 001005
12345--->012345
like above.
Please give me the code.
Regards
Rajinidata: result(6).
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = <ur field>
IMPORTING
OUTPUT = result . -
UDF for leading zero's in message mapping
Dear team,
I need UDF for leading zero's in my message mapping.
Source and Target both structures contains matnr field.But we have to maintain total 18 chars at target matnr , because RFC in R/3 needed.So I want to add leading zero's when mapping. Can anybody provide the UDF code.
Matnr[source]--->split by value(eachvalue) ->UDF->Matnr[Target]
Ex::if source matnr conatains value "9846538" ; I need matnr value at target side like "000000000009846538"[total 18 chars].
-DrumiHi Ambrish,
Good day...
I have enterd what you said and I got below error... and I gave "input" in place of var1, 18 in place of filedlenght in below program...
=================================
int len = Integer.parseInt(18);
int inputLength = input.length();
try {
Integer.parseInt(input);
// If it is an integer, add 0 (len - inputLength) times
for (int i=0; i< len-inputLength;i++)
input = "0" + input;
return input;
} catch (NumberFormatException numForEx) {
// return as it is, if alphanumeric
return input;
====================================
ERROR:
Source text of object Message Mapping: Lubrisur_SHPMNT_SHPMNT05_TO_WMMBXY_WMMBID02_TransferPosting | urn:bp:xi:dwn:lu:common:Logistics:100 has syntax errors:
Function LeadingZeros, Line 1:
cannot find symbol symbol : method parseInt(int) location: class java.lang.Integer int len = Integer.parseInt(18); ^ 1 error
=======================
Please suggest -
Using Right-justified and left zero-filled condition in message mapping of
Hi,
My Interface is outbound Interface.
Suppose source field named 'MobNumber' is mapped with Target field named 'MobileNumber'.Condition is AS IS(Right-justified and left zero-filled).
How should i do this mapping?
Thanks,
SanghamitraHi Sanghamitra,
Similar question ahs been answered earlier in this thread
Re: Message Mapping using Left justified, right blank/space filled
just replace the filler variable by zero in my post
One small request, if you think your questions are being answered correctly and properly, please kindly, if possible, close down the threads. This way forum members/users who later look up for solutions to similar problem, they know for sure that the problem was finally solved, with the solutions provided in the thread.
regards
Anupam
Edited by: anupamsap on Aug 3, 2011 11:27 AM -
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 - 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
Maybe you are looking for
-
Here's what worked for me...
Here's what worked for me: 1) I opened iTunes and in Options, I selected iTunes as the default music player for my computer (it wasn't). (I even uninstalled RealPlayer and WinAmp.) 2) I uninstalled iTunes and iPod, and reinstalled using the newer ver
-
I have a 4s iPhone on IOS 6.0.1 with an Israeli Cellular provider. I use Gmail services an exchange to sync my colander contacts and mail. When the time zone support is set to ON in the Settings->mail, Contacts, Calendars->Time Zone Support The time
-
Trying to understand serialVersionUID
so I'm coding up my own event using Eclipse (for pretty much the first time), and it gives me a warning of The serializable class CaptureEvent does not declare a static final serialVersionUID field of type long now ... first I notice that it's a warn
-
Safari keeps freezing / crashing
2012/04/11 9:27:28 PM ReportCrash[198] Saved crash report for WebProcess[195] version 6534.55 (6534.55.3) to /Users/DonnaP/Library/Logs/DiagnosticReports/WebProcess_2012-04-11-212728_donna -potgieters-macbook.crash Process: WebProcess [195] P
-
Hello, In CM25, Freeze periods in the planning table, how could we do this? Please help. Thanks Edited by: ellen gatchalian on Feb 18, 2010 1:22 PM