cancel
Showing results for 
Search instead for 
Did you mean: 

GetDueDate from SBOBlob Object

CarlesCostaMun
Participant
0 Kudos

Hi everyone,

I try to get de DueDate from:

Public Sub TestMethod_GetDueDate(ByVal cardCode As String, ByVal refDate As Date)
    Dim vObj As SAPbobsCOM.SBObob
    Dim rs As SAPbobsCOM.Recordset
    Dim strResult As String
    Dim errResult As String
    Set vObj =m_company. GetBusinessObject(BoBridge)
    Set rs =m_company. GetBusinessObject(BoRecordset)
    Set rs = vObj.GetDueDate(cardCode, refDate)
    strResult = RecorsetToText(rs)
    errResult = GetLastErrorString()
    OutputMessage(strResult, errResult)
End Sub

But is not working.

Is there anyone that work it?

The SBO version is 882 PL09.

Thanks in advance

Accepted Solutions (1)

Accepted Solutions (1)

pedro_magueija
Active Contributor
0 Kudos

Hi Carles,

Can you elaborate what is not working? Do you get an error? Does it return an unexpected result?


Best regards,

Pedro Magueija


View Pedro Magueija's profile on LinkedIn

CarlesCostaMun
Participant
0 Kudos

Hi Pedro,

Any error, but not set the correct due date.

strResult  = refDate



I need to get de DueDate given days to pay and day to pay. For example, +30 days and 15, 30 (day of month).

With the function, for today, return 16/10. The correct would be 30/10.

Thanks

pedro_magueija
Active Contributor
0 Kudos

Hi Carles,

Did you check the payment terms for the given BP? That will affect the due date calculation.


Best regards,

Pedro Magueija


View Pedro Magueija's profile on LinkedIn

CarlesCostaMun
Participant
0 Kudos

Hi Pedro,

Yes I did.

According BP, the correct due date is 30/10. If I create a new document (invoice) and set today as DocDate, UI API sets 30/10 but when I try to use this function, DI API returns the same DocDate.

Thanks.

CarlesCostaMun
Participant
0 Kudos

Hi,

I done this:

Public Function getDueDateBP(ByVal CardCode As String, ByVal RefDate As Date) As Date

        '

        getDueDateBP = RefDate

        '

        Dim ls As String

        Dim oRcs As SAPbobsCOM.Recordset = Nothing

        '

        ls = ""

        ls &= " SELECT" & vbCrLf

        ls &= " PL.Months [MonthAdded]," & vbCrLf

        ls &= " PL.PmntDate as [Day]" & vbCrLf

        ls &= " FROM(" & vbCrLf

        ls &= "     SELECT" & vbCrLf

        ls &= "     CASE" & vbCrLf

        ls &= "     WHEN PmntDate >= " & RefDate.Day & " THEN 0" & vbCrLf

        ls &= "     ELSE 1" & vbCrLf

        ls &= " END as [Months],*" & vbCrLf

        ls &= " FROM CRD5 " & vbCrLf

        ls &= " WHERE (CardCode = '" & CardCode & "')" & vbCrLf

        ls &= " )PL" & vbCrLf

        ls &= " ORDER BY PL.Months, PL.PmntDate" & vbCrLf

        '

        oRcs = m_SBOAddon.SBO_Company.GetBusinessObject(BoRecordset)

        '

        oRcs.DoQuery(ls)

        ' Guardem en un HT els dies i els mesos a afegir a l'actual data

        If Not oRcs.EoF Then

            oRcs.MoveFirst()

            Dim oDate = New Date(RefDate.Year, RefDate.Month, RefDate.Day)

            While Not oRcs.EoF

                oDate = DateAdd(DateInterval.Month, oRcs.Fields.Item("MonthAdded").Value, oDate)

                'CDate(oDate).AddMonths(oRcs.Fields.Item("MonthAdded").Value)

                oDate = New Date(CDate(oDate).Year, CDate(oDate).Month, oRcs.Fields.Item("Day").Value)

                If IsDate(oDate) Then

                    getDueDateBP = oDate

                    Exit While

                End If

            End While

        End If

        '

        LiberarObjCOM(oRcs)

        '

    End Function

RefDate has added the days of payment (+30, +60...)

Thanks

pedro_magueija
Active Contributor
0 Kudos

Hi Carles,

Maybe it's related to the PL, the following code works fine for me in 9.0.

              // on the 16.09.2014

                Recordset rs = bob.GetDueDate("C23900", DateTime.Today);

                DateTime dueDate = rs.Fields.Item(0).Value;

                Console.WriteLine(dueDate);

The output is 16.10.2014 and the payment terms for the BP is 30 days.


Best regards,

Pedro Magueija


View Pedro Magueija's profile on LinkedIn

CarlesCostaMun
Participant
0 Kudos

Hi Pedro,

The same code on 882 does not work 😞

I'll try on 9.0 and I think you are right.

Thanks for everything!

Answers (0)