Skip to Content


Introduction


In this weblog , i have explained the creation of a PHP application, that can be used to delete the data of mobile device(s) attached to the MI Server.This application is not recommended to use in production environments.



Prerequisites


1. System must be configured properly to support the PHPRFC(This provides an RFC interface to SAP function modules in PHP).

2. The MI server user , used to login , must have the appropriate authorizations to administrate the mobile devices and execute the RFC enabled function modules related with MI.

3. The custom made RFC enabled function module ZDELETE_ALL_DATA_OF_DEVICES and the associated structure (ZDEVICES , used as elementary data type for the table parameter DEVICEIDS ) should be created in the MI Server before testing with this application.You can either use this function module or use MEMGMT_MASS_DEVICE_DATA_DELETE , function module provided by SAP.



Versions Used


I used the Apache Server 2.0.58 , PHP 5.1.4 and the SAPRFC 1.4.1-5.1.1 as subject installations.



Source Code


For this application , i have created a RFC enabled function module which can be used to delete the entire data of device(s) at a time.This function module has one table parameter, which is used to fill up the device ids of selected mobiled devices to be deleted. Within this function module , i have called the standard function module DELETE_ALL_DATA_OF_DEVICE ,to delete the data of a particular mobile device using the device id by looping through the list of devices selected.Function module details is mentioned below.


Structure Details
___________________
Name                 –       ZDEVICES


Fields                 –      This structure has only one field.


 
Field Name            –         DEVICES  — which is of elementary data type –  MEDEVGUID( CHAR   36 Mobile Engine: Unique ID of Device)


Function module details
____________________
*Create a RFC enabled function module which has only one table parameter with name DEVICEIDS
*which is of elementary data type of structure  ZDEVICES.


Table Parameter


Name                –      DEVICEIDS
Elementary data type      –      ZDEVICES (above mentioned structure).


Function module code to be pasted within the created RFC
________________________________________________
FUNCTION ZDELETE_ALL_DATA_OF_DEVICES.
*”—-


“Local interface:
*”  TABLES
*”      DEVICEIDS STRUCTURE  ZDEVICES
*”—-



*Variable declarations
data wa_device type MEDEVGUID.


*loop through the device ids
loop at deviceids into wa_device.


call function
      ‘DELETE_ALL_DATA_OF_DEVICE’
      exporting DEVICEID = wa_device.


endloop.


ENDFUNCTION.

The login.php file is to provide a user interface to enter the user and MI server credentials to login into the MI Server.


MI Server Login Details


Server Name
System Number
Client
User
Password

The login page will look like this when you access the page through browser.In this screen you have to enter the MI Server login parameters.


image

The mobileDevices.php contains the script to list the mobile devices attached to the MI Server.

$serverName = $_POST[‘serverName’];
$sysNumber = $_POST[‘sysNumber’];
$sapClient = $_POST[‘sapClient’];
$sapUser = $_POST[‘sapUser’];
$userPassword = $_POST[‘userPassword’];

require_once(“saprfc.php”);

$sap = new saprfc(array(
“logindata”=>array(
“ASHOST”=> $serverName // application server
,”SYSNR”=> $sysNumber // system number
,”CLIENT”=> $sapClient // client
,”USER”=> $sapUser // user
,”PASSWD”=> $userPassword // password
)
,”show_errors”=>false // let class printout errors
,”debug”=>false)) ; // detailed debugging information

// Call-Function – For getting the list of installed mobile devices

$result=$sap->callFunction(“MEMGMT_DEVICE_GETLIST”,
array(
array(“TABLE”,”DEVICE_LIST”,array())));


// Call successfull?
if ($sap->getStatus() == SAPRFC_OK) {
// Yes, print out the LIst of devices
?>


List of All Mobile Devices


tr.miBody


td


td.1stCellHeader
{
   border-bottom: black 1px solid;
   border-left: black 1px solid;
   border-right: black 1px solid;
   border-top: black 1px solid;
}


td.nextCellHeader
{
   border-bottom: black 1px solid;
   border-left: black 0px solid;
   border-right: black 1px solid;
   border-top: black 1px solid;
}



td.1stCellBody
{
border-bottom: black 1px solid;
border-left: black 1px solid;
border-right: black 1px solid;
border-top: black 0px solid;
}


td.nextCellBody
{
border-bottom: black 1px solid;
border-left: black 0px solid;
border-right: black 1px solid;
border-top: black 0px solid;
}

input.test
{
background-color: #ededed;
font-family: “Arial, sans-serif”;
font-size: 8pt;
font-style: normal;
font-weight: normal;
border : 1px solid black ;
padding : 0;
margin : 0;
}

function checkAll(obj){
for (i = 0; i < document.MIDetailJSP.elements.length; i++) {
if (document.MIDetailJSP.elements[i].type == “checkbox” && document.MIDetailJSP.elements[i].id!=”chkAll”) {
document.MIDetailJSP.elements[i].checked = obj.checked
}
}
}

function checkSelectedDevices()
{
var count = 0;

for (i = 0; i < document.MIDetailJSP.elements.length; i++) {
if (document.MIDetailJSP.elements[i].type == “checkbox” && document.MIDetailJSP.elements[i].id!=”chkAll”)
{

if(document.MIDetailJSP.elements[i].checked)
{
count++;
}
}
}

if(count==0)
{
alert(‘Please select atleast one Device’);
return false;
}

return true;
}

This page displays the list of mobile devices attached to the MI server . From this screen , the user can select the list of devices which are to be deleted.After selecting the devices , the user has to click on the Delete Devices button to trigger the deletion of selected mobile devices from the MI Server.


image

I have a written a java script validation to check whether the user has selected at least one mobile device to delete it from the MI Server.


image


image
</p>


Useful links




Author’s Note


Since the time required to delete a device depends upon the amount of data associated
with the particular mobile device , there is a chance to occure time out exception while executing the PHP application.So we must have to set the time out parameter of the apache server accordingly.
But changing the time out parameter to higher values might decrease the apache server performance.


To report this post you need to login first.

4 Comments

You must be Logged on to comment or reply to a post.

      1. Kishor Gopinathan Post author
        Hi Alvaro,

        Thank you very much.This is only because of that inspiration got from you guys from Scripting Languages forum……

        Thanks & Regards,
        Kishor Gopinathan

        (0) 
    1. Kishor Gopinathan Post author
      Hi Anton,

      Just try the same using the standard RFC enabled
      function module provided by SAP.
      ‘MEMGMT_MASS_DEVICE_DATA_DELETE’.. In this case you have to adjust the table parameter appropriately. thanks for your suggestions…

      Thanks & Regards,
      Kishor Gopinathan

      (0) 

Leave a Reply