Filtering PO line items based on Buy-from Vendor field

kkutty2007
kkutty2007 Member Posts: 6
Hi,

1. User creates a PO with a buy-from vendor field.
2. An Vendor Item table is maintained that contains (vendor_no, item_no). Each vendor will have a list of approved items that he can supply.
3. While in PO line item ( purchase order subform ), while looking up in No. field, it currently lists all the items from item table.
I am trying to restrict this list to items supplied by the vendor selected ( in PO header).

I modified No.Lookup() function in Purchase Order subform as follows.


IF Type = Type::Item THEN BEGIN
tblPurchaseHeader.GET("Document Type","Document No.");
tblVendorItem.SETRANGE("Vendor No.",
tblPurchaseHeader."Buy-from Vendor No.");
intRecCount := tblVendorItem.COUNT;
IF(intRecCounter = 0) THEN
BEGIN
MESSAGE('There are no certified items supplied by this vendor');
EXIT;
END;

Now if I take Item numbers from tblVendorItem, it will contain all the items supplied by that supplier. May some one please tell me as how to take the list of items from tblVendorItem and filter Item table using the
list of items in tblVendorItem.

{ // I am missing few statements here....
// how to filter tblItem (Item Table) using list of items provided by
// tblVendor Item
}
CLEAR(frmItemList);
frmItemList.SETTABLEVIEW(tblItem);
frmItemList.SETRECORD(tblItem);
frmItemList.LOOKUPMODE(TRUE);
IF frmItemList.RUNMODAL = ACTION::LookupOK THEN BEGIN
frmItemList.GETRECORD(tblItem);
VALIDATE("No." , tblItem."No.");
END;

Comments

  • ssingla
    ssingla Member Posts: 2,973
    Have a look at requisition worksheet.

    Its a step before creating purchase order. The form shows only those vendor who are defined in the Item Vendor table. From there you can selct the vendor and then "carry out action message" option and it will create purcahse order.
    CA Sandeep Singla
    http://ssdynamics.co.in
  • Mbad
    Mbad Member Posts: 344
    You can mark the items and run the item list with markedonly.
  • kkutty2007
    kkutty2007 Member Posts: 6
    Mbad wrote:
    You can mark the items and run the item list with markedonly.

    Thank you. It did work. The code below works!!


    IF Type = Type::Item THEN BEGIN
    tblPurchaseHeader.GET("Document Type","Document No.");
    tblVendorItem.SETRANGE("Vendor No.", tblPurchaseHeader."Buy-from Vendor No.");
    intRecCount := tblVendorItem.COUNT;
    tblItem.RESET;
    IF ( intRecCount > 0 ) THEN
    BEGIN
    tblVendorItem.FIND('-');
    REPEAT
    tblItem.GET(tblVendorItem."Item No.");
    tblItem.MARK(TRUE);
    UNTIL tblVendorItem.NEXT=0;
    END;
    tblItem.MARKEDONLY(TRUE);
    CLEAR(frmItemList);
    frmItemList.SETTABLEVIEW(tblItem);
    frmItemList.SETRECORD(tblItem);
    frmItemList.LOOKUPMODE(TRUE);
    IF frmItemList.RUNMODAL = ACTION::LookupOK THEN BEGIN
    frmItemList.GETRECORD(tblItem);
    VALIDATE("No." , tblItem."No.");
    END;
    END;