Escolar Documentos
Profissional Documentos
Cultura Documentos
Applies to:
This applies to SAP NetWeaver, SAP-Java, SAP Java Connector (Jco). For more information, visit the Java
homepage.
Summary
This article will help you understand the ways in which you can handle and use the import and export
parameters of a ABAP function module (RFC enabled) in your Java code. This will help you in interacting
with ABAP with simple JCo calls & teach you how to use the different types of ABAP function module
parameters in Java. This article is written from Java’s prespective and teaches how to handle the different
type of values passed and returned to/from a ABAP function module in Java.
Author: Vikram Kharata
Company: Steria
Created on: 9 July 2009
Author Bio
Vikram Kharata is working as a Senior Engineer with Steria. He is primarily a Java developer
and his current work area involves creating and supporting applications in the SAP-Java
domain using SAP Netweaver Platform. He also has a good working knowledge of SAP
Enterprise Portal and a little knowledge of ABAP programming.
Table of Contents
ABAP Function vs Java method ......................................................................................................................... 3
Prerequisites ................................................................................................................................................... 3
Concept ........................................................................................................................................................... 3
Handling Import Parameters in Java .................................................................................................................. 3
Prerequisites ................................................................................................................................................... 3
Concept ........................................................................................................................................................... 3
Handling Export Parameters in Java .................................................................................................................. 5
Prerequisites ................................................................................................................................................... 5
Concept ........................................................................................................................................................... 5
Complete Example ............................................................................................................................................. 8
Related Content .................................................................................................................................................. 9
Disclaimer and Liability Notice .......................................................................................................................... 10
Concept
An ABAP function module is very similar in concept to a function or method written in Java.
Conceptually, both take a set of parameters as input, process data and return a set of parameters as output.
The values that are passed to a function are called Import Parameters in ABAP, and are called input
parameters in Java. The values that a function returns are called Export Parameters in ABAP, and are
called a return value in Java.
Note: While a Java method can return only single value or multiple values of the same data type, an ABAP function
module can return any number of export parameters which can be of same or different data types.
Concept
In order to execute a ABAP function module successfully in Java, you must set the values of the import
parameters in your Java code. How to set the import parameter’s value depends upon its type.
Import Parameters can be broadly classified into the following three categories on the basis of their data
types.
1. Simple/Elementary Data Types:
The following diagram shows the mapping between Java and ABAP.
SAP JCo automatically performs the conversion between ABAP and Java data types.
To set the import parameters of these types use the code as under,
2. Structure:
A structure is a sequence of any elementary types, reference types, or complex data types. To set a
value in the import parameter of type structure, follow the code sample given below,
3. Table:
A table is used to store rows of data where each row has the same data type, which can be
elementary or complex.
To set values in the import parameter of type table, follow the code sample given below,
Concept
Like import parameters, the export parameters are also of different types and have to be handled accordingly
in Java.
Export Parameters can be broadly classified into the following three categories on the basis of their data
types.
SAP JCo automatically performs the conversion between ABAP and Java data types.
Retrieving the values from the export parameters of these types is quite simpler as shown in the
code as under,
The above example uses HashMap to store the results in Java. You can choose your own object
type to store the values.
Complete Example
Please find the entire code sample below for your easy reference,
Related Content
SAP JCo
ABAP Function Modules
Java References
For more information, visit the Java homepage.