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

how to remove leading zeros from variable

Former Member
34,776

hi,

how to remove leading zeros from variable like it_vbap-matnr.

value in it_vbap-matnr is 000000000000000358

i want to remove leading zeros so that it become 358

regards

deepak

1 ACCEPTED SOLUTION
Read only

Former Member
13,543

Hi Deepak,

To remove leading zeros and leading blanks

Please use FM

CONVERSION_EXIT_ALPHA_INPUT Conversion exit ALPHA, external->internal

CONVERSION_EXIT_ALPHA_OUTPUT Conversion exit ALPHA, internal->external

Hope this resolves your query.

Reward all the helpful answers.

Regards

12 REPLIES 12
Read only

Former Member
13,544

Hi Deepak,

To remove leading zeros and leading blanks

Please use FM

CONVERSION_EXIT_ALPHA_INPUT Conversion exit ALPHA, external->internal

CONVERSION_EXIT_ALPHA_OUTPUT Conversion exit ALPHA, internal->external

Hope this resolves your query.

Reward all the helpful answers.

Regards

Read only

Former Member
0 Likes
13,543

use CONVERSION_EXIT_ALPHA_OUTPUT

or shift itab-matnr left deleting leading '0'.

regards

shiba dutta

Read only

13,543
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
            EXPORTING
              input  = wf_version
            IMPORTING
              output = wf_version.


Example:

input = 00000000000123 
output = 123
Read only

Former Member
0 Likes
13,543

Hi,

Use <b>shift it_vbap-matnr left deleting leading '0'</b>.

or you can move that to an integer variable .

Regards,

Sandhya

Read only

Former Member
0 Likes
13,543

use this

Convertion Exit

CONVERSION_EXIT_MATN1_OUTPUT

Read only

Former Member
0 Likes
13,543

Hi..

just take another variable of type integer and move this to that.

data:

w_n1(5) type n,

W_N TYPE I.

w_n1 = 56.

write: w_n1.

w_n = w_n1.

write w_n.

Message was edited by:

Rammohan Nagam

Message was edited by:

Rammohan Nagam

Read only

Former Member
0 Likes
13,543

Certain symbol values are printed with leading zeros. If you want to suppress these, use the Z option.

Syntax

&symbol(Z)&

suppose u have a vriable V_AMOUNT.

V_AMOUNT = 00000001234.40.

IF u write the &V_AMOUNT& THEN IT PRINTS 00000001234.40

IF u write the &V_AMOUNT(Z)& THEN IT PRINTS 1234.40

I hope every thisg is clear

Please Close this thread.. when u r problem is solved. Reward all Helpful answers

is it &V_VAR(C)&--> condence

&V_VAR(Z)&-->do not printLeading zeros

u can use these in Scripts and Smartforms

Message was edited by:

sunil kumar

Read only

Former Member
0 Likes
13,543

Hi Deepak,

Use syntax..

<b>SHIFT <VARABLE> LEFT DELETING LEADING '0'.</b>

<b>

Reward Points for Helpful Answer</b>.

Regards,

Tejas

Read only

Former Member
0 Likes
13,543

You can use Function Module <b>'CONVERSION_EXIT_MATN1_OUTPUT'</b>

This Function Module will eliminate leading Zeros.

For each MATNR Value read form DB Table,u can eliminate Leading zeros and then modify ur Internal table.

I think u will not get leading Zeros into utr Internal table when u read from VBAP.

Bcoz MATNR in VBAP itself have Conversion routine.

If u r getting leading zeros,U can use following Logic.

tables:

vbap.

data:

t_vbap like standard table of vbap.

select matnr

from vbap

into corresponding fields of table t_vbap.

loop at t_vbap into vbap.

CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT'

EXPORTING

INPUT = vbap-matnr

IMPORTING

OUTPUT = vbap-matnr

.

modify t_vbap from vbap transporting matnr.

endloop.

Hope this will work.....

Read only

Former Member
0 Likes
13,543

Hi Deepak

Just GOTO PATTERN and use CONVERSION_EXIT_ALPHA_OUTPUT u r done.

Regards,

Ram

Read only

0 Likes
13,543

I think if the variable is integer kind then we can remove the leading zero by using

Int var = Integer.parseint(integer);

Read only

Former Member
0 Likes
13,543

You can also do :

Shift Variable LEFT deleting leading zeroes..

Thanks .

Praveen .