2008 Feb 19 1:32 PM
Hi all,
I need a function module that changes a specific pricing condition in background.
For example,
I have a condition table for pricing A501. the pricing condition is about VKORG/MATNR.
Also I know the application type ('V'), condition type (PSF1 or whatever I want), validity dates(starting & ending dates) and all other parameters that I need (hierarchy etc.).
I'm about to write a remote enabled FM that creates/changes the condition data.
Do u know any FM to handle this issue.
Thanks a lot...
burak
2008 Feb 19 2:42 PM
try using the FM
BAPI_REQUIREMENTS_GETDETAIL
this will give u the old pricing
BAPI_REQUIREMENTS_CHANGE
this is to change
2008 Feb 19 2:42 PM
try using the FM
BAPI_REQUIREMENTS_GETDETAIL
this will give u the old pricing
BAPI_REQUIREMENTS_CHANGE
this is to change
2008 Feb 28 2:19 PM
Hi finally i found a FM that do the job same as VK11 & VK12.
The function that creates or changes the price conditions is 'RV_CONDITION_COPY'. also you have to use 'RV_CONDITION_SAVE' and 'RV_CONDITION_RESET' . Here is an example :
FUNCTION zlib_change_prices_single .
*"----
""Local Interface:
*" IMPORTING
*" VALUE(E_KAPPL) LIKE A501-KAPPL DEFAULT 'V'
*" VALUE(E_VKORG) LIKE A501-VKORG DEFAULT '1000'
*" VALUE(E_KSCHL) LIKE A501-KSCHL
*" VALUE(E_MATNR) LIKE A501-MATNR
*" VALUE(E_DATBI) LIKE A501-DATBI
*" VALUE(E_DATAB) LIKE A501-DATAB
*" VALUE(E_KOSRT) LIKE KONH-KOSRT OPTIONAL
*" VALUE(E_KBETR) LIKE KONP-KBETR
*" EXPORTING
*" VALUE(I_RETURN) TYPE BAPIRETURN
*"----
DATA: lt_mat_price LIKE zlib_s_material_price OCCURS 0 WITH HEADER LINE.
DATA:lt_cond LIKE zsd_price_condition_in OCCURS 0 WITH HEADER LINE,
lt_cond_rt LIKE zsd_price_condition_rt OCCURS 0 WITH HEADER LINE.
DATA : wa_komg TYPE komg.
DATA : it_komv TYPE komv OCCURS 1 WITH HEADER LINE,
it_komv_idoc TYPE komv_idoc OCCURS 1 WITH HEADER LINE,
lt_knumh_map TYPE knumh_comp OCCURS 1 WITH HEADER LINE.
DATA : new_record.
PERFORM read_t001 USING c_bukrs_beymen
CHANGING gw_t001.
lt_cond-matnr = e_matnr.
lt_cond-vkorg = e_vkorg.
lt_cond-kbstat = 'Z1'.
lt_cond-datab = e_datab.
lt_cond-datbi = e_datbi.
lt_cond-waerk = gw_t001-waers.
lt_cond-kbetr = e_kbetr.
*-arastir
lt_cond-cmpgn_id = e_kosrt.
*-
APPEND lt_cond.
MOVE-CORRESPONDING : lt_cond TO wa_komg.
it_komv-kappl = e_kappl.
it_komv-kschl = e_kschl.
it_komv-kbetr = e_kbetr.
it_komv-waers = gw_t001-waers.
it_komv-krech = 'C'.
it_komv-kpein = 1.
it_komv-kmein = 'ST'.
APPEND it_komv.
MOVE-CORRESPONDING : it_komv TO it_komv_idoc.
APPEND it_komv_idoc.
CALL FUNCTION 'RV_CONDITION_COPY'
EXPORTING
application = e_kappl
condition_table = '501'
condition_type = e_kschl
date_from = e_datab
date_to = e_datbi
enqueue = 'X'
key_fields = wa_komg
maintain_mode = 'A'
keep_old_records = 'X'
used_by_idoc = 'X'
I_KONA =
overlap_confirmed = 'X'
IMPORTING
new_record = new_record
TABLES
copy_records = it_komv
copy_recs_idoc = it_komv_idoc
EXCEPTIONS
enqueue_on_record = 1
invalid_application = 2
invalid_condition_number = 3
invalid_condition_type = 4
no_authority_ekorg = 5
no_authority_kschl = 6
no_authority_vkorg = 7
no_selection = 8
table_not_valid = 9
no_material_for_settlement = 10
no_unit_for_period_cond = 11
no_unit_reference_magnitude = 12
invalid_condition_table = 13
OTHERS = 14.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
CASE sy-subrc.
WHEN '1'. "enqueue
i_return-type = 'E'.
i_return-message = text-001.
i_return-message_v1 = text-002.
i_return-message_v2 = text-003.
CONCATENATE Condition Type:' e_kschl '->' e_matnr
INTO i_return-message_v3.
WHEN '2'.
i_return-type = 'E'.
i_return-message = text-001.
i_return-message_v1 = text-002.
i_return-message_v2 = text-004.
i_return-message_v3 = e_kappl.
i_return-message_v4 = text-005.
WHEN '3'.
i_return-type = 'E'.
i_return-message = text-001.
i_return-message_v1 = text-002.
i_return-message_v2 = text-006.
i_return-message_v4 = text-005.
WHEN '4'.
i_return-type = 'E'.
i_return-message = text-001.
i_return-message_v1 = text-002.
i_return-message_v2 = text-007.
i_return-message_v3 = e_kschl.
i_return-message_v4 = text-005.
WHEN '5'.
i_return-type = 'E'.
i_return-message = text-001.
i_return-message_v1 = text-002.
i_return-message_v2 = 'NO_AUTHORITY_EKORG'.
WHEN '6'.
i_return-type = 'E'.
i_return-message = text-001.
i_return-message_v1 = text-002.
WHEN '7'.
i_return-type = 'E'.
i_return-message = text-001.
i_return-message_v1 = text-002.
WHEN '8'.
i_return-type = 'E'.
i_return-message = text-001.
i_return-message_v1 = text-002.
i_return-message_v2 = text-008.
WHEN '9'.
i_return-type = 'E'.
i_return-message = text-001.
i_return-message_v1 = text-002.
i_return-message_v2 = 'TABLE_NOT_VALID'.
WHEN '10'.
i_return-type = 'E'.
i_return-message = text-001.
i_return-message_v1 = text-002.
i_return-message_v2 = 'no_material_for_settlement'.
WHEN '11'.
i_return-type = 'E'.
i_return-message = text-001.
i_return-message_v1 = text-002.
i_return-message_v2 = 'no_unit_for_period_cond'.
WHEN '12'.
i_return-type = 'E'.
i_return-message = text-001.
i_return-message_v1 = text-002.
i_return-message_v2 = 'no_unit_reference_magnitude'.
WHEN '13'.
i_return-type = 'E'.
i_return-message = text-001.
i_return-message_v1 = text-002.
i_return-message_v2 = 'invalid_condition_table'.
WHEN '14'.
i_return-type = 'E'.
i_return-message = text-001.
i_return-message_v1 = text-002.
i_return-message_v2 = text-009.
WHEN OTHERS.
ENDCASE.
ELSE.
CALL FUNCTION 'RV_CONDITION_SAVE'
TABLES
knumh_map = lt_knumh_map.
DESCRIBE TABLE lt_knumh_map.
IF sy-tfill GT 0.
LOOP AT lt_knumh_map.
i_return-type = 'S'.
i_return-message = lt_knumh_map-knumh_new.
WRITE e_matnr TO i_return-message_v1.
WRITE Price has been saved successfully' TO i_return-message_v2.
ENDLOOP.
CALL FUNCTION 'RV_CONDITION_RESET'.
COMMIT WORK.
ELSE.
i_return-type = 'E'.
i_return-message = text-001.
i_return-message_v1 = text-002.
i_return-message_v2 = text-010.
i_return-message_v3 = text-011.
ENDIF.
ENDIF.