Leading zeroes in ABAP

How to remove leading zeros in ABAP?

shift <field> left deleting leading '0'.
U write ur code like this
data a(9) value '000012345'.
SHIFT a LEFT DELETING LEADING '0'.
write:/ a.
Output will be : 12345
Or use this method also
data a(9) value '000012345'.
Call function 'CONVERSION_EXIT_ALPHA_OUTPUT'
Exporting
input = a
Importing
output = a.
write a.
output:
12345.
Thanks and best of luck
Reward if useful
Ankesh

Similar Messages

  • 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

  • Need to strip the leading ZERO using ABAP code.

    Hi Friends,
    I got a situation where i got customer number called 011. I need to write an ABAP in Transformation to strip the leading ZERO , 11 should be posted to the master data attribute. could you help me in the logic pls.
    Thanks in advance,

    hi friends, i got a prob again, as i mentioned if i got 0 as prefix its deleting but if any 3 digit is comming it's converting in to 2 digit, as i mentioned if the prefix is 0(zero) then only i need to delete the zero.
    Is there any other solution for this..
    thansk in advance.

  • 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
    Manfred

    I 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

  • Selection without leading zeros in query

    Hi Gurus
    In report, we have defined variable for item no. 
    Is it possible to change the selection for a defined variable (item no.) not to require the leading zeros. Ex u2013 Instead of entering 000000123 , user enters only 123. Its very difficult to search when you are selecting specific item no.
    Thanks
    BIT

    Hi,
    Yep, the values in the cube will reflect in the query input screen, but I guess you need to drop and reload the data after the change, inorder to not reflect the old values.
    Check the below links for the reference:
    How to remove leading zero from Material Number
    Need to strip the leading ZERO using ABAP code.
    Remove Leading Zero
    Remove leading zeros
    Hope this helps...
    Rgs,
    Ravikanth.

  • ABAP-based web service returns numeric values with leading zeros

    Hi SOA experts,
    I have created a web service out of an ABAP function module. Beside other values, this service returns a list of document numbers. All of these numeric values are returned by the web service with leading zeros, but we do want these values w/o leading zeros.
    Any ideas how I can tell the web service to not print any leading zeros?
    Thanks in advance for your help!
    Kind regards, Matthias
    PS: The according function module does not print any leading zeros for the numeric values

    hi,
    just a guess: I'd try to use I instead of NUMC for the document numbers.
    NUMC is no number but a character string with numeric characters only. only some display routines in SAP know that this string of numerals represents a number and omit leading zeroes.
    my 2 cents,
    anton

  • Web Services  from ABAP function modules return values- leading zeros

    I am using several web services from SAP CRM (5.0) that were created from Function modules ( I am assuming that that they are in ABAP).
    I can call the web services fine and they work as expected, but I am seeing a lot of leading zeros in the return values of fields in tables from the Web service.
    The ABAP er’s are telling me that they cannot see the leading zero’s.
    So my question is where these are appended to the values in the whole process. When I execute the Function Module in SAP CRM from transaction SE37 I can see the leading zeros. So I think that this is something that has to be handled by the ABAP er’s and not in the client consuming the web service.
    Are the functions in SAP CRM that can remove leading zeros for fields in a table (that is an export parameter?)
    Jawahar

    Hello Jawahar
    If you run your (RFC-enabled) function modules using the SAP-GUI (i.e. in dialog) then the GUI automatically replaces leading zero when the function module returns any data. However, calling the same function module remotely you will always see these leading zeros.
    These so-called conversion exits are defined as attribute of domains in the ABAP dictionary. If the function module used for the WebService is a standard fm then you have little chances to get rid of the leading zero. Perhaps the WebService has some attribute to suppress conversion exits or activate them when retrieving the data.
    Regards, 
       Uwe

  • SQ01 ABAP Query - input field contains leading zeros

    Hi,
    I have a ABAP query where some of the values are stored with leading zeros in the table. This means that the user have to enter the leading zeros as well in the selection screen in SQ01 in order to get any output.
    What I would like to do is to restrict the input in the selection screen to allow only the digits without any leading zeros. For example, the user should not enter 000000000602590, but 602590. Also, the output should be without the leading zeros.
    Does anyone know how to do this in the InfoSet?
    Thanks in advance
    Br,
    Lars

    Hi Lars,
    The leading zeroes are appearing because your field is either a Numeric or Packed decimal.
    The leading zeroes can be suppressed if you  assign the packed to a Character field.
    You have option to change the datatype of the field in Infoset.
    Try converting it to equivalent character type.
    Let me know your findings.
    Thanks
    Ajay

  • 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

  • Need leading Zeros in the excel sheet which is sent from ABAP

    Hi ,
    I am downloading data from SAP to excel sheet using the WS_DOWNLOAD Function Module. The numeric data in not having leading zeros.  if it is 0010 it is displaying 10 in the excel sheet . i need the leading zeros in the excel sheet. without manulally changing it to Text in the excel sheet .
       Is there any way to do it .
    Thanks,
    Chetan

    Hi Chetan,
      CALL FUNCTION 'WS_DOWNLOAD'
        EXPORTING
          filename                = w_file_path
          filetype                = 'DBF'                       "declare the File type as DBF then leading zeros will appear
          write_field_separator   = 'X'
          confirm_overwrite       = 'X'
        TABLES
          data_tab                = Itab.
    Regards,
    Prabhudas

  • ABAP HR leading zero's for PERNR

    Hi,
    I am working on a report where I have select statements. When the pernr is given with out leading zeros its not taking it.. I need to make the pernr with leading zeros like
    if I hav pernr 35 its not getting data.. when i give 0000035 it gets.. so can i add the leading zeros to the pernr.
    if 3737 then it should be 00003737..
    how can i do this..
    Thanks.

    Hi Oscar,
    Use CONVERSION_EXIT_ALPHA_INPUT Function module.
    Please check this code...
    DATA: lf_pernr LIKE pa0000-pernr.
    MOVE '35' TO lf_pernr.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        input  = lf_pernr
      IMPORTING
        output = lf_pernr.
    OUTPUT: 00000035
    Best regards,
    raam

  • Remove Leading zeros for Material in Transformation

    Hi Experts,
    I'm using DTP first time. I don't have much exp on DTP & Transformations.
    I'm creating infocube with some objects. I want to remove leading zeros for zmaterial.
    In 3.x writen update routines as fallows:
    data: zmat(18) type c.
    zmat = COMM_STRUCTURE-/BIC/ZMAT.
    shift zmat left deleting leading '0'.
    result value of the routine
      RESULT = zmat.
    I'm confusing in Transfermation where to write this routines.
    I'm writing in Transformation as fallows:
    data: zmat(18) type c.
    zmat = SOURCE_FIELDS-/BIC/ZMAT.
    shift zmat left deleting leading '0'.
    RESULT = zmat.
    But it's getting remove zero's.
    Anybody suggest on this.
    Siri

    Dear Sir,
    No confusion at all.
    Just double click on the Target Infoobjct i,e Material object in Transformation, you will see a wizard popping up.
    There you will see a option called "RULE TYPE" and the default value will be "Direct Assignment". In the same check box click on the drop down icon and select "Routine".
    The moment you select the routine option, it will open up ABAP workspace where in you can write your routine and get the desired result.
    Hope it helps.

  • LEADING ZERO IN MONTH

    Hi,
    is there any possibility of adding leading zero for month column in query output without writing ABAP CODE.
    SDay for March ,instead of 3 i need 03 in qury o/p.
    Thanks,
    shaw

    Hi,
    is it possible that u mean to eleminate the leading "zero" of a KF text variable?
    If yes, u can do this with the following steps:
    1. Go to query designer -> select your text variable
    2. Edit variable -> replacement path
    3. Section Offset settings-> edit offset start and offset lenght
    I dont know how 0Month is displayed, but with these two u can define at which point u the offset starts and how many text digits u want to display.
    For ex. 0FISCPER is displayed 0012008 normally, if u set offset start as 2 and offset lenght as 5 the result is 12008
    Hope it helps
    Regards

  • Leading zeros

    Hi Gurus
    how do i remove leading zeros before filed i have tried the ALPHA Converstion it did not work please help i m new in BI explain tthe whole procedure if we have to use any abap routine/
    thanks

    Hi,
    You code in Bw 3.5 should look like this
    data: tmp_"your field" like TRAN_STRUCTURE-"your field"
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
         EXPORTING
              INPUT  = TRAN_STRUCTURE-"your field"
              IMPORTING
              OUTPUT = tmp_"your field"
    Translate tmp_"your field" to upper case. //If this is a character
      RESULT = tmp_"your field".
    and in BI7 I think TRAN_STRUCTURE becomes SOURCE_FIELDS.
    Regards,
    Nikhil

  • Leading zeros from data downloads

    Hello!
    While downloading data from the ABAP tables, Excel removes the leading zeros automatically but in some SAP tables (NAST for example), those leading zeros are necessary to find the required associated data. Is there any way to prevent Excel from removing these zeros?
    Thanks a lot!

    Hi,
    There are two ways to solve it.
    1) select complete columns in the Excel sheet and then assign the number format as ' TEXT ' in the sheet.Then u ll be able to see the leading zero's
    2) If u donot want to wrk in Excel the way i have mentioned,then in the abap program just use the FM
    "CONVERSION_EXIT_ALPHA_INPUT" over that field before uploading in  a table.
    By mistake i have told u the wrong way.the first way is for copying the data from text file to excel file and preserving the leading zeros.
    regards
    kanishak
    Edited by: Kanishak Gupta on May 6, 2009 5:36 AM

Maybe you are looking for

  • SOLUTION to "Software required for communicating with the iPod is not insta

    Folks, I can not take credit for this.....you should send your checks to MarkinMadison. I've included his post in it's entirety. For me, this was the Holy Grail !! My only comment is make sure when you are in the registry that you hit the "apply" but

  • Difference in KE30 report and FGI0 report

    Hello I'am new to CO-PA, My user has come up with a unique problem. He is running a report on the profit center group for a month in transaction code KE30 for FICOPA reconcilation . It displays some value in order settlement. I checked in KE24 and th

  • How do I delete stuff in iCloud

    How do I view and delete files in icloud

  • Report to get cost objects (CC and GL)

    I need a report to see Purchasing Document Vendor Material Group Plant Storage Location Document Date Document Type Document Category Purchasing Group Purchasing Organization Document on Hold Supplying Plant Cost Center GL Account Simillar to ME80FN

  • Sending mail when  Goods Receipt created

    Hi , I am new to Workflow, I have the following requirement When ever Goods Receipt  created system automatically generate Goods Receipt output(smartform) and send a mail to user who has created Goods Receipt with PDF doc (goods receipt ) . Please te