Skip to Content
author's profile photo Former Member
Former Member

Create/Update classification data for the existing Material

Hello Friends,

Can any one worked on the below requirement.

how to Create/Update the Classification after creating a material?

BAPI_MATERIAL_SAVEDATA is used to create a material but cannot Create/Update the classification data.

I have looked into the following BAPIs.

BAPI_CHARACT_CREATE or BAPI_CHARACT_CHANGE. But these are not giving the desired result.

It would be of great help.

Thanks, Prakash.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Nov 21, 2007 at 07:26 PM

    Hi,

    Please try BAPI BAPI_OBJCL_CHANGE.

    The object key should be material number and object table should be MARA.

    Regards,

    Ferry Lianto

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 21, 2007 at 09:14 PM

    Hi

    see the sample code for the same and do accordingly

    DATA : gf_objkey TYPE bapi1003_key-object,

    gf_classnum TYPE bapi1003_key-classnum,

    lw_return TYPE bapiret2,

    gt_return TYPE STANDARD TABLE OF bapiret2,

    gf_classtype TYPE bapi1003_key-classtype,

    gt_charval TYPE STANDARD TABLE OF bapi1003_alloc_values_char,

    lw_charval TYPE bapi1003_alloc_values_char,

    gt_numval TYPE STANDARD TABLE OF bapi1003_alloc_values_num,

    lw_numval TYPE bapi1003_alloc_values_num,

    gt_currval TYPE STANDARD TABLE OF bapi1003_alloc_values_curr,

    lw_z1edkclsf TYPE z1edkclsf,

    lw_chardetail TYPE bapicharactdetail,

    gf_date_source TYPE i,

    gf_error TYPE c,

    gf_matnr TYPE matnr, "#EC NEEDED

    gf_error_in_logging TYPE c.

    CLEAR: gf_objkey.

    CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'

    EXPORTING

    input = if_matnr

    IMPORTING

    output = gf_matnr.

    gf_objkey = gf_matnr.

    • Unlock the Object

    CALL METHOD unlock_object

    EXPORTING

    if_matnr = if_matnr.

    LOOP AT mt_z1edkclsf INTO lw_z1edkclsf.

    CLEAR gt_return[].

    • Class type

    gf_classtype = lw_z1edkclsf-klart.

    • Class

    gf_classnum = lw_z1edkclsf-class.

    lw_charval-charact = lw_z1edkclsf-atnam.

    lw_charval-value_char = lw_z1edkclsf-atwrt.

    • Get the Data type of Characteristic

    CALL FUNCTION 'BAPI_CHARACT_GETDETAIL'

    EXPORTING

    charactname = lw_charval-charact

    IMPORTING

    charactdetail = lw_chardetail

    TABLES

    return = gt_return.

    CLEAR : gf_date_source.

    READ TABLE gt_return TRANSPORTING NO FIELDS WITH KEY type = co_msgty_error.

    CHECK sy-subrc NE 0.

    • If the characteristic is Date type then pass the value to NUM structure

    IF lw_chardetail-data_type EQ 'DATE'.

    gf_date_source = lw_z1edkclsf-atwrt.

    lw_numval-value_from = gf_date_source.

    lw_numval-charact = lw_z1edkclsf-atnam.

    APPEND lw_numval TO gt_numval.

    • If the characteristic is CHAR type then pass the value to char structure

    ELSEIF lw_chardetail-data_type EQ 'CHAR'.

    MOVE lw_z1edkclsf-atwrt TO lw_charval-value_char.

    APPEND lw_charval TO gt_charval.

    ENDIF.

    AT END OF class.

    • Post the data for all characteristics belonging to the Class

    CLEAR gt_return[].

    CALL FUNCTION 'BAPI_OBJCL_CHANGE'

    EXPORTING

    objectkey = gf_objkey

    objecttable = 'MARA'

    classnum = gf_classnum

    classtype = gf_classtype

    TABLES

    allocvaluesnumnew = gt_numval

    allocvaluescharnew = gt_charval

    allocvaluescurrnew = gt_currval

    return = gt_return.

    CLEAR: gt_charval[],

    gt_numval[],

    gt_currval[].

    APPEND LINES OF gt_return TO et_messages.

    READ TABLE gt_return TRANSPORTING NO FIELDS WITH KEY type = co_msgty_error.

    IF sy-subrc EQ 0.

    gf_error = co_x.

    ELSE.

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

    EXPORTING

    wait = co_x.

    ENDIF.

    Regards

    Anji

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.