Birthday app - sharathsym/SAP-Employee_summary GitHub Wiki

  • =====================================================================*
  • Intf.: ig_componentcontroller
  • Purp.: programming interface for access of this controller within
  • other controllers of the same component
  • controller: of
  • component: <zwd_hcm_bdays></zwd_hcm_bdays>
  • UDate: 20170606 133316
  • =====================================================================*
interface ig_componentcontroller.
  interfaces: ziwci_wd_hcm_bdays .
  constants:
    wdctx_context type string value `CONTEXT`.
  constants:
    wdctx_emp type string value `EMP`.
  types:
    Element_emp type HRPAD_S_PER_PHOTO,
    Elements_emp type 
       standard table of Element_emp
       with default key. "#EC NEEDED
  • @Returns: controller runtime interface


endinterface.

  • =====================================================================*
  • Intf.: if_componentcontroller
  • Purp.: programming interface for the application class of this
  • controller only
  • controller: of
  • component: <zwd_hcm_bdays></zwd_hcm_bdays>
  • UDate: 20170606 133316
  • =====================================================================*
interface if_componentcontroller.
  interfaces:
     IG_COMPONENTCONTROLLER.
 
  aliases:
    wdctx_context  for   IG_COMPONENTCONTROLLER~wdctx_context.
  aliases:
    wdctx_emp  for   IG_COMPONENTCONTROLLER~wdctx_emp.
  aliases:
    Element_emp   for   IG_COMPONENTCONTROLLER~Element_emp,
    Elements_emp  for   IG_COMPONENTCONTROLLER~Elements_emp.
    aliases: wd_get_api for IG_COMPONENTCONTROLLER~wd_get_api.
  • @Purpose: creates an action during runtime


endinterface.

  • =====================================================================*
  • Class: CL_COMPONENTCONTROLLER_Ctr
  • Purp.: definitions for application defined methods of controller
  • COMPONENTCONTROLLER (COMPONENT)
  • UDate: 20170606 133316
  • =====================================================================*
class CL_COMPONENTCONTROLLER_Ctr definition final.
  public section.
  interfaces:
    _IF_WDR_Tag_As_Application.
  methods Constructor
    importing
      Wd_This    type ref to IF_COMPONENTCONTROLLER
      Wd_Context type ref to If_Wd_Context_Node.
  • +-------------------------------------------------------------------+
  • | general methods |
  • +-------------------------------------------------------------------+
  methods WDDOAPPLICATIONSTATECHANGE
    importing
      STATE_CHANGE  type ref to If_Wd_Application_State_Change   ."#EC NEEDED
  methods WDDOBEFORENAVIGATION
    importing
      IS_CURRENT_ROOT  type Wdy_Boolean   ."#EC NEEDED
  methods WDDOEXIT
    importing
      REASON  type Wdr_Appl_Exit_Reason   ."#EC NEEDED
  methods WDDOINIT  ."#EC NEEDED
  methods WDDOPOSTPROCESSING
    importing
      IS_CURRENT_ROOT  type Wdy_Boolean   ."#EC NEEDED
  private section.
  • +-------------------------------------------------------------------+
  • | framework properties |
  • +-------------------------------------------------------------------+


endclass.

  • =====================================================================*
  • Class: CL_COMPONENTCONTROLLER_Ctr
  • Purp.: explicit definitions derived from application coding
  • (COMPONENT)
  • Notes: NOT intended for use outside of framework driven calls !!
  • UDate: 20170606 133316
  • =====================================================================*
class CL_COMPONENTCONTROLLER_Ctr implementation.



  • =======================
method Constructor. "#EC NEEDED
  • =======================
" Do NOT modify the Constructor, any changes will not be saved !
  Me->Wd_This =    Wd_This.
  Me->Wd_Context = Wd_Context.

endmethod.







  • +-------------------------------------------------------------------+
  • | general methods |
  • +-------------------------------------------------------------------+
method WDDOAPPLICATIONSTATECHANGE . "#EC NEEDED

endmethod.

method WDDOBEFORENAVIGATION . "#EC NEEDED

endmethod.

method WDDOEXIT . "#EC NEEDED

endmethod.

