Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

add zeros

i have writter below code..

DATA: lv_amt1(18) TYPE c,

lv_amtint1(14) TYPE n,

lv_amtint2(3) TYPE n,

lv_sign(1) type c.

IF p_lv_fieldval >= 0.

lv_sign = '+'.

ELSEIF p_lv_fieldval < 0.

p_lv_fieldval = p_lv_fieldval * -1.

lv_sign = '-'.

ENDIF.

WRITE : p_lv_fieldval TO lv_amt1 NO-GROUPING.

SPLIT lv_amt1 AT '.' INTO lv_amtint1 lv_amtint2.

SHIFT lv_amtint1 RIGHT DELETING TRAILING space.

SHIFT lv_amtint2 LEFT DELETING LEADING space.

p_lv_amtchar1+1(14) = lv_amtint1.

p_lv_amtchar1+15(3) = lv_amtint2.

SHIFT p_lv_amtchar1 LEFT BY 1 PLACES.

CONCATENATE lv_sign p_lv_amtchar1 '0' INTO p_lv_amtchar1.

here p_lv_amtchar1 is 18 length..

what i have to do is that i have to utilize full 18 places i.e. if amt comes as in my case "+ 45714240" so i want to dispaly as "+00000000045714240"

so how to padd zeros in front of amount depending upon the value. there should not be places between + sign and amt, the place should be filled with zeros.

how to to this ??

Tags:
Former Member
Former Member replied

hi,

U can use 'UNPACK' keyword, for the required field.

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question