Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
AbapWB_content_EN.doc
Скачиваний:
1
Добавлен:
01.03.2025
Размер:
40.44 Mб
Скачать

Wa_sbook-bookid.

ENDIF. ENDSELECT.

CLEAR wa_sbook.

AT LINE-SELECTION.

AUTHORITY-CHECK OBJECT ’S_CARRID’

Id ’carrid’ field wa_sbook-carrid

Id ’actvt’ field actvt_change.

Continued on next page

IF sy-subrc = 0.

SELECT SINGLE * FROM sbook INTO wa_sbook

WHERE carrid = wa_sbook-carrid AND connid = wa_sbook-connid AND fldate = wa_sbook-fldate AND bookid = wa_sbook-bookid.

IF sy-subrc = 0.

MOVE-CORRESPONDING wa_sbook TO sdyn_book.

CALL SCREEN 100.

ELSE.

MESSAGE s176(bc400). ENDIF.

ELSE .

MESSAGE s047(bc400) WITH wa_sbook-carrid. ENDIF.

CLEAR wa_sbook.

285 Exercise 16: Screens: Specifying the Next

Screen Dynamically

Exercise Duration: 40 Minutes

Exercise Objectives

After completing this exercise, you will be able to:

• Create pushbuttons on screens

• Evaluate the function codes triggered by the user by means of pushbuttons in order to control the program flow accordingly

• Set subsequent screens dynamically

Business Example

On the screen of your program ZBC400_##_DYNPRO_1 two pushbuttons with appropriate functions are to be implemented.

System Data

System: Will be assigned Client: Will be assigned User ID: Will be assigned Password: Will be assigned

Set up instructions: No special instructions when using a standard training system

Task 1:

Define the pushbuttons

1. Extend your program ZBC400_##_DYNPRO_1 or copy the template SAPBC400UDS_DYNPRO_2 to the new name ZBC400_##_DYNPRO_3 for further processing.

2. On the screen, define a pushbutton for returning to the basic list (Back) and one for saving the changed data in the database (Save).

Name of pushbutton

Text

Function code

PUSH_BACK

Back

BACK

PUSH_SAVE

Save (or icon

ICON_SYSTEM_SAVE)

SAVE

Continued on next page

Task 2:

Implement dynamic control of subsequent screens

1. Name the 'OK' type field on the screen and define a data object of the same name (and corresponding type) in the program. We suggest the name OK_CODE.

2. Navigate in the flow logic. Create a PAI module by means of forward navigation. In it, implement the following function code handling:

Function code

Action

BACK

Back to basic list

SAVE

Output information message 060 of message class BC400 and return to basic list

Any other action

Process screen 100 again

3. Ensure that choosing Enter always displays screen 100, regardless of the navigation history. To do this, initialize the ok code field in a PBO module.

Solution 16: Screens: Specifying the Next

Screen Dynamically

Task 1:

Define the pushbuttons

1. Extend your program ZBC400_##_DYNPRO_1 or copy the template SAPBC400UDS_DYNPRO_2 to the new name ZBC400_##_DYNPRO_3 for further processing.

a) Carry out this step as usual.

2. On the screen, define a pushbutton for returning to the basic list (Back) and one for saving the changed data in the database (Save).

Name of pushbutton

Text

Function code

PUSH_BACK

Back

BACK

PUSH_SAVE

Save (or icon

ICON_SYSTEM_SAVE)

SAVE

a) Carry out this step as described in the training material.

Task 2:

Implement dynamic control of subsequent screens

1. Name the 'OK' type field on the screen and define a data object of the same name (and corresponding type) in the program. We suggest the name OK_CODE.

a) Carry out this step as described in the training material. b) See source code excerpt in the model solution.

2. Navigate in the flow logic. Create a PAI module by means of forward navigation. In it, implement the following function code handling:

Continued on next page

Function code

Action

BACK

Back to basic list

SAVE

Output information message 060 of message class BC400 and return to basic list

Any other action

Process screen 100 again

a) See source code excerpt in the model solution.

3. Ensure that choosing Enter always displays screen 100, regardless of the navigation history. To do this, initialize the ok code field in a PBO module.

a) See the source code excerpt in the model solution.

Result

Source code excerpt: SAPBC400UDS_DYNPRO_3

REPORT sapbc400uds_dynpro_3.

CONSTANTS: actvt_display TYPE activ_auth VALUE ’03’, actvt_change TYPE activ_auth VALUE ’02’.

PARAMETERS pa_anum TYPE sbook-agencynum.

* workarea for SELECT

DATA wa_sbook TYPE sbook.

* workarea for data communication with screen

TABLES sdyn_book.

* variable for function code of user action

DATA ok_code LIKE sy-ucomm.

START-OF-SELECTION.

SELECT carrid connid fldate bookid

FROM sbook

INTO CORRESPONDING FIELDS OF wa_sbook

WHERE agencynum = pa_anum.

AUTHORITY-CHECK OBJECT ’S_CARRID’

ID ’CARRID’ FIELD wa_sbook-carrid

Continued on next page

ID ’ACTVT’ FIELD actvt_display.

IF sy-subrc = 0.

WRITE: / wa_sbook-carrid COLOR col_key, wa_sbook-connid COLOR col_key, wa_sbook-fldate COLOR col_key, wa_sbook-bookid COLOR col_key.

HIDE: wa_sbook-carrid, wa_sbook-connid, wa_sbook-fldate,

wa_sbook-bookid.

ENDIF. ENDSELECT.

CLEAR wa_sbook.

AT LINE-SELECTION.

AUTHORITY-CHECK OBJECT ’S_CARRID’

ID ’CARRID’ FIELD wa_sbook-carrid

ID ’ACTVT’ FIELD actvt_change. IF sy-subrc = 0.

SELECT SINGLE * FROM sbook INTO wa_sbook

WHERE carrid = wa_sbook-carrid AND connid = wa_sbook-connid AND fldate = wa_sbook-fldate AND bookid = wa_sbook-bookid.

IF sy-subrc = 0.

MOVE-CORRESPONDING wa_sbook TO sdyn_book. CALL SCREEN 100.

ELSE.

MESSAGE s176(bc400). ENDIF.

ELSE .

MESSAGE s047(bc400) WITH wa_sbook-carrid. ENDIF.

CLEAR wa_sbook.

Continued on next page

*&--------------------------------------------------------------*

*& Module CLEAR_OK_CODE OUTPUT *

*&--------------------------------------------------------------*

*& text *

*&--------------------------------------------------------------*

MODULE clear_ok_code OUTPUT.

CLEAR ok_code.

ENDMODULE. " CLEAR_OK_CODE OUTPUT

*&--------------------------------------------------------------*

*& Module USER_COMMAND_0100 INPUT *

*&--------------------------------------------------------------*

*& text *

*&--------------------------------------------------------------*

MODULE user_command_0100 INPUT.

CASE ok_code.