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

How to seach batch no ? using VB macro 1

Status
Not open for further replies.

CarlosY

Programmer
Mar 18, 2008
15
CA
Hi,

does any one know how to search batch(#) which open, and w/ certain batch description ?

I tried to search manual for accpac api but i have no luck sofar.

can someone tell me ".Browse, .init" what this sub do ?

here is my test code for searching batch no; I kept getting 0, even i have those batch.



mDBLinkCmpRW = mySession.OpenDBLink(AccpacCOMAPI.tagDBLinkTypeEnum.DBLINK_COMPANY, AccpacCOMAPI.tagDBLinkFlagsEnum.DBLINK_FLG_READWRITE)
Dim APINVOICE1batch As AccpacCOMAPI.AccpacView
Dim APINVOICE1batchFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView("AP0020", APINVOICE1batch)
APINVOICE1batchFields = APINVOICE1batch.Fields

Dim APINVOICE1header As AccpacCOMAPI.AccpacView
Dim APINVOICE1headerFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView("AP0021", APINVOICE1header)
APINVOICE1headerFields = APINVOICE1header.Fields

Dim APINVOICE1detail1 As AccpacCOMAPI.AccpacView
Dim APINVOICE1detail1Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView("AP0022", APINVOICE1detail1)
APINVOICE1detail1Fields = APINVOICE1detail1.Fields

Dim APINVOICE1detail2 As AccpacCOMAPI.AccpacView
Dim APINVOICE1detail2Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView("AP0023", APINVOICE1detail2)
APINVOICE1detail2Fields = APINVOICE1detail2.Fields

APINVOICE1batch.Compose(New AccpacCOMAPI.AccpacView() {APINVOICE1header})

APINVOICE1header.Compose(New AccpacCOMAPI.AccpacView() {APINVOICE1batch, APINVOICE1detail1, APINVOICE1detail2})

APINVOICE1detail1.Compose(New AccpacCOMAPI.AccpacView() {APINVOICE1header, APINVOICE1batch})

APINVOICE1detail2.Compose(New AccpacCOMAPI.AccpacView() {APINVOICE1header})

APINVOICE1batch.Browse("((BTCHSTTS = 1) OR (BTCHSTTS = 7))",1)

APINVOICE1batchFields.FieldByName("BTCHDESC").PutWithoutVerification("CAD BATCH POSTED FROM INTRANET") ' Batch Number

APINVOICE1batch.Read()
APINVOICE1detail2.Init()
APINVOICE1headerFields.FieldByName("CNTITEM").PutWithoutVerification("0") ' Entry Number
Label1.Text = APINVOICE1batchFields.FieldByName("CNTBTCH").Value





Thanks

carlos yuwono
 
APINVOICE1batch.Browse("((BTCHSTTS = 1) OR (BTCHSTTS = 7))",1)

If APINVOICE1batch.Fetch then
..............
end if

.Init is for new records, you don't want it.
 
could you please explain to me this line.

APINVOICE1batch.Browse("((BTCHSTTS = 1) OR (BTCHSTTS = 7))",1)

thanks

carlos yuwono
 
BTCHSTTS Integer Batch Status
List Presentation with 5 items in the list:
1 - Open
3 - Posted
4 - Deleted
5 - Post In Progress
7 - Ready To Post
 
Thanks for your help.
I got it to work, I am able to select the one that i want using fetch.

I hope you will be able to help me next time cos I am new with this api and I dont have the manual.

Carlos Yuwono
 
I am curious why every time I create new batch, the macro file always have

APINVOICE1batch.Browse("((BTCHSTTS = 1) OR (BTCHSTTS = 7))",1)

?

why they always check if there is open batch or ready to post batch ?




thanks
 
There is a lot of noise recorded, you need to filter out the useless bits.
 
so basically I just added to my code every time i create new batch.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top