  METHOD expert_routine.
*=== Segments ===

    FIELD-SYMBOLS:
      <SOURCE_FIELDS>    TYPE _ty_s_SC_1.

    DATA:
      RESULT_FIELDS      TYPE _ty_s_TG_1.

*$*$ begin of routine - insert your code only below this line        *-*
    ... "insert your code here

    DATA: lv_tabname_emp TYPE tabname,
          lv_tabname_per TYPE tabname,

          lv_date        TYPE dats,

          ls_source_fields LIKE LINE OF SOURCE_PACKAGE.

    CLEAR ls_source_fields.
    READ TABLE SOURCE_PACKAGE INDEX 1 INTO ls_source_fields.

* Employee
    CLEAR lv_tabname_emp.

    CONCATENATE '/BIC/AP' ls_source_fields-/bic/lsa_domai 'EMPD100' INTO
    lv_tabname_emp.
    CONDENSE lv_tabname_emp NO-GAPS.

* Person
    CLEAR lv_tabname_per.

    CONCATENATE '/BIC/AP' ls_source_fields-/bic/lsa_domai 'PERD100' INTO
    lv_tabname_per.
    CONDENSE lv_tabname_per NO-GAPS.

* Zusammengehrende Stamm- und Bewegungsdaten selektieren
* (erkennbar am Ladedatum!)
*** Optimierungspotential: Was passiert, wenn MD am 1., TD aber am 2.
*geladen werden?
*** --> Gltigkeitszeitrume fr MD einfhren

    FREE gt_employee.
    SELECT * FROM (lv_tabname_emp) INTO TABLE gt_employee
      WHERE /bic/lsa_ldate = ls_source_fields-/bic/lsa_ldate.

    FREE gt_person.
    SELECT * FROM (lv_tabname_per) INTO TABLE gt_person
      WHERE /bic/lsa_ldate = ls_source_fields-/bic/lsa_ldate.


*** Sourcepackage bearbeiten
    LOOP AT SOURCE_PACKAGE ASSIGNING <source_fields>.

* Monatsletzter bestimmen
      CONCATENATE <source_fields>-calmonth '01' INTO lv_date.

* Erhhe den Monat um 1
      ADD 31 TO lv_date.

* Ersetze den Tag durch 01
      lv_date+6(2) = '01'.

