Verständisfrage zu BCALV_EDIT_03

Die Frage ist als "gelöst" markiert. Den entsprechend Beitrag findest du hier.

Getting started ... Alles für einen gelungenen Start.
11 Beiträge • Seite 1 von 1
11 Beiträge Seite 1 von 1

Verständisfrage zu BCALV_EDIT_03

Beitrag von Gast ( / / 0 / 3 ) »
Hallo ABAP'ler,

ich habe eine Verständisfrage zu einem SAP-Demoprogramm.
Und zwar konkret zu BCALV_EDIT_03, das auf ABAP-Objects aufsetzt.
Die dort eingesetzte Funktionalität kann ich sehr gut für eine aktuelle Anforderung nutzen.
Allerdings habe ich noch nicht ganz die Peilung hinsichtlich ABAP-Objects.

Ich stehe momentan an einer Stelle auf dem Schlauch.
Wenn das o.g. Programm gestartet wird, erscheint sofort die Liste zum Bearbeiten. Logo, es fehlt ein Selektionsbild.
Mit "Zurück" wird das Programm beendet. Auch klar.

Wie bekomme ich es nun ganz einfach hin, dass ich dort ein Selektionsbild einbaue, zu dem ich nach dem Beenden des Programms gelange.
Also wenn ich mit "Zurück" mich aus der Liste verabschiede.
Das Selektionsbild definieren ist auch nicht das Problem. Das funktioniert.
Aber wie erreiche ich es, dass ich ins Selektionsbild zurückspringe und nicht ganz aus dem Programm fliege.

Kann mir jemand einen Tip geben?

Vielen Dank im voraus für Eure Hilfe.

David

gesponsert
Stellenangebote auf ABAPforum.com schalten
kostenfrei für Ausbildungsberufe und Werksstudenten


Beitrag von DeathGuardian (Expert / 759 / 0 / 3 ) »
Bei dem o.g. Programm liegt es daran, das bei "Zurück" der definierte OK-Code "EXIT" benutzt wird der im PBO abgefragt wird und den Befehl "LEAVE PROGRAMM" ausführt.

Wenn du aber aus dem "LEAVE PROGRAMM" ein "LEAVE TO SCREEN 0." machst, springt er auf den Selektionsbildschirm zurück, sofern einer vorhanden ist.

Beitrag von Gast ( / / 0 / 3 ) »
Vielen Dank DeathGuardian. Das war des Rätsels Lösung. Funktioniert jetzt alles bestens.

Nun habe ich noch eine ähnliche Frage zu einem anderen Programm.
Und zwar diesmal BCALV_GRID_05.
Auch hier würde ich gerne verstehen, wie ich beim Beenden des Programms (aus der Liste heraus), in ein Selektionsbild zurückspringen kann.
Das definieren eines Selektionsbilds ist nicht das Problem.
Nur gelange ich nicht in das Selektionsbild nachdem ich das Grid verlasse. Wie kann man so etwas realisieren?

Hat das was mit dem "SET SCREEN 100" zu tun?

Vielen Dank im voraus.

David

Beitrag von Gast ( / / 0 / 3 ) »
Anonymous hat geschrieben:Nun habe ich noch eine ähnliche Auch hier würde ich gerne verstehen, wie ich beim Beenden des Programms (aus der Liste heraus), in ein Selektionsbild zurückspringen kann.
Wenn du mit den ZURÜCK/BEENDEN/ABRECHEN das Programm verläßt wird der Funktionscode EXIT ausgelöst. In der PAI-Verarbeitung wird bei sy-ucomm = EXIT die Formroutine exit_program aufgerufen. In dieser Formroutine werden die erzeugten Objekte frei gegeben. Die letzte Anweisung LEAVE PROGRAM beendet das Programm. Anstatt das Programm zuverlassen kannst du an dieser Stelle auf deinen Selection-Screen zurück kehren.
Anonymous hat geschrieben: Hat das was mit dem "SET SCREEN 100" zu tun?
Mit dieser Anweisung wird das Dynpro 100 als nächstes zu rufende Dynpro gesetzt. Da im Report sonst nichts getan wird, wird nach dem setzten dierekt der Screen gerufen.

Gruß Hendrik

