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,
John

Sure 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

Similar Messages

  • Function module to remove leading zeros

    hi,
       is der any functional module to remove leading zeros
    thanks and regards
    Nikesh kumar

    Hi,
    You can use the <b>FM CONVERSION_EXIT_ALPHA_OUTPUT</b> and if you want to do in program do as below :
    shift <fieldname> left deleting leading '0'.
    Thanks,
    Sriram Ponna.

  • Function Module to put leading zero

    Hi,
    Function that puts leading zeros. I am getting a text file which has got cost center as 1234, but i need to put leading zero in order to check the availability of the value in the table csks.
    I want a function module which puts leading zero.

    hi,
    Use FM <b>'CONVERSION_EXIT_ALPHA_INPUT'</b>
    <b>FU CONVERSION_EXIT_ALPHA_INPUT</b>
    Text
    Conversion exit ALPHA, external->internal
    ALPHA conversion is used especially with account numbers. During conversion from the external to the internal format, the system checks to see if input in the INPUT field is purely numeric, that is, if this input consists only of numbers, possibly with spaces before and after them. If this is the case, then the number string is inserted right- justified in the display field OUTPUT and all spaces to the left of the value are filled with zeroes ('0'). If the input is not purely numeric, it is inserted in the display field from left to right and all extra spaces are filled with blanks.
    Example:
    (Input field and output field are both eight characters in length)
    1. '1234    ' --> '00001234'
    2. 'ABCD    ' --> 'ABCD    '
    3. ' 1234   ' --> '00001234'
    Conversion from the internal to the external format (function module CONVERSION_EXIT_ALPHA_OUTPUT) is undertaken in exactly the opposite manner.
    Parameters
    INPUT
    OUTPUT
    Exceptions
    Function Group
    ALFA
    Regards,
    Santosh

  • Any BAPI/Function Module for adding new record with dates in PA0027

    Hi all,
    I am tryig to find is there any BAPI/Function module for updating new record with Start Date and End date for specified Personal Number in PA0027 Table.
    In PA0027 table i will be passing start date and end date for selected personal number, it needs to add new record with this details in the table checking the condition that this start date and end dates should not be between any of of start date and end dates for the specified personal number.
    thanks for ur time.
    Murali

    Hi Raj/Suresh thanks for ur answers.
    but i am having a problem,i gave this values.
    INFTY               -
                0027
    NUMBER              -
                00000010
    SUBTYPE             -
                010
    OBJECTID
    LOCKINDICATOR
    VALIDITYEND         -
                03/12/2006
    VALIDITYBEGIN       -
                03/01/2006
    RECORDNUMBER        -
                000
    RECORD              -
                P0027
    OPERATION           -
                CHK
    TCLAS               -
                A
    DIALOG_MODE         -
                0
    NOCOMMIT            -
                Y
    VIEW_IDENTIFIER
    SECONDARY_RECORD
    i am getting short dump saying that
    The source field is too short.
    The current program, "SAPLHRMM", tried to assign a field to a field symbo
    However, the field is shorter than the type of the field symbol, which
    is not allowed.
    The statement in question is in the form ASSIGN f TO <fs> CASTING or
    ASSIGN f TO <fs> with a field symbol that was created using the
    STRUCTURE addition.
    I tried  operation - Chage,Create (same thing for all inputs)
    is this correct funtion moduel for my requirment?
    what ever i am passing the start and end dates this should check in the table records with this personal number and if this start date and end dates are not between of any start and end dates then it should add new record with this dates.
    Thanks for ur time.
    Murali.

  • 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

  • Function module for adding number of months to the date

    Hi,
    Is there any function module to get the date by adding number of months...
    Regards,
    Yadagiri

    Normally all SAP FM will return that value. As 1 month in general means 30 days only.
    You can check the code in this link for logig of 31 -
    add month in the date to find next date
    Regards,
    Amit

  • Function Module for adding components to Production Order

    Is there a function module that can add components to an existing production order ?I believe CO_BC_INSERT_CMP_OF_ORDERS can do the trick but seems this alone would not suffice .Your feedback is very much appreciated

    Sudhir,
    U r right. we need to call the function module CO_BC_INSERT_CMP_OF_ORDERS with flg_banf_create  = X and apt entries in the component details table resbb_ins. Doing this is enough. I guess u have a problem passing correct data in the internal table. For the data you do not know, you will have to pass default data.
    Hope this helps.

  • Adding leading zeros to a non-numeric field

    Hello
    I have an application which currently does not validate a field and the user can enter any string on this specific field. The customer wants me to write a view to bring information from a child table which uses the free format field as the key to join.
    Example, the field A is free format, but, we would expect something like "0000001-AB', however the users are inputing '1' or '001-AB'. The client wants to see these cases to be displayed (and joined) as '0000001-AB'. The format is 7 digits + '-' + two digit code.
    I would like to know, how can I display this on a view, since most of my cases are '1' or '001-AB'. But there are others with crazy things like '1+2+3+4' and these cases are giving me an error of "invalid number" since I am using the TO_NUMBER function so far.
    Thanks!
    Eduardo Ferrari

    WITH t AS (SELECT '1' txt FROM DUAL
               UNION
               SELECT '001-AB' FROM DUAL
               UNION
               SELECT '1+2+3+4' FROM DUAL)
    SELECT CASE
              WHEN LENGTH ( (REGEXP_REPLACE (txt, '[-AB]') || '-AB')) < 10
              THEN
                 LPAD ( (REGEXP_REPLACE (txt, '[-AB]') || '-AB'), 10, '0')
              ELSE
                 REGEXP_REPLACE (txt, '[-AB]') || '-AB'      
             end  txt
    from t
    TXT
    0000001-AB
    0000001-AB
    1+2+3+4-ABunion
    Edited by: pollywog on Nov 10, 2010 3:41 PM
    Edited by: pollywog on Nov 10, 2010 3:53 PM

  • ANY FUNCTION MODULE TO ADD LEADING ZEROS FOR A CHARACTER FIELD

    THE CHARACTER FIELD IS OF LENGTH 40 AND IT HAS 5 NON NUMERIC CHARACTERS

    Hi ,
    Try this
    DATA : c4(40).
    data : P_FIELD(40) TYPE N.
    UNPACK P_FIELD to c40.
    <b>Reward Points if useful</b>
    Regards
    Saket Sharma

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

    Hi,
    <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

  • How to create the INBOUND Function Module for INBOUND IDOCs

    Hi Friends,
    Can any Suggest me How to proceed to Create an INBOUND Function Module for Processing the INBOUND IDOCS
    which are recieved from XI Server ?
    I am working in SAP-ISU
    Here i will recieve the INBOUND IDOCs for the Meter Reading Orders.
    We have a Standard INBOUND FUNCTION MODULE
    IDOC_INPUT_ISU_MR_UPLOAD
    which Uploads the Meter Reading Results.
    I copied the Same function Module into ZIDOC_INPUT_
    and working on it.
    Can any one suggest me, whether i am going in correct way or not.
    In IDOC_INPUT_ISU_MR_UPLOAD Inbound fun module,
    BAPI_MTRREADDOC_UPLOAD is used to Update or Insert the Meter Reading Results,
    My requirment is to Insert and Update the Meter Reading Orders which are Inbounded from XI.
    Can I Use the Same BAPI
    BAPI_MTRREADDOC_UPLOAD
    to Update the below fields,
    EABL-SERNR
    EABL-ZWNUMMER
    EABLG-ABLESGR
    EABL-V_ZWSTAND
    EABL-N_ZWSTAND
    EABL-ABLHINW
    EABL-ZSKIPC
    EABL-ADAT
    EABL-ATIMTATS
    EABL-ADATTATS
    EABL-ATIM
    EABL-ZMESSAGE
    EABL-ABLESER(Meter reader number)
    Kindly Suggest me,
    Thanks in Advance,
    Ganesh

    Hello Ganesh
    I think you are going completely astray with you z-function module for IDoc processing.
    If you look at TABLES parameter METERREADINGRESULTS (type BAPIEABLU ) of BAPI_MTRREADDOC_UPLOAD you will find many of the requested fields already:
    EABL-SERNR => BAPIEABLU-SERIALNO
    EABL-ZWNUMMER =>REGISTER
    EABLG-ABLESGR
    EABL-V_ZWSTAND
    EABL-N_ZWSTAND
    EABL-ABLHINW
    EABL-ZSKIPC
    EABL-ADAT
    EABL-ATIMTATS => ACTUALMRTIME
    EABL-ADATTATS => ACTUALMRDATE
    EABL-ATIM
    EABL-ZMESSAGE
    EABL-ABLESER(Meter reader number)
    Field EABL-ZMESSAGE appears to be custom field (at least I cannot find it on ECC 6.0). If this field was added using include CI_EABL then you probably can get these values into the BAPI using the EXTENSIONIN parameter.
    Check routine CHECK_UPLOADRECORDS in the BAPI which allows two extension structures:
    - BAPI_TE_EABL
    - BAPI_TE_EOSB
    Not surprisingly BAPI_TE_EABL contains the include CI_EABL.
    Regards
      Uwe

  • Function Modules for Data and Time

    Hi all,
              I need 2 function modules for date and time. when we pass current data(sy-datum) and current time (sy-uzeit) into function modules, shoud get date in <b>dd/mm/yyyy or dd.mm.yyyy</b> and time in<b> HH:MM:SS</b> formats.
    Thanks in advance

    Hi Ranjith,
    i think this will b usefull for you..
    SAP Bar Chart Function Modules and what they are used for
    Function module
    Used for
    BARC_GRAPHIC_PBO
    Starting bar chart at PBO time, using a graphic profile (parameter PROFILE)
    BARC_GRAPHIC_PAI
    Analyzing data returned by the graphic
    BARC_SET_TIME_AXIS
    Setting start and end of time axis
    BARC_SET_OPTIONS
    Setting options
    BARC_ADD_CHART
    Creating a chart
    BARC_SET_CHART_ATTRIB
    Setting chart attributes
    BARC_ADD_SECTION
    Creating a section on the time axis
    BARC_SET_SECTION_ATTRIB
    Setting section attributes
    BARC_ADD_RIBBON
    Adding a ribbon to the time axis
    BARC_SET_RIBBON_ATTRIB
    Setting attributes for ribbons in the chart
    BARC_ADD_GRID
    Adding a time grid
    BARC_SET_GRID_ATTRIB
    Setting grid attributes
    BARC_ADD_LAYER
    Adding a layer (graphic elements)
    BARC_SET_LAYER_ATTRIB
    Setting layer attributes
    BARC_ADD_LINE
    Adding a line
    BARC_ADD_CALENDAR
    Creating a calendar
    BARC_SET_CALENDAR_ATTRIB
    Setting attributes for a calendar
    BARC_ADD_TIME_PROFILE
    Creating time profiles
    BARC_SET_TIME_PROFILE_ATTRIB
    Setting attributes for time profile
    BARC_ADD_INTERVAL
    Adding a time interval
    BARC_SET_INTERVAL_ATTRIB
    Setting time interval attributes
    BARC_ADD_TIME_OBJECT
    Creating a time object
    BARC_CONVERT_DATE
    Creating a date string in bar chart format
    BARC_REVERT_DATE
    Converting a date string in bar chart format to date and time
    BARC_ADD_DATELINE
    Creating a date line
    BARC_SET_DATELINE_ATTRIB
    Setting dateline attributes
    BARC_GET_PROFILE_CONTENTS
    Obtaining profile contents for customizing a chart
    BARC_GET_COLUMN_WIDTH
    Selecting new column width
    BARC_SET_COLUMN_WIDTH
    Setting the column width
    BARC_GET_TEXTINDEX
    Obtaining the text index of a field
    BARC_SET_LABELS
    Positioning the chart display
    BARC_SET_COLUMN_ATTRIB
    Setting column attributes
    BARC_SET_ROW_ATTRIB
    Setting row attributes
    BARC_SET_ROW_HEIGHT
    Setting the line height
    BARC_SET_MAXCHARTS
    Setting the maximum number of charts sent
    <b>If its usefull reward points
    </b>

  • Function Module for open Purchase Order & Sales Order?

    Hi, commonly I read the data from tables and calculate the open quantity for sales order and purchase order, but I want to know, are there any standard function modules for getting the list of open "purchase order" and "sales order" respectively?
    Thanks and Regards.

    hi Ren,
    u can check all these bapi's related to salesorder
    BAPI_SALESORDER_CHANGE Sales order: Change Sales Order
    BAPI_SALESORDER_CONFIRMDELVRY Sales Order: Confirmation of Delivery; Document Flow Update
    BAPI_SALESORDER_CREATEFROMDAT1 Sales order: Create Sales Order
    BAPI_SALESORDER_CREATEFROMDAT2 Sales order: Create Sales Order
    BAPI_SALESORDER_CREATEFROMDATA Create Sales Order, No More Maintenance
    BAPI_SALESORDER_GETLIST Sales order: List of all Orders for Customer
    BAPI_SALESORDER_GETSTATUS Sales Order: Display Status
    BAPI_SALESORDER_SIMULATE Sales Order: Simulate Sales Order
    May be this FM can help you
    MB_ADD_PURCHASE_ORDER_QUANTITY (Reading and adding open purchase order quantities)
    Regards,
    Naveen

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

Maybe you are looking for

  • How to retrieve the path where AE is installed?

    Is there any code I can use that will return a string of an absolute path where AE is installed on its host? Thanks, Laz

  • Does vbios br35757.027 for gx740 exist?

    I found this. So i would like to know is it fake or real? download http://narod.ru/disk/27364497000/GX740-HD5870-Normal.bin.html this page is in russian so you can translate it in google services and if it is real why i can't find it in official link

  • T-code for Report painter.

    Hi can anyone tell me, Is there any transaction code for report painter or it is an external tool.?? Thanks Utpal

  • Iterating through available virtual servers...

    Hello, I am writing a NSAPI filter on Sun ONE Web Server 6.1. Can someone point me to the docs that describe how one could programmatically iterate through all the virtual servers/sites, associated port numbers, etc., using Sun's C/C++ API? Thanks!

  • Can't Uninstall Dreamweaver!

    This is ridiculous. After having issues getting setup.exe to start (had to set explorer as my default browser for it to work; don't ask me why), I now have a problem where I can't re-install dreamweaver as it thinks dreamweaver is already installed.