λ³Έλ¬Έ λ°”λ‘œκ°€κΈ°
πŸ§‘‍πŸ’Ό SAP/ABAP

[SAP ABAP] κ°’ ν• λ‹Ή(Value Assignments) ν•˜λŠ” 법

by Jay Din 2024. 3. 20.
728x90
λ°˜μ‘ν˜•

κ°’ ν• λ‹Ή(Value Assignments)

κ°’ ν• λ‹Ή(Value Assignments)은 ν”„λ‘œκ·Έλž˜λ°μ—μ„œ λ³€μˆ˜λ‚˜ μƒμˆ˜μ— 값을 λΆ€μ—¬ν•˜λŠ” 과정을 μ˜λ―Έν•©λ‹ˆλ‹€.

κ°’ 할당은 ν”„λ‘œκ·Έλž¨μ—μ„œ 데이터λ₯Ό μ²˜λ¦¬ν•˜κ³  μ €μž₯ν•˜λŠ”λ° ν•„μˆ˜μ μž…λ‹ˆλ‹€.

값을 ν• λ‹Ήν•˜λŠ” 과정은 λ³€μˆ˜ λ˜λŠ” μƒμˆ˜μ˜ λ©”λͺ¨λ¦¬ 곡간에 νŠΉμ • 값을 μ €μž₯ν•˜λŠ” 것을 μ˜λ―Έν•©λ‹ˆλ‹€.

 

κ°’ ν• λ‹Ή μ˜ˆμ‹œ

λ³€μˆ˜μ— κ°’ ν• λ‹Ή

DATA: lv_number TYPE I. " μ •μˆ˜ν˜• λ³€μˆ˜ μ„ μ–Έ

lv_number = 10. " λ³€μˆ˜μ— κ°’ 10을 ν• λ‹Ή

 

μƒμˆ˜μ— κ°’ ν• λ‹Ή

μƒμˆ˜μ— κ°’ν• λ‹Ή μžμ„Έν•œ μ„€λͺ…

CONSTANTS: c_pi TYPE F VALUE '3.141592'. " μƒμˆ˜ μ„ μ–Έ 및 κ°’ ν• λ‹Ή

 

ꡬ쑰체에 κ°’ ν• λ‹Ή

TYPES: BEGIN OF ty_person,
         name TYPE string,
         age TYPE i,
       END OF ty_person.

DATA: ls_person TYPE ty_person. " ꡬ쑰체 λ³€μˆ˜ μ„ μ–Έ

ls_person-name = 'John'. " ꡬ쑰체의 ν•„λ“œμ— κ°’ ν• λ‹Ή
ls_person-age = 30.

 

배열에 κ°’ ν• λ‹Ή

κ°„λ‹¨ν•œ μ •μˆ˜ 배열을 λ§Œλ“€μ–΄μ„œ 10, 20, 30을 ν• λ‹Ήν•˜κ³  좜λ ₯ν•˜λŠ” μ½”λ“œμž…λ‹ˆλ‹€.

DATA: LT_NUMBERS TYPE TABLE OF I. " μ •μˆ˜ν˜• λ°°μ—΄ μ„ μ–Έ
DATA: LV_NUMBER TYPE I. " 반볡 λ³€μˆ˜ μ„ μ–Έ

" λ°°μ—΄ μ΄ˆκΈ°ν™”
CLEAR LT_NUMBERS.

" 배열에 κ°’ μΆ”κ°€
APPEND 10 TO LT_NUMBERS.
APPEND 20 TO LT_NUMBERS.
APPEND 30 TO LT_NUMBERS.

" λ°°μ—΄μ˜ κ°’ 좜λ ₯
LOOP AT LT_NUMBERS INTO LV_NUMBER.
  WRITE: / LV_NUMBER.
ENDLOOP.

 

값을 ν• λ‹Ήν•˜μ§€ μ•Šμ€ 경우

λ³€μˆ˜μ— 값을 ν• λ‹Ήν•˜μ§€ μ•Šμ€ 경우, SAP ABAP은 NULL 값이 μ—†κΈ° λ•Œλ¬Έμ— ν•΄λ‹Ή λ³€μˆ˜ νƒ€μž…μ˜ μ΄ˆκΈ°κ°’μ΄ ν• λ‹Ήλ©λ‹ˆλ‹€.

DATA: NUMBER TYPE I,
      CHARACTER TYPE C,
      STRING1 TYPE STRING,
      FLOAT TYPE F.

WRITE: / 'NUMBER: ', NUMBER.
WRITE: / 'CHARACTER: ', CHARACTER.
WRITE: / 'STRING1: ', STRING1.
WRITE: / 'FLOAT: ', FLOAT.

μ‹€ν–‰ν™”λ©΄

728x90
λ°˜μ‘ν˜•