on 06-18-2008 3:41 PM
Hi All,
I am doing an IDOC-->File scenario.
As per the Third party system requirements, I need to COUNT all the Data characters (Minus the EDIDC record) and write this value at the end of the trailer record in the file.
Example:
EDIDC--> SAPR3, LS...
E1KNA1M-->SHIRIN, UK, SW1DPL
E1KNBKM-->SHIRIN, CITIBANK
So in this example I should sum up(COUNT) all the characters(of Data) belonging to segment E1KNA1m and E1KNBKM. So here COUNT is '28'. So I need to write the value '28' at the end of the file.
I want to know, is it possible to count data in XI mapping or should this be done in R/3 itself and appended as a COUNT field to the IDOC.
Appreciate any suggestion help on this. All I want to know which is the best practise/place to count the data characters in this scenario.
Thanks
Shirin
Hi,
Use String length method for Source field Write UDF and you will get the values as String Array then use String lenght method in udf.
Thanks,
RamuV
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI,
Using StringLength function, I defuinitely can get the length of the string. But since teher are multiple Strings(segments), I will need to store the previous string length somewhere and then add to it the next string length.
If I am right in above assumption, how do I do it. Is teher some global variable in XI wheer I can store the string length andkeep on adding/manipulating its value.
Regards
Shirin
Hi Gurus,
I have still not been able to sort this issue out, except summing the values in SAP and then sending to XI.
I am trying to achieve this functionality in XI and not R/3.
Appreciate if you have UDF or any other method known, to count all characters in payload.
Many thanks
Shirin
Edited by: Shirin K on Jul 24, 2008 10:00 AM
Hi Shirin,
Folllow this.
1. Create a Global Variable: int len using the option Edit Java Section in Message Mapping and initialize it to 0.
2. Create a simple UDF.
public String calclen(String a,Container container)
{
len = len + a.length();
return a;
}
Map all ur source thru this UDF to the target. This UDF calculates and add the string length to the global variable.
3. Use this UDF to return the total string length in the final.
public String getlength(Container container)
{
String s = Integer.toString(len);
return s;
}
Map this UDF to the target field.
Thanks
SaNv...
Hi,
Thanks for the reply.
Being a newbie, I have no idea where is JAVA section in MM. tried lookingh in forums, but they all talk of how to code but dont point wheer to start
And is the UDF complete( I mean cut and paste) as I do not have Java skills, I am looking for a cut and paste UDF .
Many thanks
Shirin
Hi,
Thanks for explaining.Really appreciated.
Just to confirm,
in Java edit Section I have added the following data: Please let me know if that is correct.
Imports:
Global Variables: len
Initilisation section: 0
Clean-up:
Similarly in UDF I have entered the following data:
Label/Description: Calculate length
Cache: Value(radiobutton)
Arguments: a
Next screen:
Imports:
public String Calculate(String a, Container container)
Then entered ur code.
When I save and activate I get the following error
Starting compilation Source code has syntax error: D:/usr/sap/XRD/DVEBMGS02/j2ee/cluster/server0/./temp/classpath_resolver/Map2494b0c0596b11dda115001a4b52813a/source/com/sap/xi/tf/_MM_ALLOCATION_RESPONSE_.java:32: <identifier> expected public /*!_$ClNRep_*/_MM_ALLOCATION_RESPONSE_(){} ^ D:/usr/sap/XRD/DVEBMGS02/j2ee/cluster/server0/./temp/classpath_resolver/Map2494b0c0596b11dda115001a4b52813a/source/com/sap/xi/tf/_MM_ALLOCATION_RESPONSE_.java:210: ';' expected } ^ 2 errors
Appreciate if you could help.
Thanks
Shirin
Have a look at this..
Global Variable..
http://www.flickr.com/photos/28929439@N06/2697628937/
Calclen UDF
http://www.flickr.com/photos/28929439@N06/2697628975/
getlength
http://www.flickr.com/photos/28929439@N06/2698447914/
Thanks
SaNv...
Thankyou.
You really have been patient and helpful.
Really appreciated.
Shirin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We can perhaps write a custom module in Java to count the number of characters for the preprocessing of the payload?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
9 | |
9 | |
6 | |
6 | |
6 | |
5 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.