* Ziehe eins ab
      SUBTRACT 1 FROM lv_date.

      CLEAR RESULT_FIELDS.
      MOVE-CORRESPONDING <source_fields> TO RESULT_FIELDS.

      emp_select /bic/hrc_abkrs .
      per_select /bic/hrc_anred .
      emp_select /bic/hrc_ansvh .
      emp_select /bic/hrc_arbam .
      emp_select /bic/hrc_arber .
      emp_select /bic/hrc_atzmo .
      emp_select /bic/hrc_atzph .
      emp_select /bic/hrc_atzsr .
      emp_select /bic/hrc_aumit .
      emp_select /bic/hrc_auvor .
      emp_select /bic/hrc_avkz1 .
      per_select /bic/hrc_bland .
      per_select /bic/hrc_bldng .
      emp_select /bic/hrc_btrtl .
      emp_select /bic/hrc_bukrs .
      emp_select /bic/hrc_carea .
      per_select /bic/hrc_coxxx .
      emp_select /bic/hrc_ctbeg .
      emp_select /bic/hrc_ctedt .
      emp_select /bic/hrc_cttyp .
      per_select /bic/hrc_dsitz .
      emp_select /bic/hrc_dysch .
      emp_select /bic/hrc_eindt .
      emp_select /bic/hrc_eintr .
      emp_select /bic/hrc_empls .
      per_select /bic/hrc_entkm .
      emp_select /bic/hrc_falgk .
      emp_select /bic/hrc_falgr .
      per_select /bic/hrc_famdt .
      per_select /bic/hrc_famst .
      per_select /bic/hrc_floor .
      per_select /bic/hrc_fnamk .
      per_select /bic/hrc_fnamr .
      per_select /bic/hrc_gbdat .
      per_select /bic/hrc_gblnd .
      per_select /bic/hrc_gbort .
      per_select /bic/hrc_gesch .
      per_select /bic/hrc_gname .
      emp_select /bic/hrc_gsber .
      per_select /bic/hrc_hsnmr .
      per_select /bic/hrc_inits .
      emp_select /bic/hrc_juper .
      emp_select /bic/hrc_kdgf2 .
      emp_select /bic/hrc_kdgfr .
      emp_select /bic/hrc_kondt .
      emp_select /bic/hrc_konsl .
      emp_select /bic/hrc_kostl .
      emp_select /bic/hrc_kvbkl .
      emp_select /bic/hrc_kvgst .
      emp_select /bic/hrc_kvkz1 .
      emp_select /bic/hrc_kvsfr .
      per_select /bic/hrc_land1 .
      per_select /bic/hrc_lnamr .
      emp_select /bic/hrc_magrp .
      emp_select /bic/hrc_makrs .
      emp_select /bic/hrc_mitnr .
      per_select /bic/hrc_mname .
      emp_select /bic/hrc_mstbr .
      per_select /bic/hrc_nabik .
      per_select /bic/hrc_nabir .
      per_select /bic/hrc_nach2 .
      per_select /bic/hrc_nachn .
      per_select /bic/hrc_nachw .
      per_select /bic/hrc_namzu .
      per_select /bic/hrc_nati2 .
      per_select /bic/hrc_nati3 .
      per_select /bic/hrc_natio .
      emp_select /bic/hrc_nbtgk .
      per_select /bic/hrc_nickk .
      per_select /bic/hrc_nickr .
      emp_select /bic/hrc_orgeh .
      emp_select /bic/hrc_orgky .
      per_select /bic/hrc_ort01 .
      per_select /bic/hrc_ort02 .
      emp_select /bic/hrc_plans .
      per_select /bic/hrc_pstlz .
      emp_select /bic/hrc_pvbkl .
      emp_select /bic/hrc_pvkz1 .
      per_select /bic/hrc_rname .
      emp_select /bic/hrc_rvkz1 .
      emp_select /bic/hrc_rvnum .
      emp_select /bic/hrc_sacha .
      emp_select /bic/hrc_sachp .
      emp_select /bic/hrc_sachz .
      per_select /bic/hrc_sbadt .
      per_select /bic/hrc_sbart .
      per_select /bic/hrc_sbaud .
      per_select /bic/hrc_sbdst .
      per_select /bic/hrc_sbfak .
      per_select /bic/hrc_sbgru .
      per_select /bic/hrc_sbgsz .
      emp_select /bic/hrc_schkz .
      emp_select /bic/hrc_selkv .
      emp_select /bic/hrc_selpv .
      emp_select /bic/hrc_selrv .
      per_select /bic/hrc_state .
      emp_select /bic/hrc_stell .
      per_select /bic/hrc_stras .
      emp_select /bic/hrc_teilk .
      per_select /bic/hrc_titel .
      per_select /bic/hrc_titl2 .
      emp_select /bic/hrc_trfar .
      emp_select /bic/hrc_trfgb .
      emp_select /bic/hrc_trfgr .
      emp_select /bic/hrc_trfst .
      per_select /bic/hrc_vname .
      per_select /bic/hrc_vors2 .
      per_select /bic/hrc_vorsw .
      per_select /bic/hrc_wegdt .
      emp_select /bic/hrc_werks .
      per_select /bic/hrc_wkwng .
      emp_select /bic/hrc_wttkl .
      emp_select /bic/hrc_wweek .
      emp_select /bic/hrc_zterf .
      emp_select /bic/hrc_zuska .
      emp_select /bic/hre_kgzzh .
      emp_select /bic/hre_lfzzh .
      emp_select /bic/hre_prbeh .
      emp_select /bic/hrk_arbst .
      emp_select /bic/hrk_atzaz .
      emp_select /bic/hrk_bsgrd .
      emp_select /bic/hrk_empct .
      emp_select /bic/hrk_jrstd .
      emp_select /bic/hrk_kgzfr .
      emp_select /bic/hrk_lfzfr .
      emp_select /bic/hrk_maxja .
      emp_select /bic/hrk_maxmo .
      emp_select /bic/hrk_maxta .
      emp_select /bic/hrk_maxwo .
      emp_select /bic/hrk_minja .
      emp_select /bic/hrk_minmo .
      emp_select /bic/hrk_minta .
      emp_select /bic/hrk_minwo .
      emp_select /bic/hrk_mostd .
      emp_select /bic/hrk_prbzt .
      per_select /bic/hrk_sbpro .
      emp_select /bic/hrk_wkwdy .
      emp_select /bic/hrk_wostd .
      emp_select /bic/lsa_domai .
      emp_select /bic/lsa_ldate .
      emp_select /bic/lsa_lstmp .
      emp_select /bic/lsa_ssyst .
      per_select /bic/noc_count .

      APPEND RESULT_FIELDS TO RESULT_PACKAGE.


    ENDLOOP.


*$*$ end of routine - insert your code only before this line         *-*
  ENDMETHOD.                    "expert_routine