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

Bill of Materials problem

Status
Not open for further replies.

zalke

Programmer
Sep 11, 2003
7
US
hello all
can anybody tell me please whats wrong with this code im getting an error of record not found

Dim vSession As New xapiSession
Dim vBOMHeader, vBOMDetail As New xapiView
Dim HeaderFields, DetailFields As xapiFields


vSession.Open "blah", "blah", "blah", Now, 0
Set vBOMHeader = vSession.OpenView("IC0200", "IC")
Set vBOMDetail = vSession.OpenView("IC0190", "IC")

Set HeaderFields = vBOMHeader.Fields
Set DetailFields = vBOMDetail.Fields


vBOMHeader.Compose vBOMDetail
vBOMDetail.Compose vBOMHeader

vBOMHeader.Init
HeaderFields("ITEMNO").PutWithoutVerification ("blah")
HeaderFields("BOMNO").PutWithoutVerification ("1")
HeaderFields("REMARK").PutWithoutVerification ("blah")
HeaderFields("FIXEDCOST").PutWithoutVerification ("1")
HeaderFields("BUILDQTY").PutWithoutVerification ("1")
HeaderFields("UNIT").PutWithoutVerification ("blah")
HeaderFields("VARBLCOST").PutWithoutVerification ("1")


For i = 0 To blah
vBOMDetail.Init
DetailFields("ITEMNO").PutWithoutVerification ("blah")
DetailFields("BOMNO").PutWithoutVerification ("1")
DetailFields("LINENO").PutWithoutVerification (i)
DetailFields("COMPONENT").PutWithoutVerification ("blah")
DetailFields("QTY").PutWithoutVerification ("1")
DetailFields("UNIT").PutWithoutVerification ("blah")
DetailFields("UNITCOST").PutWithoutVerification ("1")
vBOMDetail.Insert 'the error is here
Next


vBOMHeader.Insert
vBOMDetail.Cancel
vBOMHeader.Cancel
vBOMHeader.Close
vBOMDetail.Close
vSession.Close
 
What is the error?

I would also suggest putting in an error handler. You are probably missing some required information or it is not a valid value. Recording a macro can show you what is required and what is not.

Take Care,

zemp

"Show me someone with both feet on the ground and I will show you someone who can't put their pants on."
 
this is actually written in delphi so i didnt birng over the error handlig
the error message is " Bills of Material Component. Record not found. ." i did the macro recording and it added some browse, fetch and read wich i think is not required
and finally thank's a million zemp for responding so quick
zalke
 
I think that the detail does not see the new header. It may be an order of operations error. I would try inserting the header before the detail and then updating the header after the detail is inserted.

Check the macro to see if there are any other inserts or updates.

Take Care,

zemp

"Show me someone with both feet on the ground and I will show you someone who can't put their pants on."
 
zemp here is a copy of the macro i dont see any other update or insert
the only diffrence i see is instead of using the PutWithoutVerification it uses the value on certain fields but i tried that too and still no luck


Option Explicit

Sub MainSub()
'
' ACCPAC Macro file: C:\Documents and Settings\zalke\Desktop\MACRO02.AVB
' Recorded at: Thu Nov 06 14:58:37 2003
'

On Error GoTo ACCPACErrorHandler

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

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

Dim ICBOM1header As AccpacCOMAPI.AccpacView
Dim ICBOM1headerFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "IC0200", ICBOM1header
Set ICBOM1headerFields = ICBOM1header.Fields

Dim ICBOM1detail As AccpacCOMAPI.AccpacView
Dim ICBOM1detailFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "IC0190", ICBOM1detail
Set ICBOM1detailFields = ICBOM1detail.Fields

ICBOM1header.Compose Array(ICBOM1detail, Nothing, Nothing)

ICBOM1detail.Compose Array(ICBOM1header, Nothing, Nothing)


ICBOM1detail.Browse "", 1
ICBOM1detail.Fetch

