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

Business Partner Classification - BAPI_OBJCL_CHANGE

alessio_pierfederici
Participant
0 Likes
5,209

Hi gurus,

I'm trying to use the following function to update the business partners classification.

CALL FUNCTION 'BAPI_OBJCL_CHANGE'

EXPORTING

   objectkey                = wa_objectkey

   objecttable              = 'JGVGPKLASS'

   classnum                 = 'CLIENTI'

   classtype                = '071'

*   STATUS                   = '1'

*   STANDARDCLASS            =

*   CHANGENUMBER             =

*   KEYDATE                  = SY-DATUM

*   NO_DEFAULT_VALUES        = ' '

* IMPORTING

*   CLASSIF_STATUS           =

TABLES

   allocvaluesnumnew        = gt_allocnum

   allocvaluescharnew       = gt_allocchar

   allocvaluescurrnew       = gt_alloccurr

   return                   = gt_return.


As a result I can add a characteristic to an existing classification, but I can not change a value for a characteristic already present in that classification.

I can not even delete a characteristic for that classification.

Can you give me directions about?

Thanks in advance.

Alessio

Hi gurus,

I'm trying to use the following function to update the business partners classification.

CALL FUNCTION 'BAPI_OBJCL_CHANGE'

EXPORTING

   objectkey                = wa_objectkey

   objecttable              = 'JGVGPKLASS'

   classnum                 = 'CLIENTI'

   classtype                = '071'

*   STATUS                   = '1'

*   STANDARDCLASS            =

*   CHANGENUMBER             =

*   KEYDATE                  = SY-DATUM

*   NO_DEFAULT_VALUES        = ' '

* IMPORTING

*   CLASSIF_STATUS           =

TABLES

   allocvaluesnumnew        = gt_allocnum

   allocvaluescharnew       = gt_allocchar

   allocvaluescurrnew       = gt_alloccurr

   return                   = gt_return.


As a result I can add a characteristic to an existing classification, but I can not change a value for a characteristic already present in that classification.

I can not even delete a characteristic for that classification.

Can you give me directions about?

Thanks in advance.

Alessio

17 REPLIES 17
Read only

alessio_pierfederici
Participant
0 Likes
4,179

Thanks to NAVIN FERNANDES

Now I also can change a characteristic value ... but for delete?!?

Read only

0 Likes
4,179

Hi Alessio,

You cant delete the characteristic from class but you can reset the characteristic value to initials value using change BAPI.

Regards,

Sudeesh Soni

Read only

alessio_pierfederici
Participant
0 Likes
4,179

Thanks Sudeesh Soni,

could you give me more info about reset the characteristic value to initials value using change BAPI?

Now, passing to a characteristic the initial value, do not get any change.

deleting the record of the feature to reset, I do not get the desired result.

Checking in debug the BAPI_OBJCL_CHANGE I see that the table " l_api_val_r_del" is empty.

Reagards,

Alessio

Read only

RaymondGiuseppi
Active Contributor
0 Likes
4,179

Which combination of the following BAPI, have you tested?

  • BAPI_OBJCL_GETDETAIL
  • BAPI_OBJCL_DELETE
  • BAPI_OBJCL_CHANGE or BAPI_OBJCL_CREATE

did you try ?

Regards,

Raymond

Read only

alessio_pierfederici
Participant
0 Likes
4,179

Hi Raymond,

I try

  • BAPI_OBJCL_GETDETAIL
  • BAPI_OBJCL_CHANGE

passing characteristics with the new values, if exploited.

Read only

0 Likes
4,179

Thanks Raymond!

Read only

alessio_pierfederici
Participant
0 Likes
4,179

Thanks Raymond !

Read only

alessio_pierfederici
Participant
0 Likes
4,179

... so for deleting I have to call BAPI_OBJCL_DELETE with the characteristics to delete?

Regards

Alessio

Read only

0 Likes
4,179

