- •Introduction to the abap Workbench
- •15 Introduction to the abap Workbench
- •49 Exercise 3: Creating Transactions
- •Case pa_op.
- •When ’/’.
- •In debugging mode.
- •127 Exercise 7: Working with Internal Tables
- •Loop at it_spfli into wa_spfli.
- •Into (field_1, ... , field_n)
- •100 * Wa_flight-seatsocc / wa_flight-seatsmax.
- •Insert wa_flight into table it_flight.
- •Wa_flight-percentage, ’%’.
- •Id ’actvt’ field ’02’.
- •Id ’actvt’ field actvt_display.
- •Into corresponding fields of wa_flight
- •100 * Wa_flight-seatsocc / wa_flight-seatsmax.
- •195 Exercise 11: Subroutines
- •100 * Wa_flight-seatsocc / wa_flight-seatsmax.
- •Clear wa_flight. At line-selection.
- •Wa_flight-fldate.
- •Wa_sbook-cancelled.
- •Wa_sbook-loccurkey.
- •Id ’actvt’ field actvt_display. If sy-subrc ne 0.
- •Into corresponding fields of wa_flight
- •100 * Wa_flight-seatsocc / wa_flight-seatsmax.
- •At line-selection. Call screen 100.
- •Wa_sbook-bookid.
- •Id ’carrid’ field wa_sbook-carrid
- •Id ’actvt’ field actvt_change.
- •When ’back’.
- •303 Exercise 17: Creating an Interface
- •When ’rw’.
- •Importing
- •If container_r is initial.
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.
