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: 

about update characteristic' s value of document in program.

Former Member
0 Kudos

when batcch updating characteristic' s value of document in program, find executing program each one time , one document only was updated,others were not,and function BAPI_DOCUMENT_CHANGE2 return-MESSAGE is 'document is not exist'.

what reason is?

pls help me.

5 REPLIES 5

Former Member
0 Kudos

Hello,

For updating the Batch Characteristics (MSC2N - T-Code), you can use the Following BAPIs which will serve your purpose.

BAPI_OBJCL_CONCATENATEKEY - MATNR & CHARG

Combination

BAPI_OBJCL_GETCLASSES - To fetch the Batch Class.

BAPI_OBJCL_GETSTATUS - Status of the Batch

BAPI_OBJCL_CREATE - To Create Classification

BAPI_OBJCL_GET_KEY_OF_OBJECT - to Get CUOBJ_BM

BAPI_OBJCL_GETCLASSES_KEY

BAPI_OBJCL_GETDETAIL - To Get the Characteristics.

BAPI_OBJCL_CHANGE - This Updates the Batch Chars..

Hope it was helpful.

Thanks and Regards,

Venkat Phani Prasad Konduri

Former Member
0 Kudos

hello,

whether supply a FM BAPI_OBJCL_CHANGE example for updating document characterictic,only found it for updating material characterictic.

and tried it in updating document charaterictic,but no success. I don't know how to assign OBJECTKEY and OBJECTTABLE importing parameters.

I tried to assigned doknr and DRAW, or objek of ausp and AUSP, RETURN table respective result:

E CL 535 functional module OBJECT_CHECK_AUSP not exist.

I CL 736 not create assignment

E CL 763 object not exist

I CL 736 not create assignment

thank your help.

Best Regards.

Tina PANG.

0 Kudos

Hello,

Take a look at this Example.

CLEAR: i_object, i_rettab.

REFRESH: i_object, i_rettab.

wa_object1-key_field = 'MATNR'.

wa_object1-value_int = wa_z1ctrlmm-matnr.

APPEND wa_object1 TO i_object.

wa_object1-key_field = 'CHARG'.

wa_object1-value_int = wa_batchid-charg.

APPEND wa_object1 TO i_object.

                • CONCATENATING MATNR & CHARG **********

CALL FUNCTION 'BAPI_OBJCL_CONCATENATEKEY'

EXPORTING

objecttable = 'MCH1'

IMPORTING

objectkey_conc = wa_object

TABLES

objectkeytable = i_object

return = i_rettab.

ENDFORM. " F0016_BUILD_OBJECT_KEY

&----


*& Form F0017_GET_OBJECT_CLASS

&----


  • This Subroutine will get the Object Class for the given Material Number

  • and Batch Number.

----


FORM f0017_get_object_class .

CALL FUNCTION 'BAPI_OBJCL_GETCLASSES'

EXPORTING

objectkey_imp = wa_object

objecttable_imp = 'MCH1'

classtype_imp = '023'

TABLES

alloclist = i_getclass

return = i_rettab.

CLEAR: wa_getclass.

READ TABLE i_getclass INTO wa_getclass INDEX 1.

IF sy-subrc = 0.

CLEAR: ws_c_class,

ws_c_klart.

ws_c_class = wa_getclass-classnum.

ws_c_klart = wa_getclass-classtype.

ELSE.

CLEAR: ws_c_class,

ws_c_klart.

ws_c_class = c_class.

ws_c_klart = c_klart.

ENDIF.

ENDFORM. " F0017_GET_OBJECT_CLASS

&----


*& Form F0018_OBJECT_STATUS

&----


  • This Subroutine will get the Status of the Class Object.

----


FORM f0018_object_status .

CLEAR i_rettab[].

CALL FUNCTION 'BAPI_OBJCL_GETSTATUS'

EXPORTING

objectkey = wa_object

