You are on page 1of 12

FUNCTION hrhap_c_bc_it5022_write.

ENHANCEMENT 1 ZHRHAP_C_BC_IT5022_WRITE.
"active version
data: lt_return_1
type hap_t_msg.
data: lt_msg_success_1
type bal_range.
*** workareas
data: lw_return_1
type bal_s_msg.
data: lw_reference_id_1
type hap_s_appraisal_reference_id,
lw_pt5022_1
type pt5022.
*** structure
data: ls_ret_struc_1
type hap_s_c_ret_struc.
*** variables
data:
l_objective_setting_1 type char1,
l_lines_1
type i,
l_count_1
type i.
data: l_exit_1
type char1.
*** refresh tables which are export only
refresh: t_return.
**
*** fill message range
call function 'HRHAP_C_MESSAGE_RANGE_FILL'
exporting
msg_type_s
= 'X'
***
MSG_TYPE_W
= ' '
***
MSG_TYPE_I
= ' '
***
MSG_TYPE_E
= ' '
***
MSG_TYPE_A
= ' '
importing
t_message_range
= lt_msg_success_1.
** CHECK column Existence
perform bc_it5022_column_existence using t_pt5022
error_process_mode
t_return
l_exit_1.
if l_exit_1 = c_true.
exit.
endif.
**
*** CHECK columns against the VA COLUMNS !
perform bc_it5022_va_columns using s_element_id
t_pt5022
va_objid
error_process_mode
t_return
l_exit_1.
if l_exit_1 = c_true.
exit.
endif.
**
*** CHECK column attributes

perform bc_it5022_column_attributes using s_element_id


