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

BAPI_PRICES_CONDITIONS Create new interval

FredericGirod
Active Contributor
0 Likes
4,030

Hi,

I would like to use the function BAPI_PRICES_CONDITIONS to create new range of date.

Ex:

Before

Condition_1 01.01.2001 --> 31.12.9999

After

Condition_1 01.01.2001 --> 14.08.2007

Condition_2 15.08.2007 --> 31.12.9999

I have no problem to create new condition, my problem is to modify the condition_1 to change the datbi from 31.12.9999 to the new value (in my example 14.08.2007).

If someone have an idea

Thanks

Fred

1 ACCEPTED SOLUTION
Read only

FredericGirod
Active Contributor
0 Likes
2,916

Nobody for this BAPI ?

Hi,

I would like to use the function BAPI_PRICES_CONDITIONS to create new range of date.

Ex:

Before

Condition_1 01.01.2001 --> 31.12.9999

After

Condition_1 01.01.2001 --> 14.08.2007

Condition_2 15.08.2007 --> 31.12.9999

I have no problem to create new condition, my problem is to modify the condition_1 to change the datbi from 31.12.9999 to the new value (in my example 14.08.2007).

If someone have an idea

Thanks

Fred

11 REPLIES 11
Read only

FredericGirod
Active Contributor
0 Likes
2,917

Nobody for this BAPI ?

Read only

0 Likes
2,916

if it's working properly the date of the first condition must be automatically altered when the second is entered.

when you do it manually in vk11 it works that way. I don't see why the bapi should behave different.

have you verified that the first condition isn't changed ?

Message was edited by:

A. de Smidt

Read only

0 Likes
2,916

When I just use the BAPI to change the VALID_TO, it creates a new entry. Maybe because the VALID_TO is a part of the KEY of Axxx tables.

After that I have errors in the transaction VK+C of period covering.

When I debug this BAPI, there is code to remove the deletion flag, and other code that read a table from memory to make deletion. My feeling is that this bapi can't be use alone for complex work and I need to prepare memory with CND_MAP_KNUMH... functions.

Fred

Read only

0 Likes
2,916

so when you have a valid from date and a valid to date for entering a condition . when you look in vk13 you see 2 conditions both to 31129999 ??

here is an example of a code I use for this bapi, hope it helps


DATA: ta_bapicondct  TYPE bapicondct OCCURS 0.
DATA: ta_bapicondhd  TYPE bapicondhd OCCURS 0.
DATA: ta_bapicondit  TYPE bapicondit OCCURS 0.
DATA: ta_bapicondqs  TYPE bapicondqs OCCURS 0.
DATA: ta_bapicondvs  TYPE bapicondvs OCCURS 0.
DATA: ta_bapiret2 TYPE  bapiret2  OCCURS 0.
DATA: ret TYPE  bapiret2.

DATA: ta_bapiknumhs TYPE bapiknumhs OCCURS 0.
DATA: ta_mem_initial TYPE cnd_mem_initial OCCURS 0.

DATA: wa_bapicondct  LIKE lINE OF ta_bapicondct.
DATA: wa_bapicondhd  LIKE lINE OF ta_bapicondhd.
DATA: wa_bapicondit  LIKE lINE OF ta_bapicondit.

data: h_varkey(100).
data: h_cond_unit type meins.

concatenate i_vkorg i_vtweg i_matnr into h_varkey.
select single meins from mara
             into h_cond_unit
             where matnr = i_matnr.

select single * from mvke
                    where matnr = i_matnr
                    and vkorg = i_vkorg.
if sy-subrc <> 0.
  raise vkorgerror.
endif.

