Hi Everyone,
I have recorded a macro that submits a PO for approval in PW. Now i am trying to insert the result of my code into the macro so that a PO is created from another macro. The code works and allows me to enter a PO and it even appears in the PW Purchase Order Entry Screen. However, i am failing to automatically submit the PO.
I think the Problem lies with the Sequence key. If i set the sequence key to an already existing key the PO status is set to "Entered". If i set the Sequence key to max(key)+128 (i.e create my own) i get an error:
"Could not get workflow information. Unable to process document"
How can i change my code to automatically submit a PO in PW from another macro
I have recorded a macro that submits a PO for approval in PW. Now i am trying to insert the result of my code into the macro so that a PO is created from another macro. The code works and allows me to enter a PO and it even appears in the PW Purchase Order Entry Screen. However, i am failing to automatically submit the PO.
I think the Problem lies with the Sequence key. If i set the sequence key to an already existing key the PO status is set to "Entered". If i set the Sequence key to max(key)+128 (i.e create my own) i get an error:
"Could not get workflow information. Unable to process document"
Code:
With rec
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.LockType = adLockBatchOptimistic
Set .ActiveConnection = cn
.source = "select max(PORHSEQ) MAXX FROM OLDDAT.DBO.PTPORH"
.Open
End With
Nxt = rec.Fields(0).value + 128
POPOR4header.Order = 1
POPOR4header.Order = 0
POPOR4headerFields("PORHSEQ").PutWithoutVerification ("0") ' Purchase Order Sequence Key
POPOR4header.Init
POPOR4header.Order = 1
temp = POPOR4detail1.Exists
POPOR4detail1.RecordClear
POPOR4detail3.Init
POPOR4detail2.Init
POPOR4headerFields("VDCODE").value = Me.txtVendorNumber.Text ' Vendor
POPOR4headerFields("PROCESSCMD").PutWithoutVerification ("1") ' Command
POPOR4header.Process
POPOR4headerFields("COSTCTR").value = Me.EmployeeGrid.TextMatrix(1, 1) ' Cost Center
POPOR4headerFields("DESCRIPTIO").value = Me.txtDescription.Text ' Description
POPOR4headerFields("REFERENCE").value = Me.txtReference.Text ' Reference
temp = POPOR4detail1.Exists
POPOR4detail1.RecordClear
temp = POPOR4detail1.Exists
POPOR4detail1.RecordCreate 0
With EmployeeGrid
For a = 1 To .Rows - 1
POPOR4detail1Fields("ITEMNO").value = .TextMatrix(a, 2) ' Item Number
POPOR4detail1Fields("PROCESSCMD").PutWithoutVerification ("1") ' Command
POPOR4detail1.Process
POPOR4detail1Fields("LOCATION").value = "MINE" ' Location
POPOR4detail1Fields("OQORDERED").value = .TextMatrix(a, 4) ' Quantity Ordered
POPOR4detail1Fields("UNITCOST").value = .TextMatrix(a, 5) ' Unit Cost
POPOR4detail1Fields("DISCPCT").value = .TextMatrix(a, 6) ' Discount Percentage
POPOR4detail1.Insert
POPOR4detail1Fields("PORLREV").PutWithoutVerification ("-" & a & "") ' Line Number
POPOR4detail1.Read
temp = POPOR4detail1.Exists
POPOR4detail1.RecordCreate 0
Next a
End With
POPOR4detail4Fields("FUNCTION").PutWithoutVerification ("8") ' Function
POPOR4detail4.Process
temp = POPOR4header.Exists
POPOR4header.Insert
PTFNCTN3Fields("FUNCTION").PutWithoutVerification ("20") ' Function
PTFNCTN3Fields("WORKFLOW").PutWithoutVerification ("PO") ' Workflow
PTFNCTN3Fields("TYPE").PutWithoutVerification ("20") ' Workflow Type
PTFNCTN3Fields("KEY").PutWithoutVerification ("" & Nxt & "") ' Sequence Key
PTFNCTN3.Process
POPOR4header.Init
POPOR4header.Order = 0