Application Development and Automation 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: 
Read only

Return Code value using 'starting new task' and 'wait until'

Former Member
0 Likes
2,984

I'm having a minor issue with some return code values in my ABAP.

This is what part of it used to look like before I modified it:

With Code in version 1, the sy-subrc was not always zero, sometimes it would be 4.

That was fine, and my abap would do something based on the non-zero RC.

had a need to implement an RFC timeout, the only way I could see to do it was to use 'starting new task' etc as seen in Version 2.

However, with my changes, sy-subrc is always zero.

The ABAP runs fine but I know that sy-subrc should sometimes be 4, even when it returns within the allotted 60 seconds.

Maybe I've coded it incorrectly.

Can someone point me in the right direction?


#>> Start of VERSION 1
  call function 'MY_FUNCTION_MODULE'
       destination RFCDEST
       tables
            orders_list          = t_orders_packet
            apo_orders_list      = t_apo_orders
            apo_resources        = t_apo_resources
       exceptions
            COMMUNICATION_FAILURE    = 1 MESSAGE MSG_TEXT
            SYSTEM_FAILURE           = 2 MESSAGE MSG_TEXT
            NO_ORDERS_SUPPLIED       = 3
            NO_PEGGED_ORDERS_FOUND   = 4
            ORDERID_CONVERSION_ERROR = 5
            OTHERS                   = 6.

if sy-subrc is initial.
  * do some stuff as RC was 0
else.
 * log non-zero return code etc
endif.
* << End of Version 1

4 REPLIES 4
Read only

Former Member
0 Likes
1,679

And now Version 2.

I didn't put this into the 1st post as the formatting goes bonkers.


#>> Start of VERSION 2
  call function 'MY_FUNCTION_MODULE'
       destination RFCDEST
       starting new task 'taskname'
       performing receive_result on end of task
       tables
            orders_list          = t_orders_packet
            apo_orders_list      = t_apo_orders
            apo_resources        = t_apo_resources
       exceptions
            COMMUNICATION_FAILURE    = 1 MESSAGE MSG_TEXT
            SYSTEM_FAILURE           = 2 MESSAGE MSG_TEXT
            NO_ORDERS_SUPPLIED       = 3
            NO_PEGGED_ORDERS_FOUND   = 4
            ORDERID_CONVERSION_ERROR = 5
            OTHERS                   = 6.

  WAIT UNTIL results_received = 'X' UP TO 60 SECONDS. 

if sy-subrc is initial.   << Now this is always ZERO
  * do some stuff as RC was 0
else.
 * log non-zero return code etc
endif.

...
...

FORM receive_result USING iv_taskname.
  RECEIVE RESULTS FROM FUNCTION 'MY_FUNCTION_MODULE'
       tables
            orders_list          = t_orders_packet
            apo_orders_list      = t_apo_orders
            apo_resources        = t_apo_resources
       exceptions
            COMMUNICATION_FAILURE    = 1 MESSAGE MSG_TEXT
            SYSTEM_FAILURE           = 2 MESSAGE MSG_TEXT
            NO_ORDERS_SUPPLIED       = 3
            NO_PEGGED_ORDERS_FOUND   = 4
            ORDERID_CONVERSION_ERROR = 5
            OTHERS                   = 6.

  results_received = 'X'.
endform.                    "receive_result
* < End of Version 2

Read only

0 Likes
1,679

Hi Stephen,

You have to check for the RC for individual calls in the PERFORM Receive result, based on which you will do the necessary.

Now if you want the processing to stop as soon as a RC(exception) is not zero, then you have to satisfy the condition for WAIT UNTIL.

Regards,

Chen

Read only

0 Likes
1,679

Hi, thanks for the reply.

Do you mean if I have this:


  results_received = 'X'.
  ret_rc = sy-subrc.

and check for that value as well as the other sy-subrc then that would give me what I want?

Read only

0 Likes
1,679

Yes Stephen, you have to check for ret_rc.

Regards,

Chen