*conditietabel
wa_bapicondct-table_no = '004'.
wa_bapicondct-applicatio = 'V'.
wa_bapicondct-cond_usage = 'A'.
wa_bapicondct-cond_type = I_COND_TYPE.
wa_bapicondct-operation = '009'.
wa_bapicondct-varkey = h_varkey.
wa_bapicondct-valid_to = I_VALID_TO.
wa_bapicondct-valid_from = I_VALID_FROM.
wa_bapicondct-cond_no = '
DATA: ta_bapicondct  TYPE bapicondct OCCURS 0.
DATA: ta_bapicondhd  TYPE bapicondhd OCCURS 0.
DATA: ta_bapicondit  TYPE bapicondit OCCURS 0.
DATA: ta_bapicondqs  TYPE bapicondqs OCCURS 0.
DATA: ta_bapicondvs  TYPE bapicondvs OCCURS 0.
DATA: ta_bapiret2 TYPE  bapiret2  OCCURS 0.
DATA: ret TYPE  bapiret2.

DATA: ta_bapiknumhs TYPE bapiknumhs OCCURS 0.
DATA: ta_mem_initial TYPE cnd_mem_initial OCCURS 0.

DATA: wa_bapicondct  LIKE lINE OF ta_bapicondct.
DATA: wa_bapicondhd  LIKE lINE OF ta_bapicondhd.
DATA: wa_bapicondit  LIKE lINE OF ta_bapicondit.

data: h_varkey(100).
data: h_cond_unit type meins.

concatenate i_vkorg i_vtweg i_matnr into h_varkey.
select single meins from mara
             into h_cond_unit
             where matnr = i_matnr.

select single * from mvke
                    where matnr = i_matnr
                    and vkorg = i_vkorg.
if sy-subrc <> 0.
  raise vkorgerror.
endif.

*conditietabel
wa_bapicondct-table_no = '004'.
wa_bapicondct-applicatio = 'V'.
wa_bapicondct-cond_usage = 'A'.
wa_bapicondct-cond_type = I_COND_TYPE.
wa_bapicondct-operation = '009'.
wa_bapicondct-varkey = h_varkey.
wa_bapicondct-valid_to = I_VALID_TO.
wa_bapicondct-valid_from = I_VALID_FROM.
wa_bapicondct-cond_no = '$000000001'.

APPEND wa_bapicondct TO ta_bapicondct.

*KONH
wa_bapicondhd-operation = '009'.
wa_bapicondhd-cond_no = '$000000001'.
wa_bapicondhd-created_by = sy-uname.
wa_bapicondhd-creat_date = sy-datum.
wa_bapicondhd-cond_usage = 'A'.
wa_bapicondhd-table_no = '004'.
wa_bapicondhd-applicatio = 'V'.
wa_bapicondhd-cond_type = I_COND_TYPE.
wa_bapicondhd-varkey = h_varkey.
wa_bapicondhd-valid_from = I_VALID_FROM.
wa_bapicondhd-valid_to = I_VALID_TO.


APPEND wa_bapicondhd TO ta_bapicondhd.


*KONP tabel
wa_bapicondit-operation = '009'.
wa_bapicondit-cond_no = '$000000001'.
wa_bapicondit-cond_count = '01'.
wa_bapicondit-applicatio = 'V'.
wa_bapicondit-cond_type = I_COND_TYPE.
wa_bapicondit-scaletype = 'A'.       "STFKZ Staffelsoort
wa_bapicondit-scalebasin = 'C'.      "KZBZG Teken:rekeneenheid
wa_bapicondit-scale_qty = '1'.       "KSTBM Conditiestaffelbasis hoeveelheid
wa_bapicondit-cond_p_unt = '1'.      "KPEIN prijseenheid
wa_bapicondit-cond_unit = h_cond_unit.      "KMEIN Conditie-hoeveelheidseenheid
wa_bapicondit-calctypcon = 'C'.      "KRECH Conditie-rekenregel
wa_bapicondit-cond_value = I_COND_VALUE.
wa_bapicondit-condcurr = 'EUR'.

APPEND wa_bapicondit TO ta_bapicondit.


CALL FUNCTION 'BAPI_PRICES_CONDITIONS'
* EXPORTING
*   PI_INITIALMODE       = 'X'
*   PI_BLOCKNUMBER       =
  TABLES
    ti_bapicondct        = ta_bapicondct
    ti_bapicondhd        = ta_bapicondhd
    ti_bapicondit        = ta_bapicondit
    ti_bapicondqs        = ta_bapicondqs
    ti_bapicondvs        = ta_bapicondvs
    to_bapiret2          = ta_bapiret2
    to_bapiknumhs        = ta_bapiknumhs
    to_mem_initial       = ta_mem_initial
 EXCEPTIONS
   UPDATE_ERROR         = 1
   OTHERS               = 2
          .

