0% found this document useful (0 votes)
108 views

Z Commusage Update PRL

This document contains a correction report to update communication usages in SAP. It includes forms to perform the updates across different tables, determine when tasks are finished, and process the data. SAP is not responsible for any improper use of this report. It will run the updates for various communication types like telephone, fax, email and check when the processes are complete.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
108 views

Z Commusage Update PRL

This document contains a correction report to update communication usages in SAP. It includes forms to perform the updates across different tables, determine when tasks are finished, and process the data. SAP is not responsible for any improper use of this report. It will run the updates for various communication types like telephone, fax, email and check when the processes are complete.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 8

*&---------------------------------------------------------------------*

*& Report Z_COMMUSAGE_UPDATE_PRL


*&
*&---------------------------------------------------------------------*
*& Correction report - Address Communication Usages
*& SAP is not considered as responsible for any improper
*& use of this report.
*&*&--------------------------------------------------------------------

report z_commusage_update_prl.

tables: adrc, adru, adrp, adcp.

selection-screen skip 1.
selection-screen begin of block one with frame title text1.
selection-screen skip 1.
* Parameters for selection
parameters: pckgsize type ad_pc_size default '1000' obligatory,
serv_grp like rzllitab-classname,
job_cnt type i default '10'.
selection-screen skip.
selection-screen comment /1(70) comm1.
selection-screen comment /1(70) comm2.
select-options: seladr for adrc-addrnumber.
selection-screen skip 1.
selection-screen comment /1(70) comm3.
parameters: adru_cre like szad_field-flag default space.
selection-screen: end of block one.

at selection-screen output.
comm1 = 'Address Number selection.'.
comm2 = 'If blank, picks up all address numbers.'.
comm3 = 'Create ADRU entries only.'.

initialization.
text1 = 'Correction report - Address Communication Usages'.

start-of-selection.
constants : c_yes value 'X',
gc_true value 'X',
gc_false value ' '.

types:
begin of task,
index type sytabix, "Index
statu type char1, "Status
desti like rfcdes-rfcdest, "Destination
tname type text20, "Task name
end of task.

data : gt_taskx type task occurs 0 with header line.


data : lv_taskname(10) type n value '0000000000',
gc_statu_error value 'E', "Status of task: error
gc_statu_working value 'W', "Status of task: working
gc_statu_finished value 'F'. "Status of task: finished
data : lv_group type rzlli_apcl,
gv_snd_jobs type i,
gv_rcv_jobs type i,
gv_err_jobs type i,
gv_cur_jobs type i,
lv_msg(80) type c value space,
lv_cur_jobs type i,
lv_tasks_default type i value '10',
lv_max_tasks type i ,
lv_server_name like pbtresourc-servername,
lv_parallel_failed type c,
lv_curr_line type i,
gv_task_finished type boolean, "RFC-Answer received
gv_all_tasks_finished type boolean,
gv_all_tasks_error type boolean, " all tasks finished with
gv_keeping_task type boolean,
end_of_select like c_yes,
seladr_flag like c_yes,
sel_tab type table of addr_addr_pers_cp_line,
ls_sel type addr_addr_pers_cp_line,
lt_adru type sorted table of adru with unique key
addrnumber persnumber comm_type,
ls_adru type adru.

if seladr is not initial.


seladr_flag = 'X'.
endif.

" update the communication usages.

perform comm_update using 'FLAGCOMM2' 'ADTEL' 'TEL'.


perform comm_update using 'FLAGCOMM3' 'ADFAX' 'FAX'.
perform comm_update using 'FLAGCOMM4' 'ADTTX' 'TTX'.
perform comm_update using 'FLAGCOMM5' 'ADTLX' 'TLX'.
perform comm_update using 'FLAGCOMM6' 'ADSMTP' 'INT'.
perform comm_update using 'FLAGCOMM7' 'ADRML' 'RML'.
perform comm_update using 'FLAGCOMM8' 'ADX400' 'X40'.
perform comm_update using 'FLAGCOMM9' 'ADRFC' 'RFC'.
perform comm_update using 'FLAGCOMM10' 'ADPRT' 'PRT'.
perform comm_update using 'FLAGCOMM11' 'ADSSF' 'SSF'.
perform comm_update using 'FLAGCOMM12' 'ADURI' 'URI'.
perform comm_update using 'FLAGCOMM13' 'ADPAG' 'PAG'.

write: /, 'Report Run successfully.'.

*&---------------------------------------------------------------------*
*& Form COMM_UPDATE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_0025 text
*----------------------------------------------------------------------*
form comm_update using value(iv_tabname)
value(iv_commtype)
value(iv_commusage).

