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

Delete Root

ronaldo_aparecido
Contributor
0 Likes
1,412

Hi experts

Im trying to delete a root :

    DATA: ls_sel_opt TYPE /bobf/s_frw_query_selparam,

          lt_sel_opt TYPE /bobf/t_frw_query_selparam.

    ls_sel_opt-attribute_name = /scmtms/if_tor_c=>sc_query_attribute-root-planning_attributes-tor_id.

    ls_sel_opt-sign  = 'I'.

    ls_sel_opt-option = 'EQ'.

    ls_sel_opt-low    = p_custid.

    ls_sel_opt-high  = ''.

    INSERT ls_sel_opt INTO TABLE lt_sel_opt.

    DATA lo_change        TYPE REF TO /bobf/if_tra_change.

    DATA lo_message        TYPE REF TO /bobf/if_frw_message.

    DATA lt_failed_key    TYPE /bobf/t_frw_key.

    DATA: lt_failed_act_key TYPE /bobf/t_frw_key,

          lo_srvmgr        TYPE REF TO /bobf/if_tra_service_manager.

    DATA: ls_parameters  TYPE /scmtms/tor_id,

          lr_s_parameters TYPE REF TO data,

          lx_frw          TYPE REF TO /bobf/cx_frw.

    DATA: lo_srv_mgr TYPE REF TO /bobf/if_tra_service_manager,

          lt_tor_key TYPE /bobf/t_frw_key.

* Get an instance of a service manager for e.g. BO TRQ

    lo_srv_mgr = /bobf/cl_tra_serv_mgr_factory=>get_service_manager( /scmtms/if_tor_c=>sc_bo_key ).

* Query business object - KEY

    CALL METHOD lo_srv_mgr->query

      EXPORTING

        iv_query_key            = /scmtms/if_tor_c=>sc_query-root-planning_attributes

        it_selection_parameters = lt_sel_opt

      IMPORTING

        et_key                  = lt_tor_key.

*    CREATE DATA lr_s_parameters.

* Carry out check

*      lr_s_parameters->delete_root = 'X'.

    CALL METHOD lo_srv_mgr->do_action

      EXPORTING

        iv_act_key          = /scmtms/if_tor_c=>sc_action-root-delete_root

        it_key              = lt_tor_key

        is_parameters        = lr_s_parameters

      IMPORTING

        eo_change            = lo_change

        eo_message          = lo_message

        et_failed_key        = lt_failed_key

        et_failed_action_key = lt_failed_act_key.

is ocurring dump but i dont know why

could you helpme?

the dump is attached.

1 ACCEPTED SOLUTION
Read only

former_member190794
Active Participant
0 Likes
924

Hello Ronaldo,

in order to delete node instances you must use the corresponding core service "modify" instead of invoking an internal action. Please check the example below.

Best regards

Tilmann

Example:

Attention! This example deletes ALL instances of a BO - this is not would you like to do on the TOR object I guess

" get the service manager of the InvoiceBO
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.
  APPENDls_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().

3 REPLIES 3
Read only

former_member190794
Active Participant
0 Likes
925

Hello Ronaldo,

in order to delete node instances you must use the corresponding core service "modify" instead of invoking an internal action. Please check the example below.

Best regards

Tilmann

Example:

Attention! This example deletes ALL instances of a BO - this is not would you like to do on the TOR object I guess

" get the service manager of the InvoiceBO
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.
  APPENDls_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().

Read only

0 Likes
924

HI David thanks for reply.

I dont know if is it .

I want to delete a especific shipping order.

for example i have shipping order.

00100001

00100002

00100003


i want put 00100002 in my program and delete only this number.


the code you send me do it?

Read only

0 Likes
924

hI dAVID I OPEN OTHER POST WITH OTHER PROBLEM AND I NEED HELP COULD YOU HELPME ? THE LINK IS:

IM BOPF BEGINNER.