if sy-subrc = 1.
  raise update_error.
endif.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
*EXPORTING
* WAIT =
IMPORTING
 return = ret.

'.

APPEND wa_bapicondct TO ta_bapicondct.

*KONH
wa_bapicondhd-operation = '009'.
wa_bapicondhd-cond_no = '
DATA: ta_bapicondct  TYPE bapicondct OCCURS 0.
DATA: ta_bapicondhd  TYPE bapicondhd OCCURS 0.
DATA: ta_bapicondit  TYPE bapicondit OCCURS 0.
DATA: ta_bapicondqs  TYPE bapicondqs OCCURS 0.
DATA: ta_bapicondvs  TYPE bapicondvs OCCURS 0.
DATA: ta_bapiret2 TYPE  bapiret2  OCCURS 0.
DATA: ret TYPE  bapiret2.

DATA: ta_bapiknumhs TYPE bapiknumhs OCCURS 0.
DATA: ta_mem_initial TYPE cnd_mem_initial OCCURS 0.

DATA: wa_bapicondct  LIKE lINE OF ta_bapicondct.
DATA: wa_bapicondhd  LIKE lINE OF ta_bapicondhd.
DATA: wa_bapicondit  LIKE lINE OF ta_bapicondit.

data: h_varkey(100).
data: h_cond_unit type meins.

concatenate i_vkorg i_vtweg i_matnr into h_varkey.
select single meins from mara
             into h_cond_unit
             where matnr = i_matnr.

select single * from mvke
                    where matnr = i_matnr
                    and vkorg = i_vkorg.
if sy-subrc <> 0.
  raise vkorgerror.
endif.

*conditietabel
wa_bapicondct-table_no = '004'.
wa_bapicondct-applicatio = 'V'.
wa_bapicondct-cond_usage = 'A'.
wa_bapicondct-cond_type = I_COND_TYPE.
wa_bapicondct-operation = '009'.
wa_bapicondct-varkey = h_varkey.
wa_bapicondct-valid_to = I_VALID_TO.
wa_bapicondct-valid_from = I_VALID_FROM.
wa_bapicondct-cond_no = '$000000001'.

APPEND wa_bapicondct TO ta_bapicondct.

*KONH
wa_bapicondhd-operation = '009'.
wa_bapicondhd-cond_no = '$000000001'.
wa_bapicondhd-created_by = sy-uname.
wa_bapicondhd-creat_date = sy-datum.
wa_bapicondhd-cond_usage = 'A'.
wa_bapicondhd-table_no = '004'.
wa_bapicondhd-applicatio = 'V'.
wa_bapicondhd-cond_type = I_COND_TYPE.
wa_bapicondhd-varkey = h_varkey.
wa_bapicondhd-valid_from = I_VALID_FROM.
wa_bapicondhd-valid_to = I_VALID_TO.


APPEND wa_bapicondhd TO ta_bapicondhd.


*KONP tabel
wa_bapicondit-operation = '009'.
wa_bapicondit-cond_no = '$000000001'.
wa_bapicondit-cond_count = '01'.
wa_bapicondit-applicatio = 'V'.
wa_bapicondit-cond_type = I_COND_TYPE.
wa_bapicondit-scaletype = 'A'.       "STFKZ Staffelsoort
wa_bapicondit-scalebasin = 'C'.      "KZBZG Teken:rekeneenheid
wa_bapicondit-scale_qty = '1'.       "KSTBM Conditiestaffelbasis hoeveelheid
wa_bapicondit-cond_p_unt = '1'.      "KPEIN prijseenheid
wa_bapicondit-cond_unit = h_cond_unit.      "KMEIN Conditie-hoeveelheidseenheid
wa_bapicondit-calctypcon = 'C'.      "KRECH Conditie-rekenregel
wa_bapicondit-cond_value = I_COND_VALUE.
wa_bapicondit-condcurr = 'EUR'.

