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

add zeros

Former Member
0 Likes
968

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 ??

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
939

hi,

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

8 REPLIES 8
Read only

Former Member
0 Likes
939

use FM: conversion_exit_alpha_output for add leading zeros

Regards.

Dara.

Read only

Former Member
0 Likes
939

Use the FM: CONVERSION_EXIT_ALPHA_INPUT

Read only

Former Member
0 Likes
940

hi,

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

Read only

Former Member
0 Likes
939

Hi,

Try using CONVERSION_EXIT_ALPHA_OUTPUT Function Module by passing the field p_lv_amtchar1 for both import and export and print that variable, you will get the value with leading zeros.

Regards,

Satish

Read only

Former Member
0 Likes
939

actually p_lv_amtchar1 is character field.. so in char field i have to add leading zeros.

Read only

0 Likes
939

whatever it may be if you want to add leading zeros use FM:CONVERSION_EXIT_ALPHA_INPUT

or

UNPACK <field> TO <field>.

Reward if useful.

Dara.

Read only

Former Member
0 Likes
939

use FM :

CONVERSION_EXIT_ALPHA_INPUT

Read only

Former Member
0 Likes
939

DATA: INT TYPE I.

calculate length of p_lv_amtchar1.

INT = STRLEN(p_lv_amtchar1).

  • calculate how many zeros to contactenate.

INT = 18 - INT.

  • add the required zeros to the string to make 18 char word.

DO INT times.

concatenate '0' p_lv_amtchar1 into p_lv_amtchar1.

ENDDO.

write:/ p_lv_amtchar1.