메뉴 건너뛰기

SAP 한국 커뮤니티

add 구문

sapjoy 2006.12.02 17:59 조회 수 : 6431 추천:36

ADD

Variants


1. ADD n TO m.
2. ADD n1 THEN n2 UNTIL nz GIVING m.
3. ADD n1 THEN n2 UNTIL nz TO m.
4. ADD n1 THEN n2 UNTIL nz
...ACCORDING TO sel ...GIVING m.
5. ADD n1 FROM m1 TO mz GIVING m.

Variant 1
ADD n TO m.

Effect
Adds the contents of n to the contents of M and stores the result in m .
This is equivalent to: m = m + n.

Example

DATA: NUMBER TYPE I VALUE 3,
      SUM    TYPE I VALUE 5.
ADD NUMBER TO SUM.

The field SUM now contains 8, whilst the contents of the field NUMBER remains unchanged at 3.

Note
The details about conversions and performance described under COMPUTE are identical for ADD .

Note
Runtime errors

BCD_BADDATA : P field contains incorrect BCD format.
BCD_FIELD_OVERFLOW : Result field too small (type P ).
BCD_OVERFLOW : Overflow with arithmetic operation (type P .
COMPUTE_INT_PLUS_OVERFLOW : Integer overflow when adding.

Related COMPUTE , ADD-CORRESPONDING .

Variant 2
ADD n1 THEN n2 UNTIL nz GIVING m.

Effect
Adds the contents of the fields n1, n2, ..., nz together and stores the result in m , where n1 is the first, n2 the second and nz the last of a sequence of fields the same distance apart. They can be either database fields or internal fields, but they must all have the same type and length.
This is equivalent to: m = n1 + n2 + ... + nz.

Example

DATA: BEGIN OF NUMBERS,
        ONE   TYPE P VALUE 10,
        TWO   TYPE P VALUE 20,
        THREE TYPE P VALUE 30,
        FOUR  TYPE P VALUE 40,
        FIVE  TYPE P VALUE 50,
        SIX   TYPE P VALUE 60,
      END   OF NUMBERS,
      SUM TYPE I VALUE 1000.
ADD NUMBERS-ONE THEN  NUMBERS-TWO
                UNTIL NUMBERS-FIVE GIVING SUM.

The field SUM now contains 150 but its initial value is unimportant. The fields within the field string NUMBERS remain unchanged.

Variant 3
ADD n1 THEN n2 UNTIL nz TO m.

Effect
Calculates the total as in variant 2 but then adds it to the contents of the field m .
This is equivalent to: m = m + n1 + n2 + ... + nz

Example

DATA: BEGIN OF NUMBERS,
        ONE   TYPE P VALUE 10,
        TWO   TYPE P VALUE 20,
        THREE TYPE P VALUE 30,
        FOUR  TYPE P VALUE 40,
        FIVE  TYPE P VALUE 50,
      END   OF NUMBERS,
      SUM TYPE I VALUE 1000.
ADD NUMBERS-ONE THEN  NUMBERS-TWO
                UNTIL NUMBERS-FIVE TO SUM.

The field SUM now contains 1150.

Variant 4
ADD n1 THEN n2 UNTIL nz
...ACCORDING TO sel ...GIVING m.

Effect
Calculates the total as in variants 2 and 3. In this case, however, the operands from a sequence of fields of the same type are restricted to a partial sequence by the selection specification sel generated by SELECT-OPTIONS or RANGES . The partial sequence results from the indexes that satisfy the condition IN sel (see IF ).

Example

DATA: BEGIN OF NUMBERS,
        ONE   TYPE P VALUE 10,
        TWO   TYPE P VALUE 20,
        THREE TYPE P VALUE 30,
        FOUR  TYPE P VALUE 40,
        FIVE  TYPE P VALUE 50,
      END   OF NUMBERS,
      SUM   TYPE I VALUE 1000,
      INDEX TYPE I.
RANGES SELECTION FOR INDEX.

SELECTION-SIGN   = 'I'.
SELECTION-OPTION = 'BT'.
SELECTION-LOW    = 2.
SELECTION-HIGH   = 4.
APPEND SELECTION.

ADD NUMBERS-ONE THEN NUMBERS-TWO
                UNTIL NUMBERS-FIVE
                ACCORDING TO SELECTION
                GIVING SUM.

SUM now contains 90. Only the component fields TWO to FOUR were selected from the field string NUMBERS and added together.

Variant 5
ADD n1 FROM m1 TO mz GIVING m.

Effect
The field n1 must be the first in a sequence of consecutive fields of the same type. m1 and mz should contain the numbers of the first and last fields in this sequence to be added together (whether fixed or variable). The total is stored in m .

Example

DATA: BEGIN OF NUMBERS,
        ONE   TYPE P VALUE 10,
        TWO   TYPE P VALUE 20,
        THREE TYPE P VALUE 30,
        FOUR  TYPE P VALUE 40,
        FIVE  TYPE P VALUE 50,
      END   OF NUMBERS,
      START TYPE I VALUE 2,
      SUM   TYPE I VALUE 1000.
ADD NUMBERS-ONE FROM START TO 4 GIVING SUM.

The field SUM now contains 90.

Note
Performance The details for conversion and performance specified for COMPUTE are equally valid for ADD .
The runtime required for adding two numbers of type I or F is about 2 (standardized microseconds), for type P it is roughly 8 msn.

Note
Runtime errors

Besides the runtime errors listed in variant 1, the error ADDF_INT_OVERFLOW can occur instead of COMPUTE_INT_PLUS_OVERFLOW in other variants.

Index
?SAP AG 1996
번호 제목 글쓴이 날짜 조회 수
27 SAP GUI WINDOW TITLE BAR 정보 표시 설정 방법 / 색상 설정 [15] file 미소 2010.12.26 13452
26 텍스트파일 다운받을때 유니코드 문제 해결 [8] file 솔로몬 2007.06.28 13797
25 <img src=b.gif>Windows 7 에서 SAP GUI ALV 반응느림 해결방법 공유 (GUI720 기준)[추천:e-abap][추천:유리선율][추천:보나] [17] 점점 2010.07.02 14782
24 Dynamic Internal Table 생성 꿀꿀윤뚱67 2019.11.27 14857
23 BAPI_GOODSMVT_CREATE 입고/출고/재고이동시에 사용하세요. [5] 노름마치 2007.12.10 15105
22 Abap Dump Top 10 [5] 양키 2013.01.14 15746
21 data [2] sapjoy 2006.12.03 16722
20 프로그램 정보(프로그램 리스트, PROGRAM LIST, PROGRAM TABLE) [3] sapjoy 2007.02.23 16841
19 SYST 시스템 변수 정리 [5] 아밥뽀 2014.08.23 17006
18 FOR ALL ENTRIES IN 구문 사용시 select 필드 선택시 주의사항. [7] 나침반친구 2007.03.13 17031
17 ABAP 구문 총정리 [39] file Wise 멘토 2008.11.24 17171
16 인터널 테이블 라인수 lines [8] sapjoy 2014.01.20 17272
15 ABAP 핵심정리 [23] SARA 2007.03.14 17338
14 ALV LIST 진행시 LAYOUT 속성값 [18] kwon09 2007.04.11 17363
13 SDN -> SCN 변경되면서 Contents별로 바뀐 LINK 모음 [13] Wise 멘토 2012.07.06 19045
12 숫자입력 체크(Numeric character check) [1] 양키(이경환) 2014.01.28 19637
11 LIKE와 TYPE의 차이 [13] sapjoy 2006.12.06 19723
10 문자열에 있는 값이 숫자만으로 되어있는지 문자가 포함됐는지 체크하는 함수 [3] 꿀단지 2011.10.11 19906
9 SELECT statement D.Y.Kim 2007.07.20 23647
8 BAPI_PR_CREATE 구매요청 생성시에 사용하세요 [2] 노름마치 2007.12.10 23707