2023 May 03 5:50 PM
Hi Expert,
I have one requirement that in TCODE MSC3N after entering material and batch details in classification tab DRF number is coming and that DRF number I need to print in a program.
How I can achieve this requirement can anyone please help me in details?
2023 May 03 6:48 PM
You can achieve this requirement using the BAPI "BAPI_CLASSIFICATION_CREATE" which is used to create classification data for a specific object.
1. Firstly, you need to call the BAPI "BAPI_MATERIAL_EXISTENCECHECK" to check whether the material and batch details exist or not.
2. If the material and batch details exist, then you need to call the BAPI "BAPI_CLASSIFICATION_CREATE" to create classification data for the object.
3. In the input parameters of the BAPI "BAPI_CLASSIFICATION_CREATE", you need to pass the material and batch details along with the classification data.
4. After the successful creation of classification data, the BAPI will return the DRF number which you can store in a variable and print it as per your requirement
Sample Code:
DATA: ls_mat_exist TYPE BAPI_MBEW_EXISTENCE_CHECK,
lt_classif_data TYPE STANDARD TABLE OF BAPICLASSEX,
ls_classif_data TYPE BAPICLASSEX,
lt_return TYPE STANDARD TABLE OF BAPIRET2,
ls_return TYPE BAPIRET2.
* Check material and batch existence
CALL FUNCTION 'BAPI_MATERIAL_EXISTENCECHECK'
EXPORTING
material = 'MATERIAL_NUMBER'
plant = 'PLANT'
batch = 'BATCH_NUMBER'
IMPORTING
return = ls_mat_exist.
IF ls_mat_exist-existing = 'X'.
* Create classification data
ls_classif_data-objtype = 'MATERIAL'.
ls_classif_data-objkey = 'MATERIAL_NUMBER'.
ls_classif_data-objvers = '00'.
ls_classif_data-class = 'CLASS_TYPE'.
ls_classif_data-classtype = '001'.
ls_classif_data-status = '10'.
ls_classif_data-tabnumber = '000'.
ls_classif_data-changenum = '00000000000000000000'.
APPEND ls_classif_data TO lt_classif_data.
CALL FUNCTION 'BAPI_CLASSIFICATION_CREATE'
EXPORTING
classnum = 'CLASS_TYPE'
classtype = '001'
TABLES
objectclassex = lt_classif_data
return = lt_return.
IF sy-subrc = 0.
READ TABLE lt_return INTO ls_return WITH KEY type = 'S'.
IF sy-subrc = 0.
WRITE: 'DRF number is', ls_return-message.
ENDIF.
ENDIF.
ENDIF.
Please check, if this is what you are looking for.
Regards,
2023 May 04 11:16 AM
Are you looking for a BAdI executed in MSC1N/MSC2N during creation change (such as BAdI BATCH_MASTER)
Or just trying to read classification data from another process with a BAPI such as BAPI_OBJCL_GETDETAIL
2023 May 04 12:11 PM
2023 May 04 1:10 PM
So use BAPI_OBJCL_GETDETAIL
2023 May 04 12:20 PM
SELECT SINGLE matnr charg FROM mchb INTO CORRESPONDING FIELDS OF ls_mchb WHERE matnr = p_matnr AND charg = p_charg.
IF sy-subrc IS INITIAL.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = p_matnr
IMPORTING
output = lf_matnr
.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = p_charg
IMPORTING
output = lf_charg
.
ENDIF.
CONCATENATE lf_matnr lf_charg INTO lf_objkey.
CALL FUNCTION 'BAPI_OBJCL_CHANGE'
EXPORTING
objectkey = lf_objkey
objecttable = 'MCHB'
classnum = 'BATCH_FP_PHARMA'
classtype = '023'
status = '1'
* STANDARDCLASS =
* CHANGENUMBER =
keydate = sy-datum
* NO_DEFAULT_VALUES = ' '
* KEEP_SAME_DEFAULTS = ' '
* OBJECTKEY_LONG =
* IMPORTING
* CLASSIF_STATUS =
TABLES
allocvaluesnumnew = lt_allocvaluesnumnew
allocvaluescharnew = lt_allocvaluescharnew
allocvaluescurrnew = lt_allocvaluescurrnew
return = lt_return
.
2023 May 04 12:22 PM
This is my code and lt_return I am getting the error message class type is not defined for object