Yes use GET_DETAIL to get current characteristics, if only new to add use CHANGE else use DELETE and CREATE.

Regards,

Raymond

Read only

alessio_pierfederici
Participant
0 Likes
4,179

Thanks Raymond,

but in BAPI_OBJCL_DELETE ,how do I clear the value of a single characteristic and leave unchanged the other?

In BAPI_OBJCL_CHANGE there are the tables :

ALLOCVALUESNUMNEW

ALLOCVALUESCHARNEW

ALLOCVALUESCURRNEW

In BAPI_OBJCL_DELETE we delete all the characteristics, Is this right?

Regards,

Alessio

Read only

0 Likes
4,179

Hi Alessio,


Pls refer belowmentioned  logic steps.

1. Get the BP class details using BAPI-BAPI_OBJCL_GETDETAIL.

2. In debug, You can check in which below mentioned tables your required characteristic field exist.

ALLOCVALUESNUMNEW

ALLOCVALUESCHARNEW

ALLOCVALUESCURRNEW

3. Read the identified internal table with key CHARACT   and store the data into workarea. Also, store the table index SY-TABIX into local variable.

4. Change the Workarea required field with desired value.Further, modify the step-3 identified internal table with new workarea data using INDEX = SY-TABIX.

5. Call the BAPI-BAPI_OBJCL_CHANGE and pass all above mentioned internal tables with modified value(ALLOCVALUESNUMNEW, ALLOCVALUESCHARNEW, ALLOCVALUESCURRNEW)


Why you want to delete the characteristic? I think best option is to reset the characteristic value to initial value using above mentioned logic.


Regards,

Sudeesh Soni

Read only

0 Likes
4,179

Thanks Sudeesh Soni,

I'm using the logic steps that you mentioned.


I supposed to delete the characteristic because if I reset the characteristic value to initial value I do not get any change !

After the commit I see the old characteristic value.

But the logic work right changing the characteristic value with another one different from initial (' ').

Also work right adding a value to a characteristic that were initial.

Where can I go wrong?

Regards

Alessio

Read only

alessio_pierfederici
Participant
0 Likes
4,179

Thanks Sudeesh Soni,

I'm using the logic steps that you mentioned.


I supposed to delete the characteristic because if I reset the characteristic value to initial value I do not get any change !

After the commit I see the old characteristic value.

But the logic work right changing the characteristic value with another one different from initial (' ').

Also work right adding a value to a characteristic that were initial.

Where can I go wrong?

Regards

Alessio

Read only

Former Member
0 Likes
4,179

Hi Alessio,

Can you pls copy/paste the code logic?

Regards,

Sudeesh Soni

Read only

0 Likes
4,179

    LOOP AT gt_class.

      READ TABLE char_struc INTO wa_char_struc WITH KEY  name_char = gt_class-rcdin.

  

      IF wa_char_struc-data_type = 'CURR'.

        READ TABLE gt_alloccurr INTO wa_alloccurr WITH KEY charact = gt_class-rcdin. 

        if sy-subrc = 0.                                              

          wa_alloccurr-charact = wa_char_struc-name_char.

          CLEAR lv_rinal.

          WRITE gt_class-rinal TO lv_rinal DECIMALS 0.

          REPLACE '.' WITH ' ' INTO lv_rinal.

          REPLACE ',' WITH ' ' INTO lv_rinal.

          CONDENSE gt_class-rinal NO-GAPS.

          wa_alloccurr-value_from = lv_rinal.

          wa_alloccurr-currency_from = 'EUR'.

          wa_alloccurr-value_relation = '1'.

          wa_alloccurr-currency_from_iso = 'EUR'.

*          If NOT gt_class-rinal is INITIAL.                            

            MODIFY gt_alloccurr FROM wa_alloccurr INDEX sy-tabix TRANSPORTING value_from currency_from value_relation currency_from_iso.

*          else.                                                        

*            DELETE gt_alloccurr WHERE charact = wa_alloccurr-charact.  

