07-30-2009 4:15 PM
Hi experts,
I'm tryin to implement parallel processing to this code:
EDIT: : Why is my code not structured?
-
METHOD data_select.
REFRESH gt_ltap.
* Get all relevant TA's
DATA: lt_zident_ta TYPE TABLE OF zident_ta,
lt_mara TYPE TABLE OF mara,
lt_ltap_all TYPE TABLE OF ltap,
lt_ltak_all TYPE TABLE OF ltak.
FIELD-SYMBOLS: <ls_ltap> TYPE ltap.
* <RELEVANT TA'S>
SELECT *
FROM ltak
INTO TABLE lt_ltak_all
WHERE lgnum IN so_lgnum
AND tanum IN so_tanum
AND bdatu IN so_bdatu
AND kquit = 'X' "Only fully confirmed TO
AND betyp = 'L'.
* </RELEVANT TA'S>
CHECK sy-subrc = 0.
SELECT *
FROM ltap
INTO TABLE lt_ltap_all
FOR ALL ENTRIES IN lt_ltak_all
WHERE lgnum = lt_ltak_all-lgnum
AND tanum = lt_ltak_all-tanum
AND nltyp = '916'. "Only outgoing for now
* Get all ident registrations
CHECK sy-subrc = 0.
SELECT *
FROM zident_ta
INTO TABLE lt_zident_ta
FOR ALL ENTRIES IN lt_ltap_all
WHERE lgnum = lt_ltap_all-lgnum
AND tanum = lt_ltap_all-tanum.
SELECT DISTINCT *
FROM mara
INTO TABLE lt_mara
FOR ALL ENTRIES IN lt_ltap_all
WHERE matnr = lt_ltap_all-matnr.
ENDMETHOD.
Should I create one FM for parallel processing per Select?
E.g. FM 'Z_GET_LTAK' for LTAK-select, FM 'Z_GET_LTAP' for LTAP-select and so on.
Like this... :
METHOD get_ltak.
CALL METHOD rfc_info_get. "Are there enough free processes
IF free_tasks LT 5.
MESSAGE a010(ad) WITH 'less than 5 processes available' .
ENDIF.
CALL FUNCTION 'Z_GET_LTAK'
STARTING NEW TASK 'FUNC1'
DESTINATION IN GROUP 'parallel_generators'
CALLING me->on_return ON END OF TASK
EXPORTING
ipf_lgnum = so_lgnum
ipf_tanum = so_tanum
ipf_bdatu = so_bdatu.
WAIT UNTIL functioncall1 = done.
ENDMETHOD. "get_ltak
METHOD rfc_info_get .
CALL FUNCTION 'SPBT_INITIALIZE'
IMPORTING
max_pbt_wps = max_tasks
free_pbt_wps = free_tasks
EXCEPTIONS
invalid_group_name = 1
internal_error = 2
pbt_env_already_initialized = 3
currently_no_resources_avail = 4
no_pbt_resources_found = 5
cant_init_different_pbt_groups = 6
OTHERS = 7.
CASE sy-subrc.
WHEN 0. "ok
WHEN 3.
CALL FUNCTION 'SPBT_GET_CURR_RESOURCE_INFO'
IMPORTING
max_pbt_wps = max_tasks
free_pbt_wps = free_tasks
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.
WHEN OTHERS.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDCASE.
ENDMETHOD. " rfc_info_get
METHOD on_return.
RECEIVE RESULTS FROM FUNCTION 'Z_GET_LTAK'
TABLES
lt_ltak = gt_ltak.
functioncall1 = done.
ENDMETHOD.
Or should I create one big FM.. but how should I do this because every Table has other keys..
Sorry, but I'm very confused...
Greetz,
Zaya
Edited by: Tuncay Zaya on Jul 30, 2009 5:15 PM
07-31-2009 8:32 AM
I don't think that this is a task for parallel processsing.
It is a slow SELEC and you should not use several processors to process it.
You must try to do it faster.
07-30-2009 9:49 PM
Try again without tags, or split into two parts, or leave out irrelevant code parts.
Not perfect, but better than this...
Thomas
07-31-2009 8:15 AM
Hi again, lets try it again..
I want to apply parallel processing on these selects:
<RELEVANT TA'S>
SELECT *
FROM ltak
INTO TABLE lt_ltak_all
WHERE lgnum IN so_lgnum
AND tanum IN so_tanum
AND bdatu IN so_bdatu
AND kquit = 'X'. "Only fully confirmed TO
</RELEVANT TA'S>
CHECK sy-subrc = 0.
SELECT *
FROM ltap
INTO TABLE lt_ltap_all
FOR ALL ENTRIES IN gt_ltak
WHERE lgnum = gs_ltak-lgnum
AND tanum = gs_ltak-tanum
AND nltyp = '916'. "Only outgoing for now
Do I need to create one aRFC per Select?
Like following aRFC for LTAK?
CALL FUNCTION 'Z_GET_LTAK'
STARTING NEW TASK 'FUNC1'
DESTINATION IN GROUP 'parallel_generators'
CALLING me->on_return ON END OF TASK
EXPORTING
ipf_lgnum = so_lgnum
ipf_tanum = so_tanum
ipf_bdatu = so_bdatu.
WAIT UNTIL functioncall1 = done.
My second question is about on_return method.
What should it return?
Should it return
it_LTAK -> results of my selection in FM 'Z_GET_LTAK'
or
taskid?
or both?
Thank u for any help!
Regards
Zaya
07-31-2009 8:32 AM
I don't think that this is a task for parallel processsing.
It is a slow SELEC and you should not use several processors to process it.
You must try to do it faster.
07-31-2009 12:41 PM
Hallo Siegried,
yes, you're right but I just want to learn how to implement parallel processing on this example!
Best Regards,
Zaya
07-31-2009 1:29 PM
Hello,
Best option may be to create two seperate background JOB for two seperate selects. you can create them through ABAP code.
Job's can run independent of each other. Creating task is not parallel processing it is transactional proecssing in which
one LUW is allocated to set of task and once you call the LUW the processing of the task start but still it will take dialog processing and process all the selects in sequence.
Check if this helps,
Thanks,
Augustin.
07-31-2009 1:31 PM
Sorry I mean to say once you close the LUW in above replay.
Thanks,
Augustin.
07-31-2009 3:05 PM
OK, I got ur point!
It's not related to this topics subject but my next question why following doesn't work as I want:
FUNCTION Z_GET_LTAK.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" IMPORTING
*" VALUE(IPF_LGNUM) TYPE ZLGNUM
*" VALUE(IPF_TANUM) TYPE ZTANUM
*" VALUE(IPF_BDATU) TYPE ZBDATU
*" TABLES
*" LT_LTAK STRUCTURE LTAK
*"----------------------------------------------------------------------
* <RELEVANT TA'S>
SELECT *
FROM ltak
INTO TABLE lt_ltak
WHERE lgnum = ipf_lgnum
AND tanum = ipf_tanum
AND bdatu = ipf_bdatu
AND kquit = 'X'. "Only fully confirmed TO
* </RELEVANT TA'S>
ENDFUNCTION.
As u can see ipf_lgnum ipf_tanum and ipf_bdatu are rangeparameters. I created them to import my selection options.
Above code doesn't fill lt_ltak..
And if I try to replace
WHERE lgnum = ipf_lgnum
AND tanum = ipf_tanum
AND bdatu = ipf_bdatu
AND kquit = 'X'. "Only fully confirmed TO
with
WHERE lgnum IN ipf_lgnum
AND tanum IN ipf_tanum
AND bdatu IN ipf_bdatu
AND kquit = 'X'. "Only fully confirmed TO
there comes an error that ipf_lgnum ipf_tanum and ipf_bdatu are no internal table or a value list.
What can u suggest me?
Best Regards,
Zaya
08-01-2009 11:50 AM
Hello,
I think you have defined ranges parameter using RANGES statement, instead define them using
data or types and use TYPE RANGE OF <object> form.
Check if this helps!
By the way using RANGES statement is not allowed in ABAP Objects context.
Thanks,
Augustin.
08-03-2009 5:27 AM
if your using range you should use "IN" for select statement right.
Hope your Q's is about data not fetching.
if RFC is not working then you better change if Remote part is enabled on the Functional module
Thank
Nafran
08-03-2009 5:37 AM
I recommend to go for parallel option if its has a parallel part and at the same time it takes time or else its a big effort.
if you want a basic idea
[link|http://nafran.blogspot.com/2009/06/only-way-of-parallel-or-multi-threading.html]
This is a detail document from Daniel Perecky
[detailed PDF|https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/abap/performance%20tuning%20using%20rfc.pdf]
Thanks
Nafran
08-03-2009 9:02 AM
Hey experts,
u're right!
I declared my imported SEL-OPS as structures instead of tables.. that was the problem!
So now they're declared as range-tabletypes. And it works!
This was my first experiment with parallel processing. But I used it for only one select yet. And therefore the runtime of my report is slower than the original one without parallel processing. I must implement it also for my other selects!
Thank u ALL for helping me!
@Nafran
Ure Blog is very interesting and u wrote useful articels! Especially ure article about parallel processing is well written and solved my problem.
Regards,
Zaya