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.
=head1 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');
=head1 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.
# print STDERR " value for: ".$self->name()." is ", $self->{'VALUE'},"\n";
if(my$s= $self->structure ){
$s->value( $self->{'VALUE'} );
my$flds= {};
map{ $flds->{$_} = $s->$_() } ( $s->fields );
return$flds;
} else{
return$self->{'VALUE'};
}
}
# get the parameter internal value
subintvalue {
my$self= shift;
$self->{VALUE} = shiftif@_;
# print STDERR "PARM: ".$self->name() ." type ".$self->intype()." is: ".$self->{'VALUE'}."\n";
# Sort out theinternal format
# if ( $self->{VALUE}){
if( $self->{VALUE} ne ''){
if( $self->intype() == RFCTYPE_BCD){
returnpack("H*", $self->{VALUE});
} elsif( $self->intype() == RFCTYPE_FLOAT){
returnpack("d", $self->{VALUE});
} elsif( $self->intype() == RFCTYPE_INT){
# return pack("I4", int($self->{VALUE}));
returnpack("l", int($self->{VALUE}));
} elsif( $self->intype() == RFCTYPE_INT2){
returnpack("S", int($self->{VALUE}));
} elsif( $self->intype() == RFCTYPE_INT1){
# get the last byte of the integer
return(unpack("A A A A", int($self->{VALUE})))[-1];
} else{
# print STDERR " length is: ".$self->leng()." value is: ".$self->{'VALUE'}."\n";
returnpack("A".$self->leng(),$self->{VALUE});
};
} else{
if( $self->intype() == RFCTYPE_CHAR ){
# $self->leng( 1 );
return" ";
} else{
# $self->leng( 0 );
return"";
};
};
}
# Set/get the parameter default
subdefault{
my$self= shift;
$self->{DEFAULT} = shiftif@_;
return$self->{DEFAULT};
}
# Set/get the parameter structure
substructure {
my$self= shift;
$self->{STRUCTURE} = shiftif@_;
return$self->{STRUCTURE};
}
# Set/get the parameter length
subleng {
my$self= shift;
if( $self->intype() == RFCTYPE_FLOAT){
$self->{LEN} = 8;
} elsif( $self->intype() == RFCTYPE_INT){
$self->{LEN} = 4;
} elsif( $self->intype() == RFCTYPE_INT2){
$self->{LEN} = 2;
} elsif( $self->intype() == RFCTYPE_INT1){
$self->{LEN} = 1;
} else{
$self->{LEN} = shiftif@_;
};
return$self->{LEN};
}
# get the name
subname {
my$self= shift;
return$self->{NAME};
}
=head1 NAME
SAP::Parms - Perl extension for parsing and creating an SAP parameter to be added to an RFC Interface.
=head1 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 );
=head1 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.
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.
=head1 SYNOPSIS
use SAP::Struc;
$struct = new SAP::Struc( NAME => XYZ, FIELDS => [......] );
=head1 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.
=head1 Exported constants
NONE
=head1 AUTHOR
Piers Harding, saprfc@ompa.net
But Credit must go to all those that have helped.
=head1 SEE ALSO
perl(1), SAP(3), SAP::Rfc(3), SAP::Iface(3)
=cut
1;
Keyboard Shortcuts
Global
s
Focus search bar
?
Bring up this help dialog
GitHub
gp
Go to pull requests
gi
go to github issues (only if github is preferred repository)