SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

перевод каретки на новую строку. MS Word



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP
View previous topic :: View next topic  
Author Message
Abaper_rus
Участник
Участник



Joined: 19 Dec 2013
Posts: 5

PostPosted: Thu Dec 19, 2013 4:24 pm    Post subject: перевод каретки на новую строку. MS Word Reply with quote

Доброе время суток, уважаемые ГУРУ абапа.

Возник вопрос.

Как перенести в MS Word каретку на новую строку. Константы cl_abap_char_utilities=>cr_lf и cl_abap_char_utilities=>newline не помогают. Обе отображаются как пробелы.

Выгружаю через xslt программу преобразований. С помощью call transformation с последующем сохранением на жестком диске и открытием DOC-овского файла.
Back to top
View user's profile Send private message
vga
Мастер
Мастер


Age: 200
Joined: 04 Oct 2007
Posts: 1218
Location: Санкт-Петербург

PostPosted: Thu Dec 19, 2013 5:36 pm    Post subject: Reply with quote

Если у вас xml исходник, попробуйте такие символы (для excel пробелы надо убрать):
Code:
  IF i_program = lc_excel.
    l_delimiter = '& # 1 0 ;'.
  ELSEIF i_program = lc_winword.
    l_delimiter = '<w:br/>'.
  ENDIF.

_________________
Молитва - это запрос разработчику на изменение кода программы.
Back to top
View user's profile Send private message Blog Visit poster's website
Abaper_rus
Участник
Участник



Joined: 19 Dec 2013
Posts: 5

PostPosted: Thu Dec 19, 2013 5:49 pm    Post subject: Reply with quote

Немного не понял, что значит "xml" исходник?

Вот как я вывожу. В результате переноса на новую строку не происходит.
Code:

DATA: str_data type c length 100.
DATA: lv_xml   type xstring.

str_data = 'TESTNEWLINE'.

concatinate str_data cl_abap_char_utilities=>cr_lf str_data into str_data.

call transformation ztest_newline
source str = str_data
result xml lv_xml.
Back to top
View user's profile Send private message
vga
Мастер
Мастер


Age: 200
Joined: 04 Oct 2007
Posts: 1218
Location: Санкт-Петербург

PostPosted: Thu Dec 19, 2013 5:59 pm    Post subject: Reply with quote

Поставьте в качестве разделителя '<w:br/>', посмотрите что будет....
_________________
Молитва - это запрос разработчику на изменение кода программы.
Back to top
View user's profile Send private message Blog Visit poster's website
Abaper_rus
Участник
Участник



Joined: 19 Dec 2013
Posts: 5

PostPosted: Thu Dec 19, 2013 6:04 pm    Post subject: Reply with quote

Этот тэг и выводится как строка. Кажется у меня есть кое-какая идея.
LV_XML надо объявить текстовой. А потом, после замены, переводить в xstring.
Back to top
View user's profile Send private message
Abaper_rus
Участник
Участник



Joined: 19 Dec 2013
Posts: 5

PostPosted: Thu Dec 19, 2013 6:06 pm    Post subject: Reply with quote

Благодарю, все работает! Если надо - завтра выложу код.
Back to top
View user's profile Send private message
vga
Мастер
Мастер


Age: 200
Joined: 04 Oct 2007
Posts: 1218
Location: Санкт-Петербург

PostPosted: Thu Dec 19, 2013 8:52 pm    Post subject: Reply with quote

Конечно выкладывайте!
_________________
Молитва - это запрос разработчику на изменение кода программы.
Back to top
View user's profile Send private message Blog Visit poster's website
Abaper_rus
Участник
Участник



Joined: 19 Dec 2013
Posts: 5

PostPosted: Fri Dec 20, 2013 11:23 am    Post subject: Reply with quote

vga wrote:
Конечно выкладывайте!


Code:

CONSTANTS: lc_splitter type c LENGTH 1 VALUE '~'.

DATA: lv_sxml type string.
DATA: lv_xml type xstring.
DATA: str_data type c length 100.

str_data = ''TESTNEWLINE'.

concatinate str_data lc_splitter str_data into str_data.
CALL TRANSFORMATION ztest_newline
SOURCE str = str_data
RESULT XML lv_sxml.

REPLACE ALL OCCURRENCES OF lc_splitter in lv_sxml with '</w><w><w>'.
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
    TEXT = lv_sxml
IMPORTING
    BUFFER = lv_xml
EXEPTIONS
    OTHERS = 0.
Back to top
View user's profile Send private message
sam750
Участник
Участник



Joined: 27 Feb 2013
Posts: 1

PostPosted: Thu May 15, 2014 5:43 pm    Post subject: Reply with quote

в продолжение темы:

тоже делаю выгрузку, но в Excel, точно также как и автор темы.

при попытке передать '& # 1 0 ;' (ес-но без пробелов), при трансформации "&" меняется на "&amp", и ес-но, ничего не переносит, а "красиво" выводит кучу лишних символов. Smile

никак не могу придумать, как же обмануть систему. Sad может кто подсказать, где и в чем, я ошибаюсь?

add: символы для переноса не в коде трансформации, а переменной, передаваемой в трансформацию из ABAP
Back to top
View user's profile Send private message
Tomatos
Участник
Участник


Age: 38
Joined: 20 Sep 2010
Posts: 24

PostPosted: Tue Jan 12, 2016 3:41 pm    Post subject: Reply with quote

Понимаю, что поздно, но мало ли кому пригодится Smile (как раз с этим только что столкнулся)
DATA:
_repl TYPE string VALUE '& # 10 ;', БЕЗ ПРОБЕЛОВ
_repl2 TYPE string VALUE '&amp;#10;',
_xrepl TYPE xstring,
_xrepl2 TYPE xstring
.

CALL FUNCTION 'SSFH_STRING_TO_XSTRINGUTF8'
EXPORTING
cstr_input_data = _repl
codepage = '4110'
IMPORTING
ostr_input_data = _xrepl
EXCEPTIONS
conversion_error = 1
internal_error = 2
OTHERS = 3.

CALL FUNCTION 'SSFH_STRING_TO_XSTRINGUTF8'
EXPORTING
cstr_input_data = _repl2
codepage = '4110'
IMPORTING
ostr_input_data = _xrepl2
EXCEPTIONS
conversion_error = 1
internal_error = 2
OTHERS = 3.

Дальше после трансформации делаем замену
REPLACE ALL OCCURRENCES OF _xrepl2 IN xml_result WITH _xrepl IN BYTE MODE.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.