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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I am trying to add multiple detail records to a Timecard using XAPI

Status
Not open for further replies.

sssdave

Programmer
Apr 15, 2003
3
CA
I am using VB6 and the XAPI to write multiple detail records to a Timecard in an AccPac Advantage database. The Timecard is created new each time and is not reuseable. I can open the database, and all the required views, add the employee, and write the first record to the Timecard, but when I try to write another record to the Timecard the process fails with no error message.

I am wondering if a key value is not being correctly set? I have been unable to find any comprehensive documentation describing this process in detail, does anyone know if some exists?
 
I have been using the xAPI for a while and I have not found any really helpful documentation on the subject. I do know that the views are used to ensure that data integity and the business rules are followed. This makes a failure due to a key field value not being updated unlikely without an error message.

Post some of your code and I'll see if I can see something. Which accpac version are youo using (4.2, 5.0, etc.)?



Thanks and Good Luck!

zemp
 
I am running AccPac Advantage 5.0A. The following is the VB code listing after all the required views have been opened. It makes it through the first update (where i = 0) then fails on the attempt to add a second entry.

CPTIMECARD1detail.Init

CPTIMECARD1detailFields("ENTRYTYPE").Value = "1"

CPTIMECARD1detail.Order = 0
CPTIMECARD1headerFields("EMPLOYEE").Value = EmployeeID

CPTIMECARD1headerFields("TIMECARD").Value = "1"
CPTIMECARD1headerFields("PEREND").Value = PeriodEnd

CPTIMECARD1detail.Init
CPTIMECARD1detail.Order = 0
CPTIMECARD1detail.Init
CPTIMECARD1detail.Init

For i = 0 To UBound(ChargeType)
If i = 0 Then
CPTIMECARD1detailFields("EARNDED").Value = ChargeType(i)
CPTIMECARD1detailFields("RATE").Value = Amount(i)
CPTIMECARD1detailFields("CATEGORY").Value = "5"

CPTIMECARD1detail.Insert
CPTIMECARD1detail.Order = 0
CPTIMECARD1header.Insert
CPTIMECARD1header.Read
CPTIMECARD1detail.Init
CPTIMECARD1detail.Order = 0
Else
CPTIMECARD1header.Read
CPTIMECARD1detail.Init
CPTIMECARD1detail.Order = 0

CPTIMECARD1detailFields("CATEGORY").PutWithoutVerification ("5")
CPTIMECARD1detailFields("EARNDED").PutWithoutVerification (ChargeType(i))
CPTIMECARD1detailFields("UNIQUE").PutWithoutVerification (Trim(Str(i)))

CPTIMECARD1detail.Read

CPTIMECARD1detailFields("RATE").Value = Amount(i)

CPTIMECARD1detail.Insert
CPTIMECARD1detail.Order = 0
CPTIMECARD1header.Insert
CPTIMECARD1header.Read
CPTIMECARD1detail.Init
CPTIMECARD1detail.Order = 0

End If
Next i
CPTIMECARD1detail.Order = 0

Thanks for your help

-- Dave
 
What I think is that your order of operations is off a bit. It also looks like you used a macro to give you a start on this. That is a good tool, I use it myself, however I found that the macros do so much more than is required and as a result they can be confusing.

I have found that following the steps below works well. Each view needs a bit of tweaking.

Header.init

HeaderFields.value=...
<all header fields>

for i=0 to whatever
detail.init
detailfields.value=...
<all detail fields>
detail.insert
next

header.insert
header.update

detail.cancel
header.cancel

For your code I would try the following...

CPTIMECARD1header.Init
CPTIMECARD1headerFields(&quot;EMPLOYEE&quot;).Value = EmployeeID
CPTIMECARD1headerFields(&quot;TIMECARD&quot;).Value = &quot;1&quot;
CPTIMECARD1headerFields(&quot;PEREND&quot;).Value = PeriodEnd

For i = 0 To UBound(ChargeType)
CPTIMECARD1detail.Init
CPTIMECARD1detailFields(&quot;EARNDED&quot;).Value = ChargeType(i)
CPTIMECARD1detailFields(&quot;RATE&quot;).Value = Amount(i)
CPTIMECARD1detailFields(&quot;CATEGORY&quot;).Value = &quot;5&quot;
CPTIMECARD1detail.Insert
Next i

CPTIMECARD1header.Insert
CPTIMECARD1header.Update

I was unable to test this because I don't have payroll installed right now. Let us know if it works, if not I can run some tests myself.

Thanks and Good Luck!

zemp
 
zemp you are a star! Structuring the the calls to the XAPI in the manner you suggested works perfectly. Thanks so much for your help.

-- Dave
 
Glad to be of help.

Thanks and Good Luck!

zemp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top