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

function module in new task

Former Member
0 Likes
1,095

Hi:

I've got a Z function module. I want to use starting new task syntax with it. But the problem is that its having an importing parameter also. is there any alternative for that. I need to process this FM in a new task. Points will be rewarded.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
780

Hi,

HERE THE EXAMPLE

<b>&----


*& Form DIF_PLAN

&----


</b>

FORM dif_plan TABLES it_param TYPE tdf_el

USING nam LIKE t_name

idx.

CONCATENATE nam idx INTO taskname.

CALL FUNCTION 'Y_F_CO_DIF_DF_ELEM'

STARTING NEW TASK taskname

DESTINATION IN GROUP DEFAULT

PERFORMING outdata_new ON END OF TASK

EXPORTING

i_keart = 'N'

i_kkzst = ' '

i_curtp = p_curtp

TABLES

t_param = it_param

t_el_hv = it_el_hv

t_elehkns = it_elehkns

t_ckmlkev = it_ckmlkev

r_mlcct = ra_mlcct

r_categ = ra_categ

EXCEPTIONS

int_err = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE e203(zmco).

ELSE.

ADD 1 TO started_task.

ENDIF.

IF free_task <= proc_cnt_n .

WAIT UNTIL gs_cnt >= started_task.

CLEAR: started_task, gs_cnt.

*

<b>*Quantity of free processes</b>

CALL FUNCTION 'SPBT_GET_CURR_RESOURCE_INFO'

IMPORTING

free_pbt_wps = free_task

EXCEPTIONS

internal_error = 1

pbt_env_not_initialized_yet = 2

OTHERS = 3

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

ENDIF.

PERFORM num_task USING 4.

proc_cnt = proc_cnt - 1.

ENDFORM. "DIF_PLAN

<b>&----


*& Form outdata_new

&----


*& -->TASKNAME text

&----


</b>

FORM outdata_new USING taskname.

RECEIVE RESULTS FROM FUNCTION 'Y_F_CO_DIF_DF_ELEM'

TABLES

t_outdata = it_dif_df_elem1

EXCEPTIONS

int_err = 1

OTHERS = 2.

APPEND LINES OF it_dif_df_elem1 TO it_dif_df_elem.

ADD 1 TO gs_cnt.

ENDFORM.

4 REPLIES 4
Read only

Former Member
0 Likes
780

CALL FUNCTION update_function IN UPDATE TASK

[EXPORTING p1 = a1 p2 = a2 ...]

[TABLES t1 = itab1 t2 = itab2 ...].

Read only

matt
Active Contributor
0 Likes
780

The problem is that he has IMPORTING parameters.

You call the FM STARTING NEW TASK, without IMPORTING parameters. If you need the results, then you must use the addition

{PERFORMING subr}|{CALLING meth} ON END OF TASK

And in the subroutine or method, you'll need:

RECEIVE RESULTS FROM FUNCTION, putting your import parameters there. This is all documented very well in the ABAP help.

edit: note that you have posted this before. You say you have a problem with the importing params. What precisely is the problem?

matt

Message was edited by:

Matthew Billingham

Read only

0 Likes
780

Hi:

The problem was that I've importing parameters in FM...but as per ur guidance I was able to sort it out

Read only

Former Member
0 Likes
781

Hi,

HERE THE EXAMPLE

<b>&----


*& Form DIF_PLAN

&----


</b>

FORM dif_plan TABLES it_param TYPE tdf_el

USING nam LIKE t_name

idx.

CONCATENATE nam idx INTO taskname.

CALL FUNCTION 'Y_F_CO_DIF_DF_ELEM'

STARTING NEW TASK taskname

DESTINATION IN GROUP DEFAULT

PERFORMING outdata_new ON END OF TASK

EXPORTING

i_keart = 'N'

i_kkzst = ' '

i_curtp = p_curtp

TABLES

t_param = it_param

t_el_hv = it_el_hv

t_elehkns = it_elehkns

t_ckmlkev = it_ckmlkev

r_mlcct = ra_mlcct

r_categ = ra_categ

EXCEPTIONS

int_err = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE e203(zmco).

ELSE.

ADD 1 TO started_task.

ENDIF.

IF free_task <= proc_cnt_n .

WAIT UNTIL gs_cnt >= started_task.

CLEAR: started_task, gs_cnt.

*

<b>*Quantity of free processes</b>

CALL FUNCTION 'SPBT_GET_CURR_RESOURCE_INFO'

IMPORTING

free_pbt_wps = free_task

EXCEPTIONS

internal_error = 1

pbt_env_not_initialized_yet = 2

OTHERS = 3

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

ENDIF.

PERFORM num_task USING 4.

proc_cnt = proc_cnt - 1.

ENDFORM. "DIF_PLAN

<b>&----


*& Form outdata_new

&----


*& -->TASKNAME text

&----


</b>

FORM outdata_new USING taskname.

RECEIVE RESULTS FROM FUNCTION 'Y_F_CO_DIF_DF_ELEM'

TABLES

t_outdata = it_dif_df_elem1

EXCEPTIONS

int_err = 1

OTHERS = 2.

APPEND LINES OF it_dif_df_elem1 TO it_dif_df_elem.

ADD 1 TO gs_cnt.

ENDFORM.