×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Post multiple batch AR Receipt - error

Post multiple batch AR Receipt - error

Post multiple batch AR Receipt - error

(OP)
I'm trying to add multiple AR Receipt and put the batch number in to a list so that when posting batch it is inside the loop. But upon Posting the batch I've got an error "Cannot post batch XX. Batch status is not Ready To Post or Post In Progress. - Error occurred during posting. No error batch created."

I know there's a problem in this line:

CODE --> vb

For Each batch In arr_batch
	ARRECMAC1detail4.Cancel()
	ARRECMAC1detail4Fields.FieldByName("STDOCDTE").PutWithoutVerification(vbNull)     ' Starting Date
	ARRECMAC1batchFields.FieldByName("PROCESSCMD").PutWithoutVerification("3")       ' Process Command
	ARRECMAC1batch.Process()
	
	ARRECMAC1batchFields.FieldByName("BATCHSTAT").PutWithoutVerification("7")        ' Batch Status
	
	ARRECMAC1batch.Update()
	ARRECMAC1batch.Update()
	
	ARRECMAC1batchFields.FieldByName("PROCESSCMD").PutWithoutVerification("1")       ' Process Command
	
	ARRECMAC1batch.Process()
	ARPAYMPOST2Fields.FieldByName("BATCHIDFR").PutWithoutVerification(batch)          ' Post Batch From
	
	ARPAYMPOST2Fields.FieldByName("BATCHIDTO").PutWithoutVerification(batch)          ' Post Batch To
	
	ARPAYMPOST2.Process()
	ARRECMAC1batch.Read()
	ARRECMAC1detail4.Cancel()
	ARRECMAC1detail2.Browse("(CODTRXTYPE = 81)", 1)
	
	ARRECMAC1detail2Fields.FieldByName("CNTSEQ").PutWithoutVerification("-99999")    ' Sequence No.
	
	ARRECMAC1detail2.Browse("(CODTRXTYPE = 81)", -1)
	ARRECMAC1detail2.Fetch()
	ARRECMAC1headerFields.FieldByName("CNTITEM").PutWithoutVerification("-9999999")   ' Entry Number
	ARRECMAC1header.Browse("", 1)
	ARRECMAC1header.Fetch()
	ARRECMAC1detail2.Browse("(CODTRXTYPE = 81)", 1)
	
	ARRECMAC1detail2Fields.FieldByName("CNTSEQ").PutWithoutVerification("-99999")    ' Sequence No.
	
	ARRECMAC1detail2.Browse("(CODTRXTYPE = 81)", -1)
	ARRECMAC1detail2.Fetch()
Next 

Here's the full code:

CODE --> vb

Dim newDs As DataSet
newDs = New DataSet
newDs = drDetails

Dim oInvoiceNo As String = ""

Dim ctr As Integer = 0

For Each oDr As DataRow In newDs.Tables(0).Rows
	ARRECMAC1batch.RecordClear()
	
	ARRECMAC1batchFields.FieldByName("CODEPYMTYP").PutWithoutVerification("CA")      ' Batch Type
	
	ARRECMAC1batchFields.FieldByName("CNTBTCH").PutWithoutVerification("0")          ' Batch Number
	
	ARRECMAC1batch.RecordCreate(1)
	
	ARRECMAC1batchFields.FieldByName("PROCESSCMD").PutWithoutVerification("2")       ' Process Command
	
	ARRECMAC1batch.Process()
	ARRECMAC1detail4.Cancel()
	temp = ARRECMAC1header.Exists
	ARRECMAC1header.RecordCreate(2)
	ARRECMAC1detail4.Cancel()
	temp = ARRECMAC1header.Exists
	ARRECMAC1batchFields.FieldByName("BATCHDESC").PutWithoutVerification("Astute Import - " & Date.Now)       ' Description
	
'Get Batch number 
	_newBatch = ARRECMAC1batchFields.FieldByName("CNTBTCH").Value
	arr_batch.Add(_newBatch)
	
	ARRECMAC1batch.Update()
