You are on page 1of 5

function z_adru_adj_prl.

*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(IV_COMMTYPE) TYPE AD_TABTYPE
*" TABLES
*" SEL_TAB STRUCTURE ADDR_ADDR_PERS_CP_LINE
*"----------------------------------------------------------------------

types:begin of adcp_struc,
addrnumber type ad_addrnum,
persnumber type ad_persnum,
comp_pers type ad_cmp_prs,
end of adcp_struc.

field-symbols: <lt_commtype> type table,

<ls_commtype> type any,


<lv_addrnumber> type adrc-addrnumber,
<lv_persnumber> type adrp-persnumber,
<lv_updateflag> type c.

constants : c_yes value 'X',


c_no value ' '.

data: lt_adcp type sorted table of adcp_struc with non-unique key


addrnumber persnumber,
ls_adr type addr_addr_pers_cp_line,
ls_adcp type adcp_struc,
lv_addrnumber type adrc-addrnumber,
lv_persnumber type adrp-persnumber,
lr_data type ref to data,
et_error like table of addr_error,
lv_xerro like boole-boole.

create data lr_data type table of (iv_commtype).


assign lr_data->* to <lt_commtype>.

loop at sel_tab into ls_adr.

* for the TYPE 1 addresses.


if ls_adr-persnumber is initial.
call function 'ADDR_COMM_GET'
exporting
address_number = ls_adr-addrnumber
table_type = iv_commtype
iv_current_state = c_no
importing
returncode = lv_xerro
tables
comm_table = <lt_commtype>
error_table = et_error
exceptions
parameter_error = 1
address_not_exist = 2
internal_error = 3
others = 4.
if sy-subrc eq 0 and lv_xerro <> 'E'.
loop at <lt_commtype> assigning <ls_commtype>.

assign component 'UPDATEFLAG' of structure


<ls_commtype> to <lv_updateflag>.
<lv_updateflag> = 'U'.
modify <lt_commtype> from <ls_commtype>.
endloop.

call function 'ADDR_COMM_MAINTAIN'


exporting
address_number = ls_adr-addrnumber
table_type = iv_commtype
importing
returncode = lv_xerro
tables
comm_table = <lt_commtype>
error_table = et_error
exceptions
parameter_error = 1
address_not_exist = 2
internal_error = 3
others = 4.

"if internal error then subsitute all the comm data. This will delete
" existing ADRU and creates again. But the exsisting default dates in
" if maintained, will be lost.

if sy-subrc = 3.

call function 'ADDR_COMM_MAINTAIN'


exporting
address_number = ls_adr-addrnumber
table_type = iv_commtype
substitute_all_comm_data = c_yes
importing
returncode = lv_xerro
tables
comm_table = <lt_commtype>
error_table = et_error.

endif.

endif.
endif.

* for Typw 2 & 3 addresses.


if ls_adr-addrnumber is not initial and
ls_adr-persnumber is not initial.

case ls_adr-comp_pers .

when 'C'.
call function 'ADDR_PERS_COMP_COMM_GET'
exporting
address_number = ls_adr-addrnumber
person_number = ls_adr-persnumber
table_type = iv_commtype
iv_current_state = c_no
importing
returncode = lv_xerro
tables
comm_table = <lt_commtype>
error_table = et_error
exceptions
parameter_error = 1
address_not_exist = 2
person_not_exist = 3
internal_error = 4
others = 5.

if sy-subrc eq 0 and lv_xerro <> 'E'.


loop at <lt_commtype> assigning <ls_commtype>.

assign component 'UPDATEFLAG' of structure


<ls_commtype> to <lv_updateflag>.
<lv_updateflag> = 'U'.
modify <lt_commtype> from <ls_commtype>.
endloop.

call function 'ADDR_PERS_COMP_COMM_MAINTAIN'


exporting
address_number = ls_adr-addrnumber
person_number = ls_adr-persnumber
table_type = iv_commtype
importing
returncode = lv_xerro
tables
comm_table = <lt_commtype>
error_table = et_error
exceptions
parameter_error = 1
address_not_exist = 2
person_not_exist = 3
internal_error = 4
others = 5.

if sy-subrc = 4.

call function 'ADDR_PERS_COMP_COMM_MAINTAIN'


exporting
address_number = ls_adr-addrnumber
person_number = ls_adr-persnumber
table_type = iv_commtype
substitute_all_comm_data = c_yes
importing
returncode = lv_xerro
tables
comm_table = <lt_commtype>
error_table = et_error.

endif.

endif.

when 'P'.

call function 'ADDR_PERSONAL_COMM_GET'


exporting
address_number = ls_adr-addrnumber
person_number = ls_adr-persnumber
table_type = iv_commtype
iv_current_state = c_no
importing
returncode = lv_xerro
tables
comm_table = <lt_commtype>
error_table = et_error
exceptions
parameter_error = 1
address_not_exist = 2
person_not_exist = 3
internal_error = 4
others = 5.

if sy-subrc eq 0 and lv_xerro <> 'E'.

loop at <lt_commtype> assigning <ls_commtype>.

assign component 'UPDATEFLAG' of structure


<ls_commtype> to <lv_updateflag>.
<lv_updateflag> = 'U'.
modify <lt_commtype> from <ls_commtype>.
endloop.

call function 'ADDR_PERSONAL_COMM_MAINTAIN'


exporting
address_number = ls_adr-addrnumber
person_number = ls_adr-persnumber
table_type = iv_commtype
importing
returncode = lv_xerro
tables
comm_table = <lt_commtype>
error_table = et_error
exceptions
parameter_error = 1
address_not_exist = 2
person_not_exist = 3
internal_error = 4
others = 5.

if sy-subrc = 4.

call function 'ADDR_PERSONAL_COMM_MAINTAIN'


exporting
address_number = ls_adr-addrnumber
person_number = ls_adr-persnumber
table_type = iv_commtype
substitute_all_comm_data = c_yes
importing
returncode = lv_xerro
tables
comm_table = <lt_commtype>
error_table = et_error.

endif.
endif.
endcase.
endif.
endloop.

call function 'ADDR_MEMORY_SAVE'


exceptions
address_number_missing = 1
person_number_missing = 2
internal_error = 3
database_error = 4
reference_missing = 5
others = 6.

if sy-subrc eq 0.
call function 'ADDR_MEMORY_CLEAR_COMMIT_WORK'.
endif.

endfunction.

You might also like