objecttable = 'MCH1'

classnum = ws_c_class

classtype = ws_c_klart

IMPORTING

status = wa_status

TABLES

return = i_rettab.

ENDFORM. " F0018_OBJECT_STATUS

&----


*& Form F0019_CREATE_CLASSIFICATION

&----


  • This Subroutine will get the Object Classification for the Given Batch

  • and given Material.

----


FORM f0019_create_classification .

CALL FUNCTION 'CLAP_DDB_UPDATE_CLASSIFICATION'

EXPORTING

pobtab = 'MCH1'

class = 'CF_ABSORB_BATCH'

object = wa_object

classtype = '023'

IMPORTING

internal_obj_number = ws_c_inobj

clint = ws_c_client

EXCEPTIONS

allocation_exist = 1

no_authority_type = 2

classytpe_not_def = 3

no_valid_sign_class = 4

no_authority_class = 5

class_status_not_valid = 6

class_date_not_valid = 7

class_not_found = 8

no_multi_classify = 9

foreign_lock = 10

system_failure = 11

unit_incompatible = 12

table_no_multitab = 13

other_change_number = 14

status_read_only = 15

change_kssk_not_allowed = 16

change_ausp_not_allowed = 17

set_aennr = 18

change_nr_not_exist = 19

date_in_past = 20

error_class = 21

error_date_restriction = 22

error_status = 23

mtart_not_exist = 24

mtart_classif_not_allowed = 25

rekursiv = 26

OTHERS = 27.

IF sy-subrc <> 0.

CLEAR: ws_c_line1.

ENDIF.

IF ws_c_class IS INITIAL AND ws_c_klart IS INITIAL.

CLEAR: ws_c_class,

ws_c_klart.

ws_c_class = c_class.

ws_c_klart = c_klart.

ENDIF.

CALL FUNCTION 'BAPI_OBJCL_CREATE'

EXPORTING

objectkeynew = wa_object

objecttablenew = 'MCH1'

classnumnew = ws_c_class

classtypenew = ws_c_klart

IMPORTING

classif_status = wa_status

TABLES

return = i_rettab.

ENDFORM. " F0019_CREATE_CLASSIFICATION

&----


*& Form F0020_BAPI_COMMIT

&----


  • This subroutine will perform the COMMIT WORK task.

----


FORM f0020_bapi_commit .

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

ENDFORM. " F0020_BAPI_COMMIT

&----


*& Form F0021_GET_CHARACTERISTICS

&----


  • This Subroutine will get the Characteristics of the Given Batch using

  • a BAPI Function Module.

----


FORM f0021_get_characteristics .

  • EXTRACT THE CHARACTERISTIC NAMES FOR KLART/CLASS

REFRESH i_cabn.

CLEAR : i_rettab[].

              • GET CUOBJ *********

CALL FUNCTION 'BAPI_OBJCL_GET_KEY_OF_OBJECT'

EXPORTING

objectname = wa_object

objecttable = 'MCH1'

classtype = '023'

  • CREATE_MISSING_KEY =

IMPORTING

clobjectkeyout = wa_clobject

TABLES

return = i_rettab.

CLEAR : i_getclass[],

i_rettab[].

IF NOT wa_clobject IS INITIAL.

                • GET CLASSNUM & CLASSTYPE **********

CALL FUNCTION 'BAPI_OBJCL_GETCLASSES_KEY'

EXPORTING

clobjectkeyin = wa_clobject

TABLES

alloclist = i_getclass

return = i_rettab.

READ TABLE i_getclass INTO wa_getclass INDEX 1.

IF sy-subrc = 0.

ws_c_class = wa_getclass-classnum.

ws_c_klart = wa_getclass-classtype.

ENDIF.

ENDIF.

CLEAR: ws_c_client.

SELECT SINGLE clint "#CCE

FROM klah

INTO CORRESPONDING FIELDS OF (ws_c_client)

