ABAP FM Create Material Variant Configuration with Reference (CUCB_COPY_CONFIGURATION)
In this blog post, I will share a function module to copy Variant Configuration of an existing material and paste it to another one.
We will use CUCB_GET_CONFIGURATION, CUCB_COPY_CONFIGURATION and CUCB_SET_CONFIGURATION standard function modules.
It takes reference material number and the material number itself as parameter. (Plant is optional. I used 2000 as plant number.) And it returns Variant Configuration Instance Number (MARA-CUOBF) which you may need for further processing.
Here is the source code:
ZMA_F_CREATE_VARIANT_CONFIG_WR
Import Parameters:
P_MATCFG
TYPE
MARA-MATNR
Reference Material
F_MATNR
TYPE
MARA-MATNR
The Material to Create Variant Configuration
P_WERKS
TYPE
WERKS-WERKS
Plant
Export Parameter:
E_NEW_INSTANCE
TYPE
MARA-CUOBF
Internal object number
function zma_f_create_variant_config_wr. *“———————————————————————- *”*“Local Interface: *” IMPORTING *“ REFERENCE(P_MATCFG) TYPE MARA-MATNR *” REFERENCE(F_MATNR) TYPE MARA-MATNR *“ REFERENCE(P_WERKS) TYPE WERKS-WERKS OPTIONAL *” EXPORTING *“ REFERENCE(E_NEW_INSTANCE) TYPE MARA-CUOBF *”———————————————————————- type-pools: ibco2. data: ref_cuobf type mara-cuobf. select single cuobf from mara into ref_cuobf where matnr = p_matcfg. if sy-dbcnt > 0. data: lv_satnr type mara-satnr. select single satnr from mara into lv_satnr where matnr = p_matcfg. data: instance type cuib_cuobj, ibase type ibco2_ibase_rec, configuration type ibco2_instance_tab2, wa_configuration like line of configuration, eo_cbase_ref type ref to if_cbase_e. data: iv_instance type cuib_cuobj, new_instance type cuib_cuobj, lv_root_inst type cuib_cuobj, lt_cfg type ibco2_instance_tab2, ls_cfg like line of lt_cfg, lt_match type cuib_match_instance_tab, ibase_copy type ibco2_ibase_rec, es_instance_rec type ibco2_instance_rec2, configuration_copy type ibco2_instance_tab2, wa_config_copy like line of configuration, eo_cbase_ref_copy type ref to if_cbase_e. if p_werks = “. move ref_cuobf to instance. call function ‘CUCB_GET_CONFIGURATION’ exporting instance = instance importing ibase = ibase configuration = configuration eo_cbase_ref = eo_cbase_ref exceptions invalid_input = 1 invalid_instance = 2 instance_is_a_classification = 3 others = 4. refresh: lt_cfg, lt_match. call function ‘CUCB_COPY_CONFIGURATION’ exporting source_instance = instance importing configuration = lt_cfg et_match_instance = lt_match es_instance_rec = es_instance_rec exceptions invalid_instance = 1 instance_is_a_classification = 2 others = 3. if sy-subrc 0. message id sy-msgid type sy-msgty number sy-msgno with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. endif. data: owner type ibxx_business_object. data: lv_ibase type p. loop at lt_cfg into ls_cfg. lv_root_inst = ls_cfg-instance. owner-object_type = ‘MARAT’. owner-object_key = f_matnr. ls_cfg-owner = owner. modify lt_cfg from ls_cfg. endloop. call function ‘CUCB_SET_CONFIGURATION’ exporting root_instance = lv_root_inst changing configuration = lt_cfg exceptions invalid_input = 1 invalid_instance = 2 instance_is_a_classification = 3 others = 4. call function ‘BAPI_TRANSACTION_COMMIT’ exporting "wait = ‘X’ wait = ‘X’. call function ‘CUCB_CONFIGURATION_TO_DB’ exporting root_instance = lv_root_inst root_object = ls_cfg-owner force_new_instance = ‘X’ * IV_WITHOUT_COMMIT_UPDATE = ’ ’ iv_material = f_matnr * IV_LOCATION = ‘2000’ importing new_instance = new_instance * TABLES * EXP_NEW_NESTED_CUOBJS = exceptions invalid_instance = 1 invalid_root_instance = 2 no_changes = 3 already_registered_for_update = 4 instance_is_a_classification = 5 others = 6. if sy-subrc 0. message id sy-msgid type sy-msgty number sy-msgno with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. else. data: ls_bapiret3 type bapiret2. call function ‘BAPI_TRANSACTION_COMMIT’ exporting "wait = ‘X’ wait = ‘X’ importing return = ls_bapiret3. data: wa_mara type mara. select * from mara into wa_mara where matnr = f_matnr. wa_mara-satnr = lv_satnr. wa_mara-cuobf = new_instance. update mara from wa_mara. endselect. e_new_instance = new_instance. endif. elseif p_werks = ‘2000’. ” For Werks 2000 clear: instance. data: lv_objkey type ibinown-objkey. concatenate p_matcfg p_werks into lv_objkey. select single instance from ibinown into instance where objkey = lv_objkey. call function ‘CUCB_GET_CONFIGURATION’ exporting instance = instance importing ibase = ibase configuration = configuration eo_cbase_ref = eo_cbase_ref exceptions invalid_input = 1 invalid_instance = 2 instance_is_a_classification = 3 others = 4. refresh: lt_cfg, lt_match. “ Take MARC instance call function ‘CUCB_COPY_CONFIGURATION’ exporting source_instance = instance importing configuration = lt_cfg et_match_instance = lt_match exceptions invalid_instance = 1 instance_is_a_classification = 2 others = 3. if sy-subrc 0. message id sy-msgid type sy-msgty number sy-msgno with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. endif. clear: owner. data: type_of type ibxx_business_object. loop at lt_cfg into ls_cfg. lv_root_inst = ls_cfg-instance. owner-object_type = ‘MARC’. owner-object_key = f_matnr. concatenate owner-object_key p_werks into owner-object_key. ls_cfg-owner = owner. modify lt_cfg from ls_cfg. endloop. call function ‘CUCB_SET_CONFIGURATION’ exporting root_instance = lv_root_inst changing configuration = lt_cfg exceptions invalid_input = 1 invalid_instance = 2 instance_is_a_classification = 3 others = 4. call function ‘BAPI_TRANSACTION_COMMIT’ exporting "wait = ‘X’ wait = ‘X’. call function ‘CUCB_CONFIGURATION_TO_DB’ exporting root_instance = lv_root_inst root_object = ls_cfg-owner force_new_instance = ‘X’ * IV_WITHOUT_COMMIT_UPDATE = ’ ’ iv_material = f_matnr iv_location = ‘2000’ importing new_instance = new_instance * TABLES * EXP_NEW_NESTED_CUOBJS = exceptions invalid_instance = 1 invalid_root_instance = 2 no_changes = 3 already_registered_for_update = 4 instance_is_a_classification = 5 others = 6. if sy-subrc 0. message id sy-msgid type sy-msgty number sy-msgno with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. else. clear: ls_bapiret3. call function ‘BAPI_TRANSACTION_COMMIT’ exporting "wait = ‘X’ wait = ‘X’ importing return = ls_bapiret3. data: wa_marc type marc. select * from marc into wa_marc where matnr = f_matnr. wa_marc-stdpd = lv_satnr. wa_marc-cuobj = new_instance. update marc from wa_marc. endselect. e_new_instance = new_instance. endif. endif. endif. endfunction. http://bit.ly/2jIslOJ #SAP #SAPCloud #AI
#StratBlog: #Change is Like a Roller Coaster
Change is Like a Roller Coaster
You have been waiting in line for the past hour and you finally take your seat. As the announcement blares over the loudspeaker, the overhead bar lowers and firmly presses against your chest. The anticipation is at its peak as the sound of the cars are being pulled to the top of the crest, Click, Click, Click. The silence is deafening and you begin to question your decision. In a matter of seconds, the following emotions race through your mind: fear, uncertainty, and depression.
Although many have experienced this roller coaster before, for others, this is very new. Depending on your past experience the situation will be very different.
Why is change so difficult and unpredictable? The truth is, its not. Thousands of hours have been spent in researching the causes, effects, and attributes of change. There are several white papers, communities, models, etc. that outline the change process. The challenge is not the what, the challenge is in the how.
Most organizations do not take change management seriously. It is a check the box exercise, to show that “i’s” are dotted and “t’s” are crossed. Very few organizations truly invest in their change management programs which is why their desired outcomes are not achieved. In fact, According to John Kotter (creator of the 8- step process for leading change), only 30% of Change Management programs succeed; the two primary factors for failure are sponsorship and resistance.
Let’s take a moment to unpack Change Management. As a program, the purpose of Change Management is to minimize the risk and interruption when an organization is moving from a current to a desired future state. According the dictionary, the term change means “something new” or to “make different”and term management means “to deal with”, or “control”.
Before I go farther, I want to ask yourself this question. When my organization is creating something new or making something different, Do we control the process to ensure we achieve successful outcome? Based on the research by Kotter, it is fair to say that 70% of the time you do not.
If you are currently managing a change or beginning to plan for a change, I would like to provide you with three actions that will help you be successful.
1. Clearly Define the Change. You must have a clear understanding of the entire change and the implications across the organization. What are the up-stream and down-stream impacts on people, process, and technology?, What are the new behaviors, actions that need to be take, decisions that need to be made, expectations that need to be followed? People only know as much as you tell them. You cannot expect a change, when know one knows that the change is.
2. Manage the Change like a Program vs. a Project. A program is designed to support future events and long term outcomes, i.e. Total Rewards, Talent Management, etc. A project on the other hand has a defined end date and supports short term outcomes, i.e. Implementation, Merit Cycle, etc. To manage a program effectively it requires an investment, i.e. budget, resources, capabilities, sills, time, etc. There are several viable change models that are available for you to leverage.
3. Continuously Reinforcement the Value of the Change. Lastly, Change Management is never complete. Change Management is like Star Wars, there is never an ending and there is always a sequel :). All joking aside, Change is ongoing, fluid, alive and it requires constant feeding and reinforcement to live. In many instances it is like raising children. For a child to act a certain way, it requires you as a parent to have thorough communication, constant, engagement, specific training, and a lot of reinforcement.
@brettaddis_SAP http://bit.ly/2jFQqpE #SAP #SAPCloud #AI
SAP HANA, express edition – revision 21 is available.
SAP HANA, express edition has been updated to the latest HANA revision. It’s not really typical to “announce” a revision update, but, there are a few changes worth noting.
There has been a minor update to the Download manager – so, head back to the registration page, register again, and download the updated Download manager. Keep this handy – previously, when new versions of SAP HANA, express editions included new options, it has been necessary to register and download again. The new version has been modified to build up the file list at runtime – so, no more frequent visits to that registration page!
Additionally, the “server + apps” Virtual Machine option has been modified, and more components are now available as optional installation options.
The benefit to this is that the VM consumes less memory on first startup, and therefore starts up quicker, and is easier to run in a resource constrained environment. The downside is that there is slightly more effort required to install components. In Revision 21, the WebIDE for SAP HANA is an optional component, and needs to be installed – the Getting Started guide has been updated with to reflect this.
The sizing guide for SAP HANA, express edition can be found here. Be sure to review this – it’s a great resource!
So, head on to the registration page, update your download manager, and get your updated version of SAP HANA, express edition! http://bit.ly/2jH43Vk #SAP #SAPCloud #AI
