How To change order status with bol programming

DATA: lv_status           TYPE j_estat,
      lr_adm_h            TYPE REF TO cl_crm_bol_entity,
      lr_btorder          TYPE REF TO cl_crm_bol_entity,
      lr_core             TYPE REF TO cl_crm_bol_core,
      lr_status_h         TYPE REF TO cl_crm_bol_entity,
      lr_status           TYPE REF TO cl_crm_bol_entity.

lr_core = cl_crm_bol_core=>get_instance( ).
CHECK lr_core IS BOUND.

lr_core->load_component_set( 'ALL' ).

lr_btorder = lr_core->get_root_entity( iv_object_name = 'BTOrder'
                                       iv_object_guid = ls_list-guid_mserv ).

IF lr_btorder IS BOUND.
  lr_adm_h = lr_btorder->get_related_entity( iv_relation_name = 'BTOrderHeader' ).
ENDIF.

IF lr_adm_h IS BOUND.

* check if locked
IF lr_adm_h->is_locked( ) EQ abap_false.
   lr_adm_h->lock( ).
ENDIF.

lv_object_guid = lr_adm_h->get_property_as_string( 'GUID' ).

lv_status = ‘E0005’.

TRY.
      lr_status_h = ir_adminh->get_related_entity( 'BTHeaderStatusSet' ).
      IF lr_status_h IS NOT BOUND.
        lr_status_h = ir_adminh->create_related_entity( 'BTHeaderStatusSet' ).
      ENDIF.

      CHECK lr_status_h IS BOUND.

      lr_status = lr_status_h->get_related_entity( 'BTStatusHCurrent' ).
      IF lr_status IS NOT BOUND.
        lr_status = lr_status_h->create_related_entity( 'BTStatusHCurrent' ).
      ENDIF.

      CHECK lr_status IS BOUND.

      lr_status->set_property( iv_attr_name = 'STATUS'
                               iv_value     = lv_status).
*
      lr_status->set_property( iv_attr_name = 'ACT_STATUS'
                               iv_value     = lv_status ).


    CATCH cx_crm_genil_model_error
          cx_root.
  ENDTRY.

lr_core->modify( ).

lv_transaction = lr_core->get_transaction( ).
IF lv_transaction->check_save_possible( ) EQ 'X'.
  IF lv_transaction->save( ) EQ 'X'.
    lv_transaction->commit( ).
  ENDIF.
ENDIF.

 

ABOUT Uğur Kaya

http://linkedin.com/in/kayau

RELATED POSTS

COMMENTS

comments powered by Disqus