Zu erst registriest du dich auf das ON-DOUBLE-KLICK-Ereignis des ALVs.Adrian hat geschrieben: Wie bekomme ich es hin das wenn ich doppelklick auf eine Zeile meines ALV Grids mache
automatisch eine Transaktion z.B. MM03 aufruft und den Selektionsbildschirm überspringt.
Code: Alles auswählen.
TABLES: VBAK, VBUP.
DATA VBAK1 TYPE TABLE OF VBAK.
DATA: OK_CODE LIKE SY-UCOMM,
G_CONTAINER TYPE SCRFNAME VALUE 'BCALV_GRID_DEMO_0100_CONT1',
GRID1 TYPE REF TO CL_GUI_ALV_GRID,
G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
data: gt_grid type grid occurs 0 with header line.
SELECTION-SCREEN:
BEGIN OF SCREEN 0001 AS WINDOW TITLE FENSTER1,
SKIP 2.
SELECT-OPTIONS DATUM FOR SY-DATUM.
SELECT-OPTIONS VKORG FOR VBAK-VKORG.
SELECTION-SCREEN:
SKIP 2,
END OF SCREEN 0001.
CALL SCREEN 0001 STARTING AT 10 10.
SELECT * FROM VBAK
WHERE AUDAT IN DATUM.
SELECT * FROM VBUP
WHERE VBELN = VBAK-VBELN
AND LFSTA = 'A'.
SELECT * FROM VBAK INTO TABLE VBAK1
WHERE VBELN = VBUP-VBELN.
EXIT.
ENDSELECT.
ENDSELECT.
CALL SCREEN 100.
*---------------------------------------------------------------------*
* MODULE PBO OUTPUT *
*---------------------------------------------------------------------*
MODULE PBO OUTPUT.
SET PF-STATUS 'MAIN100'.
IF G_CUSTOM_CONTAINER IS INITIAL.
CREATE OBJECT G_CUSTOM_CONTAINER
EXPORTING CONTAINER_NAME = G_CONTAINER.
CREATE OBJECT GRID1
EXPORTING I_PARENT = G_CUSTOM_CONTAINER.
CALL METHOD GRID1->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING I_STRUCTURE_NAME = 'VBAK'
CHANGING IT_OUTTAB = VBAK1.
ENDIF.
ENDMODULE.
*---------------------------------------------------------------------*
* MODULE PAI INPUT *
*---------------------------------------------------------------------*
MODULE PAI INPUT.
* to react on oi_custom_events:
CALL METHOD CL_GUI_CFW=>DISPATCH.
CASE OK_CODE.
WHEN 'EXIT'.
PERFORM EXIT_PROGRAM.
WHEN OTHERS.
* do nothing
ENDCASE.
CLEAR OK_CODE.
* call method gt_grid-grid->set_function_code
* changing
* c_ucomm = l_okcode.
ENDMODULE.
*---------------------------------------------------------------------*
* FORM EXIT_PROGRAM *
*---------------------------------------------------------------------*
FORM EXIT_PROGRAM.
* CALL METHOD G_CUSTOM_CONTAINER->FREE.
* CALL METHOD CL_GUI_CFW=>FLUSH.
LEAVE PROGRAM.
ENDFORM.
Und noch neu in ABAP?Adrian hat geschrieben:Das erste Mal mit ALV Grids gearbeitet.
Code: Alles auswählen.
...
DATA wa_aktuelle_zeile LIKE LINE OF it_zzab_alv.
...
*---------------------------------------------------------------------
* Unterprogramm für Reaktion auf Doppelklick
*---------------------------------------------------------------------
FORM user_command USING i_ucomm
i_selfield TYPE slis_selfield.
CASE i_ucomm.
WHEN '&IC1'. " bei Doppelklick
READ TABLE it_zzab_alv
INTO wa_aktuellezeile
INDEX i_selfield-tabindex.
" Transaktion aufrufen
wahlx = '02'.
SET PARAMETER ID 'ZZAB_MATNR' FIELD wa_aktuellezeile-matnr.
SET PARAMETER ID 'ZZAB_WAHLX' FIELD wahlx.
CALL TRANSACTION 'ZZAB' AND SKIP FIRST SCREEN.
ENDCASE.
ENDFORM. "user_command
Code: Alles auswählen.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_user_command = 'USER_COMMAND'
...
Das ist der REUSE-Aufruf, Adrian verwendet aber den OO-Aufruf.bliss hat geschrieben:aber dafür gibts bestimmt auch andere Möglichkeiten.
Code: Alles auswählen.
*&---------------------------------------------------------------------*
*& Report ZOFFNENEAUFTRAEGE
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZOFFNENEAUFTRAEGE.
CLASS LCL_EVENT_RECEIVER DEFINITION DEFERRED.
TABLES: VBAK, VBUP.
DATA: VBAK1 TYPE TABLE OF VBAK,
VBAK2 LIKE LINE OF VBAK1.
DATA: OK_CODE LIKE SY-UCOMM,
G_CONTAINER TYPE SCRFNAME VALUE 'BCALV_GRID_DEMO_0100_CONT1',
GRID1 TYPE REF TO CL_GUI_ALV_GRID,
G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
DATA: GT_GRID TYPE GRID OCCURS 0 WITH HEADER LINE,
EVENT_RECEIVER TYPE REF TO LCL_EVENT_RECEIVER.
*----------------------------------------------------------------------*
* CLASS LCL_EVENT_RECEIVER DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS LCL_EVENT_RECEIVER DEFINITION.
PUBLIC SECTION.
METHODS:
HANDLE_DOUBLE_CLICK
FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
IMPORTING E_ROW E_COLUMN.
PRIVATE SECTION.
ENDCLASS. "lcl_event_receiver DEFINITION
SELECTION-SCREEN:
BEGIN OF SCREEN 0001 AS WINDOW TITLE FENSTER1,
SKIP 2.
SELECT-OPTIONS DATUM FOR SY-DATUM.
SELECT-OPTIONS VKORG FOR VBAK-VKORG.
SELECTION-SCREEN:
SKIP 2,
END OF SCREEN 0001.
CALL SCREEN 0001 STARTING AT 10 10.
SELECT * FROM VBAK
WHERE AUDAT IN DATUM.
SELECT * FROM VBUP
WHERE VBELN = VBAK-VBELN
AND LFSTA = 'A'.
SELECT * FROM VBAK INTO TABLE VBAK1
WHERE VBELN = VBUP-VBELN.
EXIT.
ENDSELECT.
ENDSELECT.
CALL SCREEN 100.
*---------------------------------------------------------------------*
* MODULE PBO OUTPUT *
*---------------------------------------------------------------------*
MODULE PBO OUTPUT.
SELECT * FROM VBAK
WHERE AUDAT IN DATUM.
SELECT * FROM VBUP
WHERE VBELN = VBAK-VBELN
AND LFSTA = 'A'.
SELECT * FROM VBAK INTO TABLE VBAK1
WHERE VBELN = VBUP-VBELN.
EXIT.
ENDSELECT.
ENDSELECT.
SET PF-STATUS 'MAIN100'.
IF G_CUSTOM_CONTAINER IS INITIAL.
CREATE OBJECT G_CUSTOM_CONTAINER
EXPORTING
CONTAINER_NAME = G_CONTAINER.
CREATE OBJECT GRID1
EXPORTING
I_PARENT = G_CUSTOM_CONTAINER.
CALL METHOD GRID1->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_STRUCTURE_NAME = 'VBAK'
CHANGING
IT_OUTTAB = VBAK1.
CREATE OBJECT EVENT_RECEIVER.
SET HANDLER EVENT_RECEIVER->HANDLE_DOUBLE_CLICK FOR GRID1.
ENDIF.
ENDMODULE. "PBO OUTPUT
*---------------------------------------------------------------------*
* MODULE PAI INPUT *
*---------------------------------------------------------------------*
MODULE PAI INPUT.
* to react on oi_custom_events:
CALL METHOD CL_GUI_CFW=>DISPATCH.
OK_CODE = SY-UCOMM.
CASE OK_CODE.
WHEN 'EXIT'.
PERFORM EXIT_PROGRAM.
WHEN OTHERS.
* do nothing
ENDCASE.
CLEAR OK_CODE.
ENDMODULE. "PAI INPUT
*---------------------------------------------------------------------*
* FORM EXIT_PROGRAM *
*---------------------------------------------------------------------*
FORM EXIT_PROGRAM.
SET SCREEN 0.
LEAVE SCREEN.
LEAVE PROGRAM.
ENDFORM. "EXIT_PROGRAM
*----------------------------------------------------------------------*
* CLASS lcl_event_receiver IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS LCL_EVENT_RECEIVER IMPLEMENTATION.
METHOD HANDLE_DOUBLE_CLICK.
READ TABLE VBAK1 INDEX E_ROW INTO VBAK2.
SET PARAMETER ID 'AUN' FIELD VBAK2-VBELN.
CALL FUNCTION 'TH_CREATE_MODE'
EXPORTING
TRANSAKTION = 'VA02'
PROCESS_DARK = 'X'.
ENDMETHOD. "handle_double_click
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
Nachdem du aus dem CALL TRANSACTION in das ALV-EVENT zurück gekehrt bist, mußt du die geändertene Werte ermitteln (itab des ALVs neu aufbauen/updaten). Dann kannst du mit der Methode REFRESH_TABLE_DISPLAY die Daten neu an den ALV übergeben.Adrian hat geschrieben:Hab nur noch eine Frage wie kann ich nachdem des Event ausgelöst wurde die Tabelle und des ALV neu laden ?
Garnicht, wenn du einen neuen Modus startest läuft er paralel zum alten.Adrian hat geschrieben:Wie warte ich dann aber bis der Modus geschlossen wurde?
Folgende Benutzer bedankten sich beim Autor a-dead-trousers für den Beitrag:
Adrian