Adding leading zeros in a field mapping
Hi,
I am getting account as a 5 char field in the input file. I need to map this to a 10 char field in XI and add leading zeros in case the value is all numeric. Is there any standard data type/ mapping that can achieve this or I need to write a UDF.
Thanks,
formatNum field will cause an exception if your input isnt all numeric...
I'd go for UDF id your input isnt always numeric.
Regards,
Henrique.
Similar Messages
-
Adding leading zeros to a field in an Internal table
HI Experts,
I have an Internal table with 3 fileds
and the second filed is of lengh 10,
In this filed i get the data which is of 4 character
I want the leading 6 0's to be added for that 2 field
For Eg
HI 1234 HELLO
HI 1222 HELLO
I need the Output as
HI 0000001234 HELLO
HI 0000001222 HELLO
ThanksHello,
>
Karthick raz wrote:
> HI Experts,
>
> I have an Internal table with 3 fileds
>
> and the second filed is of lengh 10,
>
> In this filed i get the data which is of 4 character
>
> I want the leading 6 0's to be added for that 2 field
>
> For Eg
> HI 1234 HELLO
> HI 1222 HELLO
>
>
> I need the Output as
>
> HI 0000001234 HELLO
> HI 0000001222 HELLO
>
> Thanks
Consider field2 is the second field that u have mentioned.
data: temp(4) type c,
field2 type n.
temp = '1234'.
write temp to field2 right justifield.
Hope this helps.
Thanks & Regards,
Anand Patil -
Adding leading zeros in abap objects.
Can anyone explain me
1. How to add leading zeros to a field in abap objects.
For eg:
data: dmb(6) type c value '123456',
actually the output value of c should have leading zeros added to it for length 16.
i.e '0000000000123456' . If the length of dmb is less than 16 then leading zeros should be added to that value to make it 16 as length.
Please tell me how to do it in ABAP Objects.Hi Camila
Try to use the statement
DATA: ALPHABET(15) VALUE ' ABCDEFGHIJ',
M1(4) VALUE 'ABCD',
M2(6) VALUE 'BJJCA '.
SHIFT ALPHABET LEFT DELETING LEADING M1.
The field
ALPHABET
remains unchanged.
SHIFT ALPHABET LEFT DELETING LEADING SPACE.
The field ALPHABET now has the following contents:
'ABCDEFGHIJ '.
SHIFT ALPHABET RIGHT DELETING TRAILING M2.
<b>ALPHABET</b> now has the following contents:
' ABCDEFGHI'.
<u><b>IN CHARACTER MODE</b></u>
<b>Effect</b>
This is the default setting (see above), and the addition is therefore optional.
<b>Note
Performance:</b>
For performance reasons, you should avoid using SHIFT in WHILE loops.
The runtime required to shift a field with length 10 by one character to the right or left requires about 5 msn (standardized microseconds). A cyclical shift requires around 7 msn. The runtime for the ...
LEFT DELETING LEADING
... variant is around 3.5 msn, for ...
RIGHT DELETING TRAILING
... around 4.5 msn.
Reward all helpfull answers
Regards
Pavan -
Adding Leading Zero's to a variable
Hi friends ,
<b>1.</b> I want to add leading zero's to a field .
Wxample - LIFNR , if its value in a variable is 16987 then i want to convert it to standard format (0000016987).
<b>2.</b> I want to convert date format to system's format. In Dev server and quality server it is in different format and i'm facing problem while uploading data using BDC.Also how i'll identify that in which format it is in production.
How to get itHi,
<u>Use these function Modules for ur problems..</u>
(1)For adding leading zeroes or in sap format internal..
CONVERSION_EXIT_XXXXX_INPUT
(2)For changing date into systems internal format..
CONVERSION_EXIT_XXXXX_INPUT.
u can find out conversion routines for each corresponding domain of that field in given below procedure.
Domain->Defintion->Output Characteristics-> Conversion routine.
Double click on that, it will show corresponding conversion routines.
Please add ur rewards.
With regards,
Rajesh -
How to delete decimal point and adding leading zeros....
Hi,
I have one requirement in the report i.e.
<b>Present Value :</b> 44567.98
<b>Expected Value :</b> 0000004456798
In the present Value how will I remove that decimal point and how to add those six ing zeros. I tried with CONVERSION_EXIT....but it is not giving. Help me...
Thanks in advance.
Regards,
Kumar.Hi,
Use SPLIT and COMCATENATE fnctions.
Eg: split l_v at '.' into l_v1 l_v2
concatenate l_v1 l_v2 into l_v.
For adding leading zeros
Use FM CONVERSION_EXIT_ALPHA_INPUT.
Eg:
data: tknum type vttk-tknum value '99156'.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = tknum
importing
output = tknum.
Sri
Message was edited by:
Sri Tayi -
@ adding leading zeros to a number
Hi,
How do I go abt adding leading zeros to a 8- digit number?
eg DATA: number(8) Type N.
number = 16.
How do i go about converting this to '00000016'.
Note that the value in variable number would be read frm a file (Inbound prog).Hi,
Use the function.
data: tknum type vttk-tknum value '99156'.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = tknum
importing
output = tknum
Regards -
How can i avoid leading zeros for a field in smartform?
how can i avoid leading zeros for a field in smartform?
Hi,
Using the Symbols.
&symbol(Z)& Omit Leading Zeros &symbol(S)& Omit Leading Sign
&symbol(<)& Display Leading Sign to the Left
&symbol(>)& Display Leading Sign to the Right
&symbol(C)& Compress Spaces
&symbol(.N)& Display upto N decimal places
&symbol(T)& Omit thousands separator
&symbol(R)& Right justified
&symbol(I)& Suppress output of the initial value
Regards,
Shiva Kumar -
Write a Function to remove or added leading Zeros
EXPLAIN.. in Detail
leading zeros
Re: how to add leading zeros to kunnr field
Removing Leading zeros
Re: compressing zeros
Reward points.. -
How to add leading zeros to kunnr field
Hi All,
I need to add leading zeros to KUNNR field runtime.
i.e for some customer it is displaying '2001084606'
some customer's it si displaying '10434'.
I want add leading zeros when customer length is
not equal to ten '10'.
plz kind let me know this is urgent.
Regards
BhaskarHi there,,
Kunnr is using a dataelement with Char 10.
You can do in this fashion to resolve your issue.
len = strlen (itab-kunnr).
len is having the lenght of the customer number.
if len < 10..
while len < 10.
concatenate '0' itab-kunnr into temp_text.
add 1 to len.
endwhile.
endif.
now finally you can assign temp_text to your itab-kunnr.
hope this way you can resolve your issue.
if found helpful,, don't forget to reward points.
Thanks-
Rahul. -
Function Module for adding Leading Zero's to a specific field
Hi,
Can anyone please provide a Function that will do the following:
1. Take the value of the field
2. Take the field type
3. Output the value of the field with leading zero's.
Anything similar would be very helpful.
Thank You & Best Regards,
JohnSure use the function CONVERSION_EXIT_ALPHA_INPUT, this will add leading zeros to a character based field of any length.
data: lv_c(10) type c value '123'.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = lv_c
importing
output = lv_c.
write:/ lv_c.
Regards,
Rich Heilman -
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 -
How to remove leading Zeroes in all fields in Payload
Hi,
How can I remove the leading Zeroes in every Filed I have in whole Payload Structure.there are around 10000 fields that have to be removed the leading Zeroes.any good idea please.
<POSNR>000010</POSNR>
<MATNR>000002465640</MATNR>
<ARKTX>000012 KG D107</ARKTX>
<MATKL>00030010000</MATKL>
<WERKS>0000ORGC</WERKS>
<LGORT>0000GC55</LGORT>
<CHARG>000TEST</CHARG>
like this mutliple segments and multiple Fields.so I can take as whole payload with multiple fields should not have leading Zeroes.I can handle if they are 10 0r 20 fileds,but not like whole pay load/1000 fields right.
thank you,
PremHi
You can have an additional XSLT mapping, to your existing one..
use copy-of & apply-templates to copy the whole tree & make changes recursively.
below is a sample code , the marked line is where you need to try your logic of trimming Zeros. (this code does upper case)
add this below code in your interface mapping object, as XSLT mapping, which does the job (only try putting your logic)
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:output method="xml"
indent="yes"
omit-xml-declaration="yes"/>
<xsl:template match="*">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="text()">
<xsl:value-of select="upper-case(.)"/>
</xsl:template>
</xsl:stylesheet>
hope this fixes your issue
Regards
Vishnu -
Adding leading zeros...
I have a number (let's say 12345) and I need to add 3 leading zeros to it and make it 00012345. I could do it by first converting the number to a string, concatenating '000' to it and then converting it back to a number.
I realize this is a trivial question, but how do you convert a number to a string and then back to a number in Oracle 10g?
Thanks.In reference to the above, I need to store a total of 8 characters in vTgtSALES.EMPLOYEE_ID. For example, if the vTempEmpID variable has 5 characters, I need to add 3 zeros, etc. I have the following code:
vTgtSALES.EMPLOYEE_ID:=CASE Length (LTrim(RTrim(vTempEmpID)))
WHEN 0 THEN WriteLog (pCmdID, pSubCmdID, 'Employee ID value has length of zero. WMC: ' || srcSALESNNM.WMC)
WHEN 1 THEN '0000000' || vTempEmpID
WHEN 2 THEN '000000' || vTempEmpID
WHEN 3 THEN '00000' || vTempEmpID
WHEN 4 THEN '0000' || vTempEmpID
WHEN 5 THEN '000' || vTempEmpID
WHEN 6 THEN '00' || vTempEmpID
WHEN 7 THEN '0' || vTempEmpID WHEN 8 THEN vTempEmpID
ELSE WriteLog (pCmdID, pSubCmdID, 'Employee ID value too long for field. WMC: ' || srcSALESNNM.WMC)
END;
The CASE clause does not seem to work - the actual value of vTempEmpID is stored in vTgtSALES.EMPLOYEE_ID without leading zeros being asses. What am I doing wrong?
Thanks. -
Adding leading zeros to the display data
hi folks,
I have the character variable of size 9, if I get the value of the variable less than 9, I need to add leading zeros to it accordingly before displaying the numeric value stored in it. I tried to use the 'SHIFT' command for that it did not work out.
here is the code..
data: len type I,
amount type C,
addspace len type I.
len = strlen( amount ).
write: ' the length of the string',len.
if ( len < 9 ).
addspace = 9 - len.
write: addspace.
SHIFT amount BY addspace Places LEFT.
Thanks in advance.Hi Santhosh,
All the suggestions here will work. Make sure that your number is on the right justified to your character field. Here is an example.
DATA: v_char09_left_justified(09) TYPE c,
v_char09_right_justified(09) TYPE c,
v_numc09(09) TYPE n.
START-OF-SELECTION.
*-- in case the value is left justified in the field
v_char09_left_justified = '9 '.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = v_char09_left_justified
IMPORTING
output = v_char09_left_justified.
WRITE:/ 'V_CHAR09_LEFT_JUSTIFIED from FM =', v_char09_left_justified.
v_numc09 = v_char09_left_justified.
WRITE:/ 'V_NUMC09 =', v_numc09.
*-- in case the value is right justified in the field
v_char09_right_justified = ' 9'.
SHIFT v_char09_right_justified LEFT DELETING LEADING space.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = v_char09_right_justified
IMPORTING
output = v_char09_right_justified.
WRITE:/ 'V_CHAR09_RIGHT_JUSTIFIED from FM =', v_char09_right_justified.
v_numc09 = v_char09_right_justified.
WRITE:/ 'V_NUMC09 =', v_numc09. -
Delete leading zeros for a field on the pdf form
Hi,
i know it is possible to delete leading zeros via abap coding in the interface.
But is it also possible to this directly on the pdf form - scripting or a setting?
Thank you
Kind regards
ManfredI believe you can set this up as a field display pattern (if you use LCD 8.1 or something like that).
Or you can script that out. In formcalc you can easily process characater by character, test if that is zero and remove it.
http://help.adobe.com/en_US/livecycle/es/FormCalc.pdf
Otto
Maybe you are looking for
-
AVI file (on SD) won't play
I'm trying to edit some movies on iMovie. But I can't even play my .AVI files. They have voice, but no video. The video turns to be white, with only voice. Even when I opened them in Quicktime, same problem. What should I do? Thanks in advance
-
XMPTextInput control height ignored in Flex 3 Properties
I need to set my XMPTextInput controls so that they have a height of 32. I have tried this in many different ways and none of them work. In Flex 3 in "Design" mode I select the control, open the properties tab and set the height to 32. The control
-
i keep the itunes encountered a problem and needs to shut down . it was working fine until after i updated to 10.5 can someone plz help
-
Can anyone help me with a ppt presentation on SAP workflow as I am new to it Thanks Debasis
-
Weblogic 8.1.6.0 JSP version
What version of JSP is Weblogic 8.1.6.0 running? According to documentation: http://download.oracle.com/docs/cd/E13222_01/wls/docs81/jsp/intro.html#49347 it's 1.2 but when I execute the following in a JSP page <%= JspFactory.getDefaultFactory().getEn