Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Batch Classification in MSC3N

0 Kudos

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?

6 REPLIES 6

Harish_Vatsa
Active Contributor

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,

raymond_giuseppi
Active Contributor

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

0 Kudos

I just want to get this DRF number in my program logic.

0 Kudos

So use BAPI_OBJCL_GETDETAIL

  • objectkey - concatenate (internal format) matnr and charg
  • obnjecttable - should be constant MCHA
  • classnum & classtype - check your Customizing (or browse table KLAH)

0 Kudos
  • 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
    
              .

0 Kudos

This is my code and lt_return I am getting the error message class type is not defined for object