ICBOM1detailFields("ITEMNO").PutWithoutVerification ("") ' Unformatted Item Number
ICBOM1detailFields("BOMNO").PutWithoutVerification ("") ' BOM Number
ICBOM1detailFields("LINENO").PutWithoutVerification ("0") ' Line Number
ICBOM1headerFields("ITEMNO").Value = "101-000432" ' Unformatted Item Number

ICBOM1headerFields("BOMNO").Value = "56" ' BOM Number
ICBOM1detail.Browse "", 1
ICBOM1detail.Fetch

ICBOM1detailFields("ITEMNO").PutWithoutVerification ("101-000432") ' Unformatted Item Number
ICBOM1detailFields("BOMNO").PutWithoutVerification ("56") ' BOM Number
ICBOM1detailFields("LINENO").PutWithoutVerification ("0") ' Line Number

ICBOM1detailFields("LINENO").PutWithoutVerification ("-32767") ' Line Number

ICBOM1detail.Browse "", 1
ICBOM1detail.Fetch

ICBOM1detailFields("ITEMNO").PutWithoutVerification ("101-000432") ' Unformatted Item Number
ICBOM1detailFields("BOMNO").PutWithoutVerification ("56") ' BOM Number
ICBOM1detailFields("LINENO").PutWithoutVerification ("0") ' Line Number

ICBOM1detailFields("LINENO").PutWithoutVerification ("-32767") ' Line Number

ICBOM1detail.Browse "", 1
ICBOM1detail.Fetch

ICBOM1detailFields("ITEMNO").PutWithoutVerification ("101-000432") ' Unformatted Item Number
ICBOM1detailFields("BOMNO").PutWithoutVerification ("56") ' BOM Number
ICBOM1detailFields("LINENO").PutWithoutVerification ("0") ' Line Number

ICBOM1detail.Init

ICBOM1detailFields("COMPONENT").Value = "101-000532" ' Component Item Number

ICBOM1detail.Insert
ICBOM1detail.Browse "", 1

ICBOM1detailFields("LINENO").PutWithoutVerification ("-1") ' Line Number

ICBOM1detail.Read
ICBOM1detail.Init

ICBOM1detailFields("COMPONENT").Value = "2C0472-3" ' Component Item Number
ICBOM1detailFields("LINENO").PutWithoutVerification ("-1") ' Line Number

ICBOM1detail.Insert
ICBOM1detail.Browse "", 1

ICBOM1detailFields("LINENO").PutWithoutVerification ("-2") ' Line Number

ICBOM1detail.Read
ICBOM1detail.Browse "", 1

ICBOM1detailFields("LINENO").PutWithoutVerification ("-2") ' Line Number

ICBOM1detail.Read
ICBOM1detail.Browse "", 1

ICBOM1detailFields("LINENO").PutWithoutVerification ("-1") ' Line Number

ICBOM1detail.Read
ICBOM1headerFields("BUILDQTY").Value = "1.0000" ' Build Quantity

ICBOM1headerFields("UNIT").Value = "FT" ' Unit of Measure

ICBOM1header.Insert


Exit Sub

ACCPACErrorHandler:
Dim lCount As Long
Dim lIndex As Long

If Errors Is Nothing Then
MsgBox Err.Description
MsgBox "VBA Macros cannot run where Accpac is deployed as a Web Server"
Else
lCount = Errors.Count

If lCount = 0 Then
MsgBox Err.Description
Else
For lIndex = 0 To lCount - 1
MsgBox Errors.Item(lIndex)
Next
Errors.Clear
End If
Resume Next

End If
End Sub
 
I still think that the header and detail are not comunicating properly. Check your view compositions. I noticed that they are not identical to the macro. But then again I don't know how things should look in delphi.

Have you check the ACCPAC developers forum?

Take Care,

zemp

"Show me someone with both feet on the ground and I will show you someone who can't put their pants on."
 
hi zemp
i redid the compositions and still no luck.
my problem is not the delphi part, i just need a working vb example.
no luck with the ACCPAC developers forum too
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top