SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Conditions maintenance using FM RV_CONDITION_COPY



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> SD
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Thu Dec 13, 2007 7:18 am    Post subject: Conditions maintenance using FM RV_CONDITION_COPY Reply with quote

Pricing and Conditions (SD-BF-PR) -
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/SDBFPR/SDBFPR.pdf

RV_CONDITION_COPY

Code:
REPORT  z_sd_test_cond_copy           .

DATA:
cr LIKE TABLE OF komv WITH HEADER LINE, " copy_records
nr, "New_Record
key_fields LIKE TABLE OF komg WITH HEADER LINE,
komk LIKE TABLE OF komk with header line,
komp LIKE TABLE OF komp with header line.


key_fields-mandt = '100'.
key_fields-vkorg = '1000'.
key_fields-vtweg = '10'.
key_fields-werks = '1000'.
key_fields-spart = '00'.
key_fields-kunnr = '0000151935'.
key_fields-matnr = '5014042'.
key_fields-kdatu = sy-datum.

*********************************************************
* Neue Informationen zum Konditinssatz:
*cr-mandt = '100'.
cr-kappl = 'V'.
cr-kschl = 'PR00'.
cr-kbetr = '77.77'.
*cr-knumh = '0000380829'.
*cr-kposn = '999999'.
*cr-stfkz = 'A'.
*cr-krech = 'B'.
*cr-konws = 'CHF'.
cr-kdatu = '20070613'.
cr-kunnr = '0000151935'.
cr-kpein = '1'.
cr-kmein = 'ST'.
cr-waers = 'CHF'.

APPEND cr.

**********************************************************
* KOMK/KOMP Fuellen
data wa_pispr like table of pispr with header line.

wa_pispr-kunnr = '0000151935'.
wa_pispr-matnr = '5014042'.
wa_pispr-vkorg = '1000'.
append wa_pispr.

CALL FUNCTION 'SPR_KOMK_KOMP_FILL'
  EXPORTING
    pi_i_spr        = wa_pispr
 IMPORTING
   PE_I_KOMK       = komk
   PE_I_KOMP       =  komp
          .
* --> KOMK/KOMP werden korrekt gefüllt. Funktion i.o.
**********************************************************
break point.

CALL FUNCTION 'RV_CONDITION_COPY'
     EXPORTING
          application              = 'V'
          condition_table          = '305'
          condition_type           = 'PR00'
*          date_from                = sy-datum
*          date_to                  = '99990101'
          enqueue                  = 'X'
          i_komk                   = komk
          i_komp                   = komp
          key_fields               = key_fields
          maintain_mode            = 'A'
          no_authority_check       = 'X'
          no_field_check          = 'X'
*          keep_old_records         = ' '
*          overlap_confirmed        = ' '
     IMPORTING
          e_komk                   = komk
          e_komp                   = komp
          new_record               = nr
     TABLES
          copy_records             = cr
     EXCEPTIONS
          enqueue_on_record        = 01
          invalid_application      = 02
          invalid_condition_number = 03
          invalid_condition_type   = 04
          no_authority_ekorg       = 05
          no_authority_kschl       = 06
          no_authority_vkorg       = 07
          no_selection             = 08
          table_not_valid          = 09.

CALL FUNCTION 'RV_CONDITION_SAVE'.
CALL FUNCTION 'RV_CONDITION_RESET'.


Code:
CONSTANTS:
CON_A(1) TYPE C VALUE 'A',
CON_B(1) TYPE C VALUE 'B',
CON_C TYPE C VALUE 'C',
CON_D TYPE C VALUE 'D',
CON_E TYPE C VALUE 'E',
CON_F TYPE C VALUE 'F',
CON_G TYPE C VALUE 'G',
CON_K TYPE C VALUE 'K',
CON_T TYPE C VALUE 'T',
CON_S(1) TYPE C VALUE 'S',
CON_V LIKE T681A-KAPPL VALUE 'V',
CON_X TYPE C VALUE 'x',
CON_XX TYPE C VALUE 'X',
CON_T074 LIKE T681-KOTABNR VALUE '074',
CON_PREF LIKE T685A-KSCHL VALUE 'PREF',
CON_ULTIMO LIKE RV13A-DATAB VALUE '99991231',
CON_DATA_LOG_NAME(8) TYPE C VALUE 'PREF',
CON_ERROR_LOG_NAME(8) TYPE C VALUE 'ERROR',
CON_CUSTOM_LOG_NAME(8) TYPE C VALUE 'P_CUSTOM'.
* Verkaufsmengeneinheit
PERFORM f3_vkme_ermitteln.
* Hauswährung
IF t001w-werks NE cstmat-werks.
PERFORM f3_waehrung_ermitteln USING cstmat-werks.
ENDIF.