APPEND wa_bapicondit TO ta_bapicondit.


CALL FUNCTION 'BAPI_PRICES_CONDITIONS'
* EXPORTING
*   PI_INITIALMODE       = 'X'
*   PI_BLOCKNUMBER       =
  TABLES
    ti_bapicondct        = ta_bapicondct
    ti_bapicondhd        = ta_bapicondhd
    ti_bapicondit        = ta_bapicondit
    ti_bapicondqs        = ta_bapicondqs
    ti_bapicondvs        = ta_bapicondvs
    to_bapiret2          = ta_bapiret2
    to_bapiknumhs        = ta_bapiknumhs
    to_mem_initial       = ta_mem_initial
 EXCEPTIONS
   UPDATE_ERROR         = 1
   OTHERS               = 2
          .

if sy-subrc = 1.
  raise update_error.
endif.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
*EXPORTING
* WAIT =
IMPORTING
 return = ret.

'.
wa_bapicondhd-created_by = sy-uname.
wa_bapicondhd-creat_date = sy-datum.
wa_bapicondhd-cond_usage = 'A'.
wa_bapicondhd-table_no = '004'.
wa_bapicondhd-applicatio = 'V'.
wa_bapicondhd-cond_type = I_COND_TYPE.
wa_bapicondhd-varkey = h_varkey.
wa_bapicondhd-valid_from = I_VALID_FROM.
wa_bapicondhd-valid_to = I_VALID_TO.


APPEND wa_bapicondhd TO ta_bapicondhd.


*KONP tabel
wa_bapicondit-operation = '009'.
wa_bapicondit-cond_no = '
DATA: ta_bapicondct  TYPE bapicondct OCCURS 0.
DATA: ta_bapicondhd  TYPE bapicondhd OCCURS 0.
DATA: ta_bapicondit  TYPE bapicondit OCCURS 0.
DATA: ta_bapicondqs  TYPE bapicondqs OCCURS 0.
DATA: ta_bapicondvs  TYPE bapicondvs OCCURS 0.
DATA: ta_bapiret2 TYPE  bapiret2  OCCURS 0.
DATA: ret TYPE  bapiret2.

DATA: ta_bapiknumhs TYPE bapiknumhs OCCURS 0.
DATA: ta_mem_initial TYPE cnd_mem_initial OCCURS 0.

DATA: wa_bapicondct  LIKE lINE OF ta_bapicondct.
DATA: wa_bapicondhd  LIKE lINE OF ta_bapicondhd.
DATA: wa_bapicondit  LIKE lINE OF ta_bapicondit.

data: h_varkey(100).
data: h_cond_unit type meins.

concatenate i_vkorg i_vtweg i_matnr into h_varkey.
select single meins from mara
             into h_cond_unit
             where matnr = i_matnr.

select single * from mvke
                    where matnr = i_matnr
                    and vkorg = i_vkorg.
if sy-subrc <> 0.
  raise vkorgerror.
endif.

*conditietabel
wa_bapicondct-table_no = '004'.
wa_bapicondct-applicatio = 'V'.
wa_bapicondct-cond_usage = 'A'.
wa_bapicondct-cond_type = I_COND_TYPE.
wa_bapicondct-operation = '009'.
wa_bapicondct-varkey = h_varkey.
wa_bapicondct-valid_to = I_VALID_TO.
wa_bapicondct-valid_from = I_VALID_FROM.
wa_bapicondct-cond_no = '$000000001'.

APPEND wa_bapicondct TO ta_bapicondct.

*KONH
wa_bapicondhd-operation = '009'.
wa_bapicondhd-cond_no = '$000000001'.
wa_bapicondhd-created_by = sy-uname.
wa_bapicondhd-creat_date = sy-datum.
wa_bapicondhd-cond_usage = 'A'.
wa_bapicondhd-table_no = '004'.
wa_bapicondhd-applicatio = 'V'.
wa_bapicondhd-cond_type = I_COND_TYPE.
wa_bapicondhd-varkey = h_varkey.
wa_bapicondhd-valid_from = I_VALID_FROM.
wa_bapicondhd-valid_to = I_VALID_TO.