'ARRECMAC1headerFields.FieldByName("TEXTRMIT").Value = "BB"                        ' Entry Description
	
	ARRECMAC1headerFields.FieldByName("IDCUST").Value = oDr("Card ID")                      ' Customer Number
	
	ARRECMAC1detail1.Cancel()
	ARRECMAC1headerFields.FieldByName("PROCESSCMD").PutWithoutVerification("0")      ' Process Command Code
	ARRECMAC1header.Process()
	ARRECMAC1detail4.Cancel()
	
	ARRECMAC1detail4Fields.FieldByName("PAYMTYPE").Value = "CA"                       ' Batch Type
'ARRECMAC1detail4Fields.FieldByName("CNTBTCH").Value = "10"                        ' Batch Number
	ARRECMAC1detail4Fields.FieldByName("CNTITEM").Value = "0"                         ' Entry Number
	ARRECMAC1detail4Fields.FieldByName("IDCUST").Value = oDr("Card ID")                     ' ID Customer
	ARRECMAC1detail4Fields.FieldByName("AMTRMIT").Value = "0.000"                     ' Receipt Amount
	ARRECMAC1detail4Fields.FieldByName("STDOCDTE").PutWithoutVerification(DateSerial(100, 1, 1))    ' Starting Date
	ARRECMAC1detail4Fields.FieldByName("PROTYPE").PutWithoutVerification("1")        ' Process Type
	
	ARRECMAC1detail4.Process()
	
	ARRECMAC1detail4Fields.FieldByName("STDOCSTR").PutWithoutVerification("")        ' Starting Doc. Number
	ARRECMAC1detail4Fields.FieldByName("STDOCDTE").PutWithoutVerification(vbNull)     ' Starting Date
	ARRECMAC1detail4Fields.FieldByName("STDOCAMT").PutWithoutVerification("-999999999999999.999")   ' Starting Amount
	ARRECMAC1detail1.RecordClear()
	ARRECMAC1detail1.RecordCreate(0)
	
	ARRECMAC1detail1Fields.FieldByName("IDINVC").Value = oDr("Invoice No")                        ' Document Number
	ARRECMAC1detail1Fields.FieldByName("CNTPAYM").Value = "1"                         ' Payment Number
	ARRECMAC1detail1Fields.FieldByName("AMTPAYM").Value = oDr("Amount Applied")                        ' Document Number
	
	ARRECMAC1detail1.Insert()
	
	ARRECMAC1detail1Fields.FieldByName("CNTLINE").PutWithoutVerification("-1")       ' Line Number
	
	ARRECMAC1detail1.Read()
	ARRECMAC1headerFields.FieldByName("AMTRMIT").Value = oDr("Amount Applied")                   ' Bank Receipt Amount
	
	Dim _date As String
	_date = oDr("Receipt Date").ToString.Replace(".", "/")
	Dim adate As DateTime = DateTime.ParseExact(_date, "dd/MM/yyyy", CultureInfo.InvariantCulture)
	Dim reformatted As String = adate.ToString("yyyyMMdd", CultureInfo.InvariantCulture)
	
	ARRECMAC1headerFields.FieldByName("DATERMIT").Value = adate    ' Receipt Date/Adjustment Date
	ARRECMAC1headerFields.FieldByName("DATEBUS").Value = Date.Today     ' Posting Date
	
	ARRECMAC1detail5Fields.FieldByName("OPTFIELD").PutWithoutVerification("JOBCODE")   ' Optional Field
	ARRECMAC1detail5.Read()
	ARRECMAC1detail5Fields.FieldByName("SWSET").Value = "1"                           ' Value Set  
	ARRECMAC1detail5.Update()
	
	ARRECMAC1detail5Fields.FieldByName("OPTFIELD").PutWithoutVerification("RECHCLIENT")   ' Optional Field 
	ARRECMAC1detail5.Read()
	ARRECMAC1detail5Fields.FieldByName("SWSET").Value = "1"                           ' Value Set  
	ARRECMAC1detail5.Update()
	
	ARRECMAC1detail5.Read()
	ARRECMAC1header.Insert()
	ARRECMAC1detail4.Cancel()
	ARRECMAC1detail4Fields.FieldByName("PAYMTYPE").Value = "CA"                       ' Batch Type
	
