Вы находитесь на странице: 1из 47

Module-Pool Programming

Module-pool programming is defined as set of screen sequence flow. Here we enter, add data,
change data, view the data. Here we will design the screens and their coding called as flow
logic. Flow logic defines coding and triggering of each screen.

In the flow logic, you will define when to trigger the screen. Triggering of screens is done through
events. They are PBO, PAI, POH, and POV.

PBO- Process Before Output

PAI- Process After Input

POH- Process On Help-Request

POV- Process On Value-Request

Module-pool programming r online programming r dialog programming r screen programming r


same.

We can screen programming through SE51, SE38, SE80, and SE41.

If we call through SE80, u have to check the top include program check box.

If we call through SE51, you will design screen and flow logic in ABAP editor

If we call through SE38, you will call the statement CALL SCREEN 100.

Go to SE80, Right click on PACKAGE name, click on CREATE and click on PROGRAM.

Define program name SAPMZSAMPLEMODULE.

Check the option TOP include Box.

Then it will display all the include programs

The include programs are

TOP include: Where we define all data declarations

O01 include: PBO Module, where we output of programs. It is triggered before executing
program.

I01 Include: PAI Module, here we input operations after output. It is triggered after program is
executed. Like we can add, delete, view data.

F01 Include: Form Routines: Here we define sub routines.

After these activate each include programs.

It will show some errors, ignore them and activate all include programs.

Finally activate the whole program. Then right click on program name, click on SCREEN.

Then define attributes on the screen.

Then click on layout button on the application tool bar.


Then click on middle icon to retrieve data from data dictionary.

Choose the fields for displaying data.

In the first screen we input the values and see the output in the second screen.

Then define flow logic.

PROCESS BEFORE OUTPUT.


MODULE STATUS_0100.
*
PROCESS AFTER INPUT.

* MODULE USER_COMMAND_0100.

CHAIN.
FIELD: SDYN_CONN-CARRID,
SDYN_CONN-CONNID MODULE CHECK_SPLFI.

ENDCHAIN.

MODULE TRANS_FROM_100.

Then design second screen.

Same as above as we retrieved from data dictionary, define the fields on click middle icon. Select
the fields.

Then define flow logic.

Top include program.

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

*& Include MZSAMPLEMODULETOP Module Pool SAPMZSAMPLEMODULE


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

PROGRAM SAPMZSAMPLEMODULE.

TABLES: SDYN_CONN.

DATA: WA_SPFLI TYPE SPFLI.

PROCESS BEFORE OUTPUT.


MODULE STATUS_0200.

MODULE TRANS_TO_200.

PROCESS AFTER INPUT.


MODULE USER_COMMAND_0200.

Go to screen 100. Double-click on module check spfli.


It open short pop-up window. It ask for create include program
Then select yes.

Define coding in PAI.

*&---------------------------------------------------------------------*
*& Module CHECK_SPLFI INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE CHECK_SPLFI INPUT.

SELECT SINGLE * FROM SPFLI


INTO CORRESPONDING FIELDS OF SDYN_CONN
WHERE CARRID = SDYN_CONN-CARRID
AND CONNID = SDYN_CONN-CONNID.

ENDMODULE. " CHECK_SPLFI INPUT

Same way double-click on module status_0100.

*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'ZSTATUS100'.
SET TITLEBAR 'ZTITLE100'.

ENDMODULE. " STATUS_0100 OUTPUT

Then double-click on ZSTATUS100.

Define function keys over there.

Save and activate it.

Same as above double click on title.

Then double click on MODULE TRANS_FROM_100 INPUT.

*&---------------------------------------------------------------------*
*& Module TRANS_FROM_100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE TRANS_FROM_100 INPUT.

MOVE-CORRESPONDING SDYN_CONN TO WA_SPFLI.

ENDMODULE. " TRANS_FROM_100 INPUT

.
Then double-click on MODULE STATUS_0200 OUTPUT. Define coding.

*&---------------------------------------------------------------------*
*& Module STATUS_0200 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0200 OUTPUT.
SET PF-STATUS 'ZSTATUS200'.
SET TITLEBAR 'ZTITLE200'.

ENDMODULE. " STATUS_0200 OUTPUT

Then double-click on MODULE TRANS_TO_200 output. Define coding.

*&---------------------------------------------------------------------*
*& Module TRANS_TO_200 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE TRANS_TO_200 OUTPUT.

MOVE-CORRESPONDING WA_SPFLI TO SDYN_CONN.

ENDMODULE. " TRANS_TO_200 OUTPUT

Then double-click on MODULE USER_COMMAND_200 Input. Define coding.