APPEND wa_bapicondhd TO ta_bapicondhd.


*KONP tabel
wa_bapicondit-operation = '009'.
wa_bapicondit-cond_no = '$000000001'.
wa_bapicondit-cond_count = '01'.
wa_bapicondit-applicatio = 'V'.
wa_bapicondit-cond_type = I_COND_TYPE.
wa_bapicondit-scaletype = 'A'.       "STFKZ Staffelsoort
wa_bapicondit-scalebasin = 'C'.      "KZBZG Teken:rekeneenheid
wa_bapicondit-scale_qty = '1'.       "KSTBM Conditiestaffelbasis hoeveelheid
wa_bapicondit-cond_p_unt = '1'.      "KPEIN prijseenheid
wa_bapicondit-cond_unit = h_cond_unit.      "KMEIN Conditie-hoeveelheidseenheid
wa_bapicondit-calctypcon = 'C'.      "KRECH Conditie-rekenregel
wa_bapicondit-cond_value = I_COND_VALUE.
wa_bapicondit-condcurr = 'EUR'.

APPEND wa_bapicondit TO ta_bapicondit.


CALL FUNCTION 'BAPI_PRICES_CONDITIONS'
* EXPORTING
*   PI_INITIALMODE       = 'X'
*   PI_BLOCKNUMBER       =
  TABLES
    ti_bapicondct        = ta_bapicondct
    ti_bapicondhd        = ta_bapicondhd
    ti_bapicondit        = ta_bapicondit
    ti_bapicondqs        = ta_bapicondqs
    ti_bapicondvs        = ta_bapicondvs
    to_bapiret2          = ta_bapiret2
    to_bapiknumhs        = ta_bapiknumhs
    to_mem_initial       = ta_mem_initial
 EXCEPTIONS
   UPDATE_ERROR         = 1
   OTHERS               = 2
          .

if sy-subrc = 1.
  raise update_error.
endif.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
*EXPORTING
* WAIT =
IMPORTING
 return = ret.

'.
wa_bapicondit-cond_count = '01'.
wa_bapicondit-applicatio = 'V'.
wa_bapicondit-cond_type = I_COND_TYPE.
wa_bapicondit-scaletype = 'A'.       "STFKZ Staffelsoort
wa_bapicondit-scalebasin = 'C'.      "KZBZG Teken:rekeneenheid
wa_bapicondit-scale_qty = '1'.       "KSTBM Conditiestaffelbasis hoeveelheid
wa_bapicondit-cond_p_unt = '1'.      "KPEIN prijseenheid
wa_bapicondit-cond_unit = h_cond_unit.      "KMEIN Conditie-hoeveelheidseenheid
wa_bapicondit-calctypcon = 'C'.      "KRECH Conditie-rekenregel
wa_bapicondit-cond_value = I_COND_VALUE.
wa_bapicondit-condcurr = 'EUR'.

APPEND wa_bapicondit TO ta_bapicondit.


CALL FUNCTION 'BAPI_PRICES_CONDITIONS'
* EXPORTING
*   PI_INITIALMODE       = 'X'
*   PI_BLOCKNUMBER       =
  TABLES
    ti_bapicondct        = ta_bapicondct
    ti_bapicondhd        = ta_bapicondhd
    ti_bapicondit        = ta_bapicondit
    ti_bapicondqs        = ta_bapicondqs
    ti_bapicondvs        = ta_bapicondvs
    to_bapiret2          = ta_bapiret2
    to_bapiknumhs        = ta_bapiknumhs
    to_mem_initial       = ta_mem_initial
 EXCEPTIONS
   UPDATE_ERROR         = 1
   OTHERS               = 2
          .

if sy-subrc = 1.
  raise update_error.
endif.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
*EXPORTING
* WAIT =
IMPORTING
 return = ret.

Message was edited by:

A. de Smidt

Read only

0 Likes
2,916

Yep I have inconsistency.

I have found the solution, I need to use some function CND_MAP_KNUMH ...

