๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿง‘‍๐Ÿ’ผ SAP/ABAP

[SAP ABAP] IS INITIAL๊ณผ IS NOT INITIAL์ด๋ž€? (์˜ˆ์ œ ํฌํ•จ)

by Jay Din 2023. 12. 1.
728x90
๋ฐ˜์‘ํ˜•

SAP ABAP ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด์—์„œ ` IS INITIAL ` ๊ณผ ` IS NOT INITIAL ` ์€ ๋ฐ์ดํ„ฐ ํ•„๋“œ์˜ ์ดˆ๊ธฐํ™” ์—ฌ๋ถ€๋ฅผ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•œ ์กฐ๊ฑด๋ฌธ์ž…๋‹ˆ๋‹ค.

 

IS INITIAL ์ด๋ž€?

` IS INITAL ` ์€ ๋ฐ์ดํ„ฐ ํ•„๋“œ๊ฐ€ ์ดˆ๊ธฐํ™” ๋˜์—ˆ๋Š”์ง€๋ฅผ ํ™•์ธํ•˜๋Š”๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.

์ด ์กฐ๊ฑด์€ ํŠน์ • ๋ณ€์ˆ˜๋‚˜ ๋ฐ์ดํ„ฐ ๊ฐ์ฒด๊ฐ€ ๊ฐ’์œผ๋กœ ์ดˆ๊ธฐํ™”๋˜์—ˆ์„ ๋•Œ ์‹คํ–‰ํ•  ์ฝ”๋“œ๋ฅผ ์ •์˜ํ•˜๋Š”๋ฐ ํ™œ์šฉ๋ฉ๋‹ˆ๋‹ค.

 

์—ฌ๊ธฐ์—์„œ "์ดˆ๊ธฐํ™” ์ƒํƒœ๋ผ๋Š” ๊ฒƒ" ์€ ํ•ด๋‹น ๋ฐ์ดํ„ฐ ํ•„๋“œ์— ๊ฐ’์ด ์—†๋Š” ์ƒํƒœ๋ฅผ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค.

SAP์—์„œ๋Š” ์ดˆ๊ธฐํ™”๋œ ์ƒํƒœ๋ฅผ ` initial ` ์ƒํƒœ๋กœ ๊ฐ„์ฃผํ•ฉ๋‹ˆ๋‹ค.

 

์ฃผ๋กœ ๋ณ€์ˆ˜๋‚˜ ๋ฐ์ดํ„ฐ ๊ฐ์ฒด์˜ ์ดˆ๊ธฐํ™” ์—ฌ๋ถ€๋ฅผ ํ™•์ธํ•  ๋•Œ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.

DATA lv_variable TYPE i.

IF lv_variable IS INITIAL.
* ๋ณ€์ˆ˜๋Š” ์ดˆ๊ธฐํ™” ์ƒํƒœ์ด๋‹ค.
  WRITE: 'Variable is initial.'.	
ELSE.
* ๋ณ€์ˆ˜๋Š” ์ดˆ๊ธฐํ™” ์ƒํƒœ๊ฐ€ ์•„๋‹ˆ๋‹ค.
  WRITE: 'Variable is not initial.'.	
ENDIF.

์œ„ ์ฝ”๋“œ๋ฅผ ํ•ด์„ํ•˜์ž๋ฉด,

  1. DATA lv_variable TYPE i.: ์ •์ˆ˜ํ˜• ๋ฐ์ดํ„ฐ ํƒ€์ž…(i)์˜ ` lv_variable ` ์ด๋ผ๋Š” ๋ณ€์ˆ˜ ์„ ์–ธ
  2. IF lv_variable IS INITIAL.: ๋งŒ์•ฝ ` lv_variable ` ์ด ์ดˆ๊ธฐํ™” ๋˜์ง€ ์•Š์•˜๋‹ค๋ฉด, ์ฆ‰ ๊ฐ’์ด ์„ค์ •๋˜์ง€ ์•Š์•˜๋‹ค๋ฉด ๋‹ค์Œ ๋ธ”๋ก์ธ ` Variable is initial. ` ์ถœ๋ ฅ
  3. ELSE: ๋งŒ์•ฝ ` lv_variable ` ์ด ์ดˆ๊ธฐํ™”๋˜์—ˆ๋‹ค๋ฉด, ` Variable is not initial. ` ์ถœ๋ ฅ

 

์ฆ‰, ์˜ˆ์ œ์—์„œ๋Š” ` lv_variable ` ์ด ์ดˆ๊ธฐํ™”๋˜์ง€ ์•Š์•˜๊ธฐ(๊ฐ’์ด ์„ค์ •๋˜์ง€ ์•Š์•˜๋‹ค๋ฉด)  ๋•Œ๋ฌธ์— ` Variable is initial. ` ์„ ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค.

 

