Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

check if a queue is processed

former_member227595
Active Participant
0 Kudos

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

1 ACCEPTED SOLUTION

former_member227595
Active Participant
0 Kudos

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

16 REPLIES 16

nabheetscn
Active Contributor
0 Kudos

Hi Diego

You can set an infinite loop in FUNCTION_A.  then in SM50 you can go and debug.

Nabheet

Former Member
0 Kudos

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

0 Kudos

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

0 Kudos

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.

0 Kudos

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

0 Kudos


Hi Venkat

It wont work... the context are different. It is recommende to use receiving stuff

thanks

Nabheet

0 Kudos

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

0 Kudos

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

0 Kudos

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

0 Kudos


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.

former_member227595
Active Participant
0 Kudos

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

0 Kudos

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

0 Kudos

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

0 Kudos

What are you waiting for, for queue to be processed?

0 Kudos

Exactly, so I am using the wait up right now but I think I could be done in a better way.

Regards

0 Kudos

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