va_objid
t_pt5022
s_hri5022-layout_values
error_process_mode
t_return
l_exit_1.
if l_exit_1 = c_true.
exit.
endif.
**
***-- Only a max. of 18 columns allowed (R/3 can't display more!)
describe table t_pt5022 lines l_count_1.
if l_count_1 > 180.
***-Fill message table
lw_return_1-msgty = c_message_type_e.
lw_return_1-msgno = '242'.
lw_return_1-msgid = c_message_class_catalog.
***
fill additional information
ls_ret_struc_1-tabname
= 'HRI5022'.
ls_ret_struc_1-fieldname
= 'COLUMN_ID'.
lw_return_1-context-tabname = c_return_structure.
lw_return_1-context-value
= ls_ret_struc_1.
append lw_return_1 to t_return.
clear: lw_return_1,
ls_ret_struc_1.
***-Message where-used
if 1 = 2.
message e242.
endif.
***-- Continue if all errors are to be collected
check error_process_mode = 'X'.
endif.
**
***-- Check Reserved Lines for Notes => 1
loop at t_pt5022 transporting no fields
where cell_input_note <> c_note_none.
exit.
endloop.
if sy-subrc = 0.
if s_hri5022-layout_note_line < 1.
***-Fill message table
lw_return_1-msgty = c_message_type_w.
lw_return_1-msgno = '202'.
lw_return_1-msgid = c_message_class_catalog.
***
fill additional information
ls_ret_struc_1-tabname
= 'HRI5022'.
ls_ret_struc_1-fieldname
= 'LAYOUT_NOTE_LINE'.
lw_return_1-context-tabname = c_return_structure.
lw_return_1-context-value
= ls_ret_struc_1.
append lw_return_1 to t_return.
clear: lw_return_1,

ls_ret_struc_1.
Message where-used
if 1 = 2.
message w202.
endif.
***-No Check on ERROR_PROCESS_MODE -> It's a Warning, so continue
endif.
endif.
" is anywhere a note allowed ?
***--

describe table t_pt5022 lines l_lines_1.


**
*** IF NO COLUMN SELECTED -> error (except for a VB - there it is allowed)
if l_lines_1 = 0 and not s_element_id-otype eq c_otype_vb.
***-- Atleast one column has to be filled out
***-- Fill message table and skip all column checks
lw_return_1-msgty = c_message_type_e.
lw_return_1-msgno = '215'.
lw_return_1-msgid = c_message_class_catalog.
***
fill additional information
ls_ret_struc_1-tabname
= 'PT5022'.
ls_ret_struc_1-fieldname
= 'COLUMN_ID'.
lw_return_1-context-tabname = c_return_structure.
lw_return_1-context-value
= ls_ret_struc_1.
append lw_return_1 to t_return.
clear: lw_return_1,
ls_ret_struc_1.
***-- Message where-used
if 1 = 2.
message e215.
endif.
***-- Continue if all errors are to be collected
check error_process_mode = 'X'.
else.
***
if columns are choosen do the business check for the column sort
***
-> returning the parameter for objective setting
call function 'HRHAP_C_BC_IT5022_COLUMN_ORDER'
exporting
s_hri5022
= s_hri5022
t_pt5022
= t_pt5022
error_process_mode = 'X'
importing
objective_setting = l_objective_setting_1
t_return
= lt_return_1.
**
***-- All error are Column order error -> make one general error!
if not lt_return_1 is initial.
call function 'HRHAP_C_MESSAGE_FILL'
exporting
msgno
= '206'
importing
s_return = lw_return_1.
append lw_return_1 to t_return.

clear: lw_return_1,
ls_ret_struc_1.
***-Continue if all errors are to be collected
check error_process_mode = 'X'.
endif.
**
***-- Atleast OBJ0 or FAPP or PAPP should exist on VA/VC level
***-- Try to read FAPP
if s_element_id-otype ne c_otype_vb.
read table t_pt5022 with key column_id = c_column_fapp
transporting no fields.
if sy-subrc ne 0.
***-FAPP not there, TRY PAPP
read table t_pt5022 with key column_id = c_column_papp
transporting no fields.
if sy-subrc ne 0.
***-FAPP and PAPP not there, TRY OBJ0
read table t_pt5022 with key column_id = c_column_obj0
transporting no fields.
if sy-subrc ne 0.
lw_return_1-msgty = c_message_type_e.
lw_return_1-msgno = '361'.
lw_return_1-msgid = c_message_class_catalog.
***
fill additional information
ls_ret_struc_1-tabname
= 'PT5022'.
ls_ret_struc_1-fieldname
= 'COLUMN_ID'.
lw_return_1-context-tabname = c_return_structure.
lw_return_1-context-value
= ls_ret_struc_1.
append lw_return_1 to t_return.
clear: lw_return_1,
ls_ret_struc_1.
***-Message where-used
if 1 = 2.
message e361.
endif.
***-Continue if all errors are to be collected
check error_process_mode = 'X'.
endif. " OBJ0 Selected?
endif. " PAPP Selected?
endif. " FAPP Selected?
endif. " OTYPE NE VB?
**
***-- OBJ1 can't exist without OBJL
read table t_pt5022 with key column_id = c_column_obj1
transporting no fields.
if sy-subrc eq 0.
read table t_pt5022 with key column_id = c_column_objl
transporting no fields.
**
if sy-subrc ne 0.
***-OBJL not selected -> Error
***-Fill message table

lw_return_1-msgty = c_message_type_e.
lw_return_1-msgno = '234'.
lw_return_1-msgid = c_message_class_catalog.
append lw_return_1 to t_return.
clear: lw_return_1.
***-Continue if all errors are to be collected
check error_process_mode = 'X'.
endif. " OBJ1 Selected?
endif. " OBJL Selected?
**
***
free input for VA ?
if not s_hri5022-free_input is initial
and s_element_id-otype = c_otype_va.
***
free input is not allowed for VA
lw_return_1-msgty = c_message_type_e.
lw_return_1-msgno = '237'.
lw_return_1-msgid = c_message_class_catalog.
***
fill context
ls_ret_struc_1-tabname
= 'HRI5022'.
ls_ret_struc_1-fieldname
= 'FREE_INPUT'.
lw_return_1-context-tabname = c_return_structure.
lw_return_1-context-value
= ls_ret_struc_1.
append lw_return_1 to t_return.
clear: lw_return_1,
ls_ret_struc_1.
***
message where-used
if 1 = 2.
message e237.
endif.
"message where used
***
continue if all errors have to collected
check error_process_mode = 'X'.
endif.
"free input for VA ?
**
if l_objective_setting_1 = c_false.
***
Check: is the column OBJ0 marked if FREE_INPUT = 'X'
if not s_hri5022-free_input is initial.
***
not possible to have free input without OBJ0 marked
***-Fill message table
lw_return_1-msgty = c_message_type_e.
lw_return_1-msgno = '214'.
lw_return_1-msgid = c_message_class_catalog.
***
fill additional information
ls_ret_struc_1-tabname
= 'HRI5022'.
ls_ret_struc_1-fieldname
= 'FREE_INPUT'.
lw_return_1-context-tabname = c_return_structure.
lw_return_1-context-value
= ls_ret_struc_1.
append lw_return_1 to t_return.
clear: lw_return_1,
ls_ret_struc_1.
***-Message where-used
if 1 = 2.
message e214.

endif.
Continue if all errors are to be collected
check error_process_mode = 'X'.
endif.
endif.
" l_objective_setting_1 NE c_true?
endif.
" l_lines_1 = 0 and otype NE VB?

***--

**
*** CHECK FREE INPUT + DISPLAY DESRIPTION only -> empty INPUT field
if not s_hri5022-free_input is initial
and s_hri5022-layout_text = c_layout_text_d.
***
not possible to have free input without OBJ0 marked
lw_return_1-msgty = c_message_type_w.
lw_return_1-msgno = '244'.
lw_return_1-msgid = c_message_class_catalog.
***
fill additional information
ls_ret_struc_1-tabname
= 'HRI5022'.
ls_ret_struc_1-fieldname
= 'LAYOUT_TEXT'.
lw_return_1-context-tabname = c_return_structure.
lw_return_1-context-value
= ls_ret_struc_1.
append lw_return_1 to t_return.
clear: lw_return_1,
ls_ret_struc_1.
if 1 = 2.
message w244.
endif.
"message where used
***
single error or list ?
check error_process_mode = 'X'.
endif.
"free input + description only ?
**
***-- CHECK VC ONLY
***
Atleast one value (like note, val. det. or input) should be active
if s_element_id-otype eq c_otype_vc.
loop at t_pt5022 into lw_pt5022_1.
if lw_pt5022_1-cell_input_type eq c_input_none
and lw_pt5022_1-cell_value_exit is initial
and lw_pt5022_1-cell_input_note eq c_note_none
and not lw_pt5022_1-column_id = c_column_fwgt.
***-Fill message table
call function 'HRHAP_C_MESSAGE_FILL'
exporting
msgno
= '243'
msgv1
= lw_pt5022_1-column_id
***
MSGV2
=
***
MSGV3
=
***
MSGV4
=
***
FILL_VARIABLES
= ' '
***
S_MSG_FIELDS
=
importing
s_return
= lw_return_1.
***
fill additional information
ls_ret_struc_1-tabname
= 'HRI5022'.
ls_ret_struc_1-fieldname
= 'COLUMN_ID'.

lw_return_1-context-tabname = c_return_structure.
lw_return_1-context-value
= ls_ret_struc_1.
append lw_return_1 to t_return.
clear:
lw_return_1.
***-Message where-used
if 1 = 2.
message w243 with lw_pt5022_1-column_id.
endif.
***-No Check on ERROR_PROCESS_MODE -> It's a Warning, so continue
endif.
clear:
lw_pt5022_1.
endloop. " at t_pt5022
endif.
**
*** CHECK exit existence for FIX ENHANCEMENT
if not s_hri5022-exit_add_fix is initial.
call function 'HRHAP_C_CHECK_EXIST_EXIT'
exporting
exit_area = c_exit_area_ai
ap_exit
= s_hri5022-exit_add_fix
read_db
= 'X'
importing
s_return = lw_return_1.
if not lw_return_1 is initial.
***
fill additional information
ls_ret_struc_1-tabname
= 'HRI5022'.
ls_ret_struc_1-fieldname
= 'EXIT_ADD_FIX'.
lw_return_1-context-tabname = c_return_structure.
lw_return_1-context-value
= ls_ret_struc_1.
append lw_return_1 to t_return.
if not lw_return_1-msgty in lt_msg_success_1
and error_process_mode is initial.
exit.
endif.
"error list preparation ?
clear: lw_return_1,
ls_ret_struc_1.
endif.
"error?
endif.
"fix enhancement given ?
*** CHECK exit existence for FREE ENHANCEMENT
if not s_hri5022-exit_add_free is initial.
call function 'HRHAP_C_CHECK_EXIST_EXIT'
exporting
exit_area = c_exit_area_ah
ap_exit
= s_hri5022-exit_add_free
read_db
= 'X'
importing
s_return = lw_return_1.
if not lw_return_1 is initial.
***
fill additional information

ls_ret_struc_1-tabname
= 'HRI5022'.
ls_ret_struc_1-fieldname
= 'EXIT_ADD_FREE'.
lw_return_1-context-tabname = c_return_structure.
lw_return_1-context-value
= ls_ret_struc_1.
append lw_return_1 to t_return.
if not lw_return_1-msgty in lt_msg_success_1
and error_process_mode is initial.
exit.
endif.
"error list preparation ?
clear: lw_return_1,
ls_ret_struc_1.
endif.
"error?
endif.
"free enhancement given ?
**
*** CHECK exit existence for DELETION of the ELEMENT
if not s_hri5022-exit_delete is initial.
call function 'HRHAP_C_CHECK_EXIST_EXIT'
exporting
exit_area = c_exit_area_aj
ap_exit
= s_hri5022-exit_delete
read_db
= 'X'
importing
s_return = lw_return_1.
if not lw_return_1 is initial.
***
fill additional information
ls_ret_struc_1-tabname
= 'HRI5022'.
ls_ret_struc_1-fieldname
= 'EXIT_ADD_FREE'.
lw_return_1-context-tabname = c_return_structure.
lw_return_1-context-value
= ls_ret_struc_1.
append lw_return_1 to t_return.
if not lw_return_1-msgty in lt_msg_success_1
and error_process_mode is initial.
exit.
endif.
"error list preparation ?
clear: lw_return_1,
ls_ret_struc_1.
endif.
"error?
endif.
"linkage 1 given ?
**
*** CHECK: VA and deletion -> not possible
if s_element_id-otype = c_otype_va
and not s_hri5022-exit_delete is initial.
***
Deletion of the VA not allowed !
lw_return_1-msgty = c_message_type_e.
lw_return_1-msgno = '233'.
lw_return_1-msgid = c_message_class_catalog.
lw_return_1-msgv1 = c_otype_va.
***
fill additional information
ls_ret_struc_1-tabname
= 'HRI5022'.
ls_ret_struc_1-fieldname
= 'EXIT_DELETE'.
lw_return_1-context-tabname = c_return_structure.
lw_return_1-context-value
= ls_ret_struc_1.

append lw_return_1 to t_return.


Message where-used
if 1 = 2.
message e233 with c_otype_va.
endif.
***
Continue if all errors are to be collected
check error_process_mode = 'X'.
endif.
"exit defined for VC ?
***

*** CHECK: are exits allowed at all (against VC)


if
s_element_id-otype = c_otype_vc
and ( not s_hri5022-exit_add_free is initial
or
not s_hri5022-exit_add_fix is initial ).
***
ENHANCEMENT not allowed for a VC
lw_return_1-msgty = c_message_type_e.
lw_return_1-msgno = '227'.
lw_return_1-msgid = c_message_class_catalog.
***
fill additional information
ls_ret_struc_1-tabname
= 'HRI5022'.
if not s_hri5022-exit_add_free is initial.
ls_ret_struc_1-fieldname
= 'EXIT_ADD_FREE'.
else.
ls_ret_struc_1-fieldname
= 'EXIT_ADD_FIX'.
endif.
"free or fix enhancement
lw_return_1-context-tabname = c_return_structure.
lw_return_1-context-value
= ls_ret_struc_1.
append lw_return_1 to t_return.
***
Message where-used
if 1 = 2.
message e227.
endif.
***
Continue if all errors are to be collected
check error_process_mode = 'X'.
endif.
"exit defined for VC ?
**
*** check whether an reference object for the attributes is defined
if
s_hri5022-t_reference_id[] is initial
and ( not s_hri5022-exit_add_free is initial
or
not s_hri5022-exit_add_fix
is initial ).
***
ENHANCEMENT not allowed without reference object
lw_return_1-msgty = c_message_type_e.
lw_return_1-msgno = '228'.
lw_return_1-msgid = c_message_class_catalog.
***
fill additional information
ls_ret_struc_1-tabname
= 'HRI5022'.
ls_ret_struc_1-fieldname
= 'INHERITED_ID'.
lw_return_1-context-tabname = c_return_structure.
lw_return_1-context-value
= ls_ret_struc_1.
append lw_return_1 to t_return.
***
Message where-used
if 1 = 2.
message e228.

endif.
Continue if all errors are to be collected
check error_process_mode = 'X'.
elseif not s_hri5022-t_reference_id[] is initial
and
s_hri5022-exit_add_free is initial
and
s_hri5022-exit_add_fix
is initial.
***
NO ENHANCEMENT but reference object is given
lw_return_1-msgty = c_message_type_w.
lw_return_1-msgno = '230'.
lw_return_1-msgid = c_message_class_catalog.
***
fill additional information
ls_ret_struc_1-tabname
= 'HRI5022'.
ls_ret_struc_1-fieldname
= 'INHERITED_ID'.
lw_return_1-context-tabname = c_return_structure.
lw_return_1-context-value
= ls_ret_struc_1.
append lw_return_1 to t_return.
***
Message where-used
if 1 = 2.
message w230.
endif.
***
Continue if all errors are to be collected
check error_process_mode = 'X'.
endif.
"inherited object defined ?
**
*** check existence of reference object
if not s_hri5022-t_reference_id[] is initial.
loop at s_hri5022-t_reference_id[] into lw_reference_id_1.
call function 'RH_OBJECT_READ_EXIST_DB_OR_BUF'
exporting
plvar
= lw_reference_id_1-plan_version
otype
= lw_reference_id_1-reference_type
objid
= lw_reference_id_1-reference_id
exceptions
object_not_found = 1
others
= 2.
if sy-subrc <> 0.
***
object doesn't exist
lw_return_1-msgty = c_message_type_e.
lw_return_1-msgno = '229'.
lw_return_1-msgid = c_message_class_catalog.
lw_return_1-msgv1 = lw_reference_id_1-plan_version.
lw_return_1-msgv2 = lw_reference_id_1-reference_type.
lw_return_1-msgv3 = lw_reference_id_1-reference_id.
***
fill additional information
ls_ret_struc_1-tabname
= 'HRI5022'.
ls_ret_struc_1-fieldname
= 'INHERITED_ID'.
lw_return_1-context-tabname = c_return_structure.
lw_return_1-context-value
= ls_ret_struc_1.
append lw_return_1 to t_return.
***
Message where-used
if 1 = 2.
message e229 with lw_return_1-msgv1
***

lw_return_1-msgv2
lw_return_1-msgv3.
endif.
Continue if all errors are to be collected
check error_process_mode = 'X'.
endif.
"object found ?
endloop.
"at all reference elements
endif.
"reference object defined ?

***

***-- Check Layout Text -> Description exist when displayed


if s_hri5022-layout_text <> c_layout_text_n.
***-- Try to read the Description
if t_pt1002_s[] is initial
and t_pt1002_w[] is initial.
***-No description -> Give out warning
lw_return_1-msgty = c_message_type_w.
lw_return_1-msgno = '235'.
lw_return_1-msgid = c_message_class_catalog.
lw_return_1-context-tabname = c_return_structure.
lw_return_1-context-value
= ls_ret_struc_1.
append lw_return_1 to t_return.
***
Message where-used
if 1 = 2.
message w235.
endif.
endif. " Description Available?
else.
"if s_hri5022-layout_text = c_layout_text_n.
***
description displayed -> check whether is is maintained
if not t_pt1002_s[] is initial
or not t_pt1002_w[] is initial.
***
description maintained -> give out warning
lw_return_1-msgty = c_message_type_w.
lw_return_1-msgno = '241'.
lw_return_1-msgid = c_message_class_catalog.
lw_return_1-context-tabname = c_return_structure.
lw_return_1-context-value
= ls_ret_struc_1.
append lw_return_1 to t_return.
***
Message where-used
if 1 = 2.
message w241.
endif.
endif.
"description maintained
endif. " Display Name?
check 1 = 2 .
ENDENHANCEMENT.

You might also like