IPC Condition value formula to Java
Hi all,
I need code the next abap statement for a condition value formula to java in overwriteConditionValue method:
form FRM_KONDI_WERT_903.
data: L_XKOMV like XKOMV occurs 0 with header line.
data: L_KAWRT like XKOMV-KAWRT.
data: L_KMEIN like XKOMV-KMEIN.
L_XKOMV[] = XKOMV[].
read table L_XKOMV with key KOAID = 'B'
KHERK = 'A'
KSTEU = 'A'.
KINAK = 'Y'.
L_KAWRT = L_XKOMV-KAWRT.
L_KMEIN = L_XKOMV-KMEIN.
if L_KAWRT ne 0.
XKOMV-KBETR = KOMP-NETWR .
XKOMV-KBETR = XKOMV-KBETR * 1000 / L_KAWRT.
xkwert = XKOMV-KBETR * L_KAWRT / 1000.
xkwert = xkwert / 10000.
endif.
XKOMV-KMEIN = L_KMEIN.
XKOMV-KAWRT = L_KAWRT.
But i don't know how translate "read table L_XKOMV with key KOAID = 'B'" to Java.
Help me please!!
Hi David,
Here are some of the steps that may be of some help.
1. Define the query pair (parameter and value)
2. Set up the projection of the query result
3. Call the db engine for the db instance
4. Run the query and request the result set
5. Confirm the results
The sample here comes from the examples found in your IPC install directory:
/ipc/doc/spe/UserExitsExamples.html#ex1
The example uses the <u>addAttributeBindings</u> method of the <b>ItemsUserExit</b> to perform the following steps and then calls the <u>determineRelevantAttributesforValueFormula</u> of the <b>PricingUserExit</b> to collect these attributes. Once available the <u>overwriteConditionValue</u> method is called.
Here is what I believe you'll need:
Make sure your user exit is importing the following class reference:
package userexits;
import com.sap.sxe.db.*;
Code:
// Declare the query pair array
sys_query_pair[] queryPair = new sys_query_pair[3];
// Declare the projection to filter the result set
String[] projection1;
// Define the query pairs
queryPair1[0] = new sys_query_pair("KOAID", "B");
queryPair1[1] = new sys_query_pair("KOHERK", "A");
queryPair1[2] = new sys_query_pair("KSTEU", "A");
// Define the fields we want to read from table as the projection
projection1 = new String[]{"KAWRT,KMEIN"};
// This is the database access to table
db _database = _engineUserExit.getDatabase();
res resultSet = _database.db_read_table("XKOMV",
queryPair1,
projection1)
// Check whether database access was successful
if (!res.db_empty_results_p(resultSet)) {
// If successful then assign field values
l_kawrt = resultSet.db_get_row_element_string(0);
l_mein = resultSet.db_get_row_element_string(1);
else {
log_api.log_write_msg("SPE",
"ItemUserExits",
1,
"Table Query of XKOMV Failed");
return;
Similar Messages
-
The Condition value formula is not found in CRM ???
Hello Al
l
We are working on CRM 7.0 , I canu2019t find the Condition Value Formula, Condition Base Formula and Condition u201Crequirementsu201D in the pricing procedures downloaded from the ECC also in the pricing procedures that are standard in the CRM
I donu2019t know what is the reason for that
Regards
Jacopo Françoisethe IPC should work to make them available
-
SD PRICING: How to identify the last call of a Condition Value Formula
Hello Experts.
I'm working on a condition value formula, and because a Group Condition, I need to do a calculation in the last call of the formula. The formula is called 5 times and I couldn't identify any flag to diferentiate the last 3 calls.
I could use a counter in a static variable per position, but I think there must be another way to identify the last call.
Thanks in advance and best regards
MatíasHi,
Define a counter say w_ii type I in your routine.
Whenever you enter the routine use 'IMPORT' to get the last value of w_ii. If sy-subrc ne 0 its first time so increment the counter w_ii = w_ii + 1 & 'EXPORT' it. If sy-subrc = 0 check the value of w_ii to decide if it's the last time.If yes do whatever you want to do
else increment w_ii i.e. w_ii = w_ii + 1 & 'EXPORT' it which in turn will be used during next 'IMPORT'.
I hope this helps,
Regards
Raju chitale -
IPC condition value userexit - wrong condition rate
Hi Pricing-gurus,
I have a java condition value userexit to calculate the value for the very first price condition.
The condition value is calculated correctly, however, the price per unit is wrong which is due to the condition rate that was not changed, also.
If I change condition rate also in this formula, the entire pricing is wrong because the IPC carries out the pricing run multiple times (SAP: for internal reasons) resulting in a rate and value that is too high, as the changes are adding up.
How can I change the condition rate just once? Or how how can I make sure that the formula is carried out only once during a pricing update?
Regards,
MichaelHi Pricing-gurus,
I have a java condition value userexit to calculate the value for the very first price condition.
The condition value is calculated correctly, however, the price per unit is wrong which is due to the condition rate that was not changed, also.
If I change condition rate also in this formula, the entire pricing is wrong because the IPC carries out the pricing run multiple times (SAP: for internal reasons) resulting in a rate and value that is too high, as the changes are adding up.
How can I change the condition rate just once? Or how how can I make sure that the formula is carried out only once during a pricing update?
Regards,
Michael -
Pricing: header condition with condition value formula
Hi,
can anyone helps us on the following topic:
- is it possible to enter a conditon value formula for a header condition?
We have created a formula, but it is only executed when we enter the condition on item level.
Our condition settings are:
Cond. class - A
Calculat. type - G
Group condition - X
Header condition - X
Item Condition - X
thanks in advance!Hello,
we have a breakpoint at the beginning of the formula.
If we enter the condition at item level we reach the breakpoint otherwise (when entering on header level) not.
The question now is, if this is due to configuration settings on condition type or within calculation procedure - or if it is just impossible to have a conditon value formula for a header condition.
thanks -
Delivery block on Sales order using Condition Value Formula routine?
Hi ABAP Experts,
I want to place delivery block (LIFSK/LIFSP) on sales from Condition Value Forumla routine 09.
I have a structure komp and xkomv.
I don't think the field exist in either of the structures.
How can possibly place block on the Sales if there is wide difference in both the prices.
I know the standard SAP changes the status of sales order to incomplete and we have to do V.25 in order to process.
But need specific delivery block 'ZZ' to identify it.
Can you explain this??
Thanks,
MattHelllo O ,
i think u can enhance those structures ....for more info...check documentation in SPRO.
regards
Prabhu -
ABAP code in to JAVA for overwritting condition value for IPC pricing
Dear experts i am an IPC JAVA developer and i am trying to translate an ABAP Routine in to JAVA code for overwriting condition value in the pricing user exit of IPC
Here is the ABAPcode segment i am trying to transulate
DATA: l_kdkg1 LIKE komk-kdkg1,
l_work TYPE f,
l_umren LIKE marm-umren,
l_umrez LIKE marm-umrez.
SELECT SINGLE peinh FROM mbew INTO mbew-peinh
WHERE matnr = komp-matnr
AND bwkey = komp-werks.
I need some help in the following things
1. I don't know how to transulate the following Line of ABAP code into JAVA
" AND bwkey = komp-werks."
Bwkey stands for plant details. I don't know how to get plant details from Pricing Item.
2. Someone please tell me weather the following JAVA transulation is correct
Vector x = prItem.getUserExitConditions();
db database = pricingEngine.getDatabase();
// set table name
String tableStart = "mbew";
// set query parameters
sys_query_pair[] queryPair = null;
//matnr = komp-matnr . Getting the material Number
String materialNo= prItem.getProduct().toString();
//bwkey = komp-werks.Getting plant.
// TODO: werks stands for plant. Not sure how to get it from prItem
String plant = "";
queryPair = new sys_query_pair[2];
queryPair[0] = new sys_query_pair("matnr", materialNo);
queryPair[1] = new sys_query_pair("bwkey", plant);
// set query columns
String ZZFIELDStart = "peinh";
String ZZFIELD_VALUEStart;
String[] projectionStart;
projectionStart = new String[];
BigDecimal pricingUnit = null;
try{
// execute query
res resultSetStart = database.db_read_table(tableStart, queryPair,projectionStart) ;
if (!res.db_empty_results_p(resultSetStart))
ZZFIELD_VALUEStart = resultSetStart.db_get_row_element_string(0);
pricingUnit = new BigDecimal(ZZFIELD_VALUEStart);
resultSetStart.db_finish();
else
System.out.println("Coudn't find a value of field peinh in table mbew!");
catch (exc_database_error e)
e.printStackTrace();Please login to the server where IPC is installed. In the IPC folder u find libs folder or search for docs in IPC folder. There it is dealt how ABAP routines are mapped to user exits in java coding
Thanks
Surya -
IPC: How to read the Condition Rate(KBETR) in Java checkRequirement method.
Hi Experts,
As part of an IPC development, we need to read the Condition Type Rate (KBETR) in a Requirement Formula. The condition rate is the rate for the current record of the pricing procedure, e.g. Condition Type ZAB1.
I can successfully read the condition rate in a Value formula using this piece of code:
public BigDecimal overwriteConditionValue(IPricingItemUserExit pricingItem,IPricingConditionUserExit pricingCondition) {
BigDecimal ZConditionRate = pricingCondition.getConditionRate().getValue();
In a Value Formula "IPricingConditionUserExit pricingCondition" is a input parameter of the overwriteConditionValue() method. However in a Requirement formula the standard method checkRequirement(IConditionFindingManagerUserExit item, IStep step, IAccess access) does not have any parameter which can give me the rate.
I wrote the following logic in the requirement class, but line 2 is not executed.
1. public boolean checkRequirement(IConditionFindingManagerUserExit item, IStep step, IAccess access) {
2. IPricingConditionUserExit pricingHeader = (IPricingConditionUserExit) item;
3. BigDecimal ZConditionRate = pricingHeader.getConditionRate().getValue();
Please suggest how we can retrieve the condition rate in a requirement formula class using teh standard methods & classes.Hi,
I have to set the condition rate as percentage in one of my codition value formula routine which i am developing based on java.
I have overwritten the method overwriteConditionValue() in my pricing routine which is 927. My logic is below.
When I open my quotation using crmd_order, condition rate is not being displayed with % for unit condition rate coulmn in my pricing conditions.
If I try to change my quotation for ex: Agrred price: xworke, then 927 formula is called and condition rate is displayed as %.
So condition rate value is displayed perfectly , but when my quotation is in display mode condition rate value is coming as USA, but it should be % irrespective of my quotation is in display mode or change mode. I have attached the two screen shots for quotation display mode and change mode.
Can some body throw insight what is wrong in my pricing routine logic in setting % condition rate rather than USD for the Condition rate value.
public BigDecimal overwriteConditionValue(IPricingItemUserExit pricingItem,
IPricingConditionUserExit pricingCondition) {
BigDecimal condValue = null;
BigDecimal discountValue = null;
try{
BigDecimal xworkg = pricingItem.getSubtotal(PricingCustomizingConstants.ConditionSubtotal.SUBTOTAL_G).getValue();
userexitlogger.writeLogDebug(" 927 formula, Date=["+new Date()+"] , xworkg=["+xworkg+"]");
BigDecimal xworke = pricingItem.getSubtotal(PricingCustomizingConstants.ConditionSubtotal.SUBTOTAL_E).getValue();
userexitlogger.writeLogDebug(" 927 formula, Date=["+new Date()+"], xworke=["+xworke+"]");
pricingCondition.setCalculationType(PricingCustomizingConstants.CalculationType.PERCENTAGE);
if (xworkg.compareTo(PricingTransactiondataConstants.ZERO) != 0) {
condValue = xworkg.subtract(xworke);
pricingCondition.setConditionValue(condValue);
// Calculate percentage with 3-decimal-precision (as does ABAP-Version by multiplying with 100.000 instead of 100)
pricingCondition.setConditionRate(condValue.multiply(PricingTransactiondataConstants.HUNDRED).divide(xworkg,
3, BigDecimal.ROUND_HALF_UP), "%");
pricingCondition.setPricingUnit(new BigDecimal(0), null);
else {
pricingCondition.setConditionRate(PricingTransactiondataConstants.ZERO, "%");
pricingCondition.setPricingUnit(new BigDecimal(0), null);
catch (Exception ex) {
//pricingCondition.setInactive(PricingCustomizingConstants.InactiveFlag.INACTIVE_DUE_TO_ERROR);
userexitlogger.writeLogError("Error Occured in 927 formula, reason code=["+ex.getMessage()+"]");
return null;
//return condValue;
return null;
Thanks
Srikar -
Modify MVGR4 in formula for condition value
Hello everyone,
I want to modify komp-mvgr4 in a formula for condition value. Changes in komp structure are not saved, any idea which field I have to modify?
Many thanks!
AndreasSure. I have a new formula for a condition value which checks a lot of things to calculate the condition value. The result can also be zero. In all other cases than zero, I want to set an additional flag on the position to show that the condition is used. For this I choosed the material group 4. Now I have to modify the materialgroup 4 MVGR4 in the formula, if I change komp-mvgr4 is does not save the changes...
Andreas -
How to Dynamically construct the conditional IF statement in java
Is there a way to dynamically construct a conditional IF statement in java?
For example:
Suppose i have a 2D array like:
Array[the actual values to search for][the column number in the table to perform the search on].
e.g.
Array {
{"x"} , {1},
{"y"} , {2},
{"z"} , {3},
}How can i construct the if statement like:
Looping over table rows (tableRow) {
Looping over array {
IF ( {"x"}. equals( tableModel.getValueAt( tableRow, {1}) &&
{"y"}. equals( tableModel.getValueAt( tableRow, {2}) &&
{"z"}. equals( tableModel.getValueAt( tableRow, {3}) )
return true;
}The array can grow or shrink based on the values in it so therefore IF statement will grow or shrink. How can i achieve it?
If not then how can i achieve this?My understanding (feeble at best) is that a sieries of && elements will be evaluated in order until the first false value is encountered. So, in an "if a && b && c" statement where b is false c will never be evaluated and the conditional executable will not run. Is that what you mean?
Yes, logical expressions will not evaluate unnecessary operands. So you can safely write the following, for instance, without getting an error,
if ((anArray != null) && (anArray.length > 0)) { ... }because the second operand of the '&&' will never be evaluated if 'anArray' is null.
Also, is there a difference between & and &&?
& is a bitwise operator, && is a boolean operator. -
Condition value not updated when qty changed
hi all,
I have created a new condition ZPR1 (copied from PR00) and use a new formula for it.
There is a problem when I change the qty after the item is billed.
Suppose the original qty is 1 and total ZPR1 price is 100. When I change the qty to 2, the ZPR1 price is still 100! It will change to 200 if the item is not billed.
Anybody encounters such problem and how to solve?
ThanksHi,
I don't mean to change the unit price.
I mean the condition value (the item total price) is not updated
You can't change the price anymore in the condition tab after you billed
But when you change the qty of the item, the total value should change accordingly
And I think for my case I should not cancel the invoice. Suppose original qty is 10, and there is partial shipment of 7 and billed the customer. Later customer request to reduce the qty to 7 to complete the item. We should not cancel the invoice in this case.
Try to test with PR00 and PN00, you will see the item value will be changed according to the item qty. -
At time of return depot invoice creation , not capture Excise Condition Value
Hi,
my queastion is that
In retun process from Customer to Depot,
when user create return Depot invoice through t-code VF01 then Not capture Excise Condition Value ( JEXP - Basic Excise Duty , JCEP- Edu. Cess Duty and JA1X - Additional tax. ) at time of Depot. Invoice Creation.
we can also check Table J_1IRG23D, in this table have value of these Excise Cond. Value.
But Delivery No. is not update in table J_1IRG23D.
and I applied condition formula 356 in Procedure ZDOM02 ( Traders Pricing Procedure).
How can capture condition value of JEXP, JCEP and JA1X at time of Retrun Depot Invoice Creation ?
Guide me .....Hi,
I have flow your define step:
Returns from Customer to Depot
1 Create a return order in Depot
2 Key in the invoice number and execute
3 Assign Order Reason and save
4 Create a return delivery and do PGR. Maintain storage location 1030
5 Create Transfer posting in MB1B with movement type 453, storage location 1030 and save
6 Note down the material document reference
7 Go to J1IG to reverse excise issue posting
8 Click "Capture"
9 Key in the material document number and series group
10 Click "Details". Now select the line item and again click "More documents"
11 Key in the original excise invoice reference created at supplying plant
12 Skip all warning message and go back
13 Maintain the internal number and the year.
14 With this, entry from RG23D will be reversed
But still the excise condition values are not being captured during invoice VF01 and std depot routing 356 is being used.
Program name of depot routing is FV64A356.
we can also check Table J_1IRG23D, in this table have value of these Excise Cond. Value.
But Delivery No. is not update in table J_1IRG23D.
Guide me......... -
Condition value from previous PO changes total value of new PO
Dear gentlemen,
We have a surcharge condition, calculation type = B (Fixed amount), category = Delivery costs. When viewing header condition details in PO, there appears an unknown "condition base value" with no "rate unit" associated with it. This value is carried over to the next PO created, changing its total value, thus affecting inventory value. What is wrong with this condition? How can I not let the system carry over "condition value" from previous POs?
Regards,
Carlos Piana
La Universal
Guayaquil, Ecuador, South AmericaMy aim is the difference between 56062 on 10.07.2012 00:00:00 and 52013 on 13.04.2012 and so on.
The final table should look like this:
DateId
Severity
PageCount
DeviceId
ErrorId DIFF
13.04.2012 00:00:00
1
52013
163
1 52013
10.07.2012 00:00:00
1
56062
163
1 4049
13.11.2012 00:00:00
4
63907
163
1 ...
28.11.2012 00:00:00
4
64492
163
1
12.09.2012 00:00:00
4
61524
163
1
29.11.2012 00:00:00
4
64573
163
1
Why I am doing this is that I want to calculate an Printerindex. This is the Amount of Errors related to the volume of pages, printed.
The Formula in DAX is Measure:=(COUNT(FactErrors[ErrorId]))/(SUM(FactErrors[PagesCount])/10000)
So I get this PivotTable:
Zeilenbeschriftungen
CountDevices
SUM PageCount
CountErrors
PrinterIndex
MFP
523
90135296
1362
31,24906792
HP
125
30805190
241
5,529387202
Lexmark
369
53500358
856
27,39392853
Samsung
29
5829748
265
41,33069233
Samsung CLX-92x1 93x1 Series
22
5400624
246
38,36735967
Samsung SCX-8123 8128 Series
7
429124
19
4,482612183
You see, that if I can't SUM already summarized printed volume. Another way could be to aggregate the volume as MAX() but this is not working, either.
Zeilenbeschriftungen
CountDevices
MAX PageCount
CountErrors
PrinterIndex
MFP
523
435853
1362
0,151106177
HP
125
435853
241
0,07823357
Lexmark
369
312478
856
0,159998929
Samsung
29
64117
265
0,454565103
Samsung CLX-92x1 93x1 Series
22
64117
246
0,45550292
Samsung SCX-8123 8128 Series
7
42386
19
0,442762465
I hope you see my problem ... -
How to get xkomv-kwert (condition value) from a pricing condition ZZP1
Hi experts,
I have a pricing condition zcust that I need to modify in the sales order. The calculation of ZCUST is dependent on the condition value in another price condition ZZP1. The price for ZZP1 is a fixed amount of $6 which is split among line items in the order. In sapmv45A, when the code hits userexit_save_document_prepare, the value of xkomv-kwert (condition value) exist. In other user-exits in sapm45A, I was unable to find xkomv-kwert. My question is: How can I find the value of xkomv-kwert as i don't know how ZZP1 is calculated ?? There is no routine attached to ZZP1.
THE ZCUST has a routine 993 which is similar to 3. Here in program saplv61A, i was trying to get xkomv-kwert for ZZP1 but unable to get any data. Can anyone suggest where i can get the data (xkomv-kwert) for ZZP1 in saplv61a ?
I looked at userexit_xkomv_bewerten_end in saplv61a but it does not help.
XKomv-kbetr always has data. If i have ZZP1 data, then i can modify ZCUST.
Many thanks.
JoyceHi Jelena,
In VOFM, it is Formula/Condition Base Value for routine 993. In Pricing Procedure, it falls in column "Base Type" for 993.
Let's see if i can simplify this: In a sales order with 2 line items:
prices Amt Condition Value (USD)
Line 10 ZS1 sell price 2.30 1150
ZPP1 charge 6.36 3.40 (note the distribution **)
ZL1 3 3
ZR1 % 1.000% 11.50
ZR2 0.01 5
Suggested price = 2.35 1172.90
ZCUST 2.34 1170
total price 2.34 1170
Note: The ZCUST price is wrong. It is missing the ZPP1 charge which is 3.40. Zcust should be 1170 + 3.40 = 1173.40
Line 20 ZS1 sell price 25 1000
ZPP1 charge 6.36 2.96 (note the distribution **)
ZL1 3 3
ZR1 % 1.000% 10
ZR2 0.01 0.6
Suggested price = 25.41 1016.56
ZCUST 25.34 1013.60 (should be 1013.60 + 2.96)
Total price 25.34 1013.60
You can see the ZCUST is calculated incorrectly. The routine calculate zcust as $1170 and $1013.60 for each item which did not include the distribution amount of ZPP1 ($3.40 and $2.96).
When i debug the routine, the xkomv-kwert is zero. I am trying to get $3.40 and $2.96 so i can add to to zcust in the routine.
Am trying to determine in saplv61A at which include that i can see #3.40 and $2.96 for both line items in xkomv-kwert.
Then maybe i can modify the routine or saplv61A so it shows the correct zcust price after entering the 2 line items in the sales order create (VA01) ? Can you pls suggest ?
If i make the changes in USEREXIT_SAVE_DOCUMENT_PREPARE, then user cannot see the correct zcust until the order is saved. This would be too late to know the zcust price ahead of time.
Pls view in the Edit mode... i see my texts have been compressed.
Many thanks
Joyce
Edited by: Joyce Chan on Jul 9, 2009 10:24 PM
Edited by: Joyce Chan on Jul 9, 2009 10:25 PM -
Where to find Invoice Detail Condition Value
Hi Folks!
I'm working on a report where I need a column that brings me a total of shipping(condition value) where its value is entered manually when creating the invoice.
I know that the table KONV is the table that contains the information of the conditions, though this shipping value is entered manually, so I can't look for this value in this table because it would be inconsistent, I already checked the data just to make sure.
I also tried to lookup at the table VBRP(Invoice detail) for the fields KZWI1-KZWI6, however I can't get the values showed on the conditions of the invoice details(Trans. VF03).
I was wondering if anybody can tell me where I can get the value for this kind of conditions.
Anyhelp will be really appreciated.
Thanks in advice.
Regards,
Gilberto LiHi again!
Thanks for all your replies, i've found the field, it was KONV-KWERT, can't believe I couldn't see that. I was using the fieds KONV-KBETR * KONV-KAWRT, for those that were using a formula, but I never saw that KONV-KWERT already had the final value of the condition.
Thanks Again.
Regards,
Gilberto Li
Message was edited by: Gilberto Li
Maybe you are looking for
-
how do i change the memory/ram in my macbook pro and what brand would you buy
-
BI Data Temp Directory - safe to purge?
Hi, We are facing a disk space issue with our BIDATA/tmp directory. It is about 16gb in size and files keep getting created there. I am wondering if it's safe to purge this directory, or will there be any problems? Is it a good idea to set up a cron
-
Can't install flash plugin. Get "action list not found" error
Running 10.8.4 and Safari 6.05 Can't install Flash Player 11.6.602.167 Get an error "action list not found" Anyone know the answer?
-
How the relation is maintained between BOm and dependencies
Hi Gurus, Please tell me how the relation is maintained between BOm and dependencies
-
Email dissapeared. Can someone help?
I had dot mac service until a month back and have been wanting to renew but just dont have funds quite yet for the same. I saved all my dot mac email to a new folder that I created 'on my mac' so that I can search them when and if I wanted to. I come