IM Check if item is a component of a BOM

SOLVED

I've been trying to find a way to just check BOM if the raw material item open in Item Maintenance is a component of a BOM.  It appears there is a FindWhereUsed Function of BM_WhereUsedCommon, but I haven't been able to get it to work.

SET oBM= oSession.AsObject(oSession.GetObject("BM_WhereUsedCommon"))
r = oBM.FindWhereUsed(CI_ItemCode_bus_ItemCode, "N", "SINGLE-LEVEL", 0)
SET oBM = NOTHING

Return is always 1 (Success) no matter the PN.  I have also tried the "ReadBillDetail" function which also returns 1 every time.  I'm firing this from a button script currently.

  • 0
    verified answer

    BM_WhereUsedCommon is only used by the indented where-used report. The FindWhereUsed() method finds where a component is used and populates a memory file which isn't accessible to you.  The return value of 1 doesn't mean the item is used in a bill.  It only means the method completes successfully.
     
    You can try using GetResultSets() to do what you want. Here is an example in PVX syntax:

    o = NEW("BM_Bill_bus",%sys_ss)

    ! Pass in component item code and use "KWHEREINDEX" index. Need to pad component item code code to the right length with null.

    r = o'Lines'GetResultSets("BillNo$", "ComponentItemCode$", results$, $$, "", PAD("BTTRY-98422",30,$00$), PAD("BTTRY-98422",30,$00$)+$FE$, "KWHEREUSED", 1)

    if r=1 then msgbox results$ else msgbox "item is not used in a bill"

    drop object o

    end

    If you use option bill and option interaction, you will need to do the same for those.

  • 0 in reply to Natasha Chang
    Thanks Natasha, I didn't think of going that route and was hoping for a more direct approach. After fiddling with getresultsets I was able to make it work.