METHOD get_month_name.
DATA: month_names TYPE TABLE OF t247.
CALL FUNCTION 'MONTH_NAMES_GET'
TABLES
month_names = month_names
EXCEPTIONS
OTHERS = 0.
TRY.
r_name = month_names[ mnr = i_month ]-ltx.
CATCH cx_sy_itab_line_not_found.
ENDTRY.
ENDMETHOD.
Category: ABAP
ABAP
[ABAP] ALV column header
DATA: o_salv TYPE REF TO cl_salv_table.
cl_salv_table=>factory( IMPORTING r_salv_table = o_salv
CHANGING t_table = l_lines ).
LOOP AT o_salv->get_columns( )->get( ) REFERENCE INTO DATA(l_column).
DATA(lo_column) = CAST cl_salv_column( l_column->r_column ).
lo_column->set_fixed_header_text( 'L' ).
ENDLOOP.
o_salv->get_columns( )->get_column( 'TEST1' )->set_long_text( 'Test1 Header' ).
o_salv->get_columns( )->get_column( 'TEST2' )->set_long_text( 'Test2 Header' ).
[HR] Infotype – add PBO or PAI logic
There are many ways to add custom logic when processing an Infotype. Here are just a few:
SMOD
PBAS0001
PBAS0002
ZXPADU01 – when an infotype is called
ZXPADU02 – when an action is performed on an infotype
https://regotz.jimdofree.com/abap/dynpro/infotypen-pai-pbo/
BAdI’s
- HRPAD00INFTY (method IN_UPDATE) is called by the old infotype framework (PA30, SAP50UPR)
- HRPAD00INFTYDB (method UPDATE_DB) is called in the decoupled infotype framework
BAdI: HRPAD00INFTY – Verbucher / Infotyp-Pflege
BAdI: HRPAD00INFTYDB – HR: Stammdaten, Infotype DB Update Logik
“The BAdI is called, after the decoupled infotype framework writes the infotype data to the database. This is done during method FLUSH.”
Note: The Infotypes 2000-2999 are not decoupled yet! More here and here.
[ABAP] Read cost center description
DATA(kostl_text) = NEW cl_hrpa_ui_convert_0859( )->get_txt_costcenter( iv_kokrs = lv_kokrs iv_kostl = lv_kostl iv_date = sy-datum ).
# Class is using FUBA 'HRCA_COSTCENTER_GETDETAIL'
[HR] Abrechnungsergebnisse lesen
Reports:
RPCLSTRD – Anzeige des Clusters RD (Abrechnungsergebnisse Deutschland), Tcode: PC_PAYRESULT
H99_DISPLAY_PAYRESULT – Anzeigen von Abrechnungsergebnissen
Abrechnungsergebnistabelle:
Eine sehr schöne Übersicht über die Tabellen: https://l3consulting.de/die-tabellen-im-abrechnungscluster-des-sap-hcm-verstehen/
Die Tabelle RT enthält die Ergebnislohnarten der ausgewählten Abrechnungsperiode. (RT_ = komprimierte Darstellung)
Funktionsbausteine:
HR_GET_PAYROLL_RESULTS – Lesen von Abrechnungsergebnissen für Monats- und Jahresreports
PYXX_READ_PAYROLL_RESULT – Generischer Import von Abrechnungsergebnissen
HRCM_PAYROLL_RESULTS_GET – Abrechnungsdaten einer Person ermitteln
Hinweise zu Bausteinen: https://blog.hr-manager.de/2011/09/abap-abrechnungsergebnisse-lesen-per.html
Logische Datenbank:
Eine weitere Möglichkeit ist die Nutzung der logischen Datenbank PNP. Die Verwendung logischer Datenbanken ist jedoch obsolet (zumindest in anderen Modulen) und sollten daher eigentlich nicht mehr verwendet werden.
*&---------------------------------------------------------------------*
*& Report ZGETPAYROLL
*& Eigenschaften: Selektionsbildvariante 900, HR-Reportklasse PY_DEF.
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZGETPAYROLL.
TABLES: PERNR, PYORGSCREEN, PYTIMESCREEN.
INFOTYPES: 0002.
NODES: PAYROLL TYPE PAYDE_RESULT.
DATA: WA_RT TYPE PC207.
START-OF-SELECTION.
GET PERNR.
RP_PROVIDE_FROM_LAST P0002 SPACE PN-BEGDA PN-ENDDA.
WRITE:/ PERNR-PERNR, P0002-VORNA, P0002-NACHN.
GET PAYROLL.
LOOP AT PAYROLL-INTER-RT INTO WA_RT.
WRITE:/ WA_RT-LGART, WA_RT-BETRG.
ENDLOOP.
END-OF-SELECTION.
Oder in Kombination mit einem Fuba:
*&---------------------------------------------------------------------*
*& Report ZGETPAYROLL
*& Eigenschaften: HR-Reportklasse __M00001.
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZGETPAYROLL.
TABLES: pernr. "Necessary for get pernr
INFOTYPES: 0001, "Organisatorische Zuord
0002, "Daten zur Person
0006, "Anschrift
0057. "Mitgliedschaften
DATA: l_payroll_result TYPE payat_result OCCURS 0 WITH HEADER LINE.
START-OF-SELECTION.
GET pernr.
rp_provide_from_last p0001 '' pn-begda pn-endda.
CALL FUNCTION 'HR_GET_PAYROLL_RESULTS'
EXPORTING
pernr = pernr-pernr
permo = pn-permo
pabrj = pn-pabrj
pabrp = pn-pabrp
actual = space "X actual, ' ' retro-differences
waers = 'EUR'
TABLES
result_tab = l_payroll_result
EXCEPTIONS
no_results = 0
wrong_structure_of_result_tab = 2
OTHERS = 4.
IF sy-subrc NE 0.
RETURN. "nächste Pernr
ENDIF.
[ABAP] Download internal table as TXT or CSV
" ty_output and tt_output are just dummy types
DATA: l_output_line TYPE ty_output,
l_output_lines TYPE tt_output,
l_csv_output TYPE truxs_t_text_data,
l_txt_output TYPE TABLE OF string,
PARAMETERS: p_alv RADIOBUTTON GROUP rb1 DEFAULT 'X' USER-COMMAND radio,
p_csv RADIOBUTTON GROUP rb1,
p_flcsv TYPE rlgrap-filename DEFAULT 'c:\temp\file.csv',
p_txt RADIOBUTTON GROUP rb1,
p_fltxt TYPE rlgrap-filename DEFAULT 'c:\temp\file.txt'.
" fill table l_output_lines with your data you want to export as txt or csv
IF p_csv = abap_true.
CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'
TABLES
i_tab_sap_data = l_output_lines
CHANGING
i_tab_converted_data = l_csv_output.
TRY.
cl_gui_frontend_services=>gui_download( EXPORTING filename = CONV #( p_flcsv )
filetype = 'ASC'
CHANGING data_tab = l_csv_output ).
CATCH cx_root INTO DATA(e_text).
MESSAGE e_text->get_text( ) TYPE 'I'.
ENDTRY.
ELSEIF p_txt = abap_true.
LOOP AT l_output_lines INTO l_output_line.
CALL FUNCTION 'SO_STRUCT_TO_CHAR'
EXPORTING
ip_struct = l_output_line
IMPORTING
ep_string = l_string.
APPEND l_string TO l_txt_output.
ENDLOOP.
TRY.
cl_gui_frontend_services=>gui_download( EXPORTING filename = CONV #( p_fltxt )
filetype = 'ASC'
CHANGING data_tab = l_txt_output ).
CATCH cx_root INTO e_text.
MESSAGE e_text->get_text( ) TYPE 'I'.
ENDTRY.
ENDIF.
[ABAP Env] gCTS
https://blogs.sap.com/2020/05/30/sap-cloud-platform-abap-environment-lifecycle-management-introduction/
https://blogs.sap.com/2020/05/30/sap-cloud-platform-abap-environment-lifecycle-management-sample-scenarios/
Git | Git is a distributed version-control system |
CTS | Change and Transport Management System |
gCTS | Git-based CTS (the evolution of the classical CTS) |
abapGit | An open-source Git client that allows you to import existing code into your ABAP system |
Repository | A Repository is a collection of objects, their directory structure, and metadata |
Transport requests | A transport request records all the changes in your ABAP development system. With gCTS: Once a transport request is released, the changes are pushed into your central Git repository in the cloud as a commit represented by a commit ID. |
[ABAP] SE80 Shortcuts
Meine meist verwendeten Workbench Shortcuts:
Strg D | Zeile verdoppeln |
Strg J | In Kommentaren -> 1 Buchstaben groß |
Strg I | Suchen abwärts (startet beim tippen) |
Strg Shift I | Suchen aufwärts (startet beim tippen) |
Strg K | Text groß/klein switchen. Alternativ (Strg U für groß, Strg L für klein) |
Strg Shift S | Coding in Datei speichern |
Strg Shift L | Ganze Zeile löschen |
Strg Shift X | Ganze Zeile löschen und einrücken |
Ctrl / | Jump to the “command field” where we enter t-codes |
Alt Shift Pfeiltasten | Coding Block markieren (alternativ Alt + Maus) |
[ABAP] Calculation
* ab ABAP 7.54
DATA field TYPE p decimals 2.
field += 4.
field -= 2.
field *= 3.
field /= 2.
*obsolet: ADD, SUBSTRACT, MULTIPLY, DIVIDE
[ABAP] Display a database table
cl_salv_gui_table_ida=>create( iv_table_name = 'SFLIGHT' )->fullscreen( )->display( ).
Example report in your system: SALV_IDA_DISPLAY_DATA_SIMPLE