07-02-2007 7:32 AM
hello:
when i execute the code below,there is a runtime error." In die sortierte interne Tabelle (Typ SORTED_TABLE)
"PROGRAM=ZJOIN_INTER_TABLEDATA=T_ITAB1" sollte an
Position 1 eine Zeile eingefügt bzw. geändert werden.
Dadurch wurde die für die Tabelle durch ihren Schlüssel festgelegte
Sortierreihenfolge zerstört."
how can i resolve it?which one can tell me?Thanks very much
REPORT ZJOIN_INTER_TABLE.
DATA:BEGIN OF WA_ITAB,
COL1 TYPE I,
COL2(10) TYPE C,
END OF WA_ITAB.
DATA:T_ITAB1 LIKE SORTED TABLE OF WA_ITAB WITH NON-UNIQUE KEY COL1.
WA_ITAB-COL1 = 10.
WA_ITAB-COL2 = 'col2'.
APPEND WA_ITAB TO T_ITAB1.
WA_ITAB-COL1 = 9.
WA_ITAB-COL2 = 'col2'.
APPEND WA_ITAB TO T_ITAB1.
07-02-2007 7:40 AM
HI,
As you have a NON-UNIQUE and key as col1 and want to sort it you can acheive the same using.
DATA:BEGIN OF wa_itab,
col1 TYPE i,
col2(10) TYPE c,
END OF wa_itab.
DATA:t_itab1 LIKE TABLE OF wa_itab WITH KEY col1.
wa_itab-col1 = 10.
wa_itab-col2 = 'col2'.
APPEND wa_itab TO t_itab1.
CLEAR wa_itab.
wa_itab-col1 = 9.
wa_itab-col2 = 'col2'.
APPEND wa_itab TO t_itab1.
SORT t_itab1 BY col1.
Regards,
Sesh
.
07-02-2007 7:39 AM
since it is a sorted table and you are trying to break the sort order by appending 10 first then 9 in col1 so it is giving an error just change the order of appending i.e. col1 9 first then 10.
REPORT ZJOIN_INTER_TABLE.
DATA:BEGIN OF WA_ITAB,
COL1 TYPE I,
COL2(10) TYPE C,
END OF WA_ITAB.
DATA:T_ITAB1 LIKE SORTED TABLE OF WA_ITAB WITH NON-UNIQUE KEY COL1.
WA_ITAB-COL1 = 9.
WA_ITAB-COL2 = 'col2'.
APPEND WA_ITAB TO T_ITAB1.
WA_ITAB-COL1 = 10.
WA_ITAB-COL2 = 'col2'.
APPEND WA_ITAB TO T_ITAB1.
regards
shiba dutta
07-02-2007 7:40 AM
Hi
If your non-unique key is COL1, then you cannot have 2 records with same value of COL2 i.e 'col2'. [COL2 being ur unique key column]
Regards
Raj
07-02-2007 7:40 AM
HI,
As you have a NON-UNIQUE and key as col1 and want to sort it you can acheive the same using.
DATA:BEGIN OF wa_itab,
col1 TYPE i,
col2(10) TYPE c,
END OF wa_itab.
DATA:t_itab1 LIKE TABLE OF wa_itab WITH KEY col1.
wa_itab-col1 = 10.
wa_itab-col2 = 'col2'.
APPEND wa_itab TO t_itab1.
CLEAR wa_itab.
wa_itab-col1 = 9.
wa_itab-col2 = 'col2'.
APPEND wa_itab TO t_itab1.
SORT t_itab1 BY col1.
Regards,
Sesh
.
07-02-2007 7:40 AM
REPORT ZJOIN_INTER_TABLE.
DATA:BEGIN OF WA_ITAB,
COL1 TYPE I,
COL2(10) TYPE C,
END OF WA_ITAB.
DATA:T_ITAB1 LIKE SORTED TABLE OF WA_ITAB WITH NON-UNIQUE KEY COL1.
WA_ITAB-COL1 = 10.
WA_ITAB-COL2 = 'col2'.
APPEND WA_ITAB TO T_ITAB1.
CLEAR T_ITAB1.
WA_ITAB-COL1 = 9.
WA_ITAB-COL2 = 'col2'.
APPEND WA_ITAB TO T_ITAB1.
YOU NEED TO CLEAR YOUR T_ITAB1 BEFORE APPENDING ANY FURTHER
DATA INTO IT
THNKX
BHANU
07-02-2007 7:43 AM
hi
kindly go thro the lines.
syntax:
DATA itab {TYPE tabkind OF linetype|LIKE tabkind OF lineobj}
WITH [UNIQUE|NON-UNIQUE] keydef
[INITIAL SIZE n] [WITH HEADER LINE].
The system creates an internal table with table type tabkind. Since there is no generic field definition, you cannot use the table types ANY TABLE or SORTED TABLE.
The construction of the table lines is defined by linetype (if you are using a TYPE reference) or by the type of the referred object lineobj (if you are using a LIKE reference). If you specify the line type, you can also use REF TO to refer to a reference type.
The same rules apply to UNIQUE and NON-UNIQUE as apply to the TYPES definition. You may only omit this specification with standard tables.
If you do not specify an INITIAL SIZE, the system assumes a default value of INITIAL SIZE 0.
i think now u r clear... now yr code will work.
DATA:BEGIN OF WA_ITAB,
COL1 TYPE I,
COL2(10) TYPE C,
END OF WA_ITAB.
DATA:T_ITAB1 like TABLE OF WA_ITAB WITH NON-UNIQUE KEY COL1.
WA_ITAB-COL1 = 10.
WA_ITAB-COL2 = 'col2'.
APPEND WA_ITAB TO T_ITAB1.
WA_ITAB-COL1 = 9.
WA_ITAB-COL2 = 'col2'.
APPEND WA_ITAB TO T_ITAB1.
07-02-2007 7:52 AM
hi,
u r using sorted table so u have to append records in any of ascending or decending order. in our program ur trying to append 10 and then 9 th record which is not possible with soretd internal tables . if u want to do loike that make 1oth as 9 th n wise versa and add them to internal table.
if helpful reward some points.
with regards,
Suresh.A
07-02-2007 8:04 AM
Hi,
try with this code.
just copy paste the code n run.
REPORT zjoin_inter_table.
TYPES:
BEGIN OF ty_itab,
col1 TYPE i,
col2(10) TYPE c,
END OF ty_itab.
DATA:t_itab1 type SORTED TABLE OF ty_itab WITH NON-UNIQUE KEY col1,
wa_itab TYPE ty_itab.
wa_itab-col1 = 9.
wa_itab-col2 = 'col2'.
APPEND wa_itab TO t_itab1.
CLEAR wa_itab.
wa_itab-col1 = 10.
wa_itab-col2 = 'col2'.
APPEND wa_itab TO t_itab1.
CLEAR wa_itab.
LOOP AT t_itab1 INTO wa_itab.
WRITE:/ wa_itab-col1, wa_itab-col2.
CLEAR wa_itab.
ENDLOOP.
regards,
sudha
07-03-2007 7:12 AM