Skip to Content
avatar image
Former Member

MM BAPI with MARA and Matnr Classification Data

Hello all,

I need a way to take a value in the material's classification and push it to a value in the material master. This should be called for create and updates. I first implemented BADI_MATERIAL_CHECK method CHECK_DATA. That works correctly for everything on the GUI from MM01, to MM02 to mass maintenance. This works because I look in the stack and get the classification data from (SAPLCLFM)ALLAUSP[] and then push it to the CMARA parameter in the BADI. The problem is that when you call the BAPI_MATERIAL_SAVEDATA from outside of SAP via and RFC the values that are in

(SAPLCLFM)ALLAUSP[] aren't there.

So any ideas? I looked at CACL_VALUE_CHANGE and the MODIFY_INPUT method but I can change only the classification data there.

If anyone has any suggestions along these lines it would be most helpful.

Thanks.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • avatar image
    Former Member
    Apr 05, 2013 at 10:42 PM

    Why don't you read the classifications for the material before calling BAPI_MATERIAL_SAVEDATA? Maybe I'm not understanding your requirement.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      In that case you will have to create the material first and then the classifications. Once you have created the classifications, you can read them and update the material. Use BAPI_OBJCL* (and optionally BAPI_CLAS*) to work with classifications.

  • avatar image
    Former Member
    Apr 06, 2013 at 02:49 AM

    Hi Ronnie

    i got a program that saves the classification data, maybe there is a function alike to reade these data.

    *&---------------------------------------------------------------------*

    *& Form FILL_CLASSIFICATION

    *&---------------------------------------------------------------------*

    * text

    *----------------------------------------------------------------------*

    * --> p1 text

    * <-- p2 text

    *----------------------------------------------------------------------*

    FORM fill_classification .

    *View Head Data

    *View Data In Previous Views

    *View Single Data

    DATA: ls_objectkeynew TYPE bapi1003_key-object,

    ls_objecttablenew TYPE bapi1003_key-objecttable,

    ls_classnumnew TYPE bapi1003_key-classnum,

    ls_classtypenew TYPE bapi1003_key-classtype,

    ls_status TYPE bapi1003_key-status,

    ls_standardclass TYPE bapi1003_key-stdclass,

    ls_changenumber TYPE bapi1003_key-changenumber,

    ls_keydate TYPE bapi1003_key-keydate,

    ls_no_default_values TYPE bapi1003_key-flag,

    ls_classif_status TYPE bapi1003_key-status,

    lt_allocvaluesnum TYPE TABLE OF bapi1003_alloc_values_num,

    lt_allocvalueschar TYPE TABLE OF bapi1003_alloc_values_char,

    lt_allocvaluescurr TYPE TABLE OF bapi1003_alloc_values_curr,

    lt_return TYPE TABLE OF bapiret2,

    ls_allocvaluesnum TYPE bapi1003_alloc_values_num,

    ls_allocvalueschar TYPE bapi1003_alloc_values_char,

    ls_allocvaluescurr TYPE bapi1003_alloc_values_curr,

    ls_return TYPE bapiret2.

    DATA: lt_klart TYPE TABLE OF klah-klart,

    ls_klart TYPE klah-klart,

    lt_class TYPE TABLE OF klah-class,

    ls_class TYPE klah-class,

    lt_atnam TYPE TABLE OF cabn-atnam,

    ls_atnam TYPE cabn-atnam,

    lt_atwrt TYPE TABLE OF cawn-atwrt,

    ls_atwrt TYPE cawn-atwrt,

    lt_cabnt TYPE TABLE OF cabnt,

    ls_cabnt TYPE cabnt,

    lt_cawnt TYPE TABLE OF cawnt,

    ls_cawnt TYPE cawnt,

    lv_atinn TYPE c LENGTH 30,

    lv_zaehl TYPE kssk-zaehl.

    *Get All Class Types In Worksheet

    FIND '/' IN gs_tbx-klart.

    IF sy-subrc = 0.

    SPLIT gs_tbx-klart

    AT '/'

    INTO TABLE lt_klart.

    ELSE.

    ls_klart = gs_tbx-klart.

    APPEND ls_klart TO lt_klart.

    ENDIF.

    *Get All Class Names In Worksheet

    FIND '/' IN gs_tbx-class.

    IF sy-subrc = 0.

    SPLIT gs_tbx-class

    AT '/'

    INTO TABLE lt_class.

    ELSE.

    ls_class = gs_tbx-class.

    APPEND ls_class TO lt_class.

    ENDIF.

    *Get All Caracterist Names In Worksheet

    FIND '/' IN gs_tbx-atnam.

    IF sy-subrc = 0.

    SPLIT gs_tbx-atnam

    AT '/'

    INTO TABLE lt_atnam.

    ELSE.

    ls_atnam = gs_tbx-atnam.

    APPEND ls_atnam TO lt_atnam.

    ENDIF.

    *Get All Caracterist Values In Worksheet

    FIND '/' IN gs_tbx-atwrt.

    IF sy-subrc = 0.

    SPLIT gs_tbx-atwrt

    AT '/'

    INTO TABLE lt_atwrt.

    ELSE.

    ls_atwrt = gs_tbx-atwrt.

    APPEND ls_atwrt TO lt_atwrt.

    ENDIF.

    LOOP AT lt_klart INTO ls_klart.

    CLEAR: ls_objectkeynew,

    ls_objecttablenew,

    ls_classnumnew,

    ls_classtypenew,

    ls_status,

    ls_standardclass,

    ls_changenumber,

    ls_keydate,

    ls_no_default_values,

    ls_classif_status,

    lt_allocvaluesnum,

    lt_allocvalueschar,

    lt_allocvaluescurr,

    lt_return,

    ls_allocvaluesnum,

    ls_allocvalueschar,

    ls_allocvaluescurr,

    ls_return,

    ls_class,

    ls_atnam,

    ls_atwrt,

    lv_zaehl.

    READ TABLE lt_class INTO ls_class INDEX sy-tabix.

    READ TABLE lt_atnam INTO ls_atnam INDEX sy-tabix.

    READ TABLE lt_atwrt INTO ls_atwrt INDEX sy-tabix.

    lv_zaehl = lv_zaehl + 1.

    ls_objectkeynew = gs_headdata-material.

    ls_objecttablenew = 'MARA'.

    ls_classnumnew = ls_class.

    ls_classtypenew = ls_klart.

    ls_status = gs_tbx-statu.

    ls_standardclass = gs_tbx-stdcl.

    ls_no_default_values = 'X'.

    ls_allocvaluesnum-charact = ls_atnam.

    ls_allocvaluesnum-instance = lv_zaehl.

    APPEND ls_allocvaluesnum TO lt_allocvaluesnum.

    ls_allocvalueschar-charact = ls_atnam.

    ls_allocvalueschar-value_char = ls_atwrt.

    ls_allocvalueschar-instance = lv_zaehl.

    APPEND ls_allocvalueschar TO lt_allocvalueschar.

    CALL FUNCTION 'BAPI_OBJCL_CREATE'

    EXPORTING

    objectkeynew = ls_objectkeynew

    objecttablenew = ls_objecttablenew

    classnumnew = ls_classnumnew

    classtypenew = ls_classtypenew

    status = '1'

    * STANDARDCLASS =

    * CHANGENUMBER =

    * KEYDATE = SY-DATUM

    no_default_values = ls_no_default_values

    IMPORTING

    classif_status = ls_classif_status

    TABLES

    allocvaluesnum = lt_allocvaluesnum

    allocvalueschar = lt_allocvalueschar

    allocvaluescurr = lt_allocvaluescurr

    return = lt_return.

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

    EXPORTING

    wait = 'X'.

    IF ls_classif_status <> '1'.

    gs_classif_status = ls_classif_status.

    ENDIF.

    APPEND LINES OF lt_return TO gt_classreturn.

    ENDLOOP.

    ENDFORM. " FILL_CLASSIFICATION

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 08, 2013 at 04:38 AM

    Hi Ronnie,

    Suppose you have below case...

    Case 1: Material Master Data Create with Classification View .

    BAPI_MATERIAL_SAVEDATA ( Create Material using this BAPI )

    BAPI_OBJCL_CREATE ( Pass Material Number with classification view data's)

    BAPI_TRANSACTION_COMMIT

    Case 2: Material Master Data Change with Classification View .

    BAPI_MATERIAL_SAVEDATA ( Change the Material Master Record using this BAPI )

    BAPI_OBJCL_GETDETAIL (Collect Existing Class and Characteristics value)

    BAPI_OBJCL_CHANGE (then pass new value all existing and new Characteristics)

    BAPI_TRANSACTION_COMMIT

    Case 3: Only Classification View data change .


    BAPI_OBJCL_GETDETAIL (Collect Existing Class and Characteristics value)

    BAPI_OBJCL_CHANGE (then pass new values all existing and new Characteristics)

    BAPI_TRANSACTION_COMMIT

    Note : Use above BAPI's Sequence as per your requirement .

    if you doesn't use "BAPI_OBJCL_GETDETAIL" in your change scenario then your new value is updated successfully using "BAPI_OBJCL_CHANGE" bapi but existing characteristics value becomes empty, so use "BAPI_OBJCL_GETDETAIL" bapi mandatory for collecting existing value if you go for change scenario .

    or check this discussion "BAPI_OBJCL_CHANGE old values are empty only new value is filled.

    Regard's

    Smruti

    Add comment
    10|10000 characters needed characters exceeded