Read SAP Tables With RFC_READ_TABLE in Mule 4 Using SAP Connector

In this article, we are going to see how to make an RFC (Remote Function Call) to SAP and what different options are available to get your desired data. We'll also learn how to make use of various operators like AND, OR, IN, and many more, and what the default structure of RFC_READ_TABLE input looks like.

Whenever you are working with SAP, you will surely go with RFC calls and a lot of developers struggle to write XML queries for RFC.

DataWeave Tip #8: The write Function

Originally published February 26, 2019

Recently I have been working on a really simple case. When an HTTP server returned an error and a non-empty body, I needed to embed this body into an error structure. Although this is a simple case, I got a problem with implementing it in Mule 4. In the previous Mule edition, it was a little bit simpler. So let's see what it is all about.

Case

First, we have a look at the case that I have to implement. I have a mule application that is calling an external HTTP server via an HTTP request component. When the server responds with an error like 4xx, 5xx, and the returned body will is not empty, we would like to forward that response to the calling application.

Dataweave 2.4.0 Dates Module Functions

DataWeave is a programming language designed for transforming data. It is the primary language of MuleSoft for data transformation and an expression language for components and connectors configuration.

Mulesoft released Dataweave 2.4.0 for Mule Version 4.4. The 2.4.0 version of DataWeave introduced many new features. In this post, we will see one of the newly introduced DataWeave modules.

Mule Runtime 4.4 Features

Mule runtime engine 4.4 provides important enhancements and fixes. Deploy all your new and existing applications to Mule 4.4 to benefit from all the improvements in this version.

Correlation ID Management

Mule 4.4 enables you to modify the correlation ID associated with a Mule event. You can also change the algorithm Mule uses to generate each correlation ID.

Dataweave 2: Objects and Arrays

Anybody dealing with Dataweave scripts will often come across situations where an Object needs to be converted into an Array or vice-versa. The Dataweave 2 examples below describe how to convert between Objects and Arrays.

Example 1: Converting an Object to an Array

This example uses the core Dataweave function pluck; it is useful in mapping an object into an array, pluck iterates over an object and returns an array of keys, values, or indices from the object. It is an alternative to mapObject, which is similar but returns an object, instead of an array.

DataWeave Practice: Prime Number Code

What Is a Prime Number?

A prime number is a natural number that is greater than 1 and divisible by 1 and itself. That means the prime number will have only two factors 1 and that number itself. Some of the prime numbers are 2, 3, 5, 7,11,13, etc.

Before writing the code let's list down what will be the different types of inputs. So the inputs can be

Access Mule Application Properties With DataWeave

Main Points

  • DataWeave script can reference application properties.
  • DataWeave expressions can reference properties in the configuration.

Configure a Property File

Firstly, you will need to configure a property file in which application properties are defined. There are steps parts to follow:

  1. Create the property file in which the application properties are defined.
  2. Create a Configuration Property to reference the location of the file.
  3. Use property placeholders in the application configuration.

You can find more about this in my blog post How to configure Property Files in Mule 4.

Masking Data With MuleSoft DataWeave

In this article, we will see various examples of how we can mask data using MuleSoft DataWeave. MuleSoft DataWeave has a helper function, mask, in the DW Utils Values module.

We will be using the payload below to understand the mask function.

DataWeave: The map Function Explained

Main Points:

  • The map function transforms data
  • If iterates over the elements in an array 
  • It applies a transformation to each element
  • Applies only to array input
  • It can only output an array

What Is the map Function Used For?

The map function is used to transform the data contained in an array. It does this by iterating over the elements in the array and applying a transformation to each element. The result of the transformation is collected together and output as an array of transformed elements. If you are familiar with Java 8 functional programming approach, a comparison can be made with the the map() method of the Stream class, find out more in my article Contrast DataWeave and Java mapping operations.

How Is the Transformation Described?

The transformation that is applied to each element is described with DataWeave. For example, to change a text value in the source array use the upper() built in function.

How to do Memory Management for DataWeave

About

This article goes over how to perform memory management in order to effectively run larger MuleSoft DataWeave scripts. I tried to create helpful images to explain how DataWeave memory management works. 

Introduction

DataWeave is a powerful and MuleSoft proprietary data transformation expression language, tightly integrated with powerful Mule Runtime Engine.

Decode JWT Tokens With Dataweave and MuleSoft

Introduction

JWT stands for JSON Web Tokens and it represents the claims that needs to be securely transferred between two parties. It's a light weight, JSON-based, URL safe token and claim that is encoded as a JSON object which is digitally signed with a JSON Web Signature (JWS) and encrypted using JSON Web encryption (JWE).

JSON Web Token is Base64 encoded and it consists of three parts separated by the dots (.).

Difference Between Update Function and Update Operator in Dataweave

The new Update function of Dataweave is beneficial to update an object. Below are some of the useful ways to use the update function.

To use the update function, we need to import the package dw::util::Values. The other functions available in this package are attr, mask, index, field. I am providing an example of how we can use the update function in this article.

Implementing Dataweave Crypto With Mulesoft

MuleSoft provides various functions to encrypt the fields within Dataweave transformation and it can be achieved using various algorithms like MD5, SHA1, etc.

To use Crypto in the Datawave, one must import Crypto by using import dw::Crypto