Skip to main content Skip to complementary content

Defining a globalMap variable in a map

Create a Job to extract data from an API and store it in a globalMap variable.

Procedure

  1. In the Integration perspective, right-click the Job Designs node and click Create Standard Job.
  2. Enter a name, purpose and description for your Job, then click Finish.
  3. Add the following components to your design workspace and link them with Row > Main connections:
    • A tHttpRequest
    • A tHMap
    • A tLogRow
    Your Job should look like this:
  4. Double-click the tHttpRequest component and configure it as follows:
    Parameter Value
    URI "https://www.swapi.tech/api/people?page=1&limit=10"
    Method GET
  5. Double-click the tLogRow component and click the ... button next to Edit schema.
  6. Add the following columns in the input and copy them to the output, then click OK.
    Column Type
    pages Integer
    results Integer
  7. Double-click the tHMap component to generate the map.
    1. In the first step, select Select an existing hierarchical mapper structure and click Next, then select the structure you created from the API.
    2. In the second step, keep the default option and click Next, then click Finish.
    The map is created, you can now configure it.
  8. Click the output row element and drag a FixedLoop function in its Loop tab.
  9. Drag the input total_records element to the output results element, and the input total_pages to the output pages.
  10. Click the output root element and open the Util tab, then drag and drop a PutValueToExternalMap function in it.
  11. Drag and drop a Constant function on the Key argument, double-click it and define the name of the variable, total.pages for example.
  12. Drag and drop an XPathFunction function on the Value argument, double-click and enter xs:integer(%v) in the Function/Arguments field.
    In this example, the variable created should be an Integer, however, the PutValueToExternalMap produces a String by default. In order to use the variable as an Integer, you need to add the XPathFunction function to define it as a BigInteger.
  13. Drag and drop the input total_pages element on the XPathFunction.
  14. Save the map.

Results

The first part of the Job is configured, and you can run it to check the results. In the next steps, you will use the variable in another component.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!