×
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

ACCPACXAPILib VS AccpacCOMAPI in ORDER ENTRY

ACCPACXAPILib VS AccpacCOMAPI in ORDER ENTRY

ACCPACXAPILib VS AccpacCOMAPI in ORDER ENTRY

(OP)
I have been able to Connect in vb6 (not ACCPAC VBA) using the AccpacCOMAPI
using the following code:

'--------------
'--------------
' start
'--------------
'--------------

Dim mySession As New AccpacCOMAPI.AccpacSession
Dim mySignonManager As New AccpacSignonManager.AccpacSignonMgr

mySession.Init "", "CS", "CS0001", "51A"

mySignonManager.Signon mySession


On Error GoTo ACCPACErrorHandler

Dim mDBLinkCmpRW As AccpacCOMAPI.AccpacDBLink
Set mDBLinkCmpRW = mySession.OpenDBLink(DBLINK_COMPANY, DBLINK_FLG_READWRITE) ' DBLINK_COMPANY is 1 and DBLINK_FLG_READWRITE is 0

Dim mDBLinkSysRW As AccpacCOMAPI.AccpacDBLink
Set mDBLinkSysRW = mySession.OpenDBLink(DBLINK_SYSTEM, DBLINK_FLG_READWRITE) ' DBLINK_SYSTEM is 0 and DBLINK_FLG_READWRITE is 0


Dim OEORD1header As AccpacCOMAPI.AccpacView
Dim OEORD1headerFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "OE0520", OEORD1header
Set OEORD1headerFields = OEORD1header.Fields

Dim OEORD1detail1 As AccpacCOMAPI.AccpacView
Dim OEORD1detail1Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "OE0500", OEORD1detail1
Set OEORD1detail1Fields = OEORD1detail1.Fields

Dim OEORD1detail2 As AccpacCOMAPI.AccpacView
Dim OEORD1detail2Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "OE0740", OEORD1detail2
Set OEORD1detail2Fields = OEORD1detail2.Fields

Dim OEORD1detail3 As AccpacCOMAPI.AccpacView
Dim OEORD1detail3Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "OE0180", OEORD1detail3
Set OEORD1detail3Fields = OEORD1detail3.Fields

Dim OEORD1detail4 As AccpacCOMAPI.AccpacView
Dim OEORD1detail4Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "OE0680", OEORD1detail4
Set OEORD1detail4Fields = OEORD1detail4.Fields

OEORD1header.Compose Array(OEORD1detail1, OEORD1detail4, OEORD1detail3, OEORD1detail2, Nothing, Nothing, Nothing, Nothing, Nothing)

OEORD1detail1.Compose Array(OEORD1header, Nothing)

OEORD1detail2.Compose Array(OEORD1header, Nothing)

OEORD1detail3.Compose Array(OEORD1header, Nothing, OEORD1detail1)

OEORD1detail4.Compose Array(OEORD1header, Nothing, OEORD1detail1)


OEORD1header.Cancel
OEORD1header.Init

' do header fields
OEORD1headerFields("CUSTOMER").Value = "MICR15"
OEORD1headerFields("ORDNUMBER").Value = "TEST2"
OEORD1headerFields("LOCATION").Value = "MTR"

' do first detail
OEORD1detail1.Init
OEORD1detail1Fields("ITEM").Value = "PL1100SRG54582"
OEORD1detail1Fields("QTYORDERED").Value = "10.0000"
OEORD1detail1Fields("COMMINST").Value = "1"
    
    ' do comments for first detail
    OEORD1detail3.Init
    OEORD1detail3Fields("COIN").PutWithoutVerification ("c1")
    OEORD1detail3.Insert

    OEORD1detail3.Init
    OEORD1detail3Fields("COIN").PutWithoutVerification ("c2")
    OEORD1detail3.Insert

' insert first detail
OEORD1detail1.Insert

' do second detail
OEORD1detail1.Init
OEORD1detail1Fields("ITEM").Value = "PL4000SC411869005E"
OEORD1detail1Fields("QTYORDERED").Value = "10.0000"
OEORD1detail1Fields("COMMINST").Value = "1"

    ' do comments for second detail
    OEORD1detail3.Init
    OEORD1detail3Fields("COIN").PutWithoutVerification ("cc1")
    OEORD1detail3.Insert

    OEORD1detail3.Init
    OEORD1detail3Fields("COIN").PutWithoutVerification ("cc2")
    OEORD1detail3.Insert

    OEORD1detail3.Init
    OEORD1detail3Fields("COIN").PutWithoutVerification ("cc3")
    OEORD1detail3.Insert
    
' insert second detail
OEORD1detail1.Insert

' insert header
OEORD1header.Insert

'--------------
'--------------
' end
'--------------
'--------------

But the thing is that i never specified the company / user / pass

This code took one company by default, ok i have just one company in my test environnement
But i would like to knows a way to be sure i select the desired company,
because in my production environnement there is many company .

