DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Related

  • Kafka JDBC Source Connector for Large Data
  • Kafka Connect: Strategies To Handle Updates and Deletes
  • How to Restore a Transaction Log Backup in SQL Server
  • How to Attach SQL Database Without a Transaction Log File

Trending

  • Analyzing Techniques to Provision Access via IDAM Models During Emergency and Disaster Response
  • Non-Project Backlog Management for Software Engineering Teams
  • Unlocking the Benefits of a Private API in AWS API Gateway
  • Role of Cloud Architecture in Conversational AI
  1. DZone
  2. Data Engineering
  3. Databases
  4. Read SAP Tables With RFC_READ_TABLE in Mule 4 Using SAP Connector

Read SAP Tables With RFC_READ_TABLE in Mule 4 Using SAP Connector

Learn how to make an RFC to SAP, how to use various operators (like AND, OR, IN, etc.), and what the default structure of RFC_READ_TABLE input looks like.

By 
Prathamesh Kulkarni user avatar
Prathamesh Kulkarni
·
Mar. 07, 22 · Tutorial
Likes (4)
Comment
Save
Tweet
Share
7.5K Views

Join the DZone community and get the full member experience.

Join For Free

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.

Depending on your use case you may want to include a different number of fields and different types of operators, which will give you your desired data from SAP.

MuleSoft SAP Connector enables Mule runtime engines to support SAP integration as a certified SAP Java Connector (JCo) that leverages SAP JCo libraries. For connecting Mule with SAP, please check out this article. 

Assuming you have established the connection successfully, it is now time to make the first call to RFC (Remote Function Call).

Here I am going to use the Synchronous Remote Function Call and the function will be RFC_READ_TABLE.

To make a call to SAP RFC, you need to build the required XML Format,

 
%dw 2.0
output application/xml
---

{
   RFC_READ_TABLE: {
      "import": {
         DELIMITER:";",
         QUERY_TABLE: "The Name of your query table",
         ROWCOUNT: 0
      },
      tables: {
         FIELDS: {
                    
            row: {
               FIELDNAME: "Field 1"               
            },
            row: {
               FIELDNAME: "Field 2"               
            },
            row: {
               FIELDNAME: "Field 3"               
            },
            row: {
               FIELDNAME: "Field 4"               
            }
         }
      }
   	}
}

DELIMITER is basically for separating your data, you can use PIPE "|" or any other separator as well.

ROWCOUNT: 0 indicates you want to have a full copy of data from the queried table, or else you can specify the number of lines. If we can relate it with SQL, then it is like a LIMIT keyword.

Now I will be querying a table and we will see how it gives you output. SAP gives you output in XML only. We can easily convert it to JSON using the transform message.

JSON
 
{
  "RFC_READ_TABLE": {
    "import": {
      "DELIMITER": ";",
      "NO_DATA": null,
      "QUERY_TABLE": "ZPB40_IBDN",
      "ROWCOUNT": "3",
      "ROWSKIPS": "0"
    },
    "tables": {
      "DATA": {
        "row": {
          "WA": "0180035892;20170119;000000000000021112                      ;L-ARGININE C 20 KG                      ;                    ;20161220;C"
        },
        "row": {
          "WA": "0180035892;20170119;000000000000021112                      ;L-ARGININE C 20 KG                      ;                    ;20161220;C"
        },
        "row": {
          "WA": "0180035892;20170119;000000000000021112                      ;L-ARGININE C 20 KG                      ;                    ;20161220;C"
        }
      },
      "FIELDS": {
        "row": {
          "FIELDNAME": "VBELN",
          "OFFSET": "000000",
          "LENGTH": "000010",
          "TYPE": "C",
          "FIELDTEXT": "Delivery"
        },
        "row": {
          "FIELDNAME": "LFDAT",
          "OFFSET": "000011",
          "LENGTH": "000008",
          "TYPE": "D",
          "FIELDTEXT": "Delivery Date"
        },
        "row": {
          "FIELDNAME": "MATNR",
          "OFFSET": "000020",
          "LENGTH": "000040",
          "TYPE": "C",
          "FIELDTEXT": "Material Number"
        },
        "row": {
          "FIELDNAME": "ARKTX",
          "OFFSET": "000061",
          "LENGTH": "000040",
          "TYPE": "C",
          "FIELDTEXT": "Short text for sales order item"
        },
        "row": {
          "FIELDNAME": "ZWF_STATUS",
          "OFFSET": "000102",
          "LENGTH": "000020",
          "TYPE": "C",
          "FIELDTEXT": "Workflow Status"
        },
        "row": {
          "FIELDNAME": "ERDAT",
          "OFFSET": "000123",
          "LENGTH": "000008",
          "TYPE": "D",
          "FIELDTEXT": "Date on which the record was created"
        },
        "row": {
          "FIELDNAME": "WBSTK",
          "OFFSET": "000132",
          "LENGTH": "000001",
          "TYPE": "C",
          "FIELDTEXT": "Goods Movement Status (All Items)"
        }
      },
      "OPTIONS": null
    }
  }
}

As you can see, I gave the row count as three and that is the reason we got three rows in the output. It is separated by the ;.

If you see the object FIELDS, it tells you which values columns you selected with the description as well. OPTIONS are showing as null because we have not provided any value to it. OPTIONS are basically the where clause of SQL, which means you can get data for a specified column value.
Let's see how to implement it in Mule 4:
Mule 4 implementation

The input payload to SAP looks like the above image, and in OPTIONS, I have given two values and used the AND operator for that. It will return all the values that match these conditions.

You can use different types of logical operators depending on your requirement, such as OR, IN, and LIKE.

The operators =, <>, <, >, <=, and >= are equivalent to EQ, NE, LT, GT, LE, and GE respectively.

This is how you can get the data from the SAP RFC Read Table.  

Database Connector (mathematics) sql

Opinions expressed by DZone contributors are their own.

Related

  • Kafka JDBC Source Connector for Large Data
  • Kafka Connect: Strategies To Handle Updates and Deletes
  • How to Restore a Transaction Log Backup in SQL Server
  • How to Attach SQL Database Without a Transaction Log File

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!