create custom order number :
createOrder Out-of-Box API has user exit com.yantra.yfs.japi.ue.YFSGetOrderNoUE (Java Interface)
getOrderNo() Method
java.lang.String getOrderNo(YFSEnvironment env,
java.util.Map inMap) throws
com.yantra.yfs.japi.YFSUserExitException
Steps to implement
- Go to createOrder API documentation
- Look for YFSGetOrderNoUE user exit
- Create java class CreateCustomerOrderNumberUE which implements YFSGetOrderNoUE user exit
- Code
package com.oms94.test; import java.util.Map; import com.yantra.yfs.japi.YFSEnvironment; import com.yantra.yfs.japi.YFSUserExitException; import com.yantra.yfs.japi.ue.YFSGetOrderNoUE; public class CreateCustomerOrderNumberUE implements YFSGetOrderNoUE { @Override public String getOrderNo(YFSEnvironment env, Map arg1) throws YFSUserExitException { return String.valueOf(System.currentTimeMillis()); } }
- Open CREATE_ORDER transaction
- Configure the newly created user exit
- Build and deploy
- Call createOrder API without passing an order number
<?xml version="1.0" encoding="UTF-8"?> <Order EnterpriseCode="Matrix-R" ShipToID="" ShipNode="Matrix_WH1" OrderName="13780347" PriorityCode="" BillToID="" FreightTerms="3rd Party" SellerOrganizationCode="Matrix-R" DocumentType="0001" BuyerOrganizationCode="" CustomerPONo="J0380257" ReceivingNode="" EnteredBy="EDI" ApplyDefaultTemplate="Y" CustCustPONo="J0380257" > <PersonInfoShipTo ZipCode="71303" City="Alexandria" DayFaxNo="" State="LA" EMailID="NA" Country="US" Company="ABC SYSTEMS " DayPhone="999-999-0100" AddressLine6="" AddressLine1="2112 N BOLTON AVE " AddressLine4="" AddressLine3="" AddressLine2="" AddressLine5="" FirstName="TECH" MiddleName="" LastName="" EveningPhone="" EveningFaxNo="" OtherPhone="" Beeper="" JobTitle="" MobilePhone=""/> <PersonInfoBillTo ZipCode="63045" City="Earth City" Department="" DayFaxNo="" State="MO" EMailID="" Country="US" Company="Interface Security Systems" DayPhone="999-999-999" AddressLine6="" AddressLine1="3773 Corporate Center Drive" AddressLine4="" AddressLine3="" AddressLine2="" AddressLine5="" FirstName="Lisa" MiddleName="" LastName="Shoup" JobTitle="" EveningPhone="" EveningFaxNo="" OtherPhone="999-999-999" Beeper="" MobilePhone=""/> <OrderLines> <OrderLine OrderedQty="1.0" ShipNode="Matrix_WH1" PrimeLineNo="1" ShipToID="" > <Item ItemID="100001" ItemDesc="Item Description" ProductClass=""/> <OrderLineTranQuantity TransactionalUOM="EACH"/> </OrderLine> </OrderLines> </Order>
<Order OrderNo="1488350221173" DocumentType="0001" EnterpriseCode="Matrix-R" OrderHeaderKey="2017022823370129850" />
- Call createOrder API with passing an order number
<?xml version="1.0" encoding="UTF-8"?> <Order OrderNo="ABC" EnterpriseCode="Matrix-R" ShipToID="" ShipNode="Matrix_WH1" OrderName="13780347" PriorityCode="" BillToID="" FreightTerms="3rd Party" SellerOrganizationCode="Matrix-R" DocumentType="0001" BuyerOrganizationCode="" CustomerPONo="J0380257" ReceivingNode="" EnteredBy="EDI" ApplyDefaultTemplate="Y" CustCustPONo="J0380257" > <PersonInfoShipTo ZipCode="71303" City="Alexandria" DayFaxNo="" State="LA" EMailID="NA" Country="US" Company="ABC SYSTEMS " DayPhone="999-999-0100" AddressLine6="" AddressLine1="2112 N BOLTON AVE " AddressLine4="" AddressLine3="" AddressLine2="" AddressLine5="" FirstName="TECH" MiddleName="" LastName="" EveningPhone="" EveningFaxNo="" OtherPhone="" Beeper="" JobTitle="" MobilePhone=""/> <PersonInfoBillTo ZipCode="63045" City="Earth City" Department="" DayFaxNo="" State="MO" EMailID="" Country="US" Company="Interface Security Systems" DayPhone="999-999-999" AddressLine6="" AddressLine1="3773 Corporate Center Drive" AddressLine4="" AddressLine3="" AddressLine2="" AddressLine5="" FirstName="Lisa" MiddleName="" LastName="Shoup" JobTitle="" EveningPhone="" EveningFaxNo="" OtherPhone="999-999-999" Beeper="" MobilePhone=""/> <OrderLines> <OrderLine OrderedQty="1.0" ShipNode="Matrix_WH1" PrimeLineNo="1" ShipToID="" > <Item ItemID="100001" ItemDesc="Item Description" ProductClass=""/> <OrderLineTranQuantity TransactionalUOM="EACH"/> </OrderLine> </OrderLines> </Order>
<?xml version="1.0" encoding="UTF-8"?> <Order OrderNo="ABC" DocumentType="0001" EnterpriseCode="Matrix-R" OrderHeaderKey="2017022823390529891" />
Points to remember
This user exit called only when order number (OrderNo Attribute) not passed. if order number passed this user exit not called.
Any exception: Current transaction rolled back
How to apply custom order number creation only for Sales order ?
When we implement user exit YFSGetOrderNoUE method getOrderNo(), logic gets applied to all the Order type.
If we wanted to apply only for one specific type follow below steps
a) Application Platform –> Order Fulfillment –> Order Fulfillment Repository –> Create Order Transaction
b) Open com.yantra.yfs.japi.ue.YFSGetOrderNoUE click on green color + symbol and select “Sales Order” from drop down for Document Type
Also you can read about How to check installed software 32 or 64 bit


Nice Article – I would like to add few more important points,
If your requirement is to have your order number based on the Document Type, say for an example,
Purchase Order Number should start with “P”, Return Order Number should start with “R”, Sales Order Number should start with “S”, then you can write custom logic in the YFSGetOrderNoUE implementation like below,
public String getOrderNo(YFSEnvironment env, @SuppressWarnings(“rawtypes”) Map inMap) {
String strDocumentType = (String) (inMap.get(“DocumentType”));
return getDocumentTypePrefix(sDocumentType) + String.valueOf(System.currentTimeMillis());
}
private String getDocumentTypePrefix(String strDocumentType){
if (strDocumentType.equals(“0001”)) {
return “O”;
} else if (strDocumentType.equals(“0003”)) {
return “R”;
} else if (strDocumentType.equals(“0004”)) {
return “TP”;
} else if (strDocumentType.equals(“0005”)) {
return “P”;
} else if (strDocumentType.equals(“0006”)) {
return “T”;
} else if (strDocumentType.equals(“0007”)) {
return “MS”;
} else if (strDocumentType.equals(“0015”)) {
return “QT”;
}
return “NA”;
}
Using this approach you can have only one userexit implemented which will take care of all the different type of document type order number requirement.
Thanks,
Sar
Happy Coding!!!!!
Thanks for valuable comments. For sure more to learn. Keep posting your comments.
Instead of DocumentType, can we do this with orderType?
Yes. If the order type part of Map you can always use any attribute from order XML. Hope this helps !!!
Nice posting!
Please write some more interview question.
Yes we are working on it. Will post ASAP. Thanks
Ravi,
We have added new post for OMS interview question. Please review and let us know your comment. Thanks
http://activekite.com/2017/07/03/ibm-sterling-oms-interview-questions/
Thanks
This will very help full, but need answer as well.
We are working on the answers. Keep you posted soon.
Instead of returning System.currrentTimeInMillis..mostly DB sequences are used.
We agree with you. System.currrentTimeInMillis given just for explaining user exit. Anyhow we should have given with DB sequence. We accept your suggestion.
very nice
While overriding UE with a java class and if, I have configured with a class name, which is not present.
ex. For a getOrderNoUE, if I have configured with class name as yyzz etc. Whether while creating order, sterling will throws an error.
Java ClassNotFound error will be thrown.
Hi
Could you please tell how to configure supply correction ue
Hi Team,
Sourcing Configuration setup any link please