Skip to Content
0
Former Member
Feb 22, 2011 at 08:02 AM

GetFieldValue

39 Views

Hi Friends,

I have written a report for pending sales order. I want to put a field for TruckNo & Status. I have maintained the Masters for the same (UDO). I am picking the Truck No from CFL , i want that the status should be updated automatically from the masters whenever i change the trck no in the report.

My Form Fill code is as below:-

Public Sub FillForm()

oForm.Freeze(True)

Try

oForm = oApplication.SBO_Application.Forms.Item(_FormUID)

oMatrix = oForm.Items.Item("SchMatx").Specific

oedit1 = oForm.Items.Item("6").Specific

oedit2 = oForm.Items.Item("9").Specific

Dim fromdate As String = oedit1.Value

Dim todate As String = oedit2.Value

Dim strCode As String

Dim ColItemCode As SAPbouiCOM.Column

oDS = oForm.DataSources.DBDataSources.Add("ordr")

oDS = oForm.DataSources.DBDataSources.Add("rdr1")

oDS = oForm.DataSources.DBDataSources.Add("@PRS")

strSQL = "select T0.DocNum, T0.Cardcode,T0.CardName,T0.U_Grade,t1.U_NO_BOXES,t1.itemcode,T1.Dscription,T1.QUANTITY,T1.unitMsr,convert(char(8),T0.DocDueDate,112)as docDuedate,convert(char(8),T0.DocDate,112) as docdate From Ordr T0 INNER JOIN RDR1 T1 ON T0.DOCENTRY=T1.DOCENTRY where t0.DocDate between '" & fromdate & "' and '" & todate & "'"

oApplication.Utilities.ExecuteSQL(RS, strSQL)

oMatrix.FlushToDataSource()

For i = 1 To RS.RecordCount

oDS.SetValue("U_ORDERNO", i - 1, RS.Fields.Item("docnum").Value)

oDS.SetValue("U_CardCode", i - 1, RS.Fields.Item("CardCode").Value)

oDS.SetValue("U_CardName", i - 1, RS.Fields.Item("CardName").Value)

oDS.SetValue("U_Qty", i - 1, RS.Fields.Item("Quantity").Value)

oDS.SetValue("U_ItemCode", i - 1, RS.Fields.Item("ItemCode").Value)

oDS.SetValue("U_ItemName", i - 1, RS.Fields.Item("Dscription").Value)

oDS.SetValue("U_UoM", i - 1, RS.Fields.Item("UnitMsr").Value)

oDS.SetValue("U_OrderDue", i - 1, RS.Fields.Item("docDuedate").Value)

oDS.SetValue("U_OrderDat", i - 1, RS.Fields.Item("docdate").Value)

oDS.SetValue("U_Grade", i - 1, RS.Fields.Item("U_Grade").Value)

oDS.SetValue("U_Box", i - 1, RS.Fields.Item("U_NO_BOXES").Value)

If i < RS.RecordCount Then

oDS.InsertRecord(i - 1)

End If

RS.MoveNext()

Next

If RS.RecordCount = 0 Then

oApplication.Utilities.Message("No Pending Sales Order", SAPbouiCOM.BoStatusBarMessageType.smt_Error)

Exit Try

End If

oMatrix.LoadFromDataSource()

oMatrix.AutoResizeColumns()

Catch ex As Exception

oApplication.Utilities.Message(ex.Message, SAPbouiCOM.BoStatusBarMessageType.smt_Error)

Finally

oForm.Freeze(False)

RS = Nothing

oDS = Nothing

strSQL = ""

End Try

End Sub

Thanks

JS