on 05-11-2016 2:25 PM
Hi Experts , I am trying to execute BAPI , I have set up external break point and see that the BAPI does not trigger .code is below.
var rfc = session.createRFC("ZBAPI_CATIMESHEETMGR_INSERT");
var profile = "0005" ;
var date = "10.05.2016" ;
var pernum = "00182586" ;
var workorder = "1500000293" ;
var operation = "0010";
var hours = "4.00" ;
rfc.setParameter("PROFILE",profile);
rfc.setParameter("DATE", date);
rfc.setParameter("PERNUM",pernum);
rfc.setParameter("WORKORDER",workorder);
rfc.setParameter("OPERATION",operation);
rfc.setParameter("HOURS",hours);
rfc.requestResults(JSON.stringify(["CATSRECORDS_OUT"]));
rfc.send(); I have added the function module in whitelist and it is remote enabled. Kindly suggest. Best regards, pradeep.
Thank you Clemens , we will wait for SP3 in this case . Best regards, pradeep.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
When you say the BAPI does not trigger, what do you mean? What exactly happens? What are you expecting to happen? What have you done already to try and trace the problem?
Steve.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you Steve and Clemens . For date for example : todays date : 11.05.2016 SAP internally converts to 20160511 Should we explicitly do that in our case ? I added the getresult as per your earlier comment . rfc.requestResults(JSON.stringify(["EXTENSIONOUT"])); rfc.send(); var result = JSON.parse(rfc.getResult("EXTENSIONOUT")); I am getting following error . Error during script execution: TypeError: Unable to get property 'textContent' of undefined or null reference at GuiRFC.prototype.getResult 20160421000620:45:11470) at Anonymous function (eval code:1:636) Best regards, pradeep.
Hi,
this is a code sample with date and time input parameters:
var oRFC = session.createRFC("/PERSONAS/SCRIPT_RFC_TEST");
oRFC.setParameter("IV_DATE", "1234-12-30");
oRFC.setParameter("IV_TIME", "22:11:33");
oRFC.requestResults(["EV_DATE","EV_TIME"]);
oRFC.send();
var _EV_DATE = oRFC.getResultObject("EV_DATE");
var _EV_TIME = oRFC.getResultObject("EV_TIME");
BTW, Personas 3, SP03 (which will be released very, very soon) will include a scripting tool that will greatly simplify the creation of scripts that use RFCs.
Cheers,
Clemens
Hi Sushant , The note is already in there . I had no issues with other ZBAPI that I have used earlier . I am seeing issue with this ZBAPI. Earlier I had similar issue with leading zeros ,this time I concatenated like last time . I tired using 11.05.2016 and 20160511 for date but no luck . Here is the code . In my ZBAPI I have given EXTENSIONOUT as export parameter unlike being in tables in BAPI . Last time you have asked me to set the external break point in BAPI ,I checked same way this time . BAPI user get details is triggering but not this ZBAPI . where did I go wrong ? var rfc = session.createRFC("ZBAPI_CATIMESHEETMGR_INSERT"); var profile = "0005" ; var date = "11.05.2016" ; var pernum = "00182586" ; var workorder = "1500000293" ; var operation = "0010"; var hours = "4.00" ; var str1 = workorder ; var str2 = "00"; var workorder = str2.concat(str1); rfc.setParameter("PROFILE",profile); rfc.setParameter("DATE", date); rfc.setParameter("PERNUM",pernum); rfc.setParameter("WORKORDER",workorder); rfc.setParameter("OPERATION",operation); rfc.setParameter("HOURS",hours); rfc.requestResults(JSON.stringify(["EXTENSIONOUT"])); rfc.send(); var result = JSON.parse(rfc.getResult("EXTENSIONOUT")); Best regards, pradeep.
Hi Clemens , Thank you . We are at 3.0 SP2 . I have 2 questions 1) What to do with default values in BAPI .Currently there is a default value for one field in import parameter , should we code in our scripting? 2) should just pass 11.05.2016 for date field or 20160511 in our script . Best regards, pradeep.
Hello,
That's up to you if you want to set a default value in the FM definition or send the value through the script. Dates have to be sent in "YYYY-mm-dd" format as in my example script. This is independent of the user's date format setting and determined by how ABAP coverts date fields into JSON and vice versa.
Cheers,
Clemens
Hello Pradeep,
I only gave the script example to show you how dates have to be formatted. /PERSONAS/SCRIPT_RFC_TEST will be released with SP3.
Regarding SP3 release, very very soon.
Don't use /PERSONAS/RFC_EXECUTION, use your own custom RFC. If you're familiar with ABAP debugging, I suggest you set an external breakpoint in your RFC function module (in the WinGui). Then run the script. If you don't hit your breakpoint, then you know that something is wrong with your input parameter mapping. You might want to start with an example that you works like BAPI_USER_GET_DETAIL and set a breakpoint in there first to be sure that external debugging is working.
On a side note, I think there was an issue with the RFC functionality when it comes to simple parameters that are not string, such as date and time fields. That was fixed with SP3. Again, just be a little bit more patient.
Best Regards,
Clemens
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.