Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Catching Exceptions updating z tables.

Former Member
0 Kudos

Hello there, I´m trying to update a z-table , but I´m not sure if the way i´m working is the best , First I do a Select in order to check if the register exists ant then I make an update , but where I can catch any exception.???

SELECT * FROM zpx_ci_docs_proc

INTO TABLE ti_zpx_ci_docs

WHERE nume_docu = num_doc.

If sy-subrc = 0.

update zpx_ci_docs_proc set DATA_ENVI = dat_envi WHERE nume_docu = num_doc.

.

if sy-subrc = 0.

MESSAGE s000(zpb) WITH

" register update''

endif.

Thanks again.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

When you are updating /modifying a table..

Remember you need to enqueue and Dequeue the table before and after updation for data integrity.

A Enqueue and Dequeue FM's would be provided for you for the purpose once you create a custom table.

Thank you

4 REPLIES 4

Former Member
0 Kudos

You are already using sy-subrc, if it's 0 it means no errors, if you add an ELSE you are already into error handling area, because not 0 means error.

Former Member
0 Kudos

Hi,

When you are updating /modifying a table..

Remember you need to enqueue and Dequeue the table before and after updation for data integrity.

A Enqueue and Dequeue FM's would be provided for you for the purpose once you create a custom table.

Thank you

Former Member
0 Kudos

Hi,

Use enqueue FM before updating the table and After updation use dequeue FM.

DO.

Use ENQUEUE_E_TABLE FM

IF sy-subrc = 0.

EXIT.

ENDIF.

ENDDO.

UPDATE statement.

IF sy-subrc = 0.

Use DEQUEUE_E_TABLE FM

ELSE.

Error Handling.

ENDIF.

Do enddo is used to ensure that there are no locks apart from yours on the table before you update it.

Thanks,

Kartavya

Former Member
0 Kudos

Also please dequeue even if update is failed. i mean even if sy-subrc <> 0, then also dequeue the table.

Thanks,

Kartavya