2007 Jan 27 1:31 AM
I want to write a batch program to receive a large amount of stock into the inventory. But for those batch managed materials, with a batch class assigned to it, I find no way to input the batch characteristics during goods receipt.
Does anyone know any FMs can help? Thanks!
I want to write a batch program to receive a large amount of stock into the inventory. But for those batch managed materials, with a batch class assigned to it, I find no way to input the batch characteristics during goods receipt.
Does anyone know any FMs can help? Thanks!
2007 Jan 27 1:50 AM
Hi
U can try to use the BAPI BAPI_BATCH_CREATE or fm VB_CREATE_BATCH to create the batch before calling the BAPI BAPI_GOODSMVT_CREATE for goods movement.
Max
2007 Jan 27 2:45 AM
No, I can't just call BAP_BATCH_CREATE and then BAPI_GOODSMVT_CREATE. I got an error from the BAPI_RETURN "The characteristic values for the batch are incomplete".
In my case, I have assigned a customer batch class to the materials, in which there are some tailor made batch characteristics needed to input. I found no way to assign those batch characteristics in either BAP_BATCH_CREATE or BAPI_GOODSMVT_CREATE.
2007 Feb 22 5:15 PM
Hi Seed,
You can implement one badi 'MB_MIGO_BADI' and during post u can have the following code for updating the batch charastritics....
FUNCTION ZPO_BADI_UPDATE_YIELD.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(MAT) TYPE MATNR
*" REFERENCE(BATCH) TYPE CHARG_D
*" REFERENCE(ROUTE) TYPE ZATWRT
*"----------------------------------------------------------------------
DATA:
cuobj TYPE cuobj_bm,
i_objtable TYPE STANDARD TABLE OF ty_objtable WITH HEADER LINE,
i_allocvaluesnum TYPE STANDARD TABLE OF ty_allocnum WITH HEADER LINE,
i_allocvalueschar TYPE STANDARD TABLE OF ty_allocchar WITH HEADER LINE,
i_allocvaluescurr TYPE STANDARD TABLE OF ty_alloccurr WITH HEADER LINE,
wa_route TYPE atwrt,
atinn type atinn,
return TYPE TABLE OF bapiret2 WITH HEADER LINE.
SELECT cuobj_bm FROM mch1
INTO cuobj
WHERE matnr = mat AND
charg = batch.
ENDSELECT.
*
CALL FUNCTION 'BAPI_OBJCL_GET_OBJECT_OF_KEY'
EXPORTING
clobjectkeyin = cuobj
IMPORTING
objectname = i_objtable-object
objecttable = i_objtable-objecttable
classtype = i_objtable-classtype
TABLES
return = return.
i_objtable-classnum = 'Z_GSI_CLASS'.
CALL FUNCTION 'BAPI_OBJCL_GETDETAIL'
EXPORTING
objectkey = i_objtable-object
objecttable = i_objtable-objecttable
classnum = i_objtable-classnum
classtype = i_objtable-classtype
unvaluated_chars = 'X'
TABLES
allocvaluesnum = i_allocvaluesnum
allocvalueschar = i_allocvalueschar
allocvaluescurr = i_allocvaluescurr
return = return.
* READ TABLE i_allocvalueschar WITH KEY charact = 'ZACTUAL_DIE' BINARY SEARCH.
* IF sy-subrc EQ 0.
* i_allocvalueschar-value_char = value.
* i_allocvalueschar-value_neutral = value.
*
* MODIFY i_allocvalueschar INDEX sy-tabix .
* ELSE.
* i_allocvalueschar-charact = 'ZACTUAL_DIE'.
* i_allocvalueschar-value_char = value.
* APPEND i_allocvalueschar.
* ENDIF.
*
* READ TABLE i_allocvalueschar WITH KEY charact = 'ZDATE_CODE' BINARY SEARCH.
* IF sy-subrc EQ 0.
* i_allocvalueschar-value_char = datecode.
* i_allocvalueschar-value_neutral = datecode.
*
* MODIFY i_allocvalueschar INDEX sy-tabix .
* ELSE.
* i_allocvalueschar-charact = 'ZDATE_CODE'.
* i_allocvalueschar-value_char = datecode.
* i_allocvalueschar-CHARACT_DESCR = 'Date Code'.
* APPEND i_allocvalueschar.
* ENDIF.
*
loop at route into wa_route.
READ TABLE i_allocvalueschar WITH KEY charact = 'ZROUTING_RULE' BINARY SEARCH.
IF sy-subrc EQ 0.
i_allocvalueschar-value_char = wa_route.
i_allocvalueschar-value_neutral = wa_route.
append i_allocvalueschar .
ELSE.
i_allocvalueschar-charact = 'ZROUTING_RULE'.
i_allocvalueschar-value_char = wa_route.
i_allocvalueschar-CHARACT_DESCR = 'ROUTING_RULE'.
APPEND i_allocvalueschar.
ENDIF.
endloop.
REFRESH return.
CALL FUNCTION 'BAPI_OBJCL_CHANGE'
EXPORTING
objectkey = i_objtable-object
objecttable = i_objtable-objecttable
classnum = i_objtable-classnum
classtype = i_objtable-classtype
TABLES
allocvaluesnumnew = i_allocvaluesnum
allocvaluescharnew = i_allocvalueschar
allocvaluescurrnew = i_allocvaluescurr
return = return.
READ TABLE return WITH KEY type = 'E' BINARY SEARCH.
IF sy-subrc EQ 0.
*PERFORM add_message TABLES i_idoc_status.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDIF.
ENDFUNCTION.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |