Setting a byte offset in a flat structure - 7.3

Talend Data Mapper Functions Reference Guide

Version
7.3
Language
English
Product
Talend Big Data Platform
Talend Data Fabric
Talend Data Management Platform
Talend Data Services Platform
Talend MDM Platform
Talend Real-Time Big Data Platform
Module
Talend Studio
Content
Design and Development > Designing Jobs
Last publication date
2023-01-05

Use a SetElementProperty and a GetElementProperty function to edit a byte offset in an element.

Before you begin

You have created a flat structure.

About this task

In this example, you have a flat file with a root element and three child elements named a, b and c, with the following sample data:
A1111B2222C00003333
Each child element has an initiator, A, B and C respectively. The goal is to configure the c element to ignore the 0000 part of the value.

Procedure

  1. Open the Util tab for the c element.
  2. Drag and drop a SetElementProperty function in the Util tab.
  3. Drag and drop an Add function on the Value argument.
  4. Drag and drop a GetElementProperty function on the First Value argument.
  5. Double-click the GetElementProperty function and select Byte offset in the Property drop-down list, then click OK.
  6. Drag and drop the c element on the Element argument of the GetElementProperty function.
  7. Drag and drop a Constant function on the Second Value argument.
  8. Double-click the Constant function and enter 4 in the Value field, then click OK.

Results

The expression created indicates that the byte offset for the c elements should be calculated by adding the four bytes to ignore to the current offset of the c element, which is called by the GetElementProperty element.
If you want to check that the new offset is correct, you can create a map with this structure as both input and output.
When using the Test Run feature, you should get the following result:
A1111B2222C3333