*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0200 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0200 INPUT.
CASE SY-UCOMM.

WHEN 'BACK'.
LEAVE TO SCREEN 0.

WHEN 'EXIT'.
LEAVE PROGRAM.

WHEN 'STOP'.
LEAVE PROGRAM.

ENDCASE.
ENDMODULE. " USER_COMMAND_0200 INPUT

Save and activate it.

Then right click on program name, click on TRANSACTION.

Define transaction name, package name, program name and screen no.

Output:-

OPERATIONS CODING:

Go to SE80, Right click on package name create program.


Then activate all includes programs, even though it shows any error, just activate them.
Then right click on program name, create screens
Define attributes of screen. Click on layout.

Then create another screen 200 for displaying result.

Then define flow logic for screen 100.

PROCESS BEFORE OUTPUT.


* MODULE STATUS_0100.

PROCESS AFTER INPUT.


* MODULE USER_COMMAND_0100.

MODULE CHECK_INPUT.

Then define flow logic for screen 200.

PROCESS BEFORE OUTPUT.


MODULE STATUS_0200.

MODULE CHECK_INPUT.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0200.

* MODULE CHECK_INPUT.

MODULE CHECK_IN.

Define top declarations for program.

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

*& Include MYOPERATIONSTOP Module Pool SAPMYOPERATIONS


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

PROGRAM SAPMYOPERATIONS.

DATA: NUMBER1 TYPE I,


NUMBER2 TYPE I,
RES TYPE I.

DATA: ADD, SUB, MULT, DIV .

Double-click on MODULE CHECK_INPUT. Define coding.

*&---------------------------------------------------------------------*
*& Module CHECK_INPUT INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE CHECK_INPUT INPUT.

CASE SY-UCOMM.

WHEN 'ADD'.
RES = NUMBER1 + NUMBER2.
MESSAGE I001(ZSAMPLE).
WHEN 'SUBT'.
RES = NUMBER1 - NUMBER2.
MESSAGE I002(ZSAMPLE).
WHEN 'MULT'.
RES = NUMBER1 * NUMBER2.
MESSAGE I003(ZSAMPLE).

WHEN 'DIV'.
RES = NUMBER1 / NUMBER2.
MESSAGE I004(ZSAMPLE).
ENDCASE.

ENDMODULE. " CHECK_INPUT INPUT

Double click on MODULE CHECK_IN. define coding


*&---------------------------------------------------------------------*
*& Module CHECK_IN INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE CHECK_IN INPUT.

CASE SY-UCOMM.

WHEN 'BACK'.
SET SCREEN 100.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'STOP'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " CHECK_IN INPUT

Right click on program name, create TRANSACTION.


Then create transaction code for executing module-pool programmes.

Execute program with this t-code and check o/p.

SAMPLE MODULE PROGRAM USING PUSH BUTTONS

Go to SE80, right click on package name, create program.

Then activate all includes program and main program too.

Then right click on program name, create screen. Define attributes of screen.

Then design another screen for output.

Then define flow logic for screen 100.

PROCESS BEFORE OUTPUT.


MODULE STATUS_0100.

PROCESS AFTER INPUT.


MODULE USER_COMMAND_0100.

CHAIN.

FIELD: KNA1-KUNNR MODULE CHECK_KNA1.

ENDCHAIN.

MODULE TRANS_FROM_100.

Then define flow logic for screen 200.

PROCESS BEFORE OUTPUT.


MODULE STATUS_0200.

MODULE TRANS_TO_200.

PROCESS AFTER INPUT.


MODULE USER_COMMAND_0200.

Define TOP declarations.


*&---------------------------------------------------------------------*
*& Include MYPOOL3TOP Module Pool SAPMYPOOL3
*&
*&---------------------------------------------------------------------*

PROGRAM SAPMYPOOL3.

TABLES: KNA1, ZSAMPLESTRU.

DATA: ITAB TYPE KNA1 OCCURS 0 WITH HEADER LINE.

DATA: WA_KNA1 LIKE TABLE OF ITAB WITH HEADER LINE.

Double-click on MODULE CHECK_KNA1. Define coding.

*&---------------------------------------------------------------------*
*& Module CHECK_KNA1 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*

MODULE CHECK_KNA1 INPUT.

MOVE-CORRESPONDING ZSAMPLESTRU TO WA_KNA1.

ENDMODULE. CHECK_KNA1 INPUT

Double-click on MODULE TRANS_FROM_100. Define coding.

*&---------------------------------------------------------------------*
*& Module TRANS_FROM_100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE TRANS_FROM_100 INPUT.

SELECT SINGLE * FROM KNA1