'ARRECMAC1detail4Fields.FieldByName("CNTBTCH").Value = "10"                        ' Batch Number
	ARRECMAC1detail4Fields.FieldByName("CNTITEM").Value = "1"                         ' Entry Number
	ARRECMAC1detail4Fields.FieldByName("IDCUST").Value = oDr("Card ID")                     ' ID Customer
	ARRECMAC1detail4Fields.FieldByName("AMTRMIT").Value = oDr("Amount Applied")                  ' Receipt Amount
	ARRECMAC1detail4Fields.FieldByName("STDOCDTE").PutWithoutVerification(DateSerial(100, 1, 1))    ' Starting Date
	ARRECMAC1detail4Fields.FieldByName("PROTYPE").PutWithoutVerification("1")        ' Process Type
	
	ARRECMAC1detail4.Process()
	
	ARRECMAC1detail4Fields.FieldByName("STDOCSTR").PutWithoutVerification("")        ' Starting Doc. Number
	ARRECMAC1detail4Fields.FieldByName("STDOCDTE").PutWithoutVerification(vbNull)     ' Starting Date
	ARRECMAC1detail4Fields.FieldByName("STDOCAMT").PutWithoutVerification("-999999999999999.999")   ' Starting Amount
	ARRECMAC1batch.Read()
	ARRECMAC1headerFields.FieldByName("CNTITEM").PutWithoutVerification("0")         ' Entry Number
	ARRECMAC1header.RecordCreate(2)
	
	ctr += 1
Next

Catch ex As Exception
isErrHeader = True
line_no = 0
sError = Err.Description
fHandleSageErrors(sError)
sError = "ERR~~<Document Number - " & _newBatch & "> " & sError
fLogIt("[Err]-fCreateARReceiptTransaction-<Document Number - " & _newBatch & "> Error: " & sError)

For Each batch In arr_batch
	ARRECMAC1batchFields.FieldByName("CNTBTCH").Value = batch                     ' Batch Number
	ARRECMAC1batch.Read()
	ARRECMAC1batchFields.FieldByName("PROCESSCMD").PutWithoutVerification("2")      ' Process Command 
	ARRECMAC1batch.Process()
	
	ARRECMAC1batchFields.FieldByName("BATCHSTAT").Value = "4"                         ' Batch Status 4 = Delete
	ARRECMAC1batch.Update()
	
	ARRECMAC1batchFields.FieldByName("PROCESSCMD").PutWithoutVerification("0")      ' Process Command 
	ARRECMAC1batch.Process()
Next

Return False
End Try

'Post Command
'Dim batchNumber As String = ""
'batchNumber = ARRECMAC1headerFields.FieldByName("CNTBTCH").Value

For Each batch In arr_batch
	ARRECMAC1detail4.Cancel()
	ARRECMAC1detail4Fields.FieldByName("STDOCDTE").PutWithoutVerification(vbNull)     ' Starting Date
	ARRECMAC1batchFields.FieldByName("PROCESSCMD").PutWithoutVerification("3")       ' Process Command
	ARRECMAC1batch.Process()
	
	ARRECMAC1batchFields.FieldByName("BATCHSTAT").PutWithoutVerification("7")        ' Batch Status
	
	ARRECMAC1batch.Update()
	ARRECMAC1batch.Update()
	
	ARRECMAC1batchFields.FieldByName("PROCESSCMD").PutWithoutVerification("1")       ' Process Command
	
	ARRECMAC1batch.Process()
	ARPAYMPOST2Fields.FieldByName("BATCHIDFR").PutWithoutVerification(batch)          ' Post Batch From
	
	ARPAYMPOST2Fields.FieldByName("BATCHIDTO").PutWithoutVerification(batch)          ' Post Batch To
	
	ARPAYMPOST2.Process()
	ARRECMAC1batch.Read()
	ARRECMAC1detail4.Cancel()
	ARRECMAC1detail2.Browse("(CODTRXTYPE = 81)", 1)
	
	ARRECMAC1detail2Fields.FieldByName("CNTSEQ").PutWithoutVerification("-99999")    ' Sequence No.
	
	ARRECMAC1detail2.Browse("(CODTRXTYPE = 81)", -1)
	ARRECMAC1detail2.Fetch()
	ARRECMAC1headerFields.FieldByName("CNTITEM").PutWithoutVerification("-9999999")   ' Entry Number
	ARRECMAC1header.Browse("", 1)
	ARRECMAC1header.Fetch()
	ARRECMAC1detail2.Browse("(CODTRXTYPE = 81)", 1)
	
	ARRECMAC1detail2Fields.FieldByName("CNTSEQ").PutWithoutVerification("-99999")    ' Sequence No.
	
	ARRECMAC1detail2.Browse("(CODTRXTYPE = 81)", -1)
	ARRECMAC1detail2.Fetch()
