Difference between revisions of "SAP HCM WORKFLOW"

From SapWiki
Line 11: Line 11:
 
* RPTARQAPP - Solicitudes de absentismo: Autorizar documentos en su nombre
 
* RPTARQAPP - Solicitudes de absentismo: Autorizar documentos en su nombre
 
* RPTARQPOST - Notificaciones de absentismo: Contabilizar
 
* RPTARQPOST - Notificaciones de absentismo: Contabilizar
 +
 +
===Ejemplos===
 +
Autorizar documentos en su nombre
 +
<nowiki>*&---------------------------------------------------------------------*
 +
*&      Form  search_for_action
 +
*&---------------------------------------------------------------------*
 +
*      copiado de RPTARQ_ADMINREP_EVENTS
 +
*----------------------------------------------------------------------*
 +
*      -->P_C_REQ_MANUAL_POST  text
 +
*      <--P_EVENT_ALV  text
 +
*----------------------------------------------------------------------*
 +
FORM state_transition USING request_id TYPE tim_req_id
 +
                            event      TYPE tim_req_xfer_event
 +
                  CHANGING p_subrc type sy-subrc
 +
                            p_message type bapiret2-message.
 +
 +
  DATA: application TYPE REF TO cl_pt_arq_application,      "#EC NEEDED
 +
        request    TYPE REF TO if_pt_req_request,
 +
        new_status  TYPE tim_req_status.
 +
  CLASS: cl_pt_arq_application DEFINITION LOAD,
 +
        if_pt_req_request    DEFINITION LOAD.
 +
 +
  application = cl_pt_arq_application=>get_instance( ).
 +
  CALL FUNCTION 'ENQUEUE_EPTREQ'
 +
    EXPORTING
 +
      mode_ptreq_header = 'E'
 +
      request_id        = request_id
 +
    EXCEPTIONS
 +
      foreign_lock      = 1
 +
      system_failure    = 2
 +
      OTHERS            = 3.
 +
  IF sy-subrc <> 0.
 +
    MESSAGE w058(hrtim_abs_req) INTO p_message.
 +
    p_subrc = 1.
 +
  ELSE.
 +
* get request from guid
 +
    CALL METHOD ca_pt_req_header=>agent->get_request
 +
      EXPORTING
 +
        im_request_id = request_id
 +
      IMPORTING
 +
        ex_request    = request.
 +
*  Change state only for existing request object
 +
    IF request IS BOUND.
 +
* execute state transition
 +
      CALL METHOD request->initiate_state_transition
 +
        EXPORTING
 +
          im_transfer_event = event
 +
        IMPORTING
 +
          ex_new_status    = new_status
 +
          ex_ret_code      = p_subrc.
 +
      IF new_status <> cl_pt_req_const=>c_reqstat_approved.
 +
        p_message = 'Se ha producido un error durante la autorización'(E01).
 +
        p_subrc = 3.
 +
      else.
 +
        p_subrc = 0.
 +
      ENDIF.
 +
    ELSE.
 +
      p_message = 'Se ha producido un error durante la autorización'(E01).
 +
      p_subrc = 2.
 +
    ENDIF.
 +
    CALL FUNCTION 'DEQUEUE_EPTREQ'
 +
      EXPORTING
 +
        request_id = request_id.
 +
  ENDIF.
 +
ENDFORM.                    " state_transition</nowiki>
 +
 +
Autorizar documentos en Nombre de una Persona (programa RPTARQMASS_APPROVAL)
 +
 +
<nowiki>FORM aprobar USING p_data TYPE ty_salida
 +
          CHANGING p_subrc TYPE sy-subrc
 +
                  p_message TYPE bapiret2-message.
 +
  DATA: go_manager  TYPE REF TO cl_pt_arq_massapp_manager.
 +
 +
  DATA lt_guids    TYPE        ptarq_massapp_req_id_tab.
 +
  DATA ls_guid    TYPE LINE OF ptarq_massapp_req_id_tab.
 +
  DATA l_command  TYPE        ptreq_command.
 +
 +
  ls_guid = p_data-request_id.
 +
  APPEND ls_guid TO lt_guids.
 +
 +
  l_command = cl_pt_arq_massapp_manager=>c_status_approve_plan.
 +
 +
* initialize manager object
 +
  CREATE OBJECT go_manager
 +
    EXPORTING
 +
      iv_pers_no                  = p_data-aprobador
 +
    EXCEPTIONS
 +
      ex_invalid_personnel_number = 1
 +
      OTHERS                      = 2.
 +
 +
  IF sy-subrc = 1.
 +
    MESSAGE i011(hrtim_abs_req) WITH p_data-aprobador INTO p_message.
 +
*  Personnel number &1 does not exist
 +
    sy-subrc = 1.
 +
    RETURN.
 +
  ELSEIF sy-subrc = 2.
 +
    MESSAGE e016(hrtim_abs_req) INTO p_message.
 +
    sy-subrc = 2.
 +
    RETURN.
 +
*  Internal application error: Unable to run application
 +
  ENDIF.
 +
 +
  DATA(lt_requests) = go_manager->get_table( ) .
 +
  IF lt_requests IS INITIAL.
 +
    MESSAGE i098(hrtim_abs_req) INTO p_message.
 +
    p_subrc = 3.
 +
    RETURN.
 +
  ENDIF.
 +
 +
  go_manager->change_status(
 +
    EXPORTING
 +
      iv_command        = l_command
 +
      it_guids          = lt_guids ).
 +
 +
  DATA(l_answer) = go_manager->has_unsaved_changes( ).
 +
  IF l_answer = abap_true.
 +
    go_manager->save( ).
 +