WHERE KUNNR = KNA1-KUNNR.

ENDMODULE. " TRANS_FROM_100 INPUT

Double-click on MODULE TRANS_TO_200. define coding.

*&---------------------------------------------------------------------*
*& Module TRANS_TO_200 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE TRANS_TO_200 OUTPUT.

MOVE-CORRESPONDING WA_KNA1 TO ZSAMPLESTRU.

ENDMODULE. " TRANS_TO_200 OUTPUT

Double click on MODULE STATUS_0000 in PBO for screen 100 & 200.

Create GUI status for each screen.

*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'ZSTATUS-100'.
SET TITLEBAR 'CUSTOMER DETAILS'.

ENDMODULE. " STATUS_0100 OUTPUT

*&---------------------------------------------------------------------*
*& Module STATUS_0200 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0200 OUTPUT.
SET PF-STATUS 'ZSTATUS-200'.
SET TITLEBAR 'CUSTOMER DATA'.

ENDMODULE. " STATUS_0200 OUTPUT

Double-click on MODULE USER_COMMAND in PAI for screen 100 & 200.

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

*& Module USER_COMMAND_0100 INPUT


*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0100 INPUT.

CASE SY-UCOMM.

WHEN 'BACK'.
SET SCREEN 0.

WHEN 'DISPLAY'.
LEAVE PROGRAM.

WHEN 'EXIT'.
LEAVE TO SCREEN 100.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0200 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0200 INPUT.

CASE SY-UCOMM.

WHEN 'BACK'.
LEAVE TO SCREEN 100.

WHEN 'DISPLAY'.
LEAVE PROGRAM.

WHEN 'EXIT'.
*SET SCREEN 0.
leave program.

ENDCASE.

ENDMODULE. " USER_COMMAND_0200 INPUT

Create T-code to execute this application.

SAMPLE PROGRAM USING CHECK BOXES

Go to SE80, right click on package name, create program.

Then activate all includes program and main program too.

Then right click on program name, create screen. Define attributes of screen.

Then design another screen for output.

Then define flow logic for screen 100.

PROCESS BEFORE OUTPUT.


MODULE STATUS_0100.
*
PROCESS AFTER INPUT.
* MODULE USER_COMMAND_0100.

FIELD: EKKO-EBELN MODULE CHECK_INPUT.

MODULE TRANS_FROM_100.

Then define flow logic for screen 200.

PROCESS BEFORE OUTPUT.


* MODULE STATUS_0200.

MODULE TRANS_TO_200.

MODULE CHECK_OUTPUT.

PROCESS AFTER INPUT.


MODULE USER_COMMAND_0200.

Define top declarations for program.

*&---------------------------------------------------------------------*
*& Include MYUSINGCHECKBOXTOP Module Pool SAPMYUSINGCHECKBOX
*&
*&---------------------------------------------------------------------*

PROGRAM SAPMYUSINGCHECKBOX.

TABLES: EKKO.

DATA: ITAB LIKE EKKO.

DATA: WA LIKE EKKO.

DATA: CUSTOMER, COMPANY, PURCHASE.

*&---------------------------------------------------------------------*
*& Module CHECK_INPUT INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE CHECK_INPUT INPUT.
SELECT SINGLE * FROM EKKO INTO CORRESPONDING FIELDS OF ITAB WHERE EBELN = EKKO-EBELN.

ENDMODULE. " CHECK_INPUT INPUT

*&---------------------------------------------------------------------*
*& Module TRANS_FROM_100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE TRANS_FROM_100 INPUT.

MOVE-CORRESPONDING ITAB TO WA.


ENDMODULE. " TRANS_FROM_100 INPUT

*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0200 INPUT

*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0200 INPUT.

CASE SY-UCOMM.

WHEN 'BACK'.
SET SCREEN 100.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'STOP'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE.
" USER_COMMAND_0200 INPUT

*&---------------------------------------------------------------------*
*& Include MYUSINGCHECKBOXO01
*&---------------------------------------------------------------------*

*&---------------------------------------------------------------------*
*& Module TRANS_TO_200 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE TRANS_TO_200 OUTPUT.
MOVE-CORRESPONDING WA TO EKKO.

ENDMODULE. " TRANS_TO_200 OUTPUT

*&---------------------------------------------------------------------*
*& Module CHECK_OUTPUT OUTPUT

*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE CHECK_OUTPUT OUTPUT.

LOOP AT SCREEN.
IF CUSTOMER IS INITIAL AND SCREEN-GROUP1 = 'COM'.
SCREEN-ACTIVE = 0.
MODIFY SCREEN.
ENDIF.

