Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Can UI API allow insert a new record in Sales Order UI Form

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.

Former Member
Former Member replied

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

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question