title: For each inside map Dataweave
body: <p>I am trying to do a for each on a database result set in Dataweave and not able to achieve the result.</p>
  
  <p><strong>Input payload:</strong></p>
  
  <pre><code>{
      "x_orders_cursor": [{
          "LINE_QTY": 1,
          "ORDER_NUMBER": 11820490,
          "ORDERED_ITEM": "PAT1M",
          "LINE_UOM": "PC"
      }, {
          "LINE_QTY": 5000,
          "ORDER_NUMBER": 11820542,
          "ORDERED_ITEM": "ACC62-A-D",
          "LINE_NUMBER": 1,
          "LINE_UOM": "PC"
      }, {
          "LINE_QTY": 2000,
          "ORDER_NUMBER": 11820542,
          "ORDERED_ITEM": "ACC62-A-D",
          "LINE_NUMBER": 2,
          "LINE_UOM": "PC"
      }]
  }
  </code></pre>
  
  <p><strong>Expected Payload:</strong> </p>
  
  <pre><code>{
      "Orders": [
          {
              "OrderNum": "11820490",
              "Lines": [
                  {
                      "LineNum": 1,
                      "ProductNum": "PAT1M",
                      "TxnQty": 1,
                      "TxnQtyUOM": "PC"
                  }
              ]
          },
          {
              "OrderNum": "11820542",
              "Lines": [
                  {
                      "LineNum": 1,
                      "ProductNum": "ACC62-A-D",
                      "TxnQty": 1000,
                      "TxnQtyUOM": "PC"
                  },
                  {
                      "LineNum": 2,
                      "ProductNum": "ACC62-A-D",
                      "TxnQty": 2000,
                      "TxnQtyUOM": "PC"
                  }
              ]
          }
      ]
  }
  </code></pre>
  
  <p>Result set is based on a database table that stores both Order Number and Line Number.</p>