Creating a batch in AR invoice data entry

Hi Forum,

I am having an issue creating a batch, or that's is what i think.

the code below is throwing a message.

InvoiceNo = "" : BatchNo = ""

IF oBatch.nBatchEnabled = 1 Then
retVal = oBatch.nSelectBatch(BatchNo)
msgBox "retVal: " & retVal & " Batch no: " & BatchNo
end if

If retVal = 0 Then
MsgBox(o.sLastErrorMsg & vbCRLF & "Batch")
End If

'r = o.nGetNextInvoiceNo(InvoiceNo)
r = o.nSetKeyValue("InvoiceNo$", InvoiceNum)
r = o.nSetKeyValue("InvoiceType$", "IN")
strInvoiceNum = "" : strInvoiceNum = Right("0000000" & InvoiceNum, 7)
InvoiceKey = "" : InvoiceKey = mid(strInvoiceNum,1,7) & "IN"
msgbox "Record Key: " & InvoiceKey
r = o.nSetKey()

the message is..

I've done this same code a few times...

any advise ?

Regards,

Manuel Roman

  • I don't know what oBatch is referring to but BatchEnabled property and SelectBatch method should come from your regular data entry biz object:

    IF o.nBatchEnabled = 1 Then
    retVal = o.nSelectBatch(BatchNo)

  • in reply to Alnoor

    HI Alnoor,

    I've tried that and i get the same results.

    Regrads,

    Manuel

  • in reply to mroman

    In fact, the next batch number gets created in invoice data entry.

  • in reply to mroman

    by doing that i am getting the following error message

    and i think your code is correct.

    But why AM i getting the above error message.

    Regards

  • in reply to Alnoor

    Creates de Batch and the Invoice then i get the message

    Regards,

  • Your lines when dealing with the invoice key are out of order. You have the GetNextInvoiceNo commented out yet you're doing SetkeyValue on the InvoiceNo with a variable that doesn't appear to have been assigned a value until 2 lines later. Still don't see where you are assignig a value to the InvoiceNum variable. You're also referencing the strInvoiceNum variable but it doesn't look like you are using it anywhere else.

    As Alnoor said, you should be able to check if batches are enabled using the property of your business object as well as selecting the batch via the SelectBatch method of your business object.

    If your invoice number could possibly be less than 7 characters, then you should stick with using SetKeyValue on each field that makes up the primary key so they are padded correctly followed by the SetKey method without any arguments.

  • in reply to David Speck

    Thanks All for the help... the real issue here was the values that i am getting from the data source.

    It was creating the BatchNo and the InvoiceNo correctly, but the values for some fields needed to be trimmed.

    i spent time cleaning the fields and now it is creating the invoice and lines, now i need to make sure that all required fields in Sage are coming from the source.

    Thanks for all the help.

    As always, greatly appreciated.

    Regards,

    Manuel