Hello Hua Shao,
if you would like to delete a whole BO instance, it is sufficient to just delete the root instance of this BO instance. All instances of subnodes (and subsubnodes) of this root instance are automatically deleted. Here is some example code to delete all existing instances of a BO, so please take care :
" get the service manager of the Invoice BO
DATA lo_customer_invoice TYPE REF TO /bobf/if_tra_service_manager.
lo_customer_invoice = /bobf/cl_tra_serv_mgr_factory=>get_service_manager( iv_bo_key = zif_ci_00_customer_invoice_c=>sc_bo_key ).
" query all existing invoices
DATA ls_root_key TYPE /bobf/s_frw_key.
DATA lt_root_key TYPE /bobf/t_frw_key.
lo_customer_invoice->query(
EXPORTING iv_query_key = zif_ci_00_customer_invoice_c=>sc_query-root-select_all
IMPORTING et_key = lt_root_key ).
" delete all invoices
DATA ls_modification TYPE /bobf/s_frw_modification.
DATA lt_modification TYPE /bobf/t_frw_modification.
LOOP AT lt_root_key INTO ls_root_key.
ls_modification-node = zif_ci_00_customer_invoice_c=>sc_node-root.
ls_modification-key = ls_root_key-key.
ls_modification-change_mode = /bobf/if_frw_c=>sc_modify_delete.
APPEND ls_modification TO lt_modification.
ENDLOOP.
" execute modification
lo_customer_invoice->modify( it_modification = lt_modification ).
" save the transaction
DATA lo_transaction_manager TYPE REF TO /bobf/if_tra_transaction_mgr.
lo_transaction_manager = /bobf/cl_tra_trans_mgr_factory=>get_transaction_manager( ).
lo_transaction_manager->save( ).
Best regards
Tilmann