E9.2 Iterate Over from a Data Request

JohnDanter2

JohnDanter2

VIP Member
Hi folks

What am I doing wrong here.
I have a simple data request over F0005 and I want to loop through the raw response and fire off a Get Currency Exchange connection (then eventually a form recording of updating F0015 in E1)
So my UDC 55 E1 contains USD GBP and EUR. I want the Orch to loop through the UDC and use the KY values to go get each exchange rate. (The API below defaults from exchange rate input variable to Polish Zlotiy by the way)

But....Even though I return raw output and have a Data Set Variable name, I get a 404 error from the connection as the URL is garbage

1714050272121.png


1714050306851.png

Return Raw Output ticked

1714050363342.png

Code:
{
  "Errors/Warnings": [],
  "continuedOnError": [],
  "RRD_F0005_UDC_DR": [
    {
      "userDefCode": "       EUR",
      "description1": "Euro",
      "description2": " ",
      "specialHandling": " ",
      "oF": " ",
      "hardCoded": "N"
    },
    {
      "userDefCode": "       GBP",
      "description1": "British Sterling",
      "description2": " ",
      "specialHandling": " ",
      "oF": " ",
      "hardCoded": "N"
    },
    {
      "userDefCode": "       USD",
      "description1": "US Dollar",
      "description2": " ",
      "specialHandling": " ",
      "oF": " ",
      "hardCoded": "N"
    }
  ]
}

So then I want to fire off the connector for every row in my UDC.

Connector (which works fine on it's own and even when wrapped in it's own simple ORCH)

1714050487560.png

1714050560534.png

It falls over with a bad URL, which is the same error I get if I just call https://api.nbp.pl/api/exchangerates/rates/A/${Currency}/?format=json on it's own with no currency mapped.

If I remove my input in the second step and just map in USD, it works fine
1714051256413.png

So to me it's not picking up the KY value in my raw output. So what did I do wrong?

I can imagine this is very simple, but I can't figure it out.

Trim the UDC KY maybe? "userDefCode": " EUR",
If anyone agrees this maybe the issue, is there a quicker way to do it other create a new custom groovy step to do this?

Thanks

John
 
Last edited:
I'm guessing it doesn't like the leading spaces in your currency codes. Try putting the currency codes into one of the description fields and see if that works for you.
 
Hi @JohnDanter2,

I did a similar project with ECB API and I had currencies codes conversion in a UDC too.

Yes, I believe (and I'm almost sure) the problem is the KY spaces, which is map directly to URL. Remove the spaces with a trim function and try again. or you can put currency codes in DL02 or SPHD field as say @Kevin Long and you don't need trim.

Regards.
 
Nice. I'll use DL02. It works brilliantly.
But maybe it's worth me making a trim groovy block anyway :)

Thanks
 
Back
Top