Beitrag von Gast ( / / 0 / 3 ) »
Die letzte Anweisung LEAVE PROGRAM beendet das Programm. Anstatt das Programm zuverlassen kannst du an dieser Stelle auf deinen Selection-Screen zurück kehren.
OK, schon verstanden.
Nur mit welchem Befehl erreiche ich den Rücksprung in das Selektionsbild? Das ist mir noch nicht ganz klar geworden.
Doch nicht mit call selection-screen 1000, oder?

Beitrag von ereglam (Top Expert / 1829 / 2 / 7 ) »
Hallo,

wie DeathGuardian schon schrieb, ist es der 'LEAVE TO SCREEN 0', der zum vorhergehenden Screen zurückkehrt. Man kann jedoch auch die alte Variante 'SET SCREEN 0. LEAVE SCREEN.' benutzen.
Gruß
Ereglam


May the Force be with your code
|| .| |.|| | .... . ..|. ||| .|. |.|. . |... . .|| .. | .... |.|| ||| ..| .|. |.|. ||| |.. .

Beitrag von Gast ( / / 0 / 3 ) »
Das mit 'LEAVE TO SCREEN 0' statt 'LEAVE PROGRAMM' hatte ich zuerst auch ausprobiert.
Aber das scheint bei BCALV_GRID_05 nicht zu funktionieren.
Ich habe das Programm nochmal kopiert und dort nur einen Parameter als Selektionsbild definiert.
Mit 'LEAVE TO SCREEN 0' wird ebenfalls das Prgramm kpl. beendet. SAP soll aber in das Selektionsbild zurückspringen.
Das muss doch irgendwie funktionieren. Oder muss etwas Besonderes bei der Definition des Selektionsbildes beachtet werden?

Für Eure Hilfe bin ich sehr dankbar.

David

Beitrag von ereglam (Top Expert / 1829 / 2 / 7 ) »
Hallo David,

möglicherweise liegt es daran, dass wir von unterschiedlichen Programmarten ausgehen.

Poste doch bitte das Grundgerüst Deiner Reports.
Gruß
Ereglam


May the Force be with your code
|| .| |.|| | .... . ..|. ||| .|. |.|. . |... . .|| .. | .... |.|| ||| ..| .|. |.|. ||| |.. .

Beitrag von Gast ( / / 0 / 3 ) »
OK, hier nun der Report. Ist eine Kopie von BCALV_GRID_05 unter 4.6c.

Das einzige was ich geändert habe, ist ein Selektionsparamter (zum Testen sollte dieser genügen).
Außerdem habe ich in der FORM exit_program "LEAVE PROGRAM' mit 'LEAVE TO SCREEN 0' ersetzt.



PROGRAM ZBCALV_GRID_05.
*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
* Purpose:
* ~~~~~~~~
* Demonstrate the creation of an own toolbar button.
*-----------------------------------------------------------------
* To check program behavior
* ~~~~~~~~~~~~~~~~~~~~~~~~~
* The report shows a list of flights of one airline.
* Select one or more lines and press the 'Detail'-Button to popup
* a dialog window with related bookings.
*-------------------------------------------------------------------
* Essential steps (Search for '§')
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* 1.Apply steps for event handling for events TOOLBAR and
* USER_COMMAND (see example for print events)
* 2.In event handler method for event TOOLBAR: Append own functions
* by using event parameter E_OBJECT.
* 3.In event handler method for event USER_COMMAND: Query your
* function codes defined in step 2 and react accordingly.
* 4.Call method 'set_toolbar_interactive' to raise event TOOLBAR.
*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

INCLUDE <icon>.
*********
* Predefine a local class for event handling to allow the
* declaration of a reference variable before the class is defined.
CLASS lcl_event_receiver DEFINITION DEFERRED.
*
*********


DATA: ok_code LIKE sy-ucomm,
gt_sflight TYPE TABLE OF sflight,
gt_sbook TYPE TABLE OF sbook,
g_repid LIKE sy-repid,
g_max type i value 100,
gs_layout TYPE lvc_s_layo,

cont_on_main TYPE scrfname VALUE 'BCALVC_TOOLBAR_D100_C1',
cont_on_dialog TYPE scrfname VALUE 'BCALVC_TOOLBAR_D101_C1',
grid1 TYPE REF TO cl_gui_alv_grid,
grid2 TYPE REF TO cl_gui_alv_grid,
custom_container1 TYPE REF TO cl_gui_custom_container,
custom_container2 TYPE REF TO cl_gui_custom_container,
event_receiver TYPE REF TO lcl_event_receiver.

