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 spaces to data.

Former Member
0 Likes
1,001

I have a data field of 40 char.

e.g. lv_type = 'LOAN'

should display as " LOAN"

means though lv_type is 4 characters it should take 40 characters and add 36 spaces.

so how to add spaces appropriately.

if lv_type is 6 characters it should add 34 spaces.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
979

This works


DATA: inval(4) TYPE c,
      outval(40) TYPE c.

inval = 'LOAN'.
WRITE inval TO outval RIGHT-JUSTIFIED.
WRITE:/ outval.

I have a data field of 40 char.

e.g. lv_type = 'LOAN'

should display as " LOAN"

means though lv_type is 4 characters it should take 40 characters and add 36 spaces.

so how to add spaces appropriately.

if lv_type is 6 characters it should add 34 spaces.

6 REPLIES 6
Read only

Former Member
0 Likes
979

Hi

Better try to declare the variable with length 40.

After getting the variable make a command like this

Shift left lv_vbeln deleting leading space.

Thanks and Regards

arun joseph

Read only

Former Member
0 Likes
979

Hi,

Try declaring it as VARCHAR or LONGVARCHAR.

Reward if helpful.

regards,

Ramya

Read only

Former Member
0 Likes
980

This works


DATA: inval(4) TYPE c,
      outval(40) TYPE c.

inval = 'LOAN'.
WRITE inval TO outval RIGHT-JUSTIFIED.
WRITE:/ outval.

Read only

0 Likes
979

Hi

Try to declare a variable like this.

Data : x(40)

Once you got the variable in the field u have declared what ever for example we name it as y.

Then make a assignment like this.

Y = X.

Hope it will works

Arun Joseph

Read only

Former Member
0 Likes
979

Hi santosh,

1. This is one way. Just copy paste.

2.



report abc.


data : lv_type(40) type c.
data : ln type i.

lv_type = 'LOAN'.

*-------------------------- before
write :/ lv_type.

*-------------------------- after
ln = strlen( lv_type ).
ln = 40 - ln.
shift lv_type right by ln places.
write :/ lv_type.


regards,

amit m.

Read only

Bhaskar_Tripath
Participant
0 Likes
979

Hi,

Just try this code:

DATA: VAR(10) TYPE C,

INT TYPE I,

LEN TYPE I.

VAR = 'ABC'.

WRITE: / VAR.

DESCRIBE FIELD VAR LENGTH LEN IN CHARACTER MODE.

INT = STRLEN( VAR ).

INT = LEN - INT.

SHIFT VAR BY INT PLACES RIGHT.

WRITE: / VAR.

Reward if useful.

Regards,

Bhaskar