Skip to Content

SAP Cloud development has lot of interesting and undocumented features. One for such example is Field Transformation.

This document gives you an idea on how to use it and where to use it.


Using field transformations, you can avoid lot of extra fields which are basically calculated. Calculation can mean anything here based on your operation.

Let us take a small example to see how it works.


Example: To display logon language of user, you don’t need to write an absl script always. If you want to render it on the UI, then UI layer can do the same job as absl does.

With the assumption that you’ve defined your BO and opened your QAF/OIF screen in UI Designer and switched to Data Model, follow these steps:

Step 1: Create a new field in your DataModel and set the DedicatedField (LogonLanguage) property to true.

     /wp-content/uploads/2014/02/scr1_388816.jpg

Ste 2: Switch to Controller tab and create a New FieldTransformation.

     /wp-content/uploads/2014/02/scr2_388838.png

Step 3: In the next screen that you see, set the field values as shown in the below screenshot (where TargetField is the one which you created in Step1)

     /wp-content/uploads/2014/02/scr3_388839.png

Step 4: That’s it. It just works with what you’ve done till now. Bring the DedicatedField (LogonLanguage) on to the screen where ever you want and preview the screen.

     scr4.PNG



If you ask me, ” Okay. We are done with SimpleExample. Now what? How complex can this thing go? “, my answer would be ” I am here to help you to make a good start. There are lot of other reusable functions which might help your use case which you’ll have to dig it out yourself buddy.

  • Just toggle through namespaces in Step 3.
  • Make sure that you have these properties of the DedicatedField in your DataModel filled properly right after TargetField assignment in Step 3.

          scr5.PNG

  • You might encounter dumps for some FieldTransformations as it totally depends on the DataType of the DedicatedField most of the times. Each FieldTransformation returns values of a particular DataType. Some may not be even PSM released. If there’s nothing you can do and you tried your best already, then do raise an incident to know the exact reason why it didn’t work in your case.

It is just not the case that you need to use the UI layer functions always. If you want to bring up something on to the screen which is an outcome of your absl code, even that is possible.

  • Create a new Reusable library and create a New Function with the UI Designer indicator checked as shown in the below screenshot.

          Capture.PNG

  • In this case, as we are writing a simple code to return Current User’s LoggedIn language, we just need a return parameter. But, make sure that the data type you use is available in the list of released GDT datatypes as you’re gonna have to assign the same data type to the DedicatedField later on in UI Deisgner. Review and Finish the function creation screen.

          Capture.PNG

  • Prepare your absl code with something like as shown in the below screenshot.

          Capture.PNG

  • Okay. Now, we are done with what has to be done on absl side. Going back to UI Designer part, we just need to make one change in method which we already followed that is at Step 3. Select your solution Namespace in the Namespace field.

          Capture.PNG

  • You know about the rest of the Process. Good luck with it.

Is this the only advantage of such a useful feature? Well, fortunately, NO!

As the title of this document talks about using Field Transformation but not in UI Designer alone. So, here you go with another way where you can make a good use of Field Transformations.

  • Consider a general requirement that you have a Date field in your Custom BO and user stores date when creating instances but wants to see just the Month while viewing Report so that he can sort the Business Data based on ‘Month’.
  • So, when you create DataSource on your Custom BO, stop at Stage 3/6 and have a look at what that screen provides you. Select your Date field and look at the right pane for what all you can do with that. You should something like below:

     Capture.PNG

  • In this example, you will have new field in your Report with name “Month” which gives you only Month values from the custom field “FinalDate”. You don’t have to store ‘Month’ as a separate field in your Custom BO to show it for reporting purposes. Isn’t this good?
  • There are few such DataTypes with which you can play in this screen like Duration. You can get this info from Documentation. Have fun with it.

End of story pal! Let me know if this could be done in a better way or something needs to be added. Thanks for going through.

To report this post you need to login first.

22 Comments

You must be Logged on to comment or reply to a post.

    1. Sangeeta Roy

      Hi Dhruvin,

      Did you get the above scenario worked out? could you pass an importing parameter to the reuse Library function and based on it get a returning value?

      I have a ‘Read’ function in my reuse libraryID which has a importing parameter ‘ProductID’ I have a returning value based on this ProductID.

      However I am unable to successfully pass the importing parameter from the UI designer floorplan where the data is stored in my data-model’s dedicated data-field.

      (0) 
      1. Dhruvin Mehta

        I dont think it is possible sangeeta in my case i was using context Bo ( which is i think has a single instance through out the session ) so i did not need read but yes i think from UI Designer i was not able to pass parameter in import! u can do that in absl code.

        (0) 
        1. Sangeeta Roy

          Hi Janna,

          I was able to solve my problem without using field transformation. I have built a custom BO with the parameter ProductID as the key. I could call the ReadBO operation on this BO from the UI designer. From this BO I called my reuse library function.

          I can send you the details of my solution if you need it.

          (0) 
          1. Janna Meyer

            Hey Sangeeta,

            thank you for your answer! Your approach sounds sufficient. Indeed it’d be very helpful if you sent me more details of your solution..

            (0) 
  1. Dedeepya Reddy

    Hi All, Though its an old post, I have stepped on Field Transformations with import params just now, and they dont seem to work:) Is this a known limitation, that Import Parameters cannot be passed from UI Designer to Reuse Function in PDI? I have a similar scenario as Sangeetha had, but I cannot use a custom BO for it, as I need to generate a URL on the fly. Any expert comments? BR Dedepepya

    (0) 
    1. Horst Schaude

      Hello Dedeepya,

      If you are on an SAP BO you canonly use the Extensibility Explorer view inside the UI Designer. The possibilities of this Extensibility Explorer are limited. 🙁

      So, sorry, this is not possible here.

      Bye,

         Horst

      (0) 
      1. Dedeepya Reddy

        Hi Horst, I got it working. I learnt that the import does not support structured content e.g. InternalID or UUID as they are structured data types.  I updated import data type to a LONG EXTENDED TEXT and i could get the required flow. However, I would like to test if it is possible to return an entire structure 🙂 and not just a field. BR Dedeepya

        (0) 
        1. Horst Schaude

          Hello Dedeepya,

          This depends on the defintion of the input paraneter of the Transformation Definition.

          What TD are you using: From SAP or an own one?

          Bye,

              Horst

          (0) 
            1. Horst Schaude

              Hello Dedeepya,

              So it is onyour responsibility to define the interface of the TD so it matches the required data types. 😀

              Bye,

                 Horst

              (0) 
              1. Dedeepya Reddy

                Hi Horst, That is correct, I was passing ID of Account and I used the same data type in my TD as well. But the ID was not passing to the TD Function, that is when SAP Product team communicated we can only use Non-Structured data like LANGUAGE_INDEPENDANT_TEXT element.

                (0) 
  2. Fred K

    Hi all,

    Can we use custom Reuse functions for FieldTransformation in Data Source?

    I cannot find my custom Reuse function while creating Data Source.

    Best Regards,

    Fred

    (0) 
    1. Horst Schaude

      Hello Fred,

      What I take out from the docu at section 8.10.2.5 Transformation Rules is:

      Available Transformation Rules

      Transformation rules are only available for fields of the data types GLOBAL_DateTime, Date, and the Name, Description, and Text data types, which represent character strings.

      A list of available TR is following in the docu.

      Therefore I doubt that any function from your CRU lib is available in a Data Source.

      Sorry,

          Horst

      (0) 
      1. Dedeepya Reddy

        Hi Horst, I tried using my Field Transformation Rule on a LANGUAGEINDEPENDENT_EXTENDED_Text element but for the resp. field on Data Source i could only get “Concatenate” as Transformation Rule, I could not get the custom Reuse Functions i have created with same data types for import & return parameters. BR Dedeepya

        (0) 

Leave a Reply