!!! Building tranformation function
Building a transformation function, version 4.6.6.6.
Analyzing the data source from Excel, three distinct cases emerge. Firstly, a dash separates the city name from the state abbreviation. Secondly, a space delimits the city from the state. Finally, a comma serves as the separator.
A logic must be devised to identify the specific case and apply different functions accordingly to extract the city and state. To achieve this, the character at the 4th position from the end of the string will be assessed.
If this character is a dash, it signifies case 1. If it's a comma, it's case 2. Otherwise, it falls under case 3. For case 1, a split using space-dash-space as the separator will yield the city at position 1 and the state at position 2. In case 2, a split using space-dash-space will first combine the city and state, followed by a secondary split using comma-space to isolate them. In case 3, the city will be extracted directly, while the state will comprise the last two characters of the string.
The PIS offers the flexibility to develop custom transformation functions using either VB.NET or C Sharp programming languages. Additional .NET components can also be incorporated using the import clause.
While C Sharp will be utilized in this course, conversion to VB.NET is feasible if required. Alternatively, functions can be developed and debugged using Visual Studio or Visual Studio Code before integration into the PIS IDE, leveraging the enhanced capabilities of these platforms.
To create a user-defined transformation function, navigate to Data Container and select Function and Process. Input a suitable name for the function, such as "Dimension Function for Obtaining City and State," and choose the preferred programming language, in this case, C Sharp. Within the Source Code tab, the function type "Function" will be selected.
It's crucial to commence with an example function code provided by the platform to ensure compliance with PIS requirements. This code structure includes declarations for external components, a fixed namespace (DynamicCode), and a predefined class (DynamicCode).
Following these conventions, the function's implementation proceeds by defining parameters, performing the necessary logic, and returning the desired result using the return command.
In the upcoming video, the implementation of the transformation function will be demonstrated, emphasizing the understanding and utilization of C Sharp commands for effective function development within the PIS environment.
Thank you, and stay tuned for the next video.