SAP for Utilities Discussions
Connect with fellow SAP users to share best practices, troubleshoot challenges, and collaborate on building a sustainable energy future. Join the discussion.
cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI/ Function module to Meter Mechanism Code Equipment

Former Member
0 Kudos

Hi Experts,

I have a requirement to update Meter Mechanism Code for the Equipment. We can do this using transaction IQ02, but I have to do the update for bulk data. Meter Mechanism Code is stored in table AUSP (but updating AUSP table directly is not recommended). So I need to update Meter Mechanism Code using some BAPI/ Function module.

Could you please suggest BAPI/ Function module to Meter Mechanism Code for the Equipment.

Thanks in advance,

Dipin

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Thanks Asif and Chandan

I have passed below values into FM BAPI_OBJCL_CHANGE and Meter Mechanism Code is getting updated.

wa_allocvaluescharnew-charact = 'METER_MECHANISM_CODE'. (Chack the name of the characteristic in your system)
wa_allocvaluescharnew-value_char = 'XYZ'. (Provide the value of the characteristics)

But other values (Payment Method, Measuring Capacity…) got deleted.

Do I need to pass the existing values (Payment Method, Measuring Capacity…) to the FM or is there any other way to update only a particular value (i.e.  Meter Mechanism Code) and keeping the existing values as it is.

Regards,

Dipin

View solution in original post

9 REPLIES 9

Former Member
0 Kudos

Hi Dipin,

You can refer the link here for the answer -

Hope this helps!

Regards,

Asif

former_member227287
Active Participant
0 Kudos

Hi Dipin,

You can use the BAPI '  BAPI_OBJCL_CHANGE'. to achieve this.

lv_equnr will have the equipment no. Make sure to append the leading zeroes to it.

See the code snippet below.

DATA : lv_equnr TYPE bapi1003_key-object

DATA allocvaluescharnew TYPE STANDARD TABLE OF bapi1003_alloc_values_char.
DATA wa_allocvaluescharnew LIKE LINE OF allocvaluescharnew.

DATA return             TYPE STANDARD TABLE OF bapiret2.

lv_equnr = '000000000010000305'.

wa_allocvaluescharnew-charact = 'METER_MECHANISM_CODE'. (Chack the name of the characteristic in your system)
wa_allocvaluescharnew-value_char = 'XYZ'. (Provide the value of the characteristics)

APPEND wa_allocvaluescharnew TO allocvaluescharnew.

   CALL FUNCTION 'BAPI_OBJCL_CHANGE'
  EXPORTING
    objectkey          = lv_equnr
    objecttable        = 'EQUI'
    classnum           = 'Z_GMETER'
    classtype          = 'IS2'
*   STATUS             = '1'
*   STANDARDCLASS      = STANDARDCLASS
*   CHANGENUMBER       = CHANGENUMBER
    keydate            = sy-datum
*   NO_DEFAULT_VALUES  = ' '
*   IMPORTING
*   CLASSIF_STATUS     = CLASSIF_STATUS
  TABLES
    allocvaluesnumnew  = allocvaluesnumnew
    allocvaluescharnew = allocvaluescharnew
    allocvaluescurrnew = allocvaluescurrnew
    return             = return.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
  EXPORTING
    wait = 'X'.

Regards,

Chandan

Former Member
0 Kudos

Thanks Asif and Chandan

I have passed below values into FM BAPI_OBJCL_CHANGE and Meter Mechanism Code is getting updated.

wa_allocvaluescharnew-charact = 'METER_MECHANISM_CODE'. (Chack the name of the characteristic in your system)
wa_allocvaluescharnew-value_char = 'XYZ'. (Provide the value of the characteristics)

But other values (Payment Method, Measuring Capacity…) got deleted.

Do I need to pass the existing values (Payment Method, Measuring Capacity…) to the FM or is there any other way to update only a particular value (i.e.  Meter Mechanism Code) and keeping the existing values as it is.

Regards,

Dipin

0 Kudos

Hi Dipin,

You will first have to get all the existing charactersitics details using "BAPI_OBJCL_GETDETAIL" and then call the other one i.e. BAPI_OBJCL_GETDETAIL, to update only the meter mech code by which the other values will remain unchanged.

Hope this helps!

Asif

0 Kudos

Hi Dipin,

Please see the code snippet below.

DATA allocvaluesnumnew  TYPE STANDARD TABLE OF bapi1003_alloc_values_num.
DATA allocvaluescharnew TYPE STANDARD TABLE OF bapi1003_alloc_values_char.
DATA allocvaluescurrnew TYPE STANDARD TABLE OF bapi1003_alloc_values_curr.
DATA return             TYPE STANDARD TABLE OF bapiret2.
FIELD-SYMBOLS  <fs_allocvaluescharnew> LIKE LINE OF allocvaluescharnew.

DATA : lv_equnr TYPE bapi1003_key-object.
lv_equnr =  '000000000010000305'.

CALL FUNCTION 'BAPI_OBJCL_GETDETAIL'
  EXPORTING
    objectkey       = lv_equnr
    objecttable     = 'EQUI'
    classnum        = 'Z_GMETER'
    classtype       = 'IS2'
    keydate         = sy-datum
*   UNVALUATED_CHARS       = ' '
*   LANGUAGE        = SY-LANGU
* IMPORTING
*   STATUS          = STATUS
*   STANDARDCLASS   = STANDARDCLASS
  TABLES
    allocvaluesnum  = allocvaluesnumnew
    allocvalueschar = allocvaluescharnew
    allocvaluescurr = allocvaluescurrnew
    return          = return.
IF sy-subrc = 0.
  READ TABLE allocvaluescharnew ASSIGNING <fs_allocvaluescharnew> WITH KEY charact = 'METER_MECHANISM_CODE'.
  IF sy-subrc  = 0.
    <fs_allocvaluescharnew>-value_char = '11'.(give the new characteristic value here).
    <fs_allocvaluescharnew>-value_neutral = '11'.(give the new characteristic value here).
  ENDIF.
ENDIF.

CALL FUNCTION 'BAPI_OBJCL_CHANGE'
  EXPORTING
    objectkey          = lv_equnr
    objecttable        = 'EQUI'
    classnum           = 'Z_GMETER'
    classtype          = 'IS2'
*   STATUS             = '1'
*   STANDARDCLASS      = STANDARDCLASS
*   CHANGENUMBER       = CHANGENUMBER
    keydate            = sy-datum
*   NO_DEFAULT_VALUES  = ' '
*   IMPORTING
*   CLASSIF_STATUS     = CLASSIF_STATUS
  TABLES
    allocvaluesnumnew  = allocvaluesnumnew
    allocvaluescharnew = allocvaluescharnew
    allocvaluescurrnew = allocvaluescurrnew
    return             = return.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
  EXPORTING
    wait = 'X'.

Regards,

Chandan

0 Kudos

Hi Chandan,

Thanks a lot

Could you please tell how to update Certification Expiry Date for the Equipment..

Thanks in advance,

Dipin

0 Kudos


Hi Dipin,

To update the Certification Expiry Date, follow the same procedure as i have mentioned earlier. You need to explore the FM also refer the documentation of the function Module.

Regards,

Chandan.

former_member227287
Active Participant
0 Kudos

Hi Dipin,

Can you please close this thread if your query is answered?

Regards,

Chandan

Former Member
0 Kudos

Thanks a lot Chandan and Asif for your help.

Regards,

Dipin