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

macro for inserting item no in PO does not insert vendor item no

Status
Not open for further replies.

wysiwygGER01

Programmer
Feb 18, 2009
188
AU
Hello,

I'm using Accpac 5.5.
I've got the below code for entering a PO.
When I enter a PO manually Accpac automatically fills in vendor details such as vendor item number if the item has been set up for the vendor.
With my code this does not work. I would have thought by using the COMAPI it's done automatically just when entering it manually?

Would anyone have a sample of code on how to get the vendor item number inserted as well?

Code:
POPOR1headerFields("PORHSEQ").PutWithoutVerification ("0")            ' Purchase Order Sequence Key
    
    Temp = POPOR1header.Exists
    POPOR1header.Init
    POPOR1header.Order = 1
    Temp = POPOR1detail1.Exists
    POPOR1detail1.RecordClear
    Temp = POPOR1detail3.Exists
    POPOR1detail3.Init
    Temp = POPOR1detail2.Exists
    POPOR1detail2.Init
    Temp = POPOR1header.Exists
    POPOR1header.Init
    POPOR1header.Order = 0
    
    POPOR1headerFields("PORHSEQ").PutWithoutVerification ("0")            ' Purchase Order Sequence Key
    
    Temp = POPOR1header.Exists
    POPOR1header.Init
    POPOR1header.Order = 1
    Temp = POPOR1detail1.Exists
    POPOR1detail1.RecordClear
    Temp = POPOR1detail3.Exists
    POPOR1detail3.Init
    Temp = POPOR1detail2.Exists
    POPOR1detail2.Init
    POPOR1headerFields("VDCODE").Value = vendor                           ' Vendor
    POPOR1headerFields("PROCESSCMD").PutWithoutVerification ("1")         ' Command
    POPOR1header.Process
    
    POPOR1headerFields("WORKFLOW").Value = workflow                       ' Workflow
    POPOR1headerFields("COSTCTR").Value = costCtr
    
    POPOR1headerFields("STCODE").Value = shipTo
    
    POPOR1headerFields("BTCODE").Value = billTo                           ' Bill-To Location
    POPOR1headerFields("VIACODE").Value = shipVia                         ' Ship-Via
    POPOR1headerFields("DESCRIPTIO").Value = description                  ' Description
    POPOR1headerFields("REFERENCE").Value = reference
    POPOR1headerFields("FOBPOINT").Value = FOBPoint
    POPOR1headerFields("DATE").Value = DateSerial(Year(PODate), Month(PODate), Day(PODate))
    POPOR1headerFields("TEMPLATE").Value = template
    POPOR1headerFields("TERMSCODE").Value = terms
    ' Reference
    Temp = POPOR1detail1.Exists
    POPOR1detail1.RecordClear
    Temp = POPOR1detail1.Exists
    For i = 1 To numOfLines
        
        POPOR1detail1.RecordCreate 0
        POPOR1detail1Fields("ITEMNO").Value = itemNo(i)                       ' Item Number
        POPOR1detail1Fields("PROCESSCMD").PutWithoutVerification ("1")        ' Command
        POPOR1detail1.Process
        'POPOR1detail1Fields("LOCATION").Value = 1
        POPOR1detail1Fields("LOCATION").Value = "99DUB"                        'Location
        POPOR1detail1Fields("OEONUMBER").Value = ordernumber
        
        POPOR1detail1Fields("OQORDERED").Value = quantity(i)                  ' Quantity Ordered
        POPOR1detail1Fields("UNITCOST").Value = unitCost(i)                   ' Unit Cost
        POPOR1detail1.Insert       
    Next
    Temp = POPOR1header.Exists
    POPOR1header.Insert
 
You'll need to first check that itemNo(i) exists in IC0310, and if it doesn't, look it up from IC0340. There's no magic.

Also, delete all the "Temp =" lines, they're just noise from the recording.
 
Thanks for your quick reply!
I'm copying OE orders into PO so I gues it would be redundant to check whether the item number exists.
So you're saying I have to write it in my code. Need to find the item number in IC0340, then need to find the vendor and then need to get the vendor item number?

I've recorded a macro in PO but could not find any reference to IC0340 in it but the vendor item number still shows up in the PO.
Looks like there is a bit of magic involved. :)
 
Create PO from OE: You will need to group the OE item lines per vendor, then create PO based on vendor. You will need to look up the Vendor Details to find out what vendor. Depending on your process, you might want to allow the users to select which vendor, since there could be multiple vendors for 1 item.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top