Skip to Content
0
Jul 04, 2012 at 11:26 AM

MIGO Badi and creating / changing Batch

1096 Views

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?