* pro Zollgebiet Konditionssatz anlegen
LOOP AT t_matwerte.
CHECK t_matwerte-noupd_cond IS INITIAL.
CLEAR: komk,
komp,
komg,
w_komv.
REFRESH w_komv.
* Schlüssel füllen
komg-werks = w_marc-werks.
komg-matnr = w_marc-matnr.
komg-gzolx = t_matwerte-gzolx.
komg-land1 = t001w-land1. "101298
* Preisinfo füllen
w_komv-kappl = 'V '.
w_komv-kschl = con_pref.
IF t_matwerte-kp = kp_max.
w_komv-kpein = 1.
MOVE kp_max TO w_komv-kbetr.
ELSE.
w_komv-kpein = pm_peinh.
COMPUTE w_komv-kbetr = t_matwerte-kp * pm_peinh / hlp_ameng.
ENDIF.
IF w_komv-kbetr = 0.
COMPUTE w_komv-kbetr = 1 / 100 * -1.
ENDIF.
w_komv-waers = t001-waers.
w_komv-kmein = hlp_ame.
APPEND w_komv.

CHECK f3_kz_update_cond IS INITIAL OR
NOT pm_simu IS INITIAL.
IF NOT pm_mdmps IS INITIAL.
MOVE komg-werks TO bg_kond-werks.
MOVE komg-matnr TO bg_kond-matnr.
MOVE komg-gzolx TO bg_kond-gzolx.
MOVE w_komv-kpein TO bg_kond-kpein.
MOVE w_komv-kbetr TO bg_kond-kbetr.
MOVE w_komv-kmein TO bg_kond-kmein.
MOVE w_komv-waers TO bg_kond-waers.
*{ REPLACE D20K904946 1
*\ APPEND bg_kond.
* Siemens: Fehlerkorektur SAP-Standard
READ TABLE BG_KOND TRANSPORTING NO FIELDS
WITH KEY WERKS = BG_KOND-WERKS
MATNR = BG_KOND-MATNR
GZOLX = BG_KOND-GZOLX
BINARY SEARCH.
INSERT BG_KOND INDEX SY-TABIX.
*} REPLACE
ENDIF.

CHECK f3_kz_update_cond IS INITIAL.

CALL FUNCTION 'RV_CONDITION_COPY'
EXPORTING
application = con_v
condition_table = con_t074 "Konditionstabelle
condition_type = con_pref "Konditionsart
date_from = sy-datlo "Von jetzt an
date_to = con_ultimo "Bis Ultimo
enqueue = 'X' "Sperren ist besser
i_komk = komk
i_komp = komp
key_fields = komg "Schlüssel
maintain_mode = 'A' "Lieber A als B
no_authority_check = 'X' "X wie nix
keep_old_records = ' '
OVERLAP_CONFIRMED = 'X'
IMPORTING
e_komk = komk
e_komp = komp
new_record = i_new_record
TABLES
copy_records = w_komv
EXCEPTIONS
enqueue_on_record = 01
invalid_application = 02
invalid_condition_number = 03
invalid_condition_type = 04
no_authority_ekorg = 05
no_authority_kschl = 06
no_authority_vkorg = 07
no_selection = 08
table_not_valid = 09.

CASE sy-subrc.
WHEN 0.
WHEN OTHERS.
* MESSAGE A???
ENDCASE.

CALL FUNCTION 'RV_CONDITION_SAVE'.
CALL FUNCTION 'RV_CONDITION_RESET'.

ENDLOOP.


RV_CONDITION_MAINTENANCE
This will show the screen for Maintaning the condition records.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> SD All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.