Next 

RE: Post multiple batch AR Receipt - error

1. NEVER delete error batches
2. All your "temp =" lines are junk code
3. Use the ARPYPT view to post batches

Sage 300 Whisperer

RE: Post multiple batch AR Receipt - error

Here's a clip from some object code that I have to handle batches (thus some of the variables are defined elsewhere). Do future you a favour and give your variables meaningful names and clean up the code.

CODE --> VB

With ReceiptBatch
        .Fields("PROCESSCMD").PutWithoutVerification ("3")    ' Process Command
        .Process
        .Fields("BATCHSTAT").Value = "7"                      ' Batch Status
        .Update
        .Fields("PROCESSCMD").PutWithoutVerification ("1")    ' Process Command
        .Process
    End With

    Dim ARReceiptPost As AccpacCOMAPI.AccpacView
    fDBLink.OpenView "AR0049", ARReceiptPost

    ARReceiptPost.Fields("BATCHIDFR").PutWithoutVerification BatchNumber
    ARReceiptPost.Fields("BATCHIDTO").PutWithoutVerification BatchNumber

    ARReceiptPost.Process 

RE: Post multiple batch AR Receipt - error

(OP)
What is "ARPYPT" means?

@DjangMan, your code is just similar to mine.

RE: Post multiple batch AR Receipt - error

It's a Sage view, AR0049.

Sage 300 Whisperer

RE: Post multiple batch AR Receipt - error

(OP)
Here's my code prior to For each Loop.

So I guess the AR0049 is already declared for post.

CODE --> vb

