Application Development and Automation 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: 
Read only

Update characteristic with multiple values - BAPI_OBJCL_CHANGE

Former Member
0 Likes
4,971

Hello All,

I'm updating batch characteristics using FM  BAPI_OBJCL_CHANGE. It's working fine for characteristics that have only 1 value, but it's not updating characteristics with multiple values.

Example:

Characteristic: XX_COUNTRY

VALUE: CANADA

Characteristic: XX_COUNTRY

VALUE: CHILE

After program execution if you check trx MSC3N you only get value CHILE.

I tried to add multiple values with instance field like the code below but it's not working.

LOOP  AT mchb INTO ls_mchb

                          WHERE matnr IS NOT INITIAL

                            AND charg IS NOT INITIAL.

     ls_batch_char_c-charact    = 'XX_COUNTRY'.

    ls_batch_char_c-instance = ls_batch_char_c-instance + 1.

     ls_batch_char_c-value_char = ls_mchb-grw_loc.

     APPEND ls_batch_char_c TO lt_batch_char_c.

   ENDLOOP.

Is there any way to add multiple values for characteristics?

Thanks in advance for your help!

Emanuel.

1 ACCEPTED SOLUTION
Read only

JarosBaw
Active Participant
0 Likes
2,965

Hi,

In MSC2N can You input multiple values ?

If not, please check characteristic in CT04 transaction.

I've made test and can provide multiple values using this FM without problems, part of code:


DATA:

   lt_allocchar  TYPE TABLE OF bapi1003_alloc_values_char,

   ls_allocchar  TYPE bapi1003_alloc_values_char.

     ls_allocchar-charact = 'ZNUM_SERT'.

     ls_allocchar-value_char = 'ABC'.

     APPEND ls_allocchar TO lt_allocchar.

     ls_allocchar-charact = 'ZNUM_SERT'.

     ls_allocchar-value_char = 'DEF'.

     APPEND ls_allocchar TO lt_allocchar.

     CALL FUNCTION 'BAPI_OBJCL_CHANGE'

       EXPORTING

         OBJECTKEY            = l_objkey

         OBJECTTABLE          = 'MCH1'

         CLASSNUM             = 'Z_FERT'

         CLASSTYPE            = '023'

       TABLES

         RETURN               = lt_ret[]

         ALLOCVALUESNUMNEW    = lt_allocnum[]

         ALLOCVALUESCHARNEW   = lt_allocchar[]

         ALLOCVALUESCURRNEW   = lt_alloccurr[].

       CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

4 REPLIES 4
Read only

JarosBaw
Active Participant
0 Likes
2,966

Hi,

In MSC2N can You input multiple values ?

If not, please check characteristic in CT04 transaction.

I've made test and can provide multiple values using this FM without problems, part of code:


DATA:

   lt_allocchar  TYPE TABLE OF bapi1003_alloc_values_char,

   ls_allocchar  TYPE bapi1003_alloc_values_char.

     ls_allocchar-charact = 'ZNUM_SERT'.

     ls_allocchar-value_char = 'ABC'.

     APPEND ls_allocchar TO lt_allocchar.

     ls_allocchar-charact = 'ZNUM_SERT'.

     ls_allocchar-value_char = 'DEF'.

     APPEND ls_allocchar TO lt_allocchar.

     CALL FUNCTION 'BAPI_OBJCL_CHANGE'

       EXPORTING

         OBJECTKEY            = l_objkey

         OBJECTTABLE          = 'MCH1'

         CLASSNUM             = 'Z_FERT'

         CLASSTYPE            = '023'

       TABLES

         RETURN               = lt_ret[]

         ALLOCVALUESNUMNEW    = lt_allocnum[]

         ALLOCVALUESCHARNEW   = lt_allocchar[]

         ALLOCVALUESCURRNEW   = lt_alloccurr[].

       CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

Read only

Former Member
0 Likes
2,965

Thanks!

It was a program error. I was not using correct data for the BAPI.

Regards!

Read only

former_member188724
Contributor
0 Likes
2,965

Hi,

Did you try checking the threads

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

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

Regards,

K.S

Read only

0 Likes
2,965

I have tried using the same BAPI for updating characteristics data with multiple values. Instance counter (ATZHL) should be specified and data should be placed correctly in their corresponding tables depending on the format  (NUM, CHAR, CURR)