*Selektionsbild
parameters: p_box as checkbox.

* Set initial dynpro
SET SCREEN 100.

****************************************************************
* LOCAL CLASSES: Definition
****************************************************************
*===============================================================
* class lcl_event_receiver: local class to
* define and handle own functions.
*
* Definition:
* ~~~~~~~~~~~
CLASS lcl_event_receiver DEFINITION.

PUBLIC SECTION.

METHODS:
handle_toolbar
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object e_interactive,

handle_user_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm.

PRIVATE SECTION.

ENDCLASS.
*
* lcl_event_receiver (Definition)
*===============================================================

****************************************************************
* LOCAL CLASSES: Implementation
****************************************************************
*===============================================================
* class lcl_event_receiver (Implementation)
*
*
CLASS lcl_event_receiver IMPLEMENTATION.

METHOD handle_toolbar.

* § 2.In event handler method for event TOOLBAR: Append own functions
* by using event parameter E_OBJECT.
DATA: ls_toolbar TYPE stb_button.
*....................................................................
* E_OBJECT of event TOOLBAR is of type REF TO CL_ALV_EVENT_TOOLBAR_SET.
* This class has got one attribute, namly MT_TOOLBAR, which
* is a table of type TTB_BUTTON. One line of this table is
* defined by the Structure STB_BUTTON (see data deklaration above).
*

* A remark to the flag E_INTERACTIVE:
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* 'e_interactive' is set, if this event is raised due to
* the call of 'set_toolbar_interactive' by the user.
* You can distinguish this way if the event was raised
* by yourself or by ALV
* (e.g. in method 'refresh_table_display').
* An application of this feature is still unknown... :-)

* append a separator to normal toolbar
CLEAR ls_toolbar.
MOVE 3 TO ls_toolbar-butn_type.
APPEND ls_toolbar TO e_object->mt_toolbar.
* append an icon to show booking table
CLEAR ls_toolbar.
MOVE 'BOOKINGS' TO ls_toolbar-function.
MOVE icon_employee TO ls_toolbar-icon.
MOVE 'Show Bookings'(111) TO ls_toolbar-quickinfo.
MOVE 'Detail'(112) TO ls_toolbar-text.
MOVE ' ' TO ls_toolbar-disabled.
APPEND ls_toolbar TO e_object->mt_toolbar.

ENDMETHOD.
*-------------------------------------------------------------------
METHOD handle_user_command.
* § 3.In event handler method for event USER_COMMAND: Query your
* function codes defined in step 2 and react accordingly.

DATA: lt_rows TYPE lvc_t_row.

CASE e_ucomm.
WHEN 'BOOKINGS'.
CALL METHOD grid1->get_selected_rows
IMPORTING et_index_rows = lt_rows.
CALL METHOD cl_gui_cfw=>flush.
IF sy-subrc ne 0.
* add your handling, for example
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = g_repid
txt2 = sy-subrc
txt1 = 'Error in Flush'(500).
else.
perform show_booking_table tables lt_rows.
ENDIF.
ENDCASE.
ENDMETHOD. "handle_user_command
*-----------------------------------------------------------------
ENDCLASS.
*
* lcl_event_receiver (Implementation)
*===================================================================

*---------------------------------------------------------------------*
* FORM EXIT_PROGRAM *
*---------------------------------------------------------------------*
FORM exit_program.
* The instance grid2 is freed not until the program exits from the
* main screen.
* (It is created only once during the first selection of SBOOK,
* no matter how many times the second window is called).
*
CALL METHOD custom_container1->free.
IF not custom_container2 is initial.
CALL METHOD custom_container2->free.
ENDIF.
CALL METHOD cl_gui_cfw=>flush.
IF sy-subrc ne 0.
* add your handling, for example
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = g_repid
txt2 = sy-subrc
txt1 = 'Error in Flush'(500).
ENDIF.
* LEAVE PROGRAM.
LEAVE TO SCREEN 0.
ENDFORM.
*&---------------------------------------------------------------------*
*& Module PBO_100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE pbo_100 OUTPUT.

