cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI not triggering

pakula123
Participant
0 Kudos

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.

Accepted Solutions (0)

Answers (2)

Answers (2)

pakula123
Participant
0 Kudos

Thank you Clemens , we will wait for SP3 in this case  . Best regards, pradeep.

Former Member
0 Kudos

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.

pakula123
Participant
0 Kudos

Hi Steve, I have setup an external break point in ABAP side to see if it is coming to this point when I execute the script. Best regards, pradeep.

Former Member
0 Kudos

I think the backend BAPI doesn't get called until the first time you call getResult(). That seems to be what happens for me. So, try completing the code and get the BAPI results, and you might find all is fine.

Steve.

clemens_gantert
Active Participant
0 Kudos

Hello Pradeep,

Steve is right. The actual RFC call is delayed until getExceptionType(), getExceptionText(), or getResult() is called for the first time (or at the end of the script).

This was done for performance reasons.

Best Regards,

Clemens

pakula123
Participant
0 Kudos

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.

clemens_gantert
Active Participant
0 Kudos

Hello Pradeep,

if the EXTENSIONOUT parameter is a simple parameter, meaning just a field and not a structure or a table then you mustn't use JSON.parse() but just use directly what you get from getResult().

Thanks,

Clemens

pakula123
Participant
0 Kudos

Hi Clemens, Its a Structure . It was in tables in my ZBAPI . I tried to put it in export parameter and checked ,I am still getting same error. Also for date should we just use  20160511 or 11.05.2016 . Please comment. Best regards, pradeep.

0 Kudos

pradeep,

have you implemented http://service.sap.com/sap/support/notes/2247087

-sushant

clemens_gantert
Active Participant
0 Kudos

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

pakula123
Participant
0 Kudos

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.

pakula123
Participant
0 Kudos

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.

clemens_gantert
Active Participant
0 Kudos

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

pakula123
Participant
0 Kudos

Hi Clemens , I could not see /PERSONAS/SCRIPT_RFC_TEST but could see /PERSONAS/RFC_EXECUTION. I tried using same format in my code as mentioned but see the same error . Unable to get property 'textContent' of undefined or null reference at GuiRFC.prototype.getResult Best Regards, pradeep.

pakula123
Participant
0 Kudos

Hi Clemens, What are the new features in SP3 . Can we refer to any official document from SAP as a reference and also when is the release (date) going to happen. Best regards, pradeep.

clemens_gantert
Active Participant
0 Kudos

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