|
2 | 2 | outline: [2, 4] |
3 | 3 | --- |
4 | 4 | # Navigation |
5 | | - |
6 | | -In abap2UI5, each app is a single ABAP class. You can pack all logic into one class, but keeping classes at a reasonable size is better practice. Splitting functionality into multiple interacting classes lets you build reusable apps and popups that work in different contexts. |
7 | | - |
8 | | -### Cross App Navigation |
9 | | - |
10 | | -#### Backend |
11 | | -To call an ABAP class: |
12 | | -```abap |
13 | | - METHOD z2ui5_if_app~main. |
14 | | -
|
15 | | - DATA(lo_app) = NEW z2ui5_cl_new_app( ). |
16 | | - client->nav_app_call( lo_app ). |
17 | | -
|
18 | | -ENDMETHOD. |
19 | | -``` |
20 | | -The framework keeps a call stack. From the newly called class, return to the previous app with: |
21 | | -```abap |
22 | | - METHOD z2ui5_if_app~main. |
23 | | -
|
24 | | - client->nav_app_leave( ). |
25 | | -
|
26 | | -ENDMETHOD. |
27 | | -``` |
28 | | -To read data from the previous app, cast it like this: |
29 | | -```abap |
30 | | - METHOD z2ui5_if_app~main. |
31 | | -
|
32 | | - IF client->check_on_navigated( ). |
33 | | - DATA(lo_called_app) = CAST z2ui5_cl_new_app( client->get_app_prev( ) ). |
34 | | - client->message_box_display( `Input made in the previous app:` && lo_called_app->mv_input ). |
35 | | - ENDIF. |
36 | | -
|
37 | | -ENDMETHOD. |
38 | | -``` |
39 | | -To navigate to an app without pushing it onto the call stack: |
40 | | -```abap |
41 | | - METHOD z2ui5_if_app~main. |
42 | | -
|
43 | | - DATA(lo_app) = NEW z2ui5_cl_new_app( ). |
44 | | - client->nav_app_leave( lo_app ). |
45 | | -
|
46 | | -ENDMETHOD. |
47 | | -``` |
48 | | -::: tip |
49 | | -Sounds familiar? The abap2UI5 framework echoes classic `call screen` and `leave to screen` behavior. |
50 | | -::: |
51 | | - |
52 | | -#### Launchpad |
53 | | -We recommend backend communication only for view changes or popup calls. With a Launchpad, consider navigating via the Launchpad to use browser navigation and history: |
54 | | -```abap |
55 | | -client->_event_client( |
56 | | - val = client->cs_event-cross_app_nav_to_ext |
57 | | - t_arg = VALUE #( ( |
58 | | - `{ semanticObject: "Z2UI5_CL_LP_SAMPLE_04", action: "display" }` |
59 | | - ) ) ). |
60 | | -``` |
61 | | -For more on Launchpads and routing, see the [Fiori Launchpad](/configuration/launchpad) page. |
62 | | - |
63 | | -### Inner App Navigation |
64 | | - |
65 | | -Use class attributes to track the current state and switch views as needed. This keeps navigation logic in a single ABAP class with no cross-app calls. |
0 commit comments