*          endif.                                                       

        endif.

      ELSEIF wa_char_struc-data_type = 'CHAR'.

        READ TABLE gt_allocchar INTO wa_allocchar WITH KEY charact = gt_class-rcdin. 

        if sy-subrc = 0.                                                                 

          wa_allocchar-charact = wa_char_struc-name_char.

          wa_allocchar-value_char = gt_class-rinal.

          wa_allocchar-value_neutral = gt_class-rinal.

*          If NOT gt_class-rinal is INITIAL.                                              

            MODIFY gt_allocchar FROM wa_allocchar INDEX sy-tabix TRANSPORTING value_char value_neutral.

*          else.                                                                          

*            DELETE gt_allocchar  WHERE charact = wa_allocchar-charact.                   

*          endif.                                                                         

        endif.

      ELSEIF wa_char_struc-data_type = 'NUM'.

        READ TABLE gt_allocnum INTO wa_allocnum WITH KEY charact = gt_class-rcdin.

        if sy-subrc = 0.                                                                  

          wa_allocnum-charact = wa_char_struc-name_char.

          wa_allocnum-value_from = gt_class-rinal.

          wa_allocnum-unit_from = 'VIS'.

          wa_allocnum-value_relation = '1'.

          wa_allocnum-unit_from_iso = 'ANZ'.

*          If NOT gt_class-rinal is INITIAL.                          

            MODIFY gt_allocnum FROM wa_allocnum INDEX sy-tabix TRANSPORTING value_from unit_from value_relation unit_from_iso.

*          else.                                                      

*            DELETE gt_allocnum WHERE charact = wa_allocnum-charact.  

*          endif.                                                     

        endif.

      ENDIF.

    ENDLOOP.

    CALL FUNCTION 'BAPI_OBJCL_CHANGE'

EXPORTING

  objectkey                = wa_objectkey

  objecttable              = 'JGVGPKLASS'

  classnum                 = 'CLIENTI'

  classtype                = '071'

   STATUS                  = '1'

*   STANDARDCLASS            =

*   CHANGENUMBER             =

*   KEYDATE                  = SY-DATUM

*   NO_DEFAULT_VALUES        = ' '

* IMPORTING

*   CLASSIF_STATUS           =

TABLES

  allocvaluesnumnew        = gt_allocnum

  allocvaluescharnew       = gt_allocchar

  allocvaluescurrnew       = gt_alloccurr

  return                   = gt_return.

Read only

0 Likes
4,179

this code is before the code over...

CALL FUNCTION 'BAPI_OBJCL_GETDETAIL'

       EXPORTING

         objectkey       = wa_objectkey

         objecttable     = 'BUT001'

         classnum        = 'CLIENTI'

         classtype       = '071'

         keydate         = sy-datum

         language        = sy-langu

       TABLES

         allocvaluesnum  = gt_allocnum

         allocvalueschar = gt_allocchar

         allocvaluescurr = gt_alloccurr

         return          = gt_return.

     .

     CALL FUNCTION 'BAPI_CLASS_GET_CHARACTERISTICS'

       EXPORTING

         classnum        = 'CLIENTI'

         classtype       = '071'

*       LANGU_ISO       =

*       LANGU_INT       =

*       KEY_DATE        = SY-DATUM

*       WITH_VALUES     = 'X'

       IMPORTING

         return          = bapi_ret

       TABLES

         characteristics = char_struc

         char_values     = char_val.

In gt_class we have all the characteristcs about the class.

You can se the line with * about the "delete" logic.

Thanks.

Alessio

Read only

alessio_pierfederici
Participant
0 Likes
4,179

Hi gurus!

Performing additional tests, I noticed that the problem is limited to the characteristics of type CHAR.

With types CURR and NUM passing the empty value, the value of the characteristic is cleaned.

Could you tell me how to deal with the characteristics of type char , to clean up the value?

Regards Alessio