메뉴 건너뛰기

SAP 한국 커뮤니티

move 구문

sapjoy 2006.12.02 18:04 조회 수 : 7730 추천:32

MOVE


Variants


1. MOVE f TO g.
2. MOVE f+off1(len1) TO g+off2(len2).
3. MOVE c1 TO c2 PERCENTAGE n.

Variant 1
MOVE f TO g.

Effect
Moves the contents of field f to field g . Field f remains unchanged.
This statement is equivalent to:


g = f.



Example

DATA: NUMBER TYPE I,
      FIVE   TYPE I.
MOVE 5 TO FIVE.
MOVE FIVE TO NUMBER.


The fields NUMBER and FIVE now both 5.

Notes
Multiple assignments like

NUMBER = FIVE = 5.

are also possible. ABAP/4 executes them from right to left (as in the above example).
If the field types or lengths differ, type conversion follows automatically. Type I fields are handled like type P fields. If you select the fixed point arithmetic attribute for an ABAP/4 program, type P fields are either rounded according to the number of decimal places or filled with zeros.
In contrast to WRITE TO , the decimal character is always a period (.), regardless of the specification in the user master.
MOVE allows you to copy tables and structures which contain other tables.

Two tables can be copied only if this is possible for their respective lines. If the line types are incompatible, conversions are performed line by line. If itab is a table with a header line, the table itself can be addressed with itab[] .

Two structures which themselves contain tables can only be copied if they are compatible (i.e. if the ABAP/4 type check allows this).
Conversion table ( f -> g ) depending on the types of f and g :
C -> C Left-justified transfer. If the target field is longer than the source field, it is padded with blanks on the right. If it is shorter than the source field, the left part of the source field is copied and the rest is truncated. C -> D The field f must be an 8-character date in YYYYMMDD format. C -> F The character string in f must be a valid representation of a floating point number (DATA ). C -> N Only the digits in f are valid here. They are moved to g , right-justified and padded with zeros on the left. If the target field is too short, digits on the left are truncated. C -> T The field f must contain a 6-character time specification in HHMMSS format. C -> P the field f must contain a decimal number, i.e. a sequence of numeric characters with optional signs and more than once decimal point; there may be blanks on either side. If g is too short, an overflow error can occur. C -> X The field f must contain a hexadecimal character string (i.e. the only valid characters are 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F). The number to be converted is treated as a hexadecimal number rather than a decimal number,
e.g.: C'15' -> X'15' .
It is transported left-justified to g and either padded with zeros or truncated,
e.g.: C'AB' -> X'AB00' .
f is processed up to the first blank.
Examples:
C'ABC' -> X'ABC0', C'ABC0' -> X'ABC0'
C'ABC D' -> X'ABC0', C' AB' -> X'0000'
D -> C Left-justified transfer without conversion D -> D Transfer without conversion D -> F As for D -> P and then P -> F D -> N As for D -> C and then C -> N D -> P Inverse of P -> D D -> T Not supported: Error message D -> X Inverse of X -> D
F -> C f is converted to E format and moved to g . E.g.: F'-3.142' -> C'-3.14200000000000E+00'
If the mantissa is unequal to 0, it is standardized so that it lies between 1.0 and 9.99...
The exponent is generally 2-digit; it is only converted to 3-digit format if it is greater than 99 or smaller than -99
The exponent always appears with a sign.
If g is too short, the mantissa is rounded.
e.g.: F'3.152' -> C' 3.2E+00' .
The length of g should be at least 6, otherwise it g is filled with asterisks (*). F -> D See F -> N F -> F Transfer without conversion F -> N f is rounded as with F -> P and then treated like a P field. F -> P f is rounded, e.g. F'-3.512' -> P'-4' . F -> T See F -> N F -> X See F -> N
N -> C f is treated like a C field; leading zeros remain. N -> D As for N -> C and then C -> D N -> F As for N -> P and then P -> F N -> N Right-justified transfer; on the left, padded with zeros or truncated. N -> P f is packed and moved to g with a positive sign (+). If g is too short, an overflow error can occur. N -> T As for N -> C and then C -> T N -> X As for N -> P and then P -> X
P -> C f is moved to g with a trailing sign and, if required, a decimal point.
e.g.: P'-1234567' -> C'12345.67-'
Notes:
1) One position is always reserved for the sign and, in the event of a positive number, a blank is output.
2) Leading zeros are output as blanks.
3) If g is too short, the blank representing the sign in the case of positive numbers is omitted; if this is insufficient, the number is truncated on the left - this is indicated by an asterisk (*).
Examples (the P field f has the length 2, the C field g the length 3):
P'123' -> C'123', P'-123' -> C'*3-'
4) If you do not want to reserve a position for the sign, use the WRITE TO statement with the addition NO-SIGN .
5) To convert with leading zeros and without formatting characters, use the UNPACK statement. P -> D The value in f is the absolute date (i.e. the number of days since 01.01.0001) and is moved to g in the YYYYMMDD format. This takes into account that the Julian Calendar was replaced by the Gregorian Calendar on 15.10.1582. The value 0 (and negative values) are transferred into the initial date '00000000'. P -> F The field f is moved to g as a floating point number. P -> N Right-justified transfer without sign; padded with zeros on the left. P -> P If g is too short, an overflow error can occur. P -> T The value in f is an absolute time (i.e. the number of seconds since midnight modulo 24 hours = 86.400 seconds) and is moved to g in HHMMSS format. P -> X The value in f is stored in g as a hexadecimal number. E.g.: P'15' -> X'0F' .
Negative numbers are represented by the two's complement.
e.g.: P'-153' -> X'FF67' .
If the length of g is greater than 4, only the last 4 Bytes are provided for according to the value of f ; the Bytes before them are padded with Hex-0.
If g is too short, the number is truncated on the left.
T -> C As for D -> C T -> D Not supported: Error message T -> F As for T -> P and then P -> F T -> N As for T -> C T -> P Inverse of P -> T T -> T Transfer without conversion T -> X Inverse of X -> T
X -> C f is converted to hexadecimal format. The result is transferred left-justified and padded with blanks or truncated on the right.
e.g.: X'0F' -> C'0F' X -> D The value in f is an absolute date (number of days since 01.01.0001) and is moved to g in YYYYMMDD format. (See also P -> D.) X -> F As for X -> P and then P -> F X -> N As for X -> P and then P -> N X -> P f is treated as a hexadecimal number and moved to g in decimal packed format.
e.g.: X'0F' -> P'15'
If f is longer than 4, only the last 4 bytes are processed.
If g is too short, an overflow error can occur. X -> T The value in f is an absolute time (i.e. the number of seconds since midnight modulo 24 hours = 86,400 seconds) and is moved to g in HHMMSS format. (See also P -> T.) X -> X Left-justified transfer; padded with X'00' on the right or truncated.

