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

Function module for variant config

Former Member
0 Likes
6,830

Hello,

Is there any BAPI or function module to change variant configuration values.

Thanks,

KB

9 REPLIES 9
Read only

Former Member
0 Likes
2,753

KB,

Look at the following Link.

Vinodh Balakrishnan

Read only

0 Likes
2,753

Hello Vinod,

Thanks for the reply, it was very useful.

I am able to successfully change variant configuration values in a material using function module CUCB_INITIALIZER, CUCB_SET_CONFIGURATION and CUCB_CONFIGURATION_TO_DB., but when I try to create it in a material, it gives a sy-subrc = 0 but in the material master, it does not show. MARA-SATNR is also blank. When i try to create it manually from MM02 or again through the program, it gives me an error. Should I use additional function modules to modify material to show that it now has variant config values?

Thanks in advance,

KB

Read only

0 Likes
2,753

Hi Bala,

I am wondering if you have been able to fix this. I am having the same issue. I can neither see the SATNR field populated nor fill configuration values. Please let me know how it worked.

Thanks

Aravind

Read only

0 Likes
2,753

Hi All,

You can use the FM 'BAPI_UI_GETDETAIL' to read the Characteristic Grouping detail in CU50.

You can use the FM 'BAPI_UI_SAVEM' or IDOC 'VCUI_SAVEM02' to create Characteristic Grouping tabs in CU50.

Hope this solves your query.

Regards,

Bhawit Kumar

Read only

Former Member
0 Likes
2,753

Hi kumar bala,

Look at the below link it may useful for you

[]

Read only

Former Member
0 Likes
2,753

Hi,

Using BAPI 'BAPI_OBJCL_CHANGE' you can change the characteristics values.

See the Function Module documentation for passing required input parameters.

Regards,

Rajesh

Read only

Former Member
0 Likes
2,753

Yes Friend there are function modules but unreleased ones. I hope u wont mind me pastng the code but plz go through the code it basically reads the configs and then updates values for some characteristics in config.

  • READ VALUES MAINTAINED FOR THE CHARACTERISTICS

CALL FUNCTION 'CUCB_GET_CONFIGURATION'

EXPORTING

instance = lv_instance

IMPORTING

ibase = lv_ibase

configuration = lt_configuration

eo_cbase_ref = lref_eo_cbase_ref

EXCEPTIONS

invalid_input = 1

invalid_instance = 2

instance_is_a_classification = 3

OTHERS = 4.

IF sy-subrc <> 0.

ENDIF.

IF sy-subrc EQ 0.

  • Copy the configuration into local internal tables.

LOOP AT lt_configuration INTO lw_lt_configuration.

lw_lt_values_tab-values[] = lw_lt_configuration-values[].

APPEND lw_lt_values_tab TO lt_values_tab.

ENDLOOP.

ENDIF.

  • Determine the Internal characteristic for the character name ATNAM from DB Table CABN

SELECT SINGLE atinn INTO lv_atinn FROM cabn WHERE atnam = lv_atnam.

IF sy-subrc EQ 0.

  • COPIES THE VALUE OF THE INSTANCE

CLEAR: lv_count.

  • Update CUOBJ or VBELN + POSNR to KC_CUOBJ / KC_ORDER in the local internal tables before

  • updating LT_CONFIGURATION[].

LOOP AT lt_values_tab INTO lw_lt_values_tab.

lt_values[] = lw_lt_values_tab-values[].

IF lv_count GT 0.

  • CLEAR lv_instance. "Instance to be copied only in header not in child nodes

EXIT. " Exit the loop as only for the first item the CUOBJ needs to be saved.

ENDIF.

LOOP AT lt_caseboth INTO lw_lt_caseboth.

  • Read the symbol id(CABN-ATINN) based on key ATNAM.

SELECT SINGLE atinn INTO lv_atinn FROM cabn WHERE atnam = lw_lt_caseboth-atnam.

IF sy-subrc EQ 0.

LOOP AT lt_values INTO lw_lt_values WHERE atinn EQ lv_atinn.

  • WHEN UPDATE KEY IS 'CU'

IF lw_lt_caseboth-mode EQ lc_cu.

lw_lt_values-atwrt = lv_instance. " Update KC_CUOBJ

ENDIF.

  • WHEN UPDATE KEY IS 'SO'

IF lw_lt_caseboth-mode EQ lc_so.

lw_lt_values-atwrt = lv_vbeln_posnr. " Update KC_ORDER

ENDIF.

  • Commit the changes from Work area to the Internal Table

MODIFY lt_values FROM lw_lt_values.

ENDLOOP.

ENDIF. "( when ATINN read correctly)

ENDLOOP.

  • Move the value of lt_values[] back to the lw_lt_values_tab[].

lw_lt_values_tab-values[] = lt_values[].

  • Now modify current row of lt_values_tab[] from the work area.

MODIFY lt_values_tab FROM lw_lt_values_tab.

ADD 1 TO lv_count.

ENDLOOP.

CLEAR lv_count.

ENDIF.

  • Make the changes in the table lt_configuration, too.

CLEAR lv_counter.

  • COPY THE MANIPULATED VALUES FROM THE LOCAL INTERNAL TABLE BACK TO LT_CONFIGURATION[]

  • SO THAT THE CHANGES ARE SAVED.

LOOP AT lt_configuration INTO lw_lt_configuration.

ADD 1 TO lv_counter.

READ TABLE lt_values_tab INTO lw_lt_values_tab INDEX lv_counter.

IF sy-subrc EQ 0.

lw_lt_configuration-values[] = lw_lt_values_tab-values[].

MODIFY lt_configuration FROM lw_lt_configuration.

ENDIF.

ENDLOOP.

CLEAR lv_counter.

  • Once the values have been changed in the temp. variable make thechanges in database.

CALL FUNCTION 'CUCB_CHANGE_CONFIGURATION'

EXPORTING

root_instance = lv_instance

CHANGING

inserted_or_changed_instances = lt_configuration[]

EXCEPTIONS

invalid_input = 1

invalid_instance = 2

instance_is_a_classification = 3

OTHERS = 4.

IF sy-subrc <> 0.

ENDIF.

Read only

Former Member
0 Likes
2,753

so basicall u see theres an itab lt_configuration which has a field VALUES which is also a table and so once u get the characteristics values you may modify them and then make teh changes using CALL FUNCTION 'CUCB_CHANGE_CONFIGURATION'

Read only

0 Likes
2,753

Hi Prasenjit,

I got the same the requirement , I found your code very useful . I followed the same and i could retrieve and change the values in the lt_configuration[] . But wen i am using 'CUCB_CHANGE_CONFIGURATION' , the changes are not reflecting in Material VC .

'CUCB_CHANGE_CONFIGURATION' is returning Sy-subrc = 0  . but no changes in material VC .

Kindly help me  on this. Waiting for your reply

Thnx in advance .