Application Development 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: 

add leading spaces

Former Member
0 Kudos

Hello,

i have a char field with length = 30

in this field there is a 4 characters long value

i have to write this field in a file but with the 26 leading spaces ahead.

basically, i have XXXX and i would like to have ______________XXXX

i tried to concatenate spaces but it does not work.

How can i manage that please ?

Thanks

1 ACCEPTED SOLUTION

Former Member

Hi,

Try the following :

shift field right deleting trailing space

This should work.

Please reward points if this helps.

Regards,

Nicolas.

6 REPLIES 6

ferry_lianto
Active Contributor
0 Kudos

Hi,

Please try this.


DATA: NUM      TYPE I,
      TEXT(30) TYPE C.
                                               
TEXT = 'XXXX'.
NUM = STRLEN( TEXT ).
DO NUM TIMES.
  SHIFT TEXT LEFT CIRCULAR.
ENDDO.                                                              
WRITE: / TEXT.

Regards,

Ferry Lianto

Former Member

Hi,

Try the following :

shift field right deleting trailing space

This should work.

Please reward points if this helps.

Regards,

Nicolas.

Former Member
0 Kudos

Please see in the below sample code:

data: amount(9) type c,

numc_amount(9) type n.

  • If char field only contains numeric data

if amount co '0123456789 '. "Added a space in here!"

numc_amount = amount.

endif.

  • If the numc amount is filled.

if not numc_amount is initial.

  • Do something with it! (for example: WRITE)

write: / 'Number is: ' numc_amount.

endif.

Hope that helps.

Please give me reward points

Thanks

Murali Poli

Former Member
0 Kudos

Hi,

The Data Type Char is Left-Justified.

So u have to use SHIFT command to add leading Spaces.

<b>SHIFT STRING BY 26 PLACES RIGHT.</b>

Regards,

Padmam.

g_lacroix
Explorer
0 Kudos

Hello,

try CONDENSE, it will delete the spaces before.

best regards.

Former Member
0 Kudos

Thanks a lot guys

the shift field right deleting trailing space command works just as i wanted it to