<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic CALL FUNCTION, STARTING NEW TASK in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/call-function-starting-new-task/m-p/8188012#M1624899</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear forumers, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I ran into a runtime error, POSTING_ILLEGAL_STATEMENT because the SUBMIT command was used in an update task (when a purchase order is posted). More specifically, this SUBMIT command was executed from a calling method (implemented from the BADI, MB_DOCUMENT_BADI).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To resolve this error, I've created a new wrapper function module (with the attributes - Normal Function Module, Start Immediately) containing the SUBMIT command. The SUBMIT command is needed for calling an executable program. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I've a little doubt on this:-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Immediately upon executing the FM, how can I ensure that the calling method only continues with the next code lines only after the FM has completed its execution? Will the following syntax suffice?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
          CLEAR LT_SRC_DEMAND.
          ......

          CALL FUNCTION 'ZZDT_DETERMINE_DEMANDS'
            STARTING NEW TASK 'UPDATE'
            DESTINATION 'NONE'
            EXPORTING
              IM_EXCL_SOURCED = ' '
              IM_NO_SHOW      = 'X'
              IM_MATERIAL     = LR_MATNR
              IM_WORK_ORDER   = LR_AUFNR
            CHANGING
              CH_SRC_DEMANDS  = LT_SRC_DEMAND.   
         " CHANGING had to be used above, as EXPORTING is not allowed

          IF LT_SRC_DEMAND IS NOT INITIAL.
              ......
          ENDIF.

          ......
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
" The FM source codes looks like this:-

FUNCTION ZZDT_DETERMINE_DEMANDS.
*----------------------------------------------------------------------
**Local Interface:
*  IMPORTING
*     REFERENCE(IM_EXCL_SOURCED) TYPE  XFELD
*     REFERENCE(IM_NO_SHOW) TYPE  XFELD DEFAULT 'X'
*     REFERENCE(IM_MATERIAL) TYPE  ZZDT_RESERVATION_MATNR_T
*     REFERENCE(IM_WORK_ORDER) TYPE  ZZDT_RESERVATION_AUFNR_T
*  CHANGING
*     REFERENCE(CH_SRC_DEMANDS) TYPE  ZZDT_SRC_DEMAND_T
*----------------------------------------------------------------------

** This is a wrapper function module to determine demands via the     **
** Sourcing program and is especially useful to be called from an     **
** update task.                                                       **

* Clear internal table first
  CLEAR ch_src_demands.

* For performance reasons, ensure that minimal data inputs are specified
  CHECK im_material IS NOT INITIAL OR im_work_order IS NOT INITIAL.

* Execute the Sourcing program to determine the relevant demands
  SUBMIT ZZDT_SOURCING AND RETURN
    WITH ex_srcd  EQ im_excl_sourced
    WITH p_noshow EQ im_no_show
    WITH sa_matnr IN im_material
    WITH sd_work  IN im_work_order.

* Return the list of demands via SAP/ABAP memory
  IMPORT t_demand_alv TO ch_src_demands FROM MEMORY ID 'SRC_DEMAND_LIST'.

ENDFUNCTION.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 08 Sep 2011 08:37:56 GMT</pubDate>
    <dc:creator>former_member367551</dc:creator>
    <dc:date>2011-09-08T08:37:56Z</dc:date>
    <item>
      <title>CALL FUNCTION, STARTING NEW TASK</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/call-function-starting-new-task/m-p/8188012#M1624899</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear forumers, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I ran into a runtime error, POSTING_ILLEGAL_STATEMENT because the SUBMIT command was used in an update task (when a purchase order is posted). More specifically, this SUBMIT command was executed from a calling method (implemented from the BADI, MB_DOCUMENT_BADI).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To resolve this error, I've created a new wrapper function module (with the attributes - Normal Function Module, Start Immediately) containing the SUBMIT command. The SUBMIT command is needed for calling an executable program. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I've a little doubt on this:-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Immediately upon executing the FM, how can I ensure that the calling method only continues with the next code lines only after the FM has completed its execution? Will the following syntax suffice?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
          CLEAR LT_SRC_DEMAND.
          ......

          CALL FUNCTION 'ZZDT_DETERMINE_DEMANDS'
            STARTING NEW TASK 'UPDATE'
            DESTINATION 'NONE'
            EXPORTING
              IM_EXCL_SOURCED = ' '
              IM_NO_SHOW      = 'X'
              IM_MATERIAL     = LR_MATNR
              IM_WORK_ORDER   = LR_AUFNR
            CHANGING
              CH_SRC_DEMANDS  = LT_SRC_DEMAND.   
         " CHANGING had to be used above, as EXPORTING is not allowed

          IF LT_SRC_DEMAND IS NOT INITIAL.
              ......
          ENDIF.

          ......
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
" The FM source codes looks like this:-

FUNCTION ZZDT_DETERMINE_DEMANDS.
*----------------------------------------------------------------------
**Local Interface:
*  IMPORTING
*     REFERENCE(IM_EXCL_SOURCED) TYPE  XFELD
*     REFERENCE(IM_NO_SHOW) TYPE  XFELD DEFAULT 'X'
*     REFERENCE(IM_MATERIAL) TYPE  ZZDT_RESERVATION_MATNR_T
*     REFERENCE(IM_WORK_ORDER) TYPE  ZZDT_RESERVATION_AUFNR_T
*  CHANGING
*     REFERENCE(CH_SRC_DEMANDS) TYPE  ZZDT_SRC_DEMAND_T
*----------------------------------------------------------------------

** This is a wrapper function module to determine demands via the     **
** Sourcing program and is especially useful to be called from an     **
** update task.                                                       **

* Clear internal table first
  CLEAR ch_src_demands.

* For performance reasons, ensure that minimal data inputs are specified
  CHECK im_material IS NOT INITIAL OR im_work_order IS NOT INITIAL.

* Execute the Sourcing program to determine the relevant demands
  SUBMIT ZZDT_SOURCING AND RETURN
    WITH ex_srcd  EQ im_excl_sourced
    WITH p_noshow EQ im_no_show
    WITH sa_matnr IN im_material
    WITH sd_work  IN im_work_order.

* Return the list of demands via SAP/ABAP memory
  IMPORT t_demand_alv TO ch_src_demands FROM MEMORY ID 'SRC_DEMAND_LIST'.

ENDFUNCTION.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Sep 2011 08:37:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/call-function-starting-new-task/m-p/8188012#M1624899</guid>
      <dc:creator>former_member367551</dc:creator>
      <dc:date>2011-09-08T08:37:56Z</dc:date>
    </item>
    <item>
      <title>Re: CALL FUNCTION, STARTING NEW TASK</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/call-function-starting-new-task/m-p/8188013#M1624900</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Also, to add on - the calling method is executed in background.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do I need to add anything further in the CALL FUNCTION command (see above) so that the FM is run in background as well?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Sep 2011 08:50:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/call-function-starting-new-task/m-p/8188013#M1624900</guid>
      <dc:creator>former_member367551</dc:creator>
      <dc:date>2011-09-08T08:50:40Z</dc:date>
    </item>
    <item>
      <title>Re: CALL FUNCTION, STARTING NEW TASK</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/call-function-starting-new-task/m-p/8188014#M1624901</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;To resolve this error, I've created a new wrapper function module (with the attributes - Normal Function Module, Start Immediately) containing the SUBMIT command.&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;You need to make the FM as "Remote-Enabled" module. AFAIK you cannot start normal FMs asynchronously.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;Immediately upon executing the FM, how can I ensure that the calling method only continues with the next code lines only after the FM has completed its execution? Will the following syntax suffice?&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;You can try using this variant of [WAIT|http://help.sap.com/abapdocu_702/en/abapwait_until.htm] statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Suhas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Sep 2011 09:06:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/call-function-starting-new-task/m-p/8188014#M1624901</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2011-09-08T09:06:16Z</dc:date>
    </item>
    <item>
      <title>Re: CALL FUNCTION, STARTING NEW TASK</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/call-function-starting-new-task/m-p/8188015#M1624902</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    As said to ensure the FM execution completion , you can try like this..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CLEAR GV_FLAG.
CALL FUNCTION 'ZZDT_DETERMINE_DEMANDS' STARTING NEW TASK 'UPDATE' DESTINATION 'NONE' PERFORMING result ON END OF TASK
  EXPORTING
    im_excl_sourced = ' '
    im_no_show      = 'X'
    im_material     = lr_matnr
    im_work_order   = lr_aufnr.

WAIT UNTIL GV_GLAG = 'X'.

RECEIVE RESULTS FROM FUNCTION 'ZZDT_DETERMINE_DEMANDS'
CHANGING
ch_src_demands  = lt_src_demand.

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  result
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      --&amp;gt;COUNTER    text
*----------------------------------------------------------------------*
FORM result USING LV_FLAG TYPE c.  
  GV_FLAG = 'X'.
