Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AP Batch/Invoice from VB6 - hit a wall.

Status
Not open for further replies.

mork571

Programmer
Nov 24, 2003
13
0
0
CA
By browsing these forums and playing with the Macro recording in Accpac, I think I've come pretty close, but I get the following error;
"View: AP0021. View call failed"

The error is thrown on the line "hHeader.Insert". My current code is as follows (tried a lot of different things, and always get that error on the insert of the header)..

any help / pointers / advice is appreciated.


Dim hSession As xapiSession
Dim hPost As xapiView
Dim hBatch As xapiView
Dim hHeader As xapiView
Dim hDetail1 As xapiView
Dim hDetail2 As xapiView

Set hSession = New xapiSession
hSession.Open "MARK", "MARK", "SAMINC", Date, 0
If Not IsNull(hSession) Then
Set hPost = hSession.OpenView("AP0039", "AP")
Set hBatch = hSession.OpenView("AP0020", "AP")
Set hHeader = hSession.OpenView("AP0021", "AP")
Set hDetail1 = hSession.OpenView("AP0022", "AP")
Set hDetail2 = hSession.OpenView("AP0023", "AP")

hBatch.Compose Array(hHeader)
hHeader.Compose Array(hBatch, hDetail1, hDetail2)
hDetail1.Compose Array(hHeader, hBatch)
hDetail2.Compose Array(hHeader)

hBatch.Fields("CNTBTCH").PutWithoutVerification ("0")
hBatch.Init
hBatch.Fields("BTCHDESC").Value = "New Batch " & Format(Date, "yyyy-MM-dd")
hBatch.Fields("BTCHTYPE").Value = 2
hBatch.Update
End If

hHeader.Init
With hHeader
.Fields("CNTITEM").Value = 1 ' !
.Fields("IDVEND").Value = "1200"
.Fields("IDINVC").Value = 1 ' !
.Fields("TEXTTRX").Value = 1
.Fields("IDTRX").Value = 12
.Fields("INVCDESC").Value = "yo - description here."
.Fields("ORDRNBR").Value = "order number"
.Fields("PONBR").Value = "P.O. Number"
.Fields("DATEINVC").Value = Date
.Fields("SWTAXBL").Value = 0
.Fields("BASETAX1").Value = 0
.Fields("BASETAX2").Value = 0
.Fields("BASETAX3").Value = 0
.Fields("BASETAX4").Value = 0
.Fields("BASETAX5").Value = 0
.Fields("AMTTAX1").Value = 0
.Fields("AMTTAX2").Value = 0
.Fields("AMTTAX3").Value = 0
.Fields("AMTTAX4").Value = 0
.Fields("AMTTAX5").Value = 0
End With

hDetail1.Init
With hDetail1
.Fields("CNTITEM").PutWithoutVerification (hHeader.Fields("CNTITEM").Value)
.Fields("CNTLINE").PutWithoutVerification ("0")
.Fields("CNTBTCH").PutWithoutVerification (hBatch.Fields("CNTBTCH").Value)
.Fields("IDDIST").PutWithoutVerification ("INV")
.Fields("AMTDIST").Value = "225.000"
End With

hDetail1.Insert
hHeader.Insert

hDetail1.Cancel
hHeader.Cancel

Set hPost = Nothing
Set hBatch = Nothing
Set hHeader = Nothing
Set hDetail1 = Nothing
Set hDetail2 = Nothing
 
woa. I thre a "hheader.update" in front of the insert and it seems to be working now.

proof-of-concept done. now on to the real work - I'm sure I'll be back with more questions (or even answers).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top