Skip to main content
vinayj6479
October 3, 2023
Question

Compare and get the ItemName

  • October 3, 2023
  • 12 replies
  • 0 views

 Hi team,

Iam building a logic where i have two lists as listed below, now i want to check data[1] i.e, wifi Router Demand value 500 with all (5 items)count values in Items[1] . and same data[2] with items[2] with all 5 count values in items[2] and return the sparepart Names that are less than demand value.

1. data: [product=Wi-Fi Router, Demand=500, productid=]; [product=Wi-Fi Extender, Demand=7, productid=]

2.items:{

{{Sparepart: "Wi-Fi Module", count: 100, productid: 1},

{Sparepart: "Antenna", count: 100, productid: 1},

{Sparepart: "Power Supply Unit", count: 100, productid: 1},

{Sparepart: "Ethernet Port", count: 100, productid: 1},

{Sparepart: "CPU Chip", count: 100, productid: 1}

},

{

{Sparepart: "Wi-Fi Extender Module", count: 20, productid: 2},

{Sparepart: "Extension Antenna", count: 30, productid: 2},

{Sparepart: "Power Adapter", count: 15, productid: 2},

{Sparepart: "Ethernet Cable", count: 25, productid: 2},

{Sparepart: "Signal Booster", count: 10, productid: 2}

}

}

i tried with the following, but for Demand i used a flag variable at last. i am unable to understand who to achieve this. please help me in solving this.

a!localVariables(
  local!flag:1,
  local!data: ri!DemandProduct,
  local!items: a!forEach(
    items: local!data,
    expression: rule!SCM_Sparepartsdata(local!data[fv!index].product)
  ),
  a!forEach(
    items: local!items,
    expression: a!forEach(
      items: local!items[fv!index],
      expression: {a!forEach(
        items:{ fv!item.count},
        /*expression: if(fv!item>local!data[1].Demand,fv!item ," ")*/
        expression:if(
          fv!item < local!data[local!flag].Demand,
          fv!item,
          " "
        ),
        
        
      ),
      
      }
    )
  )
)

    12 replies

    Inspiring
    October 4, 2023

    Can you please explain it more

    vinayj6479
    October 4, 2023

    Okay. i will explain the above exmaple. 

    I have data list and Items list. data list contains a product name and Demand count. item list contains the set of spareparts that are required manufacture the product. example data[1] is [product=Wi-Fi Router, Demand=500, productid=], for this product we have spare parts items[1] is

    {{Sparepart: "Wi-Fi Module", count: 100, productid: 1},

    {Sparepart: "Antenna", count: 100, productid: 1},

    {Sparepart: "Power Supply Unit", count: 100, productid: 1},

    {Sparepart: "Ethernet Port", count: 100, productid: 1},

    {Sparepart: "CPU Chip", count: 100, productid: 1}

    },

    Now i want to know in data list i have a variable called Demand it should compare the the all the count variable items[1] i.e the spare part list (5 list) and return the Fv!item that are less than Demand Value

    Inspiring
    October 4, 2023

    so in second example, it will return null right?
    As all the count values are greater than demand value.