‎2007 Sep 21 2:36 PM
I am trying to update the country of origin in the classification tab of batches. It gets updated in change mode (MSC2N) but when I am in Batch Display mode (MSC3N) it is not updated. The code I am using is as follows.
t_batchattributes-countryori = wa_mcha-herkl.
t_batchattributesx-countryori = 'X'.
CALL FUNCTION 'BAPI_BATCH_CHANGE'
EXPORTING
material = wa_mcha-matnr
batch = wa_mcha-charg
plant = wa_mcha-werks
batchattributes = t_batchattributes
batchattributesx = t_batchattributesx
TABLES
return = i_return.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
IMPORTING
return = wa_return.
CALL FUNCTION 'VB_UPDATE_BATCH'.
‎2007 Sep 21 2:42 PM
‎2007 Sep 21 2:42 PM
‎2007 Sep 21 2:55 PM
How to use this BAPI. how to fill the tables. I am trying to update the 'COUNTRY OF ORIGIN' classification value.
* Assign the fields respecting blanks to object key
MOVE: wa_mcha-matnr TO gv_objek(18),
wa_mcha-werks TO gv_objek+18(4),
wa_mcha-charg TO gv_objek+22(10).
CALL FUNCTION 'BAPI_OBJCL_CHANGE'
EXPORTING
objectkey = gv_objek
objecttable = 'MCHA'
classnum = 'BATCHMGT'
classtype = '022'
TABLES
allocvaluesnumnew =
allocvaluescharnew =
allocvaluescurrnew =
return =
.Message was edited by:
Megan Flores
‎2007 Sep 21 3:25 PM
This is not working. Can someone help me please. thank you.
wa_allocvaluescharnew-charact = c_txt_origin.
wa_allocvaluescharnew-value_char = wa_mcha-herkl.
APPEND wa_allocvaluescharnew TO t_allocvaluescharnew.
CALL FUNCTION 'BAPI_OBJCL_CHANGE'
EXPORTING
objectkey = gv_objek
objecttable = 'MCHA'
classnum = 'BATCHMGT'
classtype = '022'
TABLES
allocvaluesnumnew = t_allocvaluesnumnew
allocvaluescharnew = t_allocvaluescharnew
allocvaluescurrnew = t_allocvaluescurrnew
return = i_return.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
IMPORTING
return = wa_return.
‎2007 Sep 21 3:29 PM
Look at <a href="https://service.sap.com/sap/support/notes/619913">Note 619913 - FAQ: Basic functions of batch management</a>
<i><b>Change classification data of a batch</b></i>
<i>Up to and including Release 4.6C, BAPI BAPI_OBJCL_CHANGE needs to be used.
In later releases, BAPI BAPI_BATCH_SAVE_REPLICA may also be used for that purpose.</i>
Regards
‎2007 Sep 21 3:34 PM
When I execute the BAPI using SE37, it gives out error 'COUNTRY OF ORIGIN' characteristic not found. But in MSC3N I can see the char.. .what could I be doing wrong?
‎2007 Sep 23 8:29 PM
I used this BAPI to update the classification data.
* Assign the fields respecting blanks to object key
MOVE: wa_mcha-matnr TO gv_objek(18),
wa_mcha-werks TO gv_objek+18(4),
wa_mcha-charg TO gv_objek+22(10).
* Assign the country of origin value to the characteristic
MOVE c_atnam TO wa_allocvaluescharnew-charact .
MOVE wa_mcha-herkl TO wa_allocvaluescharnew-value_char.
APPEND wa_allocvaluescharnew TO t_allocvaluescharnew.
* Call BAPI_OBJCL_CHANGE to update the country of origin value
CALL FUNCTION 'BAPI_OBJCL_CHANGE'
EXPORTING
objectkey = gv_objek
objecttable = c_mchatbl
classnum = c_batchmgt
classtype = c_batches
TABLES
allocvaluesnumnew = t_allocvaluesnumnew
allocvaluescharnew = t_allocvaluescharnew
allocvaluescurrnew = t_allocvaluescurrnew
return = t_return.
‎2008 Dec 15 11:37 AM
Hi, You can update classification for a batch using the following code.
But first, you'll need to find out that the batch management is cross-plant or plant dependant.
If it is cross plant then plant(WERKS) is not part of the key to BAPI_OBJCL_CONCATENATEKEY.
CLEAR: objectkey, objectkeytable, objectkeytable[],
allocvaluesnumnew, allocvaluesnumnew[],
return.
objectkeytable-key_field = 'MATNR'.
objectkeytable-value_int = matnr.
APPEND objectkeytable.
objectkeytable-key_field = 'CHARG'.
objectkeytable-value_int = charg.
APPEND objectkeytable.
* Only if Batch management is Plant dependant
objectkeytable-key_field = 'WERKS'.
objectkeytable-value_int = werks.
APPEND objectkeytable.
CALL FUNCTION 'BAPI_OBJCL_CONCATENATEKEY'
EXPORTING
objecttable = objecttable
IMPORTING
objectkey_conc = objectkey
TABLES
objectkeytable = objectkeytable
return = return.
allocvaluesnumnew-charact = "characteristic name goes here".
allocvaluesnumnew-value_from ="characteristic value goes here".
APPEND allocvaluesnumnew.
allocvaluesnumnew-charact = "characteristic name goes here".
allocvaluesnumnew-value_from = "characteristic value goes here".
APPEND allocvaluesnumnew.
CALL FUNCTION 'BAPI_OBJCL_CHANGE'
EXPORTING
objectkey = objectkey
objecttable = objecttable
classnum = classnum
classtype = classtype
* STATUS = '1'
* STANDARDCLASS = STANDARDCLASS
* CHANGENUMBER = CHANGENUMBER
* KEYDATE = SY-DATUM
* NO_DEFAULT_VALUES = ' '
* IMPORTING
* CLASSIF_STATUS = CLASSIF_STATUS
TABLES
allocvaluesnumnew = allocvaluesnumnew
allocvaluescharnew = allocvaluescharnew
allocvaluescurrnew = allocvaluescurrnew
return = return
.
* Do not forget to commit, otherwise changes would not take effect.
commit work.
Regards,
Hashir Ahmed