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

[SAP ABAP] SELECT-OPTIONS ๋ž€?

by Jay Din 2024. 7. 16.
728x90
๋ฐ˜์‘ํ˜•

1. SELECT-OPTIONS ๋ž€?

์˜ˆ์‹œ ํ™”๋ฉด

 

์‚ฌ์šฉ์ž๋กœ๋ถ€ํ„ฐ ๋‹ค์ค‘ ๊ฐ’์„ ์ž…๋ ฅ๋ฐ›๊ฑฐ๋‚˜ ๋ฒ”์œ„๋ฅผ ์ง€์ •ํ•  ์ˆ˜ ์žˆ๋Š” ์ž…๋ ฅ ํ•„๋“œ๋ฅผ ์ •์˜ํ•˜๋Š”๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.

SELECT-OPTIONS ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ํŠน์ • ํ•„๋“œ์— ๋Œ€ํ•ด ์—ฌ๋Ÿฌ ๊ฐ’, ๋ฒ”์œ„, ํฌํ•จ ๋ฐ ์ œ์™ธ ์กฐ๊ฑด ๋“ฑ์„ ์ง€์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

SELECT-OPTIONS ๊ตฌ์กฐ

SELECT-OPTIONS: s_field FOR db_table-field.
  • s_field: ์„ ํƒ ์˜ต์…˜์˜ ์ด๋ฆ„์ž…๋‹ˆ๋‹ค.
  • FOR db_table-field: ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ํ…Œ์ด๋ธ”์˜ ํ•„๋“œ์™€ ์—ฐ๊ฒฐ๋ฉ๋‹ˆ๋‹ค.
  • FOR  ๋‹ค์Œ์— ๋ฐ์ดํ„ฐ ํƒ€์ž…์ด ์•„๋‹ˆ๊ณ  ๋ฐ์ดํ„ฐ ์˜ค๋ธŒ์ ํŠธ.

 

2. SELECT-OPTIONS ์˜ˆ์ œ

* 1. SFLIGHT ํ…Œ์ด๋ธ” ์„ ์–ธ
TABLES: sflight.

* 2. SELECT-OPTIONS ์„ ์–ธ
SELECT-OPTIONS: s_carrid FOR sflight-carrid,
                s_fldate FOR sflight-fldate.

START-OF-SELECTION.

* 3. ์กฐํšŒ ๊ฒฐ๊ณผ๋ฅผ ์ €์žฅํ•  ์ธํ„ฐ๋„ ํ…Œ์ด๋ธ” ์„ ์–ธ
DATA: lt_flights TYPE TABLE OF sflight,
      ls_flight  TYPE sflight.

* 4. ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์กฐํšŒ
SELECT * FROM sflight
  INTO TABLE lt_flights
  WHERE carrid IN s_carrid
  AND fldate IN s_fldate.

* 5. ์กฐํšŒ๋œ ๋ฐ์ดํ„ฐ ์ถœ๋ ฅ
LOOP AT lt_flights INTO ls_flight.
  WRITE: / ls_flight-carrid, ls_flight-connid, ls_flight-fldate.