ENDFORM.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ravi.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Sep 2011 09:16:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/call-function-starting-new-task/m-p/8188015#M1624902</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-08T09:16:32Z</dc:date>
    </item>
    <item>
      <title>Re: CALL FUNCTION, STARTING NEW TASK</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/call-function-starting-new-task/m-p/8188016#M1624903</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Suhas,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried to make the FM as "Remote-Enabled", but I had these warnings when changing the parameters to pass-by-value:-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Parameter IM_MATERIAL (type ZZDT_RESERVATION_MATNR_T) can reduce performance in RFC.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Parameter IM_WORK_ORDER (type  ZZDT_RESERVATION_AUFNR_T) can reduce performance in RFC.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Parameter CH_SRC_DEMANDS (type ZZDT_SRC_DEMAND_T) can reduce performance in RFC.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All of these parameters are of internal table types. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Should I still proceed, or is there a more efficient way around this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Sep 2011 10:44:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/call-function-starting-new-task/m-p/8188016#M1624903</guid>
      <dc:creator>former_member367551</dc:creator>
      <dc:date>2011-09-08T10:44:54Z</dc:date>
    </item>
    <item>
      <title>Re: CALL FUNCTION, STARTING NEW TASK</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/call-function-starting-new-task/m-p/8188017#M1624904</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, Ravi. This seems like something that could just work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Sep 2011 10:45:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/call-function-starting-new-task/m-p/8188017#M1624904</guid>
      <dc:creator>former_member367551</dc:creator>
      <dc:date>2011-09-08T10:45:28Z</dc:date>
    </item>
    <item>
      <title>Re: CALL FUNCTION, STARTING NEW TASK</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/call-function-starting-new-task/m-p/8188018#M1624905</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It should be better to use TABLES parameter instead of an IMPORTING parameter based on table type&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But it can't understand why you need to run the report in the posting process&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Sep 2011 10:56:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/call-function-starting-new-task/m-p/8188018#M1624905</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-08T10:56:44Z</dc:date>
    </item>
    <item>
      <title>Re: CALL FUNCTION, STARTING NEW TASK</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/call-function-starting-new-task/m-p/8188019#M1624906</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Max,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I had in mind that it is not advisable to use TABLES for the formal parameters - so I tried to avoid that as much as I could.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The report is needed to return the number of open demands, if there are any. And from what I know, calling the report (via SUBMIT) is the more efficient way to determine open demands quickly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Sep 2011 07:44:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/call-function-starting-new-task/m-p/8188019#M1624906</guid>
      <dc:creator>former_member367551</dc:creator>
      <dc:date>2011-09-09T07:44:00Z</dc:date>
    </item>
    <item>
      <title>Re: CALL FUNCTION, STARTING NEW TASK</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/call-function-starting-new-task/m-p/8188020#M1624907</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Need some help again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another runtime error has occured - and this time on the RECEIVE RESULTS statement instead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
          CLEAR: lt_src_demand, gv_call_completed.

          CALL FUNCTION 'ZZDT_DETERMINE_DEMANDS'
            STARTING NEW TASK 'UPDATE'
            DESTINATION 'NONE'
            CALLING set_call_completed ON END OF TASK
            EXPORTING
              im_excl_sourced = ' '
              im_material     = lr_matnr
              im_work_order   = lr_aufnr.

          WAIT UNTIL gv_call_completed = 'X'.

" run-time error occurs here 
          RECEIVE RESULTS
            FROM FUNCTION 'ZZDT_DETERMINE_DEMANDS'
           IMPORTING
             ex_src_demands = lt_src_demand.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Details about the run-time error are as below:-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CATEGORY: Internal Kernel Error&lt;/P&gt;&lt;P&gt;RUNTIME ERROR: CALL_FUNCTION_RECEIVE_ERROR&lt;/P&gt;&lt;P&gt;APPLICATION COMPONENT: BC-MID-RFC&lt;/P&gt;&lt;P&gt;ERROR ANALYSIS: Internal error: Invalid RFC handle.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What can I do to resolve this runtime error?&lt;/P&gt;&lt;P&gt;The FM attributes ('ZZDT_DETERMINE_DEMANDS') are currently set as 'Remote-Enabled Module' and 'Start immediately'.&lt;/P&gt;&lt;P&gt;Does this need to be changed (i.e. as 'Update Module') to resolve the current runtime error?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Appreciate any help at all. Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Sep 2011 02:48:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/call-function-starting-new-task/m-p/8188020#M1624907</guid>
      <dc:creator>former_member367551</dc:creator>
      <dc:date>2011-09-22T02:48:25Z</dc:date>
    </item>
    <item>
      <title>Re: CALL FUNCTION, STARTING NEW TASK</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/call-function-starting-new-task/m-p/8188021#M1624908</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt; Shift your Receive statement inside the subroutine and no need of using gv_call_completed Flag.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt; Why you use 'Importing' in Receive statement when you have 'CHANGING' in your FM call.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;try .....&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
FORM result USING LV_FLAG TYPE c.  

RECEIVE RESULTS
            FROM FUNCTION 'ZZDT_DETERMINE_DEMANDS'
           CHANGING
             ex_src_demands = lt_src_demand.

ENDFORM.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Diwakar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Sep 2011 07:47:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/call-function-starting-new-task/m-p/8188021#M1624908</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-22T07:47:30Z</dc:date>
    </item>
  </channel>
</rss>