Dim mDBLinkCmpRW As AccpacCOMAPI.AccpacDBLink
            mDBLinkCmpRW = sSageSession.OpenDBLink(AccpacCOMAPI.tagDBLinkTypeEnum.DBLINK_COMPANY, AccpacCOMAPI.tagDBLinkFlagsEnum.DBLINK_FLG_READWRITE)
            Dim mDBLinkSysRW As AccpacCOMAPI.AccpacDBLink
            mDBLinkSysRW = sSageSession.OpenDBLink(AccpacCOMAPI.tagDBLinkTypeEnum.DBLINK_SYSTEM, AccpacCOMAPI.tagDBLinkFlagsEnum.DBLINK_FLG_READWRITE)

            Dim temp As Boolean
            Dim ARRECMAC1batch As AccpacCOMAPI.AccpacView
            Dim ARRECMAC1batchFields As AccpacCOMAPI.AccpacViewFields
            mDBLinkCmpRW.OpenView("AR0041", ARRECMAC1batch)
            ARRECMAC1batchFields = ARRECMAC1batch.Fields

            Dim ARRECMAC1header As AccpacCOMAPI.AccpacView
            Dim ARRECMAC1headerFields As AccpacCOMAPI.AccpacViewFields
            mDBLinkCmpRW.OpenView("AR0042", ARRECMAC1header)
            ARRECMAC1headerFields = ARRECMAC1header.Fields

            Dim ARRECMAC1detail1 As AccpacCOMAPI.AccpacView
            Dim ARRECMAC1detail1Fields As AccpacCOMAPI.AccpacViewFields
            mDBLinkCmpRW.OpenView("AR0044", ARRECMAC1detail1)
            ARRECMAC1detail1Fields = ARRECMAC1detail1.Fields

            Dim ARRECMAC1detail2 As AccpacCOMAPI.AccpacView
            Dim ARRECMAC1detail2Fields As AccpacCOMAPI.AccpacViewFields
            mDBLinkCmpRW.OpenView("AR0045", ARRECMAC1detail2)
            ARRECMAC1detail2Fields = ARRECMAC1detail2.Fields

            Dim ARRECMAC1detail3 As AccpacCOMAPI.AccpacView
            Dim ARRECMAC1detail3Fields As AccpacCOMAPI.AccpacViewFields
            mDBLinkCmpRW.OpenView("AR0043", ARRECMAC1detail3)
            ARRECMAC1detail3Fields = ARRECMAC1detail3.Fields

            Dim ARRECMAC1detail4 As AccpacCOMAPI.AccpacView
            Dim ARRECMAC1detail4Fields As AccpacCOMAPI.AccpacViewFields
            mDBLinkCmpRW.OpenView("AR0061", ARRECMAC1detail4)
            ARRECMAC1detail4Fields = ARRECMAC1detail4.Fields

            Dim ARRECMAC1detail5 As AccpacCOMAPI.AccpacView
            Dim ARRECMAC1detail5Fields As AccpacCOMAPI.AccpacViewFields
            mDBLinkCmpRW.OpenView("AR0406", ARRECMAC1detail5)
            ARRECMAC1detail5Fields = ARRECMAC1detail5.Fields

            Dim ARRECMAC1detail6 As AccpacCOMAPI.AccpacView
            Dim ARRECMAC1detail6Fields As AccpacCOMAPI.AccpacViewFields
            mDBLinkCmpRW.OpenView("AR0170", ARRECMAC1detail6)
            ARRECMAC1detail6Fields = ARRECMAC1detail6.Fields

            ARRECMAC1batch.Compose(New AccpacCOMAPI.AccpacView() {ARRECMAC1header})

            ARRECMAC1header.Compose(New AccpacCOMAPI.AccpacView() {ARRECMAC1batch, ARRECMAC1detail3, ARRECMAC1detail1, ARRECMAC1detail5, ARRECMAC1detail6})

            ARRECMAC1detail1.Compose(New AccpacCOMAPI.AccpacView() {ARRECMAC1header, ARRECMAC1detail2, ARRECMAC1detail4})

            ARRECMAC1detail2.Compose(New AccpacCOMAPI.AccpacView() {ARRECMAC1detail1})

            ARRECMAC1detail3.Compose(New AccpacCOMAPI.AccpacView() {ARRECMAC1header})

            ARRECMAC1detail4.Compose(New AccpacCOMAPI.AccpacView() {ARRECMAC1batch, ARRECMAC1header, ARRECMAC1detail3, ARRECMAC1detail1, ARRECMAC1detail2})

            ARRECMAC1detail5.Compose(New AccpacCOMAPI.AccpacView() {ARRECMAC1header})

            ARRECMAC1detail6.Compose(New AccpacCOMAPI.AccpacView() {ARRECMAC1header})


            Dim ARPAYMPOST2 As AccpacCOMAPI.AccpacView
            Dim ARPAYMPOST2Fields As AccpacCOMAPI.AccpacViewFields
            mDBLinkCmpRW.OpenView("AR0049", ARPAYMPOST2)
            ARPAYMPOST2Fields = ARPAYMPOST2.Fields

            Dim _newBatch As String = vbNullString
            Dim batchNumber As String = ""

            Dim arr_batch As New List(Of String)() 

RE: Post multiple batch AR Receipt - error

(OP)
Ok, figured it out. Thanks.

RE: Post multiple batch AR Receipt - error

What was the issue?

RE: Post multiple batch AR Receipt - error

(OP)
I just used your code and add maybe two lines of code.

CODE --> vb

            Dim ReceiptBatch As AccpacCOMAPI.AccpacView
Dim ReceiptBatchFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView("AR0041", ReceiptBatch)
ReceiptBatchFields = ReceiptBatch.Fields

For Each batch In arr_batch
With ReceiptBatch
.Fields.FieldByName("CODEPYMTYP").Value = "CA"
.Fields.FieldByName("CNTBTCH").Value = batch
.Read()
.Fields.FieldByName("PROCESSCMD").PutWithoutVerification("3") ' Process Command
.Process()
.Fields.FieldByName("BATCHSTAT").Value = "7" ' Batch Status
.Update()
.Fields.FieldByName("PROCESSCMD").PutWithoutVerification("1") ' Process Command
.Process()
End With

Dim ARReceiptPost As AccpacCOMAPI.AccpacView
mDBLinkCmpRW.OpenView("AR0049", ARReceiptPost)

ARReceiptPost.Fields.FieldByName("BATCHIDFR").PutWithoutVerification(batch)
ARReceiptPost.Fields.FieldByName("BATCHIDTO").PutWithoutVerification(batch)

ARReceiptPost.Process()

Next

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close