Hi
I tried the macro which is shown below, to create a PO return in AAS5.4A. It works fine and create a new return entry
in ACCpac. But the problem is "there is no change in the "quantity on hand" for the item .
Please guide me where i was wrong.
Dim TCOMMENT As String
Dim Session As AccpacCOMAPI.AccpacSession
Set Session = AccpacCOMAPI.AccpacSession
invnum = ""
Session.Init "", "AS", "AS1000", "54A"
Session.Open user, password, database, Date, 0, ""
Dim son As New AccpacSignonManager.AccpacSignonMgr
Dim sid As Long
If Session.IsOpened = True Then
sid = son.RegisterSignon(user, password, database, Date, 0)
Set mDBLinkCmpRW = Session.OpenDBLink(DBLINK_COMPANY, DBLINK_FLG_READWRITE)
End If
Dim temp As Boolean
On Error GoTo ACCPACErrorHandler ' Set error handler
' Declare the views
Dim PORET1header As AccpacCOMAPI.AccpacView
Dim PORET1detail1 As AccpacCOMAPI.AccpacView
Dim PORET1detail2 As AccpacCOMAPI.AccpacView
Dim PORET1detail3 As AccpacCOMAPI.AccpacView
Dim PORET1detail4 As AccpacCOMAPI.AccpacView
Dim PORET1detail5 As AccpacCOMAPI.AccpacView
mDBLinkCmpRW.OpenView "PO0731", PORET1header
mDBLinkCmpRW.OpenView "PO0735", PORET1detail1
mDBLinkCmpRW.OpenView "PO0729", PORET1detail2
mDBLinkCmpRW.OpenView "PO0730", PORET1detail3
mDBLinkCmpRW.OpenView "PO0738", PORET1detail4
mDBLinkCmpRW.OpenView "PO0739", PORET1detail5
PORET1header.Compose Array(PORET1detail2, PORET1detail1, PORET1detail3, PORET1detail4)
PORET1detail1.Compose Array(PORET1header, PORET1detail2, PORET1detail3, Nothing, Nothing, PORET1detail5)
PORET1detail2.Compose Array(PORET1header, PORET1detail1)
PORET1detail3.Compose Array(PORET1header, PORET1detail2, PORET1detail1)
PORET1detail4.Compose Array(PORET1header)
PORET1detail5.Compose Array(PORET1detail1)
Open FILENAME For Input As #1
Dim inputStr As String
Dim word As Variant
Dim TITEMNO As String
Dim TLOCATION As String
Dim TRQRETURNED As String
Dim TUNITCOST As String
Dim THASCOMMENT As String
Dim TVDCODE As String
'READING VALUES FROM FILE
Do Until EOF(1)
Line Input #1, inputStr
If inputStr = "*" Then
Exit Do
Else
word = Split(Trim(inputStr), " ", 2, 1)
Select Case word(0)
Case "VDCODE"
TVDCODE = word(1)
Case "ITEMNO"
TITEMNO = word(1)
Case "LOCATION"
TLOCATION = word(1)
Case "RQRETURNED"
TRQRETURNED = word(1)
Case "UNITCOST"
TUNITCOST = word(1)
Case "HASCOMMENT"
THASCOMMENT = word(1)
Case "COMMENT"
TCOMMENT = word(1)
Line Input #1, inputStr
word = Split(Trim(inputStr), " ", 2, 1)
If word(0) <> "-----" Then
TCOMMENT = TCOMMENT + word(1)
End If
Line Input #1, inputStr
word = Split(Trim(inputStr), " ", 2, 1)
If word(0) <> "-----" Then
TCOMMENT = TCOMMENT + word(1)
End If
End Select
End If
Loop
PORET1header.Order = 1
PORET1header.Order = 0
PORET1header.Fields("RETHSEQ").PutWithoutVerification ("0") ' Return Sequence Key
temp = PORET1header.Exists
PORET1header.Init
PORET1header.Order = 1
temp = PORET1detail1.Exists
PORET1detail1.RecordClear
temp = PORET1detail2.Exists
PORET1detail2.Init
PORET1header.Fields("VDCODE").Value = TVDCODE ' Vendor
temp = PORET1detail1.Exists
PORET1detail1.RecordClear
temp = PORET1detail1.Exists
PORET1detail1.RecordCreate 0
PORET1detail1.Fields("ITEMNO").Value = TITEMNO ' Item Number
PORET1detail1.Fields("LOCATION").Value = TLOCATION ' Location
PORET1detail1.Fields("RQRETURNED").Value = TRQRETURNED ' Quantity Returned
PORET1detail1.Insert
PORET1detail1.Fields("RETLREV").PutWithoutVerification ("-1") ' Line Number
PORET1detail1.Read
PORET1detail1.Read
PORET1detail3.Fields("FUNCTION").PutWithoutVerification ("7") ' Function
PORET1detail3.Process
temp = PORET1header.Exists
PORET1header.Insert
GENPORETURN = PORET1header.Fields("RETNUMBER").Value
MsgBox GENPORETURN + " Is Generated", , "Information"
Close #1
Thanks
Saravana Bavan.T
I tried the macro which is shown below, to create a PO return in AAS5.4A. It works fine and create a new return entry
in ACCpac. But the problem is "there is no change in the "quantity on hand" for the item .
Please guide me where i was wrong.
Dim TCOMMENT As String
Dim Session As AccpacCOMAPI.AccpacSession
Set Session = AccpacCOMAPI.AccpacSession
invnum = ""
Session.Init "", "AS", "AS1000", "54A"
Session.Open user, password, database, Date, 0, ""
Dim son As New AccpacSignonManager.AccpacSignonMgr
Dim sid As Long
If Session.IsOpened = True Then
sid = son.RegisterSignon(user, password, database, Date, 0)
Set mDBLinkCmpRW = Session.OpenDBLink(DBLINK_COMPANY, DBLINK_FLG_READWRITE)
End If
Dim temp As Boolean
On Error GoTo ACCPACErrorHandler ' Set error handler
' Declare the views
Dim PORET1header As AccpacCOMAPI.AccpacView
Dim PORET1detail1 As AccpacCOMAPI.AccpacView
Dim PORET1detail2 As AccpacCOMAPI.AccpacView
Dim PORET1detail3 As AccpacCOMAPI.AccpacView
Dim PORET1detail4 As AccpacCOMAPI.AccpacView
Dim PORET1detail5 As AccpacCOMAPI.AccpacView
mDBLinkCmpRW.OpenView "PO0731", PORET1header
mDBLinkCmpRW.OpenView "PO0735", PORET1detail1
mDBLinkCmpRW.OpenView "PO0729", PORET1detail2
mDBLinkCmpRW.OpenView "PO0730", PORET1detail3
mDBLinkCmpRW.OpenView "PO0738", PORET1detail4
mDBLinkCmpRW.OpenView "PO0739", PORET1detail5
PORET1header.Compose Array(PORET1detail2, PORET1detail1, PORET1detail3, PORET1detail4)
PORET1detail1.Compose Array(PORET1header, PORET1detail2, PORET1detail3, Nothing, Nothing, PORET1detail5)
PORET1detail2.Compose Array(PORET1header, PORET1detail1)
PORET1detail3.Compose Array(PORET1header, PORET1detail2, PORET1detail1)
PORET1detail4.Compose Array(PORET1header)
PORET1detail5.Compose Array(PORET1detail1)
Open FILENAME For Input As #1
Dim inputStr As String
Dim word As Variant
Dim TITEMNO As String
Dim TLOCATION As String
Dim TRQRETURNED As String
Dim TUNITCOST As String
Dim THASCOMMENT As String
Dim TVDCODE As String
'READING VALUES FROM FILE
Do Until EOF(1)
Line Input #1, inputStr
If inputStr = "*" Then
Exit Do
Else
word = Split(Trim(inputStr), " ", 2, 1)
Select Case word(0)
Case "VDCODE"
TVDCODE = word(1)
Case "ITEMNO"
TITEMNO = word(1)
Case "LOCATION"
TLOCATION = word(1)
Case "RQRETURNED"
TRQRETURNED = word(1)
Case "UNITCOST"
TUNITCOST = word(1)
Case "HASCOMMENT"
THASCOMMENT = word(1)
Case "COMMENT"
TCOMMENT = word(1)
Line Input #1, inputStr
word = Split(Trim(inputStr), " ", 2, 1)
If word(0) <> "-----" Then
TCOMMENT = TCOMMENT + word(1)
End If
Line Input #1, inputStr
word = Split(Trim(inputStr), " ", 2, 1)
If word(0) <> "-----" Then
TCOMMENT = TCOMMENT + word(1)
End If
End Select
End If
Loop
PORET1header.Order = 1
PORET1header.Order = 0
PORET1header.Fields("RETHSEQ").PutWithoutVerification ("0") ' Return Sequence Key
temp = PORET1header.Exists
PORET1header.Init
PORET1header.Order = 1
temp = PORET1detail1.Exists
PORET1detail1.RecordClear
temp = PORET1detail2.Exists
PORET1detail2.Init
PORET1header.Fields("VDCODE").Value = TVDCODE ' Vendor
temp = PORET1detail1.Exists
PORET1detail1.RecordClear
temp = PORET1detail1.Exists
PORET1detail1.RecordCreate 0
PORET1detail1.Fields("ITEMNO").Value = TITEMNO ' Item Number
PORET1detail1.Fields("LOCATION").Value = TLOCATION ' Location
PORET1detail1.Fields("RQRETURNED").Value = TRQRETURNED ' Quantity Returned
PORET1detail1.Insert
PORET1detail1.Fields("RETLREV").PutWithoutVerification ("-1") ' Line Number
PORET1detail1.Read
PORET1detail1.Read
PORET1detail3.Fields("FUNCTION").PutWithoutVerification ("7") ' Function
PORET1detail3.Process
temp = PORET1header.Exists
PORET1header.Insert
GENPORETURN = PORET1header.Fields("RETNUMBER").Value
MsgBox GENPORETURN + " Is Generated", , "Information"
Close #1
Thanks
Saravana Bavan.T