Handling in the ABAP Program

Một phần của tài liệu BC ABAP Programming PHẦN 5 potx (Trang 49 - 54)

Before you can use a tabstrip control in your ABAP program, you must create a control for each control in the declaration part of your program using the following statement:

CONTROLS <ctrl> TYPE TABSTRIP.

where <ctrl> is the name of the tabstrip area on a screen in the ABAP program. The control allows the ABAP program to work with the tabstrip control. The statement declares a structure with the name <ctrl> . The only component of this structure that you need in your program is called ACTIVETAB.

• Use in the PBO event

Before the screen is displayed, you use the control to set the tab page that is currently active. To do this, assign the function code of the corresponding tab title to the

component ACTIVETAB:

<ctrl>-ACTIVETAB = <fcode>.

When you page at the SAPgui, you only need to do this once before the screen is displayed. This initializes the tabstrip control. The default active tab page is the first page. After this, the page activated when the user chooses a tab title is set within SAPgui.

When you page on the application server, you must assign the active page both before the screen is displayed for the first time, and each time the user pages. At the same time, you must set the required subscreen screen.

You can suppress a tab page dynamically by setting the ACTIVE field of table SCREEN [Page 618] to 0 for the corresponding tab title.

• Use in the PAI event

In the PAI event, ACTIVETAB contains the function code of the last active tab title on the screen.

When you page in the SAPgui, this allows you to find out the page that the user can currently see. When you page at the application server, the active tab page is controlled by the ABAP program anyway.

The OK_CODE field behaves differently according to the paging method:

• Paging in the SAPgui

When you page in the SAPgui, the PAI event is not triggered when the user chooses a tab title, and the OK_CODE field is not filled. The OK_CODE field is only filled by user actions in the GUI status or when the user chooses a pushbutton either outside the tabstrip control or on one of the subscreens.

• Paging on the application server

If you are paging at the application server, the PAI event is triggered when the user chooses a tab title, and the OK_CODE field is filled with the corresponding function code.

To page through the tabstrip control, you must assign the function code to the ACTIVETAB component of the control:

<ctrl>-ACTIVETAB = <ok_code>.

Tabstrip Controls

This statement overwrites the function code of the last active tab page with that of the new tab title. At the same time, you must ensure that the correct subscreen is inserted in the subscreen area.

Otherwise, tabstrip controls are handled like normal subscrens in ABAP programs, that is, the ABAP program of a subscreen screen must contain the dialog modules called from the flow logic of the subscreen.

Examples

Tabstrip control, paging at SAPgui

REPORT DEMO_DYNPRO_TABSTRIP_LOCAL.

CONTROLS MYTABSTRIP TYPE TABSTRIP.

DATA: OK_CODE TYPE SY-UCOMM, SAVE_OK TYPE SY-UCOMM.

MYTABSTRIP-ACTIVETAB = 'PUSH2'.

CALL SCREEN 100.

MODULE STATUS_0100 OUTPUT.

SET PF-STATUS 'SCREEN_100'.

ENDMODULE.

MODULE CANCEL INPUT.

LEAVE PROGRAM.

ENDMODULE.

MODULE USER_COMMAND INPUT.

SAVE_OK = OK_CODE.

CLEAR OK_CODE.

IF SAVE_OK = 'OK'.

MESSAGE I888(SABAPDOCU) WITH 'MYTABSTRIP-ACTIVETAB =' MYTABSTRIP-ACTIVETAB.

ENDIF.

ENDMODULE.

The next screen (statically defined) for screen 100 is itself. It has the following layout:

Tab title 1 Tab title 2 Tab title 3

Continue

The screen contains a tabstrip area called MYTABSTRIP with three tab titles

PUSH1, PUSH2 and PUSH3. The function codes have the same name, and all have the function type P. One of the subscreen areas SUB1 to SUB3 is assigned to each tab title. The pushbutton has the name BUTTON and the function code ‘OK’.