Then when is use : mySession.Init "", "CS", "CS0001", "51A"
i just use the code of an example i found in a thread,
I don't realy know what "CS" or ""CS0001" is for, "51A" is for my version but i'm not sure if i do this right....
the good thing is that with that code, i have been able to enter an Order Entry succesfuly ...


And when i try to use the xAPI (ACCPACXAPILib 1.1)

I am able to choose the good company and enter a order entry but for multiple detail in my order entry
i need to commit the header for each line of detail. (!!TIME WASTING!!!)
If i don't, only the last detail will be inserted...!!!
Strange thing because for the comment parts i don't have to commit for each row...!
It's seems to be a bug or something or i make something wrong and i'm not able to see it.

Any help on this would be appreciated

RE: ACCPACXAPILib VS AccpacCOMAPI in ORDER ENTRY

To start, the main difference between COMAPI and the xAPI is that CONAPI is meant to be used internally (macros, ACCPAC vba)and it will use the current ACCPAC session and company. The xAPI is designed to be used externally, from VB and you need to specify the Company and create a session. That said the syntax between the two is very similar. The main difference is how the sessions are set up.

'CS' and 'CS0001' designate the module (common services) and the view that is being used (view CS0001). They are required in view declarations. Views are the ACCPAC 'recordsets' and hold the data and buisness logic as well. Any coding with the xAPI is done with views.

You don't have to commit the header each time a detail is inserted. So there may be something missing in your code.

Take a look at Thread631-616765. I have tried to explain things further and have have provided links to other threads with more information. Take a look and try to make your code work. From what I see so far you are trying to use COMAPI code instead of xAPI code. It's a good start but needs to be adjusted every time.

Thanks and Good Luck!

zemp

RE: ACCPACXAPILib VS AccpacCOMAPI in ORDER ENTRY

(OP)
Thanks , i found that using .Cancel for DetailView and Comment View is not a good thing...
Everithing seems ok now , except execution time...

Right now i'm trying to make sure i call xapi function only if i need to because it take me 8 sec to save and order entry of 3 detail...
each time i use .process or .PutWithoutVerification it cost me time of execution .

RE: ACCPACXAPILib VS AccpacCOMAPI in ORDER ENTRY