*if there are unsaved changes then the save button is displayed
 +
    l_answer = go_manager->has_unsaved_changes( ).
 +
    IF l_answer = 'X'.
 +
      p_subrc = 4.
 +
    ELSE.
 +
      p_subrc = 0.
 +
    ENDIF.
 +
  ENDIF.
 +
ENDFORM.</nowiki>

Revision as of 15:28, 16 April 2020

Workflow Solicitud de Absentismo(Vacaciones)

tablas

  • PTREQ_HEADER - Cabecera de solicitud
  • PTREQ_ATTABSDATA - Datos de solicitud para presencias/absentismos
  • PTREQ_ACTOR - Participante solicitud
  • PTREQ_NOTICE - Nota de solicitud
  • PTREQ_ITEMS - Posiciones reclam.

programas

  • RPTARQMASS_APPROVAL - Solicitud de vacaciones: Autorización en masa
  • RPTARQDBVIEW - Visualizar notificaciones de absentismo (base de datos de solicitud)
  • RPTARQAPP - Solicitudes de absentismo: Autorizar documentos en su nombre
  • RPTARQPOST - Notificaciones de absentismo: Contabilizar

Ejemplos

Autorizar documentos en su nombre

*&---------------------------------------------------------------------*
*&      Form  search_for_action
*&---------------------------------------------------------------------*
*       copiado de RPTARQ_ADMINREP_EVENTS
*----------------------------------------------------------------------*
*      -->P_C_REQ_MANUAL_POST  text
*      <--P_EVENT_ALV  text
*----------------------------------------------------------------------*
FORM state_transition USING request_id TYPE tim_req_id
                            event      TYPE tim_req_xfer_event
                   CHANGING p_subrc type sy-subrc
                            p_message type bapiret2-message.

  DATA: application TYPE REF TO cl_pt_arq_application,      "#EC NEEDED
        request     TYPE REF TO if_pt_req_request,
        new_status  TYPE tim_req_status.
  CLASS: cl_pt_arq_application DEFINITION LOAD,
         if_pt_req_request     DEFINITION LOAD.

  application = cl_pt_arq_application=>get_instance( ).
  CALL FUNCTION 'ENQUEUE_EPTREQ'
    EXPORTING
      mode_ptreq_header = 'E'
      request_id        = request_id
    EXCEPTIONS
      foreign_lock      = 1
      system_failure    = 2
      OTHERS            = 3.
  IF sy-subrc <> 0.
    MESSAGE w058(hrtim_abs_req) INTO p_message.
    p_subrc = 1.
  ELSE.
* get request from guid
    CALL METHOD ca_pt_req_header=>agent->get_request
      EXPORTING
        im_request_id = request_id
      IMPORTING
        ex_request    = request.
*   Change state only for existing request object
    IF request IS BOUND.
* execute state transition
      CALL METHOD request->initiate_state_transition
        EXPORTING
          im_transfer_event = event
        IMPORTING
          ex_new_status     = new_status
          ex_ret_code       = p_subrc.
      IF new_status <> cl_pt_req_const=>c_reqstat_approved.
        p_message = 'Se ha producido un error durante la autorización'(E01).
        p_subrc = 3.
      else.
        p_subrc = 0.
      ENDIF.
    ELSE.
      p_message = 'Se ha producido un error durante la autorización'(E01).
      p_subrc = 2.
    ENDIF.
    CALL FUNCTION 'DEQUEUE_EPTREQ'
      EXPORTING
        request_id = request_id.
  ENDIF.
ENDFORM.                    " state_transition

Autorizar documentos en Nombre de una Persona (programa RPTARQMASS_APPROVAL)

FORM aprobar USING p_data TYPE ty_salida
          CHANGING p_subrc TYPE sy-subrc
                   p_message TYPE bapiret2-message.
  DATA: go_manager   TYPE REF TO cl_pt_arq_massapp_manager.

  DATA lt_guids    TYPE         ptarq_massapp_req_id_tab.
  DATA ls_guid     TYPE LINE OF ptarq_massapp_req_id_tab.
  DATA l_command  TYPE         ptreq_command.

  ls_guid = p_data-request_id.
  APPEND ls_guid TO lt_guids.

  l_command = cl_pt_arq_massapp_manager=>c_status_approve_plan.

* initialize manager object
  CREATE OBJECT go_manager
    EXPORTING
      iv_pers_no                  = p_data-aprobador
    EXCEPTIONS
      ex_invalid_personnel_number = 1
      OTHERS                      = 2.

  IF sy-subrc = 1.
    MESSAGE i011(hrtim_abs_req) WITH p_data-aprobador INTO p_message.
*   Personnel number &1 does not exist
    sy-subrc = 1.
    RETURN.
  ELSEIF sy-subrc = 2.
    MESSAGE e016(hrtim_abs_req) INTO p_message.
    sy-subrc = 2.
    RETURN.
*   Internal application error: Unable to run application
  ENDIF.

  DATA(lt_requests) = go_manager->get_table( ) .
  IF lt_requests IS INITIAL.
    MESSAGE i098(hrtim_abs_req) INTO p_message.
    p_subrc = 3.
    RETURN.
  ENDIF.

  go_manager->change_status(
    EXPORTING
      iv_command        = l_command
      it_guids          = lt_guids ).

  DATA(l_answer) = go_manager->has_unsaved_changes( ).
  IF l_answer = abap_true.
    go_manager->save( ).
*if there are unsaved changes then the save button is displayed
    l_answer = go_manager->has_unsaved_changes( ).
    IF l_answer = 'X'.
      p_subrc = 4.
    ELSE.
      p_subrc = 0.
    ENDIF.
  ENDIF.
ENDFORM.