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: 

How to change order item type?

Former Member
0 Kudos

Hi,

I have problem with changing order items type in implementation badi order_save.
To do it, first I have to change system item status to 'open', then change item type and set previous system status again. (because there is a blockade).

To change system status I'm using CRM_STATUS_CHANGE_INTERN_VB and BAPI_TRANSACTION_COMMIT.
After that I'm trying to change item type with use CRM_ORDER_MAINTAIN.


However CRM_ORDER_MAINTAIN 'don't see' changes of  CRM_STATUS_CHANGE_INTERN_VB.

I know that both functions works good singly:
If I first manually change system status, and then call CRM_ORDER_MAINTAIN it works good.
If I call both function system status are changed but item type don't.

Maybe I have to refresh samehow database between both function callings?
Or do you have any other ideas?

regards,
Michal

2 REPLIES 2

Former Member
0 Kudos

Hello Michal,

ABAO development is a good place for this question, CRM is a better one as most ABAP guys wont know much about item categories.

I would do the change with BOL bacuse BOL takes care of any business logic regarding status or whatever.

Here is a program how to change the item category (thanks to SCN we are allowed to copy and past again, that makes it easier):

DATA: lr_core TYPE REF TO cl_crm_bol_core.
DATA: lr_btadmini TYPE REF TO cl_crm_bol_entity.
DATA: lv_item_category TYPE string.
DATA: lr_transaction TYPE REF TO if_bol_transaction_context.

lr_core ?= cl_crm_bol_core=>get_instance( ).
lr_core->start_up( 'BT' ).

lr_btadmini ?= lr_core->get_root_entity( iv_object_name = 'BTAdminI'
                                         iv_object_guid = '54520C570BDC0A50E10080000A046FA0' ).

CHECK lr_btadmini IS BOUND.

lv_item_category = 'ZFCI'. "ZFCI
lr_btadmini->set_property_as_string( iv_attr_name = 'ITM_TYPE' iv_value = lv_item_category ).

* Below coding is for saving only
lr_core->modify( ).
lr_transaction ?= lr_core->get_transaction( ).
IF lr_transaction->save( ) = abap_true.
  lr_transaction->commit( ).
ENDIF.

Of course you need to change the item-guid and and new category value. And if you make the change in order_save then you don't need the part with the save and commit.

Please tell me if it does not work for you. It is working fine in my system.

Best regards,

Thomas Wagner

former_member182421
Active Contributor
0 Kudos

That's probably because you are mixing different software layers, you should be able to change the status using the CRM_ORDER_MAINTAIN, otherwise the system buffers may not be correctly updated, and the API will behave weird, wrong, etc.

A dirty trick is use the first FM, save, use the second FM and save again, but I won't recommend that way, use correctly the CRM_ORDER_MAINTAIN or even call it two times if is necessary, the best in this scenarios is to put a break point on the CRM_ORDER_MAINTAIN and perform the action on line via CRMD_ORDER or even bettwer in the WebUI and analyse how the standard calls the API and how many times.

Cheers!

Luis