2012 Jun 04 8:30 AM
hi ,
i am having class name : COMM linked to material , class COMM contains characteristics like , 1) Handling code 2) handling sub category 3) handling category.
when i try to update material class manually using mm02 transaction ,like below
dependency condition for handing code characteristics.
handling sub category + haldling category = handling code
ex:- 05 + Al = 05AL
i did updated manually like below.
first i updated haldling sub category and handling category characteristics of material class and save.
after that i updated handling code characteristics and save , ,like this i updated material class characteristics.
problem.:
when i try to update 3 characteristics of material class using zprogramm , giving problem like before updating handling code characteristics update handling sub category and handling category.
how to update all the 3 characteristics of material class,
please guide me.
regards
naini ,
2012 Jun 04 8:56 AM
2012 Jun 04 9:03 AM
hi ,
like below i am updating material characteristics.
DATA: i_cawn TYPE TABLE OF cawn,
wa_cawn LIKE cawn.
DATA : BEGIN OF gs_chars,
classtype TYPE bapi1003_key-classtype,
classnum TYPE bapi1003_key-classnum,
atnam TYPE atwrt,
atwrt_from TYPE atwrt,
atwrt_to TYPE atwrt,
END OF gs_chars.
DATA : lt_chars LIKE STANDARD TABLE OF gs_chars WITH HEADER LINE.
DATA : wa_chars LIKE lt_chars.
DATA: ls_charactdetail TYPE bapicharactdetail.
DATA: l_objectkey LIKE bapi1003_key-object,
l_objecttable LIKE bapi1003_key-objecttable,
l_classnum LIKE bapi1003_key-classnum,
l_classtype LIKE bapi1003_key-classtype.
DATA: ls_allocvaluesnumnew TYPE bapi1003_alloc_values_num,
ls_allocvaluescharnew TYPE bapi1003_alloc_values_char,
ls_allocvaluescurrnew TYPE bapi1003_alloc_values_curr,
ls_return TYPE bapiret2.
DATA : lt_num TYPE STANDARD TABLE OF bapi1003_alloc_values_num,
lt_char TYPE STANDARD TABLE OF bapi1003_alloc_values_char ,
lt_new_char LIKE bapi1003_alloc_values_char OCCURS 0 WITH HEADER LINE,
wa_char LIKE LINE OF lt_char,
lt_curr TYPE STANDARD TABLE OF bapi1003_alloc_values_curr,
lt_return_n TYPE STANDARD TABLE OF bapiret2.
DATA: lt_allocvaluesnumnew TYPE STANDARD TABLE OF bapi1003_alloc_values_num,
lt_allocvaluescharnew TYPE STANDARD TABLE OF bapi1003_alloc_values_char,
lt_allocvaluescurrnew TYPE STANDARD TABLE OF bapi1003_alloc_values_curr,
lt_return TYPE STANDARD TABLE OF bapiret2.
DATA: ylt_new_char LIKE ZWEB_CHAR_DETAILS OCCURS 0 WITH HEADER LINE.
*--->end of data declarations
SELECT SINGLE * FROM zhandlcategories WHERE zhanditem EQ var18.
MOVE mara-matnr TO object.
l_objecttable = 'MARA'.
l_objectkey = object.
*--->this FM gets all the char values
CALL FUNCTION 'BAPI_OBJCL_GETDETAIL'
EXPORTING
objectkey = l_objectkey
objecttable = 'MARA'
classnum = 'COMMODITY'
classtype = '001'
TABLES
allocvaluesnum = lt_num
allocvalueschar = lt_char
allocvaluescurr = lt_curr
return = lt_return_n.
*--->now we have all the char values into int.table ///now to get screen values updated pass
*--->them to the INT.TABLE
LOOP AT lt_char INTO wa_char.
MOVE : wa_char-charact TO lt_new_char-charact.
IF wa_char-charact = 'CC-HAZARDOUSCLASS'.
MOVE : zhandlcategories-zhazclass TO lt_new_char-value_neutral.
ELSEIF wa_char-charact = 'CC-HAZARDOUSPRTIND'.
MOVE : zhandlcategories-zhazprnt TO lt_new_char-value_neutral.
ELSEIF wa_char-charact = 'CC-HANDLINGCAT'.
MOVE : zhandlcategories-zhandlingcat TO lt_new_char-value_neutral.
ELSEIF wa_char-charact = 'CC-HANDLINGSUBCAT'.
MOVE : zhandlcategories-zhandsubcat TO lt_new_char-value_neutral.
ELSEIF wa_char-charact = 'CC-HANDLINGCODE'.
MOVE : zhandlcategories-zhanditem TO lt_new_char-value_neutral.
ELSEIF wa_char-charact = 'CC-DISTANCE'.
MOVE : zhandlcategories-zdistan TO lt_new_char-value_neutral.
ELSEIF wa_char-charact = 'CC-LOADEMPTYIND'.
MOVE : zhandlcategories-zloademptyind TO lt_new_char-value_neutral.
ELSEIF wa_char-charact = 'CC-HANDLINGCLASS'.
MOVE : zhandlcategories-zhandclass TO lt_new_char-value_neutral.
ELSEIF wa_char-charact = 'CC-NOTES'.
IF NOT var7 IS INITIAL.
MOVE var7 TO lt_new_char-value_neutral.
ELSE.
MOVE wa_char-value_neutral TO lt_new_char-value_neutral.
ENDIF.
ELSE.
MOVE : wa_char-charact TO lt_new_char-charact.
MOVE wa_char-value_neutral TO lt_new_char-value_neutral.
ENDIF.
APPEND lt_new_char.
ENDLOOP.
REFRESH lt_return_n.
CALL FUNCTION 'BAPI_OBJCL_CHANGE'
EXPORTING
objectkey = l_objectkey
objecttable = 'MARA'
classnum = 'COMMODITY'
classtype = '001'
TABLES
allocvaluesnumnew = lt_num
allocvaluescharnew = lt_new_char
allocvaluescurrnew = lt_curr
return = lt_return_n.
READ TABLE lt_return_n INTO ls_return WITH KEY type = 'E'.
IF sy-subrc = 0.
MESSAGE e002(zfiex) WITH ls_return-message(90).
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDIF.
.
Thanks & Regards
naini
2012 Jun 04 9:40 AM
I feel that you should call the BAPI "BAPI_OBJCL_CHANGE" two times to achieve this requirement.
First time to update the dependent characteristics 'handling sub category', 'haldling category' and second time for 'handling code'.