Show TOC Start of Content Area

Procedure documentation Handling Records  Locate the document in its SAP Library structure

In the statement MappedRecord output = (MappedRecord) interaction.execute(null, input);

(see also Client Programming Model) the input parameter should be of type MappedRecord. The return object output in this method is also always of type MappedRecord.

input MappedRecord contains a list of all Import, Changing and Table parameters, that are defined for the Function Module represented by this MappedRecord.

 

output MappedRecord contains a list of all Export, Changing and Table parameters that are defined for the Function Module represented by this MappedRecord.

ResultSet represents ABAP tables.

MappedRecord represents ABAP structures.

Both MappedRecords and ResultSets may contain inner ResultSets and MappedRecords.

To retrieve/set ResultSet, MappedRecord or other Objects (e.g. BigInteger) from/to MappedRecords use the methods get(…)/ put(…). To retrieve/set them from/to ResultSet use the methods getObject(…)/updateObject(…).

 

E.g. to retrieve a structure IMPORTSTRUCT  from the input MappedRecord object you need to call the method get(l..) on it and cast on the MappedRecord class.

 

MappedRecord input =

recordFactry.createMappedRecord("STFC_STRUCTURE");

MappedRecord importstruct =

(MappedRecord)input.get("IMPORTSTRUCT");

 

To get a ResultSet RFCTABLE  from input, you would call

 

ResultSet rfctable = (ResultSet)input.get("RFCTABLE");

 

If the table rfctable contains another table “MyTable”, you will get the table from the 3rd table entry  by

 

rfctable.relative(3); // set third line

ResultSet myTable3 = (ResultSet) rfctable.get("MyTable");

 

If this table line also contains among all other parameters a structure “MyStructure”, you can get it by

 

MappedRecord myStruct =

(MappedRecord) rfctable.getObject("MyStructure");

 

If this table line also contains an Integer parameter “MyInt”, you can get it by

int myInt = rfctable.getInt("MyInt");

 

In following we will call MappedRecord and ResultSetobjects as Records.

 

To set parameters of any non-Record type on the MappedRecord instance call the put(key, value) method and pass an according object, e.g.:

 

importstruct.put("RFCCHAR1",new Float(1.23456));

 

For all object values that can be represented by a String, you may also use the short form:

 

importstruct.put("RFCFLOAT","1.23456");

importstruct.put("RFCCHAR1",new Character('A'));

 

or:

 

importstruct.put("RFCCHAR1","A");

Here are some more examples to set other java types:

importstruct.put("RFCINT2", "12345");

importstruct.put("RFCCHAR4","ABCD");

 

byte [] b = {(byte)0xf7, (byte)0xf7, (byte)0xf7};

importstruct.put("RFCHEX3", b);

 

importstruct.put "RFCTIME",

new java.sql.Time(System.currentTimeMillis());

 

or:

 

importstruct.put("RFCTIME", "032559");

 

 

importstruct.put("RFCDATE", "2001-08-24");

importstruct.put("RFCDATA1", "Comment 1 of type RFCDATA1");

importstruct.put("RFCDATA1", new String("Some comments"));

 

To get parameters of any type from the MappedRecord instance call get(key) and cast it to type you are awaiting to receive, e.g.:

 

String s = (String) exportstruct.get("RESPTEXT");

byte [] b = (byte[]) exportstruct.get("RFCHEX3 ");

int rfcint2 = ((Integer)importstruct.get("RFCINT2")).intValue();

 

To set parameters of any non-Record type on ResultSet instance call

 

Update<ObjectType>(key, value)

 

and pass an according object, e.g.:

 

rfctable.updateFloat("RFCFLOAT",(float)1.6);

rfctable.updateString("RFCCHAR1","Y");

rfctable.updateInt("RFCINT2", 260 + i);

rfctable.updateShort("RFCINT1", (short)i);

rfctable.updateString("RFCCHAR4","EFGH"+i);

rfctable.updateLong("RFCINT4", Long.parseLong("987654321"));           rfctable.updateBytes("RFCHEX3", b);

rfctable.updateObject("RFCCHAR2","AB");

rfctable.updateTime("RFCTIME",

new java.sql.Time(System.currentTimeMillis()));

rfctable.updateDate("RFCDATE",

      new java.sql.Date(System.currentTimeMillis()));

rfctable.updateString("RFCDATA1", "My RFCDATA1");

 

For any java non-Primitive type (so Objects), you may use method

 

updateObject("MyObject", object);

 

where object could be a String, byte[], Integer, BigInteger etc.

 

Usually, you set some table values by using

mechanisms like:

 

for (int i = 0; i < 5; i++)

{

          rfctable.moveToInsertRow();

 

          rfctable.updateShort("RFCINT1", (short)i);

          rfctable.updateString("RFCCHAR4","EFGH"+i);

 

          rfctable.insertRow();

}

 

and get values by

 

int count = 0;

while (rfctable.next())

{

    count += rfctable.getInt("RFCINT2");

}

 

ResultSet has a number of navigation methods (like method next()).

 

For homogenous structures it may be convenient to use iterators.

E.g. for MappedRecord struct having everywhere Strings it could be

 

Iterator keys = struct.keySet().iterator();

String key, myString = "";

while (keys.hasNext())

{

   key = (String)keys.next();

   myString += (String)struct.get(key);

}

 

 

 

End of Content Area