Skip to Content
avatar image
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 comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

5 Answers

  • Best Answer
    avatar image
    Former Member
    Jun 25, 2008 at 04:55 PM

    use the CONVERSION_EXIT_ALPHA_INPUT and CONVERSION_EXIT_ALPHA_output function module for the field

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    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 comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Subramanian,

      Even I had used in this way, I am not getting what I expected.

      What may be the problem is ?

      Do we have any alternative method to follow?

  • avatar image
    Former Member
    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 comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    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 comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    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 comment
    10|10000 characters needed characters exceeded