Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

delete leading 0's by using shift.

former_member225134
Participant
0 Kudos
462

HI,

  I want to delete leading zeroes only if the local variable having numeric field.

suppose the local variable is alpha-numeric means i want to display the full digit.

EX.

  if lo_dcno = '0000000000052'  i want 52 only otherwards

     lo_dcno = '0000000sesese1' i want to display whole digits.

anyone give idea to solve this.

1 ACCEPTED SOLUTION

anubhab
Active Participant
0 Kudos
410

Hi Anitha,

     This might be helpful for you.

IF NOT lo_dcno  CA 'abcdefghijklmnopqrstuvwxyz'.

  SHIFT lo_dcno LEFT DELETING LEADING '0'.

ENDIF.

Regards,

Anubhab

9 REPLIES 9

rosenberg_eitan
Active Contributor
0 Kudos
410

Hi,

Try CONVERSION_EXIT_MATN1_OUTPUT

Regards.

Former Member
0 Kudos
410

Hi Anitha,

1. Use these Function Module

CONVERSION_EXIT_ALPHA_INPUT

2.  Use 'No-zero' Component

WRITE  lo_dcno no-zero.

Example:

REPORT  zc_convvert.

DATA : v1(10) TYPE n.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

  EXPORTING

    input  = '000AAA112'

  IMPORTING

    output = v1.

WRITE :v1 NO-ZERO.

OUTPUT:  AAA112

Regards,

Thrimu

FredericGirod
Active Contributor
0 Kudos
410

Hi,

conversion_exit ..  is a good idea

you could code this with something like this

do.

  if lv_value+sy-tabix(1) ne '0'.

    lv_len = strlen( lv_value ) - sy-tabix.

    lv_value = lv_value+sy-tabix(lv_len).

   exit.

endif.

enddo.

Former Member
0 Kudos
410

Hi,

you can try this:

I don't know how you declar DOCNO. You can use string or char.

Regards, Dieter

anubhab
Active Participant
0 Kudos
411

Hi Anitha,

     This might be helpful for you.

IF NOT lo_dcno  CA 'abcdefghijklmnopqrstuvwxyz'.

  SHIFT lo_dcno LEFT DELETING LEADING '0'.

ENDIF.

Regards,

Anubhab

0 Kudos
410

Hi,

Use the below code to check for number presence in the variable.

IF lo_dcno CO '0123456789'.

   SHIFT lo_dcno LEFT DELETING LEADING '0'.

ENDIF.

former_member225134
Participant
0 Kudos
410

Thanx to all,

  Issue solved.

Former Member
0 Kudos
410

Just use in fieldcatalog

    LS_FCAT-CONVEXIT = 'ALPHA'.

Regards,

Vadamalai A

Former Member
0 Kudos
410

Try using:

IF lo_dcno CO '0123456789 '.

   PACK lo_dcno TO lo_dcno. CONDENSE lo_dcno.

ELSE.

  "Do nothing

ENDIF.

Regards,

Óscar