Dialog Programming (Module Pool)
Dialog programs (type M, PROGRAM) implement classic SAP GUI transactions (like VA01) with screens (dynpros) built in the Screen Painter (SE51), menus/toolbars from the Menu Painter (SE41), and a transaction code (SE93).
19.1 Concepts
Dialog programs (type M, PROGRAM) implement classic SAP GUI transactions (like VA01) with screens (dynpros) built in the Screen Painter (SE51), menus/toolbars from the Menu Painter (SE41), and a transaction code (SE93). New UIs are built with Fiori, but huge amounts of dynpro code are still maintained.
19.2 Screen flow logic
Every screen has two main events:
PBO (Process Before Output) Prepare screen: set GUI status/title, fill fields, modify attributes PAI (Process After Input)
React to user input: validation, sy-ucomm / OK code handling, navigation
Process on help request (F1) / value request (F4)
PROCESS BEFORE OUTPUT.
MODULE status_0100.
MODULE init_0100.
PROCESS AFTER INPUT.
MODULE exit_0100 AT EXIT-COMMAND. " Cancel/Back without field checks
FIELD gs_order-customer MODULE check_customer.
CHAIN.
FIELD: gs_order-amount, gs_order-currency.
MODULE check_amount ON CHAIN-REQUEST.
ENDCHAIN.
MODULE user_command_0100.19.3 ABAP modules
PROGRAM zorder_maint.
DATA: gs_order TYPE zorders,
ok_code TYPE sy-ucomm. " linked to the screen's OK field
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'.
SET TITLEBAR 'TITLE_0100'.
ENDMODULE.
MODULE init_0100 OUTPUT.
LOOP AT SCREEN.
IF screen-name = 'GS_ORDER-ORDER_ID' AND gs_order-order_id IS NOT INITIAL.
screen-input = '0'.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDMODULE.
MODULE exit_0100 INPUT.
LEAVE PROGRAM.
ENDMODULE.
MODULE check_customer INPUT.
SELECT SINGLE @abap_true FROM kna1 WHERE kunnr = @gs_order-customer INTO @DATA(lv_ok).
IF lv_ok <> abap_true.
MESSAGE e010(zorders). " field stays ready for input
ENDIF.
ENDMODULE.
MODULE check_amount INPUT.
ENDMODULE.
MODULE user_command_0100 INPUT.
DATA(lv_code) = ok_code.
CLEAR ok_code.
CASE lv_code.
WHEN 'SAVE'.
MODIFY zorders FROM @gs_order.
COMMIT WORK.
MESSAGE s011(zorders).
WHEN 'NEXT'.
CALL SCREEN 0200.
WHEN 'BACK'.
SET SCREEN 0. LEAVE SCREEN.
ENDCASE.
ENDMODULE.19.4 Screen elements and navigation
Elements: input/output fields, text fields, checkboxes, radio buttons, push buttons, table controls, tabstrips, subscreens, custom containers (for ALV grid, text editor, HTML viewer via controls framework).
Navigation: CALL SCREEN nnnn [STARTING AT x y] (stack, modal popups), SET SCREEN nnnn + LEAVE SCREEN, LEAVE TO SCREEN nnnn.
Field transport: screen fields with the same name as global data objects are copied automatically between PAI/PBO.
LOOP AT SCREEN / MODIFY SCREEN changes attributes (input, active, invisible, required).