on 11-12-2007 2:58 PM
Hi,
Does anyone has the experience to insert record into Sales Order form via UI API.
Say, i need to auto insert a new record (next line) with Item no, qty and unit price as bundled, when user entering item sold qty exceeds 100 pcs in the first line.
Appreciate if can share the sample codes in vb.net.
Hi,
Yes you can.
You just have to instanciate a Matrix object (For sales order the Item is 38) and a EditText
//strFormUID can be extracted from the item event handler
SAPbouiCOM.Form oForm = (SAPbouiCOM.Form)SBO_Application.Forms.Item(strFormUID);
SAPbouiCOM.Matrix oMatrix_Dto = (SAPbouiCOM.Matrix)oForm.Items.Item("38").Specific;
SAPbouiCOM.EditText ItemCodeEdit = (SAPbouiCOM.EditText)oMatrix_Dto.Columns.Item("1").Cells.Item(oMatrix_Dto.RowCount).Specific;
//strItemCode is the itemcode you want to add in the last line
ItemCodeEdit.Value=strItemCode
You also can set the quantity, at the moment you enter the info of the itemcode the system will put another line
SAPbouiCOM.EditText oQuantityEdit = (SAPbouiCOM.EditText)oMatrix_Dto.Columns.Item("11").Cells.Item(oMatrix_Dto.RowCount-1).Specific;
//db quantity is the quantity you want to put in the sales order.
oQuantityEdit.Value=dbQuantity
You can enter the information you need.
The logic to get the event that the quantity has exceed 100 pc is as the following.
SAPbouiCOM.Form oForm = (SAPbouiCOM.Form)SBO_Application.Forms.Item(strFormUID);
SAPbouiCOM.Matrix oMatrix_Dto = (SAPbouiCOM.Matrix)oForm.Items.Item("38").Specific;
SAPbouiCOM.EditText oQuantityEdit = (SAPbouiCOM.EditText)oMatrix_Dto.Columns.Item("11").Cells.Item(oMatrix_Dto.RowCount-1).Specific;
//You have to tae care with Culture info, because it is possible that a 6.00 would be brought as 6000000
if(Convert.ToDouble(oQuantityEdit.Value)>100)
{ do what you want}
the complete code will be:
SAPbouiCOM.Form oForm = (SAPbouiCOM.Form)SBO_Application.Forms.Item(strFormUID);
SAPbouiCOM.Matrix oMatrix_Dto = (SAPbouiCOM.Matrix)oForm.Items.Item("38").Specific;
//It is not the last, because when you entered the info of the first line the systems puts another line.
SAPbouiCOM.EditText oQuantityEdit = (SAPbouiCOM.EditText)oMatrix_Dto.Columns.Item("11").Cells.Item(oMatrix_Dto.RowCount-1).Specific;
if(Convert.ToDouble(oQuantityEdit.Value)>100)
{
int iRowCount=oMatrix_Dto.RowCount;
SAPbouiCOM.EditText ItemCodeEdit = (SAPbouiCOM.EditText)oMatrix_Dto.Columns.Item("1").Cells.Item(iRowCount).Specific;
//strItemCode is the itemcode you want to add in the last line
ItemCodeEdit.Value=strItemCode
oQuantityEdit = (SAPbouiCOM.EditText)oMatrix_Dto.Columns.Item("11").Cells.Item(iRowCount).Specific;
//db quantity is the quantity you want to put in the sales order.
oQuantityEdit.Value=dbQuantity
}
Best regards,
Guillermo Ocampo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
Can you manually insert one row in the matrix and fill the default cell values manually
Regards
Senthil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
108 | |
12 | |
11 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.