Posted: Wed Sep 05, 2007 6:56 pm Post subject: Changing Configuration Values of a Configurable Material
Author: Sharath Kumar Radhakrishna
Description
Changing Configuration Values of a Configurable Material in a SO, PO or a Service Order through an ABAP Program.
When doing a bulk update of a PO or an SO through ABAP there could be a requirement of updating new values to the configuration of a material, In these situations you can make use of this article to find out how to update the configuration values by ABAP program. (Since BDC recording supports adding new configuration values not modifying the existing ones).
Where is this Useful?
Configuration Data is maintained at the material master data and when this material becomes an item in a sales order or a purchase order, the configuration data is picked from the Material Master. But there can be situations where this configuration has to be modified, if you have to modify the configuration data of a configurable material through ABAP program you can fallow simple steps given in this article.
Overall Processing Logic
Let's take an example of a Sales order item, if the item material is configurable (MARA-KZKFG = 'X') then you can fetch the Configuration number (CUOBJ) which is a unique number within the system. This number is the key field to identify the configuration values stored in the database table; hence this field is available in VBAP, EKPO and AFKO. We have to pass this number to method GET_CURRENT_CBASE_BY_INSTANCE of class CL_CBASE in order to create an instance of this configuration data. Using this instance you can call method GET_CONFIGURATION to get the current configured values for that item and then you can change this values as you want and call method SET_CONFIGURATION to update it with modified values. For detailed processing logic you can refer the program code given below.
Program Code
Program below can be copied and used for updating material configuration. It will work for Sales order, Purchase order and service orders. In the selection screen you have to pass the Characteristic that you want to update and the new value of the characteristic. Class CL_BASE has been used to update the configuration values.
PARAMETERS : p_vbeln TYPE vbak-vbeln,
p_posnr TYPE vbap-posnr,
p_ebeln TYPE ekko-ebeln,
p_ebelp TYPE ekpo-ebelp,
p_aufnr TYPE afko-aufnr.
PARAMETERS : p_charac TYPE cabn-atinn,
p_upd TYPE v_ibin_syval-atwrt.
DATA : w_instance TYPE cuib_cuobj.
DATA: add_chr TYPE ibco2_value_tab,
l1_ind LIKE sy-tabix.
DATA: old_l TYPE i,
new_l TYPE i.
DATA: wa_chr LIKE ibvalue0,
wa_chr1 LIKE ibvalue0,
wa_con TYPE ibco2_instance_rec2.
DATA: l_obj TYPE REF TO cl_cbase.
CLEAR l_obj.
DATA: it_instances TYPE cuib_cuobj_tab.
DATA: l_head TYPE ibco2_ibase_rec,
l_config TYPE ibco2_instance_tab2.
DATA: wa_instances LIKE LINE OF it_instances.
CLEAR wa_instances.
APPEND wa_instances TO it_instances.
DATA: flg_invalid TYPE c.
CLEAR flg_invalid.
* Processing LOGIC.
IF p_vbeln IS NOT INITIAL.
SELECT SINGLE cuobj
INTO w_instance
FROM vbap
WHERE vbeln EQ p_vbeln
AND posnr EQ p_posnr.
ELSEIF p_ebeln IS NOT INITIAL.
SELECT SINGLE cuobj
INTO w_instance
FROM ekpo
WHERE ebeln EQ p_ebeln
AND ebelp EQ p_ebelp.
ELSEIF p_aufnr IS NOT INITIAL.
SELECT SINGLE cuobj
INTO w_instance
FROM afko
WHERE aufnr EQ p_aufnr.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.