SAPRFC callFunction - php

I'm new to SAP - PHP programming and I use SAPRFC for calling my SAP FM.
I use saprfc_import - saprfc_table_init - saprfc_table_read function before, but because my work, I need to pass a lot of import parameter value and because if I use this, I need to open - close SAP connection and my webpage become so slow.
Recently I read about SAPRFC class and it have callFunction function that use array as import parameter and I think it can help me, but when I debug my SAPRFC class, my import parameter always empty or it will be error like this:
Import-Parameter : 'parameter-name' could not be set. (Does it exist?)
I use this way to call my function
$arrayParam = array_push(["param_name"=>"param_value"]);
$result = $sap->callFunction("FM_NAME",
array(
array("IMPORT","param_name",$arrayParam),
array("EXPORT","output_column",array())
)
);
Is my way to call it right or not?

after searching via google for a while,
i've found way to solve my problem here
saprfc class on that github is more perfect than on saprfc official because it already modified and now i can pass an 2 dimension array as table for my parameter

Related

Joomla:Why use JView/assignRef() instead of just assigning the value

I came across this question: Whats is assignRef() function in joomla 2.5 when I tried to search for definition of this assignRef() function.
Upon reading the answers, I still have a question:
It seems to me this function is used to create a key for the object and assign a value to it, like
$this->assignRef('messages', $messages)
If that is right, then why don't just do $this->messages = $messages?
I think these anwsers anwser your question.
Whats is assignRef() function in joomla 2.5
Joomla 3 - What to use instead of assignRef?
According to above answers it is a php related thing.
Older version of Joomla(1.5) used a PHP version which is < PHP 5.2
Newer version of Joomla(2.5) used a PHP version which is > PHP 5.2
In older version of php when you assign a variable like this
$this->messages= $messagesOrig;
php creates a copy of object $messagesOrig variable is referring and assign it to $this->messages.
Meaning any changes you are doing using $this->messages will not affect original object (the one $messagesOrig was referring).
So you have to use assignRef() and you will be using/Editing the original object as $messagesOrig refering
$this->assignRef('messages', $messagesOrig)
In the newer version of php by default php assign a reference to orginal object.So you dont need to use assignRef()
References:
Joomla 3 - What to use instead of assignRef?
https://docs.joomla.org/API17:JView::assignRef
PHP References Explained
JView[Legacy]::assign() and JView[Legacy]::assignRef() have been deprecated in Joomla!3 in favor for native PHP syntax.

Different Methods in PHP Classes depending on server?

I wrote a little PHP Blogscript with classes but ended in a problem. i have 2 webspaces and on 1 it works, on the other it doesn't.
i have defined a class called $system and within this class there is a function called the_querystring. it just returns an array with all the exploded querystring entries.
<?php $system->the_querystring()['variable']; ?>
my problem is - on 1 server it works fine, on my other server i have to write
<?php $system->the_querystring(['variable']); ?>
Any idea why?
According to php.net the notation
$secondElement = getArray()[1];
is allowed from PHP 5.4
Maybe your webserver has a PHP version older, something like
$querystring = $system->the_querystring();
$querystring['variable'];
should work on both.

PHP-FFMpeg prerequisites

