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

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

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

Similar Messages

  • Starting new task in FM

    Hi,
    I have FM 'update_table' with asynchrounous call(FM which use starting new task). This FM updates the table and commits the work.But when I try to read the datas from table I don't get the updated datas.This happens only in in real scenario.
    When I try to debug the program it works fine and I get the updated data.
    Let me know how to resolve the issue?
    thanks
    Suganya

    Hi,
    As you want to update table in the function module, are you calling this fm in UPDATE TASK?
    Here are more details about the command.
    CALL FUNCTION func IN UPDATE TASK.
    Extras:
    ... EXPORTING  p1 = f1     ... pn = fn
    ... TABLES     p1 = itab1  ... pn = itabn
    Effect
    Flags the function module func for execution in the update task. It is not executed at once, but the data passed with EXPORTING or TABLES is placed in a database table and a subsequent COMMIT WORK then causes the function module to be executed by the update task. Update function modules must be flagged as such in the Function Builder
    The return value is not set.
    Addition 1
    ... EXPORTING p1 = f1 ... pn = fn
    Effect
    Values of fields and field strings specified under EXPORTING are passed from the calling program to the function module. In the function module, the formal parameters are defined as import parameters. In the interface definition, default values must be assigned to all import parameters of the update function module.
    Addition 2
    ... TABLES p1 = itab1 ... pn = itabn
    Effect
    TABLES passes references to internal tables. All table parameters of the function module must have values.
    Note
    With update function modules, both import parameters and exceptions are ignored when the call is made.
       1. During updating processes of function modules, you may not make any calls using the language statements SUBMIT, CALL DIALOG, CALL SCREEN, CALL TRANSACTION, COMMIT WORK or ROLLBACK WORK . All other language elements that trigger a database Commit (for example, a screen change using the MESSAGE statement) also lead to a runtime error during updating.
    ashish

  • Facing problem in call function starting new task taskname

    Hi all,
    when i call a function module using starting new task, it is failing with sy-subrc 3. can anyone guide me in this.
    see the code :
      DATA   lv_taskname(7) TYPE c VALUE 'PEM_EXE'.
        CALL FUNCTION 'PEM_SCHEDULE'  STARTING NEW TASK lv_taskname
             EXPORTING
                  iv_packid             = gv_packid
                  iv_pebid              = ls_alv_out-peb_id
             EXCEPTIONS
                  invalid_state_request = 1
                  database_error        = 2
                  OTHERS                = 3.
    Thanks in advance.
    Best Regards,
    Prashant

    when i change the function module from normal to remote, it gives me a error that the "generic types are not allowed in RFC", but i have not given any generic type in the parameters.
    see the signature of the function module.
    *"  IMPORTING
    *"     VALUE(IV_PACKID) TYPE  CNVMBTPACK-PACKID
    *"     VALUE(IV_PEBID) TYPE  CNVMBTPEB-PEB_ID
    *"  EXPORTING
    *"     VALUE(EV_ERROR_DETECTED) TYPE  C
    *"     VALUE(EV_STOP) TYPE  C
    *"  EXCEPTIONS
    *"      INVALID_STATE_REQUEST
    *"      DATABASE_ERROR
    *"      FORIEGN_LOCK
    Can u please check it and find out the problem
    Thanks,
    Prasanth

  • Call function starting new task:

    I am trying to create a program in which few database update are mentioned.
    after database updates , I am calling a function module using starting new task
    in which I want to commit database updates inside in function module.
    Problem is I want to commit only database updates if function module , not of main program. For that I tried using COMMIT WORK in function module and rollback statement after calling FM.  But it is not working.COMMIT statement in FM also commiting database updates of main program also that is not required.
    Can anybody help me in solving this problem.
    Thanks
    Ruchika

    I think this may be caused by an implicit database commit performed by the system at the moment of calling a fm with "starting new task".
    Try the following test:
    - Put "rollback work" statement inside your fm which you call "starting new task" (instead of "commit") and check if the updates performed by the code executed before the call to this fm are stored in db - inspite of the rollback. If they are (as I suppose) this means that the commit effect you observe is not due to the "commit work"  statement executed inside your fm but due to an implicit commit issued automatically at the time of calling the fm. If this is the case the solution could be placing the code which you now execute before "call function...starting new task" into a seperate fm called "in update task" - then the final commit or rollback statement in your main program should have the expected effect.
    regards

  • Starting new task question

    Hi,
    is there a way we can see the logs of task for all Function module that executed STARTING NEW TASK?
    for UPDATE TASK we can see it through SM13.  is this the same with STARTING NEW TASK?
    Thank you.

    STARTING NEW TASK and UPDATE TASK are related to different topics.
    STARTING NEW TASK is used to call a remote-enabled function module, see chapter "Using Asynchronous Remote Function Calls" in SAP NetWeaver help.
    UPDATE TASK is used to make major changes to the database, see chapter "Update Techniques" in SAP NetWeaver help.
    Due to the different purposes there is no equivalent of SM13 for STARTING NEW TASK. If you are the developer of the code using the STARTING NEW TASK feature you can readily track your calls with Business Application Logic (BAL), for instance, documentation see program SBAL_DOCUMENTATION.

  • Call Function'BAPI_USER_CHANGE' starting new task 'TEST'

    Hi All,
    I have problem with starting new task statement, I am using one FM after that am using starting new task 'TEST'
    statement but its not working in one system its working fine in other systems, Please help me who this works.
    Thanks in Advance.
    Eg: Call Function'BAPI_USER_CHANGE' starting new task 'TEST'
    Regar

    Thanks Lqueiroz  ,
    Now again i am getting a DUMP by saying ,
    "An error occurred when executing a REMOTE FUNCTION CALL.
    It was logged under the name "At least one entry could not be "
    on the called page."
    so what can be the reason for this
    call function 'ZRFC_PER_DIEM' starting new task lc_taskid performing subr on end of task
            exporting
              h_guid      = it_header_guid_n
              request_obj = lt_requested_objects_n.
          wait up to '1' seconds.
          read table gt_scl into ls_scl index 1.
          p_transaction_per_diem =  ls_scl-value.
          read table gt_scl into ls_scl index 2.
          transaction_currency_code = ls_scl-value.
      form subr   using task_id type clike.
      data: p_transaction_per_diem  type  char13,
            transaction_currency_code type  char3.
      receive results from function 'ZRFC_PER_DIEM'
                               tables
                                value = gt_scl.
    So basically i am getting dumo when receive statenment is running , by giving above dump.
    Regards
    PG

  • Call Function STARTING NEW TASK ----- Resource not available

    Hi All,
    I am calling a Function Module in new task using STARTING NEW TASK.
    If the resources are not available for the Dialog Process to start, for how long will SAP keep on trying to acquire the resources and in case if it fails to acquire resource, then what will happen
    Regards,
    Abhishek

    Hi,
    From memory (as it is a long time since I've done this) you can call another function module or SAP command that will tell you how many work processes are currently available before you actually then start the new task.  This can help you to avoid this issue and also stop you from eating up all available work processes on a system which will annoy all other users!
    I think this is the FM
    CALL FUNCTION 'SPBT_INITIALIZE'
      EXPORTING
        group_name     = 'parallel_generators'
      IMPORTING
        free_pbt_wps   = w_free_processes
      EXCEPTIONS
        OTHERS         = 1.
    Gareth.

  • Starting new task in update task

    Hello,
    Can we start a new task in update function module.
    Say, I want to enhance a standard update function module and call a new function module in it using STARTING NEW TASK,
    is it possible to do so?
    Because, when I try to do this, i am getting update termination
    Please suggest.

    check the bellow link
    [ http://nafran.blogspot.com/2009/06/only-way-of-parallel-or-multi-threading.html|http://nafran.blogspot.com/2009/06/only-way-of-parallel-or-multi-threading.html]

  • Use of CALL FUNCTION - STARTING NEW TASK parameter_list.

    SELECT strt_code
                 city_code
                 commu_code
                 regiogroup
          INTO TABLE gt_adrstreet1
          FROM adrstreet
          FOR ALL ENTRIES IN gt_street_district
          WHERE strt_code EQ gt_street_district-strt_code.
    To optimize the performance of teh above query I am planning to use call function CALL FUNCTION - STARTING NEW TASK .....
    by spliting the above internal table gt_street_district into two internal tables and use the value of each internal table into two different queries and these queries will be put in call function - start new task ....so that these queries are run in different workprocess and thus improve the performance of the program.
    Can you please let me know if this would be a good option and also how to implement the same.
    Thanks.....

    >To optimize the performance of teh above query I am planning to use call function CALL FUNCTION - STARTING NEW TASK .....
    nonsense! You should not try parallel processing for a non-optimized SELECT statement.
    Better add the first key field of the WHERE condition as said above and check
    + whether the driver table is empfty
    + and whether there are duplicated entries
    ... And it is also a good idea to really use the SINGLE RECORD BUFFER, therefore you must write
    field-symbol:  <fs>  type ...
    LOOP AT gt_street_district ASSIGNING <fs>
       SELECT *
                    INTO TABLE gt_adrstreet1
                    FROM adrstreet
                    WHERE counrty =
                     AND       strt_code = <fs>-strt_code.
    ENDLOOP.
    Then it will be extremely fast!

  • Question on parallel processing using the STARTING NEW TASK keyword

    I have the following code in a program on my development system:
    call function 'FUNCTION_NAME'
        starting new task ld_taskname
        performing collect_output on end of task
          exporting
            pd_param1       = ld_param1
          tables
            pt_packet       = lt_packet.
    You'll notice in the code above I left out the following part of the function call:
    DESTINATION IN GROUP group
    In my one-server development system the topmost code executes fine, but I'm getting a 'REMOTE FUNCTION CALL ERROR' when I execute this in a multi-server Q&A system. 
    My question: Is the missing 'DESTINATION' keyword required in order for this technique to work in a multi-server environment or is it optional keyword?  I made the assumption that since it worked in my development environment that without the 'DESTINATION' addition the system simply used the current logged on system to start the new processes.
    Any input appreciated.
    Thanks,
    Lee

    Hi Lee,
    Just take F1 help on CALL FUNCTION key word and go to the variant
    CALL FUNCTION func STARTING NEW TASK task
                  [DESTINATION {dest|{IN GROUP {group|DEFAULT}}}]
                  parameter_list
                  [{PERFORMING subr}|{CALLING meth} ON END OF TASK].
    This gives you very clear information about this Key word.
    No one would give you better information better than this, i hope
    Cheers
    Ram

  • Values of return code when using dba_audit_session

    Is there anywhere I can look up the possible values for return code when using dba_audit_session?
    I am generating a report over the data and have so far only been able to provide the returncode and whether the username exists (ie username or "other" error)
    Thanks
    (using 9i)

    So far I have fathomed out:
    Return code: 0 everything OK
    Return code: 1017 wrong username or password
    Return code: 28000 locked account
    Return code: 28001 expired account

  • I was using an 3GS which was SYNC thru the iTunes thru my PC  .. But I started using my new 4S and tried to plug in to my PC for SYNC and the New 4S is not identified by iTunes . It

    I was using an 3GS which was SYNC thru the iTunes thru my PC  .. But I started using my new 4S and tried to plug in to my PC for SYNC and the New 4S is not identified by iTunes . It says "the iPhone cud  not connect to iTunes for unknown reasons... Can anyone Pls help me on this as I have no way of SYNC my Contacts from the PC Out look ..

    i just now logged in the icloud from browser, there when you go to contacts, you will see a settings icon to the bottom left of the screen. it does give option to export and import vCards.. i did not see outlook option though.  i dont remember how i did it last time exactly.. outlook does create vcards, right?
    checkout this link, it might help you: http://www.pcworld.com/businesscenter/article/242401/syncing_icloud_with_windows _and_outlook.html
    hope it helps.

  • I had to return my first Ipad2, and now the new won't connect to itunes.  I verified I had the latest itunes, used the new cable and verified the port worked by syncing with my ipod, I reloaded 10.2.2 and restarted my PC. Still won't work - thoughts?

    I had to return my first IPad2, and now the new one won't connect to iTunes. I verified I had the latest version, used the new cable and verified the port worked by syncing with my iPod, I reloaded 10.2.2 and restarted my PC. Still won't work - thoughts?

    Sorry - found a couple of good threads right after posting.

  • DISCVR PARAMETER -- LOV ON DESC BUT RETURN CODE VALUE

    HOW DOES ONE IN DISCVR PARAMETER DIALOGUE CREATE A PARAMETER (SIMILAR TO ORACLE REPORT BUILDER, PICK CODE AND DESC -- HIDE FIRST COLUMN) WHERE THE
    USER SEES THE CODE DESCRIPTION IN THE LOV BUT THE CORRESPONDING CODE VALUE IS WHAT IS RETURNED TO THE PARAMETER BIND VARIABLE ??

    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

  • CALL FUNCTION func STARTING NEW TASK task

    hi,
    i developed rfc to extract data and send to xi
    as my interface is Async
    as per soem documents it was mentioned the syntax
    CALL FUNCTION func STARTING NEW TASK task
    wat is the task ? in the syntax
    and how do i use it
    jeff

    Hi suresh,
    this is the code of  RFC. if i execute without RFCDESTINATION it executes successfully. when i use RFC DESTINATION it shows error
    call to messaging system failed: com.sap.aii.af.ra.ms.api.DeliveryException
    i created RFC destination using TCP/IP and registered program. same parameters i am mentioning in XI.
    FUNCTION z_bank_reconciliation.
    ""Local interface:
    *"  IMPORTING
    *"     VALUE(COMP_CODE) TYPE  BUKRS
    *"     VALUE(HOUSE_BANK) TYPE  HBKID
    *"     VALUE(ACCOUNT_ID) TYPE  HKTID
    *"  TABLES
    *"      CHQDETAILS STRUCTURE  ZPAYR
      DATA: itab LIKE payr OCCURS 0 WITH HEADER LINE.
      DATA: jtab LIKE payr OCCURS 0 WITH HEADER LINE.
      DATA: it_bank LIKE zbankrecon OCCURS 0 WITH HEADER LINE.
      DATA: it_bank1 LIKE zpayr OCCURS 0 WITH HEADER LINE.
      TYPES :  BEGIN OF ty_bseg ,
                 bukrs LIKE bseg-bukrs,
                 hbkid LIKE bseg-hbkid,
                 belnr LIKE bseg-belnr,
                 zlsch LIKE bseg-zlsch,
                 kostl LIKE bseg-kostl,
                 hkont LIKE bseg-hkont,
                 bzdat LIKE bseg-bzdat,
             END OF ty_bseg.
      TYPES : BEGIN OF ty_t012 ,
                  bukrs  LIKE t012-bukrs,
                  bankl  LIKE t012-bankl,
                  bankn  LIKE t012k-bankn,
             END OF ty_t012.
      TABLES : payr, t012, t012k, bseg.
      DATA : itpayr LIKE zpayr OCCURS 0 WITH HEADER LINE,
             itt012 TYPE STANDARD TABLE OF ty_t012,
             itbseg TYPE STANDARD TABLE OF ty_bseg,
             wa_itt012 TYPE  ty_t012,
             wa_itbseg TYPE  ty_bseg,
             total TYPE n.
      SELECT * FROM zbankrecon INTO TABLE it_bank
                       FOR ALL ENTRIES IN itab
                       WHERE chequeno EQ itab-chect.
      SELECT  abukrs abankl b~bankn
                  INTO CORRESPONDING FIELDS OF TABLE
                  itt012 FROM t012 AS a
          INNER JOIN t012k  AS b ON bbukrs = abukrs AND b~hbkid =
    house_bank AND b~hktid = account_id
                WHERE abukrs = comp_code AND ahbkid = house_bank.
      DELETE ADJACENT DUPLICATES FROM itt012.
      SELECT  zbukr  hbkid hktid vblnr gjahr zaldt checf chect  znme1 rwbtr
      waers zaldt zbnkl FROM payr INTO CORRESPONDING FIELDS OF TABLE itpayr
        WHERE  ( zbukr = comp_code AND hbkid = house_bank ) AND hktid =
        account_id.
    SELECT bukrs hbkid belnr zlsch kostl hkont bzdat  FROM bseg INTO TABLE
    itbseg
      WHERE bukrs = comp_code AND hbkid = house_bank.
      SORT  itt012 BY bankl.
      SORT itbseg BY belnr.
      READ TABLE itt012 INTO wa_itt012 INDEX 1.
      LOOP AT itpayr.
        read table itbseg into wa_itbseg with key bukrs = itpayr-zbukr
    hbkid =  itpayr-hbkid.
        if sy-subrc = 0.
          itpayr-kostl = wa_itbseg-kostl.
          itpayr-hkont = wa_itbseg-hkont.
         itpayr-bldat = wa_itbseg-bzdat.
          itpayr-zlsch = wa_itbseg-zlsch.
        endif.
        itpayr-zbnkl = wa_itt012-bankl.
        itpayr-zbnkn = wa_itt012-bankn.
        MODIFY itpayr.
        APPEND itpayr TO chqdetails.
      ENDLOOP.
      LOOP AT chqdetails.
        READ TABLE it_bank WITH KEY chequeno = chqdetails-chect.
        IF sy-subrc NE 0.
          MOVE chqdetails TO it_bank1.
          APPEND it_bank1.
          CLEAR it_bank1.
        ENDIF.
      ENDLOOP.
      REFRESH chqdetails.
      chqdetails[] = it_bank1[].
      LOOP AT it_bank1.
        MOVE : it_bank1-chect TO zbankrecon-chequeno,
        sy-datum TO zbankrecon-check_date,
        sy-uzeit TO zbankrecon-check_time.
        INSERT zbankrecon.
        CLEAR zbankrecon.
      ENDLOOP.
    ENDFUNCTION.

Maybe you are looking for

  • Report logic to get net payment made after creditmemo posting

    i have to create a report for vendor payments made against a project i.e wbs.I am able to get the details of invoice from BSEG and payment clearing from BSAK.If i have posted credit memos to these vendors how could i get them included in the report t

  • Profit center document is not created for invoice cancellation document.

    Hi all, when i create the invoice, Profit center document is getting created, where when we try to create a cancellation document for the same invoice, Profit center document is not getting created, can anybody let me know where can i check this prob

  • Links in pdf doc are not working when viewed in Reader 9, but works with Reader 8

    Hello, When I view a pdf document using Reader 8, the links in the document work. However, when another user views the pdf document using Reader 9, the links do not work for them. Any suggestions?

  • Error at the time of execution using weblogic10

    Hi All,           i am new in the implementetion of weblogic10. anyhow i am able to deploy the message driven bean application successfully, but getting the following errors at the time of execution:           Error 500--Internal Server Error        

  • MISSING LIBRARY / INSPECTOR / FILE BROWSER

    Folks, I have now had this happen on 2 machines. When working with complex projects, Motion would crash - and then upon relaunch it would be missing the library, inspector and file browser windows. No, they are not located outside the desktop area. N