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

[SAP ABAP] ์ค‘๋ณต ์ œ๊ฑฐ DELETE ADJACENT DUPLICATES ๋ž€?

by Jay Din 2024. 1. 8.
728x90
๋ฐ˜์‘ํ˜•

DELETE ADJACENT DUPLICATES ๋ž€?

๋‚ด๋ถ€ ํ…Œ์ด๋ธ”์—์„œ ์ธ์ ‘ํ•œ(์—ฐ์†์ ์ธ) ์ค‘๋ณต ๋ ˆ์ฝ”๋“œ๋ฅผ ์ฐพ์•„ ํ•˜๋‚˜๋งŒ ๋‚จ๊ธฐ๊ณ  ๋‚˜๋จธ์ง€๋ฅผ ์ œ๊ฑฐํ•ฉ๋‹ˆ๋‹ค.

ํ•ด๋‹น ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์ „์— SORT(์ •๋ ฌ)๊ฐ€ ์„ ํ–‰๋˜์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

 

์˜ˆ์ œ

DATA: LT_TABLE TYPE TABLE OF STRING,
      LS_TABLE_LINE TYPE STRING.

APPEND 'Row 1' TO LT_TABLE.
APPEND 'Row 2' TO LT_TABLE.
APPEND 'Row 3' TO LT_TABLE.
APPEND 'Row 1' TO LT_TABLE.
APPEND 'Row 2' TO LT_TABLE.
APPEND 'Row 3' TO LT_TABLE.


WRITE: '---- ์ •๋ ฌ ์ „ ----'.
DELETE ADJACENT DUPLICATES FROM LT_TABLE.

LOOP AT LT_TABLE INTO LS_TABLE_LINE.
  WRITE: / LS_TABLE_LINE.
ENDLOOP.

WRITE: / '---- ์ •๋ ฌ ํ›„ ----'.
SORT LT_TABLE.
DELETE ADJACENT DUPLICATES FROM LT_TABLE.

LOOP AT LT_TABLE INTO LS_TABLE_LINE.
  WRITE: / LS_TABLE_LINE.
ENDLOOP.

์‹คํ–‰ ๊ฒฐ๊ณผ

 

๊ตฌ๋ฌธ ์ข…๋ฅ˜

์ด ๋‘ ์˜ต์…˜์€ ์ค‘๋ณต ์ œ๊ฑฐ์˜ ๊ธฐ์ค€์„ ์–ด๋–ป๊ฒŒ ์„ค์ •ํ•  ๊ฒƒ์ธ์ง€์— ๋Œ€ํ•ด ์œ ์—ฐ์„ฑ์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

ํ•„์š”์— ๋”ฐ๋ผ ๋ชจ๋“  ํ•„๋“œ๋ฅผ ๊ณ ๋ คํ•˜๊ฑฐ๋‚˜ ํŠน์ • ํ•„๋“œ๋ฅผ ์„ ํƒํ•˜์—ฌ ์ค‘๋ณต์„ ์ œ๊ฑฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

COMPARING ALL FIELDS

DELETE ADJACENT DUPLICATES FROM gt_list COMPARING ALL FIELDS.
  • `COMPARING ALL FIELDS`๋Š” ๋‚ด๋ถ€ ํ…Œ์ด๋ธ”์—์„œ ์ค‘๋ณต๋œ ๋ ˆ์ฝ”๋“œ๋ฅผ ์ œ๊ฑฐํ•  ๋•Œ ๋ชจ๋“  ํ•„๋“œ๋ฅผ ๊ณ ๋ คํ•˜์—ฌ ๋น„๊ตํ•œ๋‹ค๋Š” ์˜๋ฏธ์ž…๋‹ˆ๋‹ค.
  • ์ฆ‰, ๋‚ด๋ถ€ ํ…Œ์ด๋ธ”์˜ ๋ชจ๋“  ํ•„๋“œ์˜ ๊ฐ’์ด ๋™์ผํ•œ ๊ฒฝ์šฐ์— ์ค‘๋ณต์œผ๋กœ ๊ฐ„์ฃผ๋˜์–ด ํ•˜๋‚˜์˜ ๋ ˆ์ฝ”๋“œ๋งŒ ์œ ์ง€๋ฉ๋‹ˆ๋‹ค.

 

COMPARING field1 field2

DELETE ADJACENT DUPLICATES FROM gt_list COMPARING carrid connid.
  • `COMPARING field1 field2`๋Š” ํŠน์ • ํ•„๋“œ๋‚˜ ํ•„๋“œ ๊ทธ๋ฃน์„ ์ง€์ •ํ•˜์—ฌ ์ค‘๋ณต ์ œ๊ฑฐ์˜ ๊ธฐ์ค€์„ ์ •ํ•ฉ๋‹ˆ๋‹ค.
  • ์˜ˆ๋ฅผ ๋“ค์–ด, `COMPARING carrid connid`๋Š” `carrid`์™€ `connid` ํ•„๋“œ์˜ ์กฐํ•ฉ์ด ๋™์ผํ•œ ๋ ˆ์ฝ”๋“œ๋ฅผ ์ค‘๋ณต์œผ๋กœ ๊ฐ„์ฃผํ•˜์—ฌ ์ค‘๋ณต์„ ์ œ๊ฑฐํ•ฉ๋‹ˆ๋‹ค.

 

728x90
๋ฐ˜์‘ํ˜•