ENDLOOP.

 

  1. ํ…Œ์ด๋ธ” ์„ ์–ธ
    • TABLES ๊ตฌ๋ฌธ: SFLIGHT ํ…Œ์ด๋ธ”์„ ์„ ์–ธํ•ฉ๋‹ˆ๋‹ค. ์ด ์„ ์–ธ์„ ํ†ตํ•ด SFLIGHT ํ…Œ์ด๋ธ”์˜ ๋ชจ๋“  ํ•„๋“œ๋ฅผ ํ”„๋กœ๊ทธ๋žจ ๋‚ด์—์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
    • ํ•„๋“œ ์ ‘๊ทผ: SFLIGHT ํ…Œ์ด๋ธ”์˜ ํ•„๋“œ CARRID, FLDATE, CONNID ๋“ฑ)๋ฅผ ๋ณ€์ˆ˜์ฒ˜๋Ÿผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  2. SELECT-OPTIONS ์„ ์–ธ
    • s_carrid: SFLIGHT ํ…Œ์ด๋ธ”์˜ CARRID ํ•„๋“œ์— ๋Œ€ํ•œ ์„ ํƒ ์˜ต์…˜์ž…๋‹ˆ๋‹ค. ์‚ฌ์šฉ์ž๋Š” ํ•˜๋‚˜ ์ด์ƒ์˜ ํ•ญ๊ณต์‚ฌ ์ฝ”๋“œ๋ฅผ ์ž…๋ ฅํ•˜๊ฑฐ๋‚˜ ๋ฒ”์œ„๋ฅผ ์ง€์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
    • s_fldate: SFLIGHT ํ…Œ์ด๋ธ”์˜ FLDATE ํ•„๋“œ์— ๋Œ€ํ•œ ์„ ํƒ ์˜ต์…˜์ž…๋‹ˆ๋‹ค. ์‚ฌ์šฉ์ž๋Š” ํ•˜๋‚˜ ์ด์ƒ์˜ ๋น„ํ–‰ ๋‚ ์งœ๋ฅผ ์ž…๋ ฅํ•˜๊ฑฐ๋‚˜ ๋ฒ”์œ„๋ฅผ ์ง€์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  3. ๋ณ€์ˆ˜ ์„ ์–ธ
    • START-OF-SELECTION ์ด๋ฒคํŠธ: SELECTION-SCREEN ์—์„œ ์‚ฌ์šฉ์ž ์ž…๋ ฅ์„ ๋ฐ›์€ ํ›„ ์‹คํ–‰๋˜๋Š” ์ด๋ฒคํŠธ์ž…๋‹ˆ๋‹ค.
    • ์ธํ„ฐ๋„ ํ…Œ์ด๋ธ” ์„ ์–ธ
      • lt_flights: ์กฐํšŒ๋œ ๊ฒฐ๊ณผ๋ฅผ ์ €์žฅํ•  ์ธํ„ฐ๋„ ํ…Œ์ด๋ธ”์ž…๋‹ˆ๋‹ค.
      • ls_flight: ์ธํ„ฐ๋„ ํ…Œ์ด๋ธ”์˜ ๊ฐ ํ–‰์„ ์ €์žฅํ•  ์ž‘์—… ์˜์—ญ์ž…๋‹ˆ๋‹ค.
  4. ๋ฐ์ดํ„ฐ ๋ฒ ์ด์Šค ์กฐํšŒ
    • SFLIGHT ํ…Œ์ด๋ธ”์—์„œ ์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•œ ์„ ํƒ ์˜ต์…˜ (s_carrid, s_fldate)์„ ์กฐ๊ฑด์œผ๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค.
    • ์กฐํšŒ๋œ ๊ฒฐ๊ณผ๋Š” ์ธํ„ฐ๋„ ํ…Œ์ด๋ธ” lt_flights์— ์ €์žฅ๋ฉ๋‹ˆ๋‹ค.
  5. ๋ฐ์ดํ„ฐ ์ถœ๋ ฅ
    • ์ธํ„ฐ๋„ ํ…Œ์ด๋ธ” lt_flights์˜ ๊ฐ ํ–‰์„ ์ˆœ์ฐจ์ ์œผ๋กœ ์ฝ์–ด ls_flight ์ž‘์—… ์˜์—ญ์— ์ €์žฅํ•ฉ๋‹ˆ๋‹ค.
    • ls_flight ์ž‘์—… ์˜์—ญ์— ์ €์žฅ๋œ CARRID, CONNID, FLDATE ํ•„๋“œ๋ฅผ ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค.

S_CARRID ๋ณต์ˆ˜ ์„ ํƒ
์ถœ๋ ฅ ํ™”๋ฉด

 

728x90
๋ฐ˜์‘ํ˜•