SET PF-STATUS 'MAIN100'.
g_repid = sy-repid.
IF custom_container1 is initial.
* select data from table SFLIGHT
PERFORM select_table_sflight CHANGING gt_sflight.

* create a custom container control for our ALV Control
CREATE OBJECT custom_container1
EXPORTING
container_name = cont_on_main
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
IF sy-subrc ne 0.
* add your handling, for example
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = g_repid
txt2 = sy-subrc
txt1 = 'The control could not be created'(510).
ENDIF.

* create an instance of alv control
CREATE OBJECT grid1
EXPORTING i_parent = custom_container1.
*
* Set a titlebar for the grid control
*
gs_layout-grid_title = 'Flights'(100).
* allow to select multiple lines
gs_layout-sel_mode = 'A'.

CALL METHOD grid1->set_table_for_first_display
EXPORTING i_structure_name = 'SFLIGHT'
is_layout = gs_layout
CHANGING it_outtab = gt_sflight.



********
* ->Create Object to receive events and link them to handler methods.
* When the ALV Control raises the event for the specified instance
* the corresponding method is automatically called.
*
CREATE OBJECT event_receiver.
SET HANDLER event_receiver->handle_user_command FOR grid1.
SET HANDLER event_receiver->handle_toolbar FOR grid1.
*
********

* § 4.Call method 'set_toolbar_interactive' to raise event TOOLBAR.
CALL METHOD grid1->set_toolbar_interactive.

ENDIF. "IF grid1 IS INITIAL
CALL METHOD cl_gui_control=>set_focus EXPORTING control = grid1.

ENDMODULE. " PBO_100 OUTPUT
*&---------------------------------------------------------------------*
*& Module PAI_100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE pai_100 INPUT.

CASE ok_code.
WHEN 'EXIT'.
PERFORM exit_program.

ENDCASE.
CLEAR ok_code.
ENDMODULE. " PAI_100 INPUT
*&---------------------------------------------------------------------*
*& Module PBO_0101 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE pbo_0101 OUTPUT.

IF custom_container2 is initial.
* (the data from sbook is already selected)

* create a custom container control for our ALV Control
CREATE OBJECT custom_container2
EXPORTING
container_name = cont_on_dialog
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
IF sy-subrc ne 0.
* add your handling, for example
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = g_repid
txt2 = sy-subrc
txt1 = 'The control could not be created'(510).
ENDIF.
* create an instance of alv control
CREATE OBJECT grid2
EXPORTING i_parent = custom_container2.
*
* change title
*
gs_layout-grid_title = 'Bookings'(101).

gs_layout-sel_mode = ' '.
CALL METHOD grid2->set_table_for_first_display
EXPORTING i_structure_name = 'SBOOK'
is_layout = gs_layout
CHANGING it_outtab = gt_sbook.

ELSE.
CALL METHOD grid2->refresh_table_display.
ENDIF. "IF custom_container2 IS INITIAL.
CALL METHOD cl_gui_control=>set_focus EXPORTING control = grid2.
CALL METHOD cl_gui_cfw=>flush.
IF sy-subrc ne 0.
* add your handling, for example
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = g_repid
txt2 = sy-subrc
txt1 = 'Error in Flush'(500).
ENDIF.

ENDMODULE. " PBO_0101 OUTPUT
*&---------------------------------------------------------------------*
*& Form SELECT_TABLE_SFLIGHT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_GT_SFLIGHT text
*----------------------------------------------------------------------*
FORM select_table_sflight CHANGING p_gt_sflight LIKE gt_sflight[].
SELECT * FROM sflight INTO TABLE p_gt_sflight up to g_max rows.
ENDFORM. " SELECT_TABLE_SFLIGHT


*&---------------------------------------------------------------------*
*& Form SELECT_TABLE_SBOOK
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LS_SFLIGHT text
* <--P_GT_SBOOK text
*----------------------------------------------------------------------*
FORM select_table_sbook USING p_ls_sflight LIKE LINE OF gt_sflight
CHANGING p_gt_sbook LIKE gt_sbook[].
DATA: lt_sbook LIKE gt_sbook[].

* Select data from sbook according to a line of sflight
* and append that data to table p_gt_sbook
*
SELECT * FROM sbook INTO TABLE lt_sbook
WHERE carrid = p_ls_sflight-carrid
AND connid = p_ls_sflight-connid
AND fldate = p_ls_sflight-fldate.

