cancel
Showing results for 
Search instead for 
Did you mean: 

Concatenate space into a string

former_member418015
Participant
0 Kudos

Hi all,

I have a string of certain chars... i wish to check if the number of characters is less than 35 chars, i will need to add blank spaces behind the string. How can i do this in SAPScript? I tried the below code but it does not work. Pls help.

DATA: Z_INT TYPE I,

SPACE_NO TYPE I.

Z_INT = STRLEN( FCOY_NAME ).

IF Z_INT < 35.

SPACE_NO = 35 - Z_INT.

ENDIF.

DO 20 TIMES.

CONCATENATE FCOY_NAME &SPACE& INTO FCOY_NAME.

ENDDO.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

My requirement was to add 5 spaces in betwwen 2 strings and i wrote below code and it worked for me,

REPORT ztestttt.

DATA : kunnr TYPE kunnr,

        vkorg TYPE vkorg,

        text TYPE string.

DATA : lc(5) TYPE c VALUE '     '.

kunnr = 'W8400'.

vkorg = '2500'.

CONCATENATE kunnr vkorg INTO text SEPARATED BY lc.

WRITE : text.

Former Member
0 Kudos

write as

<b>&FCOY_NAME(F )&</b> in ur script

This will put leading spaces if less dan 35 chars r present

Hope dis helps..

former_member195383
Active Contributor
0 Kudos

Hi

Declare

constans : c_space type c value ' '.

notice..there's one space betn the inverted commas.If u want two spaces ,accordingly increase the length and give the value as ' '.i.e two spaces betn the inverted commas.

Then in concatanate statement use...

separated by c_space , at the end of the statement.

Hope this helps.

Regards

Rudra

former_member418015
Participant
0 Kudos

hi

thanks for your reply. But i only have 1 string. why should i use separated by space. I just need to insert x number of spaces behind my string.

former_member195383
Active Contributor
0 Kudos

if u want X no. of spaces at the begining

DO X TIMES.

CONCATENATE <b>''</b> FCOY_NAME INTO FCOY_NAME <b>separated by c_space.</b>

endo.

Notice that <b>"</b> two inverted commas with out any space.

and declare <b>c_space</b> as stated in the previous reply.

Regards

Rudra