In the same ABAP program, there are three subscreen screens 110 to 130. Each of these fits the subscreen area exactly. The layout is:

Subscreen 1,2,3

The screen flow logic for screen 100 is as follows:

PROCESS BEFORE OUTPUT.

MODULE STATUS_0100.

CALL SUBSCREEN: SUB1 INCLUDING SY-REPID '0110', SUB2 INCLUDING SY-REPID '0120', SUB3 INCLUDING SY-REPID '0130'.

PROCESS AFTER INPUT.

MODULE CANCEL AT EXIT-COMMAND.

CALL SUBSCREEN: SUB1, SUB2,

Tabstrip Controls

SUB3.

MODULE USER_COMMAND.

The screen flow logic of subscreens 110 to 130 does not contain any module calls.

When you run the program, a screen appears on which the second tab page is active, since the program sets the ACTIVETAB component of the structure

MYTABSTRIP to PUSH2 before the screen is displayed. The user can page through the tabstrip control without the PAI event being triggered. One of the three

subscreens is included on each tab page.

When the user chooses Continue, the PAI event is triggered, and an information message displays the function code of the tab title of the page that is currently active.

Tabstrip control with paging on the application server.

REPORT DEMO_DYNPRO_TABSTRIP_LOCAL.

CONTROLS MYTABSTRIP TYPE TABSTRIP.

DATA: OK_CODE TYPE SY-UCOMM, SAVE_OK TYPE SY-UCOMM.

DATA NUMBER TYPE SY-DYNNR.

MYTABSTRIP-ACTIVETAB = 'PUSH2'.

NUMBER = '0120'.

CALL SCREEN 100.

MODULE STATUS_0100 OUTPUT.

SET PF-STATUS 'SCREEN_100'.

ENDMODULE.

MODULE CANCEL INPUT.

LEAVE PROGRAM.

ENDMODULE.

MODULE USER_COMMAND INPUT.

SAVE_OK = OK_CODE.

CLEAR OK_CODE.

IF SAVE_OK = 'OK'.

MESSAGE I888(SABAPDOCU) WITH 'MYTABSTRIP-ACTIVETAB =' MYTABSTRIP-ACTIVETAB.

ELSE.

MYTABSTRIP-ACTIVETAB = SAVE_OK.

CASE SAVE_OK.

WHEN 'PUSH1'.

NUMBER = '0110'.

WHEN 'PUSH2'.

NUMBER = '0120'.

WHEN 'PUSH3'.

NUMBER = '0130'.

ENDCASE.

ENDIF.

ENDMODULE.

The statically-defined next screen for screen 100 is itself, and its layout is the same as in the above example. However, the function codes of the three tab titles have the function type <blank> and they all share a single subscreen area SUB.

The same subscreen screens 110 to 130 are defined as in the last example.

The screen flow logic for screen 100 is as follows:

PROCESS BEFORE OUTPUT.

MODULE STATUS_0100.

CALL SUBSCREEN SUB INCLUDING SY-REPID NUMBER.

PROCESS AFTER INPUT.

MODULE CANCEL AT EXIT-COMMAND.

CALL SUBSCREEN SUB.

MODULE USER_COMMAND.

In this example, the program includes a subscreen screen in the subscreen area SUB dynamically during the PBO event.

The screen flow logic of subscreens 110 to 130 does not contain any module calls.

This example has the same function as the previous example, but the paging within the tabstrip control is implemented on the application server. Each time the user chooses a tab title, the function code from the OK_CODE field is assigned to the ACTIVETAB component of structure MYTABSTRIP. At the same time, the variable NUMBER is filled with the screen number of the subscreen that has to be displayed in the subscreen area SUB of the tabstrip control.

Một phần của tài liệu BC ABAP Programming PHẦN 5 potx (Trang 49 - 54)

Tải bản đầy đủ (PDF)

(153 trang)