Tuesday, May 22, 2007

RFC Calls for Manipulating Internal Tables

One of my friend had asked to explain the process of manipulating the internal tables with the RFC calls from SAP. The RFC is enabled by the function interface that is part of the RFC library provided by SAP.

These functions allow processing of ABAP internal tables in C.

ABAP internal tables follow the model of a relational database table.

ABAP internal tables consist of identical rows. When it is created, a table is empty. In ABAP you can fill rows into a table by the statements ‘Insert’ or ‘Append’. You can access a row by ‘Read Table’, and you can delete a row by ‘Delete’. You can free a table by ‘Free Table’, and you can receive information about tables by ‘Describe’.

These language constructs correspond to the following C routines:

  • ItCreate

creates a new internal table

  • ITAB_H

handle of an internal table

  • ItDelete

deletes the content of a complete internal table and frees storage

  • ItGetLine

reads a line from an internal table

  • ItInsLine

inserts a line into the given position of an internal table

  • ItAppLine

appends a line at the end of an internal table

  • ItDelLine

deletes a line from an internal table

  • ItGupLine

reads a line for update

  • ItFree

resets an internal table to initial state

  • ItFill

returns the number of lines in a table

  • ItLeng

returns the width of a table, i.e. the size of a row of the table

The syntax and semantics of the above RFC calls are identical for all platforms supported.

The syntax of the RFC calls is described in saprfc.h. The syntax of the RFC calls for manipulating internal tables is described in sapitab.h.

Creating and filling a new internal table with the following example

const int myTableSize = 200;
ITAB_H handle;
void * ptr;

handle = IitCreate("MyTable", myTableSize, 0,0);
if(handle == ITAB_NULL)
{
... error
}

do
{
ptr = ItAppLine(handle);;

if(ptr != NULL)
{
memcpy(ptr,..., myTableSize);
}
while(ptr != NULL);


More help is available in the SAP help site:

http://help.sap.com/saphelp_46c/helpdata/de/22/043074488911d189490000e829fbbd/frameset.htm

No comments: