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: 

Space

Former Member
0 Kudos

Experts!

Do you have any idea on how i can separate '#' from its right side character.

example::

<b>TEXT</b>

#SHINE (NO SPACE)

<b>TEXT</b>

  1. SHINE (# ONE SPACE FROM SHINE)

Thanks!!!

9 REPLIES 9

gopi_narendra
Active Contributor
0 Kudos

You can make use of the SPLIT command.

See the F1 help of how to use it.

DATA : text(30) TYPE c.
DATA : text1(30) TYPE c,
       text2(30) TYPE c.

text = '# String'.

SPLIT text AT '#' INTO text1 text2.
CONDENSE text2 NO-GAPS. " removes spaces
WRITE : text1, text2. " text2 gives you STRING

Regards

Gopi

0 Kudos

Master ,

I think my question is not clear.

Again sir ,

My problem is I want to have one space from '#' character to its right side character.

I have a text field name description::

example::

description field::

color blue #house.

I want to achieve this::

color blue # house.

Did you see the difference?In the first text '#' house appears no space I want to have a space in between '#' character and in the right character like this '#' one space house.

Why I need to have this..

Because when I download the file in the excel the problem is every '#' found the right character after the '#' proceeds to the next line which is wrong so I want to have at least one space between '#' character and to its right side character to avoid this error..

I hope i made it clear..

Sorry for the inconvinience...

Many thanks..

Help me!!!

0 Kudos

Please try this ...

data: begin of itab_data occurs 0 ,

matnr like mara-matnr,

maktx like makt-maktx,

cr type x value '0D', <-- add this line

end of itab_data.

start-of-selection.

itab_data-matnr = '0000000000000000098'.

itab_data-maktx = '1234567890'.

append itab_data.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

FILENAME = 'C:\testddd.txt'

FILETYPE = 'ASC'

WRITE_FIELD_SEPARATOR = ' '

TRUNC_TRAILING_BLANKS = ' ' <-- set to space

TABLES

DATA_TAB = itab_data

EXCEPTIONS

FILE_WRITE_ERROR = 1

NO_BATCH = 2

GUI_REFUSE_FILETRANSFER = 3

INVALID_TYPE = 4

NO_AUTHORITY = 5

UNKNOWN_ERROR = 6

HEADER_NOT_ALLOWED = 7

SEPARATOR_NOT_ALLOWED = 8

FILESIZE_NOT_ALLOWED = 9

HEADER_TOO_LONG = 10

DP_ERROR_CREATE = 11

DP_ERROR_SEND = 12

DP_ERROR_WRITE = 13

UNKNOWN_DP_ERROR = 14

ACCESS_DENIED = 15

DP_OUT_OF_MEMORY = 16

DISK_FULL = 17

DP_TIMEOUT = 18

FILE_NOT_FOUND = 19

DATAPROVIDER_EXCEPTION = 20

CONTROL_FLUSH_ERROR = 21

OTHERS = 22.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Thanks

Seshu

0 Kudos

Master ,

Kindly explain what is

WRITE_FIELD_SEPARATOR = ' '

TRUNC_TRAILING_BLANKS = ' '

I did follow your advise and it seems good. But I need to verify first what does these functions are for?? Before I transport in QAS.

Many thanks!!

0 Kudos

Hi Salma,

try this code

data old type string value 'color blue#house'.
data new type string.
data pos like sy-fdpos.

search old for '#'.
if sy-subrc = 0.
  pos = sy-fdpos + 1.
endif.

concatenate old(pos) old+pos into new separated by space.
write:/ new.

0 Kudos

Hello Salma,

I had a same issue and please check the my thread :

Thanks

Seshu

0 Kudos

Seshu,

I think you pasted the wrong link

0 Kudos

Oh I am so sorry Kris ,copy and paste was the problem at my system.

Anyhow check it now :

Thanks

Seshu

Former Member
0 Kudos

Hi Salma,

You are getting # this problem arise becasue of length problem look if you are using DAT format then also you have to maintain the length of a field, which is define in data dictionary, as you are using Excel to upload/download the it will take tab sapce(1 tab = 8 space) between the field, so to mark the end of one field to have to use some seperator which you mention as 'X' caps. try to put X in the call function hope it will resolve problem.

FILENAME = '<Drive:\><filename.etx>'

FILETYPE = 'ASC'

WRITE_FIELD_SEPARATOR = 'X'

Reward if helpful!

Regards,

Mehfuze