on 08-31-2006 5:41 PM
Hi,
I would like to remove leading zeros of a column in a table. My Questions :
1. Is it possible?
2. Where is it better to truncate, in RFC or Web Dynpro?.
3. If Possible, How can I do that.
I appreciate your input.
Thanks,
Sunita.
For a read-only table cell, you could create a calculated attribute "TruncatedValue" in the context that returns the truncated value. ("Value" denotes the original attribute)
Example:
/* getter of calculated attribute */
String get<Node>TruncatedValue(I<Node>Element element)
{
return removeLeadingZeroes(element.getValue());
}
/* Utility method */
static String removeLeadingZeroes(String s)
{
if (s == null) return null;
int i = 0;
int n = s.length();
while (i < n)
{
if (s.charAt(i) != '0') break;
++i;
}
return s.substring(i);
}
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi
good
use this function module
CONVERSION_EXIT_ALPHA_OUTPUT converts any number with zeroes right into a simple integer
Example:
input = 00000000000123
output = 123
thanks
mrutyun^
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I think it's better to do the truncation in WD. Assuming that you are using WD java, you can use a code like:
public void removeLeadingZeroes(IWDNode tableData,String attribute)
{
for(int i = 0; i < tableData.size(); i++){
IWDNodeElement tableDataElement = tableData.getElementAt(i);
String rfcData = tableDataElement.getAttributeAsText(attribute);
tableDataElement.setAttribute(attribute,Integer.toString(Integer.parseInt(rfcData)));
}
}
Regards,
Satyajit.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sunita,
Please specify the datatype of the column that contains leading zeros, because if the data type of the column is integer then the leading zeros are automatically taken care.
If your RFC return you int and you are assigning it to a String then the leading zeros will appear.
For example, see the below simple ABAP Program. Just copy and execute it. You will see the difference.
data: a type mara-matnr,
str type string.
select single matnr from mara into a.
write a.
str = a.
write / str.
Hope it helps you.
Regards,
Maheswaran.B
Message was edited by: Maheswaran B
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.