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

[SAP ABAP] START/END-OF-SELECTION ์ด๋ž€? (์˜ˆ์ œ ํฌํ•จ)

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

์š”์•ฝ

START-OF-SELECTION ๋ฐ์ดํ„ฐ๋ฅผ ์ฝ์–ด์˜ค๋Š” ์ž‘์—…์„ ์ฒ˜๋ฆฌ
END-OF-SELECTION ์ฝ์–ด์˜จ ๋ฐ์ดํ„ฐ๋ฅผ ํ™”๋ฉด์— ์ถœ๋ ฅํ•˜๊ฑฐ๋‚˜ ํ›„์ฒ˜๋ฆฌ ์ž‘์—…์„ ์ฒ˜๋ฆฌ

 

๊ฐœ๋… ์ดํ•ด

  1. START-OF-SELECTION:
    • ํ”„๋กœ๊ทธ๋žจ์ด ์‹œ์ž‘๋  ๋•Œ ๊ฐ€์žฅ ๋จผ์ € ์‹คํ–‰๋˜๋Š” ๋ถ€๋ถ„์ž…๋‹ˆ๋‹ค.
    • ์ฃผ๋กœ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์—์„œ ๋ฐ์ดํ„ฐ๋ฅผ ์ฝ์–ด์˜ค๋Š” ์ž‘์—…์„ ์—ฌ๊ธฐ์— ์ž‘์„ฑํ•ฉ๋‹ˆ๋‹ค.
  2. END-OF-SELECTION:
    • ๋ฐ์ดํ„ฐ ์ฒ˜๋ฆฌ๊ฐ€ ๋๋‚œ ํ›„ ์‹คํ–‰๋˜๋Š” ๋ถ€๋ถ„์ž…๋‹ˆ๋‹ค.
    • ์ฃผ๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ํ™”๋ฉด์— ์ถœ๋ ฅํ•˜๊ฑฐ๋‚˜ ํŒŒ์ผ๋กœ ์ €์žฅํ•˜๋Š” ์ž‘์—…์„ ์—ฌ๊ธฐ์— ์ž‘์„ฑํ•ฉ๋‹ˆ๋‹ค.

 

๊ฐ„๋‹จํ•œ ์˜ˆ์ œ

์ด ์˜ˆ์ œ๋Š” SPFLI ํ…Œ์ด๋ธ”์—์„œ ํ•ญ๊ณต์‚ฌID๋ฅผ ์ž…๋ ฅํ•˜๋ฉด, ํ•ญ๊ณต์‚ฌ ๋ฐ์ดํ„ฐ๋ฅผ ์ฝ์–ด์™€์„œ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์ž…๋‹ˆ๋‹ค.

DATA: LT_SPFLI TYPE TABLE OF SPFLI,      " ์—ฌ๋Ÿฌ ํ•ญ๊ณตํŽธ ์ •๋ณด๋ฅผ ๋‹ด์„ ์ธํ„ฐ๋„ ํ…Œ์ด๋ธ”
    WA_SPFLI TYPE SPFLI.                 " ๋‹จ์ผ ํ•ญ๊ณตํŽธ ์ •๋ณด๋ฅผ ๋‹ด์„ ์ž‘์—… ์˜์—ญ

PARAMETERS: P_CARRID TYPE SPFLI-CARRID.   " ์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•  ํ•ญ๊ณต์‚ฌ ID

* START-OF-SELECTION ์ด๋ฒคํŠธ
START-OF-SELECTION.
  " ์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•œ ํ•ญ๊ณต์‚ฌ ID๋ฅผ ๊ธฐ์ค€์œผ๋กœ SPFLI ํ…Œ์ด๋ธ”์—์„œ ๋ฐ์ดํ„ฐ๋ฅผ ์ฝ์–ด์˜ค๊ธฐ
  SELECT * INTO TABLE LT_SPFLI
    FROM SPFLI
    WHERE CARRID = P_CARRID.

