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

Пробел между полями



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP
View previous topic :: View next topic  
Author Message
Влад
Специалист
Специалист



Joined: 26 Dec 2007
Posts: 63

PostPosted: Fri Jan 25, 2008 1:41 pm    Post subject: Пробел между полями Reply with quote

Соединяю два поля как в примере ниже, вместо ожидаемого
25-01-2008 10:25:25
вижу
25-01-200810:25:25

пробел пропал. Как быть?

Code:
DATA: l_date(30).
CONCATENATE sy-datum+6(2) '-' sy-datum+4(2) '-' sy-datum(4) ' '
sy-uzeit(2) ':' sy-uzeit+2(2) ':' sy-uzeit+4(2) INTO l_date.
WRITE: / l_date.
Back to top
View user's profile Send private message
John Doe
Модератор
Модератор


Age: 46
Joined: 05 Nov 2007
Posts: 725
Location: КраснАдар

PostPosted: Fri Jan 25, 2008 2:11 pm    Post subject: Reply with quote

В конце CONCATENATE допишите RESPECTING BLANKS. Или сделайте в 2 шага: соберите дату, соберите время, а потом соберите их через SEPARATED BY SPACE.
Back to top
View user's profile Send private message Blog
Влад
Специалист
Специалист



Joined: 26 Dec 2007
Posts: 63

PostPosted: Fri Jan 25, 2008 2:45 pm    Post subject: Reply with quote

John Doe wrote:
В конце CONCATENATE допишите RESPECTING BLANKS. Или сделайте в 2 шага: соберите дату, соберите время, а потом соберите их через SEPARATED BY SPACE.


John Doe, спасибо, второй способ работает. А на RESPECTING BLANKS ругается, что неправильное слово.
Back to top
View user's profile Send private message
John Doe
Модератор
Модератор


Age: 46
Joined: 05 Nov 2007
Posts: 725
Location: КраснАдар

PostPosted: Fri Jan 25, 2008 2:47 pm    Post subject: Reply with quote

Из справки:
Quote:
Addition 3
... RESPECTING BLANKS


Effect
The addition RESPECTING BLANKS is only allowed during string processing and causes the closing spaces for data objects dobj1 dobj2 ... or rows in the internal table itab to be taken into account. Without the addon, this is only the case with string.



Note
With addition RESPECTING BLANKS, statement CONCATENATE can be used in order to assign any character strings EX>text - taking into account the closing empty character - to target str of type string: CLEAR str. CONCATENATE str text INTO str RESPECTING BLANKS.



Example
After the first CONCATENATE statement, result contains "When_the_music_is_over", after the second statement it contains "When______the_______music_____is________ over______" . The underscores here represent blank characters.

TYPES text TYPE c LENGTH 10.
DATA itab TYPE TABLE OF text.
DATA result TYPE string.

APPEND 'When' TO itab.
APPEND 'the' TO itab.
APPEND 'music' TO itab.
APPEND 'is' TO itab.
APPEND 'over' TO itab.

CONCATENATE LINES OF itab INTO result SEPARATED BY space.
...
CONCATENATE LINES OF itab INTO result RESPECTING BLANKS.
Back to top
View user's profile Send private message Blog
Armann
Модератор
Модератор



Joined: 01 Jan 2008
Posts: 422
Location: Moscow

PostPosted: Fri Jan 25, 2008 3:04 pm    Post subject: Reply with quote

Может версия старая
В 4.0 например RESPECTING BLANKS нет
Back to top
View user's profile Send private message Blog
Влад
Специалист
Специалист



Joined: 26 Dec 2007
Posts: 63

PostPosted: Fri Jan 25, 2008 4:20 pm    Post subject: Reply with quote

версия 4.6D
Back to top
View user's profile Send private message
John Doe
Модератор
Модератор


Age: 46
Joined: 05 Nov 2007
Posts: 725
Location: КраснАдар

PostPosted: Fri Jan 25, 2008 4:22 pm    Post subject: Reply with quote

Влад wrote:
версия 4.6D

Это не MiniBASIS часом?
Back to top
View user's profile Send private message Blog
vga
Мастер
Мастер


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

PostPosted: Fri Jan 25, 2008 6:29 pm    Post subject: Reply with quote

Есть еще два способа:

1) Использование не прямых, а обратных кавычек. Это описывает не текстовую, а стринговую константу, которая не режется.
Code:
DATA: l_date(30).
CONCATENATE sy-datum+6(2) '-' sy-datum+4(2) '-' sy-datum(4) ' '
sy-uzeit(2) ':' sy-uzeit+2(2) ':' sy-uzeit+4(2) INTO l_date.
WRITE: / l_date.



1) Использование translate или replace.
Code:
DATA: l_date(30).
CONCATENATE sy-datum+6(2) '-' sy-datum+4(2) '-' sy-datum(4) '&'
sy-uzeit(2) ':' sy-uzeit+2(2) ':' sy-uzeit+4(2) INTO l_date.
TRANSLATE l_date USING '& '.
WRITE: / l_date.
Back to top
View user's profile Send private message Blog Visit poster's website
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.