×
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

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

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

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

(OP)
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?

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

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

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

(OP)
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

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

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("EMPLOYEE").Value = EmployeeID
   CPTIMECARD1headerFields("TIMECARD").Value = "1"
   CPTIMECARD1headerFields("PEREND").Value = PeriodEnd

   For i = 0 To UBound(ChargeType)
      CPTIMECARD1detail.Init
      CPTIMECARD1detailFields("EARNDED").Value = ChargeType(i)
      CPTIMECARD1detailFields("RATE").Value = Amount(i)
      CPTIMECARD1detailFields("CATEGORY").Value = "5"
      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

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

(OP)
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

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

Glad to be of help.

Thanks and Good Luck!

zemp

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! Already a Member? Login

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