WHERE clint NE space AND

klart = ws_c_klart AND

class = ws_c_class. "#EC *

IF sy-subrc = 0.

CLEAR : i_ksml[].

SELECT clint "#CCE

imerk

FROM ksml "CHARACTERISTICS OF CLASS

INTO CORRESPONDING FIELDS OF TABLE i_ksml

WHERE clint = ws_c_client AND

lkenz = space.

IF sy-subrc = 0.

CLEAR: i_cabn.

CLEAR: ws_c_line1.

DESCRIBE TABLE i_ksml LINES ws_c_line1.

IF NOT ws_c_line1 IS INITIAL.

SELECT a~atinn

a~atnam

a~atfor

b~atbez

FROM cabn AS a INNER JOIN cabnt AS b ON aatinn = batinn

INTO CORRESPONDING FIELDS OF TABLE i_cabn

FOR ALL ENTRIES IN i_ksml

WHERE a~atinn = i_ksml-imerk AND

b~spras = 'EN'.

IF sy-subrc EQ 0.

SORT i_cabn BY atnam.

ENDIF.

ENDIF.

ENDIF.

ENDIF.

ENDFORM. " F0021_GET_CHARACTERISTICS

&----


*& Form F0022_EXTRACT_ORIGINAL_BATCH

&----


  • This Subroutine will get the Old Batch Number for the Given Material

  • Number sent in the Inbound IDoc.

----


FORM f0022_extract_original_batch .

CLEAR : i_numtab,

i_chatab,

i_curtab,

i_rettab.

REFRESH : i_numtab,

i_chatab,

i_curtab,

i_rettab.

          • EXTRACT THE ORIGINAL CHARACTERISTIC DATA *******

CALL FUNCTION 'BAPI_OBJCL_GETDETAIL'

EXPORTING

objectkey = wa_object

objecttable = 'MCH1'

classnum = ws_c_class

classtype = ws_c_klart

  • KEYDATE = SY-DATUM

  • UNVALUATED_CHARS = ' '

  • LANGUAGE = SY-LANGU

IMPORTING

status = wa_status

standardclass = c_x

TABLES

allocvaluesnum = i_numtab

allocvalueschar = i_chatab

allocvaluescurr = i_curtab

return = i_rettab.

ENDFORM. " F0022_EXTRACT_ORIGINAL_BATCH

&----


*& Form F0024_UPDATE_ORIGINAL_BATCH

&----


  • This Subroutine will wipe out the Old Batch Characteristics of the Old

  • Batch Number.

----


FORM f0024_update_original_batch .

SORT: i_numtab BY charact,

i_chatab BY charact,

i_curtab BY charact.

CLEAR wa_update.

CLEAR: wa_cabn.

SORT i_update BY char_name charg. "#CCE

DELETE ADJACENT DUPLICATES FROM i_update COMPARING char_name. " Need to Check Later

LOOP AT i_cabn INTO wa_cabn. "#CCE

ws_c_cabn_idx = sy-tabix.

READ TABLE i_update INTO wa_update WITH KEY char_name = wa_cabn-atnam

charg = wa_batchid-charg BINARY SEARCH.

IF sy-subrc = 0.

wa_cabn-atwrt = wa_update-char_value.

MODIFY i_cabn FROM wa_cabn INDEX ws_c_cabn_idx TRANSPORTING atwrt.

CLEAR : ws_c_cabn_idx.

ELSE.

CLEAR wa_update.

ENDIF.

IF wa_cabn-atfor = 'CHAR' OR wa_cabn-atfor = 'DATE' OR wa_cabn-atfor = 'TIME'.

CLEAR wa_chatab.

READ TABLE i_chatab INTO wa_chatab WITH KEY charact = wa_cabn-atnam."#CCE

  • " BINARY SEARCH. >>>>> Binary search not working here

IF syst-subrc = 0.

wa_chatab-value_neutral = wa_update-char_value.

