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.

Similar Messages

  • Display leading zeros in the ALV

    Hello All,
    My requirement is to display leading zeros in the ALV. The leading zeros are not getting displayed. Please suggest how do I achieve this. I have tries NO_ZERO = ' ' and lzero = ' '.
    Thanks in advance.
    Regards,
    Anju

    Here is the Sample code for your ref
    type-pools: slis.
    data: begin of t_itab occurs 0,
           col1 type matnr,
           col2 type char10,
          end of t_itab.
    data: t_fieldcat type slis_t_fieldcat_alv,
          w_fieldcat type slis_fieldcat_alv.
    t_itab-col1 = 10.
    t_itab-col2 = 'A'.
    append t_itab.
    clear t_itab.
    t_itab-col1 = 11.
    t_itab-col2 = 'B'.
    append t_itab.
    clear t_itab.
    loop at t_itab.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          input         = t_itab-col1
       IMPORTING
         OUTPUT        = t_itab-col1 .
       modify t_itab index sy-tabix.
    endloop.
    w_fieldcat-fieldname = 'COL1'.
    w_fieldcat-lzero = 'X'.
    append w_fieldcat to t_fieldcat.
    clear w_fieldcat.
    w_fieldcat-fieldname = 'COL2'.
    append w_fieldcat to t_fieldcat.
    clear w_fieldcat.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
       I_CALLBACK_PROGRAM                = sy-repid
       IT_FIELDCAT                       = t_fieldcat
       I_SAVE                            = 'X'
      TABLES
        t_outtab                          = t_itab
    EXCEPTIONS
       PROGRAM_ERROR                     = 1
       OTHERS                            = 2
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Regards,
    Bhavana

  • Adding leading zeros before data loaded into DSO

    Hi
    In below PROD_ID... In some ID leading zeros are missing before data loaded into BI from SRM into PROD_ID. Data type is character. If leading zeros are missing then data activation of DSO is failed due to missing zeros and have to manually add them in PSA table. I want to add leading zeros if they're missing before data loaded into DSO.... total character length is 40.. so e.g. if character is 1502 then there should be 36 zeros before it and if character is 265721 then there should be 34 zeros. Only two type of character is coming either length is 4 or 6 so there will be always need to 34 or 36 zeros in front of them if zeros are missing.
    Can we use CONVERSION_EXIT_ALPHPA_INPUT functional module ? As this is char so I'm not sure how to use in that case.. Do need to convert it first integer?
    Can someone please give me sample code? We're using BW 3.5 data flow to load data into DSO.... please give sample code and where need to write code either in rule type or in start routine...

    Hi,
    Can you check at info object level, what kind of conversion routine it used by.
    Use T code - RSD1, enter your info object and display it.
    Even at data source level also you can see external/internal format what it maintained.
    if your info object was using ALPHA conversion then it will have leading 0s automatically.
    Can you check from source how its coming, check at RSA3.
    if your receiving this issue for records only then you need to check those records.
    Thanks

  • Leading zeros are not displaying in the excel

    Hi Experts,
    Leading zeros are not displaying in the excel
    Here is the situation:
    I have developed one report, which will create the file in Application server with TAB deleimeted. After that I am sending that file via email in the excel format using Email functionality FM.
    Normally our material numbers will start with zeros.
    But when I check the email excel file , leading zeros are not displaying.
    Even I checked the application server (AL11) file, zeros are there.
    I thought program FM was wrong and I tried it manually by downloading the file into excel. Eventhough it is suppressing zeros.
    Could you please advise, how to display leading zeros to the material number in excel file.
    Thanks in advance
    Raghu

    Application server file showing  zeros infront of the material number.
    1200#  0012401387# XXXXXXXX
    Once file created in app server, I am using one custom FM to send that output in excel format / txt format via email.
    when I send txt file via email, I am getting leading zeros. But when I send xls file via email, I am not getting zeros.
    I checked custom FUNCTION MODULE . No mistakes in that.
    ===
    Sudhir,
    As you said, I passed ( ' ) single quote infront of the material number. When I check the excel file, single quote also displaying like this '0000100.
    Application server file showing like below
    1200#  '0012401387# XXXXXXXX
    ===
    Could you please advise anyone how can we acheive this.
    Thanks

  • 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

  • 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

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

  • Suppressing Leading Zeroes in the Query output

    Hi,
    I have selected a data field(0MATERIAL) as a free characteristics, It displays text and key and the key has leading zeroes.
    In the infoobject 0MATERIAL, ALPHA conversion routine is not selected, I can't change and insert the ALPHA right now because it would end up with reloading a large volume of data in different targets. To avoid this or to reduce the impact, in the reverse way,
    Could it be possible to suppress this leading zeroes at the query level? I was hoping that there would be a change that I could make at the query level, since it is 0Material and am looking at the point of minimal impact.
    Thank You.

    Hi Senthil,
    create InfoObject ZMATERIAL like a copy of 0MATERIAL, delete all the attributes and insert ALPHA conversion.
    Insert this ZMATERIAL like display attribute of 0MATERIAL. In InfoSource for 0MATERIAL map also ZMATERIAL with the same field that is feeding 0MATERIAL (MATNL). In your query insert 0MATERIAL and ZMATERIAL, and then hide 0MATERIAL (you need to insert also 0MATERIAL because ZMATERIAL is only in display), you will see only the values of ZMATERIAL, that is the material without the zeros in front.
    You can also decide to transform ZMATERIAL like navigational attribute, but in this case you have to change all the structure where do you want ZMATERIAL, because you need to flag it like navigational in that specific structure.
    Ciao.
    Riccardo.

  • [svn:fx-trunk] 12542: When adding a mask to the display list need to validate it and all its children .

    Revision: 12542
    Revision: 12542
    Author:   [email protected]
    Date:     2009-12-04 10:38:32 -0800 (Fri, 04 Dec 2009)
    Log Message:
    When adding a mask to the display list need to validate it and all its children.  Previously the children were not validated and their display list was updated before properties were committed or measure was done.  RichText was not set up to handle this.
    QE notes:
    Doc notes:
    Bugs: SDK-24511
    Reviewer:  Evtim, Deepa
    Tests run: checkintests, fxg, primitives, Group
    Is noteworthy for integration: no
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-24511
    Modified Paths:
        flex/sdk/trunk/frameworks/projects/spark/src/spark/components/supportClasses/GroupBase.as
        flex/sdk/trunk/frameworks/projects/spark/src/spark/utils/MaskUtil.as

    AFAIK, the only way to do this is to write a system modifcation.
    The BADI is executed only once at startup of the session, so that makes it merely static. (A strange point in time, I discussed it with SAP and they just shook their heads)
    I had the same problem with some other F4-Helps and it was a big hazzle. From my experience, no straight answer.

  • How to remove leading zeros from the screen?

    Hello friends,
    I am working on dialog programming.
    I have a field with is NUMC 13. so when value is populated, It removes the leading zeros.
    How can I display the my value with leading zeros on the screen painter?

    Call SE51, layout, double-click on field, attributes, tab Program, check Leading zeros.
    Regards,
    Raymond

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

  • 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

  • BAPI to remove leading zeros from the serial number

    Hi All ,
    plz can anybody suggest me the alternative BAPI for 'BAPI_SERVNOT_MODIFY_DATA ',whose function is to delete the leading zeros,from the serial number.
    Thanks.

    Perhaps instead of using a BAPI you can code it like this.
    DATA:serial(10) TYPE n VALUE '0000340078',
    pos TYPE i VALUE 1.
    START-OF-SELECTION.
      WHILE pos <= 10 AND serial+pos(1) = 0.
        pos = pos + 1.
      ENDWHILE.
      REPLACE ALL OCCURRENCES OF '0' IN serial(pos) WITH space.
      WRITE serial.

  • Want to hide/eliminate the leading Zeros in the Variable popup for0MATERIAL

    I have a requirement where 0MATERIAL is having leading zeros and it has the MATN1 conversion routine in the production system.I want to only remove the leading zeros in the Variable popup in report for 0 MATERIAL witohut changing the definition of the object as it has too much production data to change.
    Best Regards
    Tagore

    Hi,
    You will have to write some code in F4 help BADI, please refer the sap note 1416952. And you can take help of following function module to remove leading zeros,
    CONVERSION_EXIT_ALPHA_OUTPUT.
    If above thing doesn't help then you will have to create virtual key figure.
    Regards,
    Durgesh.

  • No leading zeros in the assignment field on a billing doc header

    Can someone tell me how I can get the assigment field in a billing doc not to show any leading zero's so when the assigment field is populated in the accounting doc it will not show the zeros either .
    At the moment I have the sales order PO set in copy control to show in the reference field and the assigment field of the billing doc header but need it to show no leading zeros in the accounting doc even if there is some in the SO.
    I.E
    sales orde PO no              Assignment field in billing doc             accounting doc
    0000012345                      0000012345                                        0000012345
    i need it to show NO zeros
                                               12345                                                  12345
    any ideas

    check this thread
    VBRK-XBLNR not copied to BKPF-XBLNR in transaction VF11.
    Note: Pls Text Removed
    Edited by: Lakshmipathi on Nov 1, 2011 10:42 AM
    Please dont ask for points in each of your suggestion and deviate the forum rules

Maybe you are looking for

  • Report for Comparison of Material Qty

    Hi All, I need to Develop an Interactive report for Comparison of Material Qty. ordered through Purchase requisition, ordered material through PO and corresponding Material Receipt report. Can Someone Give a brief description about this & fields tcod

  • Lost 1680x1050 resolution

    Clean install of SL last week with zero issues. Today used bootcamp to install XP. No problems noted. Boot into OS X, using my Westinghouse monitor as I have for many months now as my indoor display and the resolution is all messed up. I go into syst

  • Install certifcate on sun java web server 7.0

    we just moved away from IIS and servlet exec because of issues we are having with the speed. sun java web server was like 4 times faster. we had the web app up and running, but for some reason we couldnt figure out how to install a certificate. i wen

  • HT1386 i'm receiving error message; "The iPhone "___" could not be synched beacuse the sync session failed to start."

    this is continually happening.  This iPhone 4 had corporate information on it.  When I left the company on Monday, they remote-wiped the phone.  I knew this would happen.  Now I can't sync it at all!!! I started from "new" and attempted to rebuild fr

  • FACES not showing on Iphone 6

    FACES from my Mac do not appear in my iphone 6 PHOTO apps, why? It does in my iphone 4s with same settings