cancel
Showing results for 
Search instead for 
Did you mean: 

Calling RFC in Background Step

0 Kudos

Hi Experts.

I have requirement. I have a background step (activity) in which i am calling an RFC (BAPI_CREATE_USER1) to other system. But when executing the workflow, the step is in process and hangs (no result, always in process). But when i call the Function Module in same system, the step executes immediately.

     But my requirement is, that this Function Module has to be executed in other system, because it'll create a new user(using BAPI).

I am calling method of a Business Object, and in method calling the RFC BAPI_CREATE_USER1.

If i am not wrong, is it that we can't call a RFC to other system in background step ?

Please Help, really very urgent.

Accepted Solutions (0)

Answers (2)

Answers (2)

I042439
Employee
Employee
0 Kudos

Hi

In addition to what Lohith has mentioned above, do check:

1) ST22 for any dumps around that time (the time of start of the step in workflow log) for user WF-BTACH. If a step goes endlessly in the status "In Process", there can be a dump

Also check Step History tab of that step in Technical WF log and see if there are any messages in there.

2) Ensure WF-BATCH has SAP_ALL so that there is no Authorization issue in RFC calls

3) Ensure that you can make RFC class to the desired system - the connections are open and are not locked

4) Check with your Basis team if there is any specific settings to be done on the target system to enable calls from WF-BATCH coming in from source system (where the workflow is).

Regards,

Modak

Message was edited by: Modak Gupta............... also check SMQA for any RFC Errors

0 Kudos

Thank you Modak, As always you replied promptly.

Now, what is happening. When i try to execute the BAPI through a program remotely it gives me a dump, RFC_NO_AUTHORITY. So i checked the authorization in AUTHORITY_CHECK_RFC FM, and found that the user is not having authorization. But when i gave WF-BATCH as user, it has authorization.

Now the method (BO METHOD) which is calling the BAPI is background, so user will be WF-BATCH, so  no dump, i checked it up in Technical Log, it's still in process, over 17 hours already passed, entire workflow is having green led's, and the step is still in process.

That means the WF-BATCH can access the BAPI in remote system, but now how do i debug this method while it is executed. Tried making the step as dialogue and kept break point, but no results, the break point does not gets triggered.

I042439
Employee
Employee
0 Kudos

Hi Shashi

What time did you check for the DUMP in ST22? You said, "In Process" status has been there for 17 Hours...did you check the dump at that "Start" date and time of that step?

Check all dumps of WF-BATCH user in ST22.

What is the result of checks in SMQA? Also check SM58

Did you check with Basis that WF-BATCH is allowed to access the Target System?

To debug the background task, you will have to apply a dirty approach.

I hope the system is a development system and your user has the auth to change variable contents during debugging.

Put an endless loop in the BO Method:

DATA: LV_1 type I value 1, LV_2 type I value 2.

Do. if LV_1 = LV_2. EXIT. ENDIF. ENDDO.

Execute the workflow, the method will go in an endless loop (will show "In Process" in WF Log)

The go to SM50, select the running process, menu Item Administration -> program -> Debugging -> The debugger will open at this endless loop, change LV_1 to value 2 and continue your debugging. Ensure SY-UNAME shows WF-BATCH.

Regards,

Modak

0 Kudos

Hi Modak.

It really worked. But when come to the statement call function 'BAPI' destination 'DEST'.

the debugger automatically disappears. I don't understand what is happening, any Idea ?

I checked for the user name in debugging mode its sy-batch. Why is it not calling the FM remotely, why the Debugger disappears.

I042439
Employee
Employee
0 Kudos

Hi Shashi

It is because you may have pressed F5 and the debugger cannot open the debugging in remote system.

When in debugging, set a breakpoint after the FM Call. At the FM press F6 and then see what the BAPI returns.

Also, is the user WF-BATCH or SY-BATCH in SY-UNAME???

Regards,

Modak

0 Kudos

Same story, i placed several break point statements before calling the BAPI and after calling.

but the moment i press F6, the debugger simply disappears. I have no chance of looking into BAPI_RETURN.

Why is the debugger acting like that.

tell me, i am thinking that i shall call this bapi as background eg.

CALL FUNCTION 'BAPI' IN BACKGROUND TASK DESTINATION 'DEST'.

If i do it in this manner, What should happen. Also i am attaching the piece of code i've written.

BREAK-POINT.

  Do.

    if LV_1 = LV_2.

      EXIT.

    ENDIF.

  ENDDO.

CALL FUNCTION 'BBP_PASSWORD_GENERATOR'

*                 EXPORTING

*                   WORD_LENGTH       = 8

       IMPORTING

         password          = lv_pswd

                .

swc_set_element container 'ExPswd' lv_pswd.

lv_bapirefus = c_space.

lv_name = ls_usr_ldap_dt_im-user_t_num.

lv_pswd = lv_pswd.

DATA lv_bidder TYPE YFLAG.

CALL FUNCTION 'BAPI_USER_CREATE1' DESTINATION 'DEST'  " destination name changed here, name is correct

  EXPORTING

    username                = lv_name

    name_in                 = lv_name

    logondata               = lv_bapilogond

    password                = lv_pswd

    defaults                = lv_default

    address                 = lv_address

*   COMPANY                 =

    snc                     = lv_bapisncu

    ref_user                = lv_bapirefus

*   ALIAS                   =

*   EX_ADDRESS              =

*   UCLASS                  =

    force_system_assignment = c_x

*   SELF_REGISTER           = ' '

  TABLES

    parameter               = ls_bapiparam

    return                  = ls_bapiret2

    parameter1              = ls_bapiparam1

    extidhead               = ls_bapiusextidhead

    extidpart               = ls_bapiusextidpart.

BREAK-POINT.

IF sy-subrc is INITIAL.

    lv_bidder-flag = 'X'.

MODIFY YFLAG FROM lv_bidder .

*COMMIT WORK.

ENDIF.

BREAK-POINT.

LOOP AT ls_bapiret2 INTO lv_bapiret2.

*** Write suitable code here, method is background method

ENDLOOP.

I042439
Employee
Employee
0 Kudos

Hi Shashi

Any info in SMQA and SM58 in both systems (Source and Target)?

What happens if you place another endless loop AFTER the BAPI Call? Does it show in SM50? If not, the call may not be coming back to the Workflow process (probably that is why it shows "In process")!!

Regards,

Modak

0 Kudos

No, in sm58 i dont see any entries, its blank, and SMQA i have no authorizations to open it.

In sm50 though,  i can see the 1 entry with sy-batch and in process and other is the BO program, where i've kept a break point.

for the second part of your question, when i call the BAPI, from a program, it calls the BAPI, creates a new user and gets back the return structure, which i can see has status, but when I'am doing this in method of business object, it's not happening.

I also tried keeping a external break point in other system(target), but that doesn't gets triggered.

Do we have any mechanism where we can call a bapi if the system is on for taking calls, like we do in subroutines e.g. PERFORM per IN PROGRAM IF FOUND.

I042439
Employee
Employee
0 Kudos

Hi Shashikant

I really do not have an answer to your latest question.

Also, you keep referring sy-batch....what is that? the workflow user is WF-BATCH!

In SM50, did you try to debug that additional entry in SM50?

Regards,

Modak

Private_Member_46505
Active Participant
0 Kudos

Hi Shasikant,

Please test your method in SWO1 tcode.If it works fine then it has to work fine in background task and most of the actions which you want to take through RFC happen in background only.

If the background Work item is in process means it has gone to error.You may check the log in SWI1 T Code and check Step History.

And I guess you have tested this mentioned Bapi in the target system.