I put my sample code, if somebody will have the same problem :



  DATA : it_condct TYPE TABLE OF bapicondct      WITH HEADER LINE ,
         it_condhd TYPE TABLE OF bapicondhd      WITH HEADER LINE ,
         it_condit TYPE TABLE OF bapicondit      WITH HEADER LINE ,
         it_condqs TYPE TABLE OF bapicondqs      WITH HEADER LINE ,
         it_condvs TYPE TABLE OF bapicondvs      WITH HEADER LINE ,
         it_return TYPE TABLE OF bapiret2        WITH HEADER LINE ,
         it_knumh  TYPE TABLE OF bapiknumhs      WITH HEADER LINE ,
         it_mem    TYPE TABLE OF cnd_mem_initial WITH HEADER LINE ,

         is_crmsfk TYPE          bapicrmsfk.


* Set data.
  MOVE : is_data-kschl   TO it_condct-cond_type ,
         is_data-knumh   TO it_condct-cond_no ,
         is_data-vakey   TO it_condct-varkey ,
         is_data-datab   TO it_condct-valid_from ,
         is_data-datbi   TO it_condct-valid_to ,
         is_data-kotabnr TO it_condct-table_no ,
         gw_kvewe        TO it_condct-cond_usage ,
         gw_kappl        TO it_condct-applicatio ,

         is_data-kschl   TO it_condhd-cond_type ,
         is_data-knumh   TO it_condhd-cond_no ,
         is_data-vakey   TO it_condhd-varkey ,
         is_data-datab   TO it_condhd-valid_from ,
         is_data-datbi   TO it_condhd-valid_to ,
         is_data-kotabnr TO it_condhd-table_no ,
         is_data-ernam   TO it_condhd-created_by ,
         is_data-erdat   TO it_condhd-creat_date ,
         gw_kvewe        TO it_condhd-cond_usage ,
         gw_kappl        TO it_condhd-applicatio ,
         gw_kschl        TO it_condhd-cond_type ,

         is_data-kschl  TO it_condit-cond_type ,
         is_data-knumh  TO it_condit-cond_no ,
         is_data-waers  TO it_condit-curren_iso ,
         is_data-kbetr2 TO it_condit-cond_value ,
         is_data-waers  TO it_condit-condcurr ,
         is_data-kpein  TO it_condit-cond_p_unt ,
         is_data-kmein  TO it_condit-cond_unit ,
         gw_kappl       TO it_condit-applicatio ,
         '01'           TO it_condit-cond_count ,
         'A'            TO it_condit-scaletype ,
         'C'            TO it_condit-calctypcon .

  IF is_data-flag EQ 'D'.
    MOVE is_data-kbetr TO it_condit-cond_value .
  ENDIF.

* If amount, make a change.
  IF is_data-flag EQ 'A' OR
     is_data-flag EQ 'B'.
    MOVE : '004' TO it_condit-operation ,
           '004' TO it_condct-operation ,
           '004' TO it_condhd-operation .
    APPEND : it_condct, it_condit, it_condhd.
  ENDIF.

* If creation, make an add.
  IF is_data-flag EQ 'C'.
    MOVE : '009' TO it_condit-operation ,
           '009' TO it_condct-operation ,
           '009' TO it_condhd-operation .
    APPEND : it_condct, it_condit, it_condhd.
  ENDIF.

* If new date, suppress the old one.
  IF is_data-flag EQ 'D'.
    MOVE : '003' TO it_condit-operation ,
           '003' TO it_condct-operation ,
           '003' TO it_condhd-operation .

    CONCATENATE   gw_kvewe
                  is_data-knumh
                  '01'
                  is_data-datbi
                  INTO is_crmsfk-sfa_key_p.
    MOVE is_data-knumh TO is_crmsfk-line_no.

    CALL FUNCTION 'CND_MAP_KNUMH_EXTRACT_MAPPING'
      EXPORTING
        pi_bapicrmsfk = is_crmsfk.
    CALL FUNCTION 'CND_MAP_KNUMH_OLD_SET'
      EXPORTING
        pi_kvewe     = gw_kvewe
        pi_knumh_tmp = is_data-knumh
        pi_datbi     = is_data-datbi2.

    CALL FUNCTION 'CND_MAP_KNUMH_READ_DB'.

    APPEND : it_condct, it_condit, it_condhd.
  ENDIF.


