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: 

BAPI_OBJCL_CHANGE to change characteristic

Former Member
0 Kudos
261

Hello All,

I am writing a program to collect materials for a specified criteria and for those materials change the characteristic values for a class. I would like to change the characteristic for the class using the following code. but this is not setting the characteristic BATCH_DELETION_INDICATOR.

On the contrary when you check the box Batch Deletion Indicator in the BasicData1 tab. Characteristic is automatically getting changed to YES. My requirement is not to check Batch deletion indicator in BasicData1 tab(MCHA-LVORM = X) rather directly change the characteristic value.

Any suggestions on this one please...

it_werks-werks = p_werks.

APPEND it_werks.

CALL FUNCTION 'VB_BATCH_DEFINITION'

IMPORTING

kzdch = g_kzdch

klart = g_klart

obtab = g_obtab

TABLES

werke = it_werks.

  • To get the object key.

wa_objecttab-key_field = 'MATNR'.

wa_objecttab-value_int = it_mchb-matnr.

APPEND wa_objecttab TO i_objecttab.

wa_objecttab-key_field = 'CHARG'.

wa_objecttab-value_int = it_mchb-charg.

APPEND wa_objecttab TO i_objecttab.

CALL FUNCTION 'BAPI_OBJCL_CONCATENATEKEY'

EXPORTING

objecttable = g_obtab

IMPORTING

objectkey_conc = v_object

TABLES

objectkeytable = i_objecttab

return = i_bapiret2.

  • Read Characteristics details

******v_object is 0000000000084977041 where 1 is the batch, also tried with material, batch and plant ******combination.

CALL FUNCTION 'BAPI_OBJCL_GETDETAIL'

EXPORTING

objectkey = v_object " 0000000000084977041

objecttable = g_obtab " MCH1

classnum = g_class " FG_BATCH_CLASS

classtype = g_klart " 023

  • KEYDATE = SY-DATUM

  • unvaluated_chars = 'X'

unvaluated_chars = ''

  • LANGUAGE = SY-LANGU

  • IMPORTING

  • STATUS =

  • STANDARDCLASS =

TABLES

allocvaluesnum = i_charnum

allocvalueschar = i_charchar

allocvaluescurr = i_charcurr

return = i_bapiret2

READ TABLE i_charchar INTO wa_charchar WITH KEY

charact = 'BATCH_DELETION_INDICATOR'.

IF sy-subrc EQ 0.

  • wa_charchar-value_char = 'X'.

wa_charchar-value_char = 'Yes'.

MODIFY i_charchar FROM wa_charchar INDEX sy-tabix.

ENDIF.

DELETE i_charnum WHERE value_from IS initial..

REFRESH i_charcurr.

REFRESH i_bapiret2.

  • Change batch characteristics

CALL FUNCTION 'BAPI_OBJCL_CHANGE'

EXPORTING

objectkey = v_object

objecttable = g_obtab

classnum = g_class

classtype = g_klart

  • STATUS = '1'

  • STANDARDCLASS =

  • CHANGENUMBER =

  • KEYDATE = SY-DATUM

  • NO_DEFAULT_VALUES = ' '

  • IMPORTING

  • CLASSIF_STATUS =

TABLES

allocvaluesnumnew = i_charnum

allocvaluescharnew = i_charchar

allocvaluescurrnew = i_charcurr

return = i_bapiret2

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'

EXCEPTIONS

OTHERS = 0.

1 REPLY 1

Former Member
0 Kudos
65

Any suggestions pls..