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

Следующее значение для RESB-POSNR



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



Joined: 11 Oct 2007
Posts: 60

PostPosted: Wed Apr 27, 2011 3:53 pm    Post subject: Следующее значение для RESB-POSNR Reply with quote

Коллеги добрый день,
в поле RESB-POSNR могут встречаться как цифорвые значения, так и символьные.
Мне нужно увеличить значение в resb на 10 для создания новой позиции. Как увеличить поле (напрмимер, если значение было AAAA, следующее дать AAAB), если оно не цифровое, может FM есть?
Back to top
View user's profile Send private message
vga
Мастер
Мастер


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

PostPosted: Thu Apr 28, 2011 2:39 pm    Post subject: Reply with quote

Например так:

Code:
CONSTANTS c_256 TYPE i VALUE 256.
FIELD-SYMBOLS : <n> TYPE x.
FIELD-SYMBOLS : <c> TYPE c.

DATA: l_posnr TYPE resb-posnr,
      n TYPE i,
      r TYPE f,
      i TYPE i,
      k TYPE i,
      sum TYPE f.

DESCRIBE FIELD l_posnr LENGTH n IN CHARACTER MODE.

l_posnr = 'AAAA'.
TRANSLATE l_posnr USING ' 0'.
sum = 0.
i = n - 1.
r = 1.
DO n TIMES.
  ASSIGN l_posnr+i(1) TO <n> CASTING.
  CHECK <n> IS ASSIGNED.
  sum = sum + ( <n> / c_256 ) * r . "unicode
*  sum = sum + <n> * r . "not unicode
  r = r * c_256.
  i = i - 1.
ENDDO.

sum = sum + 1.

i = n - 1.
DO n TIMES.
  k = sum MOD c_256.
  ASSIGN k TO <c> CASTING.
  CHECK <c> IS ASSIGNED.
  l_posnr+i(1) = <c>.

  sum = ( sum - k ) / c_256.
  i = i - 1.
ENDDO.

WRITE: / l_posnr.

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



Joined: 08 Apr 2009
Posts: 75

PostPosted: Thu Apr 28, 2011 3:15 pm    Post subject: Reply with quote

В 4.6 код код не сработал, я его изменил...

Code:
constants c_256 type i value 256.
field-symbols : <n> type x.
field-symbols : <c> type c.

data: l_posnr type resb-posnr,
      n type i,
      r type f,
      i type i,
      k type i,
      sum type f.

*DESCRIBE FIELD l_posnr LENGTH n CHARACTER MODE.
 DESCRIBE FIELD l_posnr LENGTH n.

l_posnr = 'AAAA'.
translate l_posnr using ' 0'.
sum = 0.
i = n - 1.
r = 1.
do n times.
  assign l_posnr+i(1) to <n> casting.
  check <n> is assigned.
  sum = sum + ( <n> / c_256 ) * r . "unicode
*  sum = sum + <n> * r . "not unicode
  r = r * c_256.
  i = i - 1.
enddo.

sum = sum + 2.

i = n - 1.
do n times.
  k = sum mod c_256.
*добавил   ->
  check k > 0.
*добавил   <- 
  assign k to <c> casting.
  check <c> is assigned.
*изменил  ->
* l_posnr+i(1) = <c>.
  l_posnr+i(1) = <c>+3(1).
*изменил  -> 
  sum = ( sum - k ) / c_256.
  i = i - 1.
enddo.

write: / l_posnr.
Back to top
View user's profile Send private message
vga
Мастер
Мастер


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

PostPosted: Thu Apr 28, 2011 4:13 pm    Post subject: Reply with quote

Я рассчитывал, что поможет, если поменять

Code:
*  sum = sum + ( <n> / c_256 ) * r . "unicode
  sum = sum + <n> * r . "not unicode


не помогает?

Дополнение, в юникодной системе этот код нужен только для платформы Windows
Code:
*  sum = sum + ( <n> / c_256 ) * r . "unicode


На рисковых процессорах байты и так правильно стоят.

По правильному, нужно анализировать big - little endian.

_________________
Молитва - это запрос разработчику на изменение кода программы.
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.