* Call the BAPI
  CALL FUNCTION 'BAPI_PRICES_CONDITIONS'
    TABLES
      ti_bapicondct  = it_condct
      ti_bapicondhd  = it_condhd
      ti_bapicondit  = it_condit
      ti_bapicondqs  = it_condqs
      ti_bapicondvs  = it_condvs
      to_bapiret2    = it_return
      to_bapiknumhs  = it_knumh
      to_mem_initial = it_mem
    EXCEPTIONS
      OTHERS         = 2.


* Check return code.
  READ TABLE it_return
       WITH KEY type = 'E'.
  IF sy-subrc EQ space.
    MOVE 4 TO w_code.
  ELSE.
    CLEAR w_code.
  ENDIF.


* Add the log.
  LOOP AT it_return.
    add_log '1' it_return-type it_return-id it_return-number
                it_return-message_v1 it_return-message_v2
                it_return-message_v3 it_return-message_v4.
  ENDLOOP.

I will give you the point A. (misterious A...) for your help.

Have a nice day

Fred

Read only

0 Likes
2,916

Hi,

I just used the operation code '004' then was able to change DATAB (Date From) in table A018 and KBETR (Price Rate) in table KONP. Not sure it was just luck that I didn't encounter the data inconsistency issue, or it was because I used the later version of function module 'BAPI_PRICES_CONDITIONS' (Changed on 2010-03-10).

Anyway the sample code pieces here are all very helpful. Thanks to you all.

Regards,

Arwen

Read only

Former Member
0 Likes
2,916

Hi Frédéric Girod ,

It's great that you solved your problem. Now, I have the same trouble as you but with a little bit of difference.

Assume that I have 3 entries of conditions

condition 1

: 01.01.2007 --> 01.05.2007

condition 2

: 02.05.2007 --> 01.10.2007

condition 3

: 02.10.2007 --> 31.12.9999

Now, I wanna insert a new condition: condition 4:

01.04.2007 --> 31.12.9999


After running, the results will be:
- condition 1: 01.01.2007 --> 31.03.2007
- condition 4: 01.04.2007 --> 31.12.9999

condition 2 and 3 must be deleted from table Axxx.

However, I found that BAPI_PRICES_CONDITIONS does not delete entries from table Axxx. If I ran report with operation = 003, it just make a Deletion Indicator = 'X'.

Hey guys, do you know any FMs can help?

Read only

0 Likes
2,916

Hi I have the same problem, anyone know BAPI or FM that solves this?

Read only

0 Likes
2,916

Hi Phu Nguyen, do you solves this problem?.

Read only

0 Likes
2,916

Hi,

I found this thread discussed about the deletion issue.

https://scn.sap.com/message/6330464

"Problem is solved, by applying OSS Notes

SAP Note 1101523 (6) - Physical Deletion of Price Conditions"

I haven't tried this method yet. If anyone does, please inform me with the result. Thanks.

Regards,

Arwen

======================================

Hi again,

I just found there is an optional import parameter 'BAPI_PHYSICAL_DELETION' of the function module 'BAPI_PRICES_CONDITIONS'. Just mark it with an 'X', the price conditions will be physically deleted in table Annn (for me it is A018), KONH and KONP. And I checked in ME13, the displaying was fine as well.

My system version is:

Component version    SAP ECC 6.0

Unicode System       Yes

SAP_BASIS  702  0011  SAPKB70211  SAP Basis Component

消息编辑者为:Arwen Liu

Read only

WenjingLiu
Participant
0 Likes
2,916

Hi,

I have created a new Purchase InfoRecord Price Condition Record by using FUNCTION 'BAPI_PRICES_CONDITIONS'. I just found that condition tables such as A018 can be updated by this function module without article/PIR's existence, which might cause data inconsistency. (In my case, I should first create an article and PIR, then use this function module to create purchase price condition records for the article.)