Cierta vez un cliente en USA, que administra grandes volúmenes de información, me pidió que haga el proceso utilizando esta técnica, Parallel Processing, claramente no la conozco, asique busque un código en la web para adaptarlo, lo utilicé, y claramente no me andaba. Así que paso unos tips, y mi ajuste al mismo.
1- Seudocódigo: básicamente es dividir el trabajo en pequeñas tareas (tasks), e ir enviando a una función del tipo RFC, a medida que se procesan va preguntando un comparador, contra el sumador de tareas, para finalizar el programa. La idea es que se utilice con un JOB programado y se ejecute en horarios donde el servidor pueda estar con recursos plenos.
2 - Por un tipo de datos en el Form "update_status" no me funcionaba, y no podia detectar que era, pero paso el codigo arreglado el ajuste --> (form update_status using lv_task type clike ).
data : wa_data type zzaaa_emp,
it_data type standard table of zzaaa_emp, " internal table with contentss - CSK
it_data_temp type standard table of zzaaa_emp. " Internal table to store the content to be processed
data : lv_appsvr type rzllitab-classname value 'parallel_generators'. " All the application servers assinged to an instance
" are grouped in the table rzllitab " You can see the instance data's in tcode rz12
data : lv_total type i, " Total no of dialog work process available in the group server
lv_available type i, " No of dialog work process that are free.
lv_occupied type i, " No of occupied dialog process
lv_diff type i, " Percentage difference of available work process
lv_split type i. " No of partitions the main data is to be split
data : lv_lines type i, " No of records in the internal table
lv_lines_tab type i, " No of lines per tab
lv_start type i, " Start point for processing
lv_end type i. " End point for processing
data : lv_task type string, " Name of the task to be created
lv_index type string, " Variable for index
lv_sent type i, " No of package sent
lv_comp type i, " No of package completed
lv_result type flag. " Variable to collect the result.
data : lv_result_string TYPE string. " Result string
start-of-selection.
* Call the function module spbt_initialize the list of application server available and those that are free
call function 'SPBT_INITIALIZE'
exporting
group_name = lv_appsvr
importing
max_pbt_wps = lv_total
free_pbt_wps = lv_available
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.
if sy-subrc = 0.
* Split the data to be processed into no of work processes.
lv_occupied = lv_total - lv_available.
* Calculate the difference in percentage
lv_diff = ( lv_available * 100 ) / lv_total.
* Based on the available no of workprocess split the data
if lv_diff <= 25.
lv_split = lv_available div 2.
elseif lv_diff between 25 and 50.
lv_split = lv_available * 2 div 3.
elseif lv_diff >= 50.
lv_split = lv_available * 3 div 4.
endif.
endif.
* Dummy data generation
do 1000 times.
wa_data-mandt = sy-mandt.
wa_data-field1 = sy-index.
append wa_data to it_data.
enddo.
* Split the internal table accordingly.
lv_lines = lines( it_data ).
lv_lines_tab = lv_lines / lv_split.
do lv_split times.
lv_index = sy-index.
concatenate 'task' lv_index into lv_task.
lv_start = lv_start + lv_lines_tab.
lv_end = lv_lines_tab + 1.
if lv_index = 1.
lv_start = 0.
endif.
if lv_split = lv_index.
lv_end = 0.
endif.
it_data_temp[] = it_data[].
if lv_start is not initial.
delete it_data_temp to lv_start.
endif.
if lv_end is not initial.
delete it_data_temp from lv_end.
endif.
* Process the record set
* Call the function module to update the data.
* Here each and everytime the function module is called it will be called in a dialog work process that is free
call function 'ZCSK_PARALLEL_TABLE_UPDATE' starting new task lv_task destination in group lv_appsvr
performing update_status on end of task
tables
data = it_data_temp.
if sy-subrc = 0.
lv_sent = lv_sent + 1.
endif.
enddo.
WAIT UNTIL lv_comp >= lv_sent.
write : / 'The no of packets sent' , lv_sent,
'The no of packets completed', lv_comp.
*&---------------------------------------------------------------------*
*& Form UPDATE_STATUS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_DATA text
* -->P_= text
* -->P_IT_DATA_TEMP text
*----------------------------------------------------------------------*
form update_status using lv_task type clike.
lv_comp = lv_comp + 1.
receive results from function 'ZCSK_PARALLEL_TABLE_UPDATE'
importing
lv_result = lv_result.
if lv_result is initial.
lv_result_string = 'Success'.
else.
lv_result_string = 'Failure'.
endif.
concatenate 'The data passed via task' lv_task 'updation is' lv_result_string into lv_result_string separated by space.
write : / lv_result_string.
endform. " UPDATE_STATUS
Fuente:
http://www.teamabap.com/2014/05/parallel-processing-in-abap.html
Comentarios
Publicar un comentario