Skip to Content

Probelm in updating the contract net pice with BAPI_CONTRACT_CHANGE

Hello all,

I have requirement where i am trying to change contract net price (from Excel file),

i have used BAPI_CONTRACT_CHANGE,

my problem is after updating the netprice through above BAPI,

deletion indicator is set for condition types other than 'P000' (here my requirement is to update price for condition type 'P000' only)

after updating the net price (i.e P000 ex-works ) with amount 800

deletion indicator is set for other condition types,

may i know why this is happening,

TYPE-POOLS: truxs.

data :  lv_file1 type rlgrap-filename.

data : it_raw TYPE truxs_t_text_data.

data : BEGIN OF wa_ekpo,

       ebeln type ekpo-ebeln,

       ebelp type ekpo-ebelp,

       netpr type ekpo-netpr,

       peinh type ekpo-peinh,

       END OF wa_ekpo.

data : it_ekpo like TABLE OF wa_ekpo.



data : wa_return type BAPIRET2,

       it_return type TABLE OF BAPIRET2.

data : wa_cond type BAPIMEOUTCONDITION,

       it_cond type STANDARD TABLE OF  BAPIMEOUTCONDITION,

       wa_condx type BAPIMEOUTCONDITIONX,

       it_condx type TABLE OF BAPIMEOUTCONDITIONX,

       wa_val type BAPIMEOUTVALIDITY,

       it_val type TABLE OF BAPIMEOUTVALIDITY,

       wa_valx type BAPIMEOUTVALIDITYX,

       it_valx type TABLE OF BAPIMEOUTVALIDITYX,

       wa_item type BAPIMEOUTITEM,

       it_item type STANDARD TABLE OF BAPIMEOUTITEM,



       wa_itemx type BAPIMEOUTITEMX,

       it_itemx TYPE STANDARD TABLE OF BAPIMEOUTITEMX.



*declaration for BAPI_CONTRACT_GETDETAIL ***************************

data : wa_get_cond_val type BAPIMEOUTVALIDITY,

       get_cond_val type TABLE OF BAPIMEOUTVALIDITY.


data : wa_get_cond type BAPIMEOUTCONDITION,

       get_cond type TABLE OF BAPIMEOUTCONDITION.


data : wa_get_item type BAPIMEOUTITEM,

       get_item type table of BAPIMEOUTITEM.

data : lv_serial_id type BAPIMEOUTCONDITION-SERIAL_ID.

****************sel screen declaration *******************************

SELECTION-SCREEN BEGIN OF block b1 WITH FRAME TITLE text-001.
  SELECTION-SCREEN SKIP 1.
  PARAMETERS : pfile1 type RLGRAP-FILENAME OBLIGATORY.
 SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN end of BLOCK b1.
**********************************************************************

AT SELECTION-SCREEN on VALUE-REQUEST FOR pfile1.

   CALL FUNCTION 'F4_FILENAME'

   EXPORTING

     PROGRAM_NAME        = SYST-CPROG

     DYNPRO_NUMBER       = SYST-DYNNR

     FIELD_NAME          = 'pfile1'

   IMPORTING

     FILE_NAME           = pfile1.




START-OF-SELECTION.
  if pfile1 IS not INITIAL.
    lv_file1 = pfile1.
  endif.



  IF lv_file1 IS NOT INITIAL.

   CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

      EXPORTING

        i_tab_raw_data       = it_raw

        i_filename           = lv_file1

      TABLES

        i_tab_converted_data = it_ekpo

      EXCEPTIONS

        conversion_failed    = 1

        OTHERS               = 2.



    IF sy-subrc <> 0.

      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ELSE.

      MESSAGE s368(00) WITH text-004.

    ENDIF.



  ENDIF.


 loop at it_ekpo into wa_ekpo.

 clear : lv_serial_id.

 REFRESH : get_item, get_cond_val, get_cond.


   CALL FUNCTION 'BAPI_CONTRACT_GETDETAIL'

     EXPORTING

       PURCHASINGDOCUMENT          = wa_ekpo-ebeln

       ITEM_DATA                   = 'X'

       CONDITION_DATA              = 'X'

     TABLES

       item                        = get_item

       ITEM_COND_VALIDITY          = get_cond_val

       ITEM_CONDITION              = get_cond.




 delete get_cond where item_no ne wa_ekpo-ebelp.

  delete get_cond where cond_type ne 'P000'.

  delete ADJACENT DUPLICATES FROM get_cond COMPARING cond_type.



  delete get_cond_val WHERE item_no ne wa_ekpo-ebelp.

  delete ADJACENT DUPLICATES FROM get_cond_val COMPARING serial_id.



 loop at get_cond into wa_get_cond.

  IF sy-tabix EQ 1.

     wa_get_cond-COND_VALUE = wa_ekpo-netpr.

     wa_get_cond-COND_P_UNT = wa_ekpo-peinh.

     wa_get_cond-change_id = 'U'.

MODIFY get_cond FROM wa_get_cond TRANSPORTING COND_VALUE COND_P_UNT change_id WHERE ITEM_NO eq wa_ekpo-ebelp and cond_type eq 'P000'.

     lv_serial_id = wa_get_cond-SERIAL_ID.

   endif.
 endloop.



* wa_val-ITEM_NO = wa_ekpo-ebelp.

* wa_val-SERIAL_ID = wa_ekpo-SERIAL_ID.

* wa_val-VALID_FROM = wa_ekpo-VALID_FROM.

* wa_val-VALID_TO = wa_ekpo-VALID_TO.

* APPEND wa_val to it_val.

*

wa_valx-ITEM_NO = wa_ekpo-ebelp.

wa_valx-VALID_FROM = 'X'.

wa_valx-VALID_TO = 'X'.

APPEND wa_valx to it_valx.





* wa_cond-ITEM_NO = wa_ekpo-ebelp.

* wa_cond-SERIAL_ID = wa_ekpo-SERIAL_ID.

* wa_cond-COND_VALUE = wa_ekpo-netpr.

* wa_cond-COND_P_UNT = wa_ekpo-peinh.

* wa_cond-change_id = 'U'.

* APPEND wa_cond to it_cond.





wa_condx-ITEM_NO = wa_ekpo-ebelp.

wa_condx-SERIAL_ID = lv_serial_id.

wa_condx-COND_VALUE = 'X'.

wa_condx-COND_P_UNT = 'X'.

APPEND wa_condx to it_condx.





*loop at get_cond_val into wa_get_Cond_val.

*

*

*

*  wa_get_cond_val-VALID_FROM = wa_get_cond_val-valid_from.

*  wa_get_cond_val-valid_to = wa_get_cond_val-valid_to.

*

*  MODIFY get_cond_val FROM wa_get_cond_val TRANSPORTING valid_from valid_to  WHERE SERIAL_ID eq lv_serial_id.

*

*

*

*endloop.





wa_itemx-ITEM_NO = wa_ekpo-ebelp.

wa_itemx-ITEM_NOX = 'X'.

wa_itemx-NET_PRICE = 'X'.

wa_itemx-PRICE_UNIT = 'X'.

append wa_itemx to it_itemx.





  CALL FUNCTION 'BAPI_CONTRACT_CHANGE'

    EXPORTING

      PURCHASINGDOCUMENT          = wa_ekpo-ebeln

*     HEADER                      =

*     HEADERX                     =

*     VENDOR_ADDRESS              =

*     TESTRUN                     =

*     TECHNICAL_DATA              =

*   IMPORTING

*     EXP_HEADER                  =

   TABLES

      ITEM                        = get_item

      ITEMX                       = it_itemx

*     ACCOUNT                     =

*     ACCOUNTPROFITSEGMENT        =

*     ACCOUNTX                    =

*     DELIVERY_ADDRESS            =

      ITEM_COND_VALIDITY          = get_cond_val

      ITEM_COND_VALIDITYX         = it_valx

      ITEM_CONDITION              = get_cond

      ITEM_CONDITIONX             = it_condx

*     ITEM_COND_SCALE_VALUE       =

*     ITEM_COND_SCALE_QUAN        =

*     ITEM_TEXT                   =

*     HEADER_TEXT                 =

*     HEAD_COND_VALIDITY          =

*     HEAD_COND_VALIDITYX         =

*     HEAD_CONDITION              =

*     HEAD_CONDITIONX             =

*     HEAD_COND_SCALE_VAL         =

*     HEAD_COND_SCALE_QUAN        =

*     PARTNER                     =

*     PARTNERX                    =

*     RELEASE_DOCU                =

*     EXTENSIONIN                 =

*     EXTENSIONOUT                =

      RETURN                      = it_return.

 READ TABLE it_return into wa_return with key type = 'E'.
  if sy-subrc ne 0.


    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

      EXPORTING

        WAIT          = 'X'.

    MESSAGE 'Record Updated Successfully' TYPE 'S'.
  else.
      CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.


 endif.

  clear : wa_ekpo.
  endloop.
5600000201.jpg (159.3 kB)
5600000201-1.jpg (80.5 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Jan 24 at 12:06 PM

    Please check with F'consultant about this whether they have control om that .

    Regards,

    Kavi

    Add comment
    10|10000 characters needed characters exceeded