Things that can slow the code down are the calls to the system manager with the .init, .insert, .process, etc. Try and limit then to only what is necessary. A macro using COMAPI does those far too often for what is needed by the xAPI. Basically one .init and one .insert for each record. Your posted code above does it for each field (I don't know if you are still doing that however). Also a .process is not always needed. Trial and error is the only way to know for sure.

.putwithoutverification is usually faster because it skips some of the data verification that the view tries to do. However I don't recommend using it unless necessary. I like to make sure that my data is verified by ACCPAC business logic as much as possible. Easier than dealing with corrupted data later.

Thanks and Good Luck!

zemp

RE: ACCPACXAPILib VS AccpacCOMAPI in ORDER ENTRY

(OP)
I have clean up my code to optimize th procees time!
but i fear that the most costing is when i manage comments line....

My app is a client server, i load the data and each time a add or modifiy a item(parts) i acces the server side to reprocess each row...

i could skip unmodified detail but that would not save me a lot if i build an Order Entry with 20 item in pseudo transaction mode and i Post it after, In fact i need to be able to loop for 20 detail parts for one header wich one with 2or 3 line of comment.

The thing is that i'm forced to over manage comment line
because when you insert a new comm line it show as the first and the other line come next:

comm.value = "cc1"
comm.insert
comm.value = "cc2"
comm.insert
comm.value = "cc3"
comm.insert

Will show as :
cc3
cc2
cc1
In Accpac
and if i insert one more after that:
cc4
cc3
cc2
cc1

It always insert at the top..!!

and i have to compensate for diffence between line count when i receive a hit from the interface:
for an example if i read on the server 2 line of comment, and 3 from the interface i'm force to insert on empty line and cycle 3 time comm.update to be sure that the comm are in the proper order

Any idea of how i should procced ?

thank in advance

RE: ACCPACXAPILib VS AccpacCOMAPI in ORDER ENTRY

Comment lines can be slow because of their nature as ptentially large strings. To be honest I have not worked much with comments so I can't be of much help there. However I will say that the xAPI does have some limits and it can be fussy. This may be one of those situations where there is not much you can do.

Thanks and Good Luck!

zemp

RE: ACCPACXAPILib VS AccpacCOMAPI in ORDER ENTRY

Hey Zemp,

Some info that can help:
First, the COMAPI can be used in VB, just reference the 'ACCPAC COM API Object 1.0'.  You then open the session with the following code:

Dim Session As AccpacCOMAPI.AccpacSession
Set Session = New AccpacCOMAPI.AccpacSession

Session.Init "", "AS", "AS1000", "50A"
Session.Open "ADMIN", "ADMIN", "SAMINC", Date, 0, ""

Dim CompanyLink As AccpacCOMAPI.AccpacDBLink
Set CompanyLink = Session.OpenDBLink(DBLINK_COMPANY, DBLINK_FLG_READWRITE)

Dim SysLink As AccpacCOMAPI.AccpacDBLink
Set SysLink = Session.OpenDBLink(DBLINK_SYSTEM, DBLINK_FLG_READWRITE)



The major difference with the COMAPI is with the data navigation.  After a browse"", you can use the .goNext, .goPrev, goBottom, .goTop to navigate which can be helpful instead of the .fetch.

AccpacInfo.exe & ViewInfo.exe
ACCPAC comes with 2 applications in the runtime folder that helps when programming UI's and dealing with views.

AccpacInfo.exe defines the different objects on a UI.  You get the UI number by setting the view menu in ACCPAC to details.  EX: the OrderEntry UI number is OE1100.  A right click in AccpacInfo.exe on the desired UI number will show the details.  The details also include the Views associated to a UI.  By right clicking on the desired view it will open viewinfo.exe that lists all the fields, the compositions and index fields for that view.  This makes programming with views and UI's a lot easier and eliminates a lot of the guess work.

Hope this info will help.
Good luck.

RE: ACCPACXAPILib VS AccpacCOMAPI in ORDER ENTRY

That is helpful information, thanks. I would open a CA-BLE macro (.MAC) and go to 'Object information' in the 'debug' menu or the ACCPAC website to get view details and compositions. It is nice to know that this information is available in an easier to get at and more comprehensive form.

Interesting to learn that the COMAPI can also be used externally. Eveything I had heard/read would suggest that the COMAPI was for internal use and the xAPI for external. Do you have any links to or information where I can get good documentation on programming with ACCPAC. I have been unsuccessful in finding such a beast.

Thanks again, a star for you.

Thanks and Good Luck!

zemp

RE: ACCPACXAPILib VS AccpacCOMAPI in ORDER ENTRY

(OP)
I have tested this the day i have send the firdt post:


Dim mySession As New AccpacCOMAPI.AccpacSession
Dim mySignonManager As New AccpacSignonManager.AccpacSignonMgr

mySession.Init "", "CS", "CS0001", "51A"
mySignonManager.Signon mySession

Dim mDBLinkCmpRW As AccpacCOMAPI.AccpacDBLink
Set mDBLinkCmpRW = mySession.OpenDBLink(DBLINK_COMPANY, DBLINK_FLG_READWRITE)

Dim mDBLinkSysRW As AccpacCOMAPI.AccpacDBLink
Set mDBLinkSysRW = mySession.OpenDBLink(DBLINK_SYSTEM, DBLINK_FLG_READWRITE)


I wasn't aware that you could use :
Set Session = New AccpacCOMAPI.AccpacSession

To open a session , a tought that the AccpacCom has dependency with the signon manager... that means that if we could use th AccPac com with session created on the fly and be able to drop them after th call... We could use this COM instead of the Xapi.. that is a good news because the xapi is a bit slower... but to be certain i would need to test the two solution in simulation mode to be sure. I have already test those two, but using the signon manager for the accpaccom ...
Then We will need to know if this does't have a drawn back that we are not knowing of...

Thank for the input

RE: ACCPACXAPILib VS AccpacCOMAPI in ORDER ENTRY

(OP)
I have made some simulation test. In taht test i create one Order entry with X time Two  detail , on with 2 line of comment the other with 3.
EX:
loop X time
 detail.insert
 detail.insert
endloop

Here the result :
  Running the loop 1 Time :  (2 details line)
    Xapi : avr of 4.3sec / avg of 11 try
    accpacCom : avr of 4.5sec / avg of 11 try

  Running the loop 10 Time : (20 details line)
    Xapi : avr of 6.3sec  / avg of 10 try
    accpacCom : avr of 6 / avg of 10 try

  Running the loop 30 Time : (60 details line)
    Xapi : avr of 12.2sec  / avg of 10 try
    accpacCom : avr of 11.4 / avg of 10 try

Conclusion: both method taking +/- the same time of execution:

I've run those test on a vmware it why it's maybe a bit slow.

For my prob with the comments position someone tell me This :

Current = 0
Comment.Init
Comment.Fields("UNIQUIFIER").PutWithoutVerification (Current)
Comment.Fields("COIN").PutWithoutVerification ("ccomm1")
Comment.Insert
Current = Comment.Fields("UNIQUIFIER").Value


Comment.Init
Comment.Fields("UNIQUIFIER").PutWithoutVerification (Current)
Comment.Fields("COIN").PutWithoutVerification ("cc2")
Comment.Insert
Current = Comment.Fields("UNIQUIFIER").Value


Comment.Init
Comment.Fields("UNIQUIFIER").PutWithoutVerification (Current)
Comment.Fields("COIN").PutWithoutVerification ("cc3")
Comment.Insert

Basically if you want to insert after a specific line, simply put the value
of UNIQUIFIER of that line before insertion.



So i will check if this can help me saving some execution time. Im thinking about not have to read all line , insert blank line if there is more, restart from the top , update all line, and optionnally re-read to be sure of the the value on disk.

Now i will be able to upadte all current line insert new line or delete line when there is a difference between the
value from the interface (pseudo transaction mode) and the those on the disk... So basicly i will save execution line then execution time.


If you have any other idea ....

thanks a lot

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