Posted: Wed Apr 27, 2011 3:53 pm Post subject: Следующее значение для RESB-POSNR
Коллеги добрый день,
в поле RESB-POSNR могут встречаться как цифорвые значения, так и символьные.
Мне нужно увеличить значение в resb на 10 для создания новой позиции. Как увеличить поле (напрмимер, если значение было AAAA, следующее дать AAAB), если оно не цифровое, может FM есть?
Age: 170 Joined: 04 Oct 2007 Posts: 1218 Location: Санкт-Петербург
Posted: Thu Apr 28, 2011 2:39 pm Post subject:
Например так:
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.
_________________ Молитва - это запрос разработчику на изменение кода программы.
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.
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.