I'm attempting to implement https://github.com/PHP-FFMpeg/PHP-FFMpeg
I copied the src/FFMpeg folder to my includes folder and made sure my autoloader knows where to find everything.
as a test I made a script that simply does:
$ffmpeg = FFMpeg\FFMpeg::create();
$video = $ffmpeg->open('video.mpg');
I get:
Fatal error: Class 'Doctrine\Common\Cache\ArrayCache' not found in /var/www/php/include/FFMpeg/FFProbe.php on line 203
My question is: does PHP-FFMPeg require Doctrine, because that is not stated in the documentation. What version do I need? Are there other prerequisites?
I could create a new question for this, but I'm not sure if I should. I now have PHP-ffmpeg implemented. I'm using Laravel, however that should be irrelevant for this question. I'm trying to enable progress monitoring. It works, however I need to pass in an ID so I can update the correct key in memcache.
$id = 12345;
$format->on('progress', function ($audio, $format, $percentage) {
//this works perfect, but doesn't tell me which item is being updated
Cache::put("progress", $percentage, .25);
//this does not work as I am unable to pass in $id, if I add it as the 4th argument above it will display the number of threads or something
//Cache::put("{$id}_progress", $percentage, .25);
});
I need clarification on the "on" method. I looked through https://ffmpeg-php.readthedocs.org/en/latest/_static/API/ and was not able to figure out how this method works. Any help would be appreciated.
You should follow the recommended instructions in the README.
Composer is the easiest way to install PHP-FFMpeg dependencies
The "on" method called on the format is an implementation of EventEmitter.
As you can see here : https://ffmpeg-php.readthedocs.org/en/latest/_static/API/FFMpeg/Format/ProgressableInterface.html it extends the EventEmitterInterface of https://github.com/igorw/evenement.
If you're really interested about how it works under the hood, have a look at here :
The progress listener is created here : https://github.com/PHP-FFMpeg/PHP-FFMpeg/blob/master/src/FFMpeg/Format/Audio/DefaultAudio.php#L96 and added at execution here https://github.com/PHP-FFMpeg/PHP-FFMpeg/blob/master/src/FFMpeg/Media/Video.php#L151
This is actually possible because FFMpegDriver extends the Driver provided by https://github.com/alchemy-fr/BinaryDriver
Hope this helps :)

Calling web service (SOAP) with PHP involving enums

I wish to call a web service, using SOAP, from PHP (using the included SOAP extension). The web service in question is http://www.webservicex.net/CurrencyConvertor.asmx
Now the Currency type is an enum, and I cannot figure out how to work with these in PHP in order to be able to call the 'ConversionRate' function. I know I have to do something with a class map, but I can only find limited and unhelpful information on this topic. Can anyone help? A working example maybe?
Thanks!!!!
The enum here only defines legitimate values, that is your data type is actually a string of one of those values.
Here's some psuedo-code to get you on your way:
$from_currency = "AFA";
$to_current = "ALL";
$soap_handler->ConversionRate($from_currency, $to_currency);
$exchange_rate = $soap_handler->response();

Generating WSDL when using PHP's native SOAP class?

I'm using the native SOAP class in PHP 5, having changed from NuSOAP as the native class is faster (and NuSOAP development seems to have ceased). However the PHP 5 SOAP lacks the ability to generate WSDL.
Has anyone experience of generating WSDL in PHP? If so, please recommend your preferred method.
Thanks.
Stuart,
If you or anyone else is looking for a solution to this problem here's what I did.
First get this script: http://www.phpclasses.org/browse/download/zip/package/3509/name/php2wsdl-2009-05-15.zip
Then look at its example files. After that I just sliced it the way I needed because I'm using codeigniter:
function wsdl(){
error_reporting(0);
require_once(APPPATH."/libraries/WSDLCreator.php"); //Path to the library
$test = new WSDLCreator("Webservice", $this->site."/wsdl");
//$test->includeMethodsDocumentation(false);
$test->addFile(APPPATH."/controllers/gds.php");
$test->addURLToClass("GDS", $this->site);
$test->ignoreMethod(array("GDS"=>"GDS"));
$test->ignoreMethod(array("GDS"=>"accessCheck"));
$test->createWSDL();
$test->printWSDL(true); // print with headers
}
That it, your all done.
Btw, I'm using SoapServer and SoapClient in php5+
You can try these options:
- https://code.google.com/p/php-wsdl-creator/ (GPLv3)
- https://github.com/piotrooo/wsdl-creator/ (GPLv3)
- http://www.phpclasses.org/package/3509-PHP-Generate-WSDL-from-PHP-classes-code.html (BSD like)
The first one might be your best option if the licence fits your project.
Generating a WSDL on the fly is not something that happens very often - it would tend to raise a few questions about the stability of your service!
Zend Studio can generate a WSDL from a PHP class, and there are a few other similar tools.
If you do need to generate the WSDL dynamically, take a look at Zend Framework library: Zend_Soap_AutoDiscover
Zend_Soap_AutoDiscover is a good alternative to NuSOAP. But, you can also create the WSDL file from scratch which can be very complicated and error prone. To ease this process, you can use an IDE to generate the WSDL file for your PHP functions and pass it as a parameter to your PHP SoapServer class. Check out the complete tutorial on How to generate wsdl for php native soap class

Categories