APPEND LINES OF lt_sbook TO p_gt_sbook.

ENDFORM. " SELECT_TABLE_SBOOK
*&---------------------------------------------------------------------*
*& Module PAI_0101 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE pai_0101 INPUT.
CASE ok_code.
WHEN 'RETURN'.
LEAVE TO SCREEN 0.

ENDCASE.
CLEAR ok_code.
ENDMODULE. " PAI_0101 INPUT
*&---------------------------------------------------------------------*
*& Form show_booking_table
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_ET_INDEX_ROWS text
*----------------------------------------------------------------------*
FORM show_booking_table TABLES p_et_index_rows
STRUCTURE lvc_s_row.

DATA: ls_selected_line LIKE lvc_s_row,
lf_row_index TYPE lvc_index,
ls_sflight LIKE LINE OF gt_sflight.

CLEAR gt_sbook[].
LOOP AT p_et_index_rows INTO ls_selected_line.
lf_row_index = ls_selected_line-index.
* read selected row from internal table gt_sflight
READ TABLE gt_sflight INDEX lf_row_index INTO ls_sflight.

* select corresponding lines of table sbook
* and append new lines to global table
PERFORM select_table_sbook USING ls_sflight
CHANGING gt_sbook.
ENDLOOP.
* call dialog screen and display new alv control
CALL SCREEN 101 STARTING AT 10 5.

ENDFORM. " show_booking_table

Beitrag von ereglam (Top Expert / 1829 / 2 / 7 ) »
Hallo David,

ohne mir das Programm im Einzeln zu Gemüte geführt zu haben, vermute ich, dass durch Setzen des Screen mit 'SET SCREEN 0100' der reguläre Ablauf unterbrochen wurde.

Probier mal aus, ob Du bessere Erfolge hast, wenn Du statt dessen zum START-OF-SELECTION ein 'CALL SCREEN 0100' benutzt
Gruß
Ereglam


May the Force be with your code
|| .| |.|| | .... . ..|. ||| .|. |.|. . |... . .|| .. | .... |.|| ||| ..| .|. |.|. ||| |.. .

Beitrag von Gast ( / / 0 / 3 ) »
ereglam hat geschrieben:Hallo David,

ohne mir das Programm im Einzeln zu Gemüte geführt zu haben, vermute ich, dass durch Setzen des Screen mit 'SET SCREEN 0100' der reguläre Ablauf unterbrochen wurde.

Probier mal aus, ob Du bessere Erfolge hast, wenn Du statt dessen zum START-OF-SELECTION ein 'CALL SCREEN 0100' benutzt
Hi Ereglam,

ich habe es mal kurz mit Deinem Vorschlag getestet. Und siehe da - es funktioniert nun wie gewünscht.
1000 Dank !!!

David

Seite 1 von 1

Vergleichbare Themen

2
Antw.
1513
Views
REUSE_ALV_ und EDIT
von TakerOne » 20.06.2006 13:54 • Verfasst in ABAP® Core
2
Antw.
1468
Views
RESUE_ALV_GRID_DISPLAY & edit
von Kojak » 10.07.2006 16:50 • Verfasst in ABAP® Core
4
Antw.
3539
Views
Edit-Control und Schlüsselfelder
von ewx » 10.01.2007 18:04 • Verfasst in ABAP Objects®
7
Antw.
3410
Views
Edit Funktionsbaustein REUSE_ALV_GRID_DISPLAY_LVC in Ausgabe
von reim95 » 12.04.2018 09:32 • Verfasst in ABAP® für Anfänger
2
Antw.
1995
Views
Farbe Edit Felder CL_GUI_ALV_GRID
von Pinguincommander » 07.06.2013 09:27 • Verfasst in ABAP® Core

Über diesen Beitrag


Die Frage ist als "gelöst" markiert. Den entsprechend Beitrag findest du hier.

Unterstütze die Community und teile den Beitrag für mehr Leser und Austausch

Newsletter Anmeldung

Keine Beiträge verpassen! Wöchentlich versenden wir lesenwerte Beiträge aus unserer Community.
Die letzte Ausgabe findest du hier.
Details zum Versandverfahren und zu Ihren Widerrufsmöglichkeiten findest du in unserer Datenschutzerklärung.