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: 
Read only

delete leading 0's by using shift.

former_member225134
Participant
0 Likes
2,484

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
Read only

anubhab
Active Participant
0 Likes
2,432

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
Read only

rosenberg_eitan
Active Contributor
0 Likes
2,432

Hi,

Try CONVERSION_EXIT_MATN1_OUTPUT

Regards.

Read only

Former Member
0 Likes
2,432

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

Read only

FredericGirod
Active Contributor
0 Likes
2,432

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.

Read only

Former Member
0 Likes
2,432

Hi,

you can try this:

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

Regards, Dieter

Read only

anubhab
Active Participant
0 Likes
2,433

Hi Anitha,

     This might be helpful for you.

IF NOT lo_dcno  CA 'abcdefghijklmnopqrstuvwxyz'.

  SHIFT lo_dcno LEFT DELETING LEADING '0'.

ENDIF.

Regards,

Anubhab

Read only

0 Likes
2,432

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.

Read only

former_member225134
Participant
0 Likes
2,432

Thanx to all,

  Issue solved.

Read only

Former Member
0 Likes
2,432

Just use in fieldcatalog

    LS_FCAT-CONVEXIT = 'ALPHA'.

Regards,

Vadamalai A

Read only

Former Member
0 Likes
2,432

Try using:

IF lo_dcno CO '0123456789 '.

   PACK lo_dcno TO lo_dcno. CONDENSE lo_dcno.

ELSE.

  "Do nothing

ENDIF.

Regards,

Óscar