BOM Option Description

SOLVED

We are now setting up bills as kits in BOM, and each one of our bills has options.  Ideally I would like to just show the OptionDesc for each component item code on our customized report. The problem is that the BillOptionCategory is not saved per record in the detail tables, only the BillOption(1-9) is saved; so this keeps me from being able to get the OptionDesc of the component item code selected on the sales order.

What I would like to do in a script:

1) In the SO Lines screen, get the value of the bill option description for each component item code and set the value of the item description in the SO Lines grid.

- Any  ideas?

- How would I get the OptionDesc for the specific component item code in each line?

  • 0

    So this is what I have so far but I am stuck now. I set all the keys but still cant seem to get the OptionDesc1 value from the BM_BillOptionHeader table. Does anyone have any ideas? Is my syntax wrong?

    SET oS = oSession.AsObject(oSession.GetObject("BM_BillOptionHeader_svc"))

    retval = oS.SetKeyValue("BillNo$", base_model_item_code)

    retval = oS.SetKeyValue("Revision$", revision)

    retval = oS.SetKeyValue("BillOptionCategory", bill_option_category)

    retval = oS.SetKeyValue("BillOption", 01)

    retval = oS.Find()

    error_code = oS.GetValue("OptionDesc1$", bill_option_description)

  • 0 in reply to it_q-lab
    verified answer

    In the third and fourth SetKeyValue() lines you are missing the $ on the field names.  They should be "BillOptionCategory$" and "BillOption$".  The two fields are string values not numeric.

  • 0 in reply to Steve Passmore

    At first simply adding the "$" did not fix my issue of getting the OptionDesc1 value, but I took your underlying idea that there is a data type mismatch somewhere and that was it. I was declaring the BillOptionCategory as numeric when it is in fact a string. I posted my code below in case it helps anyone in the future.

    error_code = 0

    Set oLines = oBusObj.AsObject(oBusObj.Lines)

    oLines.MoveFirst

    Do until oLines.EOF

    base_model_item_code = ""

    salesKitLineKey = ""

    explodedKitItem = ""

    revision = ""

    bill_option_category = 0

    bill_option_1 = 00

    bill_option_2 = 00

    bill_option_3 = 00

    bill_option_4 = 00

    bill_option_5 = 00

    bill_option_6 = 00

    bill_option_7 = 00

    bill_option_8 = 00

    bill_option_9 = 00

    error_code = oLines.GetValue("SalesKitLineKey$", salesKitLineKey)

    error_code = oLines.GetValue("ExplodedKitItem$", explodedKitItem)

    if salesKitLineKey <> "" AND explodedKitItem = "Y" then

    error_code = oLines.GetValue("ItemCode$", base_model_item_code)

    error_code = oLines.GetValue("Revision$", revision)

    error_code = oLines.GetValue("BillOption1$", bill_option_1)

    error_code = oLines.GetValue("BillOption2$", bill_option_2)

    error_code = oLines.GetValue("BillOption3$", bill_option_3)

    error_code = oLines.GetValue("BillOption4$", bill_option_4)

    error_code = oLines.GetValue("BillOption5$", bill_option_5)

    error_code = oLines.GetValue("BillOption6$", bill_option_6)

    error_code = oLines.GetValue("BillOption7$", bill_option_7)

    error_code = oLines.GetValue("BillOption8$", bill_option_8)

    error_code = oLines.GetValue("BillOption8$", bill_option_9)

    retVal=oLines.MoveNext()

    kit_sales_kit_line_key = ""

    kit_exploded_kit_item = ""

    error_code = oLines.GetValue("SalesKitLineKey$", kit_sales_kit_line_key)

    error_code = oLines.GetValue("ExplodedKitItem$", kit_exploded_kit_item)

    Do until oLines.EOF

    If kit_sales_kit_line_key <> "" AND kit_exploded_kit_item = "N" Then

    component_item_code = ""

    bill_option_category = 0

    bill_option_category = bill_option_category + 1

    bill_option_category_as_string = ""

    bill_option_category_as_string = CStr(bill_option_category)

    bill_option = 00

    bill_option_description = ""

    if bill_option_category = 1 Then

    bill_option = bill_option_1

    elseif bill_option_category = 2 Then

    bill_option = bill_option_2

    elseif bill_option_category = 3 Then

    bill_option = bill_option_3

    elseif bill_option_category = 4 Then

    bill_option = bill_option_4

    elseif bill_option_category = 5 Then

    bill_option = bill_option_5

    elseif bill_option_category = 6 Then

    bill_option = bill_option_6

    elseif bill_option_category = 7 Then

    bill_option = bill_option_7

    elseif bill_option_category = 8 Then

    bill_option = bill_option_8

    elseif bill_option_category = 9 Then

    bill_option = bill_option_9

    end if

    SET oS = oSession.AsObject(oSession.GetObject("BM_BillOptionHeader_svc"))

    retval = oS.SetKeyValue("BillNo$", base_model_item_code)

    retval = oS.SetKeyValue("Revision$", revision)

    retval = oS.SetKeyValue("BillOptionCategory$", bill_option_category_as_string)

    retval = oS.SetKeyValue("BillOption$", "01")

    retval = oS.Find()

    error_code = oS.GetValue("OptionDesc1$", bill_option_description)

    error_code = oLines.SetValue("ItemCodeDesc$", bill_option_description)

    error_code = oLines.Write()

    end if

    retVal=oLines.MoveNext()

    Loop

    else

    retVal=oLines.MoveNext()

    end if

    retVal=oLines.MoveNext()

    Loop