report z. parameters: pmatnr like mara-matnr obligatory, pclass type klasse_d obligatory default 'MODEL', patnam type atnam obligatory default 'MODEL_NAME', patwrt type atwrt obligatory default 'SUPER'. data: w_object like bapi1003_key-object, it_num like bapi1003_alloc_values_num occurs 0 with header line, it_char like bapi1003_alloc_values_char occurs 0 with header line, it_curr like bapi1003_alloc_values_curr occurs 0 with header line, it_ret like bapiret2 occurs 0 with header line. w_object = pmatnr. refresh: it_num, it_char, it_curr, it_ret. write: / '==== Getting details:'. call function 'BAPI_OBJCL_GETDETAIL' exporting objectkey = w_object objecttable = 'MARA' classnum = pclass classtype = '001' tables allocvaluesnum = it_num allocvalueschar = it_char allocvaluescurr = it_curr return = it_ret. loop at it_ret. write: / it_ret-message. endloop. read table it_ret with key type = 'S' id = 'CL' number = 731. if sy-subrc <> 0. write: / '==== Assigning material to the class:'. refresh it_ret. call function 'BAPI_OBJCL_CREATE' exporting objectkeynew = w_object objecttablenew = 'MARA' classnumnew = pclass classtypenew = '001' tables return = it_ret. loop at it_ret. write: / it_ret-message. endloop. read table it_ret with key type = 'S' id = 'CL' number = 735. endif. if sy-subrc = 0. read table it_char with key charact = patnam. if sy-subrc = 0. clear it_char-value_char. it_char-value_neutral = patwrt. modify it_char index sy-tabix. else. clear it_char. it_char-charact = patnam. it_char-value_neutral = patwrt. append it_char. clear it_char. endif. refresh: it_num, it_curr, it_ret. loop at it_char. clear it_char-value_char. modify it_char. endloop. write: / '==== Changing characteristic value:'. call function 'BAPI_OBJCL_CHANGE' exporting objectkey = w_object objecttable = 'MARA' classnum = pclass classtype = '001' tables allocvaluesnumnew = it_num allocvaluescharnew = it_char allocvaluescurrnew = it_curr return = it_ret. loop at it_ret. write: / it_ret-message. endloop. read table it_ret with key type = 'E'. if sy-subrc = 0. write: / '==== ERROR!', '==== Rollback changes.'. else. write: / '==== OK!', '==== Commit changes:'. clear it_ret. call function 'BAPI_TRANSACTION_COMMIT' exporting wait = 'X' importing return = it_ret. if not it_ret-type is initial. write: / it_ret-message. endif. endif. endif. write: / '==== Bye'.