method get_notes_from_refnum.
data: t_t5asrprocesses type t5asrprocesses.
data: t_t5asrscenarios type table of t5asrscenarios.
data: w_t5asrscenarios type t5asrscenarios.
data: v_activity type hrasr00_process_modelling-activity.
data: message_list type ref to cl_hrbas_message_list.
data: ref_pobj_runtime type ref to if_hrasr00_process_runtime.
data: is_authorized type boole_d.
data: is_ok type boole_d.
data: lt_notes type hrasr00_note_tab.
data: ls_notes type hrasr00_note.
data: no_of_notes.
data: process_object_guid type scmg_case_guid.
clear notes. refresh notes.
select single * into t_t5asrprocesses from t5asrprocesses
where reference_number = refnum.
if sy-subrc eq 0.
select * from t5asrscenarios into table t_t5asrscenarios
where parent_process = t_t5asrprocesses-case_guid.
v_activity = 'R'.
create object message_list.
sort t_t5asrscenarios descending.
loop at t_t5asrscenarios into w_t5asrscenarios.
* Get instance of POBJ_RUNTIME
call method cl_hrasr00_process_runtime=>get_instance
exporting
scenario_guid = w_t5asrscenarios-case_guid
activity = v_activity
message_handler = message_list
no_auth_check = 'X'
importing
instance_pobj_runtime = ref_pobj_runtime
pobj_guid_out = process_object_guid
is_authorized = is_authorized
is_ok = is_ok.
endloop.
* Get the Notes from the Last Saved Scenario since it will have all notes
sort t_t5asrscenarios descending.
loop at t_t5asrscenarios into w_t5asrscenarios.
refresh lt_notes.
clear: lt_notes, ls_notes.
* Get notes for the scenario
call method ref_pobj_runtime->get_notes_of_scenario
exporting
scenario_guid = w_t5asrscenarios-case_guid
message_handler = message_list
importing
notes = lt_notes
is_ok = is_ok.
describe table lt_notes lines no_of_notes.
if no_of_notes > 0.
sort lt_notes by changed_timestamp ascending.
notes[] = lt_notes[].
exit.
endif.
endloop.
endif.
endmethod.
if user cs 'US'.
move user+2(12) to l_created_by.
else.
move user+0(12) to l_created_by.
endif.
l_name = ZCL_HRASR_WF_UTILITY=>GET_NAME_FOR_USERID( CONV SYSID( l_created_by ) ).
lt_notes = get_notes_from_refnum( refnum = refnum ).
describe table lt_notes lines g_lin.
if g_lin gt 0.
sort lt_notes by changed_timestamp descending.
"The top record SHOULD be from our user otherwise comments have been made since their comment
"so it likely won't be relevant now.
READ TABLE lt_notes INTO ls_notes INDEX 1.
IF sy-subrc = 0. "should be
IF ls_notes-created_by = l_created_by.
clear ls_info.
write ls_notes-created_date to l_date mm/dd/yyyy.
write ls_notes-created_time to l_time using edit mask '__:__:__'.
concatenate 'Created by' l_name '(' ls_notes-created_by ') on' l_date 'at' l_time into ls_info-str separated by space.
append ls_info to notes.
call function 'SWA_STRING_SPLIT'
exporting
input_string = ls_notes-content
max_component_length = 72
tables
string_components = ls_info_tab
exceptions
max_component_length_invalid = 1
others = 2.
if sy-subrc = 0.
loop at ls_info_tab assigning <current_comment_line>.
append <current_comment_line> to notes.
endloop.
endif.
ENDIF.
ENDIF.
DATA: ref_process TYPE t5asrprocesses,
ref_scenario TYPE t5asrscenarios,
process_object_guid TYPE scmg_case_guid..
DATA: v_activity TYPE hrasr00_process_modelling-activity,
message_list TYPE REF TO cl_hrbas_message_list,
message_handler TYPE REF TO IF_HRBAS_MESSAGE_HANDLER,
error_messages TYPE hrbas_message_tab..
DATA: ref_pobj_runtime TYPE REF TO if_hrasr00_process_runtime,
is_authorized TYPE boole_d,
is_ok TYPE boole_d.
DATA: lt_steps TYPE HRASR00STEPS_TAB,
wa_step TYPE ASR_GUID.
DATA: lt_notes TYPE HRASR00_NOTE_TAB,
ls_note TYPE hrasr00_note,
l_new_content TYPE string,
no_of_notes TYPE i.
CONSTANTS: c_fld_lead_object TYPE string VALUE 'LEAD_OBJECT_ID',
c_fld_position_id TYPE string VALUE 'POS_OBJECT_ID',
c_completed TYPE asr_process_status VALUE 'COMPLETED',
c_archived TYPE asr_process_status VALUE 'ARCHIVED'.
* Look up by process number....Is this a valid process?
SELECT SINGLE * INTO ref_process FROM t5asrprocesses WHERE reference_number = proc_ref_no
AND status <> c_completed
AND status <> c_archived.
IF sy-subrc <> 0.
procstate = IF_HRASR00_UI_CONSTANTS=>C_PROC_STATUS_ERROR. "ERROR
EXIT. "no data
ENDIF.
* Get form scenario for process by GUID
SELECT SINGLE * from t5asrscenarios INTO ref_scenario WHERE parent_process = ref_process-case_guid.
v_activity = 'R'.
create object message_list.
* Get instance of POBJ_RUNTIME for scenario
call method cl_hrasr00_process_runtime=>get_instance
exporting
scenario_guid = ref_scenario-case_guid
activity = v_activity
message_handler = message_handler
no_auth_check = 'X'
importing
instance_pobj_runtime = ref_pobj_runtime
pobj_guid_out = process_object_guid
is_authorized = is_authorized
is_ok = is_ok.
IF is_ok = abap_false.
procstate = IF_HRASR00_UI_CONSTANTS=>C_PROC_STATUS_ERROR. "ERROR
EXIT. "no data
ENDIF.
* Get all steps
call method ref_pobj_runtime->IF_HRASR00_POBJ_FACTORY~GET_ALL_STEPS
EXPORTING
message_handler = message_handler
scenario_guid = ref_scenario-case_guid
IMPORTING
steps = lt_steps
is_ok = is_ok.
IF is_ok = abap_false.
procstate = IF_HRASR00_UI_CONSTANTS=>C_PROC_STATUS_ERROR. "ERROR
EXIT. "no data
ENDIF.
* This is simply the easiest way to have wa_step loaded up with the LAST step keeping in mind
* we don't know how many steps it went through because it may have been returned or such one
* or several times before final processing.
LOOP AT lt_steps INTO wa_step.
ENDLOOP.
* Get reference to step
CALL METHOD cl_hrasr00_process_runtime=>get_instance
EXPORTING
step_guid = wa_step
message_handler = message_list
IMPORTING
instance_pobj_runtime = ref_pobj_runtime
pobj_guid_out = process_object_guid
is_authorized = is_authorized
is_ok = is_ok.
refresh lt_notes.
clear: lt_notes, ls_note.
* get notes of current step
CALL METHOD ref_pobj_runtime->IF_HRASR00_POBJ_NOTE~GET_NOTES_OF_STEP
EXPORTING
step_guid = wa_step
message_handler = message_handler
IMPORTING
notes = lt_notes
is_ok = is_ok.
IF is_ok = abap_false.
procstate = IF_HRASR00_UI_CONSTANTS=>C_PROC_STATUS_ERROR. "ERROR
EXIT. "no data
ENDIF.
* auto-create a note using our "string of positions created"
IF resultstring IS NOT INITIAL.
"text-04 = The following positions were created with process reference numbers noted as well:
CONCATENATE text-004 cl_abap_char_utilities=>newline INTO l_new_content.
"loop resultstring and do same thing
LOOP AT resultstring ASSIGNING FIELD-SYMBOL(<pos>).
CONCATENATE l_new_content <pos> cl_abap_char_utilities=>newline INTO l_new_content.
ENDLOOP.
ENDIF.
READ TABLE lt_notes INTO ls_note WITH KEY category = '0001'.
IF sy-subrc EQ 0. "update existing note
CONCATENATE ls_note-content cl_abap_char_utilities=>newline cl_abap_char_utilities=>newline l_new_content INTO l_new_content.
ls_note-content = l_new_content.
ls_note-changed_by = sy-uname.
ls_note-changed_date = sy-datum.
ls_note-changed_time = sy-uzeit.
GET TIME STAMP FIELD ls_note-created_timestamp.
MODIFY lt_notes FROM ls_note INDEX sy-tabix.
ELSE. "create new note
"note header
ls_note-category = '0001'. "public
ls_note-object = 'HR_ASR_PRC'.
ls_note-name = wa_step. "GUID of step
ls_note-lang = 'E'.
ls_note-created_by = sy-uname.
ls_note-created_date = sy-datum.
ls_note-created_time = sy-uzeit.
GET TIME STAMP FIELD ls_note-created_timestamp.
ls_note-changed_by = sy-uname.
ls_note-changed_date = sy-datum.
ls_note-changed_time = sy-uzeit.
GET TIME STAMP FIELD ls_note-created_timestamp.
"actual note content
ls_note-content = l_new_content.
APPEND ls_note TO lt_notes.
ENDIF.
* Write notes back to form scenario
CALL METHOD ref_pobj_runtime->IF_HRASR00_POBJ_NOTE~ASSIGN_NOTES_2_CURRENT_STEP
EXPORTING
NOTES = lt_notes
MESSAGE_HANDLER = message_list
IMPORTING
IS_OK = is_ok.
* set return
IF is_ok = abap_false.
CALL METHOD message_list->get_error_list IMPORTING messages = error_messages.
procstate = IF_HRASR00_UI_CONSTANTS=>C_PROC_STATUS_ERROR. "ERROR
ELSE.
procstate = IF_HRASR00_UI_CONSTANTS=>C_PROC_STATUS_PROCESSED. "PROCESSED
ENDIF.
Then on the events for the field for "exit", we have the Javascript,
To test/show this, on the form I enter the notes:
Then when I click the "Check" button and switch to debugging in my service, I can see:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
3 | |
3 | |
3 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 |