Skip to Content
author's profile photo Former Member
Former Member

Asynchronous function Call

I have a requirement to retrieve data based on a selection criteria, using a BSP application.

I am using MVC. This query is a long running job, say it takes something between 2-10 minutes.

For the smaller runs, I used the “PROTECTDOUBLESUBMIT” extension, but when the jobs run for longer time, there is a connection time out error occurring. I found OSS notes on how to adjust the ICM parameters to over come this. But I would like to run the program in background and give the user some kind of progress bar, so the page refreshes every 20 seconds and the ICM connection is re-established, and I don’t get the connection timed out.

I was not able to find a way to create ABAP subroutines in a method (perform form xxx), so I created a function module to run the query, and another function module to retrieve the query results.

  • The function module to run the query, will submit the original function in background “STARTING NEW TASK TASK_NAME PERFORMING FORM_RESULTS ON END OF TASK”.

  • The form “FORM_RESULTS” will set global return parameters in the function group.

  • The retriever will read the global parameters and send it back.

*************

FUNCTION MODULE GLOBAL DATA:

Data: return_table type some table;

Process_complete type char1.

*************

FUNCTION Z_VAL_SETTER

Importing parameters = param.

Data: task_name(50) value ‘task’.

CALL FUNCTION 'Z_ACT_FUNCTION'

STARTING NEW TASK task_name

PERFORMING form_results ON END OF TASK

EXPORTING

Parameters = param…

FORM form_results USING taskname.

Clear Process_complete.

RECEIVE RESULTS FROM FUNCTION 'Z_ACT_FUNCTION'

TABLES

ret_tab = return_table

EXCEPTIONS

communication_failure = 1 MESSAGE message

system_failure = 2 MESSAGE message.

process_complete = ‘X’

ENDFORM.

*************

FUNCTION Z_VAL_GETTER

Exporting proc_compl

Tables ret_table.

Ret_table = return_table.

proc_compl = process_complete.

It works perfectly when I run it using a report program, using SE38

REPORT ZTEST.

Call function ‘Z_VAL_SETTER’ …

Do 60 times

Call function ‘Z_VAL_GETTER’

Importing proc_compl = p_comp…

If p_comp = ‘X’.

Exit.

Else.

Wait up to 1 seconds.

Enddo.

But when I call these “SETTER” and “GETTER” functions from the Model class method, I am not able to get the values back. There are no errors or short dumps but I feel the roll area is initialized after the first call.

Has anyone come across this scenario before?

Any Idea how I can make this work?

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Feb 15, 2005 at 09:05 AM

    Hi "sapnovice" (Rakesh isn't it),

    The problem with processing in the background, is that SAP uses for each process a separate workspace (roll area), so your 2 function modules each run in threir separate space.

    To resolve this you need to make sure both function modules have access to the same data. There are several ways to do so, but here is a simple one.

    In your function module <b>Z_VAL_SETTER</b>, within form <b>FORM_RESULTS</b>:

    <pre>

    <p>

    ...

    FREE MEMORY ID 'MY_RETURN_DATA'.

    CLEAR: Process_complete.

    RECEIVE RESULTS FROM FUNCTION 'Z_ACT_FUNCTION'

    TABLES

    ...

    process_complete = ‘X’.

    EXPORT process_complete

    return_table TO MEMORY ID 'MY_RETURN_DATA'.

    ...

    </pre>

    <p>

    Waiting can be achieved like this:

    <pre>

    <p>

    ...

    CLEAR: process_complete.

    WHILE process_complete NE 'X'.

    IMPORT process_complete

    return_table FROM MEMORY ID 'MY_RETURN_DATA'.

    IF sy-subrc NE 0.

    CLEAR: process_complete,

    sy-subrc.

    ENDIF.

    ENDWHILE.

    ...

    </pre>

    <p>

    Furthermore, when running in a busy environment AND with putting processes in the background, sometimes the fail because of a very peculiar problem:

    When using the WAIT command, the actual proces does NOT exist on the stack and therefore during the WAIT an extra free process is reported. If such a process is occupied by another program, after the wait period your program will terminate.

    Hope this gives you some clues on how to approach your problem.

    Regards,

    Rob.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.