07-04-2012 12:26 PM
I made an implementation in IF_EX_MB_MIGO_BADI and customer requirement is that when entering transaction MIGO, the system creates a new Batch.
I made my changes in Method: LINE_MODIFY (If field charg = empty, create new bacth) and in there i call the FM: 'BAPI_BATCH_CREATE'.
So far, so good, the Batch is beeing created, and the screenfields on MIGO are filled.
But now, for certain Batches the Classification Data of the Batch also needs to be filled.
I know it can't be done inside the 'BAPI_BATCH_CREATE' so, directly after the Create, i call the FM: 'BAPI_OBJCL_CHANGE'
But, I get an error (M3628) stating that "Batch XXX is already locked by User YYY"
This only happens when creating and directly changing batches.
Batches that do not need an update of the Characteristics go fine.
what did i try:
- do-loop over ENQUE_READ2 / ENQUEUE_READ and than check if there is no lock anymore => No lock, proceed with change
- DEQUEUE_EMMCHA
- DEQUEUE_ALL
- Commit work and wait after the Batch Creation
Nothing works.
I checked the METHOD batch_data_update in Include LMIGOKB1and at a certain point there is a FM: CALL FUNCTION 'VB_BATCH_READ_BUFFER_DB'
One of the exporting parameters to this FM = lock_batch
And indeed, the FM return with the subrc = 4 ( lock_on_batch) and there I get my message.
If I clear the parameter "lock_batch" just before entering the FM, all works fine!.
Questions:
- Is there another way of creating a batch and DIRECTLY create the Classification data? (instead of first creating batch and afterwards change it)
- Is there a way to "overwrite" this lock_batch parameter?, because I don't want it locked, I want to change it
- Any other suggestions?
07-04-2012 1:48 PM
Did you take a look at BAPI_BATCH_SAVE_REPLICA , i believe this can create Batch and classification at a single shot
07-04-2012 1:48 PM
Did you take a look at BAPI_BATCH_SAVE_REPLICA , i believe this can create Batch and classification at a single shot
07-05-2012 7:46 AM
OK, I took a look at BAPI_BATCH_SAVE_REPLICA, but the information about this FM is bad.
I managed to create the Batch, alo filled data on tab "Basic Data 1", Created Classification and Characteristics, but I can't find any examples on how to fill the values of the Characteristics.
What am I diong worng, or what am I missing?
Below 2 screenshots of the newly created Batch.
1st => 4 Fields on tab: "Basic Data 1" are filled: Date of Manufacture / Shelf Life Exp. Dat / Vendor / Vendor Batch
2nd => Tab "Classification": Class is filled with "IMPORTED_FP" / Class Type is filled with "022" / and two Characteristics are created: Country of origin & Customs duty number.
But as you can see, they don't have values.
How to get the values on the Characteristic?
This is my sample code:
DATA: ls_batchattributes TYPE bapibatchatt,
ls_batchattributesx TYPE bapibatchattx,
ls_batchstatus TYPE bapibatchstatus,
ls_batchstatusx TYPE bapibatchstatusx,
ls_batchcontrolfields TYPE bapibatchctrl,
ls_batchstoragelocation TYPE lgort_d,
ls_internalnumbercom TYPE bapibncom,
ls_extension1 TYPE bapibncomz,
ls_material_evg TYPE bapimgvmatnr,
lt_return TYPE bapiret2_tab,
lt_classallocations TYPE bapi3060_allocations,
lt_classvaluationschar TYPE bapi3060_valuations_char,
lt_classvaluationscurr TYPE bapi3060_valuations_curr,
lt_classvaluationsnum TYPE bapi3060_valuations_num,
ls_classallocations TYPE bapi3060_allocation,
ls_classvaluationschar TYPE bapi3060_valuation_char.
* Fill BatchControlFields
ls_batchcontrolfields-class_num = 'IMPORTED_FP'.
ls_batchcontrolfields-doclassify = 'X'.
* Fill BatchAttributes
ls_batchattributes-vendor_no = 'RoPo'.
ls_batchattributes-vendrbatch = '1234'.
ls_batchattributes-prod_date = '19680624'.
ls_batchattributes-expirydate = '20120101'.
ls_batchattributesx-vendor_no = 'X'.
ls_batchattributesx-vendrbatch = 'X'.
ls_batchattributesx-prod_date = 'X'.
ls_batchattributesx-expirydate = 'X'.
* Fill ClassAllocations
ls_classallocations-class_type = '022'.
ls_classallocations-objectkey = '000000000000000798RUBF0808080906'.
ls_classallocations-objecttable = 'MCHA'.
ls_classallocations-classnum = 'IMPORTED_FP'.
APPEND ls_classallocations TO lt_classallocations.
* Fill ClassValuationsChar
ls_classvaluationschar-class_type = '022'.
ls_classvaluationschar-objectkey = '000000000000000798RUBF0808080906'.
ls_classvaluationschar-objecttable = 'MCHA'.
ls_classvaluationschar-charact = 'COUNTRY_OF_ORIGIN'.
ls_classvaluationschar-value_char = 'UK'.
ls_classvaluationschar-inherited = ' '.
ls_classvaluationschar-instance = '000'.
ls_classvaluationschar-value_neutral = 'UK'.
ls_classvaluationschar-charact_descr = 'Country of origin'.
APPEND ls_classvaluationschar TO lt_classvaluationschar.
ls_classvaluationschar-class_type = '022'.
ls_classvaluationschar-objectkey = '000000000000000798RUBF0808080906'.
ls_classvaluationschar-objecttable = 'MCHA'.
ls_classvaluationschar-charact = 'CUSTOMS_DUTY_NUMBER'.
ls_classvaluationschar-value_char = '10009194/190908/0043357'.
ls_classvaluationschar-inherited = ' '.
ls_classvaluationschar-instance = '000'.
ls_classvaluationschar-value_neutral = '10009194/190908/0043357'.
ls_classvaluationschar-charact_descr = 'Customs duty number'.
APPEND ls_classvaluationschar TO lt_classvaluationschar.
BREAK-POINT.
CALL FUNCTION 'BAPI_BATCH_SAVE_REPLICA'
EXPORTING
material = '000000000000000798'
batch = '0808080906'
plant = 'RUBF'
batchattributes = ls_batchattributes
batchattributesx = ls_batchattributesx
batchstatus = ls_batchstatus
batchstatusx = ls_batchstatusx
batchcontrolfields = ls_batchcontrolfields
batchstoragelocation = ls_batchstoragelocation
internalnumbercom = ls_internalnumbercom
extension1 = ls_extension1
material_evg = ls_material_evg
TABLES
return = lt_return
classallocations = lt_classallocations
classvaluationschar = lt_classvaluationschar
classvaluationscurr = lt_classvaluationscurr
classvaluationsnum = lt_classvaluationsnum.
COMMIT WORK.
07-05-2012 8:23 AM
Rob
This Internally calls to the BAPI "BAPI_OBJCL_CHANGE" in FM CLBPAX_WRITE_CLASSIFICATIONS ,can you set a break point here and check ?
07-05-2012 9:22 AM
Yahooooo! that was the trick! thank you very much.
In debugging i saw in FM: CLBPAX_WRITE_CLASSIFICATIONS that the allocations Table was not filled correctly
* Fill ClassAllocations
ls_classallocations-class_type = '022' had to be ls_classallocations-classtype = '022'
There are two, almost the same fields in this structure, and I just took the wong one...
So it had to be the fields without the underscore.
Works like a charm!
Thx again!
07-05-2012 9:26 AM
hi what u can do is crate an Update type FM and use 'BAPI_OBJCL_CHANGE' in that FM.
now call this FM in update mode.
Hope this helps.
Cheers!!