‎2008 Feb 22 3:19 AM
Hi
i would like to catch system exception cx_sy_open_sql_db INTO error_obj_ref. can i couut the error records using this?
DATA : error_obj_ref TYPE REF TO cx_root.
Thanks
Anbu
‎2008 Feb 22 4:19 AM
Hi,
Try like this....
The exception occurs 4 times and is displayed...
DATA: it_mara TYPE STANDARD TABLE OF mara WITH HEADER LINE,
oref TYPE REF TO cx_root,
text TYPE string,
count.
SELECT *
FROM mara
UP TO 5 ROWS
INTO TABLE it_mara.
perform insert.
perform insert.
perform insert.
perform insert.
write count.
form insert .
TRY.
insert mara from table it_mara.
CATCH cx_sy_open_sql_db INTO oref.
text = oref->get_text( ).
if text is not initial.
count = count + 1.
endif.
ENDTRY.
endform. " insertCheers,
jose.
Edited by: jose on Feb 22, 2008 5:19 AM
‎2008 Feb 22 4:19 AM
Hi,
Try like this....
The exception occurs 4 times and is displayed...
DATA: it_mara TYPE STANDARD TABLE OF mara WITH HEADER LINE,
oref TYPE REF TO cx_root,
text TYPE string,
count.
SELECT *
FROM mara
UP TO 5 ROWS
INTO TABLE it_mara.
perform insert.
perform insert.
perform insert.
perform insert.
write count.
form insert .
TRY.
insert mara from table it_mara.
CATCH cx_sy_open_sql_db INTO oref.
text = oref->get_text( ).
if text is not initial.
count = count + 1.
endif.
ENDTRY.
endform. " insertCheers,
jose.
Edited by: jose on Feb 22, 2008 5:19 AM
‎2008 Feb 22 4:29 AM
Hi Jose,
For example i am trying to insert 3 records to Data base table.
These records are already there. when i execute its counting only one record. becoz it's not in loop. how to fix this?
Thanks
Anbu
‎2008 Feb 22 4:43 AM
select all the data related into the internal table and check if there is an entry or not... if not then only insert the record..
loop at one table and read on another will server this purpose.
loop at itab into wa_itab.
read table itab_next into wa_next where f1 = wa_itab-f1.
if sy-subrc eq 0.
delete itab index sy-index.
endif .
endloop.
‎2008 Feb 22 4:46 AM
Hi,
if ur inserting like below
insert DBTAB from WA.
it wont dump even if record exists already.....but sy-subrc ll 4..u can use dat..
if ur inserting like dis
insert DBTAB from table ITAB .
it ll dump even if one record exists already.....so follow dat example..
Cheers,
jose.
‎2008 Feb 22 4:53 AM
hi jose
I tried the above code. but its not counting properly
‎2008 Feb 22 4:57 AM
updating a Ztable will depend on the key field of the table, you cannot have redundant data in key fields.. keep that in mind...
‎2008 Feb 22 5:04 AM
Hi,
U need the no of records that already exists in table right.......
if its so
DATA: it_mara TYPE STANDARD TABLE OF mara WITH HEADER LINE,
count.
SELECT *
FROM mara
UP TO 5 ROWS
INTO TABLE it_mara.
LOOP AT it_mara.
INSERT mara FROM it_mara.
IF sy-subrc IS NOT INITIAL.
count = count + 1.
ENDIF.
ENDLOOP.
WRITE count.
‎2008 Feb 22 5:10 AM
Hi
i dont want to insert table in loop. b'coz my internal table having 2 milloin records. if it is in loop it ll affect the performance right?
‎2008 Feb 22 12:45 PM
Hi,
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.
So i Don think its possible without loop..........
Cheers,
jose.