Skip to Content
0
Former Member
Nov 28, 2006 at 12:36 PM

User exit value condition formula: how to access z fields of previous docum

29 Views

Hi Experts,

I have some requirements about price calculation. I am going to use a user exit automatic value condition formula, but I don´t know what coding I should use in order to achive the requirements.

I am going to try to explain it the best possible:

First step we create a business transaction ( contact type) and fill a “customer field” called gross price (Z field). After that we create a following up transaction (subsequent). This transaction is a sales type, and we must get the value filled in previous document and paste it in value condition PR00 automatically.

I have created the following class as a copy of an a SAP userexit example:

public class ZPR00ValueFormula extends ValueFormulaAdapter {

private static UserexitLogger userexitlogger = new UserexitLogger(ZPR00ValueFormula.class);

public BigDecimal overwriteConditionValue(IPricingItemUserExit item, IGroupConditionUserExit condition) {

BigDecimal result;

IPricingDocumentUserExit header = item.getUserExitDocument();

ICurrencyValue val = condition.getConditionValue(); //KONV-KWERT

userexitlogger.writeLogDebug("valor antiguo" + val.getValueAsString());

result = val.getValue().setScale(0, BigDecimal.ROUND_HALF_UP);

return result;

}

public BigDecimal overwriteGroupConditionValue(IPricingDocumentUserExit item, IGroupConditionUserExit condition) {

// do nothing

return null;

}

}

But I don´t know how to access the Z fields of the previous document. With variable header I get the header document of the actual document (sales type) from the item parameter of method overwriteConditionValue(IPricingItemUserExit item, IGroupConditionUserExit condition).

But how to get previous document (contact type)??? from variable header???

And after getting previous document, how to access a Z field??

Please, if somebody could attach the source code I would appreciate very much.

Thank in advance.

Kind Regards,

Rosa