2013 Dec 05 8:00 AM
Hi, I am trying to check if a queue recently create was processed.
For this I have the below code:
* Create
CALL FUNCTION 'TRFC_SET_QUEUE_NAME'
EXPORTING
qname = 'queue_name'
EXCEPTIONS
invalid_queue_name = 1
OTHERS = 2.
* Execute
CALL FUNCTION 'FUNCTION_A'
IN BACKGROUND TASK
EXPORTING
***************************
***************************
IMPORTING
et_return = lt_return.
COMMIT WORK AND WAIT.
WAIT UP TO 2 SECONDS.
The thing is would have to check some things that my FUNCTION_A, already did, but I dont know if it was executed right or not.
I mean isted of using wait up sentence, I would like to check correctly the status of the queue.
Does anybody knows a probably solution.
Thanks in advance.
Regards
2013 Dec 10 10:14 AM
Hi Nabheet, the thing is that I have to execute the FM in background task, so I cannot use starting new task..
thanks in advance.
Regards
2013 Dec 05 8:04 AM
Hi Diego
You can set an infinite loop in FUNCTION_A. then in SM50 you can go and debug.
Nabheet
2013 Dec 05 8:07 AM
Hi Diego,
Please correct me if my understanding is not correct towards your issue,
you want to check whether th FUNCTION_A is executed successfully or not ?
if that is the issue, you will get error message in the lt_return table. At least you can check the Sy-subrc value after function call.
i mean sy-subrc = 0 then it is success and other than that its a fail.
Let me know if you find any further issues.
Thanks and Regards,
Bhaskar
2013 Dec 05 8:52 AM
Hi bhaskar, as I excute the FM FUNCTION_A (in background task) a new thread is created, so in the end, it doesn't return to me any value in It_return.
I mean will be always empty if I execute the FM in backgroud task.
Regards
2013 Dec 05 8:56 AM
Hi Diego
It will be alwways empty it is started via TRFC.
you can debug it via infinite loop or SM58 if you set in debugging block sending TRFC.
In case you want to receive the results back then you will have to use the following syntax.
Call function FM1 starting new task
PERFORMING get_return ON END OF TASK
Wait untile GV_FLAG is X.
Create subroutine
FORM get_return USING TASKNAME.
RECEIVE RESULTS FROM FUNCTION FM1
tables
return = lt_return
gv_flag = 'X'.
ENDFORM.
2013 Dec 05 9:03 AM
Hi-
What you can do is:
In your Background job you can export your return table parameters using ABAP memory concept i.e. 'EXPORT' statement. In your calling program check for your Background job status please search for FM's which will return whether your job has run successfully or not. If it's successful you can use IMPORT statement to read your it_return table parameters.
-Venkat
2013 Dec 05 9:06 AM
Hi Venkat
It wont work... the context are different. It is recommende to use receiving stuff
thanks
Nabheet
2013 Dec 05 9:39 AM
Hello Nabheet-
Thanks for your comment. May I know why does my approach don't work? Or if it's not a preferred way may I know the reason? I am not debating please, just to correct myself if I am wrong.
-Venkat
2013 Dec 05 9:52 AM
First of all it is running the fucntion module in background means a separate luw and the moment you press f6 it will run in paralllel it wont stop for it to get finished. export import memory work in single lu concept.
Secondly using this syntax their is no job which will get created it willbe trfc entry being created in sm58
i hope it clear now.
Nabheet
2013 Dec 05 4:15 PM
I dont see the Export and Import option a correct way. I am trying to find a solution via FM. I mean, isn't there any FM in which I check if the queue is already proccessed ?
Regards
2013 Dec 06 4:39 AM
Why dont you use the below mentioned syntax. This will return you back the results of the processing in table LT_RETURN
Call function FM1 starting new task
PERFORMING get_return ON END OF TASK
Wait untile GV_FLAG is X. " GV_FLAG is global
Create subroutine
FORM get_return USING TASKNAME.
RECEIVE RESULTS FROM FUNCTION FM1
tables
return = lt_return
gv_flag = 'X'.
ENDFORM.
2013 Dec 10 10:14 AM
Hi Nabheet, the thing is that I have to execute the FM in background task, so I cannot use starting new task..
thanks in advance.
Regards
2013 Dec 10 10:21 AM
Hi Diego
In case you use call function in background task please note that it will be called as TRFC call and executeed at the last when commit happens.
It will not return you any output. If you debug and check this background function module call it is also started in new task.
In case you raise any error in function module called in background then that gets stuck in SM58
What exactly you want to achieve..?
thanks
Nabheet
2013 Dec 10 2:15 PM
Hi Nabheet, I've to call the FM as a backgroud task so It's queue in SMQ1 (the idea is to control trafic from here).
I my main FM Ive this code below
first call
CALL FUNCTION 'TRFC_SET_QUEUE_NAME'
EXPORTING
qname = 'queue_name'
EXCEPTIONS
invalid_queue_name = 1
OTHERS = 2.
and then
CALL FUNCTION 'FUNCTION_A'
IN BACKGROUND TASK
EXPORTING
COMMIT WORK AND WAIT.
WAIT UP TO 2 SECONDS.
But I don't like the WAIT UP, I know it might exist a proper way to do this.
The issue to use the WAIT UP is that it may be executed wrong.
Do you have some advice ?
Regards
2013 Dec 10 2:22 PM
2013 Dec 10 3:29 PM
Exactly, so I am using the wait up right now but I think I could be done in a better way.
Regards
2013 Dec 11 3:24 PM
I've a temporally solution. It consists in execute the FM without the background task. I this way is working. I am receiving table return.
Regards