Note
Runtime errors

BCD_BADDATA : Source field (type P ) does not contain the correct BCD format
BCD_FIELD_OVERFLOW : Result field defined too small (type P )
BCD_OVERFLOW : Arithmetic operation overflow (type P )
CONVT_NO_NUMBER : Source field cannot be interpreted as a number
CONVT_OVERFLOW : Source field conversion overflow
MOVE_COMPLEX_OVERLAP : Assignment not allowed for deep structures in case they overlap
MOVE_NOT_SUPPORTED : Assignment between types involved is not supported
MOVE_TO_LIT_NOTALLOWED : Constants and literals must not be overwritten

Related COMPUTE , WRITE TO

Variant 2
MOVE f+off1(len1) TO g+off2(len2).

Effect
With offset off2 and length len2 , field g receives the contents of field f with offset off1 and length len1 .
Therefore, the offset and length specifications can also be variable.

Example

DATA: FIELD1(10) VALUE '1234567890',
      OFF1 TYPE I VALUE 1,
      LEN1 TYPE I VALUE 2,
      FIELD2(8) VALUE 'abcdefgh',
      OFF2 TYPE I VALUE 3,
      LEN2 TYPE I VALUE 4.
MOVE FIELD1+OFF1(LEN1) TO FIELD2+OFF2(LEN2).


FIELD2 now has the value ' abc23 h '.

Variant 3
MOVE c1 TO c2 PERCENTAGE n.

Additions

1. ... LEFT
2. ... RIGHT

Effect
c1 and c2 must be type C fields; n is a field with a numeric value between 0 and 100. The left part of field c1 ( n percent) is moved to field c2 and is left-justified. c2 is filled with blanks if necessary.

Addition 1
... LEFT

Effect
This is the standard. With this statement, you can make clear that transfer is to be left-justified.

Addition 2
... RIGHT

Effect
Transfer is right-justified, the left part of field c1 as standard.

Note
Performance
The runtime required to transfer a C(1) field to a C(1) field is 1 msn (standard microseconds).
Conversions should be avoided for performance reasons, i.e. the fields should have the same type and length. For example, a MOVE of a C(10) field to a C(10) field takes about 2 msn, while a MOVE of a C(10) field to a type I field needs about 10 msn.

Index
?SAP AG 1996
번호 제목 글쓴이 날짜 조회 수
447 Overview transport requests for all systems and clients [3] file 노름마치 2009.11.05 3676
446 새로운 Print format 추가하기 [5] file 이명환 2007.10.18 3679
445 How to read same field from D.Base into two fields of ITAB [1] sapjoy 2006.12.12 3690
444 F1 도움말 존닭 2014.12.11 3696
443 OPEN SQL 사용법인데, 내용이 정리가 잘 되어 있네요 [21] file 노름마치 2008.06.09 3712
442 <b>[완료]</b>NW04 설치시 에러 몇가지 해결법 [3] file Abap consultant 2009.03.13 3715
441 ALV 활용해 보기 [4] file 박진만 2007.06.28 3727
440 new_abap_editor [3] file Lastforone 2007.07.31 3734
439 일자에 포멧에 맞게 자동으로 처리하는 프로그램 [1] 박종갑 2007.07.13 3741
438 zebra printer 상세 사용메뉴얼입니다. 양키 2013.08.26 3744
437 Selection Screeen에서 저장버튼 Disable 처리 [3] 양키(이경환) 2014.11.13 3753
436 Picking material description from custom table in the SAP Sales Order [2] file 노름마치 2009.07.10 3757
435 SAP BEST PRACTICES BASELINE PACKAGE Link(한국어) [10] ac3mania 2009.06.23 3789
434 파트너 정보 테이블(partner) sapjoy 2007.04.10 3799
433 Internal Table 내용 PC에 저장하기 [11] 별이고픈구름 2008.05.28 3828
432 BSP 명령구절 [3] gauguin 2008.06.04 3837
431 New ABAP Editor Concept [4] file D.Y.Kim 2007.06.07 3847
430 인용부호를 변수에 저장하려면 [2] 푸른밤 2007.07.31 3847
429 HELP를 WEB으로 접속하려면,,, 이렇게 하세요 [8] 김창훈 2007.08.08 3847
428 CLUSTER 테이블 찾는법~~ [4] 첼시 2008.02.28 3853