| 1 | package SAP::BC::Iface; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 1 | ▶ | use vars qw($VERSION $AUTOLOAD); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | # Globals | ||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | # Valid parameters | ||||||||||||||||||||
| 10 | 1 | my $VALID = { | |||||||||||||||||||
| 11 | NAME => 1, | ||||||||||||||||||||
| 12 | PARAMETERS => 1, | ||||||||||||||||||||
| 13 | TABLES => 1, | ||||||||||||||||||||
| 14 | EXCEPTIONS => 1 | ||||||||||||||||||||
| 15 | }; | ||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 1 | $VERSION = '0.03'; | |||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | # empty destroy method to stop capture by autoload | ||||||||||||||||||||
| 20 | 0 | ▶ | sub DESTROY { | ||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 21 | } | ||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 0 | ▶ | sub AUTOLOAD { | ||||||||||||||||||
|
Subroutine
AUTOLOAD: not called CC=4 SCAR=30.0
| |||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | 0 | my $self = shift; | |||||||||||||||||||
| 26 | 0 | my @parms = @_; | |||||||||||||||||||
| 27 | 0 | ▶ | my $type = ref($self) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 28 | or die "$self is not an Object in autoload of Iface"; | ||||||||||||||||||||
| 29 | 0 | my $name = $AUTOLOAD; | |||||||||||||||||||
| 30 | 0 | $name =~ s/.*://; | |||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | # Autoload parameters and tables | ||||||||||||||||||||
| 33 | 0 | ▶ | if ( exists $self->{PARAMETERS}->{uc($name)} ) { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 34 | 0 | &Parm($self, $name); | |||||||||||||||||||
| 35 | } elsif ( exists $self->{TABLES}->{uc($name)} ) { | ||||||||||||||||||||
| 36 | 0 | &Tab($self, $name); | |||||||||||||||||||
| 37 | } else { | ||||||||||||||||||||
| 38 | 0 | die "Parameter $name does not exist in Interface - no autoload"; | |||||||||||||||||||
| 39 | }; | ||||||||||||||||||||
| 40 | } | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | # Construct a new SAP::Interface object | ||||||||||||||||||||
| 44 | 0 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | 0 | my $proto = shift; | |||||||||||||||||||
| 47 | 0 | ▶ | my $class = ref($proto) || $proto; | ||||||||||||||||||
|
Condition0%0/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||
| 48 | 0 | my $self = { | |||||||||||||||||||
| 49 | PARAMETERS => {}, | ||||||||||||||||||||
| 50 | TABLES => {}, | ||||||||||||||||||||
| 51 | EXCEPTIONS => {}, | ||||||||||||||||||||
| 52 | @_ | ||||||||||||||||||||
| 53 | }; | ||||||||||||||||||||
| 54 | 0 | ▶ | die "No RFC Name supplied to Interface !" if ! exists $self->{NAME}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | # Validate parameters | ||||||||||||||||||||
| 57 | 0 | ▶ | map { delete $self->{$_} if ! exists $VALID->{$_} } keys %{$self}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 58 | 0 | $self->{NAME} = $self->{NAME}; | |||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | # create the object and return it | ||||||||||||||||||||
| 61 | 0 | bless ($self, $class); | |||||||||||||||||||
| 62 | 0 | return $self; | |||||||||||||||||||
| 63 | } | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | # get the name | ||||||||||||||||||||
| 67 | 0 | ▶ | sub name { | ||||||||||||||||||
|
Subroutine
name: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | 0 | my $self = shift; | |||||||||||||||||||
| 70 | 0 | return $self->{NAME}; | |||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | } | ||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | # Add an export parameter Object | ||||||||||||||||||||
| 76 | 0 | ▶ | sub addParm { | ||||||||||||||||||
|
Subroutine
addParm: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | 0 | my $self = shift; | |||||||||||||||||||
| 79 | 0 | ▶ | die "No parameter supplied to Interface !" if ! @_; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 80 | 0 | my $parm; | |||||||||||||||||||
| 81 | 0 | ▶ | if (my $ref = ref($_[0])){ | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 82 | 0 | ▶ | die "This is not an Parameter for the Interface - $ref ! " | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 83 | if $ref ne "SAP::BC::Parms"; | ||||||||||||||||||||
| 84 | 0 | $parm = $_[0]; | |||||||||||||||||||
| 85 | } else { | ||||||||||||||||||||
| 86 | 0 | $parm = SAP::BC::Parms->new( @_ ); | |||||||||||||||||||
| 87 | }; | ||||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | 0 | return $self->{PARAMETERS}->{$parm->name()} = $parm; | |||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | } | ||||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | |||||||||||||||||||||
| 94 | # Access the export parameters | ||||||||||||||||||||
| 95 | 0 | ▶ | sub Parm { | ||||||||||||||||||
|
Subroutine
Parm: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||
| 96 | |||||||||||||||||||||
| 97 | 0 | my $self = shift; | |||||||||||||||||||
| 98 | 0 | ▶ | die "No parameter name supplied for interface" if ! @_; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 99 | 0 | my $parm = uc(shift); | |||||||||||||||||||
| 100 | die "Export $parm Does not exist in interface !" | ||||||||||||||||||||
| 101 | 0 | ▶ | if ! exists $self->{PARAMETERS}->{$parm}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 102 | 0 | return $self->{PARAMETERS}->{$parm}; | |||||||||||||||||||
| 103 | |||||||||||||||||||||
| 104 | } | ||||||||||||||||||||
| 105 | |||||||||||||||||||||
| 106 | |||||||||||||||||||||
| 107 | # Return the parameter list | ||||||||||||||||||||
| 108 | 0 | ▶ | sub Parms { | ||||||||||||||||||
|
Subroutine
Parms: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 109 | |||||||||||||||||||||
| 110 | 0 | my $self = shift; | |||||||||||||||||||
| 111 | 0 | return sort { $a->name() cmp $b->name() } values %{$self->{PARAMETERS}}; | |||||||||||||||||||
| 112 | |||||||||||||||||||||
| 113 | } | ||||||||||||||||||||
| 114 | |||||||||||||||||||||
| 115 | |||||||||||||||||||||
| 116 | # Add an Table Object | ||||||||||||||||||||
| 117 | 0 | ▶ | sub addTab { | ||||||||||||||||||
|
Subroutine
addTab: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||
| 118 | |||||||||||||||||||||
| 119 | 0 | my $self = shift; | |||||||||||||||||||
| 120 | 0 | ▶ | die "No Table supplied for interface !" if ! @_; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 121 | 0 | my $table; | |||||||||||||||||||
| 122 | 0 | ▶ | if ( my $ref = ref($_[0]) ){ | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 123 | 0 | ▶ | die "This is not a Table for interface: $ref ! " | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 124 | if $ref ne "SAP::BC::Tab"; | ||||||||||||||||||||
| 125 | 0 | $table = $_[0]; | |||||||||||||||||||
| 126 | } else { | ||||||||||||||||||||
| 127 | 0 | $table = SAP::BC::Tab->new( @_ ); | |||||||||||||||||||
| 128 | }; | ||||||||||||||||||||
| 129 | 0 | return $self->{TABLES}->{$table->name()} = $table; | |||||||||||||||||||
| 130 | |||||||||||||||||||||
| 131 | } | ||||||||||||||||||||
| 132 | |||||||||||||||||||||
| 133 | |||||||||||||||||||||
| 134 | # Access the Tables | ||||||||||||||||||||
| 135 | 0 | ▶ | sub Tab { | ||||||||||||||||||
|
Subroutine
Tab: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||
| 136 | |||||||||||||||||||||
| 137 | 0 | my $self = shift; | |||||||||||||||||||
| 138 | 0 | ▶ | die "No Table name supplied for interface" if ! @_; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 139 | 0 | my $table = uc(shift); | |||||||||||||||||||
| 140 | die "Table $table Does not exist in interface !" | ||||||||||||||||||||
| 141 | 0 | ▶ | if ! exists $self->{TABLES}->{ $table }; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 142 | 0 | return $self->{TABLES}->{ $table }; | |||||||||||||||||||
| 143 | |||||||||||||||||||||
| 144 | } | ||||||||||||||||||||
| 145 | |||||||||||||||||||||
| 146 | |||||||||||||||||||||
| 147 | # Return the Table list | ||||||||||||||||||||
| 148 | 0 | ▶ | sub Tabs { | ||||||||||||||||||
|
Subroutine
Tabs: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 149 | |||||||||||||||||||||
| 150 | 0 | my $self = shift; | |||||||||||||||||||
| 151 | 0 | return sort { $a->name() cmp $b->name() } values %{$self->{TABLES}}; | |||||||||||||||||||
| 152 | |||||||||||||||||||||
| 153 | } | ||||||||||||||||||||
| 154 | |||||||||||||||||||||
| 155 | |||||||||||||||||||||
| 156 | # Empty The contents of all tables in an interface | ||||||||||||||||||||
| 157 | 0 | ▶ | sub emptyTables { | ||||||||||||||||||
|
Subroutine
emptyTables: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 158 | |||||||||||||||||||||
| 159 | 0 | my $self = shift; | |||||||||||||||||||
| 160 | map { | ||||||||||||||||||||
| 161 | 0 | my $table = $self->{TABLES}->{ $_ }; | |||||||||||||||||||
| 162 | 0 | $table->empty(); | |||||||||||||||||||
| 163 | 0 | } keys %{$self->{TABLES}}; | |||||||||||||||||||
| 164 | |||||||||||||||||||||
| 165 | } | ||||||||||||||||||||
| 166 | |||||||||||||||||||||
| 167 | |||||||||||||||||||||
| 168 | =head1 NAME | ||||||||||||||||||||
| 169 | |||||||||||||||||||||
| 170 | SAP::BC::Iface - Perl extension for parsing and creating an Interface Object. The interface object would then be passed to the SAP::BC::XMLRFC object to carry out the actual call, and return of values. | ||||||||||||||||||||
| 171 | |||||||||||||||||||||
| 172 | =head1 SYNOPSIS | ||||||||||||||||||||
| 173 | |||||||||||||||||||||
| 174 | use SAP::BC::Iface; | ||||||||||||||||||||
| 175 | $iface = new SAP::BC::Iface( NAME =>"SAPBC:ServiceName" ); | ||||||||||||||||||||
| 176 | |||||||||||||||||||||
| 177 | NAME is mandatory. | ||||||||||||||||||||
| 178 | |||||||||||||||||||||
| 179 | =head1 DESCRIPTION | ||||||||||||||||||||
| 180 | |||||||||||||||||||||
| 181 | This class is used to construct a valid interface object ( SAP::BC::Iface.pm ). | ||||||||||||||||||||
| 182 | The constructor requires the parameter value pairs to be passed as | ||||||||||||||||||||
| 183 | hash key values ( see SYNOPSIS ). | ||||||||||||||||||||
| 184 | Generally you would not create one of these manually as it is far easier to use the "discovery" functionality of the SAP::BC::XMLRFC->Iface() method. Tis takes the name of an existing BC service, and returns a fully formed interface object. | ||||||||||||||||||||
| 185 | |||||||||||||||||||||
| 186 | Methods: | ||||||||||||||||||||
| 187 | new | ||||||||||||||||||||
| 188 | use SAP::BC::Iface; | ||||||||||||||||||||
| 189 | $iface = new SAP::BC::Iface( NAME =>"SAPBC:ServiceName" ); | ||||||||||||||||||||
| 190 | |||||||||||||||||||||
| 191 | Create a new Interface object. | ||||||||||||||||||||
| 192 | |||||||||||||||||||||
| 193 | |||||||||||||||||||||
| 194 | =head1 Exported constants | ||||||||||||||||||||
| 195 | |||||||||||||||||||||
| 196 | NONE | ||||||||||||||||||||
| 197 | |||||||||||||||||||||
| 198 | =cut | ||||||||||||||||||||
| 199 | |||||||||||||||||||||
| 200 | package SAP::BC::Tab; | ||||||||||||||||||||
| 201 | |||||||||||||||||||||
| 202 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 203 | 1 | ▶ | use vars qw($VERSION); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 204 | |||||||||||||||||||||
| 205 | # Globals | ||||||||||||||||||||
| 206 | |||||||||||||||||||||
| 207 | # Valid parameters | ||||||||||||||||||||
| 208 | 1 | my $VALID = { | |||||||||||||||||||
| 209 | DATA => 1, | ||||||||||||||||||||
| 210 | NAME => 1, | ||||||||||||||||||||
| 211 | STRUCTURE => 1 | ||||||||||||||||||||
| 212 | }; | ||||||||||||||||||||
| 213 | |||||||||||||||||||||
| 214 | # Construct a new SAP::BC::Table object. | ||||||||||||||||||||
| 215 | 0 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: not called CC=5 SCAR=34.0
| |||||||||||||||||||||
| 216 | |||||||||||||||||||||
| 217 | 0 | my $proto = shift; | |||||||||||||||||||
| 218 | 0 | ▶ | my $class = ref($proto) || $proto; | ||||||||||||||||||
|
Condition0%0/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||
| 219 | 0 | my $self = { | |||||||||||||||||||
| 220 | DATA => [], | ||||||||||||||||||||
| 221 | TYPE => "chars", | ||||||||||||||||||||
| 222 | @_ | ||||||||||||||||||||
| 223 | }; | ||||||||||||||||||||
| 224 | |||||||||||||||||||||
| 225 | 0 | ▶ | die "Table Name not supplied !" if ! exists $self->{NAME}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 226 | 0 | ▶ | die "Table Structure not supplied !" if ! exists $self->{STRUCTURE}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 227 | |||||||||||||||||||||
| 228 | # Validate parameters | ||||||||||||||||||||
| 229 | 0 | ▶ | map { delete $self->{$_} if ! exists $VALID->{$_} } keys %{$self}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 230 | 0 | $self->{NAME} = uc($self->{NAME}); | |||||||||||||||||||
| 231 | |||||||||||||||||||||
| 232 | # create the object and return it | ||||||||||||||||||||
| 233 | 0 | bless ($self, $class); | |||||||||||||||||||
| 234 | 0 | return $self; | |||||||||||||||||||
| 235 | |||||||||||||||||||||
| 236 | } | ||||||||||||||||||||
| 237 | |||||||||||||||||||||
| 238 | |||||||||||||||||||||
| 239 | # Set/get the table rows - pass a reference to a anon array | ||||||||||||||||||||
| 240 | 0 | ▶ | sub rows { | ||||||||||||||||||
|
Subroutine
rows: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 241 | |||||||||||||||||||||
| 242 | 0 | my $self = shift; | |||||||||||||||||||
| 243 | 0 | ▶ | $self->{DATA} = shift if @_; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 244 | 0 | return @{$self->{DATA}}; | |||||||||||||||||||
| 245 | |||||||||||||||||||||
| 246 | } | ||||||||||||||||||||
| 247 | |||||||||||||||||||||
| 248 | |||||||||||||||||||||
| 249 | # Return the next available row from a table | ||||||||||||||||||||
| 250 | 0 | ▶ | sub nextrow { | ||||||||||||||||||
|
Subroutine
nextrow: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 251 | |||||||||||||||||||||
| 252 | 0 | my $self = shift; | |||||||||||||||||||
| 253 | 0 | my $row = shift @{$self->{DATA}}; | |||||||||||||||||||
| 254 | |||||||||||||||||||||
| 255 | 0 | return { map {$self->structure->Fieldname( $_ ) => $row->[$_ - 1] } | |||||||||||||||||||
| 256 | 0 | ▶ | ( 1 .. scalar @{[$self->structure->Fields]} ) } if $row; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 257 | |||||||||||||||||||||
| 258 | } | ||||||||||||||||||||
| 259 | |||||||||||||||||||||
| 260 | |||||||||||||||||||||
| 261 | # Set/get the structure parameter | ||||||||||||||||||||
| 262 | 0 | ▶ | sub structure { | ||||||||||||||||||
|
Subroutine
structure: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 263 | |||||||||||||||||||||
| 264 | 0 | my $self = shift; | |||||||||||||||||||
| 265 | 0 | ▶ | $self->{STRUCTURE} = shift if @_; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 266 | 0 | return $self->{STRUCTURE}; | |||||||||||||||||||
| 267 | |||||||||||||||||||||
| 268 | } | ||||||||||||||||||||
| 269 | |||||||||||||||||||||
| 270 | |||||||||||||||||||||
| 271 | # add a row | ||||||||||||||||||||
| 272 | 0 | ▶ | sub addrow { | ||||||||||||||||||
|
Subroutine
addrow: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 273 | |||||||||||||||||||||
| 274 | 0 | my $self = shift; | |||||||||||||||||||
| 275 | 0 | ▶ | push(@{$self->{DATA}}, @_) if @_; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 276 | |||||||||||||||||||||
| 277 | } | ||||||||||||||||||||
| 278 | |||||||||||||||||||||
| 279 | |||||||||||||||||||||
| 280 | # Delete all rows in the table | ||||||||||||||||||||
| 281 | 0 | ▶ | sub empty { | ||||||||||||||||||
|
Subroutine
empty: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 282 | |||||||||||||||||||||
| 283 | 0 | my $self = shift; | |||||||||||||||||||
| 284 | 0 | $self->{DATA} = [ ]; | |||||||||||||||||||
| 285 | 0 | return @{$self->{DATA}}; | |||||||||||||||||||
| 286 | |||||||||||||||||||||
| 287 | } | ||||||||||||||||||||
| 288 | |||||||||||||||||||||
| 289 | # Get the table name | ||||||||||||||||||||
| 290 | 0 | ▶ | sub name { | ||||||||||||||||||
|
Subroutine
name: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 291 | |||||||||||||||||||||
| 292 | 0 | my $self = shift; | |||||||||||||||||||
| 293 | 0 | return $self->{NAME}; | |||||||||||||||||||
| 294 | |||||||||||||||||||||
| 295 | } | ||||||||||||||||||||
| 296 | |||||||||||||||||||||
| 297 | |||||||||||||||||||||
| 298 | # Get the number of rows | ||||||||||||||||||||
| 299 | 0 | ▶ | sub rowcount { | ||||||||||||||||||
|
Subroutine
rowcount: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 300 | |||||||||||||||||||||
| 301 | 0 | my $self = shift; | |||||||||||||||||||
| 302 | 0 | return $#{$self->{DATA}} + 1; | |||||||||||||||||||
| 303 | |||||||||||||||||||||
| 304 | } | ||||||||||||||||||||
| 305 | |||||||||||||||||||||
| 306 | |||||||||||||||||||||
| 307 | |||||||||||||||||||||
| 308 | # Autoload methods go after =cut, and are processed by the autosplit program. | ||||||||||||||||||||
| 309 | |||||||||||||||||||||
| 310 | |||||||||||||||||||||
| 311 | =head1 NAME | ||||||||||||||||||||
| 312 | |||||||||||||||||||||
| 313 | SAP::BC::Tab - Perl extension for parsing and creating Tables to be added to an RFC Iface. | ||||||||||||||||||||
| 314 | |||||||||||||||||||||
| 315 | =head1 SYNOPSIS | ||||||||||||||||||||
| 316 | |||||||||||||||||||||
| 317 | use SAP::BC::Tab; | ||||||||||||||||||||
| 318 | $tab1 = new SAP::BC::Tab( NAME => XYZ, VALUE => abc ); | ||||||||||||||||||||
| 319 | |||||||||||||||||||||
| 320 | =head1 DESCRIPTION | ||||||||||||||||||||
| 321 | |||||||||||||||||||||
| 322 | This class is used to construct a valid Table object to be add to an interface | ||||||||||||||||||||
| 323 | object ( SAP::BC::Iface.pm ). | ||||||||||||||||||||
| 324 | The constructor requires the parameter value pairs to be passed as | ||||||||||||||||||||
| 325 | hash key values ( see SYNOPSIS ). | ||||||||||||||||||||
| 326 | |||||||||||||||||||||
| 327 | Methods: | ||||||||||||||||||||
| 328 | new | ||||||||||||||||||||
| 329 | use SAP::BC::Tab; | ||||||||||||||||||||
| 330 | $tab1 = new SAP::BC::Tab( NAME => XYZ, ROWLENGTH => 1, | ||||||||||||||||||||
| 331 | DATA => [a, b, c, ..] ); | ||||||||||||||||||||
| 332 | |||||||||||||||||||||
| 333 | rows | ||||||||||||||||||||
| 334 | @r = $tab1->rows( [ row1, row2, row3 .... ] ); | ||||||||||||||||||||
| 335 | optionally set and Give the current rows of a table. | ||||||||||||||||||||
| 336 | |||||||||||||||||||||
| 337 | rowcount | ||||||||||||||||||||
| 338 | $c = $tab1->rowcount(); | ||||||||||||||||||||
| 339 | return the current number of rows in a table object. | ||||||||||||||||||||
| 340 | |||||||||||||||||||||
| 341 | |||||||||||||||||||||
| 342 | =head1 Exported constants | ||||||||||||||||||||
| 343 | |||||||||||||||||||||
| 344 | NONE | ||||||||||||||||||||
| 345 | |||||||||||||||||||||
| 346 | =cut | ||||||||||||||||||||
| 347 | |||||||||||||||||||||
| 348 | package SAP::BC::Parms; | ||||||||||||||||||||
| 349 | |||||||||||||||||||||
| 350 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 351 | 1 | ▶ | use vars qw($VERSION); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 352 | |||||||||||||||||||||
| 353 | # Globals | ||||||||||||||||||||
| 354 | |||||||||||||||||||||
| 355 | # Valid parameters | ||||||||||||||||||||
| 356 | 1 | my $VALID = { | |||||||||||||||||||
| 357 | NAME => 1, | ||||||||||||||||||||
| 358 | PHASE => 1, | ||||||||||||||||||||
| 359 | STRUCTURE => 1, | ||||||||||||||||||||
| 360 | TYPE => 1, | ||||||||||||||||||||
| 361 | VALUE => 1 | ||||||||||||||||||||
| 362 | }; | ||||||||||||||||||||
| 363 | |||||||||||||||||||||
| 364 | # Valid data types | ||||||||||||||||||||
| 365 | 1 | my $VALTYPE = { | |||||||||||||||||||
| 366 | chars => 1, | ||||||||||||||||||||
| 367 | date => 1, | ||||||||||||||||||||
| 368 | time => 1, | ||||||||||||||||||||
| 369 | int => 1, | ||||||||||||||||||||
| 370 | decimal => 1, | ||||||||||||||||||||
| 371 | num => 1, | ||||||||||||||||||||
| 372 | float => 1 | ||||||||||||||||||||
| 373 | }; | ||||||||||||||||||||
| 374 | |||||||||||||||||||||
| 375 | # Construct a new SAP::Parms parameter object. | ||||||||||||||||||||
| 376 | 0 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: not called CC=5 SCAR=34.0
| |||||||||||||||||||||
| 377 | |||||||||||||||||||||
| 378 | 0 | my $proto = shift; | |||||||||||||||||||
| 379 | 0 | ▶ | my $class = ref($proto) || $proto; | ||||||||||||||||||
|
Condition0%0/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||
| 380 | 0 | my $self = { | |||||||||||||||||||
| 381 | TYPE => "chars", | ||||||||||||||||||||
| 382 | VALUE => undef, | ||||||||||||||||||||
| 383 | PHASE => 'I', | ||||||||||||||||||||
| 384 | @_ | ||||||||||||||||||||
| 385 | }; | ||||||||||||||||||||
| 386 | |||||||||||||||||||||
| 387 | 0 | ▶ | die "Parameter Name not supplied !" if ! exists $self->{NAME}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 388 | die "Parameter Type not valid $self->{TYPE} !" | ||||||||||||||||||||
| 389 | 0 | ▶ | if ! exists $VALTYPE->{$self->{TYPE}}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 390 | |||||||||||||||||||||
| 391 | # Validate parameters | ||||||||||||||||||||
| 392 | 0 | ▶ | map { delete $self->{$_} if ! exists $VALID->{$_} } keys %{$self}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 393 | 0 | $self->{NAME} = uc($self->{NAME}); | |||||||||||||||||||
| 394 | |||||||||||||||||||||
| 395 | # create the object and return it | ||||||||||||||||||||
| 396 | 0 | bless ($self, $class); | |||||||||||||||||||
| 397 | 0 | return $self; | |||||||||||||||||||
| 398 | } | ||||||||||||||||||||
| 399 | |||||||||||||||||||||
| 400 | |||||||||||||||||||||
| 401 | # Set/get the value of type | ||||||||||||||||||||
| 402 | 0 | ▶ | sub type { | ||||||||||||||||||
|
Subroutine
type: not called CC=3 SCAR=24.8
| |||||||||||||||||||||
| 403 | |||||||||||||||||||||
| 404 | 0 | my $self = shift; | |||||||||||||||||||
| 405 | 0 | ▶ | $self->{TYPE} = shift if @_; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 406 | die "Parameter Type not valid $self->{TYPE} !" | ||||||||||||||||||||
| 407 | 0 | ▶ | if ! exists $VALTYPE->{$self->{TYPE}}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 408 | 0 | return $self->{TYPE}; | |||||||||||||||||||
| 409 | |||||||||||||||||||||
| 410 | } | ||||||||||||||||||||
| 411 | |||||||||||||||||||||
| 412 | |||||||||||||||||||||
| 413 | # Set/get the parameter value | ||||||||||||||||||||
| 414 | 0 | ▶ | sub value { | ||||||||||||||||||
|
Subroutine
value: not called CC=3 SCAR=24.8
| |||||||||||||||||||||
| 415 | |||||||||||||||||||||
| 416 | 0 | my $self = shift; | |||||||||||||||||||
| 417 | 0 | ▶ | $self->{VALUE} = shift if @_; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 418 | 0 | ▶ | if ($self->{VALUE}){ | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 419 | 0 | return $self->{VALUE}; | |||||||||||||||||||
| 420 | } else { | ||||||||||||||||||||
| 421 | 0 | return ""; | |||||||||||||||||||
| 422 | }; | ||||||||||||||||||||
| 423 | |||||||||||||||||||||
| 424 | } | ||||||||||||||||||||
| 425 | |||||||||||||||||||||
| 426 | |||||||||||||||||||||
| 427 | # Set/get the parameter structure | ||||||||||||||||||||
| 428 | 0 | ▶ | sub structure { | ||||||||||||||||||
|
Subroutine
structure: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 429 | |||||||||||||||||||||
| 430 | 0 | my $self = shift; | |||||||||||||||||||
| 431 | 0 | ▶ | $self->{STRUCTURE} = shift if @_; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 432 | 0 | return $self->{STRUCTURE}; | |||||||||||||||||||
| 433 | |||||||||||||||||||||
| 434 | } | ||||||||||||||||||||
| 435 | |||||||||||||||||||||
| 436 | |||||||||||||||||||||
| 437 | # get the name | ||||||||||||||||||||
| 438 | 0 | ▶ | sub name { | ||||||||||||||||||
|
Subroutine
name: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 439 | |||||||||||||||||||||
| 440 | 0 | my $self = shift; | |||||||||||||||||||
| 441 | 0 | return $self->{NAME}; | |||||||||||||||||||
| 442 | |||||||||||||||||||||
| 443 | } | ||||||||||||||||||||
| 444 | |||||||||||||||||||||
| 445 | |||||||||||||||||||||
| 446 | |||||||||||||||||||||
| 447 | # Below is the stub of documentation for your module. You better edit it! | ||||||||||||||||||||
| 448 | |||||||||||||||||||||
| 449 | =head1 NAME | ||||||||||||||||||||
| 450 | |||||||||||||||||||||
| 451 | SAP::BC::Parms - Perl extension for parsing and creating an SAP parameter to be added to an RFC Interface. | ||||||||||||||||||||
| 452 | |||||||||||||||||||||
| 453 | =head1 SYNOPSIS | ||||||||||||||||||||
| 454 | |||||||||||||||||||||
| 455 | use SAP::BC::Parms; | ||||||||||||||||||||
| 456 | $imp1 = new SAP::BC::Parms( NAME => XYZ, | ||||||||||||||||||||
| 457 | TYPE => chars, VALUE => abc ); | ||||||||||||||||||||
| 458 | |||||||||||||||||||||
| 459 | =head1 DESCRIPTION | ||||||||||||||||||||
| 460 | |||||||||||||||||||||
| 461 | This class is used to construct a valid parameter to add to an interface | ||||||||||||||||||||
| 462 | object ( SAP::BC::Iface.pm ). | ||||||||||||||||||||
| 463 | The constructor requires the parameter value pairs to be passed as | ||||||||||||||||||||
| 464 | hash key values ( see SYNOPSIS ). | ||||||||||||||||||||
| 465 | |||||||||||||||||||||
| 466 | Methods: | ||||||||||||||||||||
| 467 | new | ||||||||||||||||||||
| 468 | use SAP::BC::Parms; | ||||||||||||||||||||
| 469 | $imp1 = new SAP::BC::Parms( NAME => XYZ, | ||||||||||||||||||||
| 470 | TYPE => chars, VALUE => abc ); | ||||||||||||||||||||
| 471 | |||||||||||||||||||||
| 472 | value | ||||||||||||||||||||
| 473 | $v = $imp1->value( [ val ] ); | ||||||||||||||||||||
| 474 | optionally set and Give the current value. | ||||||||||||||||||||
| 475 | |||||||||||||||||||||
| 476 | type | ||||||||||||||||||||
| 477 | $t = $imp1->type( [ type ] ); | ||||||||||||||||||||
| 478 | optionally set and Give the current value of type. | ||||||||||||||||||||
| 479 | |||||||||||||||||||||
| 480 | =head1 Exported constants | ||||||||||||||||||||
| 481 | |||||||||||||||||||||
| 482 | NONE | ||||||||||||||||||||
| 483 | |||||||||||||||||||||
| 484 | =cut | ||||||||||||||||||||
| 485 | |||||||||||||||||||||
| 486 | |||||||||||||||||||||
| 487 | package SAP::BC::Struc; | ||||||||||||||||||||
| 488 | |||||||||||||||||||||
| 489 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 490 | 1 | ▶ | use vars qw($VERSION $AUTOLOAD); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 491 | |||||||||||||||||||||
| 492 | # require AutoLoader; | ||||||||||||||||||||
| 493 | |||||||||||||||||||||
| 494 | # Globals | ||||||||||||||||||||
| 495 | |||||||||||||||||||||
| 496 | # Valid parameters | ||||||||||||||||||||
| 497 | 1 | my $VALID = { | |||||||||||||||||||
| 498 | NAME => 1, | ||||||||||||||||||||
| 499 | FIELDS => 1 | ||||||||||||||||||||
| 500 | }; | ||||||||||||||||||||
| 501 | |||||||||||||||||||||
| 502 | # Valid Field parameters | ||||||||||||||||||||
| 503 | 1 | my $FIELDVALID = { | |||||||||||||||||||
| 504 | NAME => 1, | ||||||||||||||||||||
| 505 | TYPE => 1, | ||||||||||||||||||||
| 506 | POSITION => 1, | ||||||||||||||||||||
| 507 | VALUE => 1 | ||||||||||||||||||||
| 508 | }; | ||||||||||||||||||||
| 509 | |||||||||||||||||||||
| 510 | |||||||||||||||||||||
| 511 | # Valid data types | ||||||||||||||||||||
| 512 | 1 | my $VALTYPE = { | |||||||||||||||||||
| 513 | chars => 1, | ||||||||||||||||||||
| 514 | num => 1, | ||||||||||||||||||||
| 515 | int => 1, | ||||||||||||||||||||
| 516 | date => 1, | ||||||||||||||||||||
| 517 | time => 1, | ||||||||||||||||||||
| 518 | decimal => 1, | ||||||||||||||||||||
| 519 | float => 1 | ||||||||||||||||||||
| 520 | }; | ||||||||||||||||||||
| 521 | |||||||||||||||||||||
| 522 | # empty destroy method to stop capture by autoload | ||||||||||||||||||||
| 523 | 0 | ▶ | sub DESTROY { | ||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 524 | } | ||||||||||||||||||||
| 525 | |||||||||||||||||||||
| 526 | 0 | ▶ | sub AUTOLOAD { | ||||||||||||||||||
|
Subroutine
AUTOLOAD: not called CC=3 SCAR=24.8
| |||||||||||||||||||||
| 527 | |||||||||||||||||||||
| 528 | 0 | my $self = shift; | |||||||||||||||||||
| 529 | 0 | my @parms = @_; | |||||||||||||||||||
| 530 | 0 | ▶ | my $type = ref($self) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 531 | or die "$self is not an Object in autoload of Structure"; | ||||||||||||||||||||
| 532 | 0 | my $name = $AUTOLOAD; | |||||||||||||||||||
| 533 | 0 | $name =~ s/.*://; | |||||||||||||||||||
| 534 | 0 | ▶ | unless ( exists $self->{FIELDS}->{uc($name)} ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 535 | 0 | die "Field $name does not exist in structure - no autoload"; | |||||||||||||||||||
| 536 | }; | ||||||||||||||||||||
| 537 | 0 | &Fieldvalue($self,$name,@parms); | |||||||||||||||||||
| 538 | } | ||||||||||||||||||||
| 539 | |||||||||||||||||||||
| 540 | # Construct a new SAP::export parameter object. | ||||||||||||||||||||
| 541 | 0 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: not called CC=4 SCAR=30.0
| |||||||||||||||||||||
| 542 | |||||||||||||||||||||
| 543 | 0 | my $proto = shift; | |||||||||||||||||||
| 544 | 0 | ▶ | my $class = ref($proto) || $proto; | ||||||||||||||||||
|
Condition0%0/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||
| 545 | 0 | my $self = { | |||||||||||||||||||
| 546 | FIELDS => {}, | ||||||||||||||||||||
| 547 | @_ | ||||||||||||||||||||
| 548 | }; | ||||||||||||||||||||
| 549 | |||||||||||||||||||||
| 550 | 0 | ▶ | die "Structure Name not supplied !" if ! exists $self->{NAME}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 551 | 0 | $self->{NAME} = uc($self->{NAME}); | |||||||||||||||||||
| 552 | |||||||||||||||||||||
| 553 | # Validate parameters | ||||||||||||||||||||
| 554 | 0 | ▶ | map { delete $self->{$_} if ! exists $VALID->{$_} } keys %{$self}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 555 | |||||||||||||||||||||
| 556 | # create the object and return it | ||||||||||||||||||||
| 557 | 0 | bless ($self, $class); | |||||||||||||||||||
| 558 | 0 | return $self; | |||||||||||||||||||
| 559 | |||||||||||||||||||||
| 560 | } | ||||||||||||||||||||
| 561 | |||||||||||||||||||||
| 562 | |||||||||||||||||||||
| 563 | # Set/get structure field | ||||||||||||||||||||
| 564 | 0 | ▶ | sub addField { | ||||||||||||||||||
|
Subroutine
addField: not called CC=6 SCAR=37.4
| |||||||||||||||||||||
| 565 | |||||||||||||||||||||
| 566 | 0 | my $self = shift; | |||||||||||||||||||
| 567 | |||||||||||||||||||||
| 568 | 0 | my %field = @_; | |||||||||||||||||||
| 569 | 0 | ▶ | map { delete $field{$_} if ! exists $FIELDVALID->{$_} } keys %field; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 570 | 0 | ▶ | die "Structure NAME not supplied!" if ! exists $field{NAME}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 571 | 0 | $field{NAME} = uc($field{NAME}); | |||||||||||||||||||
| 572 | 0 | $field{NAME} =~ s/ //g; | |||||||||||||||||||
| 573 | die "Structure NAME allready exists - $field{NAME}!" | ||||||||||||||||||||
| 574 | 0 | ▶ | if exists $self->{FIELDS}->{$field{NAME}}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 575 | 0 | $field{TYPE} =~ s/ //g; | |||||||||||||||||||
| 576 | |||||||||||||||||||||
| 577 | 0 | ▶ | die "Structure TYPE not supplied!" if ! exists $field{TYPE}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 578 | die "Structure Type not valid $field{TYPE} !" | ||||||||||||||||||||
| 579 | 0 | ▶ | if ! exists $VALTYPE->{$field{TYPE}}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 580 | 0 | $field{POSITION} = ( scalar keys %{$self->{FIELDS}} ) + 1; | |||||||||||||||||||
| 581 | |||||||||||||||||||||
| 582 | return $self->{FIELDS}->{$field{NAME}} = | ||||||||||||||||||||
| 583 | 0 | { map { $_ => $field{$_} } keys %field }; | |||||||||||||||||||
| 584 | |||||||||||||||||||||
| 585 | } | ||||||||||||||||||||
| 586 | |||||||||||||||||||||
| 587 | |||||||||||||||||||||
| 588 | # Delete a field from the structure | ||||||||||||||||||||
| 589 | 0 | ▶ | sub deleteField { | ||||||||||||||||||
|
Subroutine
deleteField: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 590 | |||||||||||||||||||||
| 591 | 0 | my $self = shift; | |||||||||||||||||||
| 592 | 0 | my $field = shift; | |||||||||||||||||||
| 593 | die "Structure field does not exist: $field " | ||||||||||||||||||||
| 594 | 0 | ▶ | if ! exists $self->{FIELDS}->{uc($field)}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 595 | 0 | delete $self->{FIELDS}->{uc($field)}; | |||||||||||||||||||
| 596 | 0 | return $field; | |||||||||||||||||||
| 597 | |||||||||||||||||||||
| 598 | } | ||||||||||||||||||||
| 599 | |||||||||||||||||||||
| 600 | |||||||||||||||||||||
| 601 | # Set/get the field value and update the overall structure value | ||||||||||||||||||||
| 602 | 0 | ▶ | sub Fieldvalue { | ||||||||||||||||||
|
Subroutine
Fieldvalue: not called CC=4 SCAR=30.0
| |||||||||||||||||||||
| 603 | |||||||||||||||||||||
| 604 | 0 | my $self = shift; | |||||||||||||||||||
| 605 | 0 | my $field = shift; | |||||||||||||||||||
| 606 | 0 | ▶ | $field = ($self->Fields)[$field] if $field =~ /^\d+$/; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 607 | die "Structure field does not exist: $field " | ||||||||||||||||||||
| 608 | 0 | ▶ | if ! exists $self->{FIELDS}->{uc($field)}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 609 | 0 | $field = $self->{FIELDS}->{uc($field)}; | |||||||||||||||||||
| 610 | 0 | ▶ | if (scalar @_ > 0){ | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 611 | 0 | $field->{VALUE} = shift @_; | |||||||||||||||||||
| 612 | } | ||||||||||||||||||||
| 613 | |||||||||||||||||||||
| 614 | 0 | return $field->{VALUE}; | |||||||||||||||||||
| 615 | |||||||||||||||||||||
| 616 | } | ||||||||||||||||||||
| 617 | |||||||||||||||||||||
| 618 | |||||||||||||||||||||
| 619 | # get the field name by position | ||||||||||||||||||||
| 620 | 0 | ▶ | sub Fieldname { | ||||||||||||||||||
|
Subroutine
Fieldname: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 621 | |||||||||||||||||||||
| 622 | 0 | my $self = shift; | |||||||||||||||||||
| 623 | 0 | my $field = shift; | |||||||||||||||||||
| 624 | # print "Number: $field \n"; | ||||||||||||||||||||
| 625 | 0 | ▶ | die "Structure field does not exist by array position: $field " | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 626 | if ! ($self->Fields)[$field - 1]; | ||||||||||||||||||||
| 627 | 0 | return ($self->Fields)[$field - 1 ]; | |||||||||||||||||||
| 628 | |||||||||||||||||||||
| 629 | } | ||||||||||||||||||||
| 630 | |||||||||||||||||||||
| 631 | |||||||||||||||||||||
| 632 | # get the name | ||||||||||||||||||||
| 633 | 0 | ▶ | sub Name { | ||||||||||||||||||
|
Subroutine
Name: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 634 | |||||||||||||||||||||
| 635 | 0 | my $self = shift; | |||||||||||||||||||
| 636 | 0 | return $self->{NAME}; | |||||||||||||||||||
| 637 | |||||||||||||||||||||
| 638 | } | ||||||||||||||||||||
| 639 | |||||||||||||||||||||
| 640 | |||||||||||||||||||||
| 641 | # return the current set of field names | ||||||||||||||||||||
| 642 | 0 | ▶ | sub Fields { | ||||||||||||||||||
|
Subroutine
Fields: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 643 | |||||||||||||||||||||
| 644 | 0 | my $self = shift; | |||||||||||||||||||
| 645 | return sort { $self->{FIELDS}->{$a}->{POSITION} <=> | ||||||||||||||||||||
| 646 | 0 | $self->{FIELDS}->{$b}->{POSITION} } | |||||||||||||||||||
| 647 | 0 | keys %{$self->{FIELDS}}; | |||||||||||||||||||
| 648 | |||||||||||||||||||||
| 649 | } | ||||||||||||||||||||
| 650 | |||||||||||||||||||||
| 651 | |||||||||||||||||||||
| 652 | |||||||||||||||||||||
| 653 | |||||||||||||||||||||
| 654 | # Below is the stub of documentation for your module. You better edit it! | ||||||||||||||||||||
| 655 | |||||||||||||||||||||
| 656 | =head1 NAME | ||||||||||||||||||||
| 657 | |||||||||||||||||||||
| 658 | SAP::BC::Struc - Perl extension for parsing and creating a Structure definition. The resulting structure object is then used for SAP::BC::Parms, and SAP::BC::Tab objects to manipulate complex data elements. | ||||||||||||||||||||
| 659 | |||||||||||||||||||||
| 660 | =head1 SYNOPSIS | ||||||||||||||||||||
| 661 | |||||||||||||||||||||
| 662 | use SAP::BC::Struc; | ||||||||||||||||||||
| 663 | $struct = new SAP::BC::Struc( NAME => XYZ, FIELDS => [......] ); | ||||||||||||||||||||
| 664 | |||||||||||||||||||||
| 665 | =head1 DESCRIPTION | ||||||||||||||||||||
| 666 | |||||||||||||||||||||
| 667 | 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::BC::Iface.pm ). | ||||||||||||||||||||
| 668 | The constructor requires the parameter value pairs to be passed as | ||||||||||||||||||||
| 669 | 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(). | ||||||||||||||||||||
| 670 | |||||||||||||||||||||
| 671 | Methods: | ||||||||||||||||||||
| 672 | new | ||||||||||||||||||||
| 673 | use SAP::BC::Struc; | ||||||||||||||||||||
| 674 | $str = new SAP::BC::Struc( NAME => XYZ ); | ||||||||||||||||||||
| 675 | |||||||||||||||||||||
| 676 | |||||||||||||||||||||
| 677 | addField | ||||||||||||||||||||
| 678 | use SAP::BC::Struc; | ||||||||||||||||||||
| 679 | $str = new SAP::BC::Struc( NAME => XYZ ); | ||||||||||||||||||||
| 680 | $str->addField( NAME => field1, | ||||||||||||||||||||
| 681 | TYPE => chars ); | ||||||||||||||||||||
| 682 | 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. | ||||||||||||||||||||
| 683 | |||||||||||||||||||||
| 684 | |||||||||||||||||||||
| 685 | deleteField | ||||||||||||||||||||
| 686 | use SAP::BC::Struc; | ||||||||||||||||||||
| 687 | $str = new SAP::BC::Struc( NAME => XYZ ); | ||||||||||||||||||||
| 688 | $str->addField( NAME => field1, | ||||||||||||||||||||
| 689 | TYPE => chars ); | ||||||||||||||||||||
| 690 | $str->deleteField('field1'); | ||||||||||||||||||||
| 691 | Allow fields to be deleted from a structure. | ||||||||||||||||||||
| 692 | |||||||||||||||||||||
| 693 | |||||||||||||||||||||
| 694 | Name | ||||||||||||||||||||
| 695 | $name = $str->Name(); | ||||||||||||||||||||
| 696 | Get the name of the structure. | ||||||||||||||||||||
| 697 | |||||||||||||||||||||
| 698 | |||||||||||||||||||||
| 699 | Fieldtype | ||||||||||||||||||||
| 700 | $ftype = $str->Fieldtype(field1, [ new field type ]); | ||||||||||||||||||||
| 701 | 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. | ||||||||||||||||||||
| 702 | |||||||||||||||||||||
| 703 | |||||||||||||||||||||
| 704 | Fieldvalue | ||||||||||||||||||||
| 705 | $fvalue = $str->Fieldvalue(field1, | ||||||||||||||||||||
| 706 | [new component value]); | ||||||||||||||||||||
| 707 | Set/Get the value of a component field of the structure. This will force the overall value of the structure to be recalculated. | ||||||||||||||||||||
| 708 | |||||||||||||||||||||
| 709 | |||||||||||||||||||||
| 710 | Field | ||||||||||||||||||||
| 711 | $fhashref = $str->Field(field1); | ||||||||||||||||||||
| 712 | Set/Get the value of a component field of the structure. This will force the overall value of the structure to be recalculated. | ||||||||||||||||||||
| 713 | |||||||||||||||||||||
| 714 | |||||||||||||||||||||
| 715 | Fields | ||||||||||||||||||||
| 716 | @f = &$struct->Fields(); | ||||||||||||||||||||
| 717 | Return an array of the fields of a structure sorted in positional order. | ||||||||||||||||||||
| 718 | |||||||||||||||||||||
| 719 | |||||||||||||||||||||
| 720 | =head1 Exported constants | ||||||||||||||||||||
| 721 | |||||||||||||||||||||
| 722 | NONE | ||||||||||||||||||||
| 723 | |||||||||||||||||||||
| 724 | |||||||||||||||||||||
| 725 | =head1 AUTHOR | ||||||||||||||||||||
| 726 | |||||||||||||||||||||
| 727 | Piers Harding, saprfc@kogut.demon.co.uk. | ||||||||||||||||||||
| 728 | |||||||||||||||||||||
| 729 | But Credit must go to all those that have helped. | ||||||||||||||||||||
| 730 | |||||||||||||||||||||
| 731 | =head1 SEE ALSO | ||||||||||||||||||||
| 732 | |||||||||||||||||||||
| 733 | perl(1), SAP::BC(3), SAP::BC::XMLRFC(3), SAP::BC::Iface(3) | ||||||||||||||||||||
| 734 | |||||||||||||||||||||
| 735 | =cut | ||||||||||||||||||||
| 736 | |||||||||||||||||||||
| 737 | |||||||||||||||||||||
| 738 | 1 | 1; | |||||||||||||||||||
| 739 | |||||||||||||||||||||
| 740 | __END__ | ||||||||||||||||||||