data: lines_read like sy-tabix,


package_no like adrc_qu2-pckg_no_in.

data: lv_cursor type cursor,


ls_addrnumber type ad_addrnum,
ls_persnumber type ad_persnum.

lv_max_tasks = job_cnt.
clear: end_of_select.
define select_db_adrc.
if seladr_flag ne space.
select distinct addrnumber from adrc
into corresponding fields of table sel_tab
up to pckgsize rows where addrnumber in seladr and
addrnumber gt ls_addrnumber and &1 eq 'X' order by addrnumber
ascending.
else.
select distinct addrnumber from adrc
into corresponding fields of table sel_tab
up to pckgsize rows where addrnumber gt ls_addrnumber and
&1 eq 'X' order by addrnumber ascending.
endif.
end-of-definition.

define select_db_adcp.
if seladr_flag ne space.
select distinct s~persnumber p~addrnumber p~comp_pers
into corresponding fields of table sel_tab up to pckgsize rows
from adrp as s inner join adcp as p on p~persnumber = s~persnumber
where p~addrnumber in seladr and s~persnumber ge ls_persnumber
and &1 eq 'X' order by s~persnumber ascending .

else.
select distinct s~persnumber p~addrnumber p~comp_pers
into corresponding fields of table sel_tab up to pckgsize rows
from adrp as s inner join adcp as p on p~persnumber = s~persnumber
where s~persnumber ge ls_persnumber and &1 eq 'X'
order by s~persnumber ascending .
endif.
end-of-definition.

*TYPE 1 addresses.
do.

clear: sel_tab.
if end_of_select = 'X'.
exit.
endif.

case iv_tabname.
when 'FLAGCOMM2'. select_db_adrc flagcomm2.
when 'FLAGCOMM3'. select_db_adrc flagcomm3.
when 'FLAGCOMM4'. select_db_adrc flagcomm4.
when 'FLAGCOMM5'. select_db_adrc flagcomm5.
when 'FLAGCOMM6'. select_db_adrc flagcomm6.
when 'FLAGCOMM7'. select_db_adrc flagcomm7.
when 'FLAGCOMM8'. select_db_adrc flagcomm8.
when 'FLAGCOMM9'. select_db_adrc flagcomm9.
when 'FLAGCOMM10'. select_db_adrc flagcomm10.
when 'FLAGCOMM11'. select_db_adrc flagcomm11.
when 'FLAGCOMM12'. select_db_adrc flagcomm12.
when 'FLAGCOMM13'. select_db_adrc flagcomm13.
endcase.

describe table sel_tab lines lines_read.


if sel_tab is not initial.
if lines_read < pckgsize.
end_of_select = 'X'.
endif.
read table sel_tab into ls_sel index lines_read.
ls_addrnumber = ls_sel-addrnumber.
if adru_cre is not initial.
perform filter_adru tables sel_tab using iv_commusage.
endif.
if sel_tab is not initial.
perform fm_prl tables sel_tab using iv_commtype.
endif.
else.
exit.
endif.

enddo.

* type 2 & 3 addresses.


clear: end_of_select, ls_persnumber , ls_addrnumber, lines_read .
do.

clear: sel_tab.

if end_of_select = 'X'.
exit.
endif.

case iv_tabname.
when 'FLAGCOMM2'. select_db_adcp flagcomm2.
when 'FLAGCOMM3'. select_db_adcp flagcomm3.
when 'FLAGCOMM4'. select_db_adcp flagcomm4.
when 'FLAGCOMM5'. select_db_adcp flagcomm5.
when 'FLAGCOMM6'. select_db_adcp flagcomm6.
when 'FLAGCOMM7'. select_db_adcp flagcomm7.
when 'FLAGCOMM8'. select_db_adcp flagcomm8.
when 'FLAGCOMM9'. select_db_adcp flagcomm9.
when 'FLAGCOMM10'. select_db_adcp flagcomm10.
when 'FLAGCOMM11'. select_db_adcp flagcomm11.
when 'FLAGCOMM12'. select_db_adcp flagcomm12.
when 'FLAGCOMM13'. select_db_adcp flagcomm13.
endcase.

describe table sel_tab lines lines_read.

if sel_tab is not initial.


if lines_read < pckgsize.
end_of_select = 'X'.
endif.
read table sel_tab into ls_sel index lines_read.
ls_persnumber = ls_sel-persnumber.
if adru_cre is not initial.
perform filter_adru tables sel_tab using iv_commusage.
endif.
if sel_tab is not initial.
perform fm_prl tables sel_tab using iv_commtype.
endif.
else.
exit.
endif.

