The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

SAP::Iface - Perl extension for parsing and creating an Interface Object. The interface object would then be passed to the SAP::Rfc object to carry out the actual call, and return of values.

SYNOPSIS

use SAP::Iface;
$iface = new SAP::Iface( NAME =>"RFCNAME" );
NAME is mandatory.

or more commonly:

use SAP::Rfc;
$rfc = new SAP::Rfc( ASHOST => ... );
$iface = $rfc->discover('RFC_READ_REPORT');

DESCRIPTION

This class is used to construct a valid interface object ( SAP::Iface.pm ). The constructor requires the parameter value pairs to be passed as hash key values ( see SYNOPSIS ). Generally you would not create one of these manually as it is far easier to use the "discovery" functionality of the SAP::Rfc->discover("RFCNAME") method. This returns a fully formed interface object. This is achieved by using standard RFCs supplied by SAP to look up the definition of an RFC interface and any associated structures.

Methods: new use SAP::Iface; $iface = new SAP::Iface( NAME =>"RFC_READ_TABLE" ); Create a new Interface object.

$iface->PARM_NAME(' new value ') Parameters and tables are autoloaded methods - than can be accessed like this to set and get their values.

$iface->RFCTYPE_CHAR Autoloaded methods are provided for all the constant definitions relating to SAP parameter types.

$iface->name() Return the name of an interface.

$iface->addParm( TYPE => SAP::Iface->RFCEXPORT, INTYPE => SAP::Iface->RFCTYPE_CHAR, NAME => 'A_NAME', STRUCTURE => $rfc->structure('NAME_OF_STRUCTURE'), DEFAULT => 'the default value', VALUE => 'the current value', DECIMALS => 0, LEN => 20 ); Add an RFC interface parameter to the SAP::Iface definition - see SAP::Parm.

$iface->parm('PARM_NAME'); Return a reference to a named parameter object.

$iface->parms(); Return a list of parameter objects for an interface.

$iface->addTab( INTYPE => SAP::Iface->RFCTYPE_BYTE, NAME => 'NAME_OF_TABLE', STRUCTURE => $rfc->structure('NAME_OF_STRUCTURE'), LEN => 35 ); Add an RFC interface table definition to the SAP::Iface object - see SAP::Tab.

$iface->isTab('TAB_NAME'); Returns true if the named parameter is a table.

$iface->tab('TAB_NAME'); Return a reference to the named table object - see SAP::Tab.

$iface->tabs(); Return a list of table objects for the SAPP::Iface object.

$iface->emptyTables(); Empty the contents of all the tables on a SAP::Iface object.

$iface->addException('EXCEPTION_NAME'); Add an exception name to the interface.

$iface->exception('EXCEPTION_NAME'); Return the named exception name - basically I dont do anything with exceptions yet except keep a list of names that could be checked against an RFC failure return code.

$iface->exceptions(); Return a list of exception names associated with a SAP::Iface object.

$iface->reset(); Empty all the tables and reset paramters to their default values - useful when you are doing multiple calls.

$iface->iface(); An internal method that generates the internal structure passed into the C routines.

NAME

SAP::Tab - Perl extension for parsing and creating Tables to be added to an RFC Iface.

SYNOPSIS

use SAP::Tab;
$tab1 = new SAP::Tab( 
              INTYPE => SAP::Iface->RFCTYPE_BYTE, 
               NAME => 'NAME_OF_TABLE',
               STRUCTURE =>
                   $rfc->structure('NAME_OF_STRUCTURE'), 
               LEN => 35 );

DESCRIPTION

This class is used to construct a valid Table object to be add to an interface object ( SAP::Iface.pm ). The constructor requires the parameter value pairs to be passed as hash key values ( see SYNOPSIS ).

Methods: new use SAP::Tab; $tab1 = new SAP::Tab( INTYPE => SAP::Iface->RFCTYPE_BYTE, NAME => 'NAME_OF_TABLE', STRUCTURE => $rfc->structure('NAME_OF_STRUCTURE'), LEN => 35 );

$tab->rows() @r = $tab1->rows( [ row1, row2, row3 .... ] ); optionally set and Give the current rows of a table.

or:
$tab1->rows( [ { TEXT => "NAME LIKE 'SAPL\%RFC\%'", .... } ] );
pass in a list of hash refs where each hash ref is the key value pairs of the 
table structures fields ( as per the DDIC ).

$tab->addRow() Add a row to the table contents.

$tab->hashRows() @r = $tab1->hashRows; This returns an array of hashes representing each row of a table. The hashes are fieldname/value pairs of the row structure.

$tab->nextRow() shift the first row off the table contents, and return a hash ref of the field values as per the table structure.

$tab->rowCount() $c = $tab1->rowCount(); return the current number of rows in a table object.

$tab->empty() empty the row out of the table.

$tab->name() get the name of the table object.

$tab->intype() Set or get the internal table type.

$tab->leng() Set or get the table row length.

$tab->structure() Set or get the structure object of the table - see SAP::Struct.

NAME

SAP::Parms - Perl extension for parsing and creating an SAP parameter to be added to an RFC Interface.

SYNOPSIS

use SAP::Parms;
$imp1 = new SAP::Parms(
               TYPE => SAP::Iface->RFCEXPORT,
               INTYPE => SAP::Iface->RFCTYPE_CHAR,
               NAME => 'A_NAME', 
               STRUCTURE =>
                  $rfc->structure('NAME_OF_STRUCTURE'), 
               DEFAULT => 'the default value',
               VALUE => 'the current value',
               DECIMALS => 0,
               LEN => 20 );

DESCRIPTION

This class is used to construct a valid parameter to add to an interface object ( SAP::Iface.pm ). The constructor requires the parameter value pairs to be passed as hash key values ( see SYNOPSIS ).

Methods: new use SAP::Parms; $imp1 = new SAP::Parms( TYPE => SAP::Iface->RFCEXPORT, INTYPE => SAP::Iface->RFCTYPE_CHAR, NAME => 'A_NAME', STRUCTURE => $rfc->structure('NAME_OF_STRUCTURE'), DEFAULT => 'the default value', VALUE => 'the current value', DECIMALS => 0, LEN => 20 );

$p->value() $v = $imp1->value( [ val ] ); optionally set and Give the current value.

or - pass in a hash ref where the hash ref contains  key/value pairs
for the fields in the complex parameters structure ( as per the DDIC ).

$p->type() $t = $imp1->type( [ type ] ); optionally set and Give the current value of type - this denotes whether this is an export or import parameter.

$p->decimals() Set or get the decimals place of the parameter.

$p->intype() Set or get the internal type ( as required by librfc ).

$p->intvalue() An internal method for translating the value of a parameter into the required native C format.

$p->default() Set or get the place holder for the default value of a paramter - in order to reset the value of a parameter to the default you need to $p->value( $p->default ); This is really an internal method that $iface->reset calls on each parameter.

$p->structure() Set or get the structure object for a parameter - not all parameters will have an associated structures - only complex ones. See SAP::Struc.

$p->leng() Set or get the length attribute of a parameter.

$p->name() Get the name of a parameter object.

NAME

SAP::Struc - Perl extension for parsing and creating a Structure definition. The resulting structure object is then used for SAP::Parms, and SAP::Tab objects to manipulate complex data elements.

SYNOPSIS

use SAP::Struc;
$struct = new SAP::Struc( NAME => XYZ, FIELDS => [......] );

DESCRIPTION

This class is used to construct a valid structure object - a structure object that would be used in an Export(Parms), Import(Parms), and Table(Tab) object ( SAP::Iface.pm ). This is normally done through the SAP::Rfc->structure('STRUCT_NAME') method that does an auto look up of the data dictionary definition of a structure. The constructor requires the parameter value pairs to be passed as hash key values ( see SYNOPSIS ). The value of each field can either be accessed through $str->fieldValue(field1), or through the autoloaded method of the field name eg. $str->FIELD1().

Methods: new use SAP::Struc; $str = new SAP::Struc( NAME => XYZ );

addField use SAP::Struc; $str = new SAP::Struc( NAME => XYZ ); $str->addField( NAME => field1, INTYPE => chars ); add a new field into the structure object. The field is given a position counter of the number of the previous number of fields + 1. Name is mandatory, but type will be defaulted to chars if omitted.

deleteField use SAP::Struc; $str = new SAP::Struc( NAME => XYZ ); $str->addField( NAME => field1, INTYPE => chars ); $str->deleteField('field1'); Allow fields to be deleted from a structure.

name $name = $str->name(); Get the name of the structure.

fieldName Get the field name by position in the structure - $s->fieldName( 3 ).

fieldType $ftype = $str->fieldType(field1, [ new field type ]); Set/Get the SAP BC field type of a component field of the structure. This will force the overall value of the structure to be recalculated.

value $fvalue = $str->value('new value'); Set/Get the value of the whole structure.

fieldValue $fvalue = $str->fieldValue(field1, [new component value]); Set/Get the value of a component field of the structure. This will force the overall value of the structure to be recalculated.

fields @f = &$struct->fields(); Return an array of the fields of a structure sorted in positional order.

Exported constants

NONE

AUTHOR

Piers Harding, saprfc@ompa.net

But Credit must go to all those that have helped.

SEE ALSO

perl(1), SAP(3), SAP::Rfc(3), SAP::Iface(3)