IF COMPANY IS INITIAL AND SCREEN-GROUP1 = 'CUS'.


SCREEN-ACTIVE = 0.
MODIFY SCREEN.
ENDIF.

IF PURCHASE IS INITIAL AND SCREEN-GROUP1 = 'PUR'.


SCREEN-ACTIVE = 0.
MODIFY SCREEN.
ENDIF.

ENDLOOP.

ENDMODULE. " CHECK_OUTPUT OUTPUT


*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'ZSAMPLEMENU'.
* SET TITLEBAR 'xxx'.

ENDMODULE. " STATUS_0100 OUTPUT

SAMPLE PROGRAM USING RADIOBUTTONS:

Go to SE80, right click on package name, create program.

Then activate all includes program and main program too.

Then right click on program name, create screen. Define attributes of screen.

Then design output screen.

Then define top declarations.


*&---------------------------------------------------------------------*
*& Include MYUSINGRADIOBUTTONTOP Module Pool SAPMYUSINGRADIOBUTTON
*&
*&---------------------------------------------------------------------*

PROGRAM SAPMYUSINGRADIOBUTTON.

TABLES: EKKO.

DATA: ITAB LIKE EKKO.

DATA: WA LIKE ITAB.

*DATA: BEGIN OF OPTIONS,


DATA: CUSTOMER TYPE C,
PURCHASE TYPE C,
EXIT TYPE C.
* END OF OPTIONS.

DATA: OK_CODE LIKE SY-UCOMM.

Then go to flow logic of screen 100.

PROCESS BEFORE OUTPUT.


* MODULE STATUS_0100.

*
PROCESS AFTER INPUT.
* MODULE USER_COMMAND_0100.

CHAIN.
FIELD: EKKO-BUKRS MODULE CHECK_INPUT.
ENDCHAIN.

MODULE TRANS_FROM_100.

MODULE CHECK_CODING.

Then go to flow logic of screen 200.

PROCESS BEFORE OUTPUT.


* MODULE STATUS_0200.

MODULE TRANS_TO_200.

MODULE CHECK_OUTPUT.

PROCESS AFTER INPUT.


* MODULE USER_COMMAND_0200.

Double click on MODULE CHECK_INPUT. Define coding.

*&---------------------------------------------------------------------*
*& Module CHECK_INPUT INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE CHECK_INPUT INPUT.

SELECT SINGLE * FROM EKKO INTO CORRESPONDING FIELDS OF ITAB WHERE BUKRS = EKKO-BUKRS.

ENDMODULE. " CHECK_INPUT INPUT

Then double-click on MODULE TRANS_FROM_100.

*&---------------------------------------------------------------------*
*& Module TRANS_FROM_100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE TRANS_FROM_100 INPUT.

MOVE-CORRESPONDING ITAB TO WA.

ENDMODULE. " TRANS_FROM_100 INPUT

Then double-click on MODULE TRANS_TO_200. Define coding.

*&---------------------------------------------------------------------*
*& Module TRANS_TO_200 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE TRANS_TO_200 OUTPUT.
MOVE-CORRESPONDING WA TO EKKO.
ENDMODULE. " TRANS_TO_200 OUTPUT

Double click on MODULE CHECK_OUTPUT.

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

*& Module CHECK_OUTPUT OUTPUT


*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE CHECK_OUTPUT OUTPUT.

CASE OK_CODE.

WHEN 'RADIO'.

*LOOP AT SCREEN.
*
*IF CUSTOMER EQ 'X' AND SCREEN-GROUP1 = 'CUS'.
*SELECT SINGLE * FROM EKKO WHERE BUKRS = EKKO-BUKRS.
*ENDIF.
*
*IF PURCHASE EQ 'X' AND SCREEN-GROUP1 = 'PUR'.
*SELECT SINGLE * FROM EKKO WHERE BUKRS = EKKO-BUKRS.
*ENDIF.
*
*IF EXIT EQ 'X'.
*LEAVE PROGRAM.
*ENDIF.

IF SCREEN-NAME = 'CUSTOMER' AND SCREEN-GROUP1 = 'CUS'.


SELECT SINGLE * FROM EKKO WHERE BUKRS = EKKO-BUKRS.
SCREEN-INPUT = 0.
SCREEN-ACTIVE = 0.
MODIFY SCREEN.
*ENDIF.

ELSEIF SCREEN-NAME = 'PURCHASE' AND SCREEN-GROUP1 = 'PUR'.


SELECT SINGLE * FROM EKKO WHERE BUKRS = EKKO-BUKRS.

SCREEN-INPUT = 1.
SCREEN-ACTIVE = 1.
MODIFY SCREEN.
*ENDIF.

ELSEIF EXIT EQ 'X'.


LEAVE PROGRAM.
ENDIF.

*ENDLOOP.
ENDCASE.
ENDMODULE. " CHECK_OUTPUT OUTPUT

Then define transaction code to execute the application.

SAMPLE PROGRAM USING TABSTRIP CONTROLS:

Go to SE80, right click on package name, create program.

Then activate all includes program and main program too.

Then right click on program name, create screen. Define attributes of screen.

Then design output screen. Select tabstrip wizard

Click on continue .give the name of tabstrip wizard customer details

Then click on continue. Provide text of each tab strip.


Like customer details, customer company, customer bank, customer sale.

Click on continue.

Click on continue.

Then click on continue.

Then click on finish.

Then design subscreens in each tabstrip, drag the fields from dictionary fields. Click on flow logic. It
generate auto code for tabstrip and subscreen screen.

Then click on flow logic for screen 100.

PROCESS BEFORE OUTPUT.


* MODULE STATUS_0100.

PROCESS AFTER INPUT.


* MODULE USER_COMMAND_0100.

FIELD: KNA1-KUNNR MODULE CHECK_INPUT.

MODULE TRANS_FROM_100.

Then click flow logic of screen 200.

This is an auto-generated code by SAP.

PROCESS BEFORE OUTPUT.


*&SPWIZARD: PBO FLOW LOGIC FOR TABSTRIP 'MYTABSTRIP'
MODULE MYTABSTRIP_ACTIVE_TAB_SET.
CALL SUBSCREEN MYTABSTRIP_SCA
INCLUDING G_MYTABSTRIP-PROG G_MYTABSTRIP-SUBSCREEN.
* MODULE STATUS_0200.
MODULE TRANS_TO_200. Defined by programmer

MODULE GET_DATA. Defined by programmer

PROCESS AFTER INPUT.


*&SPWIZARD: PAI FLOW LOGIC FOR TABSTRIP 'MYTABSTRIP'

CALL SUBSCREEN MYTABSTRIP_SCA.


MODULE MYTABSTRIP_ACTIVE_TAB_GET.
* MODULE USER_COMMAND_0200.
Then click flow logic of screen 201.

This is an auto-generated code by SAP.

PROCESS BEFORE OUTPUT.


* MODULE STATUS_0110.

MODULE TRANS_TO_200. Defined by programmer

MODULE GET_DATA. Defined by programmer

PROCESS AFTER INPUT.


* MODULE USER_COMMAND_0110.

Then click flow logic of screen 202.

This is an auto-generated code by SAP.

PROCESS BEFORE OUTPUT.


* MODULE STATUS_0110.

MODULE TRANS_TO_200. Defined by programmer

MODULE GET_DATA. Defined by programmer

PROCESS AFTER INPUT.


* MODULE USER_COMMAND_0110.

Then click flow logic of screen 203.

This is an auto-generated code by SAP.

PROCESS BEFORE OUTPUT.


* MODULE STATUS_0110.

MODULE TRANS_TO_200. Defined by programmer

MODULE GET_BANK. Defined by programmer

PROCESS AFTER INPUT.


* MODULE USER_COMMAND_0110.

Then click flow logic of screen 204.

This is an auto-generated code by SAP.

PROCESS BEFORE OUTPUT.


* MODULE STATUS_0110.

MODULE TRANS_TO_200.

Defined by programmer

MODULE GET_BANK. Defined by programmer

PROCESS AFTER INPUT.


MODULE USER_COMMAND_0110.

Define top declarations

*&---------------------------------------------------------------------*
*& Include MZDEMOTABSTRIPTOP Module Pool SAPMZDEMOTABSTRIP
*&
*&---------------------------------------------------------------------*

PROGRAM SAPMZDEMOTABSTRIP.

TABLES: KNA1, KNB1.

DATA: ITAB LIKE KNA1 OCCURS 0 WITH HEADER LINE,


ITAB2 LIKE KNB1 OCCURS 0 WITH HEADER LINE.

DATA: WA1 LIKE ITAB OCCURS 0 WITH HEADER LINE,


WA2 LIKE ITAB2 OCCURS 0 WITH HEADER LINE.

This is an auto-generated code by SAP.

*&SPWIZARD: FUNCTION CODES FOR TABSTRIP 'MYTABSTRIP'


CONSTANTS: BEGIN OF C_MYTABSTRIP,
TAB1 LIKE SY-UCOMM VALUE 'MYTABSTRIP_FC1',
TAB2 LIKE SY-UCOMM VALUE 'MYTABSTRIP_FC2',
TAB3 LIKE SY-UCOMM VALUE 'MYTABSTRIP_FC3',
TAB4 LIKE SY-UCOMM VALUE 'MYTABSTRIP_FC4',
END OF C_MYTABSTRIP.
*&SPWIZARD: DATA FOR TABSTRIP 'MYTABSTRIP'
CONTROLS: MYTABSTRIP TYPE TABSTRIP.
DATA: BEGIN OF G_MYTABSTRIP,
SUBSCREEN LIKE SY-DYNNR,
PROG LIKE SY-REPID VALUE 'SAPMZDEMOTABSTRIP',
PRESSED_TAB LIKE SY-UCOMM VALUE C_MYTABSTRIP-TAB1,
END OF G_MYTABSTRIP.

DATA: OK_CODE LIKE SY-UCOMM.

This an auto generated code in PBO of screen 200.

*&---------------------------------------------------------------------*
*& Include MZDEMOTABSTRIPO01
*&---------------------------------------------------------------------*

*&SPWIZARD: OUTPUT MODULE FOR TS 'MYTABSTRIP'. DO NOT CHANGE THIS LINE!


*&SPWIZARD: SETS ACTIVE TAB
MODULE MYTABSTRIP_ACTIVE_TAB_SET OUTPUT.
MYTABSTRIP-ACTIVETAB = G_MYTABSTRIP-PRESSED_TAB.
CASE G_MYTABSTRIP-PRESSED_TAB.
WHEN C_MYTABSTRIP-TAB1.
G_MYTABSTRIP-SUBSCREEN = '0201'.
WHEN C_MYTABSTRIP-TAB2.
G_MYTABSTRIP-SUBSCREEN = '0202'.
WHEN C_MYTABSTRIP-TAB3.
G_MYTABSTRIP-SUBSCREEN = '0203'.
WHEN C_MYTABSTRIP-TAB4.
G_MYTABSTRIP-SUBSCREEN = '0204'.
WHEN OTHERS.
*&SPWIZARD: DO NOTHING
ENDCASE
ENDMODULE.

This an auto generated code in PAI of screen 200.

*&---------------------------------------------------------------------*
*& Include MZDEMOTABSTRIPI01
*&---------------------------------------------------------------------*

*&SPWIZARD: INPUT MODULE FOR TS 'MYTABSTRIP'. DO NOT CHANGE THIS LINE!


*&SPWIZARD: GETS ACTIVE TAB
MODULE MYTABSTRIP_ACTIVE_TAB_GET INPUT.
OK_CODE = SY-UCOMM.
CASE OK_CODE.
WHEN C_MYTABSTRIP-TAB1.
G_MYTABSTRIP-PRESSED_TAB = C_MYTABSTRIP-TAB1.
WHEN C_MYTABSTRIP-TAB2.
G_MYTABSTRIP-PRESSED_TAB = C_MYTABSTRIP-TAB2.
WHEN C_MYTABSTRIP-TAB3.
G_MYTABSTRIP-PRESSED_TAB = C_MYTABSTRIP-TAB3.
WHEN C_MYTABSTRIP-TAB4.
G_MYTABSTRIP-PRESSED_TAB = C_MYTABSTRIP-TAB4.
WHEN OTHERS.
*&SPWIZARD: DO NOTHING
ENDCASE.
ENDMODULE.

Then double click on MODULE CHECK_INPUT of screen 100.


Define coding.

*&---------------------------------------------------------------------*
*& Module CHECK_INPUT INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE CHECK_INPUT INPUT.

SELECT SINGLE * FROM KNA1 INTO CORRESPONDING FIELDS OF ITAB WHERE KUNNR = KNA1-KUNNR.
ENDMODULE. " CHECK_INPUT INPUT

Then double click on MODULE TRANS_FROM_100.

*&---------------------------------------------------------------------*
*& Module TRANS_FROM_100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE TRANS_FROM_100 INPUT.

MOVE-CORRESPONDING ITAB TO WA1.


ENDMODULE. " TRANS_FROM_100 INPUT

Then double click on MODULE TRANS_TO_200.

*&---------------------------------------------------------------------*
*& Module TRANS_TO_200 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE TRANS_TO_200 OUTPUT.

MOVE-CORRESPONDING WA1 TO ITAB.

ENDMODULE. " TRANS_TO_200 OUTPUT

Then double-click on MODULE GET_DATA.

*&---------------------------------------------------------------------*
*& Module GET_DATA OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE GET_DATA OUTPUT.

SELECT SINGLE * FROM KNA1 WHERE KUNNR = KNA1-KUNNR.

ENDMODULE. " GET_DATA OUTPUT

Then double click on screen 203. define coding.

*&---------------------------------------------------------------------*
*& Module GET_BANK OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE GET_BANK OUTPUT.
SELECT SINGLE * FROM KNB1 WHERE KUNNR = KNA1-KUNNR.

ENDMODULE. " GET_BANK OUTPUT

Then define t-code for executing applications.

SAMPLE PROGRAM USING TABLE CONTROLS

Go to SE80, right click on package name, create program.

Then activate all includes program and main program too.

Then right click on program name, create screen. Define attributes of screen.

Then design other screen for output. Select table control wizard. Drag and paste it.

Click on continue
Then give name of table control.

Then click on continue. Provide from where u have to fetch data either from data dictionary r internal table

Click on continue. Then select fields from table

Click on continue. Then select table control should be output r input.

Then check scroll box.

Then it creates all include prog,click on continue

Then click on complete.

Then it generates coding in top declarations PBO, PAI modules.

Coding in top declarations.

*&---------------------------------------------------------------------*
*& Include MYTABLECONTROLTOP Module Pool SAPMYTABLECONTROL
*&
*&---------------------------------------------------------------------*

PROGRAM SAPMYTABLECONTROL.

***&SPWIZARD: DATA DECLARATION FOR TABLECONTROL 'MYTABLECONTROL'


*&SPWIZARD: DEFINITION OF DDIC-TABLE
TABLES: EKKO, ZPURCHASESTRU.

*&SPWIZARD: TYPE FOR THE DATA OF TABLECONTROL 'MYTABLECONTROL'


TYPES: BEGIN OF T_MYTABLECONTROL,
EBELN LIKE EKKO-EBELN,
BUKRS LIKE EKKO-BUKRS,
BSTYP LIKE EKKO-BSTYP,
BSART LIKE EKKO-BSART,
LIFNR LIKE EKKO-LIFNR,
SPRAS LIKE EKKO-SPRAS,
ZTERM LIKE EKKO-ZTERM,
EKORG LIKE EKKO-EKORG,
EKGRP LIKE EKKO-EKGRP,
WAERS LIKE EKKO-WAERS,
TELF1 LIKE EKKO-TELF1,
KUNNR LIKE EKKO-KUNNR,
END OF T_MYTABLECONTROL.

*&SPWIZARD: INTERNAL TABLE FOR TABLECONTROL 'MYTABLECONTROL'


DATA: G_MYTABLECONTROL_ITAB TYPE T_MYTABLECONTROL OCCURS 0,
G_MYTABLECONTROL_WA TYPE T_MYTABLECONTROL. "work area
DATA: G_MYTABLECONTROL_COPIED. "copy flag

*&SPWIZARD: DECLARATION OF TABLECONTROL 'MYTABLECONTROL' ITSELF


CONTROLS: MYTABLECONTROL TYPE TABLEVIEW USING SCREEN 0200.

DATA: ITAB LIKE EKKO OCCURS 0 WITH HEADER LINE.


* WA_EKKO LIKE TABLE OF ITAB.

Flow logic for screen 100.

PROCESS BEFORE OUTPUT.


MODULE STATUS_0100.

PROCESS AFTER INPUT.


MODULE USER_COMMAND_0100.

CHAIN.
FIELD: EKKO-EBELN MODULE CHECK_EKKO.
ENDCHAIN.

*MODULE TRANS_FROM_100.

Flow logic for 200.

PROCESS BEFORE OUTPUT.


*&SPWIZARD: PBO FLOW LOGIC FOR TABLECONTROL 'MYTABLECONTROL'
MODULE MYTABLECONTROL_INIT.
*&SPWIZARD: MODULE MYTABLECONTROL_CHANGE_TC_ATTR.
*&SPWIZARD: MODULE MYTABLECONTROL_CHANGE_COL_ATTR.
LOOP AT G_MYTABLECONTROL_ITAB
INTO G_MYTABLECONTROL_WA
WITH CONTROL MYTABLECONTROL
CURSOR MYTABLECONTROL-CURRENT_LINE.
*&SPWIZARD: MODULE MYTABLECONTROL_CHANGE_FIELD_ATTR

MODULE MYTABLECONTROL_MOVE.
ENDLOOP.

MODULE STATUS_0200.

MODULE GET_EKKO.

MODULE TRANS_TO_200.

PROCESS AFTER INPUT.


*&SPWIZARD: PAI FLOW LOGIC FOR TABLECONTROL 'MYTABLECONTROL'
LOOP AT G_MYTABLECONTROL_ITAB.
CHAIN.
FIELD EKKO-EBELN.
FIELD EKKO-BUKRS.
FIELD EKKO-BSTYP.
FIELD EKKO-BSART.
FIELD EKKO-LIFNR.
FIELD EKKO-SPRAS.
FIELD EKKO-ZTERM.
FIELD EKKO-EKORG.
FIELD EKKO-EKGRP.
FIELD EKKO-WAERS.
FIELD EKKO-TELF1.
FIELD EKKO-KUNNR.
ENDCHAIN.
ENDLOOP.
*&SPWIZARD: MODULE MYTABLECONTROL_CHANGE_TC_ATTR.
*&SPWIZARD: MODULE MYTABLECONTROL_CHANGE_COL_ATTR.

MODULE USER_COMMAND_0200.

Coding in pbo module


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

*& Include MYTABLECONTROLO01


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

*&SPWIZARD: OUTPUT MODULE FOR TC 'MYTABLECONTROL'. DO NOT CHANGE THIS LI


*&SPWIZARD: COPY DDIC-TABLE TO ITAB
MODULE MYTABLECONTROL_INIT OUTPUT.
IF G_MYTABLECONTROL_COPIED IS INITIAL.
*&SPWIZARD: COPY DDIC-TABLE 'EKKO'
*&SPWIZARD: INTO INTERNAL TABLE 'g_MYTABLECONTROL_itab'
SELECT * FROM EKKO
INTO CORRESPONDING FIELDS
OF TABLE G_MYTABLECONTROL_ITAB
WHERE EBELN = ITAB-EBELN.
G_MYTABLECONTROL_COPIED = 'X'.
REFRESH CONTROL 'MYTABLECONTROL' FROM SCREEN '0200'.
ENDIF.
ENDMODULE.

*&SPWIZARD: OUTPUT MODULE FOR TC 'MYTABLECONTROL'. DO NOT CHANGE THIS LI


*&SPWIZARD: MOVE ITAB TO DYNPRO
MODULE MYTABLECONTROL_MOVE OUTPUT.
MOVE-CORRESPONDING G_MYTABLECONTROL_WA TO EKKO.
ENDMODULE.

*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'ZSTATUS100'.
SET TITLEBAR 'ZTITLE100'.

ENDMODULE. " STATUS_0100 OUTPUT

*&---------------------------------------------------------------------*
*& Module STATUS_0200 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0200 OUTPUT.
SET PF-STATUS 'ZSTATUS200'.
SET TITLEBAR 'ZTITLE200'.

ENDMODULE. " STATUS_0200 OUTPUT

*&---------------------------------------------------------------------*
*& Module TRANS_TO_200 OUTPUT
*&---------------------------------------------------------------------*
* text
**----------------------------------------------------------------------*
MODULE TRANS_TO_200 OUTPUT.

MOVE-CORRESPONDING ITAB TO G_MYTABLECONTROL_WA.

ENDMODULE. " TRANS_TO_200 OUTPUT

*&---------------------------------------------------------------------*
*& Module GET_EKKO OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE GET_EKKO OUTPUT.

SELECT SINGLE * FROM EKKO


WHERE EBELN = EKKO-EBELN.

ENDMODULE. " GET_EKKO OUTPUT

Coding in pai module

*&---------------------------------------------------------------------*
*& Include MYTABLECONTROLI01
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0100 INPUT.

CASE SY-UCOMM.

WHEN 'BACK'.
SET SCREEN 0.

WHEN 'EXIT'.
LEAVE PROGRAM.

WHEN 'STOP'.
LEAVE TO SCREEN 0.

ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT

*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0200 INPUT
*&---------------------------------------------------------------------*

* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0200 INPUT.

CASE SY-UCOMM.

WHEN 'BACK'.
SET SCREEN 100.

WHEN 'EXIT'.
LEAVE PROGRAM.

WHEN 'STOP'.
LEAVE TO SCREEN 0.

ENDCASE.

ENDMODULE. " USER_COMMAND_0200 INPUT

*&---------------------------------------------------------------------*
*& Module CHECK_EKKO INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE CHECK_EKKO INPUT.

SELECT SINGLE * FROM EKKO INTO ITAB WHERE EBELN = EKKO-EBELN.

*SELECT SINGLE * FROM EKKO INTO G_MYTABLECONTROL_WA WHERE EBELN = EKKO-EBELN.

ENDMODULE. " CHECK_EKKO INPUT

*&---------------------------------------------------------------------*
*& Module TRANS_FROM_100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
*MODULE TRANS_FROM_100 INPUT.
*
*MOVE-CORRESPONDING ITAB TO G_MYTABLECONTROL_WA.
*
*ENDMODULE. " TRANS_FROM_100 INPUT

Then create t-codes for executing applications.