METHOD wddoinit .

    TYPES: BEGIN OF lty_bday,
            pernr TYPE pa0002-pernr,
            nachn TYPE pa0002-nachn,
            vorna TYPE pa0002-vorna,
            gbtag TYPE pa0002-gbtag,
           END OF lty_bday.
    DATA lo_nd_emp TYPE REF TO if_wd_context_node.
    DATA ls_emp TYPE wd_this->element_emp.
    data lv_date TYPE sy-datum.
    data lv_month TYPE n LENGTH 2.
    DATA lt_emp TYPE wd_this->elements_emp.
    DATA:lt_pernr TYPE TABLE OF lty_bday,
         lv_gbtag TYPE int1,
         lv_ltx TYPE t247-ltx,
         lv_url(4096) TYPE c.
    lv_date = sy-datum.
    SELECT SINGLE ltx
      FROM t247
      INTO lv_ltx
     WHERE spras = sy-langu
       AND mnr   = lv_date+4(2).
    IF sy-subrc NE 0.
      "Do nothing
    ENDIF.
    lv_month = sy-datum+4(2).
    SELECT b~pernr
           nachn
           vorna
           gbtag
      FROM pa0000 AS b INNER JOIN pa0002 AS a
      ON b~pernr = a~pernr
      INTO TABLE lt_pernr
     WHERE b~endda GE lv_date
       AND b~begda LE lv_date
       AND b~stat2 EQ '3'               "Active employee
       AND a~gbmon EQ lv_month
       AND a~GBTAG GE lv_date+6(2).
    IF sy-subrc NE 0.
      "Do nothing
    ENDIF.
    SORT lt_pernr BY pernr.
    DELETE ADJACENT DUPLICATES FROM lt_pernr COMPARING pernr.
    SORT lt_pernr BY gbtag.
    LOOP AT lt_pernr ASSIGNING FIELD-SYMBOL(&lt;fs_pernr&gt;&lt;/fs_pernr&gt;).
      lv_gbtag = &lt;fs_pernr&gt;&lt;/fs_pernr&gt;-gbtag.
      CASE &lt;fs_pernr&gt;&lt;/fs_pernr&gt;-gbtag.
        WHEN '1' OR '21' OR '31'.
          DATA(lv_dayformat) = 'st'.
        WHEN '2' OR '22'.
          lv_dayformat = 'nd'.
        WHEN '3' OR '23'.
          lv_dayformat = 'rd'.
        WHEN OTHERS.
          lv_dayformat = 'th'.
      ENDCASE.
      CALL FUNCTION 'HRWPC_RFC_EP_READ_PHOTO_URI'
        EXPORTING
          pernr            = &lt;fs_pernr&gt;&lt;/fs_pernr&gt;-pernr
          datum            = sy-datlo
        IMPORTING
          uri              = lv_url
        EXCEPTIONS
          not_supported    = 1
          nothing_found    = 2
          no_authorization = 3
          internal_error   = 4
          OTHERS           = 5.
      IF sy-subrc EQ 0.
        REPLACE '\' IN lv_url WITH '/'.
        ls_emp-image_url  = lv_url.
        ls_emp-object_key = |{ lv_ltx } { lv_gbtag }{ lv_dayformat }: { &lt;fs_pernr&gt;&lt;/fs_pernr&gt;-vorna } { &lt;fs_pernr&gt;&lt;/fs_pernr&gt;-nachn }|.
        APPEND ls_emp TO lt_emp.
      ELSE.
        ls_emp-image_url  = 'http://portaldev.ptabank.org:50000/PTALogon/layout/happy-birthday-white-cake-burning-candles-animated-gif.gif'.
        ls_emp-object_key = |{ lv_ltx } { lv_gbtag }{ lv_dayformat }: { &lt;fs_pernr&gt;&lt;/fs_pernr&gt;-vorna } { &lt;fs_pernr&gt;&lt;/fs_pernr&gt;-nachn }|.
        APPEND ls_emp TO lt_emp.
      ENDIF.
    ENDLOOP.
    IF lt_emp[] IS INITIAL.
      ls_emp-object_key = |No further birthdays for this month|.
      APPEND ls_emp TO lt_emp.
    ENDIF.
    lo_nd_emp = wd_context->get_child_node( name = wd_this->wdctx_emp ).
    lo_nd_emp->bind_table( new_items = lt_emp set_initial_elements = abap_false ).

ENDMETHOD.

method WDDOPOSTPROCESSING . "#EC NEEDED

endmethod.

endclass.

⚠️ **GitHub.com Fallback** ⚠️