on 12-06-2005 10:58 AM
Hi
it is posible to display a report who use ALV Grid with SAPRFC/PHP on the browser?
Thanx for help.
Arne
You can also have a look at http://scbr.com/docs/products/dhtmlxGrid/
It's got some nice features (even the free version) and it has nice PHP integration examples too
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
don't reinvent the wheel ! such functions already exist in PHP world : take a look at
http://www.phpscripts-fr.net/articles/voir.php?id=203
this should make it easier
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi François,
great link. Here is my improved PHP SE16 Version from Alvaro Tejada https://weblogs.sdn.sap.com/pub/wlg/3170. The result looks like http://www.flickr.com/photos/lupomania/127633936/:
<?php
// Initialize the session.
// If you are using session_name("something"), don't forget it now!
session_start();
// Use PEAR Structures/DataGrid
require_once "Structures/DataGrid.php";
?>
<html>
<head>
<title>SE16 Simulation</title>
<style>
body {
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
font-size: 11px;
}
table.output {
border-left: solid 1px #990033;
border-top: solid 1px #990033;
border-bottom: solid 1px #990033;
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
font-size: 11px;
border-collapse: collapse;
width: 36em;
margin-left: 1em;
}
table.output th {
text-align: center;
border-right: solid 1px #990033;
border-bottom: solid 1px #990033;
background: #990033;
padding: 2px;
color: white;
padding-left: 1em;
padding-right: 1em;
}
table.output th a {
color: white;
text-decoration: none;
}
table.output th a:hover {
color: #EEEEEE;
}
table.output td {
text-align: right;
border-right: solid 1px #990033;
padding: 2px;
}
table.output tr.odd {
background: #F4F4F4;
}
p.paging {
text-align: center;
font-weight: bold;
}
p.paging a {
color: #990033;
}
</style>
</head>
<body>
<?php
//Convert to uppercase the name of the table to show
$Table = STRTOUPPER($_REQUEST['table']);
$debug = $_REQUEST['debug'];
// Page content, many ways to create page content in PHP
$page_body = 'Currently <b>'.$_SESSION["User"].'</b> '
. 'is logged in, if this is not you please <a href="index.php">Log Out</a>'
. '<form action="'.$PHP_SELF.'" method="POST">'
. '<input type="text" name="table" value="'.$Table.'"/><br/>'
. '<input type="checkbox" name="debug" value="X"';
if ($debug == "X") {
$page_body .= ' checked';
}
$page_body .= '/> Debug?<br>'
. '<input type="SUBMIT" value="Show Table" name="Show_Table"/>'
. '</form>';
if(isset($_POST['log_in'])) {
//We define login parameters as sessions, so we can use them everytime
$_SESSION["Server"] = $_POST["server"];
$_SESSION["Sysnum"] = $_POST["sysnum"];
$_SESSION["Client"] = $_POST["client"];
$_SESSION["User"] = $_POST["user"];
$_SESSION["Pass"] = $_POST["pass"];
}
if (isset($_SESSION['User'])){
echo $page_body;
if(isset($_REQUEST['Show_Table'])){
//Build the login array
$LOGIN = array ("ASHOST"=>$_SESSION['Server'],
"SYSNR"=>$_SESSION['Sysnum'],
"CLIENT"=>$_SESSION['Client'],
"USER"=>$_SESSION['User'],
"PASSWD"=>$_SESSION['Pass'],
"CODEPAGE"=>"1100");
//Try to connect to SAP using our Login array
$rfc = saprfc_open ($LOGIN);
if(!$rfc){
echo "The RFC connection has failed with the following error:".saprfc_error();
exit;
}
//We must know if the function really exists
$fce = saprfc_function_discover($rfc, "RFC_READ_TABLE");
if(!$fce){
echo "The function module has failed.";
echo $rfc;
exit;
}
//Pass import parameters
saprfc_import ($fce,"QUERY_TABLE",$Table);
saprfc_import ($fce,"DELIMITER","/");
//Pass table parameters
saprfc_table_init ($fce,"OPTIONS");
saprfc_table_init ($fce,"FIELDS");
saprfc_table_init ($fce,"DATA");
//Call and execute the function
$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;
}
// Instanciate DataGrid
$datagrid =& new Structures_DataGrid(20);
//Fetch the data from the internal tables
$data_row = saprfc_table_rows ($fce,"DATA");
$field_row = saprfc_table_rows ($fce,"FIELDS");
// Fill fields
for($i=1; $i<=$field_row ; $i++){
$FIELDS = saprfc_table_read ($fce,"FIELDS",$i);
$fields_array[] .= $FIELDS[FIELDNAME];
}
$datagridOptions["fields"] = $fields_array;
if ($debug == "X") {
echo '<pre><code>';
echo print_r($datagridOptions);
echo '</code></pre>';
}
// Fill array to pass to Structures_DataGrid
for ($i=1; $i<=$data_row; $i++){
$DATA = saprfc_table_read ($fce,"DATA",$i);
//We have use the / symbol as a delimiter, so we need to cut every field
//and put it on an array slot
$TEST = SPLIT("/",$DATA[WA]);
for($j=0; $j<=$field_row; $j++){
$key = $fields_array[$j];
$row_array[$key] = $TEST[$j];
}
$data_array[] = $row_array;
}
if ($debug == "X") {
echo '<pre><code>';
echo print_r($data_array);
echo '</code></pre>';
}
// Bind to DataGrid
$datagrid->bind($data_array);
$renderer =& $datagrid->getRenderer();
$renderer->setExtraVars(array('table' => $Table,'Show_Table' => 'true'));
$renderer->setTableAttribute("class", "output");
$renderer->setTableOddRowAttributes(array ("class" => "odd"));
$pagingHtml = $renderer->getPaging();
echo "<p>Pages : $pagingHtml</p>";
$datagrid->render();
//realease the function and close the connection
saprfc_function_free($fce);
saprfc_close($rfc);
}
} else {
// Unset all of the session variables.
$_SESSION = array();
// If it's desired to kill the session, also delete the session cookie.
// Note: This will destroy the session, and not just the session data!
if (isset($_COOKIE[session_name()])) {
setcookie(session_name(), '', time()-42000, '/');
}
// Finally, destroy the session.
session_destroy();
// return to login
echo 'Not logged in, please <a href="index.php">login</a>';
}
?>
</body>
</html>
Regards
Gregor
Edited by: Craig Cmehil on Mar 15, 2008 11:00 AM
hi gregor,
excellent job!
Tried it too, but since I din't have pear packages in place I had to install them first and I got to say that this is kind of a pain in the ... since the package installer doesn't automatically resolve (and install) dependencies.
Since I didn't want to simply install all PEAR packages but wanted to have control over the stuff installed I had to install them one after the other
But once in place DB_DATAOBJECT and STRUCTURES_DATAGRID are really nice to work with.
regards, anton
Great Gregor!!! -:D I love when someone tooks my code and make such great improvements -;) Thanx!
But...Believe or not...I can't test it -:S I must install PEAR...hehehe...I just read the code to know what is supposed to do -;)
As soon as I can really see your app working I'm going to post again -:)
Greetings,
Blag.
Hi Craig,
this are the PEAR Modules I've installed:
Installed packages:
===================
Package Version State
Archive_Tar 1.3.1 stable
Auth_SASL 1.0.1 stable
Console_Getopt 1.2 stable
Console_Table 1.0.4 stable
DB 1.7.6 stable
HTML_Common 1.2.2 stable
HTML_Table 1.6.1 stable
HTTP 1.4.0 stable
HTTP_Request 1.3.0 stable
Mail 1.1.9 stable
Mail_Mime 1.3.1 stable
Net_DIME 0.3 beta
Net_SMTP 1.2.8 stable
Net_Socket 1.0.6 stable
Net_URL 1.0.14 stable
PEAR 1.3.2 stable
Pager 2.3.6 stable
SOAP 0.9.3 beta
Structures_DataGrid 0.6.3 beta
XML_Parser 1.2.7 stable
XML_RPC 1.4.5 stable
XML_RSS 0.9.9 beta
XML_Serializer 0.18.0 beta
XML_Util 1.1.1 stable
I think the latest important thing was:
pear install HTML_Table HTML_Common
Regards
Gregor
Hi Everybody,
on Craig's Scripting in a Box I've used this commands to install the required PEAR packages
- chage to C:\Development\Apache\PHP
- run go-pear and do a local installation
- set "pear config-set preferred_state beta"
- run: pear install --alldeps Structures_DataGrid
- Exchange the script in C:\Development\htdocs\SE16_RFC\SAP_Connection.php with my version.
- Run start.bat in C:\Development to start Eclipse
- Start Apache via Run -> External Tools -> apache_start
- Open SE16_RFC -> index.php to login
- Try table SFLIGHT
A strange thing: On my Windows Box the Sorting does not work. On my Debian sytem it does. Some help?
Regards
Gregor
you don't have to install much PEAR packages, you just need to respect some dependancies.
For example, Structures_Datagrid is a package with name 'Datagrid' that will be present in directory 'Structures'
at address http://pear.php.net/packages.php you click on Structures then Structures_Datagrid (in fact there is some shortcut on the main page)
then you click on tabstrip 'Download' and you will get the last version with changelog and ... dependencies !
basic packages are installed at the same time as PHP in last releases of it so you will probably have to install only few of it
I recommend to just put files into directories without using package manager as it is not easy to use (even more for Windows users !)
Hi Gregor,
Sorry my poor English, i'm brazilian.
I need use the OPTIONS table, but I didn't know how to use.
When I execute my PHP code:
Warning: CALDBG: Can't find structure item TEXT for interface OPTIONS, __cal_set() in .....
saprfc_import ($fce,"QUERY_TABLE",$Table);
saprfc_import ($fce,"DELIMITER","/");
saprfc_import ($fce,"NO_DATA","");
saprfc_import ($fce,"ROWSKIPS","");
saprfc_import ($fce,"ROWCOUNT","30");
//Pass table parameters
saprfc_table_init ($fce,"DATA");
saprfc_table_init ($fce,"FIELDS");
saprfc_table_init ($fce,"OPTIONS");
saprfc_table_append ($fce,"OPTIONS", array ("TEXT"=>"PERIODO = '201204'"));
I tried this too
saprfc_table_append ($fce,"OPTIONS", array ("0"=>"PERIODO = '201204'"));
//Call and execute the function
$rfcresults = saprfc_call_and_receive ($fce);
In 'red case' the PHP don't show error, but not respect the where clause.
Can you help me?
Thank you very much,
My first thought is simply no, typically you would retreive the raw data from your system and display a reporting of that raw data in PHP. Basically you would use PHP like you do the ALV GRID in ABAP, you would need to build the display and functions in PHP to show the data.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The ALV is generated by some ABAP instructions and functions...So, using PHP you can not build one in your pages. But what you can do, is retrive the data from SAP, make some html tables and make a nice presentation.
Remember that besided all the fancy button...the ALV is nothing more than a table with rows and columns -;)
Greetings,
Blag.
That's right...And remember that using PHP Object Orientation, you can make some classes to add full functionality. You can use some images, javascript and make some sorting algorithms....That something i'm going to start working on....And PHP ALV Class....I hope i can make it -:P It's a hard work but it worst a try.
Anyway, when i finished i'm planning to make a blog about it...So stay tuned and wish me luck...I'm pretty sure i need it...hehehehe.
Greetings,
Blag.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.