@ 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
Similar Messages
-
Problem adding leading zero to a number using JavaScript
I am trying to put the elapsed time into a slide using a display such as "7:08" - seven minutes and 8 seconds. Problem is I can't for the life of me get that 0 to display before the 8. Here is my Javascript, which is executed upon entering a slide:
var objCP = document.Captivate;
var ElapsedTimeInSeconds = Math.round(objCP.cpEIGetValue('rdinfoCurrentFrame') / objCP.cpEIGetValue('rdinfoFPS'));
var ElapsedMinutes = Math.floor(ElapsedTimeInSeconds / 60);
var ElapsedSeconds = ElapsedTimeInSeconds - (ElapsedMinutes * 60);
if (ElapsedSeconds < 10) {
ElapsedSeconds = ElapsedSeconds.toString();
ElapsedSeconds = '0' + ElapsedSeconds;
objCP.cpEISetValue('ElapsedMinutes', ElapsedMinutes);
objCP.cpEISetValue('ElapsedSeconds', ElapsedSeconds);
Here is the text in the slide:
Time: $$ElapsedMinutes$$:$$ElapsedSeconds$$ / $$TotalMinutes$$:$$TotalSeconds$$
So for an ElapsedSeconds value of 1-9, I want to pad one zero. This, however, doesn't work. If I substitute another number of letter for zero in the statement "ElapsedSeconds = '0' + ElapsedSeconds;" it works as expected. I'm thinking there is some quirk going on, because it makes no sense to me why I cannot prepend a zero character to a string.
Thanks for any help.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 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 -
Trouble adding leading zeros to numbers in PowerShell script
I am new to PowerShell scripting (so have mercy on me please!), and I'm trying to write a script that takes simplified, menu-based user input to create a folder on the network named based on a month number and the year. The month must be expressed as a two-digit
number, but I'm trying to make it simple enough that the user only needs to input a one-digit number (for the first nine months of the year) and have the script add the leading zero (for example, if a user inputs the number "2" for February, the
script will output "02").
Here is a portion of my script:
# Get current year
$year = Get-Date -Format yyyy
# Provide menu of months for user to choose from
Write-Host "Choose the name of the month for the folder you want to create."
Write-Host "1. January"
Write-Host "2. February"
Write-Host "3. March"
Write-Host "4. April"
Write-Host "5. May"
Write-Host "6. June"
Write-Host "7. July"
Write-Host "8. August"
Write-Host "9. September"
Write-Host "10. October"
Write-Host "11. November"
Write-Host "12. December"
Write-Host " "
Do {
$mNum = Read-Host "Select the number of the month (1 - 12): "
# Convert the menu item to the month name
switch ($mNum)
1 {$month = "January"}
2 {$month = "February"}
3 {$month = "March"}
4 {$month = "April"}
5 {$month = "May"}
6 {$month = "June"}
7 {$month = "July"}
8 {$month = "August"}
9 {$month = "September"}
10 {$month = "October"}
11 {$month = "November"}
12 {$month = "December"}
default {"Invalid entry. Please select a number from 1 - 12 (without the trailing period)."}
# Validate user input. Current code is cumbersome; try to find more elegant method.
While ($mNum -ne 1 -and $mNum -ne 2 -and $mNum -ne 3 -and $mNum -ne 4 -and $mNum -ne 5 -and `
$mNum -ne 6 -and $mNum -ne 7 -and $mNum -ne 8 -and $mNum -ne 9 -and $mNum -ne 10 -and `
$mNum -ne 11 -and $mNum -ne 12)
# Add leading zeros to month number
$fNum = "{0:D2}" -f $mNum
Write-Host $fNum
When I run it, I don't get the leading zero. However, when I create a very basic script, it seems to work:
$mNum = 3
$fNum = "{0:D2}" -f $mNum
Write-Host $fNum
Can anyone offer any suggestions as to what I might be doing wrong?
Also, if anyone has a suggestion on how to better validate the user input (making sure they enter a number between 1 and 12), I would appreciate that as well..NET formatting is a complicated subject
http://msdn.microsoft.com/en-us/library/26etazsy(v=vs.110).aspx#FormatStrings
I'm not sure how all that documentation applies when you attempt to format a value that is already a string.
In general, formatting is described as "Formatting is the process of converting an instance of a class,
structure, or enumeration value to its string representation". If it is already a string I'm not sure what to expect.
For example,
<# C: #> '3',3,'03',03,'003',003 | % { "{0:D2}" -f $_ }
3
03
03
03
003
03
<# C: #> -
Appending leading zeros to material number
Hi,
I want to form a object key for material number. so i need to append leading zeros to material number. but i am getting "TYPE CONFLICT" shot dump in FM 'BAPI_OBJCL_GETDETAIL'.
The following code is giving the dump.
data: wa_object(18) type c.
wa_object = '100301010'. "Material No
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = wa_object
IMPORTING
OUTPUT = wa_object.
CALL FUNCTION 'BAPI_OBJCL_GETDETAIL'
EXPORTING
OBJECTKEY = wa_object
OBJECTTABLE = 'MARA'
CLASSNUM = 'FINISHED_MATERIAL'
CLASSTYPE = '001'
KEYDATE = SY-DATUM
UNVALUATED_CHARS = ' '
LANGUAGE = SY-LANGU
TABLES
ALLOCVALUESNUM = IT_ALLOCVALUESNUM
ALLOCVALUESCHAR = IT_ALLOCVALUESCHAR
ALLOCVALUESCURR = IT_ALLOCVALUESCURR
RETURN = IT_RETURN
but if I hard code to 18 characters, the following code is working fine:
CALL FUNCTION 'BAPI_OBJCL_GETDETAIL'
EXPORTING
OBJECTKEY = '0000000000100301010'
OBJECTTABLE = 'MARA'
CLASSNUM = 'FINISHED_MATERIAL'
CLASSTYPE = '001'
KEYDATE = SY-DATUM
UNVALUATED_CHARS = ' '
LANGUAGE = SY-LANGU
TABLES
ALLOCVALUESNUM = IT_ALLOCVALUESNUM
ALLOCVALUESCHAR = IT_ALLOCVALUESCHAR
ALLOCVALUESCURR = IT_ALLOCVALUESCURR
RETURN = IT_RETURN
Please tell me how to rectify the short dump which uses Conversion_exit_alpha_input.
Thanks .
SankarHi Shankar,
When ever u pass parameters to any function module the type of parameters must match with the ones defined in function module. Here u defined ur object key like this
data: wa_object(18) type c.(18 digits). But the in function module it referenced with BAPI1003_KEY-OBJECT (50 digits). So u have to define the variable with BAPI1003_KEY-OBJECT.
Check this solution. It will work for u.
data: wa_object(18) type c,
wa_object1 TYPE BAPI1003_KEY-OBJECT.
wa_object = '100301010'. "Material No
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = wa_object
IMPORTING
OUTPUT = wa_object.
wa_object1 = wa_object.
CALL FUNCTION 'BAPI_OBJCL_GETDETAIL'
EXPORTING
OBJECTKEY = wa_object1
OBJECTTABLE = 'MARA'
CLASSNUM = 'FINISHED_MATERIAL'
CLASSTYPE = '001'
KEYDATE = SY-DATUM
UNVALUATED_CHARS = ' '
LANGUAGE = SY-LANGU
TABLES
ALLOCVALUESNUM = IT_ALLOCVALUESNUM
ALLOCVALUESCHAR = IT_ALLOCVALUESCHAR
ALLOCVALUESCURR = IT_ALLOCVALUESCURR
RETURN = IT_RETURN
Thanks,
Vinod. -
We are using SU Managment
How do we get rid of leading zeros in SU# number range. System is storing pallet ID # with leading zeros in the LEIN table. This is causing issues while we retrive SU data from the tables, systems ask to enter the SU# number with leading zeros.
My Pallet Tag is printed with out leading zeros SU # 1234567890 and when the user tries to put away using LM02 system does not read the pallet ID. It looking for 00000000001234567890.
Even on desktop LS33 if I try to display a pallet with SU # 1234567890 system looks for SU Num. with leading zeros. Is there a way to get the leading zeros off from SU#
Appriciate your helpPlease check in SPRO whether the conversion exit is maintained for Storage Unit Management. Follow the below path to do so.
SPRO -> Storage Unit Management - > Master Data - > Define Number Ranges. In the Pop Up choose "Conversion exit for storage unit number" .
Here you can define the "length of SU Numbers "
Regards,
Kumaran -
How to remove leading zero from Material Number
Hello Everyone,
I need to figure it out how to remove leading zero from material number. Cureently extractor is sending material number as 100663. But when comes into BI i am getting as "000000000000100663" and similariy in report it is appearing as "000000000000100663". Now my client wants me to exclude preceeding zero for a material in all the reports.
Is there any setting in query desinger to handle this issure or in the backend.
Need your inputs.
Thanks,
Lasya.Hi
you can use the function Module
CONVERSION_EXIT_ALPHA_OUTPUT in the start routine
to test this go to SE37 --- give the CONVERSION_EXIT_ALPHA_OUTPUT -
>display -
> F8
in the input give 000000456
and execute
the out put will be 456
for getting Zeros you can use
CONVERSION_EXIT_ALPHA_INPUT--- to remove leading zeros
Santosh
Edited by: Santhosh Nagaraj on Oct 29, 2009 10:52 PM
Edited by: Santhosh Nagaraj on Oct 29, 2009 10:54 PM -
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 -
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 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. -
How can I format a cell in Numbers to have leading zeros in a number?
I imported a spreadsheet from Excel (Office 2014, Win 7) through iCloud and some numbers were formatted to have leading zeros (012358) in the original Excel file but the leading zero format was lost in Numbers. Is there a way to format cells to have a number displayed with the leading zero in Numbers? The leading zero is part of an identification and is important to the numbers (0027 is not the same as 27 in these records).
thanks,
BobJames has the formating part, but if you already did the import you can use the following formula to replace the zeros that were leading if you know it is a four digit reference number....
=right("000" & A2,4)
copy those values into your text formatted column from James' answer and you got it.
Jason -
Need to show leading zeros in the number field when printed from RDF
We have a requirement to show leading zeros in the rdf output.
We cannot use a format mask to achieve the same as the length of the field is not fixed.
for ex if we have 0.68 then the same is printed in RDF as .68
we cannot use a format mask as the length of the field is not fixed.
we need to
Kindly suggest if any solution exists for the same.the numbers after the decima can be anything..
it can range between 2 to 10 or more...
as told by you if we put the format as to_char(.68,'90.99') it shall give 0.68 but what for numbers like0.678,0.4567,0.765433 it will display only 2 digits after the decimal...
The requirement is to dispaly the number as it is ,only the zeroes before the decimal should stay intact..
we are not able to achieve this in rdf output..
if it is
0.678 then 0.678 shld be dispalyed
0.4567 then 0.4567
0.765433 then 0.765433
one format mask shld wrk for all the above..
we would not be changing the format mask for each number.... -
How to delimit leading zero in vendor number in OO ABAP ALV without using conversion routine
Hi,
How to delimit leading zero in OO ABAP ALV without using conversion routine, because I have many fields like vendor, customer, material number etc..
How to address this leading zero.
I appreciate your quick response.
Regards,
Nalini S.Hi Nalini,
Delimiting leading zeros in fields has to be done via conversion routines, as suggested by Vadamalai you need to pass on the conversion routine name in you field catalog variable.
Now as to which object oriented approach are you using to have your table contents display in ALV as it matters -
Using FACTORY method of CL_SALV_TABLE class, or
Using SET_TABLE_FOR_FIRST_DISPLAY method of CL_GUI_ALV_GRID class.
Using FACTORY method of CL_SALV_TABLE will do your own work, no need to apply any conversion routines or set long/medium/short text for columns as we do in field catalogs!
Cheers,
Varun -
The leading zero in serial number..
Hi all,
Does anyone happen to know how to stop SAP from erasing the leading zero when entering a Serial number. I'm using profile 0003 (standard) and when a GR is posted the leading zeros are removed?
Any help would be greatly appreciated.
Best regards
Begüm A.In the Standard SAP system, it is not possible to stop it from truncated the leading zeros.
But if you are using ECC6.0 and using Industrial Solutions, you may use the modification
introduced by note 198285 to achieve this functionality.
Maybe you are looking for
-
How to provide hyperlink for a particular field in ALV
Hi, How to provide hyperlink for a particular field in alv report. Regards, Ramu.
-
I recently exchanged my faulty iPad while travelling.i backed it up to brother's laptop and fneedlessly backed up all iTunes purchases.... I synced new iPad with brother's laptop and now all albums appear but none will play. Any suggestions? Many tha
-
Seriously, What am I supposed to feel about this?.
I didn't know what I should think about and I could not put up with this anymore. Roughly a month ago, I had to take my laptop to the tech support again since I had found out a new issue related to a wierd line on the LCD screen. As the laptop had al
-
Change height of column in Analysis
Hi, I have a simple analysis that I use to write comment back to the database, it works fine but the users have asked if I can increase the size of the input box on the dashboard. I have had a look and I can't find any default functionality to do thi
-
Jsf page url don't show full path on address bar.
Hi, my problem is jsf page url don't show full path on address bar. 1st page located on: http://127.0.0.1:7101/ViewController/faces/home.jspx 2nd page located on:http://127.0.0.1:7101/ViewController/faces/pages/private/main.jspx when click 2nd page c