‎2007 Jun 19 11:51 AM
Hello everybody,
I have requirement where in i need to insert spcaes into a string based upon a condition.
I have tried using the below code butits not working .
Can anybody suggest me if there is any other way out.
parameter : p_matnr(24).
data : len type i.
len = STRLEN( p_matnr ).
data : length type i.
length = 18 - len.
do length times.
concatenate p_matnr ' ' into p_matnr.
if sy-index = length.
concatenate p_matnr '000010' into p_matnr.
endif.
enddo.
write : p_matnr.
Helpful answers will b rewarded.
Thankx in advance.
Sanghamitra.
‎2007 Jun 19 12:17 PM
Hi,
what do you want to do exactly?
is it that way :
from a string like "xxxxxxxxxxx" with length lesser than or equal to 18, you would like to have a string "xxxxxxxxxxx 000010" on 24 chars? with enough spaces between the original string and the 6 chars long string enqueued?
if that's your issue, you could use overlay, you overlay a string of 24 chars, begining with 18 spaces and ending with your '000010'.
Hope that helps.
‎2007 Jun 19 11:56 AM
‎2007 Jun 19 12:05 PM
Hi,
Use Separated by Space.
<b>concatenate p_matnr '000010' into p_matnr separated by space.</b>
Regards,
Padmam.
‎2007 Jun 19 12:05 PM
solved....
i solved the issue myself by adding RESPECTING BLANKS at the end of concatenate statement.
This is the code.
parameter : p_matnr like mara-matnr.
data : str(24).
concatenate p_matnr '000010' into str respecting blanks.
write 😕 str.
Regards,
sanghamitra.
‎2007 Jun 19 12:06 PM
thanks a lot for ur response...
but even b4 that i could solve that....
have awarded points..
‎2007 Jun 19 12:12 PM
parameter : p_matnr(24).
data : len type i.
len = STRLEN( p_matnr ).
data : length type i.
data : v_ch,
pat(18).
length = 18 - len.
do length times.
concatenate v_ch space into pat separated by space.
if sy-index = length.
concatenate p_matnr '000010' into p_matnr separated by pat.
endif.
enddo.
regards
shiba dutta
‎2007 Jun 19 12:17 PM
Hi,
what do you want to do exactly?
is it that way :
from a string like "xxxxxxxxxxx" with length lesser than or equal to 18, you would like to have a string "xxxxxxxxxxx 000010" on 24 chars? with enough spaces between the original string and the 6 chars long string enqueued?
if that's your issue, you could use overlay, you overlay a string of 24 chars, begining with 18 spaces and ending with your '000010'.
Hope that helps.