Batch Classification Document
Batch Classification Document
Batch Classification Document
===========================
FUNCTION zmaterial_classfication.
*"---------------------------------------------------------------------
-
*"*"Local Interface:
*" TABLES
*" T_INPUT STRUCTURE ZMM_CHAR1
*" T1_DISPLAY STRUCTURE ZMM_CHAR
*" T1_UPDATE STRUCTURE ZMM_CHAR2
*" T1_CRE_UPDATE STRUCTURE ZMM_CHAR2
*"---------------------------------------------------------------------
-
==========================
Table Parameters
================
Structure ZMM_CHAR1
======================
ZMM_CHAR
==========
ZMM_CHAR2
==============
===================================
*----------------------------------------------------------------------
*
***INCLUDE LZMATERIAL_CLASSFICATIONF01.
*----------------------------------------------------------------------
*
*&---------------------------------------------------------------------
*
*& Form DISPLAY
*&---------------------------------------------------------------------
*
* text
*----------------------------------------------------------------------
*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------
*
FORM display .
CLEAR: lv_objecttable,w_objectkeytable,lv_objectkey_conc.
REFRESH:t_objectkeytable.
* IF w_mat1-matnr IS NOT INITIAL AND w_mat1-werks IS INITIAL.
lv_objecttable = 'MCH1'.
w_objectkeytable-key_field = 'MATNR'.
w_objectkeytable-value_int = w_mat1-matnr.
APPEND w_objectkeytable TO t_objectkeytable.
CLEAR:w_objectkeytable.
w_objectkeytable-key_field = 'CHARG'.
w_objectkeytable-value_int = w_mat1-charg.
APPEND w_objectkeytable TO t_objectkeytable.
CLEAR:w_objectkeytable.
* ELSE.
* lv_objecttable = 'MCHA'.
* w_objectkeytable-key_field = 'MATNR'.
* w_objectkeytable-value_int = w_mat1-matnr.
* APPEND w_objectkeytable TO t_objectkeytable.
* CLEAR:w_objectkeytable.
* w_objectkeytable-key_field = 'WERKS'.
* w_objectkeytable-value_int = w_mat1-werks.
* APPEND w_objectkeytable TO t_objectkeytable.
* CLEAR:w_objectkeytable.
* w_objectkeytable-key_field = 'CHARG'.
* w_objectkeytable-value_int = w_mat1-charg.
* APPEND w_objectkeytable TO t_objectkeytable.
* CLEAR:w_objectkeytable.
* ENDIF.
REFRESH:t_objectkeytable ,
t_return .
IF w_mat1-matnr IS NOT INITIAL AND w_mat1-werks IS NOT INITIAL.
lv_material = w_mat1-matnr.
lv_plant = w_mat1-werks .
CALL FUNCTION 'BAPI_BATCH_CREATE'
EXPORTING
material = lv_material
plant = lv_plant
IMPORTING
batch = lv_batch
TABLES
return = t_return.
IF t_return IS NOT INITIAL.
READ TABLE t_return INTO w_return WITH KEY type = 'E'.
IF sy-subrc EQ 0.
EXIT.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDIF.
ENDIF.
IF lv_batch IS NOT INITIAL.
w_create-msg = lv_batch.
CONCATENATE text-101 lv_batch text-102 lv_material text-103
lv_plant INTO w_create-msg SEPARATED BY space.
APPEND w_create TO t_create.
CLEAR:w_create.
ENDIF.
ELSE.
lv_material = w_mat1-matnr.
CALL FUNCTION 'BAPI_BATCH_CREATE'
EXPORTING
material = lv_material
IMPORTING
batch = lv_batch
TABLES
return = t_return.
IF t_return IS NOT INITIAL.
READ TABLE t_return INTO w_return WITH KEY type = 'E'.
IF sy-subrc EQ 0.
EXIT.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDIF.
ENDIF.
IF lv_batch IS NOT INITIAL.
w_create-msg = lv_batch.
CONCATENATE text-101 lv_batch text-102 lv_material INTO w_create-
msg SEPARATED BY space.
APPEND w_create TO t_create.
CLEAR:w_create.
ENDIF.
ENDIF.