IF wa_update-char_value = space.

DELETE i_chatab INDEX sy-tabix.

ELSE.

MODIFY i_chatab FROM wa_chatab INDEX sy-tabix.

ENDIF.

CLEAR: wa_chatab-value_neutral.

ELSE.

IF NOT wa_update-char_value IS INITIAL.

wa_chatab-charact = wa_cabn-atnam.

wa_chatab-value_neutral = wa_update-char_value.

wa_chatab-charact_descr = wa_cabn-atbez.

APPEND wa_chatab TO i_chatab.

ENDIF.

ENDIF.

ELSEIF wa_cabn-atfor = 'NUM'.

CLEAR wa_numtab.

READ TABLE i_numtab INTO wa_numtab WITH KEY charact = wa_cabn-atnam."#CCE

  • " BINARY SEARCH. >>>>> Binary search not working here

IF sy-subrc = 0.

wa_numtab-value_from = wa_update-char_value.

IF wa_update-char_value = space.

DELETE i_numtab INDEX sy-tabix.

ELSE.

MODIFY i_numtab FROM wa_numtab INDEX sy-tabix.

ENDIF.

CLEAR: wa_numtab-value_from.

ELSE.

wa_numtab-charact = wa_cabn-atnam.

IF NOT wa_update-char_value IS INITIAL.

wa_numtab-value_from = wa_update-char_value.

APPEND wa_numtab TO i_numtab.

ENDIF.

ENDIF.

ELSEIF wa_cabn-atfor = 'CURR'.

CLEAR wa_curtab.

READ TABLE i_curtab INTO wa_curtab WITH KEY charact = wa_cabn-atnam."#CCE

IF syst-subrc = 0.

wa_curtab-value_from = wa_update-char_value.

MODIFY i_curtab FROM wa_curtab INDEX sy-tabix.

ELSE.

wa_curtab-charact = wa_cabn-atnam.

wa_curtab-value_from = wa_cabn-atwrt.

APPEND wa_curtab TO i_curtab.

ENDIF.

ENDIF.

ENDLOOP.

ENDFORM. " F0024_UPDATE_ORIGINAL_BATCH

&----


*& Form F0025_BAPI_CHANGE

&----


  • This Subroutine will update the New Batch Number Characteristics using

  • a BAPI Function Module.

----


FORM f0025_bapi_change .

CALL FUNCTION 'BAPI_OBJCL_CHANGE'

EXPORTING

objectkey = wa_object

objecttable = 'MCH1'

classnum = ws_c_class

classtype = ws_c_klart

IMPORTING

classif_status = wa_status

TABLES

allocvaluesnumnew = i_numtab

allocvaluescharnew = i_chatab

allocvaluescurrnew = i_curtab

return = i_rettab.

Hope it would be helpful.

Thanks and Regards,

Venkat Phani Prasad Konduri

Former Member
0 Kudos

Hello,

At first, thank you very much for your help.

now,still have problem.

1.CALL FUNCTION 'BAPI_OBJCL_GET_KEY_OF_OBJECT'

return-message is 'Class type 017 requires additional objects'.

CLOBJECTKEYOUT ='000000000000000000'

importing parameter OBJECTNAME is concatenation of DOKAR DOKNR DOKVR DOKTL I don't know if it is right.

2. CALL FUNCTION 'BAPI_OBJCL_GETDETAIL' AND 'BAPI_OBJCL_CHANGE'

return result:

S |CL |506 |Saving changes to assignments

S |CL |737 |Assignment changed

but actually,the characteritic for document I want to update was not updated.

debug program,before call function 'BAPI_OBJCL_CHANGE',lt_ALLOCVALUESCHARNEW-VALUE_CHAR has been changed.

how to solve this problem.

thank you.

Best Regards.

Tina pang.

Former Member
0 Kudos

who could help me solve this problem?

thank you

TINA PANG