* END-OF-SELECTION ์ด๋ฒคํŠธ
END-OF-SELECTION.
  " ์ฝ์–ด์˜จ ๋ฐ์ดํ„ฐ๋ฅผ ํ™”๋ฉด์— ์ถœ๋ ฅํ•˜๊ธฐ
  LOOP AT LT_SPFLI INTO WA_SPFLI.
    WRITE: /'ํ•ญ๊ณต์‚ฌ ID:', WA_SPFLI-CARRID,
           /'๋น„ํ–‰ํŽธ ๋ฒˆํ˜ธ:', WA_SPFLI-CONNID,
           /'์ถœ๋ฐœ ๋„์‹œ:', WA_SPFLI-CITYFROM,
           /'๋„์ฐฉ ๋„์‹œ:', WA_SPFLI-CITYTO.
  ENDLOOP.
  • ๋ฐ์ดํ„ฐ ์„ ์–ธ๋ถ€:
    • lt_spfli: ์—ฌ๋Ÿฌ ํ•ญ๊ณตํŽธ ์ •๋ณด๋ฅผ ๋‹ด์„ ์ธํ„ฐ๋„ ํ…Œ์ด๋ธ”
    • wa_spfli: ๋‹จ์ผ ํ•ญ๊ณตํŽธ ์ •๋ณด๋ฅผ ๋‹ด์„ ์ž‘์—… ์˜์—ญ
  • ์„ ํƒ ํ™”๋ฉด:
    • PARAMETERS ๋ฌธ์„ ์‚ฌ์šฉํ•˜์—ฌ ์‚ฌ์šฉ์ž๋กœ๋ถ€ํ„ฐ ํ•ญ๊ณต์‚ฌ ID(carrid)๋ฅผ ์ž…๋ ฅ ๋ฐ›์Œ
  • START-OF-SELECTION ์ด๋ฒคํŠธ:
    • ํ”„๋กœ๊ทธ๋žจ์ด ์‹œ์ž‘๋˜๋ฉด START-OF-SELECTION ์ด๋ฒคํŠธ๊ฐ€ ํŠธ๋ฆฌ๊ฑฐ๋ฉ๋‹ˆ๋‹ค.
    • ์ด ๋ถ€๋ถ„์—์„œ๋Š” ์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•œ ํ•ญ๊ณต์‚ฌ ID(carrid)๋ฅผ ๊ธฐ์ค€์œผ๋กœ SPFLI ํ…Œ์ด๋ธ”์—์„œ ํ•ญ๊ณตํŽธ ๋ฐ์ดํ„ฐ๋ฅผ ์ฝ์–ด์™€ lt_spfli ์ธํ„ฐ๋„ ํ…Œ์ด๋ธ”์— ์ €์žฅํ•ฉ๋‹ˆ๋‹ค.

ํŒŒ๋ผ๋ฏธํ„ฐ ์ž…๋ ฅ

 

  • END-OF-SELECTION ์ด๋ฒคํŠธ:
    • ๋ฐ์ดํ„ฐ ์ฝ๊ธฐ ์ž‘์—…์ด ์™„๋ฃŒ๋˜๋ฉด END-OF-SELECTION ์ด๋ฒคํŠธ๊ฐ€ ํŠธ๋ฆฌ๊ฑฐ๋ฉ๋‹ˆ๋‹ค.
    • ์ด ๋ถ€๋ถ„์—์„œ๋Š” lt_spfli ์ธํ„ฐ๋„ ํ…Œ์ด๋ธ”์— ์ €์žฅ๋œ ํ•ญ๊ณตํŽธ ๋ฐ์ดํ„ฐ๋ฅผ ํ™”๋ฉด์— ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค.
    • LOOP AT lt_spfli INTO wa_spfli: ์ธํ„ฐ๋„ ํ…Œ์ด๋ธ” lt_spfli์˜ ๊ฐ ๋ ˆ์ฝ”๋“œ๋ฅผ ์ˆœ์ฐจ์ ์œผ๋กœ ์ฝ์–ด ์ž‘์—… ์˜์—ญ wa_spfli์— ์ €์žฅํ•ฉ๋‹ˆ๋‹ค.
    • WRITE: ์ฝ์–ด์˜จ ๋ฐ์ดํ„ฐ๋ฅผ ํ™”๋ฉด์— ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค.

์ฝ์–ด์˜จ ๋ฐ์ดํ„ฐ ํ™”๋ฉด์— ์ถœ๋ ฅ

 

728x90
๋ฐ˜์‘ํ˜•