IS NOT INITIAL ์ด๋ž€?

` IS NOT INITIAL ` ์€ ๋ฐ์ดํ„ฐ ํ•„๋“œ๊ฐ€ ์ดˆ๊ธฐํ™”๋˜์ง€ ์•Š์•˜๋Š”์ง€๋ฅผ ํ™•์ธํ•˜๋Š”๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.

์ด ์กฐ๊ฑด๋ฌธ์€ ํŠน์ • ๋ณ€์ˆ˜๋‚˜ ๋ฐ์ดํ„ฐ ๊ฐ์ฒด๊ฐ€ ๊ฐ’์œผ๋กœ ์ดˆ๊ธฐํ™”๋˜์ง€ ์•Š์•˜์„ ๋•Œ ์‹คํ–‰ํ•  ์ฝ”๋“œ๋ฅผ ์ •์˜ํ•˜๋Š”๋ฐ ํ™œ์šฉ๋ฉ๋‹ˆ๋‹ค.

 

์—ฌ๊ธฐ์—์„œ "์ดˆ๊ธฐํ™” ์ƒํƒœ๊ฐ€ ์•„๋‹ˆ๋ผ๋Š” ๊ฒƒ" ์€ ํ•ด๋‹น ๋ฐ์ดํ„ฐ ํ•„๋“œ๊ฐ€ ๊ฐ’์„ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ์ƒํƒœ๋ฅผ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค.

DATA lv_variable TYPE i.
lv_variable = 'Value'.

IF lv_variable IS NOT INITIAL.
  WRITE: 'Variable is not initial.'.
ELSE.
  WRITE: 'Variable is initial.'.
ENDIF.
  1. DATA lv_variable TYPE i.: ์ •์ˆ˜ํ˜• ๋ฐ์ดํ„ฐ ํƒ€์ž…(i)์˜ ` lv_variable ` ์ด๋ผ๋Š” ๋ณ€์ˆ˜ ์„ ์–ธ
  2. IF lv_variable IS NOT INITIAL.: ๋งŒ์•ฝ ` lv_variable ` ์ด ์ดˆ๊ธฐํ™” ์ƒํƒœ๊ฐ€ ์•„๋‹ˆ๋ผ๋ฉด, ์ฆ‰ ๊ฐ’์ด ์„ค์ •๋˜์—ˆ๋‹ค๋ฉด ` Variable is not initial. ` ์ถœ๋ ฅ
  3. ELSE: ๋งŒ์•ฝ ` lv_variable ` ์ด ์ดˆ๊ธฐํ™” ์ƒํƒœ๋ผ๋ฉด, ` Variable is initial. ` ์ถœ๋ ฅ

 

์œ„์˜ ์˜ˆ์ œ์—์„œ ` lv_variable ` ์ด ์ดˆ๊ธฐํ™” ์ƒํƒœ(๊ฐ’์ด ์„ค์ •๋จ)์ด๊ธฐ ๋•Œ๋ฌธ์— ` Variable is not initial. ` ์„ ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค.

 

์ด๋ ‡๊ฒŒ ์‚ฌ์šฉํ•จ์œผ๋กœ์จ ํ”„๋กœ๊ทธ๋ž˜๋จธ๋Š” ๋ณ€์ˆ˜๋ฅผ ์•ˆ์ „ํ•˜๊ฒŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๊ณ , ์ดˆ๊ธฐํ™”๋˜์ง€ ์•Š์€ ๋ณ€์ˆ˜๋กœ ์ธํ•œ ํ”„๋กœ๊ทธ๋žจ ์˜ค๋ฅ˜๋ฅผ ๋ฐฉ์ง€ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์ฃผ๋กœ ๋ฐ์ดํ„ฐ์˜ ์œ ํšจ์„ฑ์„ ๊ฒ€์ฆํ•˜๊ฑฐ๋‚˜ ์ดˆ๊ธฐํ™” ์—ฌ๋ถ€๋ฅผ ํ™•์ธํ•ด์•ผ ํ•  ๋•Œ ` IS NOT INITIAL ` ์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

 

์ด๋Ÿฌํ•œ ์กฐ๊ฑด๋ฌธ๋“ค์€ ๋ฐ์ดํ„ฐ์˜ ์ดˆ๊ธฐํ™” ์—ฌ๋ถ€๋ฅผ ํ™•์ธํ•˜์—ฌ ์•ˆ์ „ํ•˜๊ฒŒ ๋ณ€์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ํ”„๋กœ๊ทธ๋žจ ์˜ค๋ฅ˜๋ฅผ ๋ฐฉ์ง€ํ•˜๋Š”๋ฐ ๋„์›€์ด ๋ฉ๋‹ˆ๋‹ค.

728x90
๋ฐ˜์‘ํ˜•