-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathclient.php
71 lines (61 loc) · 2.28 KB
/
client.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?
// ----------------------------------------------------------------------------
// SAPRFC - Client example
// Call function module RFC_READ_REPORT - Get ABAP report from SAP R/3
// http://saprfc.sourceforge.net
// ----------------------------------------------------------------------------
//----------------------------------------------------------------------
//RFC_READ_REPORT:
// IMPORTING
// VALUE(PROGRAM) LIKE SY-REPID
// EXPORTING
// VALUE(SYSTEM) LIKE SY-SYSID
// VALUE(TRDIR) LIKE TRDIR STRUCTURE TRDIR
// TABLES
// QTAB STRUCTURE D022S
//----------------------------------------------------------------------
$REPORT = "RSUSR000"; // Set name of the report
$LOGIN = array ( // Set login data to R/3
"ASHOST"=>"garfield", // application server host name
"SYSNR"=>"30", // system number
"CLIENT"=>"900", // client
"USER"=>"rfctest", // user
"PASSWD"=>"*****", // password
"CODEPAGE"=>"1404"); // codepage
// ----------------------------------------------------------------------------
$rfc = saprfc_open ($LOGIN);
if (! $rfc )
{
echo "RFC connection failed with error:".saprfc_error();
exit;
}
$fce = saprfc_function_discover($rfc, "RFC_READ_REPORT");
if (! $fce )
{
echo "Discovering interface of function module RFC_READ_REPORT failed";
exit;
}
saprfc_import ($fce,"PROGRAM",$REPORT);
saprfc_table_init ($fce,"QTAB");
$rc = saprfc_call_and_receive ($fce);
if ($rfc_rc != SAPRFC_OK)
{
if ($rfc == SAPRFC_EXCEPTION )
echo ("Exception raised: ".saprfc_exception($fce));
else
echo ("Call error: ".saprfc_error($fce));
exit;
}
$SYSTEM = saprfc_export ($fce,"SYSTEM");
$TRDIR = saprfc_export ($fce,"TRDIR");
$rows = saprfc_table_rows ($fce,"QTAB");
echo "<PRE>";
for ($i=1; $i<=$rows; $i++)
{
$QTAB = saprfc_table_read ($fce,"QTAB",$i);
echo ($QTAB[LINE]."\n");
}
echo "</PRE>";
saprfc_function_free($fce);
saprfc_close($rfc);
?>