Displaying leading zeros in ALV

Hi experts,
  I have a field of length 12 char. I want to display the field in grid.
My requirement is if the field is below 6 char(such as 101) i want to display as 000101 .I added logic for adding zeros up to six char but the leading zeros are supressed in my grid.
I want as 000101 but it is showing as 101.
I am using REUSE_ALV_FIELDCATALOG_MERGE for building the field catalog.
How to solve this.
Thanks & regards,
karthik.

Hi,
you must work with a mask for your field like this:
  repid = sy-repid.
  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
       EXPORTING
            i_program_name     = repid
            i_internal_tabname = 'MY_TABLE'
            i_inclname         = repid
       CHANGING
            ct_fieldcat        = field_catal.
  Modify field for leading 000
  LOOP AT field_catal INTO w_fieldcat_alv.
    CASE w_fieldcat_alv-fieldname.
      WHEN 'NUM_FELD'.                                    "<-- this is your field
        w_fieldcat_alv-edit_mask   = '000000'.
        MODIFY field_catal FROM w_fieldcat_alv.
    ENDCASE.
  ENDLOOP.

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

  • F8as2-displaying leading zeros in a dynamic text field

    F8as2-
    Background:
    Currently I have to use two different text fields to display 10000 due to the different font sizes.
    The 10 is a larger font and the 000 is a smaller font.  When I assign '0 'to the dynamic text fields of the smaller font I get just that a '0' not a '000' which is what I want.
    Question:
    Is there an easy way to display leading zeros in a dynamic text field?  Or can a dynamic text field have different character positions displayed in different font sizes?  or both?
    Thanks for the help.

    F8as2-
    Thanks for the reply kglad.
    Are for saying the best way to display numerically calculated numbers that need leading zeros and or different font sizes is to convert them to a string for display purposes with textFormatting??

  • Display Leading Zeros in bex query

    Hi,
    I am new to BI and need to display leading zeros in bex report.
    There is an info-object billing number which is of type CHAR. The values, 00001 - 00010 has been given in the CSV file.
    when i generate the same in IP, the leading zeros are mentioned, but the same is not appearing in the bex query.
    I have tried ALPHA conversion but this has no affect on the output.
    How to achieve the same??
    thanks in advance for the answers

    Hi,
    To answer your question in detail, there is a  conversion routine at infoobject level( Tab- general ), that determines how the values are displayed in the front end. For ex, alpha conversion routine takes away the leading zeros when you display the value in query. ( 0001 displayed as 1 )
    Assuming this is custom infoobject, I would suggest you to remove the conversion routine from the infoobject. This will help you in displaying leading zeros in the report.
    However, you have to ensure that all the values loaded for this infoobject is properly alpha converted ( packed with leading zeros ) by adding a field routine in the transformation. This will avoid same values getting stored with different internal formats like 01,001 etc.
    Hope this explains.
    Thanks.

  • Displaying leading zeroes

    Hi,
    I am facing a problem in displaying leading zeroes for a char in a BW report. This char has length 4 and it should show the value as 0ABC in the report but instead it displays just ABC. When checked the info providers, the data is right there.
    Technical details: length - 4, Conv Routine - ALPHA, BEx display - Key & text
    Could someone please throw some light on this?
    Thanks a lot in advance.

    Hi Bobs,
    Here is what I understood from your query;
    You have leading zeros for the char info object in the info provider but while running the query it is returning with the rest of the characters but not leading zeros?
    Yes while loading in to info provider ALPHA conversion does add any leading zeros according to the char size to load in to the info provider but while reporting it does the reverse ALPHA. but you have to check the values in the master data for the char info object where the default option for query results on char objects to retrieve key and text values from char object master tables. I think the master data for the char info object might not be have leading zeros.

  • Display leading zeros in OLE

    Hi Friends,
    When I am writing report in OLE( excel ), some of the fields which are having leading zeros automatically deleted . It shoud not happen . I have to display leading zeros also.
    Please tell me which class and method to do this ...
    Thanks ,
    Varma

    Use OLE itself to set the formatting of the cell (or column itself) to character type
    * character type for columns
    data: h_columns        TYPE ole2_object,
          h_cell           TYPE ole2_object.
    CALL METHOD OF excel 'Columns' = h_columns
      EXPORTING
        #1 = 'F:K'.
    set property of h_columns 'NumberFormat' = '@'.
    CALL METHOD OF excel 'Cells' = h_cell
      EXPORTING
        #1 = 14
        #2 = 7.
    SET PROPERTY OF h_cell 'Value' = '0001'.

  • Suppress leading zeros for ALV column

    Hello,
    I have an ALV with a column mapped to a context attribute of type NUMC and would like to suppress the leading zeros being displayed.  My initial solution was to change the attribute to a char/string type and remove the zeros in my code, but then, the sort functionality no longer works correctly.  Any ideas if the ALV can use a 'hidden' field to do the sorting for a certain column... that way, I can display the number as a char/string without the zeros and when the user sorts the column, the ALV will use the hidden NUMC type field.
    Thanx for any directions...

    Hi,
    You can follow the following way which i implemnted for one of my application. Here i am setting this property for the context attrubute. May be this will work. But in ALV there is no separate method for this type of setting.
    **This method is used to display the Leading zeros for the Lot Number in Step-1
      DATA:
        node_do_not_change                  TYPE REF TO if_wd_context_node,
        node_d0130_sapmf05a                 TYPE REF TO if_wd_context_node,
        node_pstap                          TYPE REF TO if_wd_context_node,
        node_info                           TYPE REF TO if_wd_context_node_info,
        ls_fprops                           TYPE wdy_attribute_format_prop.
      node_do_not_change = wd_context->get_child_node( name = wd_this->wdctx_do_not_change ).
      node_d0130_sapmf05a = node_do_not_change->get_child_node( name = wd_this->wdctx_d0130_sapmf05a ).
      node_pstap = node_d0130_sapmf05a->get_child_node( name = wd_this->wdctx_pstap ).
      node_info = node_pstap->get_node_info( ).
      ls_fprops = node_info->get_attribute_format_props( 'VALUE' ).
      ls_fprops-null_as_blank = if_wd_context_node_info=>c_format_null_as_BLANK.
      node_info->set_attribute_format_props(
        name              = 'VALUE'
        format_properties = ls_fprops ).
    Warm Regards,
    Vijay

  • How to display leading zeros in a report

    Hi folks,
    I am doing a HR report and the users are very much used to seeing a two digit numeric value as the pay scale since their legacy days.
    In BW, I have the Pay Scale defined as a character (2) and it shows the values on the report as follows:
    Pay Scale
    0
    1
    2
    3
    11, etc.
    But the users would like to see 00, 01, 02, 03, 11, etc.
    Under the query properties, display tab, there are four separate options - display zeros, show zeros as, etc. I tried all the options but the pay scale still does not show the leading zeros. I remember seeing a SAP note a while back that talks about this. Does anybody know how to force the leading zeros on the BEx report.
    Thanks.
    Abdul

    Try removing the ALPHA Conversion from info object defintion.

  • Displaying Leading Zeros

    Having recently switched to Mac and trying to embrace the iWork applications I've struggled with something that I really couldn't find help with. Since I think this is a relatively common need I am posting this message in the event others need to present a Numbers cell that has leading zeros.
    The way I have found to create leading zeros in numbers is by using the CONCATENATE and RIGHT functions. Say for example you have zip codes stored in numeric format (perhaps pulled in from a database) but need them to display in a cell properly. The zip code for Salem, NH is 03079. If you have the value 3079 stored you need that leading zero added.
    Assuming 3079 is stored in A1 you could add the following formula into an adjoining field:
    =RIGHT(CONCATENATE("00000",A1),5)
    CONCATENATE turns A1 into a string ("000003079") and RIGHT grabs the 5 right-most characters from that string.
    If someone else has a better way of handling this please do comment.

    DRAlison wrote:
    Having recently switched to Mac and trying to embrace the iWork applications I've struggled with something that I really couldn't find help with.
    Funny comment, this 'question' was asked and responded many times in this forum.
    Here are some links:
    http://discussions.apple.com/thread.jspa?messageID=8278267
    http://discussions.apple.com/thread.jspa?messageID=6639837
    http://discussions.apple.com/thread.jspa?messageID=6126095
    http://discussions.apple.com/thread.jspa?messageID=6856405
    http://discussions.apple.com/thread.jspa?messageID=7474228
    http://discussions.apple.com/thread.jspa?messageID=5270661
    http://discussions.apple.com/thread.jspa?messageID=9394800
    grabbed with a simple search in the existing threads using the keystring "leading AND zero"
    Yvan KOENIG (from FRANCE mardi 30 juin 2009 16:48:06)

  • Display leading zeros

    How to take an integer with no leading zeros and display it
    with leading zeros?
    Thank you in advance.

    There are a couple of ways. Let's say you are looking for 7
    digits altogether.
    Method 1
    NewString = '0000000' & thenumber;
    NewString = right(newString, 7);
    Method 2
    while (len(thenumber) lt 7)
    thenumber = '0' & thenumber;

  • Leading zero for a character datatype field in ALV display

    I have field access sequence value(VAKEY) which is concatenated by sales org, distibution chnl and division
    (0100/01/01).  the field is populating proprerly in internal tables, but in ALV display it is displaying as 100/01/01. How to consider leading zero in ALV for a CHAR datatype field.
    Thanks in Advance.

    Hi Srnii,
    You can use the below sample statement
    Shift mara-matnr right deleting trailing ' '.
    overlay mara-matnr with '0000000'.
    Thanks,
    Chidanand

  • ALV Leading ZERO issue

    There is leading zeros in internal table passing to FM 'REUSE_ALV_GRID_DISPLAY'
    but i am not able to see the leading zero in alv report display. how fix this.

    hi
    check out
    have u added no_zero(1)     type c, in fieldcatalog.
    if yes than remove it.
    else
    pass the value by function module 'CONVERSION_EXIT_ALPHA_INPUT' .
    hope this will help u.

  • 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

  • ALV: ADD leading ZEROs in a CHAR field

    Hello Everybody!
    I have a problem and I hope you can help me
    What I have:
    1. ALV (hier)
    2. Char field 'DEBIT' type SAKNR.
    3. Field catalog TYPE slis_t_fieldcat_alv,
       created by FUNCTION MODULE 'REUSE_ALV_FIELDCATALOG_MERGE'.
    The problem is: i need to show leading zeros in ALV.
    For example: an account '07110000' (in the inner table) is shown as '7110000'.
    What I've done:
    1. ls_fieldcat-lzero = 'X'.
         ls_fieldcat-no_convext = 'X'.
    2. CLEAR ls_fieldcat-ref_tabname.
         ls_fieldcat-lzero = 'X'.
    ( ls_fieldcat-ref_fieldname was clear after filling by the function module)
    I'm realy waiting for your advice!

    >
    nagaraj kumar nishtala wrote:
    > Hi,
    >
    > try to give refernce table name and reference field name for the field after the fieldcatalog merge FM.
    >
    > i mean to say modify the fieldcatalog for that particluar field  by giving refernce table name and reference field name .
    I've tried it, but it doesn't work:
        ls_fieldcat-outputlen = 8.
        ls_fieldcat-lzero = 'X'.
        ls_fieldcat-no_convext = 'X'.
        ls_fieldcat-ref_tabname = 'T599I'.
        ls_fieldcat-ref_fieldname = 'PARAM'.
        ls_fieldcat-datatype = 'NUMC'.
        ls_fieldcat-inttype = 'N'.
    >
    nagaraj kumar nishtala wrote:
    > or use conversion_exit_alpha_input to add zero's to it.
    >
    > Regards,
    > Nagaraj
    How can I use conversion_exit_alpha_input? I have no idea...

  • How to remove leading zero in a inputfield

    I have a inputfield UI element which is bind to a NUM type context.  When it display a number, it always come with leading zero, like '001'. Can anyone teach me how to remove the leading zero.

    http://help.sap.com/saphelp_nw70ehp1/helpdata/en/3a/2232666aeb45f4b759848a4caf9c8b/frameset.htm
    Use the Display leading zeros formatting option in the context attribute properties.
    The other option is to use a data dictionary domain for the field that has a built in field conversion exit. The ALPHA conversion exit is commonly used on NUMC fields like Sales Order number to suppress leading zeros.  The WD runtime will automatically use the underlying DDIC Domain Field Conversion Exit.  You don't need to do anything except use that DDic to define the context.

Maybe you are looking for

  • Transferring songs from my external HD straight to iPod

    Hello all Is there any way to transfer songs that I have stored on my external HD to my iPod without putting the files back on my computer? I connected my iPod to my computer without thinking to change the settings to manual, so I lost some stuff tha

  • Interference from neighbor's wireless network

    Hello, Whenever I boot up my computer the airport card on it somehow defaults to my neighbor's wireless network. How can I prevent their wayward signal from interfering? Thanks!

  • Cannot find report Invalid ID

    I am running Oracle10gAS, and running report from form and getting this message "FRM-41219: Cannot find report Invalid ID" The coding is declare      repid report_object;      v_rep varchar2(100); begin      repid:=find_report_object('erp_emp_asgn');

  • Suggest me please how to fix currupt rar files?

    I´ve download a rar file and finally i got a message that my rar file is currupt...is there a tool to fix it? Can someone help me with this?

  • Confused with datafile status in v$datafile and v$recovery_file

    Hi All, Am facing great confused problem in prod database, accidently i created datafile so i tried to drop it by using "alter database datafile' ' offline drop" But its showing recovery status in v$datafile and offline status in v$recovery_file. Ple