PK Tool
************************************************************************
**************************** *******************************
*************************** MREGOTZ ******************************
**************************** *******************************
************************************************************************
*&H
*&H PROGRAMMNAME : ZHR_PK
*&H TRANSAKTIONSCODE : ZHR_PK
*&H PROGRAMMTITEL : PK Personalschnittstelle (PSS)
*&H ZWECK : Es werden alle Daten der Versicherten geliefert
*&H an die PK (nicht nur die Mutationen).
*&H AUTOR : Regotz Michel
*&H DATUM : 01.10.2016
*&H SAP-MODUL : HR
*&H
*&H Company/Department : Swisscom AG
*&H Phone : +41 79 322 04 86 (Mobil)
*&H E-Mail : Michel.Regotz@Swisscom.ch
*&H
************************************************************************
*&D
*&D Beschreibung : Mit der Schnittstelle werden verschiedene
*&D Recordarten übermittelt.
*&D Es werden alle Daten der Versicherten geliefert
*&D an die PK (nicht nur die Mutationen).
*&D Mit der KOPFZEILE (erste Zeile im File) beginnt
*&D und mit der FUSSZEILE (letzte Zeile im File) endet
*&D die Schnittstellendatei.Jedes Schnittstellenfile
*&D beginnt zwingend mit der Kopfzeile. Die
*&D Datenstruktur ist fix vorgegeben.
*&D Eintritte/Mutationen und Austritt inkl. der
*&D Stammdaten werden mit dieser Recordart übermittelt.
*&D Ehegatten und Heiratsdatum können mit dieser
*&D Recordart übermittelt werden. Die Postadresse
*&D wird mit dieser Recordart übermittelt.
*&D Die Recordart Grundlagen enthält die Löhne,
*&D Schichtzulagen und Beschäftigungsgrade.
*&D
*&D --------------------------------------------------------------------
*&D Leistung : PK Personalschnittstelle (PSS)
*&D --------------------------------------------------------------------
*&D Tabellen :
*&D
*&D Struktur :
*&D --------------------------------------------------------------------
*&D Verarbeitung : <Daten holen>
*&D <Daten konvertieren>
*&D <TXT erstellen/runterladen>
*&D <Erstellung Fehlerliste>
*&D <ALV File Inhalte>
************************************************************************
*&C Change history :
*&C --------------------------------------------------------------------
*&C Developer | Date | Description
*&C --------------------------------------------------------------------
*&C <Name> | <Date> | <Description>
*&C --------------------------------------------------------------------
*&C <Name> | <Date> | <Description>
*&C --------------------------------------------------------------------
*&C <Name> | <Date> | <Description>
*&C --------------------------------------------------------------------
*&C <Name> | <Date> | <Description>
************************************************************************
REPORT zhr_pk MESSAGE-ID zhr_pk.
"=======================================================================
" Datendeklaration für die Buttons steuern zu können
"=======================================================================
*-----------------------------------------------------------------------
* Beginn Datendeklarationen
*-----------------------------------------------------------------------
" Damit man die Buttons steuern kann.
*-----------------------------------------------------------------------
TABLES: sscrfields.
"=======================================================================
" Datendeklaration für GET PERAS
"=======================================================================
*-----------------------------------------------------------------------
* Beginn Datendeklarationen
*-----------------------------------------------------------------------
" Damit GET_PERAS funktioniert muss unter Eigeschaften noch die Logische
" Datenbank PNPCE angegeben werden.
*-----------------------------------------------------------------------
NODES: person, group, peras.
TABLES: pernr.
INFOTYPES: 0000, 0001, 0002, 0006, 0007, 0008, 0016, 0017, 0014, 0036, 0041, 0105.
DATA: gf_datum TYPE sy-datum.
"=======================================================================
" Datendeklaration für den Dateinamen
"=======================================================================
*-----------------------------------------------------------------------
* Beginn Datendeklarationen
*-----------------------------------------------------------------------
" Damit man den Filenamen und Datei Pfad hat.
*-----------------------------------------------------------------------
DATA: gf_path TYPE string.
DATA: gf_name TYPE string.
"=======================================================================
" Datendeklaration Kopf Data und Fusszeile
"=======================================================================
*-----------------------------------------------------------------------
* Beginn Datendeklarationen
*-----------------------------------------------------------------------
* Datendeklaration für die Daten sammlung und gewinnung.
* Bis zur übergabe an das TXT File
*-----------------------------------------------------------------------
TYPES: BEGIN OF gty_kopf,
kopfz TYPE c LENGTH 10,
erdat TYPE c LENGTH 10,
END OF gty_kopf.
TYPES: BEGIN OF gty_pss_ver,
recar TYPE c LENGTH 3,
perns TYPE c LENGTH 8,
pernr TYPE c LENGTH 11,
nachn TYPE c LENGTH 25,
vorna TYPE c LENGTH 25,
gesch TYPE c LENGTH 3,
gbpas TYPE c LENGTH 10,
sprsl TYPE c LENGTH 3,
famst TYPE c LENGTH 3,
gespu TYPE c LENGTH 3,
perka TYPE c LENGTH 3,
beruf TYPE c LENGTH 4,
mutda TYPE c LENGTH 10,
zusid TYPE c LENGTH 3,
zusnr TYPE c LENGTH 4,
regid TYPE c LENGTH 6,
pkdat TYPE c LENGTH 10,
fired TYPE c LENGTH 10,
massg TYPE c LENGTH 3,
perid TYPE c LENGTH 6,
werks TYPE c LENGTH 6,
einbe TYPE c LENGTH 10,
ahvnr TYPE c LENGTH 11,
zusda TYPE c LENGTH 10,
nahvn TYPE c LENGTH 13,
END OF gty_pss_ver.
TYPES: BEGIN OF gty_pss_ehe,
reart TYPE c LENGTH 3,
perni TYPE c LENGTH 8,
famdt TYPE c LENGTH 10,
famst TYPE c LENGTH 3,
famna TYPE c LENGTH 25,
famvo TYPE c LENGTH 25,
fgbdt TYPE c LENGTH 10,
dstod TYPE c LENGTH 10,
fasex TYPE c LENGTH 3,
END OF gty_pss_ehe.
TYPES: BEGIN OF gty_pss_adr,
recat TYPE c LENGTH 3,
perna TYPE c LENGTH 8,
adres TYPE c LENGTH 3,
anred TYPE c LENGTH 3,
stras TYPE c LENGTH 35,
adre1 TYPE c LENGTH 35,
adre2 TYPE c LENGTH 35,
pstlz TYPE c LENGTH 6,
ort01 TYPE c LENGTH 25,
state TYPE c LENGTH 2,
land1 TYPE c LENGTH 4,
usrty TYPE c LENGTH 18,
faxnr TYPE c LENGTH 18,
usrid TYPE c LENGTH 18,
titel TYPE c LENGTH 25,
mit01 TYPE c LENGTH 25,
mit02 TYPE c LENGTH 25,
mit03 TYPE c LENGTH 25,
mit04 TYPE c LENGTH 25,
END OF gty_pss_adr.
TYPES: BEGIN OF gty_pss_gru,
recoa TYPE c LENGTH 3,
recoi TYPE c LENGTH 8,
begda TYPE c LENGTH 10,
endda TYPE c LENGTH 10,
pktyp TYPE c LENGTH 3,
ansal TYPE c LENGTH 12,
regli TYPE c LENGTH 6,
mutad TYPE c LENGTH 10,
bsgrd TYPE c LENGTH 6,
ivgra TYPE c LENGTH 6,
END OF gty_pss_gru.
TYPES: BEGIN OF gty_fuss,
fussz TYPE c LENGTH 10,
anzre TYPE c LENGTH 5,
END OF gty_fuss.
TYPES: BEGIN OF gty_data,
string TYPE string,
END OF gty_data.
* Data gs_returncs TYPE bapiret2.
DATA: gt_kopf TYPE TABLE OF gty_kopf,
gs_kopf TYPE gty_kopf,
gt_pss_ver TYPE TABLE OF gty_pss_ver,
gs_pss_ver TYPE gty_pss_ver,
gt_pss_ehe TYPE TABLE OF gty_pss_ehe,
gs_pss_ehe TYPE gty_pss_ehe,
gt_pss_adr TYPE TABLE OF gty_pss_adr,
gs_pss_adr TYPE gty_pss_adr,
gt_pss_gru TYPE TABLE OF gty_pss_gru,
gs_pss_gru TYPE gty_pss_gru,
gt_fuss TYPE TABLE OF gty_fuss,
gs_fuss TYPE gty_fuss,
gt_data TYPE TABLE OF gty_data,
gs_data TYPE gty_data,
gf_string TYPE c LENGTH 400.
DATA: gf_fgbdt TYPE sy-datum.
"=======================================================================
" Datendeklaration für ALV
"=======================================================================
*-----------------------------------------------------------------------
* Beginn Datendeklarationen fuer den ALV
*-----------------------------------------------------------------------
* Kopieren Sie diesen Block zu den Datendeklarationen des ABAP-Programms
* Auch die Handler-Definition fuer Doppeklick ist eine Deklaration
*-----------------------------------------------------------------------
DATA go_alv TYPE REF TO cl_salv_table.
DATA go_functions TYPE REF TO cl_salv_functions_list.
DATA: go_columns TYPE REF TO cl_salv_columns_table,
go_column TYPE REF TO cl_salv_column_table.
DATA go_display TYPE REF TO cl_salv_display_settings.
DATA go_events TYPE REF TO cl_salv_events_table.
DATA: go_layout TYPE REF TO cl_salv_layout,
gf_variant TYPE slis_vari,
gs_key TYPE salv_s_layout_key.
"=======================================================================
" Selektionsbildschirm
"=======================================================================
*-----------------------------------------------------------------------
* Beginn deklaration des Selektionsbildschirmes
*-----------------------------------------------------------------------
* Hier wird der Selektionsbildschirm erstellt
*-----------------------------------------------------------------------
" Block zum auswählen des Pfades und aktivieren des Test Buttons
SELECTION-SCREEN BEGIN OF BLOCK 10 WITH FRAME TITLE text-010.
PARAMETERS: pa_file TYPE rlgrap-filename. "DEFAULT 'C:\xXx\XLSEINSPIELEN.xls'.
PARAMETERS: pa_test AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK 10.
" Block für die Buttons
SELECTION-SCREEN BEGIN OF BLOCK 20 WITH FRAME TITLE text-020.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN PUSHBUTTON /3(18) get_prot USER-COMMAND prot.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN PUSHBUTTON /3(18) get_doku USER-COMMAND doku.
SELECTION-SCREEN END OF BLOCK 20.
"=======================================================================
" At Selection Screen Output
"=======================================================================
AT SELECTION-SCREEN OUTPUT. "PBO
"Desktop Pfad holen
IF pa_file IS INITIAL.
PERFORM pathname.
ENDIF.
" Checkbox ausblenden
* PERFORM nodisplay.
"=======================================================================
" AT SELECTION SCREEN
"=======================================================================
AT SELECTION-SCREEN. "PAI
" Buttons Anweisen was Sie zu tun haben
PERFORM button.
"=======================================================================
" AT SELECTION SCREEN ON VAlUE REQUEST FOR
"=======================================================================
AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_file.
" Ermöglichen das man den Pfad über ein Dialogfenseter auswählen kann.
PERFORM selectfile.
"=======================================================================
" START OF SELECTION
"=======================================================================
INITIALIZATION.
" Beschriften der Buttons inklusive Logo
CONCATENATE '@DR@' text-pro INTO get_prot SEPARATED BY space.
CONCATENATE '@AR@' text-dok INTO get_doku SEPARATED BY space.
START-OF-SELECTION.
"The report only runs with ONE specific date:
gf_datum = pn-endda.
"Sammeln von Kopf PSS Fuss Daten und diese in eine Transparente Tabelle schreiben.
GET peras.
PERFORM add_pss_ver.
PERFORM add_pss_ehe.
PERFORM add_pss_adr.
PERFORM add_pss_gru.
PERFORM sort.
END-OF-SELECTION.
PERFORM add_fuss.
PERFORM add_kopf.
IF pa_test = 'X'.
"Keine TXT Ausgabe nur ALV anzeigen.
PERFORM alv_txt.
ELSE.
"Text File auf Desktop speichern
PERFORM save_data."Im Testfall mache nichts
ENDIF.
* "Fehlerprotokoll im ALV anzeigen
* PERFORM alv_error.
*&---------------------------------------------------------------------*
*& Form PATHNAME
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM pathname .
"Desktop suchen
CALL METHOD cl_gui_frontend_services=>get_desktop_directory
CHANGING
desktop_directory = gf_path
EXCEPTIONS
cntl_error = 1.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
"Desktop name holen
CALL METHOD cl_gui_cfw=>update_view.
"Pfad in Parameter schreiben
pa_file = gf_path.
"Dateiname hinzufüge
CONCATENATE '\' sy-datum '_' sy-uzeit '_' 'PK PSS.txt' INTO gf_name.
CONCATENATE pa_file '\' gf_name INTO pa_file.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form SELECTFILE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM selectfile .
DATA: lf_filename TYPE string,
lf_fullpath TYPE string,
lf_path TYPE string,
lf_result TYPE i.
* Anzeigen eines Dialogfensters zum speichern.
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
window_title = 'REGOTZ '
default_extension = 'TXT'
default_file_name = gf_name
initial_directory = gf_path "c:\temp\'
CHANGING
filename = lf_filename
path = lf_path
fullpath = lf_fullpath
user_action = lf_result.
"Pfad speichern
pa_file = lf_fullpath.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form BUTTON
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM button .
" Buttons anweisen was Sie zu tun haben.
IF sscrfields-ucomm = 'PROT'.
" Protokoll aufrufen
* SUBMIT zmm_upd_po_delivery_date_prot AND RETURN VIA SELECTION-SCREEN..
ELSEIF sscrfields-ucomm = 'DOKU'.
" Doku anzeigen
CALL FUNCTION 'RS_TOOL_ACCESS'
EXPORTING
operation = 'DOCS'
object_name = 'ZMM_UPD_PO_DELIVERY_DATE'
object_type = 'PROG'
EXCEPTIONS
not_executed = 1
invalid_object_type = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form ADD_KOPF
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM add_kopf .
"=======================================================================
" Kopfdaten sammeln
"=======================================================================
" Feld Kopfzeile wird befüllt
gs_kopf-kopfz = 'KOPFZEILE:'.
" Feld Erstellungsdatum wird befüllt
CONCATENATE sy-datum+6(2) '.' sy-datum+4(2) '.' sy-datum(4) INTO gs_kopf-erdat.
" Zeile wird in ein Charakterfeld eingefügt
gf_string = gs_kopf-kopfz.
gf_string+10(10) = gs_kopf-erdat.
" Charakterfeld wird in einen String verschoben
gs_data-string = gf_string.
" Der Ausgabe Tabelle wird die String Zeile hinzugefügt
INSERT gs_data INTO gt_data INDEX 1.
" Initialisieren
CLEAR: gs_data-string, gf_string.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form ADD_PSS_VER
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM add_pss_ver .
"=======================================================================
" PSSdaten des Versicherten Datendeklaration
"=======================================================================
DATA: lf_dar TYPE datar.
DATA: lf_dat TYPE dardt.
"=======================================================================
" PSSdaten des Versicherten sammeln
"=======================================================================
" Feld Kopfzeile wird befüllt
gs_pss_ver-recar = '002'.
" Feld Vers_Id (P000-PERNR)
gs_pss_ver-perns = pernr-pernr.
SHIFT gs_pss_ver-perns LEFT DELETING LEADING '0'.
SHIFT gs_pss_ver-perns RIGHT DELETING TRAILING space.
" Feld Personal_Id (P000-PERNR)
gs_pss_ver-pernr = pernr-pernr.
SHIFT gs_pss_ver-pernr LEFT DELETING LEADING '0'.
SHIFT gs_pss_ver-pernr RIGHT DELETING TRAILING space.
"Zugriff IT 0002
PROVIDE * FROM p0002 BETWEEN gf_datum AND gf_datum. "-----------------**
" Feld Nachname (P0002-NACHN)
gs_pss_ver-nachn = p0002-nachn.
" Feld Vorname (P0002-VORNA)
gs_pss_ver-vorna = p0002-vorna.
" Feld Geschlecht (P0002-GESCH)
IF p0002-gesch = 1.
gs_pss_ver-gesch = '000'.
ELSEIF p0002-gesch = 2.
gs_pss_ver-gesch = '001'.
ELSE.
gs_pss_ver-gesch = ''.
ENDIF.
" Feld Geburtstag (P0002-GBPAS)
CONCATENATE p0002-gbpas+6(2) '.' p0002-gbpas+4(2) '.' p0002-gbpas(4) INTO gs_pss_ver-gbpas.
" Feld Sprache (P002-SPRSL)
IF p0002-sprsl = 'DE'.
gs_pss_ver-sprsl = '001'.
ELSEIF p0002-sprsl = 'FR'.
gs_pss_ver-sprsl = '002'.
ELSEIF p0002-sprsl = 'IT'.
gs_pss_ver-sprsl = '003'.
ELSE.
gs_pss_ver-sprsl = ''.
ENDIF.
" Feld Zivilstand (P0002 FMAST)
CASE p0002-famst.
WHEN '0'.
gs_pss_ver-famst = '000'.
WHEN '1'.
gs_pss_ver-famst = '001'.
WHEN '2'.
gs_pss_ver-famst = '003'.
WHEN '3'.
gs_pss_ver-famst = '002'.
WHEN '4'.
gs_pss_ver-famst = '000'.
WHEN '5'.
gs_pss_ver-famst = '004'.
WHEN '9'.
gs_pss_ver-famst = '006'.
WHEN OTHERS.
gs_pss_ver-famst = ''.
ENDCASE.
ENDPROVIDE. "---------------------------------------------------------**
" Feld Gesundheitsprüfung
gs_pss_ver-gespu = '000'.
" Feld Personalkategorie
gs_pss_ver-perka = '000'.
" Feld Beruf
gs_pss_ver-beruf = '0000'.
" Feld Mutationdatum
gs_pss_ver-mutda = '00.00.0000'.
" Feld Zusatzinformation
gs_pss_ver-zusid = '000'.
" Feld Zusatznummer
gs_pss_ver-zusnr = ' '.
" Feld Reglement_Id
gs_pss_ver-regid = '021000'.
" Zugrif IT 0041
PROVIDE * FROM p0041 BETWEEN gf_datum AND gf_datum. "-----------------**
" Lesen der Datumsarten
DO 12 TIMES VARYING lf_dar FROM p0041-dar01 NEXT p0041-dar02 RANGE p0041
VARYING lf_dat FROM p0041-dat01 NEXT p0041-dat02 RANGE p0041.
IF lf_dar = 'EP'.
" Feld Eintrittsdatum Pensionskasse (P0041-DATAR = EP)
gs_pss_ver-pkdat = lf_dat.
ELSEIF lf_dar = 'EE'.
" Feld Eintrittsdatum_Betrieb (P0041-DATAR = EE)
gs_pss_ver-einbe = lf_dat.
ENDIF.
CLEAR: lf_dat, lf_dar.
ENDDO.
" Feld Austrittsdatum
CALL FUNCTION 'HR_LEAVING_DATE'
EXPORTING
persnr = pernr-pernr
* RCLAS =
begda = gf_datum
endda = gf_datum
* VARKY =
* INITIALIZE_PS_BUFFER = 'X'
IMPORTING
leavingdate = lf_dat
* TABLES
* LEAVING_DATES =
EXCEPTIONS
leaving_date_not_found = 1
pernr_not_assigned = 2
OTHERS = 3.
IF sy-subrc = 0.
CONCATENATE lf_dat+6(2) '.' lf_dat+4(2) '.' lf_dat(4)
INTO gs_pss_ver-fired.
ELSE.
gs_pss_ver-fired = ''.
ENDIF.
CLEAR lf_dat.
ENDPROVIDE. "---------------------------------------------------------**
" Zugrif IT 0000
PROVIDE * FROM p0000 BETWEEN gf_datum AND gf_datum. "-----------------**
" Feld Austrittsgrund (P0000-MASSN / P0000-MASSG)
IF p0000-massn = 'C4'.
CASE p0000-massg.
WHEN '32'.
gs_pss_ver-massg = '006'.
WHEN '33'.
gs_pss_ver-massg = '002'.
WHEN OTHERS.
gs_pss_ver-massg = ''.
ENDCASE.
ENDIF.
ENDPROVIDE. "---------------------------------------------------------**
" Feld Personalteilbereich_ID
gs_pss_ver-perid = '000000'.
" Zugrif IT 0001
PROVIDE * FROM p0001 BETWEEN gf_datum AND gf_datum. "-----------------**
" Feld Betrieb_Id (P0001-WERKS)
CASE p0001-werks.
WHEN '1000'.
gs_pss_ver-werks = '21150'.
WHEN '1001'.
gs_pss_ver-werks = '21201'.
WHEN '1002'.
gs_pss_ver-werks = '21402'.
WHEN '1003'.
gs_pss_ver-werks = '21301'.
WHEN '1004'.
gs_pss_ver-werks = '21801'.
WHEN '1005'.
gs_pss_ver-werks = '21701'.
WHEN '1006'.
gs_pss_ver-werks = '21202'.
WHEN '1007'.
gs_pss_ver-werks = '21302'.
WHEN '1009'.
gs_pss_ver-werks = '21401'.
WHEN '1010'.
gs_pss_ver-werks = '21900'.
WHEN '1011'.
gs_pss_ver-werks = '21501'.
WHEN '1012'.
gs_pss_ver-werks = '21601'.
WHEN '1014'.
gs_pss_ver-werks = '21905'.
WHEN '1015'.
gs_pss_ver-werks = '21915'.
WHEN '1016'.
gs_pss_ver-werks = '21750'.
WHEN OTHERS.
gs_pss_ver-werks = ''.
ENDCASE.
ENDPROVIDE. "---------------------------------------------------------**
" Zugrif IT 0001
PROVIDE * FROM p0001 BETWEEN gf_datum AND gf_datum. "-----------------**
" Feld AHV_Id (P0036-AHVNR)
gs_pss_ver-ahvnr = p0036-ahvnr.
" Feld SozVers_Id (P0036-NAHVN)
gs_pss_ver-nahvn = p0036-nahvn.
ENDPROVIDE. "---------------------------------------------------------**
" Feld Zusatzdatum
gs_pss_ver-zusda = ' '.
" Zeile wird in ein Charakterfeld eingefügt
gf_string = gs_pss_ver-recar.
" Tabelle gt_pss wird befüllt
APPEND gs_pss_ver TO gt_pss_ver.
"========================================================================="
" Zeile wird in ein Charakterfeld eingefügt
gf_string(3) = gs_pss_ver-recar.
gf_string+3(8) = gs_pss_ver-perns.
gf_string+11(11) = gs_pss_ver-pernr.
gf_string+22(25) = gs_pss_ver-nachn.
gf_string+47(25) = gs_pss_ver-vorna.
gf_string+72(3) = gs_pss_ver-gesch.
gf_string+75(10) = gs_pss_ver-gbpas.
gf_string+85(3) = gs_pss_ver-sprsl.
gf_string+88(3) = gs_pss_ver-famst.
gf_string+91(3) = gs_pss_ver-gespu.
gf_string+94(3) = gs_pss_ver-perka.
gf_string+97(4) = gs_pss_ver-beruf.
gf_string+101(10) = gs_pss_ver-mutda.
gf_string+111(3) = gs_pss_ver-zusid.
gf_string+114(4) = gs_pss_ver-zusnr.
gf_string+118(6) = gs_pss_ver-regid.
gf_string+124(10) = gs_pss_ver-pkdat.
gf_string+134(10) = gs_pss_ver-fired.
gf_string+144(3) = gs_pss_ver-massg.
gf_string+147(6) = gs_pss_ver-perid.
gf_string+153(6) = gs_pss_ver-werks.
gf_string+159(10) = gs_pss_ver-einbe.
gf_string+169(11) = gs_pss_ver-ahvnr.
gf_string+180(10) = gs_pss_ver-zusda.
gf_string+190(13) = gs_pss_ver-nahvn.
" Charakterfeld wird in einen String verschoben
gs_data-string = gf_string.
" Der Ausgabe Tabelle wird die String Zeile hinzugefügt
APPEND gs_data TO gt_data.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form ADD_PSS_EHE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM add_pss_ehe .
" Feld Recordart
gs_pss_ehe-reart = '202'.
" Feld Personal_Id
gs_pss_ehe-perni = pernr-pernr.
SHIFT gs_pss_ehe-perni LEFT DELETING LEADING '0'.
SHIFT gs_pss_ehe-perni RIGHT DELETING TRAILING space.
" Zugrif IT 0002
PROVIDE * FROM p0002 BETWEEN gf_datum AND gf_datum. "-----------------**
" Feld Heiratsdatum (P0002-FAMDT) Datum nur Eintragen wenn Zivilstand Verheiratet.
IF p0002-famst = '1'.
CONCATENATE p0002-famdt+6(2) '.' p0002-famdt+4(2) '.' p0002-famdt(4)
INTO gs_pss_ehe-famdt.
ELSE.
gs_pss_ehe-famdt = ''.
ENDIF.
" Feld Zivilstand (P0002-FAMST)
CASE p0002-famst.
WHEN 0. " ledig
gs_pss_ehe-famst = '0'.
WHEN 1. " verheiratet
gs_pss_ehe-famst = '1'.
WHEN 2. " verwitwert
gs_pss_ehe-famst = '3'.
WHEN 3. " geschieden
gs_pss_ehe-famst = '2'.
WHEN 4. " nv
gs_pss_ehe-famst = '0'.
WHEN 5. " getrennt
gs_pss_ehe-famst = '4'.
WHEN 9. " regPar
gs_pss_ehe-famst = '6'.
WHEN OTHERS.
gs_pss_ehe-famst = ''.
ENDCASE.
" Feld Datum_Scheidung_Tod
" Scheidung
CASE p0002-famst.
WHEN 3. " geschieden
CONCATENATE p0002-famdt+6(2) '.' p0002-famdt+4(2) '.' p0002-famdt(4)
INTO gs_pss_ehe-dstod.
ENDCASE.
ENDPROVIDE. "---------------------------------------------------------**
" Zugrif IT 0000
PROVIDE * FROM p0000 BETWEEN gf_datum AND gf_datum. "-----------------**
" Feld Datum_Scheidung_Tod (P0000-MASSN / P0000-MASSG)
" Tod
IF p0000-massn = 'C4'.
CASE p0000-massg.
WHEN '33'.
CONCATENATE p0002-begda+6(2) '.' p0002-begda+4(2) '.' p0002-begda(4)
INTO gs_pss_ehe-dstod .
ENDCASE.
ENDIF.
ENDPROVIDE. "---------------------------------------------------------**
* " Zugrif IT 0021
*PROVIDE FIELDS * FROM p0021 INTO gs_p0021 VALID flag bounds in and ind
* where p0021-subty = '1' BETWEEN gf_datum AND gf_datum .
* ENDPROVIDE. "---------------------------------------------------------**
" Feld EName (PA0021-fanam)
" Feld Vorname (PA0021-favor)
" Feld Geschlecht_Id (PA0021-fasex)
SELECT SINGLE fanam favor fgbdt fasex FROM pa0021
INTO (gs_pss_ehe-famna, gs_pss_ehe-famvo, gf_fgbdt, gs_pss_ehe-fasex)
WHERE pernr = pernr-pernr AND
" OBJPS = space AND "Objektidentikfikation Falls 2 Sätze mit gleichen Primärkey existieren
sprps = space AND "Sperkennzeichen
subty = '1' AND
begda <= gf_datum AND
endda >= gf_datum.
" Feld Geburtsdatum (PA0021-fgbdt)
CONCATENATE gf_fgbdt+6(2) '.' gf_fgbdt+4(2) '.' gf_fgbdt(4)
INTO gs_pss_ehe-fgbdt.
"========================================================================="
" Zeile wird in ein Charakterfeld eingefügt
gf_string(3) = gs_pss_ehe-reart.
gf_string+3(8) = gs_pss_ehe-perni.
gf_string+11(10) = gs_pss_ehe-famdt.
gf_string+21(3) = gs_pss_ehe-famst.
gf_string+24(25) = gs_pss_ehe-famna.
gf_string+49(25) = gs_pss_ehe-famvo.
gf_string+74(10) = gs_pss_ehe-fgbdt.
gf_string+84(10) = gs_pss_ehe-dstod.
gf_string+94(3) = gs_pss_ehe-fasex .
" Charakterfeld wird in einen String verschoben
gs_data-string = gf_string.
" Der Ausgabe Tabelle wird die String Zeile hinzugefügt
APPEND gs_data TO gt_data.
" Initialisieren
CLEAR: gs_data-string, gf_string.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form ADD_PSS_ADR
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM add_pss_adr .
" Feld Recordart
gs_pss_adr-recat = '302'.
" Feld Personal_Id
gs_pss_adr-perna = pernr-pernr.
SHIFT gs_pss_adr-perna LEFT DELETING LEADING '0'.
SHIFT gs_pss_adr-perna RIGHT DELETING TRAILING space.
" Feld Adressart
gs_pss_adr-adres = ' 0'.
" Zugrif IT 0002
PROVIDE * FROM p0002 BETWEEN gf_datum AND gf_datum. "-----------------**
" Feld Anrede
IF p0002-anred = 1.
gs_pss_adr-anred = ' 0'.
ELSE.
gs_pss_adr-anred = ' 1'.
ENDIF.
" Feld Titel
gs_pss_adr-titel = p0002-titel.
ENDPROVIDE. "---------------------------------------------------------**
" Zugrif IT 0006
PROVIDE * FROM p0006 BETWEEN gf_datum AND gf_datum. "-----------------**
" Feld Adresszeile 1
gs_pss_adr-stras = p0006-stras.
" Feld Adresszeile 2
gs_pss_adr-adre1 = ''.
" Feld Adresszeile 3
gs_pss_adr-adre2 = ''.
" Feld PLZ
gs_pss_adr-pstlz = p0006-pstlz.
" Feld Ort
gs_pss_adr-ort01 = p0006-ort01.
" Feld Kanton
gs_pss_adr-state = p0006-state.
" Feld Land
gs_pss_adr-land1 = p0006-land1.
ENDPROVIDE. "---------------------------------------------------------**
PROVIDE * FROM p0105 BETWEEN pn-begda AND pn-endda."------------------**
CHECK: p0105-subty = '9015'.
" Feld Tel_Nummer
gs_pss_adr-usrty = p0105-usrid.
" Feld Fax_Nummer
gs_pss_adr-faxnr = ''.
ENDPROVIDE. "---------------------------------------------------------**
PROVIDE * FROM p0105 BETWEEN pn-begda AND pn-endda."------------------**
CHECK: p0105-subty = '9030'.
" Feld EMail
gs_pss_adr-usrid = p0105-usrid.
ENDPROVIDE. "---------------------------------------------------------**
" Feld Mitteilung_1
gs_pss_adr-mit01 = ''.
" Feld Mitteilung_2
gs_pss_adr-mit02 = ''.
" Feld Mitteilung_3
gs_pss_adr-mit03 = ''.
" Feld Mitteilung_4
gs_pss_adr-mit04 = ''.
"========================================================================="
" Zeile wird in ein Charakterfeld eingefügt
gf_string(3) = gs_pss_adr-recat.
gf_string+3(8) = gs_pss_adr-perna.
gf_string+11(3) = gs_pss_adr-adres.
gf_string+14(3) = gs_pss_adr-anred.
gf_string+17(35) = gs_pss_adr-stras.
gf_string+52(35) = gs_pss_adr-adre1.
gf_string+87(35) = gs_pss_adr-adre2.
gf_string+122(6) = gs_pss_adr-pstlz.
gf_string+128(25) = gs_pss_adr-ort01.
gf_string+153(2) = gs_pss_adr-state.
gf_string+155(4) = gs_pss_adr-land1.
gf_string+159(18) = gs_pss_adr-usrty.
gf_string+177(18) = gs_pss_adr-faxnr.
gf_string+195(50) = gs_pss_adr-usrid.
gf_string+245(25) = gs_pss_adr-titel.
gf_string+270(25) = gs_pss_adr-mit01.
gf_string+295(25) = gs_pss_adr-mit02.
gf_string+320(25) = gs_pss_adr-mit03.
gf_string+345(25) = gs_pss_adr-mit04.
" Charakterfeld wird in einen String verschoben
gs_data-string = gf_string.
" Der Ausgabe Tabelle wird die String Zeile hinzugefügt
APPEND gs_data TO gt_data.
" Initialisieren
CLEAR: gs_data-string, gf_string.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form ADD_PSS_GRU
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM add_pss_gru .
" Feld Recordart
gs_pss_gru-recoa = '602'.
" Feld Personal_Id
gs_pss_gru-recoi = pernr-pernr.
SHIFT gs_pss_gru-recoi LEFT DELETING LEADING '0'.
SHIFT gs_pss_gru-recoi RIGHT DELETING TRAILING space.
" Zugrif IT 0008
PROVIDE * FROM p0008 BETWEEN gf_datum AND gf_datum. "-----------------**
" Feld Gueltig_Ab
CONCATENATE p0008-begda+6(2) '.' p0008-begda+4(2) '.' p0008-begda(4)
INTO gs_pss_gru-begda.
" Feld Gueltig_Bis
gs_pss_gru-endda = ''.
" Feld Betrag
gs_pss_gru-ansal = p0008-ansal.
SHIFT gs_pss_gru-ansal RIGHT DELETING TRAILING space.
" Feld Mutationsdatum
CONCATENATE p0008-aedtm+6(2) '.' p0008-aedtm+4(2) '.' p0008-aedtm(4)
INTO gs_pss_gru-mutad.
" Feld Beschäftigungsgrad
gs_pss_gru-bsgrd = p0008-bsgrd.
ENDPROVIDE. "---------------------------------------------------------**
" Feld PKTyp_Id
gs_pss_gru-pktyp = '011'.
" Feld Reglement_Id
gs_pss_gru-regli = '021000'.
" Feld IV_Grad
gs_pss_gru-ivgra = ''.
"========================================================================="
" Zeile wird in ein Charakterfeld eingefügt
gf_string(3) = gs_pss_gru-recoa.
gf_string+3(8) = gs_pss_gru-recoi.
gf_string+11(10) = gs_pss_gru-begda.
gf_string+21(10) = gs_pss_gru-endda.
gf_string+31(3) = gs_pss_gru-pktyp .
gf_string+34(12) = gs_pss_gru-ansal.
gf_string+46(6) = gs_pss_gru-regli.
gf_string+52(10) = gs_pss_gru-mutad.
gf_string+62(6) = gs_pss_gru-bsgrd.
gf_string+69(6) = gs_pss_gru-ivgra.
" Charakterfeld wird in einen String verschoben
gs_data-string = gf_string.
" Der Ausgabe Tabelle wird die String Zeile hinzugefügt
APPEND gs_data TO gt_data.
" Initialisieren
CLEAR: gs_data-string, gf_string.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form SORT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM sort .
" Absteigend sortieren
SORT gt_data BY string ASCENDING.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form ADD_FUSS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM add_fuss .
"=======================================================================
" Fussdaten sammeln
"=======================================================================
" Feld Fusszeile wird befüllt
gs_fuss-fussz = 'FUSSZEILE:'.
" Feld Anzahl Records wird befüllt
DESCRIBE TABLE gt_data LINES gs_fuss-anzre.
SHIFT gs_fuss-anzre RIGHT DELETING TRAILING space.
OVERLAY gs_fuss-anzre WITH '00000'.
" Zeile wird in ein Charakterfeld eingefügt
gf_string = gs_fuss-fussz.
gf_string+10(5) = gs_fuss-anzre.
" Charakterfeld wird in einen String verschoben
gs_data-string = gf_string.
" Der Ausgabe Tabelle wird die String Zeile hinzugefügt
APPEND gs_data TO gt_data.
" Initialisieren
CLEAR: gs_data-string, gf_string.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form SAVE_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM save_data .
****************************************************************
* Daten speichern
****************************************************************
" Lokale Datendeklaration
DATA: lf_filename TYPE string.
" Filename dem String Parameter übergeben.
lf_filename = pa_file.
" TXT File auf den Desktop downlaoden.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = lf_filename
filetype = 'ASC'
TABLES
data_tab = gt_data
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form ALV_TXT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM alv_txt .
*-----------------------------------------------------------------------
* Beginn ALV-Ausgabe
*-----------------------------------------------------------------------
* Kopieren Sie diesen Block an das Endes des Verarbeitungsblocks
* des ABAP-Programms
*-----------------------------------------------------------------------
" Instanz der Klasse cl_salv_table erzeugen
cl_salv_table=>factory(
IMPORTING r_salv_table = go_alv
CHANGING t_table = gt_data ).
" Funktionstasten (Sortieren, Filtern, Excel-Export etc.)
go_functions = go_alv->get_functions( ).
go_functions->set_all( abap_true ).
" optimale Spaltenbreite
go_columns = go_alv->get_columns( ).
go_columns->set_optimize( abap_true ).
" Titel und/oder Streifenmuster
go_display = go_alv->get_display_settings( ).
IF pa_test <> 'X'.
go_display->set_list_header( value = text-040 ).
ELSE.
go_display->set_list_header( value = text-041 ).
ENDIF.
go_display->set_striped_pattern( abap_true ).
" get layout object
go_layout = go_alv->get_layout( ).
" set Layout save restriction
" 1. Set Layout Key .. Unique key identifies the Differenet ALVs
gs_key-report = sy-repid.
go_layout->set_key( gs_key ).
" 2. Remove Save layout the restriction.
go_layout->set_save_restriction( if_salv_c_layout=>restrict_none ).
" set initial Layout
gf_variant = '/DEFAULT'.
go_layout->set_initial_layout( gf_variant ).
*" Ereignisse einlesen und Handler für Doppelklick registrieren
* go_events = go_alv->get_event( ).
* SET HANDLER lcl_handler=>on_double_click FOR go_events.
* " Ampel einbauen
* " 1. Hole die Zeilen
* go_columns = go_alv->get_columns( ).
* " 2. Hole sag bei welcher Spalte eine Ampelfunktion hinterlegt werden soll.
* go_columns->set_exception_column( value = 'LIGHTS' ).
* TRY.
* go_column ?= go_columns->get_column( 'LIGHTS' ).
* go_column->set_medium_text( 'STATUS' ).
* go_column->set_long_text( 'STATUS' ).
* go_column->set_short_text( 'STATUS' ).
* CATCH cx_salv_not_found. "#EC NO_HANDLER
* ENDTRY.
*" Liste anzeigen
go_alv->display( ).
ENDFORM.
Input
************************************************************************
**************************** *******************************
*************************** MREGOTZ ******************************
**************************** *******************************
************************************************************************
*&H
*&H PROGRAMMNAME : ZHR_PK_INPUT
*&H TRANSAKTIONSCODE : ZHR_PK_INPUT
*&H PROGRAMMTITEL : PK Personalschnittstelle (PSS)
*&H ZWECK : Es werden alle Daten der Versicherten geliefert
*&H an die PK (nicht nur die Mutationen).
*&H AUTOR : Regotz Michel
*&H DATUM : 01.10.2016
*&H SAP-MODUL : HR
*&H
*&H Company/Department : Swisscom AG
*&H Phone : +41 79 322 04 86 (Mobil)
*&H E-Mail : Michel.Regotz@Swisscom.ch
*&H
************************************************************************
*&D
*&D Beschreibung : Mit der Schnittstelle werden verschiedene
*&D PK Beiträge in den Infotyp 0015 eingelesen mit den
*&D dazugehörigen Lohnarten.
*&D Also hier wird das TXT Rückfile der PK in den IT
*&D 0015 eingelesen.
*&D
*&D --------------------------------------------------------------------
*&D Leistung : PK Personalschnittstelle (PSS) Input
*&D --------------------------------------------------------------------
*&D Tabellen :
*&D
*&D Struktur :
*&D --------------------------------------------------------------------
*&D Verarbeitung : <Daten lesen>
*&D <Daten konvertieren>
*&D <itab in IT0015 einlesen>
*&D <Erstellung Fehlerliste>
*&D <ALV File Inhalte>
************************************************************************
*&C Change history :
*&C --------------------------------------------------------------------
*&C Developer | Date | Description
*&C --------------------------------------------------------------------
*&C <Name> | <Date> | <Description>
*&C --------------------------------------------------------------------
*&C <Name> | <Date> | <Description>
*&C --------------------------------------------------------------------
*&C <Name> | <Date> | <Description>
*&C --------------------------------------------------------------------
*&C <Name> | <Date> | <Description>
************************************************************************
REPORT zhr_pk_input MESSAGE-ID zhr_pk.
TABLES: pa0001, pa0000, pa0046, pa0015.
INFOTYPES: 0015.
"=======================================================================
" Datendeklaration für die Buttons steuern zu können
"=======================================================================
*-----------------------------------------------------------------------
* Beginn Datendeklarationen
*-----------------------------------------------------------------------
" Damit man die Buttons steuern kann.
*-----------------------------------------------------------------------
TABLES: sscrfields.
"=======================================================================
" Datendeklaration für den Dateinamen
"=======================================================================
*-----------------------------------------------------------------------
* Beginn Datendeklarationen
*-----------------------------------------------------------------------
" Damit man den Filenamen und Datei Pfad hat.
*-----------------------------------------------------------------------
DATA: gf_path TYPE string.
DATA: gf_name TYPE string.
DATA: gf_pfad TYPE pc_path.
"=======================================================================
" Datendeklaration Kopf Data und Fusszeile
"=======================================================================
*-----------------------------------------------------------------------
* Beginn Datendeklarationen
*-----------------------------------------------------------------------
* Datendeklaration für die Daten sammlung und gewinnung.
* Bis zur übergabe an das TXT File
*-----------------------------------------------------------------------
*
TYPES: BEGIN OF gty_data,
pernr TYPE p_pernr,
nachn TYPE nachn,
vorna TYPE vorna,
begda TYPE begda,
endda TYPE endda,
lgart TYPE lgart,
betrg TYPE pad_amt7s,
regid TYPE c LENGTH 6,
erdat TYPE erdat,
* zusnr TYPE c LENGTH 4,
END OF gty_data.
*TYPES: BEGIN OF gty_return,
* light TYPE c LENGTH 1,
* type TYPE bapi_mtype,
* count TYPE p LENGTH 10,
* pernr TYPE p_pernr,
* nachn TYPE nachn,
* vorna TYPE vorna,
* begda TYPE begda,
* endda TYPE endda,
* lgart TYPE lgart,
* betrg TYPE pad_amt7s,
* regid TYPE c LENGTH 6,
* erdat TYPE erdat,
* zusnr TYPE c LENGTH 4,
* id TYPE symsgid,
* number TYPE symsgno,
* message TYPE bapi_msg,
* log_no TYPE balognr,
* log_msg_no TYPE balmnr,
* message_v1 TYPE symsgv,
* message_v2 TYPE symsgv,
* message_v3 TYPE symsgv,
* message_v4 TYPE symsgv,
* END OF gty_return.
TYPES: BEGIN OF gty_batch,
pernr TYPE p_pernr,
begda TYPE c LENGTH 10,
endda TYPE c LENGTH 10,
lgart TYPE lgart,
betrg TYPE c LENGTH 18,
END OF gty_batch.
TYPES: BEGIN OF gty_string,
string TYPE string,
END OF gty_string.
DATA: gt_string TYPE TABLE OF gty_string,
gs_string TYPE gty_string,
gt_data TYPE TABLE OF gty_data,
gs_data TYPE gty_data.
DATA: gt_p0000 TYPE TABLE OF p0000,
gs_p0000 TYPE p0000.
DATA: gt_p0001 TYPE TABLE OF p0001,
gs_p0001 TYPE p0001.
DATA: gt_p0015 TYPE TABLE OF p0015,
gs_p0015 TYPE p0015.
DATA: gt_p0046 TYPE TABLE OF p0046,
gs_p0046 TYPE p0046.
DATA: gt_batch TYPE TABLE OF gty_batch,
gs_batch TYPE gty_batch.
*TYPES: BEGIN OF gty_error.
*TYPES: light TYPE c LENGTH 1,
* count TYPE p LENGTH 10.
* INCLUDE STRUCTURE bapireturn1.
* INCLUDE STRUCTURE gs_data.
*TYPES: END OF gty_error.
DATA: gt_error TYPE TABLE OF zhr_pk_input,
gs_error TYPE zhr_pk_input.
"=======================================================================
" Datendeklaration für ALV
"=======================================================================
*-----------------------------------------------------------------------
* Beginn Datendeklarationen fuer den ALV
*-----------------------------------------------------------------------
* Kopieren Sie diesen Block zu den Datendeklarationen des ABAP-Programms
* Auch die Handler-Definition fuer Doppeklick ist eine Deklaration
*-----------------------------------------------------------------------
DATA go_alv TYPE REF TO cl_salv_table.
DATA go_functions TYPE REF TO cl_salv_functions_list.
DATA: go_columns TYPE REF TO cl_salv_columns_table,
go_column TYPE REF TO cl_salv_column_table.
DATA go_display TYPE REF TO cl_salv_display_settings.
DATA go_events TYPE REF TO cl_salv_events_table.
DATA: go_layout TYPE REF TO cl_salv_layout,
gf_variant TYPE slis_vari,
gs_key TYPE salv_s_layout_key.
"=======================================================================
" Datendeklaration für Batch Input
"=======================================================================
*-----------------------------------------------------------------------
* Beginn Datendeklarationen fuer die Batch Input Datei
*-----------------------------------------------------------------------
* Kopieren Sie diesen Block zu den Datendeklarationen des ABAP-Programms
* Auch die Handler-Definition fuer Doppeklick ist eine Deklaration
*-----------------------------------------------------------------------
* Batchinputdata of single transaction
DATA: bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.
* messages of call transaction
DATA: messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.
* error session opened (' ' or 'X')
DATA: e_group_opened.
* message texts
TABLES: t100.
" Trennzeichen
DATA: nodata TYPE c LENGTH 1 VALUE '/'.
" Mappe halten
*Data: E_GROUP(12).
" Mappennamen
DATA: group(12).
" Sperrdatum
DATA: holddate LIKE sy-datum.
" Mappe halten
DATA: keep(1) VALUE 'X'.
" Username
DATA: user(12)." VALUE SY-UNAME.
"=======================================================================
" Selektionsbildschirm
"=======================================================================
*-----------------------------------------------------------------------
* Beginn deklaration des Selektionsbildschirmes
*-----------------------------------------------------------------------
* Hier wird der Selektionsbildschirm erstellt
*-----------------------------------------------------------------------
" Block zum auswählen des Pfades und aktivieren des Test Buttons
SELECTION-SCREEN BEGIN OF BLOCK 10 WITH FRAME TITLE text-010.
PARAMETERS: pa_file TYPE rlgrap-filename. "DEFAULT 'C:\xXx\XLSEINSPIELEN.xls'.
PARAMETERS: pa_test AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK 10.
" Block für die Buttons
SELECTION-SCREEN BEGIN OF BLOCK 20 WITH FRAME TITLE text-020.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN PUSHBUTTON /3(18) get_view USER-COMMAND view.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN PUSHBUTTON /3(18) get_batc USER-COMMAND batc.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN PUSHBUTTON /3(18) get_prot USER-COMMAND prot.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN PUSHBUTTON /3(18) get_doku USER-COMMAND doku.
SELECTION-SCREEN END OF BLOCK 20.
"=======================================================================
" At Selection Screen Output
"=======================================================================
AT SELECTION-SCREEN OUTPUT. "PBO
"Desktop Pfad holen
IF pa_file IS INITIAL.
PERFORM pathname.
ENDIF.
" Checkbox ausblenden
* PERFORM nodisplay.
"=======================================================================
" AT SELECTION SCREEN
"=======================================================================
AT SELECTION-SCREEN. "PAI
" Buttons Anweisen was Sie zu tun haben
PERFORM button.
"=======================================================================
" AT SELECTION SCREEN ON VAlUE REQUEST FOR
"=======================================================================
AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_file.
" Ermöglichen das man den Pfad über ein Dialogfenseter auswählen kann.
PERFORM selectfile.
"=======================================================================
" START OF SELECTION
"=======================================================================
INITIALIZATION.
" Beschriften der Buttons inklusive Logo
CONCATENATE '@45@' text-vie INTO get_view SEPARATED BY space.
CONCATENATE '@DH@' text-pro INTO get_prot SEPARATED BY space.
CONCATENATE '@4K@' text-bat INTO get_batc SEPARATED BY space.
CONCATENATE '@0S@' text-dok INTO get_doku SEPARATED BY space.
START-OF-SELECTION.
" TXT in gt_string speichern
PERFORM save_data.
" Daten in ITAB einfügen.
PERFORM add_data.
END-OF-SELECTION.
IF pa_test = 'X'.
"Keine TXT Ausgabe nur ALV anzeigen.
PERFORM alv_txt.
ELSE.
"Im Testfall mache nichts
"Text File auf Desktop speichern
PERFORM add_it0015.
PERFORM alv_error.
"Falls Fehler vorhanden daraus eine Batchdatei erzeugen
IF gt_batch IS NOT INITIAL.
PERFORM creat_batch.
ENDIF.
ENDIF.
* "Fehlerprotokoll im ALV anzeigen
* PERFORM alv_error.
*&---------------------------------------------------------------------*
*& Form PATHNAME
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM pathname .
"Desktop suchen
CALL METHOD cl_gui_frontend_services=>get_desktop_directory
CHANGING
desktop_directory = gf_path
EXCEPTIONS
cntl_error = 1.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
"Desktop name holen
CALL METHOD cl_gui_cfw=>update_view.
"Pfad in Parameter schreiben
pa_file = gf_path.
* "Dateiname hinzufüge
IF sy-uname = 'RES_MRE'.
CONCATENATE 'Kasse21_2018_02' '.txt' INTO gf_name.
CONCATENATE pa_file '\' gf_name INTO pa_file.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form SELECTFILE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM selectfile .
DATA :
lv_subrc LIKE sy-subrc,
lt_it_tab TYPE filetable.
"Anzeeigen des File im Open Dialog control/screen
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = 'Select Source TXT File'
default_filename = '*.txt'
multiselection = ' '
"initial_directory = 'H:\desktop'
CHANGING
file_table = lt_it_tab
rc = lv_subrc.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF."
" Schreibe den PFAD in die das Inputfeld
READ TABLE lt_it_tab INTO pa_file INDEX 1.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form BUTTON
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM button .
" Buttons anweisen was Sie zu tun haben.
IF sscrfields-ucomm = 'BATC'.
" Batch Input aufrufen
SUBMIT rsbdc_protocol AND RETURN VIA SELECTION-SCREEN.
ELSEIF sscrfields-ucomm = 'PROT'.
" Protokoll aufrufen
SUBMIT zhr_pk_input_prot AND RETURN VIA SELECTION-SCREEN.
ELSEIF sscrfields-ucomm = 'VIEW'.
*SUBMIT sapmsvma AND RETURN via SELECTION-SCREEN
CALL TRANSACTION 'ZHR_PK_VIEWS'.
ELSEIF sscrfields-ucomm = 'DOKU'.
" Doku anzeigen
CALL FUNCTION 'RS_TOOL_ACCESS'
EXPORTING
operation = 'DOCS'
object_name = 'ZHR_PK_INPUT'
object_type = 'PROG'
EXCEPTIONS
not_executed = 1
invalid_object_type = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
ENDFORM.
**&---------------------------------------------------------------------*
**& Form SAVE_DATA
**&---------------------------------------------------------------------*
** text
**----------------------------------------------------------------------*
** --> p1 text
** <-- p2 text
**----------------------------------------------------------------------*
FORM save_data .
****************************************************************
* Daten speichern
****************************************************************
" Datendeklaration für FUBA GUI_UPLOAD.
DATA: ls_raw_data TYPE truxs_t_text_data WITH HEADER LINE.
" Lokale Datendeklaration
DATA: lf_filename TYPE string."localfile.
" Zähler
DATA: lf_count TYPE p LENGTH 10,
lf_check TYPE p LENGTH 10.
" Filename dem String Parameter übergeben.
lf_filename = pa_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = lf_filename
filetype = 'ASC'
TABLES
data_tab = ls_raw_data.
LOOP AT ls_raw_data.
gs_string-string = ls_raw_data.
APPEND gs_string TO gt_string.
ENDLOOP.
* " Kopf Zeile löschen
* DELETE gt_string INDEX 1.
* " Fuss Zeile löschen
* DESCRIBE TABLE gt_string LINES lf_count.
* DELETE gt_string INDEX lf_count.
" Datendeklaration für FUBA TEXT_CCONVERT_TEX_TO_SAP.
* ls_data TYPE gty_data,
* lt_data TYPE TABLE OF gty_data.
*
* " Upload txt File
* CALL FUNCTION 'TEXT_CONVERT_TEX_TO_SAP'
* EXPORTING
** I_FIELD_SEPERATOR =
* i_line_header = 'X'
* i_tab_raw_data = ls_raw_data
** i_filename = lf_filename
* TABLES
* i_tab_converted_data = gt_string[]
* EXCEPTIONS
* conversion_failed = 1
* OTHERS = 2.
* IF sy-subrc <> 0.
** Implement suitable error handling here
* ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form ADD_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM add_data .
LOOP AT gt_string INTO gs_string.
IF gs_string-string(10) = 'KOPFZEILE:' OR gs_string-string(10) = 'FUSSZEILE:'.
"mache nichts
CLEAR: gs_string.
ELSE.
" TXT Zeile in eine Struktur schreiben
gs_data-pernr = gs_string-string(8).
gs_data-nachn = gs_string-string+8(25).
gs_data-vorna = gs_string-string+33(25).
CONCATENATE gs_string-string+64(4) gs_string-string+61(2) gs_string-string+58(2) INTO gs_data-begda.
CONCATENATE gs_string-string+74(4) gs_string-string+71(2) gs_string-string+68(2) INTO gs_data-endda.
SELECT SINGLE lgart FROM zhr_pk_lgart INTO gs_data-lgart
WHERE codid = gs_string-string+78(3).
IF sy-subrc = 0.
"mache nichts
ELSE.
gs_data-lgart = ''.
ENDIF.
" CONCATENATE gs_string-string+82(11) gs_string-string+81(1) INTO gs_data-betrg.
gs_data-betrg = gs_string-string+81(12).
gs_data-regid = gs_string-string+93(6).
CONCATENATE gs_string-string+105(4) gs_string-string+102(2) gs_string-string+99(2) INTO gs_data-erdat.
* gs_data-zusnr = gs_string-string+109(4).
" Struktur gt_data hinzufügen.
APPEND gs_data TO gt_data.
" Struktur initialisieren.
CLEAR: gs_data.
ENDIF.
ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form ALV_TXT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM alv_txt .
*-----------------------------------------------------------------------
* Beginn ALV-Ausgabe
*-----------------------------------------------------------------------
* Kopieren Sie diesen Block an das Endes des Verarbeitungsblocks
* des ABAP-Programms
*-----------------------------------------------------------------------
" Instanz der Klasse cl_salv_table erzeugen
cl_salv_table=>factory(
IMPORTING r_salv_table = go_alv
CHANGING t_table = gt_data ).
" Funktionstasten (Sortieren, Filtern, Excel-Export etc.)
go_functions = go_alv->get_functions( ).
go_functions->set_all( abap_true ).
" optimale Spaltenbreite
go_columns = go_alv->get_columns( ).
go_columns->set_optimize( abap_true ).
" Titel und/oder Streifenmuster
go_display = go_alv->get_display_settings( ).
IF pa_test <> 'X'.
go_display->set_list_header( value = text-040 ).
ELSE.
go_display->set_list_header( value = text-041 ).
ENDIF.
go_display->set_striped_pattern( abap_true ).
"Titel Reg. ID
go_column ?= go_columns->get_column( 'REGID' ).
go_column->set_short_text( 'Reg. ID' ).
go_column->set_medium_text( 'Reglement ID' ).
go_column->set_long_text( 'Reglement ID' ).
" get layout object
go_layout = go_alv->get_layout( ).
" set Layout save restriction
" 1. Set Layout Key .. Unique key identifies the Differenet ALVs
gs_key-report = sy-repid.
go_layout->set_key( gs_key ).
" 2. Remove Save layout the restriction.
go_layout->set_save_restriction( if_salv_c_layout=>restrict_none ).
" set initial Layout
gf_variant = '/DEFAULT'.
go_layout->set_initial_layout( gf_variant ).
*" Ereignisse einlesen und Handler für Doppelklick registrieren
* go_events = go_alv->get_event( ).
* SET HANDLER lcl_handler=>on_double_click FOR go_events.
* " Ampel einbauen
* " 1. Hole die Zeilen
* go_columns = go_alv->get_columns( ).
* " 2. Hole sag bei welcher Spalte eine Ampelfunktion hinterlegt werden soll.
* go_columns->set_exception_column( value = 'LIGHT' ).
* TRY.
* go_column ?= go_columns->get_column( 'LIGHT' ).
* go_column->set_medium_text( 'STATUS' ).
* go_column->set_long_text( 'STATUS' ).
* go_column->set_short_text( 'STATUS' ).
* CATCH cx_salv_not_found. "#EC NO_HANDLER
* ENDTRY.
*" Liste anzeigen
go_alv->display( ).
ENDFORM.
*&---------------------------------------------------------------------*
*& Form ADD_IT0015
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM add_it0015 .
DATA: lt_return TYPE TABLE OF bapireturn1,
ls_return TYPE bapireturn1,
lf_return TYPE bapi_mtype,
ls_key TYPE bapipakey.
DATA: lt_count TYPE p LENGTH 10,
lf_status TYPE vwsta,
lf_ok TYPE c LENGTH 1.
"Daten für das Fehlerprotokoll
gs_error-mandt = sy-mandt.
gs_error-datum = sy-datum.
gs_error-uzeit = sy-uzeit.
gs_error-uname = sy-uname.
SELECT MAX( laufn ) FROM zhr_pk_input INTO gs_error-laufn.
gs_error-laufn = gs_error-laufn + 1.
"Dateinamen in Fehlerprotokoll schreiben
gf_pfad = pa_file.
CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'
EXPORTING
complete_filename = gf_pfad
* CHECK_DOS_FORMAT =
IMPORTING
* DRIVE =
* EXTENSION =
name = gf_name
* name_with_ext = gf_name
* PATH =
EXCEPTIONS
invalid_drive = 1
invalid_extension = 2
invalid_name = 3
invalid_path = 4
OTHERS = 5.
IF sy-subrc <> 0.
* Implement suitable error handling here
ELSE.
gs_error-fname = gf_name.
ENDIF.
LOOP AT gt_data INTO gs_data.
"Daten für Fehlerprotokoll
gs_error-satzn = gs_error-satzn + 1.
gs_error-pernrk = gs_data-pernr.
MOVE-CORRESPONDING gs_data TO gs_error.
" Um den IT zu schreiben.
gs_p0015-pernr = gs_data-pernr.
gs_p0015-infty = '0015'.
gs_p0015-subty = gs_data-lgart.
gs_p0015-endda = gs_data-endda.
gs_p0015-begda = gs_data-begda.
gs_p0015-lgart = gs_data-lgart.
gs_p0015-betrg = gs_data-betrg.
APPEND gs_p0015 TO gt_p0015.
"=======================================================================
" Verwaltungssatz prüfen
"=======================================================================
"Prüfen ob der Abrechnungskreis gesperrt ist
" Infotyp 0001 abfragen.
CALL FUNCTION 'HR_READ_INFOTYPE'
EXPORTING
tclas = 'A'
pernr = gs_data-pernr
infty = '0001'
begda = gs_data-begda
endda = gs_data-endda
* BYPASS_BUFFER = ' '
* LEGACY_MODE = ' '
* IMPORTING
* SUBRC =
TABLES
infty_tab = gt_p0001
EXCEPTIONS
infty_not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ELSE.
LOOP AT gt_p0001 INTO gs_p0001.
SELECT SINGLE state INTO lf_status FROM t569v
WHERE abkrs = gs_p0001-abkrs.
IF lf_status <> 2.
gs_error-light = 1.
gs_error-typebap = 'E'.
gs_error-idbap = 'ZHR_PK'.
gs_error-numberbap = '020'.
gs_error-message_v1bap = gs_p0001-abkrs.
zclhr_pk=>get_error( CHANGING c_gs_error = gs_error c_gt_error = gt_error ).
CLEAR: gs_p0001.
lf_ok = 'E'.
ENDIF.
ENDLOOP.
ENDIF.
"=======================================================================
" IT0046 ist gepflegt und hat die Werte PK 01 und Versicherungsart 01
"=======================================================================
"Lese den Infotypen 0046
CALL FUNCTION 'HR_READ_INFOTYPE'
EXPORTING
tclas = 'A'
pernr = gs_data-pernr
infty = '0046'
begda = gs_data-begda
endda = gs_data-endda
* BYPASS_BUFFER = ' '
* LEGACY_MODE = ' '
* IMPORTING
* SUBRC =
TABLES
infty_tab = gt_p0046
EXCEPTIONS
infty_not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ELSE.
"Prüfen ob der IT0046 leer ist wenn ja Fehlermeldung
IF gt_p0046 IS INITIAL.
"Fehler Ausgeben
gs_error-light = 1.
gs_error-typebap = 'E'.
gs_error-idbap = 'ZHR_PK'.
gs_error-numberbap = '022'.
zclhr_pk=>get_error( CHANGING c_gs_error = gs_error c_gt_error = gt_error ).
lf_ok = 'E'.
ENDIF.
"Falls der IT0046 nicht leer ist prüffen ob PK=01 und die Versicherungsart=01 ist
"sonst ein Fehler ausgeben
LOOP AT gt_p0046 INTO gs_p0046.
IF gs_p0046-vsges = 01 AND gs_p0046-vsart = 01.
"alles gut kein Fehler ausgeben
ELSE.
"Fehler Ausgeben
gs_error-light = 1.
gs_error-typebap = 'E'.
gs_error-idbap = 'ZHR_PK'.
gs_error-numberbap = '021'.
gs_error-message_v1bap = gs_p0046-vsges.
gs_error-message_v2bap = gs_p0046-vsart.
zclhr_pk=>get_error( CHANGING c_gs_error = gs_error c_gt_error = gt_error ).
CLEAR: gs_p0046.
lf_ok = 'E'.
ENDIF.
ENDLOOP.
ENDIF.
"=======================================================================
" Statusbeschäftigung ist 3 im IT0000
"=======================================================================
"Lese den Infotyp Massnahmen
CALL FUNCTION 'HR_READ_INFOTYPE'
EXPORTING
tclas = 'A'
pernr = gs_data-pernr
infty = '0000'
begda = gs_data-begda
endda = gs_data-endda
* BYPASS_BUFFER = ' '
* LEGACY_MODE = ' '
* IMPORTING
* SUBRC =
TABLES
infty_tab = gt_p0000
EXCEPTIONS
infty_not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ELSE.
"Prüfen ob der IT0000 leer ist wenn ja Fehlermeldung
IF gt_p0000 IS INITIAL.
"Fehler Ausgeben
gs_error-light = 1.
gs_error-typebap = 'E'.
gs_error-idbap = 'ZHR_PK'.
gs_error-numberbap = '023'.
zclhr_pk=>get_error( CHANGING c_gs_error = gs_error c_gt_error = gt_error ).
lf_ok = 'E'.
ENDIF.
"Falls der IT0046 nicht leer ist prüffen ob PK=01 und die Versicherungsart=01 ist
"sonst ein Fehler ausgeben
LOOP AT gt_p0000 INTO gs_p0000.
IF gs_p0000-stat2 = 3.
"alles gut kein Fehler ausgeben
ELSE.
"Fehler Ausgeben
gs_error-light = 1.
gs_error-typebap = 'E'.
gs_error-idbap = 'ZHR_PK'.
gs_error-numberbap = '024'.
gs_error-message_v1bap = gs_p0000-stat2.
zclhr_pk=>get_error( CHANGING c_gs_error = gs_error c_gt_error = gt_error ).
CLEAR: gs_p0000.
lf_ok = 'E'.
ENDIF.
ENDLOOP.
ENDIF.
"=======================================================================
" PNR sperren
"=======================================================================
"Sperren der Personalnummer
CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'
EXPORTING
number = gs_p0015-pernr
IMPORTING
return = ls_return.
.
IF ls_return-type IS NOT INITIAL AND ls_return-id IS NOT INITIAL AND ls_return-number IS NOT INITIAL.
gs_error-light = 1.
gs_error-typebap = ls_return-type.
gs_error-idbap = ls_return-id.
gs_error-numberbap = ls_return-number.
gs_error-log_nobap = ls_return-log_no.
gs_error-log_msg_nobap = ls_return-log_msg_no.
gs_error-message_v1bap = ls_return-message_v1.
gs_error-message_v2bap = ls_return-message_v2.
gs_error-message_v3bap = ls_return-message_v3.
gs_error-message_v4bap = ls_return-message_v4.
zclhr_pk=>get_error( CHANGING c_gs_error = gs_error c_gt_error = gt_error ).
lf_ok = 'E'.
ENDIF.
"=======================================================================
" Prüfung fehlgeschlagen dan HR_Infotype_Operation nicht ausführen
" Ansosnten einen Satz im IT0015 anlegen.
"=======================================================================
IF lf_ok = 'E'.
"Dann mache kein Update
ELSE.
"Füge einen neuen Satz ein
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
infty = '0015'
number = gs_p0015-pernr
subtype = gs_p0015-subty
* OBJECTID = gs_p2012-objps
* LOCKINDICATOR = gs_p2012-SPRPS
validityend = gs_p0015-endda
validitybegin = gs_p0015-begda
* recordnumber = gs_data-regid"-seqnr
record = gs_p0015
operation = 'INS' " MOD ändern INS einfügen DEL Löschen COP Kopieren LIS9 Abgrenzen
tclas = 'A' " A = Mitarbeiterdaten B = Bewerberdaten.
dialog_mode = '0' " 0 = dunkel Aktion wird abgebrochen, 1 = dunkel, im Fehlerfall Dialog 2=
* NOCOMMIT =
* VIEW_IDENTIFIER =
* SECONDARY_RECORD =
IMPORTING
return = ls_return
key = ls_key.
IF ls_return-type IS NOT INITIAL.
gs_error-light = 1.
gs_error-typebap = ls_return-type.
gs_error-idbap = ls_return-id.
gs_error-numberbap = ls_return-number.
gs_error-log_nobap = ls_return-log_no.
gs_error-log_msg_nobap = ls_return-log_msg_no.
gs_error-message_v1bap = ls_return-message_v1.
gs_error-message_v2bap = ls_return-message_v2.
gs_error-message_v3bap = ls_return-message_v3.
gs_error-message_v4bap = ls_return-message_v4.
zclhr_pk=>get_error( CHANGING c_gs_error = gs_error c_gt_error = gt_error ).
lf_ok = 'E'.
ELSE.
gs_error-light = 3.
gs_error-typebap = 'S'.
gs_error-idbap = 'ZHR_PK'.
gs_error-numberbap = '030'.
zclhr_pk=>get_error( CHANGING c_gs_error = gs_error c_gt_error = gt_error ).
CLEAR: gs_p0001-abkrs.
lf_ok = 'S'.
ENDIF.
ENDIF.
"=======================================================================
" PNR entsperren
"=======================================================================
"Sperren der Personalnummer
CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'
EXPORTING
number = gs_p0015-pernr
IMPORTING
return = ls_return.
IF ls_return-type IS NOT INITIAL AND ls_return-id IS NOT INITIAL AND ls_return-number IS NOT INITIAL.
gs_error-light = 1.
gs_error-typebap = ls_return-type.
gs_error-idbap = ls_return-id.
gs_error-numberbap = ls_return-number.
gs_error-log_nobap = ls_return-log_no.
gs_error-log_msg_nobap = ls_return-log_msg_no.
gs_error-message_v1bap = ls_return-message_v1.
gs_error-message_v2bap = ls_return-message_v2.
gs_error-message_v3bap = ls_return-message_v3.
gs_error-message_v4bap = ls_return-message_v4.
zclhr_pk=>get_error( CHANGING c_gs_error = gs_error c_gt_error = gt_error ).
ENDIF.
"=======================================================================
" Erstellen einer BatchInput Tabelle für die Fehlerhaften PNR
"=======================================================================
IF lf_ok = 'E'.
gs_batch-pernr = gs_p0015-pernr. "'10002'.
CONCATENATE gs_p0015-begda+6(2) '.' gs_p0015-begda+4(2) '.' gs_p0015-begda(4) INTO gs_batch-begda."'26.10.2016'.
CONCATENATE gs_p0015-endda+6(2) '.' gs_p0015-endda+4(2) '.' gs_p0015-endda(4) INTO gs_batch-endda."'26.10.2016'.
gs_batch-lgart = gs_p0015-lgart."'6875'.
gs_batch-betrg = gs_p0015-betrg."' 100'. 18
APPEND gs_batch TO gt_batch.
ENDIF.
CLEAR: gs_p0015, gt_p0000, gt_p0046, gt_p0001, gs_p0000, gs_p0046, gs_p0001.
ENDLOOP.
INSERT zhr_pk_input FROM TABLE gt_error.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form ALV_ERROR
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM alv_error .
*-----------------------------------------------------------------------
* Beginn ALV-Ausgabe
*-----------------------------------------------------------------------
* Kopieren Sie diesen Block an das Endes des Verarbeitungsblocks
* des ABAP-Programms
*-----------------------------------------------------------------------
" Instanz der Klasse cl_salv_table erzeugen
cl_salv_table=>factory(
IMPORTING r_salv_table = go_alv
CHANGING t_table = gt_error ).
" Funktionstasten (Sortieren, Filtern, Excel-Export etc.)
go_functions = go_alv->get_functions( ).
go_functions->set_all( abap_true ).
" optimale Spaltenbreite
go_columns = go_alv->get_columns( ).
go_columns->set_optimize( abap_true ).
" Titel und/oder Streifenmuster
go_display = go_alv->get_display_settings( ).
IF pa_test <> 'X'.
go_display->set_list_header( value = text-040 ).
ELSE.
go_display->set_list_header( value = text-041 ).
ENDIF.
go_display->set_striped_pattern( abap_true ).
" get layout object
go_layout = go_alv->get_layout( ).
" set Layout save restriction
" 1. Set Layout Key .. Unique key identifies the Differenet ALVs
gs_key-report = sy-repid.
go_layout->set_key( gs_key ).
" 2. Remove Save layout the restriction.
go_layout->set_save_restriction( if_salv_c_layout=>restrict_none ).
" set initial Layout
gf_variant = '/DEFAULT'.
go_layout->set_initial_layout( gf_variant ).
*" Ereignisse einlesen und Handler für Doppelklick registrieren
* go_events = go_alv->get_event( ).
* SET HANDLER lcl_handler=>on_double_click FOR go_events.
" Ampel einbauen
" 1. Hole die Zeilen
go_columns = go_alv->get_columns( ).
" 2. Hole sag bei welcher Spalte eine Ampelfunktion hinterlegt werden soll.
go_columns->set_exception_column( value = 'LIGHT' ).
TRY.
go_column ?= go_columns->get_column( 'LIGHT' ).
go_column->set_medium_text( 'STATUS' ).
go_column->set_long_text( 'STATUS' ).
go_column->set_short_text( 'STATUS' ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
*" Liste anzeigen
go_alv->display( ).
ENDFORM.
*&---------------------------------------------------------------------*
*& Form CREAT_BATCH
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM creat_batch .
" Um den IT zu schreiben.
* gs_p0015-pernr = gs_data-pernr.
* gs_p0015-infty = '0015'.
* gs_p0015-subty = gs_data-lgart.
* gs_p0015-endda = gs_data-endda.
* gs_p0015-begda = gs_data-begda.
* gs_p0015-lgart = gs_data-lgart.
* gs_p0015-betrg = gs_data-betrg.
*include bdcrecx1.
user = sy-uname.
CONCATENATE 'PK' sy-datum+6(2) sy-datum+4(2) sy-uzeit INTO group.
PERFORM open_group.
LOOP AT gt_batch INTO gs_batch.
PERFORM bdc_dynpro USING 'SAPMP50A' '1000'.
* PERFORM bdc_field USING 'BDC_OKCODE' '=TIMERANGE'.
PERFORM bdc_field USING 'RP50G-PERNR' '10002'.
* PERFORM bdc_field USING 'BDC_CURSOR' 'RP50G-TIMR1'.
PERFORM bdc_field USING 'RP50G-TIMR6' ''.
PERFORM bdc_field USING 'RP50G-TIMR1' 'X'.
PERFORM bdc_field USING 'RP50G-CHOIC' '15'.
PERFORM bdc_dynpro USING 'SAPMP50A' '1000'.
PERFORM bdc_field USING 'BDC_OKCODE' '=INS'.
PERFORM bdc_field USING 'RP50G-PERNR' gs_batch-pernr. "'10002'.
PERFORM bdc_field USING 'RP50G-BEGDA' gs_batch-begda."'26.10.2016'.
PERFORM bdc_field USING 'RP50G-ENDDA' gs_batch-endda."'26.10.2016'.
PERFORM bdc_field USING 'RP50G-TIMR1' 'X'.
* PERFORM bdc_field USING 'BDC_CURSOR' 'RP50G-SUBTY'.
PERFORM bdc_field USING 'RP50G-CHOIC' 'Ergänzende Zahlung'.
PERFORM bdc_field USING 'RP50G-SUBTY' gs_batch-lgart."'6875'.
PERFORM bdc_dynpro USING 'MP001500' '2000'.
* PERFORM bdc_field USING 'BDC_CURSOR' 'Q0015-BETRG'.
PERFORM bdc_field USING 'BDC_OKCODE' '=UPD'.
PERFORM bdc_field USING 'P0015-LGART' gs_batch-lgart."'6875'.
PERFORM bdc_field USING 'Q0015-BETRG' gs_batch-betrg."' 100'. 18
PERFORM bdc_field USING 'P0015-BEGDA' gs_batch-begda."'26.10.2016'.
PERFORM bdc_transaction USING 'PA30'.
ENDLOOP.
PERFORM close_group.
ENDFORM.
*----------------------------------------------------------------------*
* Start new screen *
*----------------------------------------------------------------------*
FORM bdc_dynpro USING program dynpro.
CLEAR bdcdata.
bdcdata-program = program.
bdcdata-dynpro = dynpro.
bdcdata-dynbegin = 'X'.
APPEND bdcdata.
ENDFORM.
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM bdc_field USING fnam fval.
CLEAR bdcdata.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
APPEND bdcdata.
ENDFORM.
*----------------------------------------------------------------------*
* Start new transaction according to parameters *
*----------------------------------------------------------------------*
FORM bdc_transaction USING tcode.
DATA: l_mstring(480).
DATA: l_subrc LIKE sy-subrc.
* batch input session
CALL FUNCTION 'BDC_INSERT'
EXPORTING
tcode = tcode
TABLES
dynprotab = bdcdata.
ENDFORM.
*----------------------------------------------------------------------*
* end batchinput session *
* (call transaction using...: error session) *
*----------------------------------------------------------------------*
FORM close_group.
* close batchinput group
CALL FUNCTION 'BDC_CLOSE_GROUP'.
WRITE: /(30) 'BDC_CLOSE_GROUP'(I04),
(12) 'returncode:'(I05),
sy-subrc.
ENDFORM.
*----------------------------------------------------------------------*
* create batchinput session *
* (not for call transaction using...) *
*----------------------------------------------------------------------*
FORM open_group.
* IF SESSION = 'X'.
SKIP.
WRITE: /(20) 'Create group'(I01), group.
SKIP.
* open batchinput group
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
client = sy-mandt
group = group
user = user
keep = keep
holddate = holddate.
WRITE: /(30) 'BDC_OPEN_GROUP'(I02),
(12) 'returncode:'(I05),
sy-subrc.
* ENDIF.
ENDFORM.
Protokoll Input
************************************************************************
**************************** *******************************
*************************** MREGOTZ ******************************
**************************** *******************************
************************************************************************
*&H
*&H PROGRAMMNAME : ZHR_PK_INPUT_PROT
*&H TRANSAKTIONSCODE : ZHR_PK_INPUT_PROT
*&H PROGRAMMTITEL : PK Personalschnittstelle (PSS)
*&H ZWECK : Es werden alle Daten der Versicherten geliefert
*&H an die PK (nicht nur die Mutationen).
*&H AUTOR : Regotz Michel
*&H DATUM : 01.10.2016
*&H SAP-MODUL : HR
*&H
*&H Company/Department : Swisscom AG
*&H Phone : +41 79 322 04 86 (Mobil)
*&H E-Mail : Michel.Regotz@Swisscom.ch
*&H
************************************************************************
*&D
*&D Beschreibung : Protokoll Historye des Programmes ZHR_PK_INPUT
*&D
*&D --------------------------------------------------------------------
************************************************************************
*&C Change history :
*&C --------------------------------------------------------------------
*&C Developer | Date | Description
*&C --------------------------------------------------------------------
*&C <Name> | <Date> | <Description>
*&C --------------------------------------------------------------------
*&C <Name> | <Date> | <Description>
*&C --------------------------------------------------------------------
*&C <Name> | <Date> | <Description>
*&C --------------------------------------------------------------------
*&C <Name> | <Date> | <Description>
************************************************************************
REPORT zhr_pk_input_prot MESSAGE-ID zhr_pk.
TABLES: zhr_pk_input.
"=======================================================================
" Datendeklaration für die Buttons steuern zu können
"=======================================================================
*-----------------------------------------------------------------------
* Beginn Datendeklarationen
*-----------------------------------------------------------------------
" Damit man die Buttons steuern kann.
*-----------------------------------------------------------------------
"=======================================================================
" Datendeklaration für den Dateinamen
"=======================================================================
*-----------------------------------------------------------------------
* Beginn Datendeklarationen
*-----------------------------------------------------------------------
" Damit man den Filenamen und Datei Pfad hat.
*-----------------------------------------------------------------------
"=======================================================================
" Datendeklaration Kopf Data und Fusszeile
"=======================================================================
*-----------------------------------------------------------------------
* Beginn Datendeklarationen
*-----------------------------------------------------------------------
* Datendeklaration für die Daten sammlung und gewinnung.
* Bis zur übergabe an das TXT File
*-----------------------------------------------------------------------
DATA: gt_error TYPE TABLE OF zhr_pk_input,
gs_error TYPE zhr_pk_input.
"=======================================================================
" Datendeklaration für ALV
"=======================================================================
*-----------------------------------------------------------------------
* Beginn Datendeklarationen fuer den ALV
*-----------------------------------------------------------------------
* Kopieren Sie diesen Block zu den Datendeklarationen des ABAP-Programms
* Auch die Handler-Definition fuer Doppeklick ist eine Deklaration
*-----------------------------------------------------------------------
DATA go_alv TYPE REF TO cl_salv_table.
DATA go_functions TYPE REF TO cl_salv_functions_list.
DATA: go_columns TYPE REF TO cl_salv_columns_table,
go_column TYPE REF TO cl_salv_column_table.
DATA go_display TYPE REF TO cl_salv_display_settings.
DATA go_events TYPE REF TO cl_salv_events_table.
DATA: go_layout TYPE REF TO cl_salv_layout,
gf_variant TYPE slis_vari,
gs_key TYPE salv_s_layout_key.
"=======================================================================
" Selektionsbildschirm
"=======================================================================
*-----------------------------------------------------------------------
* Beginn deklaration des Selektionsbildschirmes
*-----------------------------------------------------------------------
* Hier wird der Selektionsbildschirm erstellt
*-----------------------------------------------------------------------
" Block zum auswählen des Pfades und aktivieren des Test Buttons
SELECTION-SCREEN BEGIN OF BLOCK 10 WITH FRAME TITLE text-010.
SELECT-OPTIONS: s_fname FOR zhr_pk_input-fname,
s_laufn FOR zhr_pk_input-laufn,
s_satzn FOR zhr_pk_input-satzn,
s_count FOR zhr_pk_input-counter,
s_pernrk FOR zhr_pk_input-pernrk,
s_uname FOR zhr_pk_input-uname,
s_datum FOR zhr_pk_input-datum,
s_uzeit FOR zhr_pk_input-uzeit,
s_Type for zhr_pk_input-TYPEBAP.
SELECTION-SCREEN END OF BLOCK 10.
"=======================================================================
" At Selection Screen Output
"=======================================================================
"=======================================================================
" AT SELECTION SCREEN
"=======================================================================
"=======================================================================
" AT SELECTION SCREEN ON VAlUE REQUEST FOR
"=======================================================================
"=======================================================================
" START OF SELECTION
"=======================================================================
INITIALIZATION.
START-OF-SELECTION.
" Daten in ITAB einfügen.
PERFORM add_data.
END-OF-SELECTION.
PERFORM alv_error.
*&---------------------------------------------------------------------*
*& Form ADD_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM add_data .
SELECT * INTO TABLE gt_error FROM zhr_pk_input
WHERE fname IN s_fname AND
laufn IN s_laufn AND
satzn IN s_count AND
pernrk IN s_pernrk AND
uname IN s_uname AND
datum IN s_datum AND
uzeit IN s_uzeit AND
TYPEBAP in s_Type.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form ALV_ERROR
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM alv_error .
*-----------------------------------------------------------------------
* Beginn ALV-Ausgabe
*-----------------------------------------------------------------------
* Kopieren Sie diesen Block an das Endes des Verarbeitungsblocks
* des ABAP-Programms
*-----------------------------------------------------------------------
" Instanz der Klasse cl_salv_table erzeugen
cl_salv_table=>factory(
IMPORTING r_salv_table = go_alv
CHANGING t_table = gt_error ).
" Funktionstasten (Sortieren, Filtern, Excel-Export etc.)
go_functions = go_alv->get_functions( ).
go_functions->set_all( abap_true ).
" optimale Spaltenbreite
go_columns = go_alv->get_columns( ).
go_columns->set_optimize( abap_true ).
" Titel und/oder Streifenmuster
go_display = go_alv->get_display_settings( ).
go_display->set_list_header( value = text-020 ).
go_display->set_striped_pattern( abap_true ).
" get layout object
go_layout = go_alv->get_layout( ).
" set Layout save restriction
" 1. Set Layout Key .. Unique key identifies the Differenet ALVs
gs_key-report = sy-repid.
go_layout->set_key( gs_key ).
" 2. Remove Save layout the restriction.
go_layout->set_save_restriction( if_salv_c_layout=>restrict_none ).
" set initial Layout
gf_variant = '/DEFAULT'.
go_layout->set_initial_layout( gf_variant ).
*" Ereignisse einlesen und Handler für Doppelklick registrieren
* go_events = go_alv->get_event( ).
* SET HANDLER lcl_handler=>on_double_click FOR go_events.
" Ampel einbauen
" 1. Hole die Zeilen
go_columns = go_alv->get_columns( ).
" 2. Hole sag bei welcher Spalte eine Ampelfunktion hinterlegt werden soll.
go_columns->set_exception_column( value = 'LIGHT' ).
TRY.
go_column ?= go_columns->get_column( 'LIGHT' ).
go_column->set_medium_text( 'STATUS' ).
go_column->set_long_text( 'STATUS' ).
go_column->set_short_text( 'STATUS' ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
*" Liste anzeigen
go_alv->display( ).
ENDFORM.
Output
************************************************************************
**************************** *******************************
*************************** MREGOTZ ******************************
**************************** *******************************
************************************************************************
*&H
*&H PROGRAMMNAME : ZHR_PK
*&H TRANSAKTIONSCODE : ZHR_PK
*&H PROGRAMMTITEL : PK Personalschnittstelle (PSS)
*&H ZWECK : Es werden alle Daten der Versicherten geliefert
*&H an die PK (nicht nur die Mutationen).
*&H AUTOR : Regotz Michel
*&H DATUM : 01.10.2016
*&H SAP-MODUL : HR
*&H
*&H Company/Department : Swisscom AG
*&H Phone : +41 79 322 04 86 (Mobil)
*&H E-Mail : Michel.Regotz@Swisscom.ch
*&H
************************************************************************
*&D
*&D Beschreibung : Mit der Schnittstelle werden verschiedene
*&D Recordarten übermittelt.
*&D Es werden alle Daten der Versicherten geliefert
*&D an die PK (nicht nur die Mutationen).
*&D Mit der KOPFZEILE (erste Zeile im File) beginnt
*&D und mit der FUSSZEILE (letzte Zeile im File) endet
*&D die Schnittstellendatei.Jedes Schnittstellenfile
*&D beginnt zwingend mit der Kopfzeile. Die
*&D Datenstruktur ist fix vorgegeben.
*&D Eintritte/Mutationen und Austritt inkl. der
*&D Stammdaten werden mit dieser Recordart übermittelt.
*&D Ehegatten und Heiratsdatum können mit dieser
*&D Recordart übermittelt werden. Die Postadresse
*&D wird mit dieser Recordart übermittelt.
*&D Die Recordart Grundlagen enthält die Löhne,
*&D Schichtzulagen und Beschäftigungsgrade.
*&D
*&D --------------------------------------------------------------------
*&D Leistung : PK Personalschnittstelle (PSS)
*&D --------------------------------------------------------------------
*&D Tabellen :
*&D
*&D Struktur :
*&D --------------------------------------------------------------------
*&D Verarbeitung : <Daten holen>
*&D <Daten konvertieren>
*&D <TXT erstellen/runterladen>
*&D <Erstellung Fehlerliste>
*&D <ALV File Inhalte>
************************************************************************
*&C Change history :
*&C --------------------------------------------------------------------
*&C Developer | Date | Description
*&C --------------------------------------------------------------------
*&C <Name> | <Date> | <Description>
*&C --------------------------------------------------------------------
*&C <Name> | <Date> | <Description>
*&C --------------------------------------------------------------------
*&C <Name> | <Date> | <Description>
*&C --------------------------------------------------------------------
*&C <Name> | <Date> | <Description>
************************************************************************
REPORT zhr_pk_output MESSAGE-ID zhr_pk.
"=======================================================================
" Datendeklaration für die Buttons steuern zu können
"=======================================================================
*-----------------------------------------------------------------------
* Beginn Datendeklarationen
*-----------------------------------------------------------------------
" Damit man die Buttons steuern kann.
*-----------------------------------------------------------------------
TABLES: sscrfields, zhr_pk_output.
"=======================================================================
" Datendeklaration für GET PERAS
"=======================================================================
*-----------------------------------------------------------------------
* Beginn Datendeklarationen
*-----------------------------------------------------------------------
" Damit GET_PERAS funktioniert muss unter Eigeschaften noch die Logische
" Datenbank PNPCE angegeben werden.
*-----------------------------------------------------------------------
NODES: person, group, peras.
TABLES: pernr.
INFOTYPES: 0000, 0001, 0002, 0006, 0007, 0008, 0016, 0017, 0014, 0036, 0041, 0046, 0105.
DATA: gf_datum TYPE sy-datum.
"=======================================================================
" Datendeklaration für den Dateinamen
"=======================================================================
*-----------------------------------------------------------------------
* Beginn Datendeklarationen
*-----------------------------------------------------------------------
" Damit man den Filenamen und Datei Pfad hat.
*-----------------------------------------------------------------------
DATA: gf_path TYPE string.
DATA: gf_name TYPE string.
"=======================================================================
" Datendeklaration Kopf Data und Fusszeile
"=======================================================================
*-----------------------------------------------------------------------
* Beginn Datendeklarationen
*-----------------------------------------------------------------------
* Datendeklaration für die Daten sammlung und gewinnung.
* Bis zur übergabe an das TXT File
*-----------------------------------------------------------------------
TYPES: BEGIN OF gty_kopf,
kopfz TYPE c LENGTH 10,
erdat TYPE c LENGTH 10,
END OF gty_kopf.
TYPES: BEGIN OF gty_pss_ver,
recar TYPE c LENGTH 3,
perns TYPE c LENGTH 8,
pernr TYPE c LENGTH 11,
nachn TYPE c LENGTH 25,
vorna TYPE c LENGTH 25,
gesch TYPE c LENGTH 3,
gbpas TYPE c LENGTH 10,
sprsl TYPE c LENGTH 3,
famst TYPE c LENGTH 3,
gespu TYPE c LENGTH 3,
perka TYPE c LENGTH 3,
beruf TYPE c LENGTH 4,
mutda TYPE c LENGTH 10,
zusid TYPE c LENGTH 3,
zusnr TYPE c LENGTH 4,
regid TYPE c LENGTH 6,
pkdat TYPE c LENGTH 10,
fired TYPE c LENGTH 10,
massg TYPE c LENGTH 3,
perid TYPE c LENGTH 6,
werks TYPE c LENGTH 6,
einbe TYPE c LENGTH 10,
ahvnr TYPE c LENGTH 11,
zusda TYPE c LENGTH 10,
nahvn TYPE c LENGTH 13,
END OF gty_pss_ver.
TYPES: BEGIN OF gty_pss_ehe,
reart TYPE c LENGTH 3,
perni TYPE c LENGTH 8,
famdt TYPE c LENGTH 10,
famse TYPE c LENGTH 3,
famna TYPE c LENGTH 25,
famvo TYPE c LENGTH 25,
fgbdt TYPE c LENGTH 10,
dstod TYPE c LENGTH 10,
fasex TYPE c LENGTH 3,
END OF gty_pss_ehe.
TYPES: BEGIN OF gty_pss_adr,
recat TYPE c LENGTH 3,
perna TYPE c LENGTH 8,
adres TYPE c LENGTH 3,
anred TYPE c LENGTH 3,
stras TYPE c LENGTH 35,
adre1 TYPE c LENGTH 35,
adre2 TYPE c LENGTH 35,
pstlz TYPE c LENGTH 6,
ort01 TYPE c LENGTH 25,
state TYPE c LENGTH 2,
land1 TYPE c LENGTH 4,
usrty TYPE c LENGTH 18,
faxnr TYPE c LENGTH 18,
usrid TYPE c LENGTH 18,
titel TYPE c LENGTH 25,
mit01 TYPE c LENGTH 25,
mit02 TYPE c LENGTH 25,
mit03 TYPE c LENGTH 25,
mit04 TYPE c LENGTH 25,
END OF gty_pss_adr.
TYPES: BEGIN OF gty_pss_gru,
recoa TYPE c LENGTH 3,
recoi TYPE c LENGTH 8,
begda TYPE c LENGTH 10,
endda TYPE c LENGTH 10,
pktyp TYPE c LENGTH 3,
ansal TYPE c LENGTH 12,
regli TYPE c LENGTH 6,
mutad TYPE c LENGTH 10,
bsgrd TYPE c LENGTH 6,
ivgra TYPE c LENGTH 6,
END OF gty_pss_gru.
TYPES: BEGIN OF gty_fuss,
fussz TYPE c LENGTH 10,
anzre TYPE c LENGTH 5,
END OF gty_fuss.
TYPES: BEGIN OF gty_data,
"string TYPE c LENGTH 500,
string TYPE string,
END OF gty_data.
* Data gs_returncs TYPE bapiret2.
DATA: gt_kopf TYPE TABLE OF gty_kopf,
gs_kopf TYPE gty_kopf,
gt_pss_ver TYPE TABLE OF gty_pss_ver,
gs_pss_ver TYPE gty_pss_ver,
gt_pss_ehe TYPE TABLE OF gty_pss_ehe,
gs_pss_ehe TYPE gty_pss_ehe,
gt_pss_adr TYPE TABLE OF gty_pss_adr,
gs_pss_adr TYPE gty_pss_adr,
gt_pss_gru TYPE TABLE OF gty_pss_gru,
gs_pss_gru TYPE gty_pss_gru,
gt_fuss TYPE TABLE OF gty_fuss,
gs_fuss TYPE gty_fuss,
gt_data TYPE TABLE OF gty_data,
gs_data TYPE gty_data,
gf_string TYPE c LENGTH 400.
*TYPES: BEGIN OF gty_error.
*TYPES: mandt TYPE mandt,
* fname TYPE termfile,
* laufn TYPE cacsrun_id,
* datum TYPE sy-datum,
* uzeit TYPE sy-uzeit,
* uname TYPE sy-uname,
* light TYPE c LENGTH 1,
* mesid TYPE c LENGTH 1,
* metxt TYPE text120.
* INCLUDE STRUCTURE gs_pss_ver.
* INCLUDE STRUCTURE gs_pss_ehe.
* INCLUDE STRUCTURE gs_pss_adr.
* INCLUDE STRUCTURE gs_pss_gru.
*TYPES: END OF gty_error.
TYPES: BEGIN OF gty_errors.
TYPES: ppppp TYPE pernr-pernr,
light TYPE c LENGTH 1,
mesid TYPE c LENGTH 1,
metxt TYPE text120,
counter TYPE cifcountn7.
TYPES: END OF gty_errors.
DATA: gt_error TYPE TABLE OF zhr_pk_output, "gty_error,
gs_error TYPE zhr_pk_output. "gty_error.
DATA: gt_errors TYPE TABLE OF gty_errors,
gs_errors TYPE gty_errors.
DATA: gf_fgbdt TYPE sy-datum.
DATA: gf_fasex TYPE gesch.
DATA: gf_begda TYPE begda.
DATA: gf_ok TYPE c LENGTH 1.
DATA: gf_filename TYPE termfile.
DATA: gf_satzn TYPE zzhr_pksatzn.
DATA: gf_counter TYPE cifcountn7.
DATA: gf_subty TYPE c.
"=======================================================================
" Datendeklaration für ALV
"=======================================================================
*-----------------------------------------------------------------------
* Beginn Datendeklarationen fuer den ALV
*-----------------------------------------------------------------------
* Kopieren Sie diesen Block zu den Datendeklarationen des ABAP-Programms
* Auch die Handler-Definition fuer Doppeklick ist eine Deklaration
*-----------------------------------------------------------------------
DATA go_alv TYPE REF TO cl_salv_table.
DATA go_functions TYPE REF TO cl_salv_functions_list.
DATA: go_columns TYPE REF TO cl_salv_columns_table,
go_column TYPE REF TO cl_salv_column_table.
DATA: gs_color TYPE lvc_s_colo.
DATA go_display TYPE REF TO cl_salv_display_settings.
DATA go_events TYPE REF TO cl_salv_events_table.
DATA: go_layout TYPE REF TO cl_salv_layout,
gf_variant TYPE slis_vari,
gs_key TYPE salv_s_layout_key.
"=======================================================================
" Selektionsbildschirm
"=======================================================================
*-----------------------------------------------------------------------
* Beginn deklaration des Selektionsbildschirmes
*-----------------------------------------------------------------------
* Hier wird der Selektionsbildschirm erstellt
*-----------------------------------------------------------------------
" Block zum auswählen des Pfades und aktivieren des Test Buttons
SELECTION-SCREEN BEGIN OF BLOCK 10 WITH FRAME TITLE text-010.
PARAMETERS: pa_file TYPE rlgrap-filename. "DEFAULT 'C:\xXx\XLSEINSPIELEN.xls'.
PARAMETERS: pa_test AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK 10.
" Block für die Buttons
SELECTION-SCREEN BEGIN OF BLOCK 20 WITH FRAME TITLE text-020.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN PUSHBUTTON /3(18) get_view USER-COMMAND view.
*SELECTION-SCREEN SKIP 1.
*SELECTION-SCREEN PUSHBUTTON /3(18) get_batc USER-COMMAND batc.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN PUSHBUTTON /3(18) get_prot USER-COMMAND prot.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN PUSHBUTTON /3(18) get_doku USER-COMMAND doku.
SELECTION-SCREEN END OF BLOCK 20.
"=======================================================================
" At Selection Screen Output
"=======================================================================
AT SELECTION-SCREEN OUTPUT. "PBO
"Desktop Pfad holen
IF pa_file IS INITIAL.
PERFORM pathname.
ENDIF.
" Checkbox ausblenden
* PERFORM nodisplay.
"=======================================================================
" AT SELECTION SCREEN
"=======================================================================
AT SELECTION-SCREEN. "PAI
" Buttons Anweisen was Sie zu tun haben
PERFORM button.
"=======================================================================
" AT SELECTION SCREEN ON VAlUE REQUEST FOR
"=======================================================================
AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_file.
" Ermöglichen das man den Pfad über ein Dialogfenseter auswählen kann.
PERFORM selectfile.
"=======================================================================
" START OF SELECTION
"=======================================================================
INITIALIZATION.
" Datum von heute Vorschlagen
pnpbegda = sy-datum.
" Beschriften der Buttons inklusive Logo
CONCATENATE '@45@' text-vie INTO get_view SEPARATED BY space.
CONCATENATE '@DH@' text-pro INTO get_prot SEPARATED BY space.
* CONCATENATE '@4K@' text-bat INTO get_batc SEPARATED BY space.
CONCATENATE '@0S@' text-dok INTO get_doku SEPARATED BY space.
START-OF-SELECTION.
"The report only runs with ONE specific date:
gf_datum = pn-endda.
"Sammeln von Kopf PSS Fuss Daten und diese in eine Transparente Tabelle schreiben.
GET peras.
" Prüfen ob die Person im File aufgenommen werden Soll oder nicht.
" Prüfen ob ein Stundenlöhner oder nicht Stundenlöhner werden nur im Januar verarbeitet.
PERFORM check_pernr.
" Daten Sammeln
PERFORM add_pss_ver.
PERFORM add_pss_ehe.
PERFORM add_pss_adr.
PERFORM add_pss_gru.
CLEAR: gs_pss_ver, gs_pss_ehe, gs_pss_adr, gs_pss_gru.
PERFORM add_gt_error.
PERFORM sort.
END-OF-SELECTION.
PERFORM add_fuss.
PERFORM add_kopf.
IF pa_test = 'X'.
"Keine TXT Ausgabe nur ALV anzeigen.
PERFORM alv_txt.
ELSE.
"Text File auf Desktop speichern
PERFORM save_data."Im Testfall mache nichts
ENDIF.
* "Fehlerprotokoll im ALV anzeigen
* PERFORM alv_error.
*&---------------------------------------------------------------------*
*& Form PATHNAME
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM pathname .
"Desktop suchen
CALL METHOD cl_gui_frontend_services=>get_desktop_directory
CHANGING
desktop_directory = gf_path
EXCEPTIONS
cntl_error = 1.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
"Desktop name holen
CALL METHOD cl_gui_cfw=>update_view.
"Pfad in Parameter schreiben
pa_file = gf_path.
"Dateiname hinzufüge
CONCATENATE sy-datum '_' sy-uzeit '_' 'PK PSS.txt' INTO gf_name.
CONCATENATE pa_file '\' gf_name INTO pa_file.
gf_filename = gf_name.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form SELECTFILE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM selectfile .
DATA: lf_filename TYPE string,
lf_fullpath TYPE string,
lf_path TYPE string,
lf_result TYPE i.
* Anzeigen eines Dialogfensters zum speichern.
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
window_title = 'REGOTZ '
default_extension = 'TXT'
default_file_name = gf_name
initial_directory = gf_path "c:\temp\'
CHANGING
filename = lf_filename
path = lf_path
fullpath = lf_fullpath
user_action = lf_result.
"Pfad speichern
pa_file = lf_fullpath.
IF lf_filename IS NOT INITIAL.
gf_filename = lf_filename.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form BUTTON
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM button .
* " Buttons anweisen was Sie zu tun haben.
* IF sscrfields-ucomm = 'BATC'.
*
* " Batch Input aufrufen
* SUBMIT rsbdc_protocol AND RETURN VIA SELECTION-SCREEN.
*
* ELSE
*
IF sscrfields-ucomm = 'PROT'.
" Protokoll aufrufen
SUBMIT zhr_pk_output_prot AND RETURN VIA SELECTION-SCREEN.
ELSEIF sscrfields-ucomm = 'VIEW'.
*SUBMIT sapmsvma AND RETURN via SELECTION-SCREEN
CALL TRANSACTION 'ZHR_PK_VIEWS'.
ELSEIF sscrfields-ucomm = 'DOKU'.
" Doku anzeigen
CALL FUNCTION 'RS_TOOL_ACCESS'
EXPORTING
operation = 'DOCS'
object_name = 'ZHR_PK_OUTPUT'
object_type = 'PROG'
EXCEPTIONS
not_executed = 1
invalid_object_type = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form ADD_KOPF
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM add_kopf .
"=======================================================================
" Kopfdaten sammeln
"=======================================================================
" Feld Kopfzeile wird befüllt
gs_kopf-kopfz = 'KOPFZEILE:'.
" Feld Erstellungsdatum wird befüllt
CONCATENATE sy-datum+6(2) '.' sy-datum+4(2) '.' sy-datum(4) INTO gs_kopf-erdat.
" Zeile wird in ein Charakterfeld eingefügt
gf_string = gs_kopf-kopfz.
gf_string+10(10) = gs_kopf-erdat.
" Charakterfeld wird in einen String verschoben
gs_data-string = gf_string.
" Der Ausgabe Tabelle wird die String Zeile hinzugefügt
INSERT gs_data INTO gt_data INDEX 1.
" Initialisieren
CLEAR: gs_data-string, gf_string.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form ADD_PSS_VER
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM add_pss_ver .
"=======================================================================
" PSSdaten des Versicherten Datendeklaration
"=======================================================================
DATA: lf_dar TYPE datar.
DATA: lf_dat TYPE dardt.
DATA: lf_dat_fired TYPE dardt.
DATA: lf_massn TYPE massn.
DATA: lf_massg TYPE massg.
"=======================================================================
" PSSdaten des Versicherten sammeln
"=======================================================================
" Feld Kopfzeile wird befüllt
gs_pss_ver-recar = '002'.
" Feld Vers_Id (P000-PERNR)
gs_pss_ver-perns = pernr-pernr.
SHIFT gs_pss_ver-perns LEFT DELETING LEADING '0'.
SHIFT gs_pss_ver-perns RIGHT DELETING TRAILING space.
" Feld Personal_Id (P000-PERNR)
gs_pss_ver-pernr = pernr-pernr.
SHIFT gs_pss_ver-pernr LEFT DELETING LEADING '0'.
SHIFT gs_pss_ver-pernr RIGHT DELETING TRAILING space.
"Zugriff IT 0002
PROVIDE * FROM p0002 BETWEEN gf_datum AND gf_datum. "-----------------**
" Feld Nachname (P0002-NACHN)
gs_pss_ver-nachn = p0002-nachn.
IF p0002-nachn IS INITIAL.
gf_ok = 'E'.
CLEAR: gs_errors.
gf_counter = gf_counter + 1.
gs_errors-counter = gf_counter.
gs_errors-light = 1.
gs_errors-mesid = 'E'.
CONCATENATE 'Im IT0002 ist das Feld Nachname nicht gepflegt für die PNR ' pernr-pernr INTO gs_errors-metxt.
APPEND gs_errors TO gt_errors.
ENDIF.
" Feld Vorname (P0002-VORNA)
gs_pss_ver-vorna = p0002-vorna.
IF p0002-vorna IS INITIAL.
gf_ok = 'E'.
CLEAR: gs_errors.
gf_counter = gf_counter + 1.
gs_errors-counter = gf_counter.
gs_errors-light = 1.
gs_errors-mesid = 'E'.
CONCATENATE 'Im IT0002 ist das Feld Vorname nicht gepflegt für die PNR ' pernr-pernr INTO gs_errors-metxt.
APPEND gs_errors TO gt_errors.
ENDIF.
" Feld Geschlecht (P0002-GESCH)
IF p0002-gesch = 1.
gs_pss_ver-gesch = '000'.
ELSEIF p0002-gesch = 2.
gs_pss_ver-gesch = '001'.
ELSE.
gf_ok = 'E'.
CLEAR: gs_errors.
gf_counter = gf_counter + 1.
gs_errors-counter = gf_counter.
gs_errors-light = 1.
gs_errors-mesid = 'E'.
CONCATENATE 'Im IT0002 ist das Feld Geschlecht nicht gepflegt für die PNR ' pernr-pernr INTO gs_errors-metxt.
APPEND gs_errors TO gt_errors.
ENDIF.
" Feld Geburtstag (P0002-GBPAS)
CONCATENATE p0002-gbpas+6(2) '.' p0002-gbpas+4(2) '.' p0002-gbpas(4) INTO gs_pss_ver-gbpas.
" Feld Sprache (P002-SPRSL)
IF p0002-sprsl = 'D'.
gs_pss_ver-sprsl = '001'.
ELSEIF p0002-sprsl = 'F'.
gs_pss_ver-sprsl = '002'.
ELSEIF p0002-sprsl = 'I'.
gs_pss_ver-sprsl = '003'.
ELSEIF p0002-sprsl IS INITIAL.
gf_ok = 'E'.
CLEAR: gs_errors.
gf_counter = gf_counter + 1.
gs_errors-counter = gf_counter.
gs_errors-light = 1.
gs_errors-mesid = 'E'.
CONCATENATE 'Im IT0002 ist das Feld Sprachschlüssel nicht gepflegt für die PNR ' pernr-pernr INTO gs_errors-metxt.
APPEND gs_errors TO gt_errors.
ELSE.
gs_pss_ver-sprsl = ''.
ENDIF.
" Feld Zivilstand (P0002 FMAST)
SELECT SINGLE codef FROM zhr_pk_famst INTO gs_pss_ver-famst
WHERE famst = p0002-famst.
IF sy-subrc = 0.
"mache nichts
ELSE.
gs_pss_ver-famst = ''.
ENDIF.
* CASE p0002-famst.
* WHEN '0'.
* gs_pss_ver-famst = '000'.
* WHEN '1'.
* gs_pss_ver-famst = '001'.
* WHEN '2'.
* gs_pss_ver-famst = '003'.
* WHEN '3'.
* gs_pss_ver-famst = '002'.
* WHEN '4'.
* gs_pss_ver-famst = '000'.
* WHEN '5'.
* gs_pss_ver-famst = '004'.
* WHEN '9'.
* gs_pss_ver-famst = '006'.
* WHEN OTHERS.
* gs_pss_ver-famst = ''.
* ENDCASE.
ENDPROVIDE. "---------------------------------------------------------**
IF sy-subrc <> 0.
gf_ok = 'E'.
CLEAR: gs_errors.
gf_counter = gf_counter + 1.
gs_errors-counter = gf_counter.
gs_errors-light = 1.
gs_errors-mesid = 'E'.
CONCATENATE 'Der IT0002 existiert nicht für die PNR' pernr-pernr INTO gs_errors-metxt.
APPEND gs_errors TO gt_errors.
ENDIF.
" Feld Gesundheitsprüfung
gs_pss_ver-gespu = '000'.
" Feld Personalkategorie
gs_pss_ver-perka = '000'.
" Feld Beruf
gs_pss_ver-beruf = '0000'.
" Feld Mutationdatum
gs_pss_ver-mutda = '00.00.0000'.
" Feld Zusatzinformation
gs_pss_ver-zusid = '000'.
" Feld Zusatznummer
gs_pss_ver-zusnr = ' '.
" Feld Reglement_Id
gs_pss_ver-regid = '021000'.
" Zugrif IT 0041
PROVIDE * FROM p0041 BETWEEN gf_datum AND gf_datum. "-----------------**
" Lesen der Datumsarten
DO 12 TIMES VARYING lf_dar FROM p0041-dar01 NEXT p0041-dar02 RANGE p0041
VARYING lf_dat FROM p0041-dat01 NEXT p0041-dat02 RANGE p0041.
IF lf_dar = 'EP'.
" Feld Eintrittsdatum Pensionskasse (P0041-DATAR = EP)
CONCATENATE lf_dat+6(2) '.' lf_dat+4(2) '.' lf_dat(4)
INTO gs_pss_ver-pkdat.
* gs_pss_ver-pkdat = lf_dat.
ELSEIF lf_dar = 'EE'.
" Feld Eintrittsdatum_Betrieb (P0041-DATAR = EE)
CONCATENATE lf_dat+6(2) '.' lf_dat+4(2) '.' lf_dat(4)
INTO gs_pss_ver-einbe.
* gs_pss_ver-einbe = lf_dat.
ENDIF.
CLEAR: lf_dat, lf_dar.
ENDDO.
ENDPROVIDE. "---------------------------------------------------------**
IF gs_pss_ver-pkdat IS INITIAL.
gf_ok = 'E'.
CLEAR: gs_errors.
gf_counter = gf_counter + 1.
gs_errors-counter = gf_counter.
gs_errors-light = 1.
gs_errors-mesid = 'E'.
CONCATENATE 'Im IT0041 ist das DATUM EP (Eintrittsdatum PK) nicht gepflegt für die PNR ' pernr-pernr INTO gs_errors-metxt..
APPEND gs_errors TO gt_errors.
ENDIF.
IF gs_pss_ver-einbe IS INITIAL.
gf_ok = 'E'.
CLEAR: gs_errors.
gf_counter = gf_counter + 1.
gs_errors-counter = gf_counter.
gs_errors-light = 1.
gs_errors-mesid = 'E'.
CONCATENATE 'Im IT0041 ist das DATUM EE (Eintrittsdatum Betrieb) nicht gepflegt für die PNR ' pernr-pernr INTO gs_errors-metxt..
APPEND gs_errors TO gt_errors.
ENDIF.
" Feld Austrittsdatum
CALL FUNCTION 'HR_LEAVING_DATE'
EXPORTING
persnr = pernr-pernr
* RCLAS = 'ZHR_PK'
* begda = gf_datum
* endda = gf_datum
* VARKY = 'ZHR_PK'
* INITIALIZE_PS_BUFFER = 'X'
IMPORTING
leavingdate = lf_dat
* TABLES
* LEAVING_DATES = GT_DAT
EXCEPTIONS
leaving_date_not_found = 1
pernr_not_assigned = 2
OTHERS = 3.
IF sy-subrc = 0.
CONCATENATE lf_dat+6(2) '.' lf_dat+4(2) '.' lf_dat(4)
INTO gs_pss_ver-fired.
ELSE.
CONCATENATE lf_dat+6(2) '.' lf_dat+4(2) '.' lf_dat(4)
INTO gs_pss_ver-fired.
ENDIF.
IF gs_pss_ver-fired IS NOT INITIAL AND gs_pss_ver-fired <> '00.00.0000'.
lf_dat = lf_dat + 1.
CONCATENATE gs_pss_ver-fired+6(4) gs_pss_ver-fired+3(2) gs_pss_ver-fired(2) INTO lf_dat_fired.
lf_dat_fired = lf_dat_fired + 1.
"Select einbauen statt Provid
" Zugrif IT 0000
* PROVIDE * FROM p0000 BETWEEN lf_dat_fired AND lf_dat_fired. "-----------------**
" Feld Austrittsgrund (P0000-MASSN / P0000-MASSG)
SELECT SINGLE massn massg FROM pa0000
INTO (lf_massn, lf_massg)
WHERE pernr = pernr-pernr AND
begda <= lf_dat_fired AND
endda >= lf_dat_fired.
SELECT SINGLE codid FROM zhr_pk_massg INTO gs_pss_ver-massg
WHERE massn = lf_massn "p0000-massn
AND massg = lf_massg. "p0000-massg.
IF sy-subrc = 0.
"mache nichts
ELSE.
gs_pss_ver-massg = ''.
ENDIF.
* IF p0000-massn = 'C4'.
* CASE p0000-massg.
* WHEN '32'.
* gs_pss_ver-massg = '006'.
* WHEN '33'.
* gs_pss_ver-massg = '002'.
* WHEN OTHERS.
* gs_pss_ver-massg = '001'.
* ENDCASE.
* ENDIF.
* ENDPROVIDE. "---------------------------------------------------------**
ENDIF.
CLEAR: lf_dat, lf_dat_fired.
" Feld Personalteilbereich_ID
gs_pss_ver-perid = '000000'.
" Zugrif IT 0001
PROVIDE * FROM p0001 BETWEEN gf_datum AND gf_datum. "-----------------**
" Feld Betrieb_Id (P0001-WERKS)
SELECT SINGLE betid FROM zhr_pk_werks INTO gs_pss_ver-werks
WHERE werks = p0001-werks.
IF sy-subrc = 0.
"mache nichts
ELSE.
gf_ok = 'E'.
CLEAR: gs_errors.
gf_counter = gf_counter + 1.
gs_errors-counter = gf_counter.
gs_errors-light = 1.
gs_errors-mesid = 'E'.
CONCATENATE 'Der Personalteilbereich ist nicht zugeordnet in der View ZHR_PK_WERKS für die PNR ' pernr-pernr INTO gs_errors-metxt.
APPEND gs_errors TO gt_errors.
ENDIF.
*
* CASE p0001-werks.
* WHEN '1000'.
* gs_pss_ver-werks = '21150'.
* WHEN '1001'.
* gs_pss_ver-werks = '21201'.
* WHEN '1002'.
* gs_pss_ver-werks = '21402'.
* WHEN '1003'.
* gs_pss_ver-werks = '21301'.
* WHEN '1004'.
* gs_pss_ver-werks = '21801'.
* WHEN '1005'.
* gs_pss_ver-werks = '21701'.
* WHEN '1006'.
* gs_pss_ver-werks = '21202'.
* WHEN '1007'.
* gs_pss_ver-werks = '21302'.
* WHEN '1009'.
* gs_pss_ver-werks = '21401'.
* WHEN '1010'.
* gs_pss_ver-werks = '21900'.
* WHEN '1011'.
* gs_pss_ver-werks = '21501'.
* WHEN '1012'.
* gs_pss_ver-werks = '21601'.
* WHEN '1014'.
* gs_pss_ver-werks = '21905'.
* WHEN '1015'.
* gs_pss_ver-werks = '21915'.
* WHEN '1016'.
* gs_pss_ver-werks = '21750'.
* WHEN OTHERS.
* gs_pss_ver-werks = ''.
* ENDCASE.
ENDPROVIDE. "---------------------------------------------------------**
IF sy-subrc <> 0.
gf_ok = 'E'.
CLEAR: gs_errors.
gf_counter = gf_counter + 1.
gs_errors-counter = gf_counter.
gs_errors-light = 1.
gs_errors-mesid = 'E'.
CONCATENATE 'Der IT0001 existiert nicht für die PNR' pernr-pernr INTO gs_errors-metxt.
APPEND gs_errors TO gt_errors.
ENDIF.
" Zugrif IT 0036
PROVIDE * FROM p0036 BETWEEN gf_datum AND gf_datum. "-----------------**
" Feld AHV_Id (P0036-AHVNR)
gs_pss_ver-ahvnr = p0036-ahvnr.
" Feld SozVers_Id (P0036-NAHVN)
gs_pss_ver-nahvn = p0036-nahvn.
ENDPROVIDE. "---------------------------------------------------------**
" Feld Zusatzdatum
gs_pss_ver-zusda = ' '.
" Zeile wird in ein Charakterfeld eingefügt
gf_string = gs_pss_ver-recar.
" Tabelle gt_pss wird befüllt
APPEND gs_pss_ver TO gt_pss_ver.
MOVE-CORRESPONDING gs_pss_ver TO gs_error.
"========================================================================="
" Nur Daten ohne Fehler wegschreiben.
IF gf_ok = 'S'.
" Zeile wird in ein Charakterfeld eingefügt
gf_string(3) = gs_pss_ver-recar.
gf_string+3(8) = gs_pss_ver-perns.
gf_string+11(11) = gs_pss_ver-pernr.
gf_string+22(25) = gs_pss_ver-nachn.
gf_string+47(25) = gs_pss_ver-vorna.
gf_string+72(3) = gs_pss_ver-gesch.
gf_string+75(10) = gs_pss_ver-gbpas.
gf_string+85(3) = gs_pss_ver-sprsl.
gf_string+88(3) = gs_pss_ver-famst.
gf_string+91(3) = gs_pss_ver-gespu.
gf_string+94(3) = gs_pss_ver-perka.
gf_string+97(4) = gs_pss_ver-beruf.
gf_string+101(10) = gs_pss_ver-mutda.
gf_string+111(3) = gs_pss_ver-zusid.
gf_string+114(4) = gs_pss_ver-zusnr.
gf_string+118(6) = gs_pss_ver-regid.
gf_string+124(10) = gs_pss_ver-pkdat.
gf_string+134(10) = gs_pss_ver-fired.
gf_string+144(3) = gs_pss_ver-massg.
gf_string+147(6) = gs_pss_ver-perid.
gf_string+153(6) = gs_pss_ver-werks.
gf_string+159(10) = gs_pss_ver-einbe.
gf_string+169(11) = gs_pss_ver-ahvnr.
gf_string+180(10) = gs_pss_ver-zusda.
gf_string+190(13) = gs_pss_ver-nahvn.
" Charakterfeld wird in einen String verschoben
gs_data-string = gf_string.
" Der Ausgabe Tabelle wird die String Zeile hinzugefügt
APPEND gs_data TO gt_data.
ENDIF.
" Initialisieren
CLEAR: gs_data-string, gf_string.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form ADD_PSS_EHE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM add_pss_ehe .
"Wenn ledig keine Daten zum Ehegatten liefern
IF gs_pss_ver-famst = '000'.
"mache nichts.
ELSE.
" Feld Recordart
gs_pss_ehe-reart = '202'.
" Feld Personal_Id
gs_pss_ehe-perni = pernr-pernr.
SHIFT gs_pss_ehe-perni LEFT DELETING LEADING '0'.
SHIFT gs_pss_ehe-perni RIGHT DELETING TRAILING space.
" Zugrif IT 0002
PROVIDE * FROM p0002 BETWEEN gf_datum AND gf_datum. "-----------------**
" Feld Heiratsdatum (P0002-FAMDT) Datum nur Eintragen wenn Zivilstand Verheiratet.
IF p0002-famst = '1'.
CONCATENATE p0002-famdt+6(2) '.' p0002-famdt+4(2) '.' p0002-famdt(4)
INTO gs_pss_ehe-famdt.
ELSE.
gs_pss_ehe-famdt = ''.
ENDIF.
" Feld Zivilstand (P0002-FAMST)
SELECT SINGLE codef FROM zhr_pk_famst INTO gs_pss_ehe-famse
WHERE famst = p0002-famst.
IF sy-subrc = 0.
"mache nichts
ELSE.
gf_ok = 'E'.
CLEAR: gs_errors.
gf_counter = gf_counter + 1.
gs_errors-counter = gf_counter.
gs_errors-light = 1.
gs_errors-mesid = 'E'.
CONCATENATE 'Im IT0002 ist das Feld Zivilstand nicht gepflegt für die PNR ' pernr-pernr INTO gs_errors-metxt.
APPEND gs_errors TO gt_errors.
ENDIF.
* CASE p0002-famst.
* WHEN 0. " ledig
* gs_pss_ehe-famst = '0'.
* WHEN 1. " verheiratet
* gs_pss_ehe-famst = '1'.
* WHEN 2. " verwitwert
* gs_pss_ehe-famst = '3'.
* WHEN 3. " geschieden
* gs_pss_ehe-famst = '2'.
* WHEN 4. " nv
* gs_pss_ehe-famst = '0'.
* WHEN 5. " getrennt
* gs_pss_ehe-famst = '4'.
* WHEN 9. " regPar
* gs_pss_ehe-famst = '6'.
* WHEN OTHERS.
* gs_pss_ehe-famst = ''.
* ENDCASE.
" Feld Datum_Scheidung_Tod
" Scheidung
CASE p0002-famst.
WHEN 3. " geschieden
CONCATENATE p0002-famdt+6(2) '.' p0002-famdt+4(2) '.' p0002-famdt(4)
INTO gs_pss_ehe-dstod.
ENDCASE.
ENDPROVIDE. "---------------------------------------------------------**
" Zugrif IT 0000
PROVIDE * FROM p0000 BETWEEN gf_datum AND gf_datum. "-----------------**
" Feld Datum_Scheidung_Tod (P0000-MASSN / P0000-MASSG)
" Tod
IF p0000-massn = 'C4'.
CASE p0000-massg.
WHEN '33'.
CONCATENATE p0002-begda+6(2) '.' p0002-begda+4(2) '.' p0002-begda(4)
INTO gs_pss_ehe-dstod .
ENDCASE.
ENDIF.
ENDPROVIDE. "---------------------------------------------------------**
* " Zugrif IT 0021
*PROVIDE FIELDS * FROM p0021 INTO gs_p0021 VALID flag bounds in and ind
* where p0021-subty = '1' BETWEEN gf_datum AND gf_datum .
* ENDPROVIDE. "---------------------------------------------------------**
" Feld EName (PA0021-fanam)
" Feld Vorname (PA0021-favor)
" Feld Geschlecht_Id (PA0021-fasex)
SELECT SINGLE fanam favor fgbdt fasex FROM pa0021
INTO (gs_pss_ehe-famna, gs_pss_ehe-famvo, gf_fgbdt, gf_fasex)
WHERE pernr = pernr-pernr AND
" OBJPS = space AND "Objektidentikfikation Falls 2 Sätze mit gleichen Primärkey existieren
sprps = space AND "Sperkennzeichen
subty = '1' OR
subty = '10' OR
subty = '13' OR
subty = '15' AND
begda <= gf_datum AND
endda >= gf_datum.
" Feld Geschlecht_ID (P0021-fasex)
IF gf_fasex = 1.
gs_pss_ehe-fasex = '000'.
ELSEIF gf_fasex = 2.
gs_pss_ehe-fasex = '001'.
ELSE.
gf_ok = 'E'.
CLEAR: gs_errors.
gf_counter = gf_counter + 1.
gs_errors-counter = gf_counter.
gs_errors-light = 1.
gs_errors-mesid = 'E'.
CONCATENATE 'Im IT0021 ist das Geschlecht für den Ehegaten nicht gepflegt für die PNR ' pernr-pernr INTO gs_errors-metxt.
APPEND gs_errors TO gt_errors.
ENDIF.
" Feld Geburtsdatum (PA0021-fgbdt)
CONCATENATE gf_fgbdt+6(2) '.' gf_fgbdt+4(2) '.' gf_fgbdt(4)
INTO gs_pss_ehe-fgbdt.
CLEAR: gf_fgbdt, gf_fasex.
" Tabelle gt_pss wird befüllt
APPEND gs_pss_ehe TO gt_pss_ehe.
MOVE-CORRESPONDING gs_pss_ehe TO gs_error.
"========================================================================="
" Nur Daten ohne Fehler wegschreiben.
IF gf_ok = 'S'.
" Zeile wird in ein Charakterfeld eingefügt
gf_string(3) = gs_pss_ehe-reart.
gf_string+3(8) = gs_pss_ehe-perni.
gf_string+11(10) = gs_pss_ehe-famdt.
gf_string+21(3) = gs_pss_ehe-famse.
gf_string+24(25) = gs_pss_ehe-famna.
gf_string+49(25) = gs_pss_ehe-famvo.
gf_string+74(10) = gs_pss_ehe-fgbdt.
gf_string+84(10) = gs_pss_ehe-dstod.
gf_string+94(3) = gs_pss_ehe-fasex .
" Charakterfeld wird in einen String verschoben
gs_data-string = gf_string.
" Der Ausgabe Tabelle wird die String Zeile hinzugefügt
APPEND gs_data TO gt_data.
ENDIF.
" Initialisieren
CLEAR: gs_data-string, gf_string.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form ADD_PSS_ADR
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM add_pss_adr .
" Feld Recordart
gs_pss_adr-recat = '302'.
" Feld Personal_Id
gs_pss_adr-perna = pernr-pernr.
SHIFT gs_pss_adr-perna LEFT DELETING LEADING '0'.
SHIFT gs_pss_adr-perna RIGHT DELETING TRAILING space.
" Feld Adressart
gs_pss_adr-adres = ' 0'.
" Zugrif IT 0002
PROVIDE * FROM p0002 BETWEEN gf_datum AND gf_datum. "-----------------**
" Feld Anrede
IF p0002-anred = 1.
gs_pss_adr-anred = ' 0'.
ELSE.
gs_pss_adr-anred = ' 1'.
ENDIF.
" Feld Titel
gs_pss_adr-titel = p0002-titel.
ENDPROVIDE. "---------------------------------------------------------**
" Zugrif IT 0006
PROVIDE * FROM p0006 BETWEEN gf_datum AND gf_datum."-----------------**
IF p0006-subty = '1'.
"Check Subty vorhanden
gf_subty = 'X'.
" Feld Adresszeile 1
gs_pss_adr-stras = p0006-stras.
" Feld Adresszeile 2
gs_pss_adr-adre1 = ''.
" Feld Adresszeile 3
gs_pss_adr-adre2 = ''.
" Feld PLZ
gs_pss_adr-pstlz = p0006-pstlz.
IF p0006-pstlz IS INITIAL.
gf_ok = 'E'.
CLEAR: gs_errors.
gf_counter = gf_counter + 1.
gs_errors-counter = gf_counter.
gs_errors-light = 1.
gs_errors-mesid = 'E'.
CONCATENATE 'Im IT0006 ist das Feld PLZ nicht gepflegt für die PNR ' pernr-pernr INTO gs_errors-metxt.
APPEND gs_errors TO gt_errors.
ENDIF.
" Feld Ort
gs_pss_adr-ort01 = p0006-ort01.
IF p0006-ort01 IS INITIAL.
gf_ok = 'E'.
CLEAR: gs_errors.
gf_counter = gf_counter + 1.
gs_errors-counter = gf_counter.
gs_errors-light = 1.
gs_errors-mesid = 'E'.
CONCATENATE 'Im IT0006 ist das Feld Ort nicht gepflegt für die PNR ' pernr-pernr INTO gs_errors-metxt.
APPEND gs_errors TO gt_errors.
ENDIF.
" Feld Land
gs_pss_adr-land1 = p0006-land1.
IF gs_pss_adr-land1 = 'CH '.
" Feld Kanton
gs_pss_adr-state = p0006-state.
ENDIF.
ELSE.
"mache nichts
ENDIF.
ENDPROVIDE. "---------------------------------------------------------**
IF sy-subrc <> 0 OR gf_subty IS INITIAL.
gf_ok = 'E'.
CLEAR: gs_errors.
gf_counter = gf_counter + 1.
gs_errors-counter = gf_counter.
gs_errors-light = 1.
gs_errors-mesid = 'E'.
CONCATENATE 'Der IT0006 oder der Subtyp 1 existiert nicht für die PNR' pernr-pernr INTO gs_errors-metxt.
APPEND gs_errors TO gt_errors.
ENDIF.
CLEAR: gf_subty.
PROVIDE * FROM p0105 BETWEEN pn-begda AND pn-endda."------------------**
CHECK: p0105-subty = '9015'.
" Feld Tel_Nummer
gs_pss_adr-usrty = p0105-usrid.
" Feld Fax_Nummer
gs_pss_adr-faxnr = ''.
ENDPROVIDE. "---------------------------------------------------------**
PROVIDE * FROM p0105 BETWEEN pn-begda AND pn-endda."------------------**
CHECK: p0105-subty = '9030'.
" Feld EMail
gs_pss_adr-usrid = p0105-usrid.
ENDPROVIDE. "---------------------------------------------------------**
" Feld Mitteilung_1
gs_pss_adr-mit01 = ''.
" Feld Mitteilung_2
gs_pss_adr-mit02 = ''.
" Feld Mitteilung_3
gs_pss_adr-mit03 = ''.
" Feld Mitteilung_4
gs_pss_adr-mit04 = ''.
" Tabelle gt_pss wird befüllt
APPEND gs_pss_adr TO gt_pss_adr.
MOVE-CORRESPONDING gs_pss_adr TO gs_error.
"========================================================================="
" Nur Daten ohne Fehler wegschreiben.
IF gf_ok = 'S'.
" Zeile wird in ein Charakterfeld eingefügt
gf_string(3) = gs_pss_adr-recat.
gf_string+3(8) = gs_pss_adr-perna.
gf_string+11(3) = gs_pss_adr-adres.
gf_string+14(3) = gs_pss_adr-anred.
gf_string+17(35) = gs_pss_adr-stras.
gf_string+52(35) = gs_pss_adr-adre1.
gf_string+87(35) = gs_pss_adr-adre2.
gf_string+122(6) = gs_pss_adr-pstlz.
gf_string+128(25) = gs_pss_adr-ort01.
gf_string+153(2) = gs_pss_adr-state.
gf_string+155(4) = gs_pss_adr-land1.
gf_string+159(18) = gs_pss_adr-usrty.
gf_string+177(18) = gs_pss_adr-faxnr.
gf_string+195(50) = gs_pss_adr-usrid.
gf_string+245(25) = gs_pss_adr-titel.
gf_string+270(25) = gs_pss_adr-mit01.
gf_string+295(25) = gs_pss_adr-mit02.
gf_string+320(25) = gs_pss_adr-mit03.
gf_string+345(25) = gs_pss_adr-mit04.
" Charakterfeld wird in einen String verschoben
gs_data-string = gf_string.
" Der Ausgabe Tabelle wird die String Zeile hinzugefügt
APPEND gs_data TO gt_data.
ENDIF.
" Initialisieren
CLEAR: gs_data-string, gf_string.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form ADD_PSS_GRU
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM add_pss_gru .
" Feld Recordart
gs_pss_gru-recoa = '602'.
" Feld Personal_Id
gs_pss_gru-recoi = pernr-pernr.
SHIFT gs_pss_gru-recoi LEFT DELETING LEADING '0'.
SHIFT gs_pss_gru-recoi RIGHT DELETING TRAILING space.
" Zugrif IT 0008
PROVIDE * FROM p0008 BETWEEN gf_datum AND gf_datum. "-----------------**
" Feld Gueltig_Ab
* CONCATENATE p0008-begda+6(2) '.' p0008-begda+4(2) '.' p0008-begda(4)
* INTO gs_pss_gru-begda.
SELECT SINGLE begda FROM pa0008
INTO gf_begda
WHERE pernr = pernr-pernr AND
" OBJPS = space AND "Objektidentikfikation Falls 2 Sätze mit gleichen Primärkey existieren
sprps = space AND "Sperkennzeichen
" subty = '1' AND
begda <= gf_datum AND
endda >= gf_datum.
" seqnr
CONCATENATE gf_begda+6(2) '.' gf_begda+4(2) '.' gf_begda(4)
INTO gs_pss_gru-begda.
IF gs_pss_gru-begda IS INITIAL.
gf_ok = 'E'.
CLEAR: gs_errors.
gf_counter = gf_counter + 1.
gs_errors-counter = gf_counter.
gs_errors-light = 1.
gs_errors-mesid = 'E'.
CONCATENATE 'Im IT0008 ist das Feld Gültig ab nicht gepflegt für die PNR ' pernr-pernr INTO gs_errors-metxt.
APPEND gs_errors TO gt_errors.
ENDIF.
" Feld Gueltig_Bis
gs_pss_gru-endda = ''.
" Feld Betrag
gs_pss_gru-ansal = p0008-ansal.
"Falls das Feld durch eine indirekte Bewertung berechnet wird. Manuelle berechnung mit FUBA
IF p0008-ansal IS INITIAL.
"=======================================================================
" Manuelle Berechnung für ANSAL = Jahresgehalt im IT0008
"=======================================================================
" Dies muss gemacht werden weil dieses Feld zur Laufzeit berechnet wird.
"=======================================================================
" Relevante Lohnarten für ANSAL Berechnung
"=======================================================================
"CSAL Vergleich Sollbezahlung 1 01.01.1900 31.12.9999 1000 Monatsgehalt 100.00
"CSAL Vergleich Sollbezahlung 2 01.01.1900 31.12.9999 1060 Monatsgehalt 100.00
"CSAL Vergleich Sollbezahlung 3 01.01.1900 31.12.9999 1020 Monatsfixum 100.00
"=======================================================================
" Merkmal PFREQ
"=======================================================================
" Zahlungsfrequenz für ANSAL fünfter Rückgabewert ist Relevant
DATA: gf_ansal TYPE pa0008-ansal.
" Fuba aus Funktionsgruppe PARA
CALL FUNCTION 'RP_ANSAL_FROM_PERNR'
EXPORTING
f_date = gf_datum
f_tclas = 'A'
f_pernr = pernr-pernr
IMPORTING
f_ansal = gf_ansal
EXCEPTIONS
internal_error = 1
error_read_0001 = 2
error_read_0008 = 3
error_at_indirect_evaluation = 4
currency_conversion_error = 5
OTHERS = 6.
IF sy-subrc = 0.
gs_pss_gru-ansal = gf_ansal.
ENDIF.
ENDIF.
SHIFT gs_pss_gru-ansal RIGHT DELETING TRAILING space.
IF p0008-ansal IS INITIAL AND gf_ansal IS INITIAL.
gf_ok = 'E'.
CLEAR: gs_errors.
gf_counter = gf_counter + 1.
gs_errors-counter = gf_counter.
gs_errors-light = 1.
gs_errors-mesid = 'E'.
CONCATENATE 'Im IT0008 ist das Feld Jahresgehalt nicht gepflegt für die PNR ' pernr-pernr INTO gs_errors-metxt.
APPEND gs_errors TO gt_errors.
ENDIF.
" Feld Mutationsdatum
CONCATENATE p0008-aedtm+6(2) '.' p0008-aedtm+4(2) '.' p0008-aedtm(4)
INTO gs_pss_gru-mutad.
" Feld Beschäftigungsgrad
gs_pss_gru-bsgrd = p0008-bsgrd.
ENDPROVIDE. "---------------------------------------------------------**
IF sy-subrc <> 0.
gf_ok = 'E'.
CLEAR: gs_errors.
gf_counter = gf_counter + 1.
gs_errors-counter = gf_counter.
gs_errors-light = 1.
gs_errors-mesid = 'E'.
CONCATENATE 'Der IT0008 existiert nicht für die PNR' pernr-pernr INTO gs_errors-metxt.
APPEND gs_errors TO gt_errors.
ENDIF.
" Feld PKTyp_Id
gs_pss_gru-pktyp = '011'.
" Feld Reglement_Id
gs_pss_gru-regli = '021000'.
" Feld IV_Grad
gs_pss_gru-ivgra = ''.
" Tabelle gt_pss wird befüllt
APPEND gs_pss_gru TO gt_pss_gru.
MOVE-CORRESPONDING gs_pss_gru TO gs_error.
"========================================================================="
" Nur Daten ohne Fehler wegschreiben.
IF gf_ok = 'S'.
" Zeile wird in ein Charakterfeld eingefügt
gf_string(3) = gs_pss_gru-recoa.
gf_string+3(8) = gs_pss_gru-recoi.
gf_string+11(10) = gs_pss_gru-begda.
gf_string+21(10) = gs_pss_gru-endda.
gf_string+31(3) = gs_pss_gru-pktyp .
gf_string+34(12) = gs_pss_gru-ansal.
gf_string+46(6) = gs_pss_gru-regli.
gf_string+52(10) = gs_pss_gru-mutad.
gf_string+62(6) = gs_pss_gru-bsgrd.
gf_string+69(6) = gs_pss_gru-ivgra.
" Charakterfeld wird in einen String verschoben
gs_data-string = gf_string.
" Der Ausgabe Tabelle wird die String Zeile hinzugefügt
APPEND gs_data TO gt_data.
ENDIF.
" Initialisieren
CLEAR: gs_data-string, gf_string.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form SORT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM sort .
" Absteigend sortieren
SORT gt_data BY string ASCENDING.
SORT gt_error BY pernr ASCENDING.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form ADD_FUSS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM add_fuss .
"=======================================================================
" Fussdaten sammeln
"=======================================================================
" Feld Fusszeile wird befüllt
gs_fuss-fussz = 'FUSSZEILE:'.
" Feld Anzahl Records wird befüllt
DESCRIBE TABLE gt_data LINES gs_fuss-anzre.
SHIFT gs_fuss-anzre RIGHT DELETING TRAILING space.
OVERLAY gs_fuss-anzre WITH '00000'.
" Zeile wird in ein Charakterfeld eingefügt
gf_string = gs_fuss-fussz.
gf_string+10(5) = gs_fuss-anzre.
" Charakterfeld wird in einen String verschoben
gs_data-string = gf_string.
" Der Ausgabe Tabelle wird die String Zeile hinzugefügt
APPEND gs_data TO gt_data.
" Initialisieren
CLEAR: gs_data-string, gf_string.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form SAVE_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM save_data .
****************************************************************
* Daten speichern
****************************************************************
" Lokale Datendeklaration
DATA: lf_filename TYPE string.
" Filename dem String Parameter übergeben.
lf_filename = pa_file.
" TXT File auf den Desktop downlaoden.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = lf_filename
filetype = 'ASC'
TABLES
data_tab = gt_data
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
INSERT zhr_pk_output FROM TABLE gt_error.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form ALV_TXT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM alv_txt .
*-----------------------------------------------------------------------
* Beginn ALV-Ausgabe
*-----------------------------------------------------------------------
* Kopieren Sie diesen Block an das Endes des Verarbeitungsblocks
* des ABAP-Programms
*-----------------------------------------------------------------------
" Instanz der Klasse cl_salv_table erzeugen
cl_salv_table=>factory(
IMPORTING r_salv_table = go_alv
CHANGING t_table = gt_error ).
" Funktionstasten (Sortieren, Filtern, Excel-Export etc.)
go_functions = go_alv->get_functions( ).
go_functions->set_all( abap_true ).
" optimale Spaltenbreite
go_columns = go_alv->get_columns( ).
go_columns->set_optimize( abap_true ).
" Titel und/oder Streifenmuster
go_display = go_alv->get_display_settings( ).
IF pa_test <> 'X'.
go_display->set_list_header( value = text-040 ).
ELSE.
go_display->set_list_header( value = text-041 ).
ENDIF.
go_display->set_striped_pattern( abap_true ).
" get layout object
go_layout = go_alv->get_layout( ).
" set Layout save restriction
" 1. Set Layout Key .. Unique key identifies the Differenet ALVs
gs_key-report = sy-repid.
go_layout->set_key( gs_key ).
" 2. Remove Save layout the restriction.
go_layout->set_save_restriction( if_salv_c_layout=>restrict_none ).
" set initial Layout
gf_variant = '/DEFAULT'.
go_layout->set_initial_layout( gf_variant ).
*" Ereignisse einlesen und Handler für Doppelklick registrieren
* go_events = go_alv->get_event( ).
* SET HANDLER lcl_handler=>on_double_click FOR go_events.
" Ampel einbauen
" 1. Hole die Zeilen
go_columns = go_alv->get_columns( ).
" 2. Hole sag bei welcher Spalte eine Ampelfunktion hinterlegt werden soll.
go_columns->set_exception_column( value = 'LIGHT' ).
TRY.
go_column ?= go_columns->get_column( 'LIGHT' ).
go_column->set_medium_text( 'STATUS' ).
go_column->set_long_text( 'STATUS' ).
go_column->set_short_text( 'STATUS' ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
" Feldkatalog erstellen.
go_column ?= go_columns->get_column( 'COUNTER' ).
go_column->set_medium_text( 'Count' ).
go_column->set_long_text( 'Count' ).
go_column->set_short_text( 'Count' ).
go_column ?= go_columns->get_column( 'MESID' ).
go_column->set_medium_text( 'Message ID' ).
go_column->set_long_text( 'Message ID' ).
go_column->set_short_text( 'ID' ).
go_column ?= go_columns->get_column( 'METXT' ).
go_column->set_medium_text( 'Message' ).
go_column->set_long_text( 'Message' ).
go_column->set_short_text( 'Message' ).
go_column ?= go_columns->get_column( 'RECAR' ).
go_column->set_long_text( 'Recordart' ).
gs_color-col = '1'.
gs_color-int = '1'.
gs_color-inv = '0'.
go_column->set_color( gs_color ).
go_column ?= go_columns->get_column( 'PERNS' ).
go_column->set_short_text( 'PNR' ).
go_column->set_medium_text( 'Personalnummer' ).
go_column->set_long_text( 'Personalnummer' ).
go_column ?= go_columns->get_column( 'PERNR' ).
go_column->set_short_text( 'PNR ID' ).
go_column->set_medium_text( 'Personal Id' ).
go_column->set_long_text( 'Personal Id' ).
go_column ?= go_columns->get_column( 'NACHN' ).
go_column->set_short_text( 'Nachname' ).
go_column->set_medium_text( 'Nachname' ).
go_column->set_long_text( 'Nachname' ).
go_column ?= go_columns->get_column( 'VORNA' ).
go_column->set_short_text( 'Vorname' ).
go_column->set_medium_text( 'Vorname' ).
go_column->set_long_text( 'Vorname' ).
go_column ?= go_columns->get_column( 'GESCH' ).
go_column->set_short_text( 'Gesch.' ).
go_column->set_medium_text( 'Geschlecht' ).
go_column->set_long_text( 'Geschlecht' ).
go_column ?= go_columns->get_column( 'GBPAS' ).
go_column->set_short_text( 'Geburtsd.' ).
go_column->set_medium_text( 'Geburtsdatum' ).
go_column->set_long_text( 'Geburtsdatum' ).
go_column ?= go_columns->get_column( 'SPRSL' ).
go_column->set_short_text( 'Sprache' ).
go_column->set_medium_text( 'Sprache' ).
go_column->set_long_text( 'Sprache' ).
go_column ?= go_columns->get_column( 'FAMST' ).
go_column->set_short_text( 'Zivils.' ).
go_column->set_medium_text( 'Zivilstand' ).
go_column->set_long_text( 'Zivilstand' ).
go_column ?= go_columns->get_column( 'GESPU' ).
go_column->set_short_text( 'Ges. Prü.' ).
go_column->set_medium_text( 'Gesundheitsprüfung' ).
go_column->set_long_text( 'Gesundheitsprüfung' ).
go_column ?= go_columns->get_column( 'PERKA' ).
go_column->set_short_text( 'PersKat.' ).
go_column->set_medium_text( 'Personalkategorie' ).
go_column->set_long_text( 'Personalkategorie' ).
go_column ?= go_columns->get_column( 'BERUF' ).
go_column->set_short_text( 'Beruf' ).
go_column->set_medium_text( 'Beruf' ).
go_column->set_long_text( 'Beruf' ).
go_column ?= go_columns->get_column( 'MUTDA' ).
go_column->set_short_text( 'Mut.Dat.' ).
go_column->set_medium_text( 'Mutationsdatum' ).
go_column->set_long_text( 'Mutationsdatum' ).
go_column ?= go_columns->get_column( 'ZUSID' ).
go_column->set_short_text( 'Zusatz. ID' ).
go_column->set_medium_text( 'Zusatzinformation ID' ).
go_column->set_long_text( 'Zusatzinformation ID' ).
go_column ?= go_columns->get_column( 'ZUSNR' ).
go_column->set_short_text( 'Zus.Nr.' ).
go_column->set_medium_text( 'Zusatznummer' ).
go_column->set_long_text( 'Zusatznummer' ).
go_column ?= go_columns->get_column( 'REGID' ).
go_column->set_short_text( 'Reg. ID' ).
go_column->set_medium_text( 'Reglement ID' ).
go_column->set_long_text( 'Reglement ID' ).
go_column ?= go_columns->get_column( 'PKDAT' ).
go_column->set_short_text( 'EintPK' ).
go_column->set_medium_text( 'Eintrittsdatum PK' ).
go_column->set_long_text( 'Eintrittsdatum Pensionskasse' ).
go_column ?= go_columns->get_column( 'FIRED' ).
go_column->set_short_text( 'AustriDat' ).
go_column->set_medium_text( 'Austrittsdatum' ).
go_column->set_long_text( 'Austrittsdatum' ).
go_column ?= go_columns->get_column( 'MASSG' ).
go_column->set_short_text( 'Aus. Gru.' ).
go_column->set_medium_text( 'Austrittsgurnd' ).
go_column->set_long_text( 'Austrittsgrund' ).
go_column ?= go_columns->get_column( 'PERID' ).
go_column->set_short_text( 'PB ID' ).
go_column->set_medium_text( 'Personalb. ID' ).
go_column->set_long_text( 'Personalbereich ID' ).
go_column ?= go_columns->get_column( 'WERKS' ).
go_column->set_short_text( 'B. ID' ).
go_column->set_medium_text( 'Betrieb ID' ).
go_column->set_long_text( 'Betrieb ID' ).
go_column ?= go_columns->get_column( 'EINBE' ).
go_column->set_short_text( 'EintBetr.' ).
go_column->set_medium_text( 'Eintritt Betrieb' ).
go_column->set_long_text( 'Eintrittsdatum Betrieb' ).
go_column ?= go_columns->get_column( 'AHVNR' ).
go_column->set_short_text( 'AHV Id' ).
go_column->set_medium_text( 'AHV Id' ).
go_column->set_long_text( 'AHV Id' ).
go_column ?= go_columns->get_column( 'ZUSDA' ).
go_column->set_short_text( 'Zu. Dat.' ).
go_column->set_medium_text( 'Zusatz Dat.' ).
go_column->set_long_text( 'Zusatz Datum' ).
go_column ?= go_columns->get_column( 'NAHVN' ).
go_column->set_short_text( 'SozVers Id' ).
go_column->set_medium_text( 'SozVers Id' ).
go_column->set_long_text( 'Sozialversicherungs ID' ).
go_column ?= go_columns->get_column( 'REART' ).
go_column->set_long_text( 'Recordart' ).
gs_color-col = '1'.
gs_color-int = '1'.
gs_color-inv = '0'.
go_column->set_color( gs_color ).
go_column ?= go_columns->get_column( 'PERNI' ).
go_column->set_short_text( 'Pers. Id' ).
go_column->set_medium_text( 'Personal Id' ).
go_column->set_long_text( 'Personal Id' ).
go_column ?= go_columns->get_column( 'FAMDT' ).
go_column->set_short_text( 'Heiratsdat' ).
go_column->set_medium_text( 'Hereiratsdatum' ).
go_column->set_long_text( 'Hereiatsdatum' ).
go_column ?= go_columns->get_column( 'FAMSE' ).
go_column->set_short_text( 'Zivilst.' ).
go_column->set_medium_text( 'Zivilstand' ).
go_column->set_long_text( 'Zivilstand' ).
go_column ?= go_columns->get_column( 'FAMNA' ).
go_column->set_short_text( 'EName' ).
go_column->set_medium_text( 'EName' ).
go_column->set_long_text( 'EName' ).
go_column ?= go_columns->get_column( 'FAMVO' ).
go_column->set_short_text( 'Vorname' ).
go_column->set_medium_text( 'Vorname' ).
go_column->set_long_text( 'Vorname' ).
go_column ?= go_columns->get_column( 'FGBDT' ).
go_column->set_short_text( 'Geburtsd.' ).
go_column->set_medium_text( 'Geburtsdatum' ).
go_column->set_long_text( 'Geburtsdatum' ).
go_column ?= go_columns->get_column( 'DSTOD' ).
go_column->set_short_text( 'DAT S. T.' ).
go_column->set_medium_text( 'Datum Scheidung Tod' ).
go_column->set_long_text( 'Datum Scheidung Tod' ).
go_column ?= go_columns->get_column( 'FASEX' ).
go_column->set_short_text( 'Gesch. Id' ).
go_column->set_medium_text( 'Geschlecht Id' ).
go_column->set_long_text( 'Geschlecht ID' ).
go_column ?= go_columns->get_column( 'RECAT' ).
go_column->set_long_text( 'Recordart' ).
gs_color-col = '1'.
gs_color-int = '1'.
gs_color-inv = '0'.
go_column->set_color( gs_color ).
go_column ?= go_columns->get_column( 'PERNA' ).
go_column->set_short_text( 'Pers. Id' ).
go_column->set_medium_text( 'Personal Id' ).
go_column->set_long_text( 'Personal Id' ).
go_column ?= go_columns->get_column( 'ADRES' ).
go_column->set_short_text( 'AdArt' ).
go_column->set_medium_text( 'Adressart' ).
go_column->set_long_text( 'Adressart' ).
go_column ?= go_columns->get_column( 'ANRED' ).
go_column->set_short_text( 'Anrede' ).
go_column->set_medium_text( 'Anrede' ).
go_column->set_long_text( 'Anrede' ).
go_column ?= go_columns->get_column( 'STRAS' ).
go_column->set_short_text( 'Adressz1' ).
go_column->set_medium_text( 'Adresszeile 1' ).
go_column->set_long_text( 'Adresszeile 1' ).
go_column ?= go_columns->get_column( 'ADRE1' ).
go_column->set_short_text( 'Adressz2' ).
go_column->set_medium_text( 'Adresszeile 2' ).
go_column->set_long_text( 'Adresszeile 2' ).
go_column ?= go_columns->get_column( 'ADRE2' ).
go_column->set_short_text( 'Adressz3' ).
go_column->set_medium_text( 'Adresszeile 3' ).
go_column->set_long_text( 'Adresszeile 3' ).
go_column ?= go_columns->get_column( 'PSTLZ' ).
go_column->set_short_text( 'PLZ' ).
go_column->set_medium_text( 'PLZ' ).
go_column->set_long_text( 'PLZ' ).
go_column ?= go_columns->get_column( 'ORT01' ).
go_column->set_short_text( 'Ort' ).
go_column->set_medium_text( 'Ort' ).
go_column->set_long_text( 'Ort' ).
go_column ?= go_columns->get_column( 'STATE' ).
go_column->set_short_text( 'Kanton' ).
go_column->set_medium_text( 'Kanton' ).
go_column->set_long_text( 'Kanton' ).
go_column ?= go_columns->get_column( 'LAND1' ).
go_column->set_short_text( 'Land' ).
go_column->set_medium_text( 'Land' ).
go_column->set_long_text( 'Land' ).
go_column ?= go_columns->get_column( 'USRTY' ).
go_column->set_short_text( 'Tel Nr' ).
go_column->set_medium_text( 'Tel Nummer' ).
go_column->set_long_text( 'Telefonnummer' ).
go_column ?= go_columns->get_column( 'FAXNR' ).
go_column->set_short_text( 'Fax Nr' ).
go_column->set_medium_text( 'Fax Nr' ).
go_column->set_long_text( 'Faxnummer' ).
go_column ?= go_columns->get_column( 'USRID' ).
go_column->set_short_text( 'Email' ).
go_column->set_medium_text( 'Email' ).
go_column->set_long_text( 'Email' ).
go_column ?= go_columns->get_column( 'TITEL' ).
go_column->set_short_text( 'Titel' ).
go_column->set_medium_text( 'Titel' ).
go_column->set_long_text( 'Titel' ).
go_column ?= go_columns->get_column( 'MIT01' ).
go_column->set_short_text( 'Mit01' ).
go_column->set_medium_text( 'Mitteilung 1' ).
go_column->set_long_text( 'Mitteilung 1' ).
go_column ?= go_columns->get_column( 'MIT02' ).
go_column->set_short_text( 'Mit02' ).
go_column->set_medium_text( 'Mitteilung 2' ).
go_column->set_long_text( 'Mitteilung 2' ).
go_column ?= go_columns->get_column( 'MIT03' ).
go_column->set_short_text( 'Mit03' ).
go_column->set_medium_text( 'Mitteilung 3' ).
go_column->set_long_text( 'Mitteilung 3' ).
go_column ?= go_columns->get_column( 'MIT04' ).
go_column->set_short_text( 'Mit04' ).
go_column->set_medium_text( 'Mitteilung 4' ).
go_column->set_long_text( 'Mitteilung 4' ).
go_column ?= go_columns->get_column( 'RECOA' ).
go_column->set_long_text( 'Recordart' ).
gs_color-col = '1'.
gs_color-int = '1'.
gs_color-inv = '0'.
go_column->set_color( gs_color ).
go_column ?= go_columns->get_column( 'RECOI' ).
go_column->set_short_text( 'Pers Id' ).
go_column->set_medium_text( 'Personal Id' ).
go_column->set_long_text( 'Personal Id' ).
go_column ?= go_columns->get_column( 'BEGDA' ).
go_column->set_short_text( 'Gültig ab' ).
go_column->set_medium_text( 'Gültig ab' ).
go_column->set_long_text( 'Gültig ab' ).
go_column ?= go_columns->get_column( 'ENDDA' ).
go_column->set_short_text( 'Gültig bis' ).
go_column->set_medium_text( 'Gültig bis' ).
go_column->set_long_text( 'Gültig bis' ).
go_column ?= go_columns->get_column( 'PKTYP' ).
go_column->set_short_text( 'PKTyp Id' ).
go_column->set_medium_text( 'PKTyp Id' ).
go_column->set_long_text( 'PKTyp Id' ).
go_column ?= go_columns->get_column( 'ANSAL' ).
go_column->set_short_text( 'Betrag' ).
go_column->set_medium_text( 'Betrag' ).
go_column->set_long_text( 'Betrag' ).
go_column ?= go_columns->get_column( 'REGLI' ).
go_column->set_short_text( 'Reg Id' ).
go_column->set_medium_text( 'Reglement Id' ).
go_column->set_long_text( 'Reglement IDd' ).
go_column ?= go_columns->get_column( 'MUTAD' ).
go_column->set_short_text( 'MutDat' ).
go_column->set_medium_text( 'Mutationsdatum' ).
go_column->set_long_text( 'Mutationsdatum' ).
go_column ?= go_columns->get_column( 'BSGRD' ).
go_column->set_short_text( 'BsGrd' ).
go_column->set_medium_text( 'Bechäftigungsgrad' ).
go_column->set_long_text( 'Beschäftigungsgrad' ).
go_column ?= go_columns->get_column( 'IVGRA' ).
go_column->set_short_text( 'IV Grad' ).
go_column->set_medium_text( 'IV Grad' ).
go_column->set_long_text( 'IV Grad' ).
*" Liste anzeigen
go_alv->display( ).
ENDFORM.
*&---------------------------------------------------------------------*
*& Form CHECK_PERNR
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM check_pernr .
" Prüfen ob er im IT0046 Beitragspflichtig ist
PROVIDE * FROM p0046 BETWEEN gf_datum AND gf_datum. "-----------------**
" Setzte ein S nur Personen die Beitragspflichtig sind.
CLEAR: gf_ok.
IF p0046-vsges = 01 AND p0046-vsart = 01.
gf_ok = 'S'.
ELSE.
gf_ok = 'E'.
ENDIF.
ENDPROVIDE. "---------------------------------------------------------**
IF sy-subrc <> 0.
gf_ok = 'E'.
CLEAR: gs_errors.
gf_counter = gf_counter + 1.
gs_errors-counter = gf_counter.
gs_errors-light = 1.
gs_errors-mesid = 'E'.
CONCATENATE 'Der IT0046 existiert nicht für die PNR' pernr-pernr INTO gs_errors-metxt.
APPEND gs_errors TO gt_errors.
ENDIF.
IF gf_ok = 'S'.
" Püfen ob es ein Stundenlöhner ist
PROVIDE * FROM p0001 BETWEEN gf_datum AND gf_datum. "-----------------**
" Setzte ein S für Personen die nicht Stundenlöhner sind
" oder die Stundenlöhner sind und der aktuelle Monat Januar ist.
IF p0001-persk = '50' AND gf_datum+4(2) <> '01' AND gf_ok <> 'E'.
gf_ok = 'E'.
ENDIF.
ENDPROVIDE. "---------------------------------------------------------**
IF sy-subrc <> 0.
gf_ok = 'E'.
CLEAR: gs_errors.
gf_counter = gf_counter + 1.
gs_errors-counter = gf_counter.
gs_errors-light = 1.
gs_errors-mesid = 'E'.
CONCATENATE 'Der IT0001 existiert nicht für die PNR' pernr-pernr INTO gs_errors-metxt.
APPEND gs_errors TO gt_errors.
ENDIF.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form ADD_GT_ERROR
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM add_gt_error .
gs_error-mandt = sy-mandt.
gs_error-fname = gf_filename.
SELECT SINGLE MAX( laufn ) FROM zhr_pk_output INTO gs_error-laufn.
gs_error-laufn = gs_error-laufn + 1.
gs_error-pernrk = pernr-pernr.
gs_error-datum = sy-datum.
gs_error-uzeit = sy-uzeit.
gs_error-uname = sy-uname.
"Satznummer für das Fehlerprotokoll
gs_error-satzn = gf_satzn + 1.
IF gf_ok = 'S'.
gf_counter = gf_counter + 1.
gs_error-counter = gf_counter.
gs_error-light = 3.
gs_error-mesid = 'S'.
gs_error-metxt = 'Satz ist vollständig'.
APPEND gs_error TO gt_error.
ELSE.
LOOP AT gt_errors INTO gs_errors.
CLEAR: gs_error-light, gs_error-mesid, gs_error-metxt.
gs_error-counter = gs_errors-counter.
gs_error-light = gs_errors-light.
gs_error-mesid = gs_errors-mesid.
gs_error-metxt = gs_errors-metxt.
APPEND gs_error TO gt_error.
ENDLOOP.
ENDIF.
gf_satzn = gs_error-satzn.
CLEAR: gt_errors, gs_errors, gs_error, gf_counter.
ENDFORM.
Protokoll Output
************************************************************************
**************************** *******************************
*************************** MREGOTZ ******************************
**************************** *******************************
************************************************************************
*&H
*&H PROGRAMMNAME : ZHR_PK_OUTPUT_PROT
*&H TRANSAKTIONSCODE : ZHR_PK_OUTPUT_PROT
*&H PROGRAMMTITEL : PK Personalschnittstelle (PSS)
*&H ZWECK : Protokoll ZHR_PK_OUTPUT
*&H AUTOR : Regotz Michel
*&H DATUM : 01.10.2016
*&H SAP-MODUL : HR
*&H
*&H Company/Department : Swisscom AG
*&H Phone : +41 79 322 04 86 (Mobil)
*&H E-Mail : Michel.Regotz@Swisscom.ch
*&H
************************************************************************
*&D
*&D Beschreibung : Protokoll Historye des Programmes ZHR_PK_OUTPUT
*&D
*&D --------------------------------------------------------------------
************************************************************************
*&C Change history :
*&C --------------------------------------------------------------------
*&C Developer | Date | Description
*&C --------------------------------------------------------------------
*&C <Name> | <Date> | <Description>
*&C --------------------------------------------------------------------
*&C <Name> | <Date> | <Description>
*&C --------------------------------------------------------------------
*&C <Name> | <Date> | <Description>
*&C --------------------------------------------------------------------
*&C <Name> | <Date> | <Description>
************************************************************************
REPORT zhr_pk_output_prot MESSAGE-ID zhr_pk.
TABLES: zhr_pk_output.
"=======================================================================
" Datendeklaration für die Buttons steuern zu können
"=======================================================================
*-----------------------------------------------------------------------
* Beginn Datendeklarationen
*-----------------------------------------------------------------------
" Damit man die Buttons steuern kann.
*-----------------------------------------------------------------------
"=======================================================================
" Datendeklaration für den Dateinamen
"=======================================================================
*-----------------------------------------------------------------------
* Beginn Datendeklarationen
*-----------------------------------------------------------------------
" Damit man den Filenamen und Datei Pfad hat.
*-----------------------------------------------------------------------
"=======================================================================
" Datendeklaration Kopf Data und Fusszeile
"=======================================================================
*-----------------------------------------------------------------------
* Beginn Datendeklarationen
*-----------------------------------------------------------------------
* Datendeklaration für die Daten sammlung und gewinnung.
* Bis zur übergabe an das TXT File
*-----------------------------------------------------------------------
DATA: gt_error TYPE TABLE OF zhr_pk_output,
gs_error TYPE zhr_pk_output.
"=======================================================================
" Datendeklaration für ALV
"=======================================================================
*-----------------------------------------------------------------------
* Beginn Datendeklarationen fuer den ALV
*-----------------------------------------------------------------------
* Kopieren Sie diesen Block zu den Datendeklarationen des ABAP-Programms
* Auch die Handler-Definition fuer Doppeklick ist eine Deklaration
*-----------------------------------------------------------------------
DATA go_alv TYPE REF TO cl_salv_table.
DATA go_functions TYPE REF TO cl_salv_functions_list.
DATA: go_columns TYPE REF TO cl_salv_columns_table,
go_column TYPE REF TO cl_salv_column_table.
DATA: gs_color TYPE lvc_s_colo.
DATA go_display TYPE REF TO cl_salv_display_settings.
DATA go_events TYPE REF TO cl_salv_events_table.
DATA: go_layout TYPE REF TO cl_salv_layout,
gf_variant TYPE slis_vari,
gs_key TYPE salv_s_layout_key.
"=======================================================================
" Selektionsbildschirm
"=======================================================================
*-----------------------------------------------------------------------
* Beginn deklaration des Selektionsbildschirmes
*-----------------------------------------------------------------------
* Hier wird der Selektionsbildschirm erstellt
*-----------------------------------------------------------------------
" Block zum auswählen des Pfades und aktivieren des Test Buttons
SELECTION-SCREEN BEGIN OF BLOCK 10 WITH FRAME TITLE text-010.
SELECT-OPTIONS: s_fname FOR zhr_pk_output-fname,
s_laufn FOR zhr_pk_output-laufn,
s_satzn FOR zhr_pk_output-satzn,
s_count FOR zhr_pk_output-counter,
s_pernrk FOR zhr_pk_output-pernrk,
s_uname FOR zhr_pk_output-uname,
s_datum FOR zhr_pk_output-datum,
s_uzeit FOR zhr_pk_output-uzeit,
s_mesid FOR zhr_pk_output-mesid.
SELECTION-SCREEN END OF BLOCK 10.
"=======================================================================
" At Selection Screen Output
"=======================================================================
"=======================================================================
" AT SELECTION SCREEN
"=======================================================================
"=======================================================================
" AT SELECTION SCREEN ON VAlUE REQUEST FOR
"=======================================================================
"=======================================================================
" START OF SELECTION
"=======================================================================
INITIALIZATION.
START-OF-SELECTION.
" Daten in ITAB einfügen.
PERFORM add_data.
END-OF-SELECTION.
PERFORM alv_error.
*&---------------------------------------------------------------------*
*& Form ADD_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM add_data .
SELECT * INTO TABLE gt_error FROM zhr_pk_output
WHERE fname IN s_fname AND
laufn IN s_laufn AND
satzn IN s_count AND
pernrk IN s_pernrk AND
uname IN s_uname AND
datum IN s_datum AND
uzeit IN s_uzeit AND
mesid IN s_mesid.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form ALV_ERROR
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM alv_error .
*-----------------------------------------------------------------------
* Beginn ALV-Ausgabe
*-----------------------------------------------------------------------
* Kopieren Sie diesen Block an das Endes des Verarbeitungsblocks
* des ABAP-Programms
*-----------------------------------------------------------------------
" Instanz der Klasse cl_salv_table erzeugen
cl_salv_table=>factory(
IMPORTING r_salv_table = go_alv
CHANGING t_table = gt_error ).
" Funktionstasten (Sortieren, Filtern, Excel-Export etc.)
go_functions = go_alv->get_functions( ).
go_functions->set_all( abap_true ).
" optimale Spaltenbreite
go_columns = go_alv->get_columns( ).
go_columns->set_optimize( abap_true ).
" Titel und/oder Streifenmuster
go_display = go_alv->get_display_settings( ).
go_display->set_list_header( value = text-030 ).
go_display->set_striped_pattern( abap_true ).
" get layout object
go_layout = go_alv->get_layout( ).
" set Layout save restriction
" 1. Set Layout Key .. Unique key identifies the Differenet ALVs
gs_key-report = sy-repid.
go_layout->set_key( gs_key ).
" 2. Remove Save layout the restriction.
go_layout->set_save_restriction( if_salv_c_layout=>restrict_none ).
" set initial Layout
gf_variant = '/DEFAULT'.
go_layout->set_initial_layout( gf_variant ).
*" Ereignisse einlesen und Handler für Doppelklick registrieren
* go_events = go_alv->get_event( ).
* SET HANDLER lcl_handler=>on_double_click FOR go_events.
" Ampel einbauen
" 1. Hole die Zeilen
go_columns = go_alv->get_columns( ).
" 2. Hole sag bei welcher Spalte eine Ampelfunktion hinterlegt werden soll.
go_columns->set_exception_column( value = 'LIGHT' ).
TRY.
go_column ?= go_columns->get_column( 'LIGHT' ).
go_column->set_medium_text( 'STATUS' ).
go_column->set_long_text( 'STATUS' ).
go_column->set_short_text( 'STATUS' ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
" Feldkatalog erstellen.
go_column ?= go_columns->get_column( 'COUNTER' ).
go_column->set_medium_text( 'Count' ).
go_column->set_long_text( 'Count' ).
go_column->set_short_text( 'Count' ).
go_column ?= go_columns->get_column( 'MESID' ).
go_column->set_medium_text( 'Message ID' ).
go_column->set_long_text( 'Message ID' ).
go_column->set_short_text( 'ID' ).
go_column ?= go_columns->get_column( 'METXT' ).
go_column->set_medium_text( 'Message' ).
go_column->set_long_text( 'Message' ).
go_column->set_short_text( 'Message' ).
go_column ?= go_columns->get_column( 'RECAR' ).
go_column->set_long_text( 'Rekortart' ).
gs_color-col = '1'.
gs_color-int = '1'.
gs_color-inv = '0'.
go_column->set_color( gs_color ).
go_column ?= go_columns->get_column( 'PERNS' ).
go_column->set_short_text( 'PNR' ).
go_column->set_medium_text( 'Personalnummer' ).
go_column->set_long_text( 'Personalnummer' ).
go_column ?= go_columns->get_column( 'PERNR' ).
go_column->set_short_text( 'PNR ID' ).
go_column->set_medium_text( 'Personal Id' ).
go_column->set_long_text( 'Personal Id' ).
go_column ?= go_columns->get_column( 'NACHN' ).
go_column->set_short_text( 'Nachname' ).
go_column->set_medium_text( 'Nachname' ).
go_column->set_long_text( 'Nachname' ).
go_column ?= go_columns->get_column( 'VORNA' ).
go_column->set_short_text( 'Vorname' ).
go_column->set_medium_text( 'Vorname' ).
go_column->set_long_text( 'Vorname' ).
go_column ?= go_columns->get_column( 'GESCH' ).
go_column->set_short_text( 'Gesch.' ).
go_column->set_medium_text( 'Geschlecht' ).
go_column->set_long_text( 'Geschlecht' ).
go_column ?= go_columns->get_column( 'GBPAS' ).
go_column->set_short_text( 'Geburtsd.' ).
go_column->set_medium_text( 'Geburtsdatum' ).
go_column->set_long_text( 'Geburtsdatum' ).
go_column ?= go_columns->get_column( 'SPRSL' ).
go_column->set_short_text( 'Sprache' ).
go_column->set_medium_text( 'Sprache' ).
go_column->set_long_text( 'Sprache' ).
go_column ?= go_columns->get_column( 'FAMST' ).
go_column->set_short_text( 'Zivils.' ).
go_column->set_medium_text( 'Zivilstand' ).
go_column->set_long_text( 'Zivilstand' ).
go_column ?= go_columns->get_column( 'GESPU' ).
go_column->set_short_text( 'Ges. Prü.' ).
go_column->set_medium_text( 'Gesundheitsprüfung' ).
go_column->set_long_text( 'Gesundheitsprüfung' ).
go_column ?= go_columns->get_column( 'PERKA' ).
go_column->set_short_text( 'PersKat.' ).
go_column->set_medium_text( 'Personalkategorie' ).
go_column->set_long_text( 'Personalkategorie' ).
go_column ?= go_columns->get_column( 'BERUF' ).
go_column->set_short_text( 'Beruf' ).
go_column->set_medium_text( 'Beruf' ).
go_column->set_long_text( 'Beruf' ).
go_column ?= go_columns->get_column( 'MUTDA' ).
go_column->set_short_text( 'Mut.Dat.' ).
go_column->set_medium_text( 'Mutationsdatum' ).
go_column->set_long_text( 'Mutationsdatum' ).
go_column ?= go_columns->get_column( 'ZUSID' ).
go_column->set_short_text( 'Zusatz. ID' ).
go_column->set_medium_text( 'Zusatzinformation ID' ).
go_column->set_long_text( 'Zusatzinformation ID' ).
go_column ?= go_columns->get_column( 'ZUSNR' ).
go_column->set_short_text( 'Zus.Nr.' ).
go_column->set_medium_text( 'Zusatznummer' ).
go_column->set_long_text( 'Zusatznummer' ).
go_column ?= go_columns->get_column( 'REGID' ).
go_column->set_short_text( 'Reg. ID' ).
go_column->set_medium_text( 'Reglement ID' ).
go_column->set_long_text( 'Reglement ID' ).
go_column ?= go_columns->get_column( 'PKDAT' ).
go_column->set_short_text( 'EintPK' ).
go_column->set_medium_text( 'Eintrittsdatum PK' ).
go_column->set_long_text( 'Eintrittsdatum Pensionskasse' ).
go_column ?= go_columns->get_column( 'FIRED' ).
go_column->set_short_text( 'AustriDat' ).
go_column->set_medium_text( 'Austrittsdatum' ).
go_column->set_long_text( 'Austrittsdatum' ).
go_column ?= go_columns->get_column( 'MASSG' ).
go_column->set_short_text( 'Aus. Gru.' ).
go_column->set_medium_text( 'Austrittsgurnd' ).
go_column->set_long_text( 'Austrittsgrund' ).
go_column ?= go_columns->get_column( 'PERID' ).
go_column->set_short_text( 'PB ID' ).
go_column->set_medium_text( 'Personalb. ID' ).
go_column->set_long_text( 'Personalbereich ID' ).
go_column ?= go_columns->get_column( 'WERKS' ).
go_column->set_short_text( 'B. ID' ).
go_column->set_medium_text( 'Betrieb ID' ).
go_column->set_long_text( 'Betrieb ID' ).
go_column ?= go_columns->get_column( 'EINBE' ).
go_column->set_short_text( 'EintBetr.' ).
go_column->set_medium_text( 'Eintritt Betrieb' ).
go_column->set_long_text( 'Eintrittsdatum Betrieb' ).
go_column ?= go_columns->get_column( 'AHVNR' ).
go_column->set_short_text( 'AHV Id' ).
go_column->set_medium_text( 'AHV Id' ).
go_column->set_long_text( 'AHV Id' ).
go_column ?= go_columns->get_column( 'ZUSDA' ).
go_column->set_short_text( 'Zu. Dat.' ).
go_column->set_medium_text( 'Zusatz Dat.' ).
go_column->set_long_text( 'Zusatz Datum' ).
go_column ?= go_columns->get_column( 'NAHVN' ).
go_column->set_short_text( 'SozVers Id' ).
go_column->set_medium_text( 'SozVers Id' ).
go_column->set_long_text( 'Sozialversicherungs ID' ).
go_column ?= go_columns->get_column( 'REART' ).
go_column->set_long_text( 'Rekortart' ).
gs_color-col = '1'.
gs_color-int = '1'.
gs_color-inv = '0'.
go_column->set_color( gs_color ).
go_column ?= go_columns->get_column( 'PERNI' ).
go_column->set_short_text( 'Pers. Id' ).
go_column->set_medium_text( 'Personal Id' ).
go_column->set_long_text( 'Personal Id' ).
go_column ?= go_columns->get_column( 'FAMDT' ).
go_column->set_short_text( 'Heiratsdat' ).
go_column->set_medium_text( 'Hereiratsdatum' ).
go_column->set_long_text( 'Hereiatsdatum' ).
go_column ?= go_columns->get_column( 'FAMSE' ).
go_column->set_short_text( 'Zivilst.' ).
go_column->set_medium_text( 'Zivilstand' ).
go_column->set_long_text( 'Zivilstand' ).
go_column ?= go_columns->get_column( 'FAMNA' ).
go_column->set_short_text( 'EName' ).
go_column->set_medium_text( 'EName' ).
go_column->set_long_text( 'EName' ).
go_column ?= go_columns->get_column( 'FAMVO' ).
go_column->set_short_text( 'Vorname' ).
go_column->set_medium_text( 'Vorname' ).
go_column->set_long_text( 'Vorname' ).
go_column ?= go_columns->get_column( 'FGBDT' ).
go_column->set_short_text( 'Geburtsd.' ).
go_column->set_medium_text( 'Geburtsdatum' ).
go_column->set_long_text( 'Geburtsdatum' ).
go_column ?= go_columns->get_column( 'DSTOD' ).
go_column->set_short_text( 'DAT S. T.' ).
go_column->set_medium_text( 'Datum Scheidung Tod' ).
go_column->set_long_text( 'Datum Scheidung Tod' ).
go_column ?= go_columns->get_column( 'FASEX' ).
go_column->set_short_text( 'Gesch. Id' ).
go_column->set_medium_text( 'Geschlecht Id' ).
go_column->set_long_text( 'Geschlecht ID' ).
go_column ?= go_columns->get_column( 'RECAT' ).
go_column->set_long_text( 'Rekortart' ).
gs_color-col = '1'.
gs_color-int = '1'.
gs_color-inv = '0'.
go_column->set_color( gs_color ).
go_column ?= go_columns->get_column( 'PERNA' ).
go_column->set_short_text( 'Pers. Id' ).
go_column->set_medium_text( 'Personal Id' ).
go_column->set_long_text( 'Personal Id' ).
go_column ?= go_columns->get_column( 'ADRES' ).
go_column->set_short_text( 'AdArt' ).
go_column->set_medium_text( 'Adressart' ).
go_column->set_long_text( 'Adressart' ).
go_column ?= go_columns->get_column( 'ANRED' ).
go_column->set_short_text( 'Anrede' ).
go_column->set_medium_text( 'Anrede' ).
go_column->set_long_text( 'Anrede' ).
go_column ?= go_columns->get_column( 'STRAS' ).
go_column->set_short_text( 'Adressz1' ).
go_column->set_medium_text( 'Adresszeile 1' ).
go_column->set_long_text( 'Adresszeile 1' ).
go_column ?= go_columns->get_column( 'ADRE1' ).
go_column->set_short_text( 'Adressz2' ).
go_column->set_medium_text( 'Adresszeile 2' ).
go_column->set_long_text( 'Adresszeile 2' ).
go_column ?= go_columns->get_column( 'ADRE2' ).
go_column->set_short_text( 'Adressz3' ).
go_column->set_medium_text( 'Adresszeile 3' ).
go_column->set_long_text( 'Adresszeile 3' ).
go_column ?= go_columns->get_column( 'PSTLZ' ).
go_column->set_short_text( 'PLZ' ).
go_column->set_medium_text( 'PLZ' ).
go_column->set_long_text( 'PLZ' ).
go_column ?= go_columns->get_column( 'ORT01' ).
go_column->set_short_text( 'Ort' ).
go_column->set_medium_text( 'Ort' ).
go_column->set_long_text( 'Ort' ).
go_column ?= go_columns->get_column( 'STATE' ).
go_column->set_short_text( 'Kanton' ).
go_column->set_medium_text( 'Kanton' ).
go_column->set_long_text( 'Kanton' ).
go_column ?= go_columns->get_column( 'LAND1' ).
go_column->set_short_text( 'Land' ).
go_column->set_medium_text( 'Land' ).
go_column->set_long_text( 'Land' ).
go_column ?= go_columns->get_column( 'USRTY' ).
go_column->set_short_text( 'Tel Nr' ).
go_column->set_medium_text( 'Tel Nummer' ).
go_column->set_long_text( 'Telefonnummer' ).
go_column ?= go_columns->get_column( 'FAXNR' ).
go_column->set_short_text( 'Fax Nr' ).
go_column->set_medium_text( 'Fax Nr' ).
go_column->set_long_text( 'Faxnummer' ).
go_column ?= go_columns->get_column( 'USRID' ).
go_column->set_short_text( 'Email' ).
go_column->set_medium_text( 'Email' ).
go_column->set_long_text( 'Email' ).
go_column ?= go_columns->get_column( 'TITEL' ).
go_column->set_short_text( 'Titel' ).
go_column->set_medium_text( 'Titel' ).
go_column->set_long_text( 'Titel' ).
go_column ?= go_columns->get_column( 'MIT01' ).
go_column->set_short_text( 'Mit01' ).
go_column->set_medium_text( 'Mitteilung 1' ).
go_column->set_long_text( 'Mitteilung 1' ).
go_column ?= go_columns->get_column( 'MIT02' ).
go_column->set_short_text( 'Mit02' ).
go_column->set_medium_text( 'Mitteilung 2' ).
go_column->set_long_text( 'Mitteilung 2' ).
go_column ?= go_columns->get_column( 'MIT03' ).
go_column->set_short_text( 'Mit03' ).
go_column->set_medium_text( 'Mitteilung 3' ).
go_column->set_long_text( 'Mitteilung 3' ).
go_column ?= go_columns->get_column( 'MIT04' ).
go_column->set_short_text( 'Mit04' ).
go_column->set_medium_text( 'Mitteilung 4' ).
go_column->set_long_text( 'Mitteilung 4' ).
go_column ?= go_columns->get_column( 'RECOA' ).
go_column->set_long_text( 'Rekortart' ).
gs_color-col = '1'.
gs_color-int = '1'.
gs_color-inv = '0'.
go_column->set_color( gs_color ).
go_column ?= go_columns->get_column( 'RECOI' ).
go_column->set_short_text( 'Pers Id' ).
go_column->set_medium_text( 'Personal Id' ).
go_column->set_long_text( 'Personal Id' ).
go_column ?= go_columns->get_column( 'BEGDA' ).
go_column->set_short_text( 'Gültig ab' ).
go_column->set_medium_text( 'Gültig ab' ).
go_column->set_long_text( 'Gültig ab' ).
go_column ?= go_columns->get_column( 'ENDDA' ).
go_column->set_short_text( 'Gültig bis' ).
go_column->set_medium_text( 'Gültig bis' ).
go_column->set_long_text( 'Gültig bis' ).
go_column ?= go_columns->get_column( 'PKTYP' ).
go_column->set_short_text( 'PKTyp Id' ).
go_column->set_medium_text( 'PKTyp Id' ).
go_column->set_long_text( 'PKTyp Id' ).
go_column ?= go_columns->get_column( 'ANSAL' ).
go_column->set_short_text( 'Betrag' ).
go_column->set_medium_text( 'Betrag' ).
go_column->set_long_text( 'Betrag' ).
go_column ?= go_columns->get_column( 'REGLI' ).
go_column->set_short_text( 'Reg Id' ).
go_column->set_medium_text( 'Reglement Id' ).
go_column->set_long_text( 'Reglement IDd' ).
go_column ?= go_columns->get_column( 'MUTAD' ).
go_column->set_short_text( 'MutDat' ).
go_column->set_medium_text( 'Mutationsdatum' ).
go_column->set_long_text( 'Mutationsdatum' ).
go_column ?= go_columns->get_column( 'BSGRD' ).
go_column->set_short_text( 'BsGrd' ).
go_column->set_medium_text( 'Bechäftigungsgrad' ).
go_column->set_long_text( 'Beschäftigungsgrad' ).
go_column ?= go_columns->get_column( 'IVGRA' ).
go_column->set_short_text( 'IV Grad' ).
go_column->set_medium_text( 'IV Grad' ).
go_column->set_long_text( 'IV Grad' ).
*" Liste anzeigen
go_alv->display( ).
ENDFORM.