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: 

Characteristics update in batch

0 Kudos

Hi Experts

I am new to ABAP.

I am using BAPI BAPI_BATCH_SAVE_REPLICA to create/update batch with characteristics as well.

Batch is getting created , but w/o characteristics value in batch master.

Can you please have a look and help me on this?

My code below:

REPORT ZBATCHSAVEREPLICA_002.

DATA: matnr1 TYPE BAPIBATCHKEY-MATERIAL VALUE 'PEDIMONTO-001',

       batch1 TYPE BAPIBATCHKEY-BATCH VALUE 'TODAY-001',

       plant1 TYPE BAPIBATCHKEY-PLANT VALUE 'A901',

       sloc1 TYPE BAPIBATCHSTOLOC-STGE_LOC VALUE 'W900'.

DATA: obkey TYPE c LENGTH 45.

CONCATENATE matnr1 batch1 INTO obkey.

DATA: control1 TYPE BAPIBATCHCTRL.

control1-CLASS_NUM = 'YBATCH'.

control1-DOCLASSIFY = 'X'.

DATA: class1 TYPE BAPI3060_ALLOCATION,

       it1 TYPE TABLE OF BAPI3060_ALLOCATION,

       value1 TYPE BAPI3060_VALUATION_CHAR,

       it2 TYPE TABLE OF BAPI3060_VALUATION_CHAR.

class1-CLASS_TYPE = '023'.

class1-OBJECTKEY = obkey.

class1-CLASSNUM = 'YBATCH'.

class1-OBJECTTABLE = 'MCH1'.

class1-STATUS = '1'.

APPEND class1 to it1.

value1-CLASS_TYPE = '023'.

value1-OBJECTKEY = obkey.

value1-OBJECTTABLE = 'MCH1'.

value1-CHARACT = 'PEDIMONTO'.

value1-VALUE_CHAR = '9999'.

APPEND value1 to it2.

value1-CLASS_TYPE = '023'.

value1-OBJECTKEY = obkey.

value1-CHARACT = 'PORT'.

value1-OBJECTTABLE = 'MCH1'.

value1-VALUE_CHAR = '9999'.

APPEND value1 to it2.

DATA: return1 TYPE BAPIRET2,

       it3 TYPE TABLE OF BAPIRET2.

CALL FUNCTION 'BAPI_BATCH_SAVE_REPLICA'

   EXPORTING

     material                   = matnr1

     batch                      = batch1

    PLANT                       = plant1

*   BATCHATTRIBUTES            =

*   BATCHATTRIBUTESX           =

*   BATCHSTATUS                =

*   BATCHSTATUSX               =

    BATCHCONTROLFIELDS         = control1

    BATCHSTORAGELOCATION        = sloc1

*   INTERNALNUMBERCOM          =

*   EXTENSION1                 =

*   MATERIAL_EVG               =

  TABLES

    RETURN                     = it3

    CLASSALLOCATIONS           = it1

    CLASSVALUATIONSCHAR        = it2

*   CLASSVALUATIONSCURR        =

*   CLASSVALUATIONSNUM         =

           .

loop at it3 INTO return1.

   WRITE: return1-TYPE,/,

          return1-ID,/,

          return1-number,/,

          return1-message,/.

ENDLOOP.


Error log:



Program ZBATCHSAVEREPLICA_002

E

CL

117

Class type 023, object type MCH1, object PED

E

CL

763

Object PEDIMONTO-001TODAY-001 does not exist

I

CL

736

Assignment was not created

2 REPLIES 2

paul_bakker2
Active Contributor
0 Kudos

The characteristics are not being updated because the BAPI is returning error messages.

You might want to investigate and fix those first!The debugger is your friend.

Former Member
0 Kudos

Dear Aslam,

You need to change your logic for some below parameters :

class1-OBJECTTABLE = 'MCH1'.    ->  class1-OBJECTTABLE = 'MCHA'.

value1-OBJECTTABLE = 'MCH1'.   ->  value1-OBJECTTABLE = 'MCHA'.

Please refer the below link :

http://scn.sap.com/thread/1633106

Regards,

Yance