Skip to Content
author's profile photo Former Member
Former Member

How to remove leading zeroes on form.

Hi all,

Is there a way that I can remove the leading zeros that come along with the Serial number from showing in my form.

i.e for example: the value of &QALS-EMATNR&

Actual value in the databse table is : "0280012380",

Printing value on the form is : "000000000280012380",

Now I should get the actual value of the field EMATNR

I had tried with the ways like..

&QALS-EMATNR(Z)&

&QALS-EMATNR(CIZ)&

Is there any aternatives???

Thanks,

Surender.

Add a comment
10|10000 characters needed characters exceeded

Related questions

5 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jun 25, 2008 at 04:55 PM

    use the CONVERSION_EXIT_ALPHA_INPUT and CONVERSION_EXIT_ALPHA_output function module for the field

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 25, 2008 at 04:48 PM

    Hi,

    The length of the field is char(18), so the leading zeroes are stored in the database table.

    If you want to suppress the zero, then what you entered is correct:

    &QALS-EMATNR(Z)&

    Regards,

    Subramanian

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 25, 2008 at 05:28 PM

    Hi

    If you print 000000000280012380 it means the value in the variable QALS-EMATNR is 000000000280012380.

    The field EMATNR has MATNR as domain, this is a type char long 18, it has the routines MATN1 for input/output convertion and that routine doesn't delete the leading.

    I think the option Z works for type number only, so u need to delete the leading zero before printing the data.

    So just as somebody said u can use the fm CONVERSION_EXIT_ALPHA_OUTPUT in order to convert the output format, u should use it in driver program:

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
           EXPORTING
                input  = QALS-EMATNR
           IMPORTING
                output = QALS-EMATNR.

    If you can't change the program, u can create a routine (form) in a new program and call it by the sapscript:

    /: PERFORM DELETE_LED_ZERO IN PROGRAM ZPROGRAM
    /: USING       &QALS-EMATNR&
    /: CHANGING &QALS-EMATNR&
    /: ENDPERFORM
    * &QALS-EMATNR(Z)&

    So create the new program where defining the routine

    FORM DELETE_LED_ZERO TABLES IN_TAB   STRUCTURE ITCSY
                                                            OUT_TAB STRUCTURE ITCSY.
    
      DATA: MATNR TYPE MATNR.
      
      READ TABLE IN_TAB  WITH KEY NAME = ' QALS-EMATNR'.
      IF SY-SUBRC = 0.
        MOVE IN_TAB-VALUE TO MATNR.  
    
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
              EXPORTING
                   input  = MATNR
              IMPORTING
                  output = MATNR
        READ TABLE OUT_TAB  WITH KEY NAME = ' QALS-EMATNR'.
        IF SY-SUBRC = 0.
           MOVE MATNR TO OUT_TAB-VALUE.
           MODIFY OUT_TAB INDEX SY-TABIX. 
        ENDIF.
    ENDIF.
    ENDFORM.

    Max

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 25, 2008 at 05:38 PM

    Hi,

    In script while you are writing &QALS-EMATNR& just include formatting option (Z) which means that it does not display leading Zeros..

    mention like &QALS-EMATNR(Z)&

    if you want to look at more formatting options in scripts which would be helpful for you click the below link.

    http://help.sap.com/saphelp_nw04/helpdata/en/d1/80345f454211d189710000e8322d00/frameset.htm

    This will solve your problem...

    Hope this would surely help you

    Regards

    Narin Nandivada

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 26, 2008 at 11:19 AM

    Hi Naveed,

    Thanks for your response, I got the solution from yor reply.

    I had rewared points to you and closing this thread.

    Max Bianchi,

    Thanks for your detailed response also, I got the output as I my requirment

    from your solutions. I tried to reward points to you also. But, I dont

    know y this is not able to reward for two equalent best answers.

    I want to give 10 points each to u both for best answers and closing this thread.

    Thanks & Regards,

    Surender Batlanki.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.