enddo.
clear: sel_tab, end_of_select, ls_persnumber , ls_addrnumber,
lines_read.

endform. " COMM_UPDATE

*&---------------------------------------------------------------------*
*& Form DETERMINE_END_OF_TASK
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
form determine_end_of_task using iv_taskname.

data: ls_task type task,


lv_index like sy-tabix,
lv_running_tasks type i.
data: lv_msgtx(80) type c,
lv_flag(1) type c.

gv_rcv_jobs = gv_rcv_jobs + 1.

read table gt_taskx into ls_task


with key tname = iv_taskname.
lv_index = sy-tabix.
ls_task-statu = gc_statu_finished.

if sy-subrc eq 0.
delete gt_taskx index lv_index.
endif.

*--> Flag Task_Finished set to finish WAIT-Status


gv_task_finished = gc_true.

lv_running_tasks = 0.
loop at gt_taskx
where statu <> gc_statu_error.
lv_running_tasks = 1.
exit.
endloop.

if lv_running_tasks = 0.
gv_all_tasks_finished = gc_true.
endif.

endform. " DETERMINE_END_OF_TASK


*&---------------------------------------------------------------------*
*& Form FM_PRL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form fm_prl
tables sel_tab structure addr_addr_pers_cp_line
using value(iv_commtype).

data: lv_snd_jobs type i.

lv_taskname = lv_taskname + 1.
gt_taskx-tname = lv_taskname.
gt_taskx-index = lv_taskname.
gt_taskx-statu = gc_statu_working.

if not serv_grp is initial.


lv_group = serv_grp.
endif.

call function 'FUNCTION_EXISTS'


exporting
funcname = 'Z_ADRU_ADJ_PRL'
exceptions
function_not_exist = 1
others = 2.

if sy-subrc = 0.
" Processing the logic in different threads - parallelization.
call function 'Z_ADRU_ADJ_PRL'
starting new task gt_taskx-tname
destination in group lv_group
performing determine_end_of_task on end of task
exporting
iv_commtype = iv_commtype
tables
sel_tab = sel_tab
exceptions
system_failure = 01
communication_failure = 02
resource_failure = 03.

case sy-subrc.
when 0.
call function 'SPBT_GET_PP_DESTINATION'
importing
rfcdest = gt_taskx-desti.
when 1 or 2.
call function 'SPBT_GET_PP_DESTINATION'
importing
rfcdest = gt_taskx-desti.
move gt_taskx-desti to lv_server_name.
gt_taskx-statu = gc_statu_error.
gv_err_jobs = gv_err_jobs + 1.
when 3.
wait until gv_rcv_jobs ge lv_snd_jobs.
endcase.
endif.
*--> Append to task-table
append gt_taskx.

*--> Statistics
add 1 to lv_snd_jobs.
lv_cur_jobs = lv_snd_jobs - gv_rcv_jobs.

*--> Always work with constant number of active jobs


if lv_cur_jobs ge lv_max_tasks.
wait until gv_task_finished eq gc_true.
clear gv_task_finished.
endif.

*--> Stop: When RFC problems


if gv_err_jobs > lv_max_tasks
and gv_err_jobs = gv_rcv_jobs.
lv_parallel_failed = c_yes.
exit.
endif.

*--> Stop: Raise exception


if lv_parallel_failed eq c_yes.
raise error_with_rfc.
endif.

* IF end_of_select = 'X' OR package_no = '0000000011'.


if end_of_select = 'X'.
wait until gv_all_tasks_finished eq gc_true.
exit.
endif.

endform. " FM_PRL


*&---------------------------------------------------------------------*
*& Form FILTER_ADRU
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_SEL_TAB text
* -->P_IV_COMMUSAGE text
*----------------------------------------------------------------------*
form filter_adru tables sel_tab structure addr_addr_pers_cp_line

using value(iv_commusage).

select distinct addrnumber persnumber comm_type from adru into


corresponding
fields
of table lt_adru for all entries
in sel_tab where addrnumber = sel_tab-addrnumber and
persnumber = sel_tab-persnumber and
comm_type = iv_commusage.

loop at sel_tab into ls_sel.


read table lt_adru into ls_adru with key
addrnumber = ls_sel-addrnumber
persnumber = ls_sel-persnumber
comm_type = iv_commusage
binary search.
if sy-subrc = 0.
delete table sel_tab from ls_sel.
endif.
endloop.

endform. " FILTER_ADRU

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy