Application Development and Automation 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: 
Read only

Truncate Command Not working

Former Member
0 Likes
755

Folks, I have a SAP Table that I want to delete all the data from but still want to keep the table definition.. I dont want to fetch the records and then delete as this is a huge table so want to use a truncate command. The issue is that program has no syntax errors but it would not delete the data at all. Here is the code I have used and I am on a DB2 system, can someone help what I am doing wrong?

DATA: exc_ref TYPE REF TO cx_sy_native_sql_error,

error_text TYPE string.

TRY.

EXEC SQL.

TRUNCATE TABLE S194

ENDEXEC.

CATCH cx_sy_native_sql_error INTO exc_ref.

error_text = exc_ref->get_text( ).

ENDTRY.

IF SY-SUBRC = 0.

commit work.

ELSE.

write : / error_text .

ENDIF.

Message was edited by:

Ram Gowda

2 REPLIES 2
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
560

How about.....

delete from s194 client specified where mandt = sy-mandt.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
560

You may want to Google TRUNCATE DB2. I'm not sure if you can do this, but there appear to be other options.

Rob