출력하는 프로그램을 만들고 있습니다.
인터널테이블에서 각 필드마다 중복되는 부분을 딱 한번만 나타내려고 합니다.
어떻게 하면 좋을 까요?
댓글 6
-
꼬맹이
2009.02.18 07:02
-
째마니
2009.02.18 12:41
질문이 조금 애매한데 값이 중복되는 필드가 1개일경우 그 필드를 일단 sort를 시키시고 delete에 필드명1에 그 필드를 넣어주시면 되구요.
만약 여러 필드가 중복이 된다면 sort에 해당필드를 모두 넣어서 sort를 시킨후 비교해서 삭제할 모든 필드를 delete에 필드명에다 넣어주시면 됩니다.
SORT ITAB BY 필드명1 필드명2 필드명3 ASCENDING.
DELETE ADJACENT DUPLICATES FROM ITAB COMPARING 필드명1 필드명2 필드명3.
-
無念군
2009.02.18 17:33
헛 .. 저건 F1 인가효~~~ 하하하 -
w
2009.02.18 18:46
F1...시원하군요..^^
-
튀밥
2009.02.18 20:11
F1이 좋긴한데..영어라서..ㅜㅜ
-
Storyroom.Net
2009.02.18 22:44
오옷 젤 정확한 답변!!!!
F1 에 한표여~
INSERT dbtab - source
Syntax
... { {VALUES wa}
| {FROM wa|{TABLE itab [ACCEPTING DUPLICATE KEYS]}} }.
Alternatives:
1. ... {VALUES wa} | {FROM wa} ...
2. ... FROM TABLE itab [ACCEPTING DUPLICATE KEYS] ...
Effect
After FROM and VALUES, you can specify a non-table-type data object wa. After FROM, you can also specify an internal table itab.
The contents of the row(s) to be inserted are taken from these data objects.
Alternative 1
... {VALUES wa} | {FROM wa} ...
Effect
If you specify a non-table-type work area wa, a row is created from its contents for insertion in the database table. The content of the row to be inserted is taken from the work area wa without taking its data type into consideration and without conversion
from left to right according to the structure of the database table or the view. The work area has to meet the prerequisites for use in Open SQL statements.
The new row is inserted in the database table if this does not already contain a row with the same primary key or the same unique secondary index. If it does, the row is not inserted and sy-subrc is set to 4.
If a view is specified in target that does not include all columns in the database table, these are set to the type-related initial value or to the null value in the inserted rows. The latter applies only if, for the relevant database column, the attribute initial
value is not selected in the ABAP Dictionary.
Notes
for the relevant database table or for the view with statement TABLES. The system then enhances the INSERT statement implicitly with the addition FROM dbtab.
Example
Inserting a new airline company in the database table SCARR.
DATA scarr_wa TYPE scarr.
scarr_wa-carrid = 'FF'.
scarr_wa-carrname = 'Funny Flyers'.
scarr_wa-currcode = 'EUR'.
scarr_wa-url = 'http://www.funnyfly.com'.
INSERT INTO scarr VALUES scarr_wa.
Alternative 2
... FROM TABLE itab [ACCEPTING DUPLICATE KEYS] ...
Effect
If you specify an internal table itab, several rows are created from its content for insertion in the database table. A row for insertion into the table is taken from each row of the internal table according to the same rules as for a single work area Einfgenwa.
The line type of the internal table has to meet the prerequisites for use in Open-SQL statements.
If a row witht he same primary key or a same unique secondary index does not already exist in the database table for any of the rows to be inserted, all rows are inserted and sy-subrc is set to 0. If the internal table is empty, sy-subrc is also set
to 0. The system field sy-dbcnt is always set to the number of rows that were actually inserted.
If a row with the same primary key or a same unique secondary index already exists in the database table for one or more of the rows to be inserted, these rows cannot be inserted. In this situation, there are three possibilities:
If the addition ACCEPTING DUPLICATE KEYS is specified, all rows are inserted for which this is possible. The remaining rows are rejected and sy-subrc is set to 4.
The system field sy-dbcnt is set to the number of lines that are inserted.
If the addition ACCEPTING DUPLICATE KEYS is not specified, a treatable exception occurs CX_SY_OPEN_SQL_DB (it always occurs since Release 6.10). Rows are inserted until the exception occurs. The number of rows that are inserted is not defined. The system fields
sy-subrc and sy-dbcnt retain their previous value.
If the addition ACCEPTING DUPLICATE KEYS is not specified and if the exception is not handled, then a runtime error occurs (it always occurs prior to Release 6.10). This executes a database rollback that reverses all changes to the current database LUW. This applies in
particular to rows that were inserted before a double entry occurred.
Note
If the runtime error is prevented because an exception is being treated, instead of using addition ACCEPTING DUPLICATE KEYS, if required, you have to initiate a program-controlled database rollback.