FI ALV mit Doppelklick
*-----------------------------------------------------------------------
* Swisscom Schweiz AG
* SAP-RELEASE: 7.50
*-----------------------------------------------------------------------
* DOKUMENTATION ZUM PROGRAMM
* Name: ZFI_TAX_AUS_GE
* Zweck: Auswertung Tax Gemeinden
*-----------------------------------------------------------------------
* DATEN ZUR ERSTELLUNG
* Auftraggeber: Vontobel Erich
* Project / CR: 2000000315
* Ersteller: Michel Regotz
* Datum: 01.07.2019
* Zweck: Auswertung
*-----------------------------------------------------------------------
* DATEN ZUR ÄNDERUNG
* Auftraggeber: <Name, Vorname>
* Ersteller: <Name, Vorname>
* Datum: <DDMMYYYY>
* Zweck: <????>
*-----------------------------------------------------------------------
* ZUSATZDOKUMENTATION ZUM PROGRAMM
*
*-----------------------------------------------------------------------
*&---------------------------------------------------------------------*
*### ###
*###=ooO=========Ooo=###
*### \\ (o o) // ###
*----------(_)----------
*&---------------------------------------------------------------------*
REPORT zfi_tax_aus_ge.
"=======================================================================
" Datendeklaration
"=======================================================================
TABLES: lfa1, zfi_tax_accounts, zzre_v_tivbdmuni, bseg.
TYPE-POOLS: abap.
TYPES:
BEGIN OF gty_ac,
bukrs TYPE bukrs,
stkont TYPE saknr,
stjahr TYPE zfi_stjahr,
tkonid TYPE /psitax/_de_tkonid,
END OF gty_ac.
TYPES:
BEGIN OF gty_bsakbsik,
bukrs TYPE bukrs,
lifnr TYPE lifnr,
belnr TYPE belnr_d,
xblnr TYPE xblnr1,
END OF gty_bsakbsik.
TYPES:
BEGIN OF gty_bsakbsiks,
bukrs TYPE bukrs,
lifnr TYPE lifnr,
belnr TYPE belnr_d,
xblnr TYPE xblnr1,
END OF gty_bsakbsiks.
TYPES:
BEGIN OF gty_bsk,
bukrs TYPE bukrs,
lifnr TYPE lifnr,
belnr TYPE belnr_d,
xblnr TYPE xblnr1,
hkont TYPE saknr,
pswsl TYPE pswsl,
buzei TYPE buzei,
sgtxt TYPE zfi_tax_sgtxt,
gjahr TYPE gjahr,
dmbtr TYPE zfi_tax_betrg,
END OF gty_bsk.
DATA: gf_tkonid TYPE /psitax/_de_tkonid.
DATA: gf_break TYPE c LENGTH 1.
DATA: gs_data TYPE zfi_tax_aus_detail.
DATA: gt_data TYPE TABLE OF zfi_tax_aus_detail.
DATA: gs_hist TYPE zfi_tax_aus_hist.
DATA: gt_hist TYPE TABLE OF zfi_tax_aus_hist.
DATA: gs_cock TYPE zfi_tax_aus_cockpit.
DATA: gt_cock TYPE TABLE OF zfi_tax_aus_cockpit.
DATA: gs_cocks TYPE zfi_tax_aus_cockpit.
DATA: gt_cocks TYPE TABLE OF zfi_tax_aus_cockpit.
DATA: gs_detail TYPE zfi_tax_aus_detail.
DATA: gt_detail TYPE TABLE OF zfi_tax_aus_detail.
DATA: gf_titel TYPE text70.
DATA: gs_ac TYPE gty_ac.
DATA: gt_ac TYPE TABLE OF gty_ac.
DATA: gs_acc TYPE gty_ac.
DATA: gt_acc TYPE TABLE OF gty_ac.
DATA: gs_bsakbsik TYPE gty_bsakbsik.
DATA: gt_bsakbsik TYPE TABLE OF gty_bsakbsik.
DATA: gs_bsakbsiks TYPE gty_bsakbsiks.
DATA: gt_bsakbsiks TYPE TABLE OF gty_bsakbsiks.
DATA: gs_bsk TYPE gty_bsk.
DATA: gt_bsk TYPE TABLE OF gty_bsk.
DATA: gs_bse TYPE gty_bsk.
DATA: gt_bse TYPE TABLE OF gty_bsk.
DATA: gs_bseg TYPE bseg.
DATA: gt_bseg TYPE TABLE OF bseg.
DATA: gs_input TYPE zfi_tax_st_tval,
gs_ouput TYPE zfi_tax_st_tval,
gt_input TYPE TABLE OF zfi_tax_st_tval,
gt_ouput TYPE TABLE OF zfi_tax_st_tval.
DATA: gf_kondv TYPE zfi_tax_tkondv.
DATA: gf_po_sum_k TYPE zfi_tax_kname.
"=======================================================================
" 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.
DATA: go_selections TYPE REF TO cl_salv_selections.
DATA: go_err_salv TYPE REF TO cx_salv_msg.
DATA: go_err_salv_exist TYPE REF TO cx_salv_existing.
DATA: go_err_wrong_call TYPE REF TO cx_salv_wrong_call.
DATA: gf_string TYPE string.
DATA: go_func TYPE REF TO cl_salv_functions_list.
DATA: go_col TYPE REF TO cl_salv_columns_list.
DATA: gs_col TYPE lvc_t_scol.
*---------------------------------------------------------------------*
* CLASS lcl_handle_events DEFINITION
*---------------------------------------------------------------------*
* §5.1 define a local class for handling events of cl_salv_table
*---------------------------------------------------------------------*
CLASS lcl_event_handler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
on_double_click FOR EVENT double_click OF cl_salv_events_table
IMPORTING row column,
on_double_click_field FOR EVENT double_click OF cl_salv_events_table
IMPORTING row column.
*
* on_before_salv_function for event before_salv_function of cl_salv_events
* importing e_salv_function,
*
* on_after_salv_function for event after_salv_function of cl_salv_events
* importing e_salv_function,
*
* on_double_click for event double_click of cl_salv_events_table
* importing row column,
*
* on_link_click for event link_click of cl_salv_events_table
* importing row column.
ENDCLASS. "lcl_handle_events DEFINITION
*---------------------------------------------------------------------*
* CLASS lcl_handle_events IMPLEMENTATION
*---------------------------------------------------------------------*
* §5.2 implement the events for handling the events of cl_salv_table
*---------------------------------------------------------------------*
CLASS lcl_event_handler IMPLEMENTATION.
METHOD on_double_click.
PERFORM on_double_click_row USING row column.
ENDMETHOD.
METHOD on_double_click_field.
PERFORM on_double_click_field USING row column.
ENDMETHOD. "on_user_command
* method on_before_salv_function.
* perform show_function_info using e_salv_function text-i09.
* endmethod. "on_before_salv_function
*
* method on_after_salv_function.
* perform show_function_info using e_salv_function text-i10.
* endmethod. "on_after_salv_function
*
* method on_double_click.
* perform show_cell_info using row column text-i07.
* endmethod. "on_double_click
*
* method on_link_click.
* perform show_cell_info using row column text-i06.
* endmethod. "on_single_click
ENDCLASS. "lcl_handle_events IMPLEMENTATION
CLASS z_color_view DEFINITION.
PUBLIC SECTION.
METHODS set_column_color
IMPORTING
icl_alv TYPE REF TO cl_salv_table
iv_column TYPE lvc_fname
iv_color TYPE int4
iv_intense TYPE int1
iv_inverse TYPE int4 .
ENDCLASS.
CLASS z_color_view IMPLEMENTATION.
*----------------------------------------------------------------------*
* Spaltenfarbe setzen
*----------------------------------------------------------------------*
METHOD set_column_color.
DATA: lcl_columns_table TYPE REF TO cl_salv_columns_table,
lcl_column TYPE REF TO cl_salv_column_table,
ls_color TYPE lvc_s_colo.
IF icl_alv IS NOT INITIAL.
TRY.
lcl_columns_table = icl_alv->get_columns( ).
lcl_column ?= lcl_columns_table->get_column( iv_column ).
ls_color-col = iv_color.
ls_color-int = iv_intense.
ls_color-inv = iv_inverse.
IF ls_color IS NOT INITIAL AND
lcl_column IS NOT INITIAL.
lcl_column->set_color( ls_color ).
ENDIF.
CATCH cx_salv_not_found.
ENDTRY.
ENDIF.
ENDMETHOD.
ENDCLASS.
DATA: go_color TYPE REF TO z_color_view.
"=======================================================================
" Selektionsscreen für ALV
"=======================================================================
SELECTION-SCREEN BEGIN OF BLOCK 0 WITH FRAME TITLE TEXT-000.
SELECTION-SCREEN BEGIN OF BLOCK 1 WITH FRAME TITLE TEXT-001.
PARAMETERS: p_bukrs TYPE bukrs.
SELECT-OPTIONS: s_lifnr FOR lfa1-lifnr.
PARAMETERS: p_stjahr TYPE gjahr.
SELECTION-SCREEN END OF BLOCK 1.
SELECTION-SCREEN END OF BLOCK 0.
*=======================================================================
* AT SELECTION-SCREEN ON VALUE REQUEST
*=======================================================================
**=======================================================================
**At Selection-Screen
**=======================================================================
*AT SELECTION-SCREEN.
**=======================================================================
**At Selection-Screen OUTPUT
**=======================================================================
*AT SELECTION-SCREEN OUTPUT.
*=======================================================================
* INITIALIZATION
*=======================================================================
*INITIALIZATION.
*=======================================================================
* START OF SELECTION
*=======================================================================
START-OF-SELECTION.
"Daten holen
PERFORM set_data.
"ALV anzeigen
PERFORM show_alv.
*&---------------------------------------------------------------------*
*& Form SET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM set_data .
"Lesen der BSIK offene Posten wenn Rechnung nicht bezahlt ist.
SELECT bsik~bukrs, bsik~lifnr, bsik~belnr, bsik~xblnr, bseg~hkont, bseg~pswsl, bseg~buzei, bseg~sgtxt, bseg~gjahr,
CASE WHEN bseg~shkzg = 'H' THEN bseg~dmbtr * -1 ELSE bseg~dmbtr END INTO TABLE @gt_bsk
FROM bsik INNER JOIN bseg ON bsik~bukrs = bseg~bukrs
AND bsik~belnr = bseg~belnr
WHERE bsik~lifnr IN @s_lifnr
AND bsik~bukrs = @p_bukrs
AND bsik~xblnr = @p_stjahr.
APPEND LINES OF gt_bsk TO gt_bse.
"Lesen der BSAK geschlossene Posten wenn Rechnung bezahlt ist.
SELECT bsak~bukrs, bsak~lifnr, bsak~belnr, bsak~xblnr, bseg~hkont, bseg~pswsl, bseg~buzei, bseg~sgtxt, bseg~gjahr,
CASE WHEN bseg~shkzg = 'H' THEN bseg~dmbtr * -1 ELSE bseg~dmbtr END INTO TABLE @gt_bsk
FROM bsak INNER JOIN bseg ON bsak~bukrs = bseg~bukrs
AND bsak~belnr = bseg~belnr
WHERE bsak~lifnr IN @s_lifnr
AND bsak~bukrs = @p_bukrs
AND bsak~xblnr = @p_stjahr.
APPEND LINES OF gt_bsk TO gt_bse.
* "Erstelle Ausgabe Stuktur
LOOP AT gt_bse ASSIGNING FIELD-SYMBOL(<fs_bse>). "INTO gs_bsakbsiks.
"Daten aus BSAK BSIK und BSEG in Ausgabestruktur schreiben
gs_data-bukrs = <fs_bse>-bukrs.
gs_data-lifnr = <fs_bse>-lifnr.
gs_data-stjahr = <fs_bse>-xblnr.
gs_data-belnr = <fs_bse>-belnr.
gs_data-pswsl = <fs_bse>-pswsl.
gs_data-dmbtr = <fs_bse>-dmbtr.
gs_data-buzei = <fs_bse>-buzei.
gs_data-sgtxt = <fs_bse>-sgtxt.
gs_data-belnr = <fs_bse>-belnr.
gs_data-gjahr = <fs_bse>-gjahr.
gs_data-saknr = <fs_bse>-hkont.
"Kredioren Name
SELECT SINGLE name1 FROM lfa1 INTO gs_data-name1
WHERE lifnr = gs_data-lifnr.
"BFS Gemeindenummer
SELECT SINGLE name4 FROM lfa1 INTO gs_data-name4
WHERE lifnr = gs_data-lifnr.
"Dokument
gs_data-dokument = 'Dokument'.
"Zuordnungsnummer holen
SELECT SINGLE zuonr FROM bsik INTO gs_data-zuonr
WHERE lifnr = gs_data-lifnr AND
bukrs = p_bukrs AND
xblnr = p_stjahr AND
belnr = gs_data-belnr.
IF gs_data-zuonr IS INITIAL.
"Lesen der BSAK geschlossene Posten wenn Rechnung bezahlt ist.
SELECT SINGLE zuonr FROM bsak INTO gs_data-zuonr
WHERE lifnr = gs_data-lifnr AND
bukrs = p_bukrs AND
xblnr = p_stjahr AND
belnr = gs_data-belnr.
ENDIF.
"BFS Gemeindenummer Beleg holen
SELECT SINGLE xgemeinde FROM tivga INTO gs_data-xgemeinde
WHERE gemeinde = gs_data-zuonr.
"Zeile in Ausgabetabelle hinzu fügen
APPEND gs_data TO gt_data.
"Initialisieren der Strukturfelder
CLEAR: gs_data-pswsl, gs_data-dmbtr, gs_data-zuonr, gs_data-xgemeinde,
gs_data-buzei, gs_data-sgtxt, gs_data-belnr, gs_data-gjahr,
gs_data-descript, gs_data-dokument, gs_data-name1, gs_data-name4,
gs_data-saknr.
ENDLOOP.
LOOP AT gt_data INTO gs_data.
CLEAR: gs_acc, gf_po_sum_k.
"Steuerkondition PO_SUM_K prüfen in Name4. 0351PO_SUM_K
SELECT SINGLE name4 FROM lfa1 INTO gf_po_sum_k
WHERE lifnr = gs_data-lifnr.
"Abfragen Steuerkondition mit Jahr
SELECT SINGLE tkonid FROM zfi_tax_accounts INTO gf_tkonid
WHERE bukrs = p_bukrs AND
stjahr = p_stjahr AND
stkont = gs_data-saknr.
"Abfragen Steuerkondition ohne Jahr
IF gf_tkonid IS INITIAL.
SELECT SINGLE tkonid FROM zfi_tax_accounts INTO gf_tkonid
WHERE bukrs = p_bukrs AND
stjahr = '' AND
stkont = gs_data-saknr.
ENDIF.
"Wenn PO_SUM_K setzte PO_SUM_K sonst normales Vorgehen.
IF gf_po_sum_k+4(8) = 'PO_SUM_K' AND gf_tkonid = 'PO_SUM_G'.
gf_tkonid = 'PO_SUM_K'.
ELSE.
"mache nichts
ENDIF.
IF gf_tkonid IS INITIAL.
"Unerwünschte Zeilen löschen.
DELETE TABLE gt_data FROM gs_data.
ELSE.
"Steuerkondition holen
gs_data-tkonid = gf_tkonid.
"Beschreibung der Steuerkondition lesen
SELECT SINGLE descript FROM /psitax/c_tkon INTO gs_data-descript
WHERE tkonid = gs_data-tkonid.
"Ausgabe Modifiziern
MODIFY gt_data FROM gs_data.
ENDIF.
"Intialisiere Hilfsparameter.
CLEAR: gf_tkonid, gs_data.
ENDLOOP.
"=======================================================================
" Hole Historische Daten aus ZFI_TAX_AUS_HIST
"=======================================================================
SELECT * FROM zfi_tax_aus_hist INTO TABLE gt_hist
WHERE lifnr IN s_lifnr AND
bukrs = p_bukrs AND
stjahr = p_stjahr.
"Folgende Felder werden übertragen.
"bukrs stjahr saknr tkonid descript lifnr name4 name1 zuonr xgemeinde belnr dmbtr pswsl
LOOP AT gt_hist INTO gs_hist.
MOVE-CORRESPONDING gs_hist TO gs_data.
APPEND gs_data TO gt_data.
CLEAR: gs_hist, gs_data.
ENDLOOP.
"=======================================================================
" Erstelle Cockpit
"=======================================================================
MOVE-CORRESPONDING gt_data TO gt_cock.
SORT gt_cock BY bukrs stjahr tkonid descript lifnr name4 name1 pswsl ASCENDING.
LOOP AT gt_cock INTO gs_cock.
IF sy-tabix = 1.
gs_cocks-bukrs = gs_cock-bukrs.
gs_cocks-stjahr = gs_cock-stjahr.
gs_cocks-tkonid = gs_cock-tkonid.
gs_cocks-descript = gs_cock-descript.
gs_cocks-lifnr = gs_cock-lifnr.
gs_cocks-name4 = gs_cock-name4.
gs_cocks-name1 = gs_cock-name1.
gs_cocks-pswsl = gs_cock-pswsl.
ADD gs_cock-dmbtr TO gs_cocks-dmbtr.
ELSE.
IF gs_cock-bukrs = gs_cocks-bukrs AND gs_cock-stjahr = gs_cocks-stjahr AND gs_cock-tkonid = gs_cocks-tkonid AND gs_cock-lifnr = gs_cocks-lifnr.
ADD gs_cock-dmbtr TO gs_cocks-dmbtr.
ELSE.
APPEND gs_cocks TO gt_cocks.
CLEAR: gs_cocks.
gs_cocks-bukrs = gs_cock-bukrs.
gs_cocks-stjahr = gs_cock-stjahr.
gs_cocks-tkonid = gs_cock-tkonid.
gs_cocks-descript = gs_cock-descript.
gs_cocks-lifnr = gs_cock-lifnr.
gs_cocks-name4 = gs_cock-name4.
gs_cocks-name1 = gs_cock-name1.
gs_cocks-pswsl = gs_cock-pswsl.
ADD gs_cock-dmbtr TO gs_cocks-dmbtr.
* gs_cocks-dmbtr = gs_cock-dmbtr + gs_cocks-dmbtr.
ENDIF.
ENDIF.
ENDLOOP.
APPEND gs_cocks TO gt_cocks.
CLEAR: gs_cocks.
"=======================================================================
" Hole die Planwerte
"=======================================================================
LOOP AT gt_cocks INTO gs_cocks.
"Setze Selektionswerte für die Abfrage der Planwerte
gs_input-bfsnr = gs_cocks-name4.
gs_input-tkonid = gs_cocks-tkonid.
APPEND gs_input TO gt_input.
"Fuba mit dem man die Planwerte holt
CALL FUNCTION 'ZFI_TAX_READ_TVAL'
EXPORTING
iv_bukrs = gs_cocks-bukrs
iv_sjahr = gs_cocks-stjahr
TABLES
it_tkond = gt_input
et_tkonv = gt_ouput.
"Summieren der Planwerte falls notwendig
LOOP AT gt_ouput INTO gs_ouput.
gf_kondv = gf_kondv + gs_ouput-kondv.
ENDLOOP.
"Setzen des Planwertes und des Deltas
gs_cocks-planw = gf_kondv.
gs_cocks-delta = gs_cocks-dmbtr - gs_cocks-planw.
"Speichere die neuen Werte ab in der ITAB
MODIFY gt_cocks FROM gs_cocks.
"Initialisiere die Hilfsvariabeln
CLEAR: gf_kondv, gt_input, gt_ouput, gs_input, gs_ouput.
ENDLOOP.
ENDFORM.
FORM show_alv .
*-----------------------------------------------------------------------
* Beginn ALV-Ausgabe
*-----------------------------------------------------------------------
* Kopieren Sie diesen Block an das Endes des Verarbeitungsblocks
* des ABAP-Programms
*-----------------------------------------------------------------------
"**************************************************************************
"* Instanz der Klasse cl_salv_table erzeugen
"**************************************************************************
TRY.
cl_salv_table=>factory(
* EXPORTING list_display = if_salv_c_bool_sap=>false
* r_container = cl_gui_custom_container=>default_screen
IMPORTING r_salv_table = go_alv
CHANGING t_table = gt_cocks ).
CATCH cx_salv_msg INTO go_err_salv.
" Fehler anzeigen
gf_string = go_err_salv->get_text( ).
MESSAGE gf_string TYPE 'E'.
ENDTRY.
"**************************************************************************
"* optimale Spaltenbreite aktivieren
"**************************************************************************
" Instanz für Spalten holen
go_columns = go_alv->get_columns( ).
" Spaltenbreite optimieren
go_columns->set_optimize( abap_true ). " nur ein 'X'
"**************************************************************************
"* Selection-Mode aktivieren
"**************************************************************************
" Instanz des Selection-Objektes holen
go_selections = go_alv->get_selections( ).
" Selektionsmodus setzen
go_selections->set_selection_mode( if_salv_c_selection_mode=>row_column ).
"**************************************************************************
"* Alle Standard-Funktionen auf aktiv setzen
"**************************************************************************
" Instanz für Funktionen holen Funktionstasten (Sortieren, Filtern, Excel-Export etc.)
go_functions = go_alv->get_functions( ).
" Alle Standardfunktionen aktivieren
go_functions->set_all( abap_true ). " nur ein 'X'
"**************************************************************************
"* Alle Standard-Anzeige Möglichkeiten definieren
"**************************************************************************
" Titel und/oder Streifenmuster
go_display = go_alv->get_display_settings( ).
" Titel
gf_titel = 'Cockpit'.
go_display->set_list_header( value = gf_titel ).
" Streifenmuster
go_display->set_striped_pattern( abap_true ).
"***************************************************************************
"* Alle Standard-Layout Möglichkeiten definieren
"***************************************************************************
" Instanz des Layouts holen 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 ).
" Default Layout hinterlegen set initial Layout
gf_variant = '/DEFAULT'.
go_layout->set_initial_layout( gf_variant ).
* "***************************************************************************
* "* Doppelklick Ereigniss einbauen.
* "***************************************************************************
" Ereignisse einlesen und Handler für Doppelklick registrieren
go_events = go_alv->get_event( ).
SET HANDLER lcl_event_handler=>on_double_click FOR go_events.
* "**************************************************************************
* "* Toolbar um eigene Funktionen erweitern
* "**************************************************************************
* TRY.
* " Neue Funktion für das ALV vorsehen
* go_functions->add_function(
* name = 'NFUNC'
* icon = '@L1@' " Irgendein ICON aus Tabelle ICON
* text = 'ZHR_LV_COCKPIT_VIEW bearbeiten'
* tooltip = 'Hinzugefügte Funktion'
* position = if_salv_c_function_position=>right_of_salv_functions ).
* CATCH cx_salv_existing INTO go_err_salv_exist.
* " Fehler anzeigen
* gf_string = go_err_salv_exist->get_text( ).
* MESSAGE gf_string TYPE 'E'.
* CATCH cx_salv_wrong_call INTO go_err_wrong_call.
* " Fehler anzeigen
* gf_string = go_err_wrong_call->get_text( ).
* MESSAGE gf_string TYPE 'E'.
* ENDTRY.
"**************************************************************************
"* Ereignis zum Behandeln des Button-Click registrieren
"**************************************************************************
* " Das Objekt für die möglichen ALV-Ereignisse holen
* go_events = go_alv->get_event( ).
* " Objekt für die Ereignisbehandlung erzeugen ...
* CREATE OBJECT go_event_handler.
** EXPORTING
** ir_salv = go_alv
** it_cockpit = gt_cockpit.
*
* " ... und bei den Plegeview aufruf registrieren
* SET HANDLER go_event_handler->handle_toolbar_click FOR go_events.
"**************************************************************************
"* Ampel einbauen
"*************************************************************************
* " 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.
"***************************************************************************
"* Ereignis zum Behandeln des Button-Click registrieren
"***************************************************************************
** Das Objekt für die möglichen ALV-Ereignisse holen
* go_events = go_alv->get_event( ).
** Objekt für die Ereignisbehandlung erzeugen ...
* CREATE OBJECT go_event_handler
* EXPORTING
* cr_salv = go_alv
* it_sflight = gt_sflight.
** ... und bei den ALV-Ereignissen registrieren
* SET HANDLER go_event_handler->handle_toolbar_click FOR go_events.
"**************************************************************************
"* ALV-Anzeige anstoßen
"**************************************************************************
" Liste anzeigen
go_alv->display( ).
"**************************************************************************
"* Toolbar um eigene Funktionen erweitern dafür braucht es ein Container
"**************************************************************************
"Trägerbildschirm" für Container rufen (Sonst findet es keinen Container)
* WRITE: space.
ENDFORM. "show_alv
*&---------------------------------------------------------------------*
*& Form show_function_info
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM on_double_click_row USING i_row TYPE i
i_column TYPE lvc_fname.
DATA: l_row_string TYPE string,
l_col_string TYPE string,
l_row TYPE char128.
* WRITE i_row TO l_row LEFT-JUSTIFIED.
CLEAR: gs_cocks, gs_data, gs_detail, gt_detail.
READ TABLE gt_cocks INTO gs_cocks INDEX i_row.
LOOP AT gt_data INTO gs_data.
IF gs_data-bukrs = gs_cocks-bukrs AND gs_data-stjahr = gs_cocks-stjahr
AND gs_data-tkonid = gs_cocks-tkonid AND gs_data-lifnr = gs_cocks-lifnr.
APPEND gs_data TO gt_detail.
ENDIF.
ENDLOOP.
*-----------------------------------------------------------------------
* Beginn ALV-Ausgabe
*-----------------------------------------------------------------------
* Kopieren Sie diesen Block an das Endes des Verarbeitungsblocks
* des ABAP-Programms
*-----------------------------------------------------------------------
"**************************************************************************
"* Instanz der Klasse cl_salv_table erzeugen
"**************************************************************************
CREATE OBJECT go_color.
TRY.
cl_salv_table=>factory(
* EXPORTING list_display = if_salv_c_bool_sap=>false
* r_container = cl_gui_custom_container=>default_screen
IMPORTING r_salv_table = go_alv"_detail
CHANGING t_table = gt_detail ).
CATCH cx_salv_msg INTO go_err_salv.
"Fehler anzeigen
gf_string = go_err_salv->get_text( ).
MESSAGE gf_string TYPE 'E'.
ENDTRY.
"**************************************************************************
"* Setze Spalten Farbe
"**************************************************************************
go_color->set_column_color( icl_alv = go_alv
iv_column = 'DOKUMENT'
iv_color = 1
iv_intense = 1
iv_inverse = 0 ).
go_color->set_column_color( icl_alv = go_alv
iv_column = 'BELNR'
iv_color = 1
iv_intense = 1
iv_inverse = 0 ).
"**************************************************************************
"* optimale Spaltenbreite aktivieren
"**************************************************************************
" Instanz für Spalten holen
go_columns = go_alv->get_columns( ).
" Spaltenbreite optimieren
go_columns->set_optimize( abap_true ). " nur ein 'X'
"**************************************************************************
"* Selection-Mode aktivieren
"**************************************************************************
" Instanz des Selection-Objektes holen
go_selections = go_alv->get_selections( ).
" Selektionsmodus setzen
go_selections->set_selection_mode( if_salv_c_selection_mode=>row_column ).
"**************************************************************************
"* Alle Standard-Funktionen auf aktiv setzen
"**************************************************************************
" Instanz für Funktionen holen Funktionstasten (Sortieren, Filtern, Excel-Export etc.)
go_functions = go_alv->get_functions( ).
" Alle Standardfunktionen aktivieren
go_functions->set_all( abap_true ). " nur ein 'X'
"**************************************************************************
"* Spalten Farbe setzen
"**************************************************************************
* go_col->SET_COLOR_COLUMN( value = gs_col ).
"**************************************************************************
"* Alle Standard-Anzeige Möglichkeiten definieren
"**************************************************************************
" Titel und/oder Streifenmuster
go_display = go_alv->get_display_settings( ).
" Titel
CONCATENATE 'Detailsicht von'
gs_cocks-bukrs
gs_cocks-stjahr
gs_cocks-lifnr
gs_cocks-tkonid INTO gf_titel SEPARATED BY space.
go_display->set_list_header( value = gf_titel ).
" Streifenmuster
go_display->set_striped_pattern( abap_true ).
"***************************************************************************
"* Alle Standard-Layout Möglichkeiten definieren
"***************************************************************************
" Instanz des Layouts holen 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 ).
" Default Layout hinterlegen set initial Layout
gf_variant = '/DEFAULT'.
go_layout->set_initial_layout( gf_variant ).
* "***************************************************************************
* "* Doppelklick Ereigniss einbauen.
* "***************************************************************************
" Ereignisse einlesen und Handler für Doppelklick registrieren
go_events = go_alv->get_event( ).
SET HANDLER lcl_event_handler=>on_double_click_field FOR go_events.
* "**************************************************************************
* "* Toolbar um eigene Funktionen erweitern
* "**************************************************************************
* TRY.
* " Neue Funktion für das ALV vorsehen
* go_functions->add_function(
* name = 'NFUNC'
* icon = '@L1@' " Irgendein ICON aus Tabelle ICON
* text = 'ZHR_LV_COCKPIT_VIEW bearbeiten'
* tooltip = 'Hinzugefügte Funktion'
* position = if_salv_c_function_position=>right_of_salv_functions ).
* CATCH cx_salv_existing INTO go_err_salv_exist.
* " Fehler anzeigen
* gf_string = go_err_salv_exist->get_text( ).
* MESSAGE gf_string TYPE 'E'.
* CATCH cx_salv_wrong_call INTO go_err_wrong_call.
* " Fehler anzeigen
* gf_string = go_err_wrong_call->get_text( ).
* MESSAGE gf_string TYPE 'E'.
* ENDTRY.
"**************************************************************************
"* Ereignis zum Behandeln des Button-Click registrieren
"**************************************************************************
* " Das Objekt für die möglichen ALV-Ereignisse holen
* go_events = go_alv->get_event( ).
* " Objekt für die Ereignisbehandlung erzeugen ...
* CREATE OBJECT go_event_handler.
** EXPORTING
** ir_salv = go_alv
** it_cockpit = gt_cockpit.
*
* " ... und bei den Plegeview aufruf registrieren
* SET HANDLER go_event_handler->handle_toolbar_click FOR go_events.
"**************************************************************************
"* Ampel einbauen
"*************************************************************************
* " 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.
"***************************************************************************
"* Ereignis zum Behandeln des Button-Click registrieren
"***************************************************************************
** Das Objekt für die möglichen ALV-Ereignisse holen
* go_events = go_alv->get_event( ).
** Objekt für die Ereignisbehandlung erzeugen ...
* CREATE OBJECT go_event_handler
* EXPORTING
* cr_salv = go_alv
* it_sflight = gt_sflight.
** ... und bei den ALV-Ereignissen registrieren
* SET HANDLER go_event_handler->handle_toolbar_click FOR go_events.
"**************************************************************************
"* ALV-Anzeige anstoßen
"**************************************************************************
" Liste anzeigen
go_alv->display( ).
"**************************************************************************
"* Toolbar um eigene Funktionen erweitern dafür braucht es ein Container
"**************************************************************************
"Trägerbildschirm" für Container rufen (Sonst findet es keinen Container)
* WRITE: space.
ENDFORM. " show_function_info
**&---------------------------------------------------------------------*
**& Form BELEG
**&---------------------------------------------------------------------*
** Objekt für generische Dienste erstellen
**----------------------------------------------------------------------*
** --> p1 text
** <-- p2 text
**----------------------------------------------------------------------*
*form beleg using objtype type borident-objtype .
* data: ls_awtyp type awtyp,
* ls_awkey type awkey.
* select single awtyp awkey into (ls_awtyp, ls_awkey) from bkpf where bukrs = ls_list-bukrs
* and belnr = ls_list-belnr
* and gjahr = ls_list-gjahr.
* if ls_awtyp = 'RMRP '.
* concatenate ls_awkey(10) ls_list-gjahr into ls_object-objkey.
* ls_object-objtype = 'BUS2081'.
* else.
* concatenate ls_list-bukrs ls_list-belnr ls_list-gjahr ls_list-buzei
* into ls_object-objkey.
* ls_object-objtype = objtype.
* perform publish_doc_icon in program sapmf05l
* using objtype ls_list-bukrs ls_list-belnr
* ls_list-gjahr ls_list-buzei space ls_rcode.
* if ls_rcode ne 0.
* message i002(sgos_msg).
* endif.
* endif.
*
*endform.
**&---------------------------------------------------------------------*
**& Form RECHN
**&---------------------------------------------------------------------*
** Objekt für generische Dienste erstellen
**----------------------------------------------------------------------*
** --> p1 text
** <-- p2 text
**----------------------------------------------------------------------*
*form rechn .
*
* concatenate ls_list-belnr ls_list-gjahr into ls_object-objkey.
* ls_object-objtype = 'BUS2081'.
*
*endform.
*&---------------------------------------------------------------------*
*& Form show_function_info
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM on_double_click_field USING i_row TYPE i
i_column TYPE lvc_fname.
DATA: l_row_string TYPE string,
l_col_string TYPE string,
l_row TYPE char128.
DATA: rspar TYPE TABLE OF rsparams WITH HEADER LINE.
* WRITE i_row TO l_row LEFT-JUSTIFIED.
IF i_column = 'BELNR'.
CLEAR: gs_data.
READ TABLE gt_data INDEX i_row INTO gs_data.
"Message / Meldung wenn Feld Dokument leer ist.
IF gs_data-dokument IS INITIAL.
MESSAGE 'Historische Daten sind in der FB03 nicht gepflegt' TYPE 'I'.
ELSE.
SET PARAMETER ID 'BLN' FIELD gs_data-belnr.
SET PARAMETER ID 'BUK' FIELD gs_data-bukrs.
SET PARAMETER ID 'GJR' FIELD gs_data-gjahr.
CALL TRANSACTION 'FB03' AND SKIP FIRST SCREEN.
ENDIF.
ELSEIF i_column = 'DOKUMENT'.
* Absprung Anlagenliste
DATA: mo_gos_manager TYPE REF TO cl_gos_manager,
mo_container TYPE REF TO cl_gui_custom_container,
ls_object TYPE borident.
DATA: ls_awtyp TYPE awtyp,
ls_awkey TYPE awkey.
DATA: ls_rcode TYPE sy-subrc.
CLEAR: gs_data.
READ TABLE gt_data INDEX i_row INTO gs_data.
"Message / Meldung wenn Feld Dokument leer ist.
IF gs_data-dokument IS INITIAL.
MESSAGE 'Historische Daten sind in der FB03 nicht gepflegt' TYPE 'I'.
ELSE.
CONCATENATE gs_data-bukrs gs_data-belnr gs_data-gjahr gs_data-buzei
INTO ls_object-objkey.
ls_object-objtype = 'BSEG'.
SELECT SINGLE awtyp awkey INTO (ls_awtyp, ls_awkey) FROM bkpf WHERE bukrs = gs_data-bukrs
AND belnr = gs_data-belnr
AND gjahr = gs_data-gjahr.
* IF ls_awtyp = 'RMRP '.
* CONCATENATE ls_awkey(10) gs_data-gjahr INTO ls_object-objkey.
* ls_object-objtype = 'BUS2081'.
* ELSE.
* CONCATENATE gs_data-bukrs gs_data-belnr gs_data-gjahr gs_data-buzei
* INTO ls_object-objkey.
* ls_object-objtype = 'BSEG'.
** ls_object-objtype = objtype.
* PERFORM publish_doc_icon IN PROGRAM sapmf05l
* USING ls_object-objtype gs_data-bukrs gs_data-belnr
* gs_data-gjahr gs_data-buzei space ls_rcode.
* IF ls_rcode NE 0.
* MESSAGE i002(sgos_msg).
* ENDIF.
* ENDIF.
CREATE OBJECT mo_gos_manager.
CALL METHOD mo_gos_manager->start_service_direct
EXPORTING
ip_service = 'VIEW_ATTA'
is_object = ls_object
io_container = mo_container
EXCEPTIONS
no_object = 1
object_invalid = 2
execution_failed = 3
OTHERS = 4.
IF sy-subrc NE 0.
MESSAGE i004(sgos_msg) WITH 'VIEW_ATTA'.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. " show_function_info
* "Lesen der BSIK offene Posten wenn Rechnung nicht bezahlt ist.
* SELECT bukrs lifnr belnr xblnr FROM bsik INTO TABLE gt_bsakbsik
* WHERE lifnr IN s_lifnr AND
* bukrs = p_bukrs AND
* xblnr = p_stjahr.
* APPEND LINES OF gt_bsakbsik TO gt_bsakbsiks.
* "Lesen der BSAK geschlossene Posten wenn Rechnung bezahlt ist.
* SELECT bukrs lifnr belnr xblnr FROM bsak INTO TABLE gt_bsakbsik
* WHERE lifnr IN s_lifnr AND
* bukrs = p_bukrs AND
* xblnr = p_stjahr.
* APPEND LINES OF gt_bsakbsik TO gt_bsakbsiks.
*
* "Erstelle Ausgabe Stuktur
* LOOP AT gt_bsakbsiks INTO gs_bsakbsiks.
* "Lesen der BSEG
* SELECT belnr gjahr buzei dmbtr pswsl zuonr sgtxt hkont FROM bseg INTO CORRESPONDING FIELDS OF TABLE gt_bseg
* WHERE belnr = gs_bsakbsiks-belnr.
*
* "Setzen der Felder in der Ausgabestruktur
* LOOP AT gt_bseg INTO gs_bseg.
* "Daten aus BSAK und BSIK in Ausgabestruktur schreiben
* gs_data-bukrs = gs_bsakbsiks-bukrs.
* gs_data-lifnr = gs_bsakbsiks-lifnr.
* gs_data-stjahr = gs_bsakbsiks-xblnr.
* gs_data-belnr = gs_bsakbsiks-belnr.
* "Daten aus BSEG in die Ausgabestrucktur schreiben
* gs_data-pswsl = gs_bseg-pswsl.
* gs_data-dmbtr = gs_bseg-dmbtr.
** gs_data-zuonr = gs_bseg-zuonr.
* gs_data-buzei = gs_bseg-buzei.
* gs_data-sgtxt = gs_bseg-sgtxt.
* gs_data-belnr = gs_bseg-belnr.
* gs_data-gjahr = gs_bseg-gjahr.
* gs_data-saknr = gs_bseg-hkont.
* "BFS Gemeindenummer Beleg holen
* SELECT SINGLE xgemeinde FROM tivga INTO gs_data-xgemeinde
* WHERE gemeinde = gs_data-zuonr.
* "Kredioren Name
* SELECT SINGLE name1 FROM lfa1 INTO gs_data-name1
* WHERE lifnr = gs_data-lifnr.
* "BFS Gemeindenummer
* SELECT SINGLE name4 FROM lfa1 INTO gs_data-name4
* WHERE lifnr = gs_data-lifnr.
* gs_data-dokument = 'Dokument'.
* "Zuordnungsnummer holen
* SELECT SINGLE zuonr FROM bsik INTO gs_data-zuonr
* WHERE lifnr = gs_data-lifnr AND
* bukrs = p_bukrs AND
* xblnr = p_stjahr AND
* belnr = gs_data-belnr.
* IF gs_data-zuonr IS INITIAL.
* "Lesen der BSAK geschlossene Posten wenn Rechnung bezahlt ist.
* SELECT SINGLE zuonr FROM bsak INTO gs_data-zuonr
* WHERE lifnr = gs_data-lifnr AND
* bukrs = p_bukrs AND
* xblnr = p_stjahr AND
* belnr = gs_data-belnr.
* ENDIF.
* "Zeile in Ausgabetabelle hinzu fügen
* APPEND gs_data TO gt_data.
* "Initialisieren der Strukturfelder
* CLEAR: gs_data-pswsl, gs_data-dmbtr, gs_data-zuonr, gs_data-xgemeinde,
* gs_data-buzei, gs_data-sgtxt, gs_data-belnr, gs_data-gjahr,
* gs_data-descript, gs_data-dokument, gs_data-name1, gs_data-name4,
* gs_data-saknr.
* ENDLOOP.
*
* ENDLOOP.