‎2007 Sep 27 5:07 PM
Hi,
I want to use BAPI_PRICES_CONDITIONS but don't know what to pass to <b>ti_bapicondct, ti_bapicondhd, ti_bapicondit</b> table parameters of the function. The condition depens on Customer / Material and the related table is A005. The tables affected after a succesfull condition save using VK11 are KONP and KONH.
Let me know what should be the values of <b>table_no</b> and <b>varkey</b> parameters of the tables mentioned above.
thanks,
- ferudun
‎2007 Sep 27 5:37 PM
You have to build the VARKEY. The other fields of ti_bapicondct will be
Eg:
CONCATENATE pm_vkorg pm_vtweg pm_spart pm_werks pm_kunwe pm_kunwe pm_matnr INTO ls_table1-varkey.
ls_table1-table_no = '825'.
ls_table1-applicatio = 'V'.
ls_table1-cond_type = 'ZPCM'.
ls_table1-cond_usage = 'A'.
ls_table1-valid_to = '99991231'.
ls_table1-valid_from = '20070423'.
ls_table1-cond_no = '$000000001'.
APPEND ls_table1 TO lt_table1.
Pass this lt_table1 to t_bapicondct.
The table number will be based on the Access Sequence you are using for the Condition Type. Check table T682I and T682Z for that.
Actually even ti_bapicondhd will also have pretty much same fields as above. You can use the same varkey built above.
ti_bapicondit will have the actual values, uoms etc.
Lemme know if u need further info
Sri
‎2007 Sep 27 5:24 PM
Hi
Check the KONH table.
We have VAKEY field, which is concatenation of the fields in AXXX table.
create a itab structure similar to VAKEY and pass the value to VARKEY
TABLE_NO field is nothing but KONH-KOTABNR.
Let me know, if you need further information on the same
Regards
MD
‎2007 Sep 27 5:37 PM
You have to build the VARKEY. The other fields of ti_bapicondct will be
Eg:
CONCATENATE pm_vkorg pm_vtweg pm_spart pm_werks pm_kunwe pm_kunwe pm_matnr INTO ls_table1-varkey.
ls_table1-table_no = '825'.
ls_table1-applicatio = 'V'.
ls_table1-cond_type = 'ZPCM'.
ls_table1-cond_usage = 'A'.
ls_table1-valid_to = '99991231'.
ls_table1-valid_from = '20070423'.
ls_table1-cond_no = '$000000001'.
APPEND ls_table1 TO lt_table1.
Pass this lt_table1 to t_bapicondct.
The table number will be based on the Access Sequence you are using for the Condition Type. Check table T682I and T682Z for that.
Actually even ti_bapicondhd will also have pretty much same fields as above. You can use the same varkey built above.
ti_bapicondit will have the actual values, uoms etc.
Lemme know if u need further info
Sri
‎2007 Sep 28 6:49 AM
Hi,
Thanks for your attention guys! Let me explain my problem in detail:
I have created a condion using VK11. The result was a record in KONH and KONP tables. After your replies I have checked the T682I table and the sequence is as fallows:
KOZGF KOLNR KOTABNR
-
ZR00 10 5
ZR00 20 55
ZR00 40 4
ZR00 60 800
I have checked the tables listed above for the record created using VK11. The A005 contains a record related with my condition, A055 and A004 are empty, A800 contains a record for ZR00 but not mine.
I can't figure out which table name to use for TI_BAPICONDCT, TI_BAPICONDHD, TI_BAPICONDIT parameters of the function.
thanks,
- ferudun
‎2007 Sep 28 2:55 PM
Hi Feruddun,
Let me explain you something i know..
There are 4 entries in your T682I table for ZR00 Access Sequence. Now if you go to T682Z table you would have the Key fields of the access sequence. The link between T682I and T682Z would be KOZGF and KOLNR. There are 4 access sequnces, and if you look at the key fields of the Access Sequence, they start of being very specific and finally less specific.
For Eg: ZR00- 10 - Key Fields - VKORG/VTWEG/SPART/KUNNR/MATNR
ZR00- 20 - Key Fields- VKORG/VTWEG/SPART/MATNR
So u can see..the first access sequence is more specific, however for the system to use the condition records, all 5 values must be present. So, you first check if all 5 values are there, if there is then you create an access sequence using its corresponding KOTABNR which is 5. And if you do not have atleast one of the 5 key fields, you would read the key fields of the next Access sequence and use its corresponding table 55 and so on..
I hope i made sense...
Lemme know if you need further help.
Sri
‎2007 Oct 02 10:18 AM
Hi Sri Tayi,
I found your explanation is really clear and it is quite useful for me.
I have a question: as in your example, if I need more than available key fields of an Access Sequence in table T682Z, what should I do?
For example, ZR00 - n - Key Fields A / B / C / D / E.
I need a combination of A / B / C / D / E / <b>F</b>, but Key Field F is not in the table. So, what now?
By the way, <b>please explain me more about the parameter VARKEY.</b>
As above, VARKEY is a combination of fields of Axxx table. I went to this table, but which fields do we use?
I see that parameters passed to the FM include 5 tables. What are there functions? Do we have to pass all tables with data?
‎2007 Oct 03 4:24 AM
Hi Sri Tayj,
I think with the requirement of Ferudun ATAKAN , accessing to T682I and T682Z to get information about <b>Table_No</b> is not right. The right table is KONH, as Madhan said.
Because, in my case, if I went to T682I, it told me to use table A006 while KONH told me to use A306. Actually, I created some entries in VK11 and they were saved in KONH (for header), KONP (for detail) and A306. Looking into A006 didn't return my items. So confused here. Can you make me clear?
‎2007 Sep 28 7:05 AM
see the sample code below...................
data:
dd02l_tabname like dd02l-tabname,
BAPI_PRICES_CONDITIONS-Tabellen
ti_bapicondct type table of bapicondct with header line,
ti_bapicondhd type table of bapicondhd with header line,
ti_bapicondit type table of bapicondit with header line,
ti_bapicondqs type table of bapicondqs with header line,
ti_bapicondvs type table of bapicondvs with header line,
to_bapiret2 type table of bapiret2 with header line,
to_bapiknumhs type table of bapiknumhs,
to_mem_initial type table of cnd_mem_initial with header line,
help_vakey like ti_bapicondct-varkey.
Fehlerauswertung
data: begin of fehler_tab occurs 0, " Tabelle für Fehlermeldungen
line like sy-lisel, " 255 Char
end of fehler_tab.
returncode(2).
tables: a100.
Neue KonditionsNr holen für Neuanlage Kondition
data: knumh_new type knumh.
data: ls_return type bapiret2.
weiter Daten zu Konditionen
data: help_konp like konp.
data: help_konm like konm.
data: help_konw like konw,
gestern type d.
selection-screen begin of block block5 with frame title text-bl5.
parameters:
p_preis as checkbox modif id upd,
p_proz type kbetr_kond modif id upd,
p_datab like a100-datab modif id upd,
p_datbi like a100-datbi modif id upd,
p_waers like a106-waerk default 'EUR' modif id upd.
parameters:
p_kappl like a100-kappl default 'V' no-display.
selection-screen end of block block5.
break-point.
*----
*
Form preisanpassung
*----
*
form preisanpassung using alter_preis type kbetr_kond " CURR 11.2
neuer_preis type kbetr_kond.
neuer_preis = alter_preis + ( alter_preis * p_proz / 100 ).
endform. " preisanpassung
*
*----
*
Form bapi_prices_conditions
*----
*
form bapi_prices_conditions.
clear: ti_bapicondct, ti_bapicondhd, ti_bapicondit, ti_bapicondqs,
ti_bapicondvs, to_bapiret2, to_bapiknumhs, to_mem_initial.
refresh: ti_bapicondct, ti_bapicondhd, ti_bapicondit, ti_bapicondqs,
ti_bapicondvs, to_bapiret2, to_bapiknumhs, to_mem_initial.
gestern = sy-datum - 1.
dd02l_tabname = 'A100'.
perform fill_a914.
perform bapi_buchen.
endform. " bapi_prices_conditions
*----
*
Form fill_a914
*----
*
form fill_a914.
Bapi für Tabelle A914 füllen
alle markierten zutreffenden Konditionen aus A914 auslesen
loop at et_row_no. " enthält die markierten Zeilen
if p_ekinfo = ''.
read table i_ausg index et_row_no-row_id.
select single * from a914 client specified
where mandt = sy-mandt
and kappl = p_kappl " Applikation, V = Vetrieb
and kschl = i_ausg-kschl
and vkorg = i_ausg-vkorg
and vtweg = i_ausg-vtweg
and matnr = i_ausg-matnr
and kfrst = i_ausg-kfrst
and datbi = i_ausg-datbi
and datab = i_ausg-datab.
if sy-subrc ne 0. " SELECT SINGLE * FROM a914
continue.
endif. " sy-subrc ne 0. " SELECT SINGLE * FROM a914
perform zeitvergleich using
'A914' a914-kschl a914-knumh
i_ausg-datab i_ausg-datab_n
i_ausg-datbi i_ausg-datbi_n
i_ausg-kbetr i_ausg-kbetr_n.
else. " p_ekinfo = ''
read table i_ausg_ek index et_row_no-row_id.
select single * from a914 client specified
where mandt = sy-mandt
and kappl = p_kappl " Applikation, V = Vetrieb
and kschl = i_ausg_ek-kschl
and vkorg = i_ausg_ek-vkorg
and vtweg = i_ausg_ek-vtweg
and matnr = i_ausg_ek-matnr
and kfrst = i_ausg_ek-kfrst
and datbi = i_ausg_ek-datbi
and datab = i_ausg_ek-datab.
if sy-subrc ne 0. " SELECT SINGLE * FROM a914
continue.
endif. " sy-subrc ne 0. " SELECT SINGLE * FROM a914
perform zeitvergleich using
'A914' a914-kschl a914-knumh
i_ausg_ek-datab i_ausg_ek-datab_n
i_ausg_ek-datbi i_ausg_ek-datbi_n
i_ausg_ek-kbetr i_ausg_ek-kbetr_n.
endif." p_ekinfo = ''
endloop. " at ET_ROW_NO
endform. " fill_a914
*----
*
Form zeitvergleich
*----
*
form zeitvergleich using tabelle kschl knumh_alt
datab_alt datab_neu
datbi_alt datbi_neu
kbetr_alt kbetr_neu.
so, wie ist das denn mit dem Gültigkeitszeitraum
if datbi_neu gt datbi_alt.
das neue Ende-Datum endet nach dem alten
if datab_neu le sy-datum.
und die Kondition ist ab sofort gültig
ja gut, der einfache Fall 1a,
Teil 1: die alte Kondition enden lassen
Teil 2: und eine neue mit dem neuen Preis anlegen
if datbi_alt ge sy-datum.
alte Kondition ist noch gültig !!
perform bapi_fuellen using tabelle 'AENDERN' ''
kschl knumh_alt
datab_alt gestern kbetr_alt.
endif. " datbi_alt ge sy-datum
perform bapi_fuellen using tabelle 'ANLEGEN' 'X'
kschl knumh_alt
datab_neu datbi_neu kbetr_neu.
else. " datab_neu le sy-datum
Gültigkeit ab liegt in der Zukunft
ja gut, der einfache Fall 1b,
Teil 1: die alte Kondition in der Zukunft enden lassen
Teil 2: und eine neue mit dem neuen Preis anlegen
if datab_alt = datab_neu.
zukuenftig = datab_neu.
else. " datab_alt = datab_neu
zukuenftig = datab_neu - 1.
endif. " datab_alt = datab_neu
perform bapi_fuellen using tabelle 'AENDERN' ''
kschl knumh_alt
datab_alt zukuenftig kbetr_alt.
perform bapi_fuellen using tabelle 'ANLEGEN' 'X'
kschl knumh_alt
datab_neu datbi_neu kbetr_neu.
endif. " datab_neu le sy-datum
elseif datbi_neu = datbi_alt.
dieselbe Kondition soll geändert werden???
if datab_neu le sy-datum.
und die Kondition ist ab sofort gültig
ja gut, der einfache Fall 1a,
Teil 1: die alte Kondition enden lassen
Teil 2: und eine neue mit dem neuen Preis anlegen
if datbi_alt ge sy-datum.
alte Kondition ist noch gültig !!
perform bapi_fuellen using tabelle 'AENDERN' ''
kschl knumh_alt
datab_alt gestern kbetr_alt.
endif. " datbi_alt ge sy-datum
perform bapi_fuellen using tabelle 'ANLEGEN' 'X'
kschl knumh_alt
datab_neu datbi_neu kbetr_neu.
else. " datab_neu le sy-datum
Gültigkeit ab liegt in der Zukunft
ja gut, der einfache Fall 1b,
Teil 1: die alte Kondition in der Zukunft enden lassen
Teil 2: und eine neue mit dem neuen Preis anlegen
if datab_alt = datab_neu.
es soll eindeutig der gleiche Satz geändert werden
perform bapi_fuellen using tabelle 'AENDERN' 'X'
kschl knumh_alt
datab_alt datbi_alt kbetr_neu.
else. " datab_alt = datab_neu
zukuenftig = datab_neu - 1.
perform bapi_fuellen using tabelle 'AENDERN' ''
kschl knumh_alt
datab_alt zukuenftig kbetr_alt.
perform bapi_fuellen using tabelle 'ANLEGEN' 'X'
kschl knumh_alt
datab_neu datbi_neu kbetr_neu.
endif. " datab_alt = datab_neu
endif. " datab_neu le sy-datum
else. " datbi_neu > datbi_alt
das neue Ende-Datum endet VOR dem alten
der komplexere Fall 2a:
if datab_neu le sy-datum.
und die Kondition ist ab sofort gültig
Teil 1: die alte Kondition sofort enden lassen
Teil 2: und eine neue mit neuem Preis mit neuer Gültigkeit
Teil 3: alte Kond. ab neuem Ende bis altem Ende anlegen
perform bapi_fuellen using tabelle 'AENDERN' ''
kschl knumh_alt
datab_alt gestern kbetr_alt.
perform bapi_fuellen using tabelle 'ANLEGEN' 'X'
kschl knumh_alt
datab_neu datbi_neu kbetr_neu.
zukuenftig = datab_neu + 1.
perform bapi_fuellen using tabelle 'ANLEGEN' ''
kschl knumh_alt
zukuenftig datbi_alt kbetr_alt.
else. " datab_neu le sy-datum
Gültigkeit ab liegt in der Zukunft
der komplexere Fall 2b:
Teil 1: die alte Kondition in der Zukunft enden lassen
Teil 2: und eine neue mit dem neuen Preis anlegen
Teil 3: alte Kond. ab neuem Ende bis altem Ende anlegen
zukuenftig = datab_neu - 1.
perform bapi_fuellen using tabelle 'AENDERN' ''
kschl knumh_alt
datab_alt zukuenftig kbetr_alt.
perform bapi_fuellen using tabelle 'ANLEGEN' 'X'
kschl knumh_alt
datab_neu datbi_neu kbetr_neu.
zukuenftig = datbi_neu + 1.
perform bapi_fuellen using tabelle 'ANLEGEN' ''
kschl knumh_alt
zukuenftig datbi_alt kbetr_alt.
endif. " datab_neu le sy-datum
endif. " datbi_neu > i_ausg-datbi
endform. " zeitvergleich
*----
*
Form bapi_fuellen
*----
*
form bapi_fuellen using tabelle operation erhoehung " X = JA
kschl knumh_alt
datab_neu
datbi_neu
kbetr_neu.
hier muss also jetzt der BAPI gefüllt werden
siehe auch
if operation = 'ANLEGEN'. " ==> Kondition wird NICHT 'geändert'
Neue KonditionsNr holen für Neuanlage Kondition
clear: knumh_new.
call function 'NUMBER_GET_NEXT'
exporting
nr_range_nr = '01'
object = 'KONH'
importing
number = knumh_new
exceptions
others = 1.
if sy-subrc ne 0.
problems with the number range
perform error_message_syst changing ls_return.
append ls_return to to_bapiret2.
check 1 = 2.
endif.
endif. " operation = 'ANLEGEN'
Inhalte aus Axxx
clear: ti_bapicondct.
ti_bapicondct-operation
*003 Löschen: Nachricht enthält Objekte, die zu Löschen sind.
*004 Änderung: Nachricht enthält Änderungen
*005 Ersetze: Diese Nachricht ersetzt vorige Nachrichten
*009 Original: erste Nachricht zum Vorgang
*023 Warte/Abgleich: Daten sollen nicht eingespielt werden
*018 Wiederversenden
if operation = 'AENDERN'.
ti_bapicondct-operation = '004'.
elseif operation = 'ANLEGEN'.
ti_bapicondct-operation = '009'.
endif. " operation = 'AENDERN'
ti_bapicondct-cond_usage = dd02l_tabname(1).
ti_bapicondct-table_no = dd02l_tabname+1(3).
ti_bapicondct-applicatio = p_kappl. " Fix V
ti_bapicondct-cond_type = kschl.
if tabelle = 'A914'.
concatenate a914-vkorg a914-vtweg " a914-kunnr
a914-matnr into help_vakey.
elseif tabelle = 'A915'.
concatenate a915-vkorg a915-vtweg a915-kunnr
a915-matnr into help_vakey.
elseif tabelle = 'A916'.
concatenate a916-vkorg a916-vtweg a916-pltyp
a916-waerk into help_vakey.
help_vakey+13 = a916-matnr.
elseif tabelle = 'A918'.
concatenate a918-spart a918-matnr
into help_vakey.
endif. " Tabelle = 'A914'
CONDENSE help_vakey NO-GAPS.
ti_bapicondct-varkey = help_vakey.
Konditionsdatum gültig bis
ti_bapicondct-valid_to = datbi_neu.
ti_bapicondct-AGREE_COND =
ti_bapicondct-valid_from = datab_neu.
if operation = 'ANLEGEN'.
ti_bapicondct-cond_no = knumh_new.
elseif operation = 'AENDERN'.
ti_bapicondct-cond_no = knumh_alt.
endif. " operation = 'ANLEGEN'
ti_bapicondct-VADAT =
append ti_bapicondct.
Inhalte aus KONH mit KNUMH aus Axxx
clear: ti_bapicondhd.
ti_bapicondhd-operation = ti_bapicondct-operation.
ti_bapicondhd-SD_DOC = VBELN
ti_bapicondhd-ITM_NUMBER = POSNR
ti_bapicondhd-cond_no = ti_bapicondct-cond_no.
ti_bapicondhd-applicatio = p_kappl. " Fix V.
ti_bapicondhd-cond_type = kschl.
ti_bapicondhd-created_by = sy-uname.
ti_bapicondhd-creat_date = sy-datum.
ti_bapicondhd-cond_usage = ti_bapicondct-cond_usage.
ti_bapicondhd-table_no = ti_bapicondct-table_no.
ti_bapicondhd-varkey = help_vakey.
ti_bapicondhd-valid_from = datab_neu.
ti_bapicondhd-valid_to = datbi_neu.
ti_bapicondhd-SEARCHTERM = KOSRT
ti_bapicondhd-RESPONS = KZUST
ti_bapicondhd-PROMOT_NO = KNUMA_PI
ti_bapicondhd-SALES_DEAL = KNUMA_AG
ti_bapicondhd-SALESQUOTE = KNUMA_SQ
ti_bapicondhd-STD_AGRMNT = KNUMA_SD
ti_bapicondhd-PROMOTION = AKTNR
ti_bapicondhd-REBAGREEMT = KNUMA_BO
ti_bapicondhd-LIC_NO = LICNO
ti_bapicondhd-LIC_DATE = LICDT
ti_bapicondhd-VARDATE = VADAT
append ti_bapicondhd.
Inhalte aus KONP mit KNUMH aus Axxx
clear: ti_bapicondit.
select * from konp client specified into help_konp
where mandt = sy-mandt and knumh = knumh_alt.
keine Konditionen mit Löschkennzeichen anlegen
if help_konp-loevm_ko is initial.
ti_bapicondit-operation = ti_bapicondct-operation.
ti_bapicondit-cond_no = ti_bapicondct-cond_no.
ti_bapicondit-cond_count = help_konp-kopos.
ti_bapicondit-applicatio = help_konp-kappl.
ti_bapicondit-cond_type = help_konp-kschl.
ti_bapicondit-text_no = help_konp-knumt.
ti_bapicondit-scaletype = help_konp-stfkz.
ti_bapicondit-scalebasin = help_konp-kzbzg.
ti_bapicondit-scale_qty = help_konp-kstbm.
ti_bapicondit-unitmeasur = help_konp-konms.
ti_bapicondit-measur_iso = help_konp-.
ti_bapicondit-scale_val = help_konp-kstbw.
ti_bapicondit-scale_val = kbetr_neu. "!!!!!
ti_bapicondit-currenckey = help_konp-konws.
ti_bapicondit-curren_iso = help_konp-konws.
ti_bapicondit-calctypcon = help_konp-krech.
Prozentwerte werden falsch umgerechnet!!!
if help_konp-konwa = '%'.
kbetr_neu = kbetr_neu / 10.
endif.
ti_bapicondit-cond_value = kbetr_neu. "!!!!!
ti_bapicondit-condcurr = help_konp-konwa.
ti_bapicondit-cond_iso = help_konp-konwa.
ti_bapicondit-cond_p_unt = help_konp-kpein.
ti_bapicondit-cond_unit = help_konp-kmein.
ti_bapicondit-conunitiso = help_konp-.
ti_bapicondit-pricelevel = help_konp-prsch.
ti_bapicondit-numconvert = help_konp-kumza.
ti_bapicondit-denominato = help_konp-kumne.
ti_bapicondit-base_uom = help_konp-meins.
ti_bapicondit-baseqtyiso = help_konp-.
ti_bapicondit-lowerlimit = help_konp-mxwrt.
ti_bapicondit-upperlimit = help_konp-gkwrt.
ti_bapicondit-plcondval = help_konp-pkwrt. " ???
ti_bapicondit-cum_value = help_konp-fkwrt. " ???
ti_bapicondit-cumm_accr = help_konp-rswrt. " ???
ti_bapicondit-lowerlimit = kbetr_neu. "!!!!!
ti_bapicondit-upperlimit = kbetr_neu. "!!!!!
ti_bapicondit-plcondval = kbetr_neu. "!!!!!
ti_bapicondit-cum_value = kbetr_neu. "!!!!!
ti_bapicondit-cumm_accr = kbetr_neu. "!!!!!
ti_bapicondit-CURRENCY = help_konp-konwa.
ti_bapicondit-CURR_ISO = help_konp-.
ti_bapicondit-condcurren = help_konp-kwaeh.
ti_bapicondit-ISOCURRENC = help_konp-.
ti_bapicondit-plan_basis = help_konp-ukbas.
ti_bapicondit-plan_basis = kbetr_neu. "!!!!!
ti_bapicondit-RATE_UNIT = help_konp-.
ti_bapicondit-exclusion = help_konp-kznep.
ti_bapicondit-customer = help_konp-kunnr.
ti_bapicondit-vendor_no = help_konp-lifnr.
ti_bapicondit-tax_code = help_konp-mwsk1.
ti_bapicondit-indidelete = help_konp-loevm_ko.
ti_bapicondit-conditidx = help_konp-zaehk_ind.
ti_bapicondit-matlsettl = help_konp-bomat.
ti_bapicondit-accruals = help_konp-kbrue.
ti_bapicondit-accruals = kbetr_neu. "!!!!!
ti_bapicondit-reb_retroa = help_konp-kspae.
ti_bapicondit-statofagre = help_konp-bosta.
ti_bapicondit-promot_no = help_konp-knuma_pi.
ti_bapicondit-sales_deal = help_konp-knuma_ag.
ti_bapicondit-salesquote = help_konp-knuma_sq.
ti_bapicondit-add_val_dy = help_konp-valtg.
ti_bapicondit-fix_val_dy = help_konp-valdt.
ti_bapicondit-pmnttrms = help_konp-zterm.
ti_bapicondit-numborders = help_konp-anzauf.
ti_bapicondit-minconbava = help_konp-mikbas.
ti_bapicondit-maxconbava = help_konp-mxkbas.
ti_bapicondit-maxconval = help_konp-komxwrt.
ti_bapicondit-maxconval = kbetr_neu. "!!!!!
ti_bapicondit-incr_scale = help_konp-klf_stg.
ti_bapicondit-pricscale = help_konp-klf_kal.
ti_bapicondit-relprcg = help_konp-vkkal.
ti_bapicondit-promotion = help_konp-aktnr.
ti_bapicondit-rebagreemt = help_konp-knuma_bo.
ti_bapicondit-withtaxcod = help_konp-mwsk2.
ti_bapicondit-contract = help_konp-vertt.
ti_bapicondit-contractno = help_konp-vertn.
ti_bapicondit-flow_type = help_konp-vbewa.
ti_bapicondit-indimatmai = help_konp-mdflg.
ti_bapicondit-status = help_konp-kfrst.
ti_bapicondit-umsabst = help_konp-uasta.
append ti_bapicondit.
endif. " help_konp-LOEVM_KO is initial
endselect. " FROM konp
IF ti_bapicondit-cond_no IS INITIAL.
alle Pos mit Löschkennzeichen
CONTINUE.
ENDIF.
Inhalte aus KONM Konditionen (Mengenstaffel 1-dimensional)
clear: ti_bapicondqs.
select * from konm client specified into help_konm
where mandt = sy-mandt and knumh = knumh_alt.
ti_bapicondqs-operation = ti_bapicondct-operation.
TI_BAPICONDQS-SD_DOC = VBELN.
ti_bapicondqs-itm_number = posnr.
ti_bapicondqs-cond_no = ti_bapicondct-cond_no.
ti_bapicondqs-cond_count = help_konm-kopos.
ti_bapicondqs-line_no = help_konm-klfn1.
ti_bapicondqs-scale_qty = help_konm-kstbm.
ti_bapicondqs-cond_unit = help_konp-kmein.
ti_bapicondqs-t_unit_iso =
Prozentwerte werden falsch umgerechnet!!!
TNT: bitte prüfen ob diese Umsetzung erforderlich ist !!!!!
IF help_konp-konwa = '%'.
help_konm-kbetr = help_konm-kbetr / 10.
ENDIF.
ti_bapicondqs-currency = help_konm-kbetr.
clear: kbetr_neu.
if erhoehung = 'X'.
perform preisanpassung using help_konm-kbetr kbetr_neu.
else.
kbetr_neu = help_konm-kbetr.
endif. " erhoehung = 'X'
ti_bapicondqs-currency = kbetr_neu.
ti_bapicondqs-condcurr = help_konp-konwa.
ti_bapicondqs-curren_iso =
append: ti_bapicondqs.
clear: help_konm.
endselect. " from konm
Inhalte aus KONW Konditionen (Wertstaffel 1-dimensional)
clear: ti_bapicondvs.
select * from konw client specified into help_konw
where mandt = sy-mandt and knumh = knumh_alt.
ti_bapicondvs-operation = ti_bapicondct-operation.
ti_bapicondvs-SD_DOC = VBELN.
ti_bapicondvs-ITM_NUMBER = POSNR.
ti_bapicondvs-cond_no = ti_bapicondct-cond_no.
ti_bapicondvs-cond_count = help_konw-kopos.
ti_bapicondvs-line_no = help_konw-klfn1.
ti_bapicondvs-scale_val = help_konw-kstbw.
ti_bapicondvs-currenckey = help_konp-konws.
ti_bapicondvs-CURRENCISO =
Prozentwerte werden falsch umgerechnet!!!
TNT: bitte prüfen ob diese Umsetzung erforderlich ist !!!!!
IF help_konp-konwa = '%'.
help_konw-kbetr = help_konw-kbetr / 10.
ENDIF.
clear: kbetr_neu.
if erhoehung = 'X'.
perform preisanpassung using help_konw-kbetr kbetr_neu.
else.
kbetr_neu = help_konw-kbetr.
endif. " erhoehung = 'X'
ti_bapicondvs-currency = kbetr_neu.
ti_bapicondvs-condcurr = help_konp-konwa.
ti_bapicondvs-CURREN_ISO =
append: ti_bapicondvs.
endselect. " from konw
endform. " bapi_fuellen
*----
*
Form error_message_syst
*----
*
form error_message_syst changing pc_return type bapiret2.
call function 'BALW_BAPIRETURN_GET2'
exporting
type = sy-msgty
cl = sy-msgid
number = sy-msgno
par1 = sy-msgv1
par2 = sy-msgv2
par3 = sy-msgv3
par4 = sy-msgv4
importing
return = pc_return.
endform. " error_message_syst
*----
*
Form bapi_buchen
*----
*
form bapi_buchen.
nu geiht datt los, denn man tau
call function 'BAPI_PRICES_CONDITIONS'
EXPORTING
PI_INITIALMODE = ' '
PI_BLOCKNUMBER =
tables
ti_bapicondct = ti_bapicondct
ti_bapicondhd = ti_bapicondhd
ti_bapicondit = ti_bapicondit
ti_bapicondqs = ti_bapicondqs
ti_bapicondvs = ti_bapicondvs
to_bapiret2 = to_bapiret2
to_bapiknumhs = to_bapiknumhs
to_mem_initial = to_mem_initial
exceptions
update_error = 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.
endif.
read table to_bapiret2 with key type = 'E'
transporting no fields.
if sy-subrc = 0. " READ TABLE to_bapiret2
loop at to_bapiret2 where type ne 'I'
and type ne 'S'
and type ne 'W'.
TNT
WRITE: / to_bapiret2-type, to_bapiret2-message,
to_bapiret2-id, to_bapiret2-log_no,
to_bapiret2-log_msg_no, to_bapiret2-message_v1,
to_bapiret2-message_v2, to_bapiret2-message_v3,
to_bapiret2-message_v4, to_bapiret2-parameter,
to_bapiret2-row, to_bapiret2-field.
concatenate to_bapiret2-type to_bapiret2-id(4)
to_bapiret2-number to_bapiret2-message
into fehler_tab-line separated by ' '.
append fehler_tab.
endloop. " AT to_bapiret2
else. " sy-subrc = 0. " READ TABLE to_bapiret2
call function 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT =
importing
return = to_bapiret2.
Erfolgsmeldung schreiben
describe table ti_bapicondhd lines sy-tfill.
data: help_tfill(10).
move sy-tfill to help_tfill.
concatenate help_tfill
'Konditionen bearbeitet.'(104)
into fehler_tab-line separated by ' '.
append fehler_tab.
und noch 'markieren'
*TNT it_daten-erfolg = 'KOND'.
*TNT MODIFY it_daten.
endif. " sy-subrc = 0. " READ TABLE to_bapiret2
clear: ti_bapicondct, ti_bapicondhd, ti_bapicondit,
ti_bapicondqs, ti_bapicondvs, to_bapiret2,
to_bapiknumhs, to_mem_initial.
refresh: ti_bapicondct, ti_bapicondhd, ti_bapicondit,
ti_bapicondqs, ti_bapicondvs, to_bapiret2,
to_bapiknumhs, to_mem_initial.
endform. " bapi_buchen
reward points if helpful...........
‎2007 Sep 28 7:21 AM
Hi ramway,
I have tried your code before but could not manage to execute it. I have no German and could't solve the problems.
I have wrote the following code but got nothing. No bapi return message, no errors, no records created...
where is the problem:
data: ti_bapicondct TYPE TABLE OF bapicondct WITH HEADER LINE,
ti_bapicondhd TYPE TABLE OF bapicondhd WITH HEADER LINE,
ti_bapicondit TYPE TABLE OF bapicondit WITH HEADER LINE,
ti_bapicondqs TYPE TABLE OF bapicondqs WITH HEADER LINE,
ti_bapicondvs TYPE TABLE OF bapicondvs WITH HEADER LINE,
to_bapiret2 TYPE TABLE OF bapiret2 WITH HEADER LINE,
to_bapiknumhs TYPE TABLE OF bapiknumhs,
to_mem_initial TYPE TABLE OF cnd_mem_initial WITH HEADER LINE.
ti_bapicondct-table_no = '005'.
ti_bapicondct-applicatio = 'V'.
ti_bapicondct-cond_type = 'ZR00'.
ti_bapicondct-operation = '009'.
ti_bapicondct-varkey = '5000050070000000000000000213000000'.
ti_bapicondct-valid_to = '99991231'.
ti_bapicondct-valid_from = '20070928'.
ti_bapicondct-cond_no = '$000000001'.
APPEND ti_bapicondct.
ti_bapicondhd-operation = '009'.
ti_bapicondhd-cond_no = '$000000001'.
ti_bapicondhd-created_by = sy-uname.
ti_bapicondhd-creat_date = '20070928'.
ti_bapicondhd-cond_usage = 'A'.
ti_bapicondhd-table_no = '005'.
ti_bapicondhd-applicatio = 'V'.
ti_bapicondhd-cond_type = 'ZR00'.
ti_bapicondhd-varkey = '5000050070000000000000000213000000'.
ti_bapicondhd-valid_from = '20070928'.
ti_bapicondhd-valid_to = '99991231'.
APPEND ti_bapicondhd.
ti_bapicondit-operation = '009'.
ti_bapicondit-cond_no = '$000000001'.
ti_bapicondit-cond_count = '01'.
ti_bapicondit-applicatio = 'V'.
ti_bapicondit-cond_type = 'ZR00'.
ti_bapicondit-scaletype = 'A'.
ti_bapicondit-scalebasin = 'C'.
ti_bapicondit-scale_qty = '1'.
ti_bapicondit-cond_p_unt = '1'.
ti_bapicondit-cond_unit = 'ST'.
ti_bapicondit-calctypcon = 'C'.
ti_bapicondit-cond_value = '13'.
ti_bapicondit-condcurr = 'TRY'.
APPEND ti_bapicondit.
CALL FUNCTION 'BAPI_PRICES_CONDITIONS'
EXPORTING
PI_INITIALMODE = ' '
PI_BLOCKNUMBER =
TABLES
TI_BAPICONDCT = TI_BAPICONDCT
TI_BAPICONDHD = TI_BAPICONDHD
TI_BAPICONDIT = TI_BAPICONDIT
TI_BAPICONDQS = ti_bapicondqs
TI_BAPICONDVS = ti_bapicondvs
TO_BAPIRET2 = to_bapiret2
TO_BAPIKNUMHS = to_bapiknumhs
TO_MEM_INITIAL = to_mem_initial
EXCEPTIONS
UPDATE_ERROR = 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.
endif.
read table to_bapiret2 with key type = 'E' transporting no fields.
if sy-subrc = 0.
loop at to_bapiret2.
write: / to_bapiret2-type,
to_bapiret2-message,
to_bapiret2-id,
to_bapiret2-log_no,
to_bapiret2-log_msg_no,
to_bapiret2-message_v1,
to_bapiret2-message_v2,
to_bapiret2-message_v3,
to_bapiret2-message_v4,
to_bapiret2-parameter,
to_bapiret2-row,
to_bapiret2-field.
endloop.
else.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
*exporting
wait =
importing
return = to_bapiret2.