sap abap dialog programming

90
Working with Screen Painter SCREEN PAINTER:- Screen painter is a tool in ABAP dev workbench used to create the screens using the T-code SE51. In the screen painter, you can define the following interface elements with their associated attributes. 1. Input/Output Fields 2. Field Names 3. Checkboxes 4. Radio Buttons 5. Group Boxes 6. Sub screens. 7. Pushbuttons with No Fixed Position and others STEP-BY-STEP DEMO FOR SCREEN PAINTER. Create a Z program in SE38 . Click on Save. We will write the code later in this. Go to transaction SE51.

Upload: rajesh98765

Post on 04-Dec-2014

335 views

Category:

Documents


28 download

DESCRIPTION

done by david..hyd

TRANSCRIPT

Page 1: Sap Abap  Dialog Programming

Working with Screen Painter

SCREEN PAINTER:-

 Screen painter is a tool in ABAP dev workbench used to create the screens using the

T-code SE51. In the screen painter, you can define the following interface elements with their associated attributes.1. Input/Output Fields2. Field Names3. Checkboxes4. Radio Buttons5. Group Boxes6. Sub screens.7. Pushbuttons with No Fixed Position

and others 

STEP-BY-STEP DEMO FOR SCREEN PAINTER. 

Create a Z program in SE38. 

 

Click on Save. We will write the code later in this. 

Go to transaction SE51. 

Page 2: Sap Abap  Dialog Programming

 

Enter the created program name and screen number. 

 Enter the short description and click on save. 

 

Click on flowlogic tab. 

Page 3: Sap Abap  Dialog Programming

 

Uncomment the statement “ MODULE STATUS_0100 “. 

 

Double click the “ status_0100.”

The below screen will be displayed,

Click on yes.

Page 4: Sap Abap  Dialog Programming

 

Following pop-up screen appears. Select the “zdemo_screen_painter”  “main program” and click on continue.

Click on yes.

Page 5: Sap Abap  Dialog Programming

 

Screen would be displayed as follows: 

 

Now come back to the transaction SE51. Select flow logic. Click in layout. 

Page 6: Sap Abap  Dialog Programming

 

Screen painter window will be displayed like this. Here we will design the required screen fields.

Click on the middle icon   dictionary / program fields window. Or F6. 

 

Following screen appears: 

Page 7: Sap Abap  Dialog Programming

 Enter the table name in the table field name.

Click on get from dictionary. 

 

Select the required fields from MARA table from dictionary. Click on OK or continue. 

Page 8: Sap Abap  Dialog Programming

 

 

After placing the required fields, you can view the below screen. 

Page 9: Sap Abap  Dialog Programming

 

Create the push button from the toolbox. 

 

Select the pushbutton, drag and drop the button onto the screen. 

Page 10: Sap Abap  Dialog Programming

Create the other required buttons in the same procedure mentioned above and assign the name, text, and function code for each one. 

 

After creating the screen click on save check and activate. 

 press flow logic button.  . 

Page 11: Sap Abap  Dialog Programming

 

Click on tab Element List enter OK_CODE. 

 

Paste the below Code in created z program created earlier: 

*&-------------------------------------------------------------------**& Report ZDEMO_SCREEN_PAINTER*&*&-------------------------------------------------------------------**& Demo for Screen Painter.*& By Vikramchellappa.*&-------------------------------------------------------------------*REPORT ZDEMO_SCREEN_PAINTER.******************************************************************* TABLE DECLARATIONS.****************************************************************** TABLES: MARA.

Page 12: Sap Abap  Dialog Programming

******************************************************************* DATA DECLARATIONS.*****************************************************************DATA: MATNR TYPE MARA-MATNR, ERSDA TYPE MARA-ERSDA, ERNAM TYPE MARA-ERNAM, MTART TYPE MARA-MTART, MATKL TYPE MARA-MATKL, DISPLAY TYPE C, SAVE TYPE C, DELETE TYPE C, CLEAR TYPE C, EXIT TYPE C, OK_CODE LIKE SY-UCOMM.****************************************************************** CALLING SCREEN.*****************************************************************CALL SCREEN 100.*&--------------------------------------------------------------**& Module STATUS_0100 OUTPUT*&--------------------------------------------------------------** text*--------------------------------------------------------------*MODULE STATUS_0100 OUTPUT.* SET PF-STATUS 'ZMENU'.* SET TITLEBAR 'ZMENU_PAINTER'.

CASE SY-UCOMM. WHEN 'EXIT'. LEAVE PROGRAM. WHEN 'BACK'. LEAVE PROGRAM. WHEN 'DISPLAY'. SELECT SINGLE ERSDA ERNAM MTART MATKL FROM MARA INTO (MARA-ERSDA, MARA-ERNAM, MARA-MTART, MARA-MATKL) WHERE MATNR = MARA-MATNR. WHEN 'CLEAR'. CLEAR MARA. ENDCASE.ENDMODULE. " STATUS_0100 OUTPUT

Output:-

 Enter Material number On Material Field. Click on Display. 

 

Page 13: Sap Abap  Dialog Programming

Material Information is displayed as shown below: 

Create ABAP dialog screen dynpro Table Control within SAP.

capture line selection of a SAP dynpro table control and store which has been selected The SAP ABAP code below demonstrates how to implement row selection functionality to a dynpro table control so that the user is able to select / highlight a specific row and perform further processing based on this selection. 

Using the example of a basic table control as your starting point please implement the following ABAP code changes:

Step 1 - Declare ABAP variable to store line selection indicator. DATA: MARK TYPE C.

Step 2 - Assign created variable to dynpro table control.

Page 14: Sap Abap  Dialog Programming

Step 3 - Modify dialog screen Flow logic in-order to capture users line selection. PROCESS BEFORE OUTPUT.* MODULE STATUS_0100. module data_retrieval. loop at it_ekko into wa_ekko with control TC100. module populate_screen. endloop.*

PROCESS AFTER INPUT. loop at it_ekko. module update_table. endloop.* MODULE USER_COMMAND_0100.

To create module update_table please Double click on it and select yes to the next pop-up. Ensure that a new include is created

Page 15: Sap Abap  Dialog Programming

to hold all the PAI modules (default) and Press enter. 

Now insert the following ABAP code into this PAI module!

*&---------------------------------------------------------------------**& Module update_table INPUT*&---------------------------------------------------------------------** text*----------------------------------------------------------------------*module update_table input.

read table it_ekko into wa_ekko index tc100-CURRENT_LINE. if not mark is initial. wa_ekko-SEL = 'X'. modify it_ekko from wa_ekko index tc100-CURRENT_LINE. endif.

endmodule. " update_table INPUT

         Step 1 (Create new structure for table control)

Type is name of structure (ZTC_EKKO) and press create 

 

 Enter the fields that you want to display in the table control. Example uses fields from EKKO. Now save and activate it! 

Page 16: Sap Abap  Dialog Programming

        Step 2 (Create Program)Goto transaction SE80(Object Navigator) -> Repository Browser -> Program.Enter your program name, please ensure that is begins with SAPMZ…… as this is a module pool (dialog program).Press enter to create, and press yes! 

 Ensure that you create a top include, and press Enter.

  

Page 17: Sap Abap  Dialog Programming

Accept the name created for the top include.Press Enter.    

 

Press Save 

        Step 3 (Create TOP include)Double click on the top include and enter following ABAP code:

 Tables: ZTC_EKKO.controls: tc100 type tableview using screen 100.

 data: ok_code type sy-ucomm.data: it_ekko type standard

           table of ZTC_EKKO initial size 0,        wa_ekko type ZTC_EKKO. 

 

         Press Save and Activate

Page 18: Sap Abap  Dialog Programming

         Step 4 (Create screen)

Right click the program to create a screen 100 for the dialog. Enter Short description, set screen type to Normal and enter 0 or blank into Next screen. Then move to Element List tab and enter the OK code as OK_CODE (i.e. the same as what you declared in the top include with data: ok_code type sy-ucomm). 

 

 

 

        Step 5 (Create table control) 

Press the Layout button to bring up the screen painter editor.

Page 19: Sap Abap  Dialog Programming

  Press table control button and drag it on to the screen, enter the name of table control created in TOP include (TC100). Now press the yellow button for attributes and set the table control as below options

 

         Step 6 (Populate table control )

Press the orange button (Fields). On the next screen enter ZTC_EKKO and press the ‘Get from Dict’ button. Select the fields you want (all) and press enter. Now drag them onto your Table Control.

 

Page 20: Sap Abap  Dialog Programming

 Below is the result, there will been syntax errors if we check now! So Save and go back

into the flow logic tab. 

 

        Step 7 (Create flow control )Within the flow logic of screen 100 and create two modules, one to select the data from the database and the other to move the selected fields into the table control. Also insert the two loop statements to populate and retrieve the lines of the table control. 

PROCESS BEFORE OUTPUT.* MODULE STATUS_0100.  module data_retrieval.  loop at it_ekko into wa_ekko with control TC100.    module populate_screen.  endloop.*

Page 21: Sap Abap  Dialog Programming

PROCESS AFTER INPUT.  loop at it_ekko.  endloop.* MODULE USER_COMMAND_0100. 

Double click the module data_retrieval to create and click yes to get past the popup. Ensure that a new include is created to hold all the PBO modules (default). Press enter.

 Select 10 rows of data from the EKKO table and load into the internal table it_ekko. Go back to the flow logic to load this data into the Table Control.

*----------------------------------------------------------------------****INCLUDE MZ_TCONTROL_DATA_RETRIEVALO01 .*----------------------------------------------------------------------**&---------------------------------------------------------------------**&      Module  data_retrieval  OUTPUT*&---------------------------------------------------------------------**       text*----------------------------------------------------------------------*MODULE data_retrieval OUTPUT.* select data from ekko table  SELECT ebeln bukrs bstyp bsart         bsakz loekz statu aedat   UP TO 10 ROWS    FROM ekko    INTO CORRESPONDING FIELDS OF TABLE it_ekko.ENDMODULE.                 " data_retrieval  OUTPUT 

 Double click the module populate_screen to create. Now move the values in this loop from the wa_ekko into the Table Control with the move-corresponding statement.

MODULE populate_screen OUTPUT.    DATA: ld_line TYPE i. *   Set which line of table is a top of displayed table control    IF sy-stepl = 1.      tc100-lines =        tc100-top_line + sy-loopc - 1.    ENDIF. *   move fields from work area to scrren fields    MOVE-CORRESPONDING wa_ekko TO ztc_ekko.   ENDMODULE.                 " populate_screen  OUTPUT

Page 22: Sap Abap  Dialog Programming

 

        Step 8 (Create transaction )Now create a transaction to test the table control program. Right click the Program and select create-> transaction.

 

  

   

            

        Step 9 (Execute transaction )Execute transaction ZTC 

Page 23: Sap Abap  Dialog Programming

Demo on using Table Control*&---------------------------------------------------------------------**& Report Z_DB_TABLECONTROL **& **&---------------------------------------------------------------------**& **& **&---------------------------------------------------------------------*REPORT Z_DB_TABLECONTROL.TABLES: MARA.CONTROLS MATERIAL TYPE TABLEVIEW USING SCREEN 130.TYPES: BEGIN OF ST_MARA, MATNR TYPE MARA-MATNR, ERSDA TYPE MARA-ERSDA, ERNAM TYPE MARA-ERNAM, LAEDA TYPE MARA-LAEDA, END OF ST_MARA.DATA: IT_ST TYPE TABLE OF ST_MARA, WA_ST TYPE ST_MARA, IT_MARA TYPE MARA, WA_MARA TYPE MARA, OK_CODE LIKE SY-UCOMM.CALL SCREEN 130.*&---------------------------------------------------------------------**& Module V1 INPUT*&---------------------------------------------------------------------** text*----------------------------------------------------------------------*MODULE V1 INPUT.CASE OK_CODE.WHEN 'SAVE'.WA_ST-MATNR = MARA-MATNR.WA_ST-ERSDA = MARA-ERSDA.WA_ST-ERNAM = MARA-ERNAM.WA_ST-LAEDA = MARA-LAEDA.MOVE-CORRESPONDING WA_ST TO WA_MARA.INSERT INTO MARA VALUES WA_MARA.WHEN 'DELETE'.WA_ST-MATNR = MARA-MATNR.WA_ST-ERSDA = MARA-ERSDA.WA_ST-ERNAM = MARA-ERNAM.WA_ST-LAEDA = MARA-LAEDA.MOVE-CORRESPONDING WA_ST TO WA_MARA.DELETE MARA FROM WA_MARA.WHEN 'MODIFY'.WA_ST-MATNR = MARA-MATNR.WA_ST-ERSDA = MARA-ERSDA.WA_ST-ERNAM = MARA-ERNAM.WA_ST-LAEDA = MARA-LAEDA.MOVE-CORRESPONDING WA_ST TO WA_MARA.MODIFY MARA FROM WA_MARA.ENDCASE.ENDMODULE. " V1 INPUT*&---------------------------------------------------------------------*

Page 24: Sap Abap  Dialog Programming

*& Module EXIT INPUT*&---------------------------------------------------------------------** text*----------------------------------------------------------------------*MODULE EXIT INPUT.IF OK_CODE = 'EXIT'.LEAVE PROGRAM.ENDIF.ENDMODULE. " EXIT INPUTCreate a screen by number 130 and provide the following attributes:

 

LAYOUT:

 

ELEMENT LIST:

Page 25: Sap Abap  Dialog Programming

 

FLOW LOGIC.

 

EXECUTE: 

Page 26: Sap Abap  Dialog Programming

 Working with Check box (Module pool programming)

Scenario: We would design a screen with an input field for customer number and three check boxes for Name, City and Address. Upon entering the customer number and selecting any of the check boxes, the corresponding data should be displayed

1) Go to Tcode SE38 . 

 

Click on create and save the program. We would write the code later. 

2) Go to Tcode SE51

 

Page 27: Sap Abap  Dialog Programming

 

 

In the Layout:

Drag and drop the fields as shown below. (The properties of each field can be seen on the right hand side of the screenshot) 

 

Page 28: Sap Abap  Dialog Programming

Customer Number:

 

Input field:

 

Check box: Name

Page 29: Sap Abap  Dialog Programming

 

Check box: CITY

 

Check box: Address

Page 30: Sap Abap  Dialog Programming

Push button: Display

 

Push button: Cancel

Page 31: Sap Abap  Dialog Programming

3) Go to SE38.

 

Enter the following code:

*&---------------------------------------------------------------------**& Report  ZSCREEN_NEXTSCREEN                                          **&                                                                     **&---------------------------------------------------------------------**&                                                                     **&                                                                     **&---------------------------------------------------------------------*

REPORT  ZSCREEN_NEXTSCREEN .DATA : KUNNR TYPE KUNNR,       NAME TYPE C,       CITY TYPE C,       ADDRESS TYPE C,       OK_CODE LIKE SY-UCOMM.

DATA : NAME1 TYPE NAME1,       ORT01 TYPE ORT01,

Page 32: Sap Abap  Dialog Programming

       ADRNR TYPE ADRNR.DATA : W_NAME1 TYPE NAME1,       W_ORT01 TYPE ORT01,       W_ADRNR TYPE ADRNR.

CALL SCREEN 100.

*&---------------------------------------------------------------------**&      Module  CHECK_VALUES  INPUT*&---------------------------------------------------------------------**       text*----------------------------------------------------------------------*MODULE CHECK_VALUES INPUT.  IF OK_CODE EQ 'DISPLAY'.  LEAVE TO LIST-PROCESSING.SELECT SINGLE NAME1 ORT01 ADRNR  FROM KNA1 INTO (W_NAME1, W_ORT01, W_ADRNR)  WHERE KUNNR = KUNNR.      IF NAME EQ 'X'.      WRITE : W_NAME1.      NAME1 = W_NAME1.      ENDIF.      IF CITY EQ 'X'.      WRITE : W_ORT01.      ORT01 =  W_ORT01.      ENDIF.      IF ADDRESS EQ 'X'.     ADRNR = W_ADRNR.     WRITE : W_ADRNR.      ENDIF.    ELSEIF OK_CODE EQ 'CANCEL' OR OK_CODE EQ 'BACK'.      LEAVE PROGRAM.      ENDIF.  ENDMODULE.                 " CHECK_VALUES  INPUT            " PBO  OUTPUT

Execute the program 

 

Page 33: Sap Abap  Dialog Programming

 

Display images on the screen

Step 1: Upload picture into SAP using the transaction SE78. Test picture. 

 

Page 34: Sap Abap  Dialog Programming

Step 2: Create a custom screen section in the screen.

 

Step 3: In the PBO module of the screen, attach the following code. Please note that the object name is ‘winny’, please pass your own object name to the method:*&---------------------------------------------------------------------**& Module STATUS_9000 OUTPUT*&---------------------------------------------------------------------** text*----------------------------------------------------------------------*MODULE STATUS_9000 OUTPUT. DATA: W_LINES TYPE I. TYPES PICT_LINE(256) TYPE C. DATA : CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER, EDITOR TYPE REF TO CL_GUI_TEXTEDIT, PICTURE TYPE REF TO CL_GUI_PICTURE, PICT_TAB TYPE TABLE OF PICT_LINE, URL(255) TYPE C. DATA: GRAPHIC_URL(255). DATA: BEGIN OF GRAPHIC_TABLE OCCURS 0, LINE(255) TYPE X, END OF GRAPHIC_TABLE. DATA: L_GRAPHIC_CONV TYPE I. DATA: L_GRAPHIC_OFFS TYPE I. DATA: GRAPHIC_SIZE TYPE I. DATA: L_GRAPHIC_XSTR TYPE XSTRING. . CALL METHOD CL_GUI_CFW=>FLUSH. CREATE OBJECT: CONTAINER EXPORTING CONTAINER_NAME = 'PICTURE_CONTAINER', PICTURE EXPORTING PARENT = CONTAINER.

Page 35: Sap Abap  Dialog Programming

CALL METHOD CL_SSF_XSF_UTILITIES=>GET_BDS_GRAPHIC_AS_BMP EXPORTING P_OBJECT = 'GRAPHICS' P_NAME = 'WINNY' P_ID = 'BMAP' P_BTYPE = 'BCOL' RECEIVING P_BMP = L_GRAPHIC_XSTR* EXCEPTIONS* NOT_FOUND = 1* INTERNAL_ERROR = 2* others = 3 . IF SY-SUBRC <> 0.* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. GRAPHIC_SIZE = XSTRLEN( L_GRAPHIC_XSTR ). L_GRAPHIC_CONV = GRAPHIC_SIZE. L_GRAPHIC_OFFS = 0. WHILE L_GRAPHIC_CONV > 255. GRAPHIC_TABLE-LINE = L_GRAPHIC_XSTR+L_GRAPHIC_OFFS(255). APPEND GRAPHIC_TABLE. L_GRAPHIC_OFFS = L_GRAPHIC_OFFS + 255. L_GRAPHIC_CONV = L_GRAPHIC_CONV - 255. ENDWHILE. GRAPHIC_TABLE-LINE = L_GRAPHIC_XSTR+L_GRAPHIC_OFFS(L_GRAPHIC_CONV). APPEND GRAPHIC_TABLE. CALL FUNCTION 'DP_CREATE_URL' EXPORTING TYPE = 'IMAGE' SUBTYPE = 'X-UNKNOWN' SIZE = GRAPHIC_SIZE LIFETIME = 'T' TABLES DATA = GRAPHIC_TABLE CHANGING URL = URL. CALL METHOD PICTURE->LOAD_PICTURE_FROM_URL EXPORTING URL = URL. CALL METHOD PICTURE->SET_DISPLAY_MODE EXPORTING DISPLAY_MODE = PICTURE->DISPLAY_MODE_FIT_CENTER.ENDMODULE. " STATUS_9000 OUTPUT

Output: 

 

Page 36: Sap Abap  Dialog Programming

Dynamically editable cells in a table control

This document tells us how to make a specific cell as dynamically editable in a table control.

Create a screen and table control using wizard.

Drag the table control wizard option from the options and draw on the screen…

Page 37: Sap Abap  Dialog Programming

Wizard will start to create a table control.

Page 38: Sap Abap  Dialog Programming

Specify the table control name “TC_2000”. And press continue..

Page 39: Sap Abap  Dialog Programming

Select the table & work area from the program. And press continues…

Page 40: Sap Abap  Dialog Programming

Select the fields to display in table control and press continue..

Page 41: Sap Abap  Dialog Programming

Select Input control radio button, check with column headers, line selection column field “SEL” (field declared in table control internal table.)

Page 42: Sap Abap  Dialog Programming
Page 43: Sap Abap  Dialog Programming
Page 44: Sap Abap  Dialog Programming
Page 45: Sap Abap  Dialog Programming

 

Page 46: Sap Abap  Dialog Programming

PROCESS BEFORE OUTPUT.*&SPWIZARD: PBO FLOW LOGIC FOR TABLECONTROL 'TC_2000'  MODULE TC_2000_CHANGE_TC_ATTR.*&SPWIZARD: MODULE TC_2000_CHANGE_COL_ATTR.   LOOP  AT   IT_EMP_DETAILS       INTO WA_EMP_DETAILS       WITH CONTROL TC_2000       CURSOR TC_2000-CURRENT_LINE.    MODULE TC_2000_GET_LINES.*&SPWIZARD:   MODULE TC_2000_CHANGE_FIELD_ATTR  ENDLOOP.

 MODULE STATUS_2000.*PROCESS AFTER INPUT.*&SPWIZARD: PAI FLOW LOGIC FOR TABLECONTROL 'TC_2000'  LOOP AT IT_EMP_DETAILS.    CHAIN.      FIELD WA_EMP_DETAILS-PERNR.      FIELD WA_EMP_DETAILS-GENDER.      FIELD WA_EMP_DETAILS-INPUT.      MODULE TC_2000_MODIFY ON CHAIN-REQUEST.    endchain.    FIELD WA_EMP_DETAILS-SEL      MODULE TC_2000_MARK ON REQUEST.  ENDLOOP.  MODULE TC_2000_USER_COMMAND.*&SPWIZARD: MODULE TC_2000_CHANGE_TC_ATTR.*&SPWIZARD: MODULE TC_2000_CHANGE_COL_ATTR.

Page 47: Sap Abap  Dialog Programming

 MODULE USER_COMMAND_2000.

  IF IT_EMP_DETAILS IS INITIAL.    APPEND WA_EMP_DETAILS TO IT_EMP_DETAILS.  ENDIF.

Page 48: Sap Abap  Dialog Programming

LOOP AT SCREEN. IF SCREEN-NAME = 'WA_EMP_DETAILS-INPUT'. IF WA_EMP_DETAILS-GENDER NE '1'. SCREEN-INPUT = '1'. ELSE. SCREEN-INPUT = '0'. ENDIF. MODIFY SCREEN. ENDIF. ENDLOOP.*All the code related to Table control will automatically by wizard option.*&---------------------------------------------------------------------**& Report ZDYN_EDITABLE_TABLE_CONTROL

Page 49: Sap Abap  Dialog Programming

*&*&---------------------------------------------------------------------**&*&*&---------------------------------------------------------------------*REPORT ZDYN_EDITABLE_TABLE_CONTROL.TYPES : BEGIN OF TY_EMP_DETAILS, PERNR TYPE PA0001-PERNR , GENDER TYPE GESCH, INPUT TYPE CHAR10, SEL TYPE CHAR1, END OF TY_EMP_DETAILS.DATA : IT_EMP_DETAILS TYPE TABLE OF TY_EMP_DETAILS, WA_EMP_DETAILS TYPE TY_EMP_DETAILS.

*&SPWIZARD: DECLARATION OF TABLECONTROL 'TC_2000' ITSELFCONTROLS: TC_2000 TYPE TABLEVIEW USING SCREEN 2000.*&SPWIZARD: LINES OF TABLECONTROL 'TC_2000'DATA: G_TC_2000_LINES LIKE SY-LOOPC.DATA: OK_CODE LIKE SY-UCOMM.START-OF-SELECTION. CALL SCREEN 2000.*&SPWIZARD: OUTPUT MODULE FOR TC 'TC_2000'. DO NOT CHANGE THIS LINE!*&SPWIZARD: UPDATE LINES FOR EQUIVALENT SCROLLBARMODULE TC_2000_CHANGE_TC_ATTR OUTPUT. IF IT_EMP_DETAILS IS INITIAL. APPEND WA_EMP_DETAILS TO IT_EMP_DETAILS. ENDIF. DESCRIBE TABLE IT_EMP_DETAILS LINES TC_2000-LINES.ENDMODULE. "TC_2000_CHANGE_TC_ATTR OUTPUT*&SPWIZARD: OUTPUT MODULE FOR TC 'TC_2000'. DO NOT CHANGE THIS LINE!*&SPWIZARD: GET LINES OF TABLECONTROLMODULE TC_2000_GET_LINES OUTPUT. G_TC_2000_LINES = SY-LOOPC. LOOP AT SCREEN. IF SCREEN-NAME = 'WA_EMP_DETAILS-INPUT'. IF WA_EMP_DETAILS-GENDER NE '1'. SCREEN-INPUT = '1'. ELSE. SCREEN-INPUT = '0'. ENDIF. MODIFY SCREEN. ENDIF. ENDLOOP.ENDMODULE. "TC_2000_GET_LINES OUTPUT*&SPWIZARD: INPUT MODULE FOR TC 'TC_2000'. DO NOT CHANGE THIS LINE!*&SPWIZARD: MODIFY TABLEMODULE TC_2000_MODIFY INPUT. MODIFY IT_EMP_DETAILS FROM WA_EMP_DETAILS INDEX TC_2000-CURRENT_LINE.ENDMODULE. "TC_2000_MODIFY INPUT*&SPWIZARD: INPUT MODUL FOR TC 'TC_2000'. DO NOT CHANGE THIS LINE!*&SPWIZARD: MARK TABLEMODULE TC_2000_MARK INPUT. DATA: G_TC_2000_WA2 LIKE LINE OF IT_EMP_DETAILS. IF TC_2000-LINE_SEL_MODE = 1 AND WA_EMP_DETAILS-SEL = 'X'. LOOP AT IT_EMP_DETAILS INTO G_TC_2000_WA2 WHERE SEL = 'X'. G_TC_2000_WA2-SEL = ''.

Page 50: Sap Abap  Dialog Programming

MODIFY IT_EMP_DETAILS FROM G_TC_2000_WA2 TRANSPORTING SEL. ENDLOOP. ENDIF. MODIFY IT_EMP_DETAILS FROM WA_EMP_DETAILS INDEX TC_2000-CURRENT_LINE TRANSPORTING SEL.ENDMODULE. "TC_2000_MARK INPUT*&SPWIZARD: INPUT MODULE FOR TC 'TC_2000'. DO NOT CHANGE THIS LINE!*&SPWIZARD: PROCESS USER COMMANDMODULE TC_2000_USER_COMMAND INPUT. OK_CODE = SY-UCOMM. PERFORM USER_OK_TC USING 'TC_2000' 'IT_EMP_DETAILS' 'SEL' CHANGING OK_CODE. SY-UCOMM = OK_CODE.ENDMODULE. "TC_2000_USER_COMMAND INPUT*----------------------------------------------------------------------** INCLUDE TABLECONTROL_FORMS **----------------------------------------------------------------------**&---------------------------------------------------------------------**& Form USER_OK_TC **&---------------------------------------------------------------------*FORM USER_OK_TC USING P_TC_NAME TYPE DYNFNAM P_TABLE_NAME P_MARK_NAME CHANGING P_OK LIKE SY-UCOMM.*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------* DATA: L_OK TYPE SY-UCOMM, L_OFFSET TYPE I.*&SPWIZARD: END OF LOCAL DATA------------------------------------------**&SPWIZARD: Table control specific operations **&SPWIZARD: evaluate TC name and operations * SEARCH P_OK FOR P_TC_NAME. IF SY-SUBRC <> 0. EXIT. ENDIF. L_OFFSET = STRLEN( P_TC_NAME ) + 1. L_OK = P_OK+L_OFFSET.*&SPWIZARD: execute general and TC specific operations * CASE L_OK. WHEN 'INSR'. "insert row PERFORM FCODE_INSERT_ROW USING P_TC_NAME P_TABLE_NAME. CLEAR P_OK. WHEN 'DELE'. "delete row PERFORM FCODE_DELETE_ROW USING P_TC_NAME P_TABLE_NAME P_MARK_NAME. CLEAR P_OK. WHEN 'P--' OR "top of list 'P-' OR "previous page 'P+' OR "next page 'P++'. "bottom of list PERFORM COMPUTE_SCROLLING_IN_TC USING P_TC_NAME L_OK. CLEAR P_OK. WHEN 'MARK'. "mark all filled lines

Page 51: Sap Abap  Dialog Programming

PERFORM FCODE_TC_MARK_LINES USING P_TC_NAME P_TABLE_NAME P_MARK_NAME . CLEAR P_OK. WHEN 'DMRK'. "demark all filled lines PERFORM FCODE_TC_DEMARK_LINES USING P_TC_NAME P_TABLE_NAME P_MARK_NAME . CLEAR P_OK. ENDCASE.ENDFORM. " USER_OK_TC*&---------------------------------------------------------------------**& Form FCODE_INSERT_ROW **&---------------------------------------------------------------------*FORM FCODE_INSERT_ROW USING P_TC_NAME TYPE DYNFNAM P_TABLE_NAME .*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------* DATA L_LINES_NAME LIKE FELD-NAME. DATA L_SELLINE LIKE SY-STEPL. DATA L_LASTLINE TYPE I. DATA L_LINE TYPE I. DATA L_TABLE_NAME LIKE FELD-NAME. FIELD-SYMBOLS <TC> TYPE CXTAB_CONTROL. FIELD-SYMBOLS <TABLE> TYPE STANDARD TABLE. FIELD-SYMBOLS <LINES> TYPE I.*&SPWIZARD: END OF LOCAL DATA------------------------------------------* ASSIGN (P_TC_NAME) TO <TC>.*&SPWIZARD: get the table, which belongs to the tc * CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body ASSIGN (L_TABLE_NAME) TO <TABLE>. "not headerline*&SPWIZARD: get looplines of TableControl * CONCATENATE 'G_' P_TC_NAME '_LINES' INTO L_LINES_NAME. ASSIGN (L_LINES_NAME) TO <LINES>.*&SPWIZARD: get current line * GET CURSOR LINE L_SELLINE. IF SY-SUBRC <> 0. " append line to table L_SELLINE = <TC>-LINES + 1.*&SPWIZARD: set top line * IF L_SELLINE > <LINES>. <TC>-TOP_LINE = L_SELLINE - <LINES> + 1 . ELSE. <TC>-TOP_LINE = 1. ENDIF. ELSE. " insert line into table L_SELLINE = <TC>-TOP_LINE + L_SELLINE - 1. L_LASTLINE = <TC>-TOP_LINE + <LINES> - 1. ENDIF.*&SPWIZARD: set new cursor line * L_LINE = L_SELLINE - <TC>-TOP_LINE + 1.*&SPWIZARD: insert initial line * INSERT INITIAL LINE INTO <TABLE> INDEX L_SELLINE. <TC>-LINES = <TC>-LINES + 1.*&SPWIZARD: set cursor * SET CURSOR LINE L_LINE.ENDFORM. " FCODE_INSERT_ROW*&---------------------------------------------------------------------**& Form FCODE_DELETE_ROW **&---------------------------------------------------------------------*FORM FCODE_DELETE_ROW USING P_TC_NAME TYPE DYNFNAM

Page 52: Sap Abap  Dialog Programming

P_TABLE_NAME P_MARK_NAME .*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------* DATA L_TABLE_NAME LIKE FELD-NAME. FIELD-SYMBOLS <TC> TYPE CXTAB_CONTROL. FIELD-SYMBOLS <TABLE> TYPE STANDARD TABLE. FIELD-SYMBOLS <WA>. FIELD-SYMBOLS <MARK_FIELD>.*&SPWIZARD: END OF LOCAL DATA------------------------------------------* ASSIGN (P_TC_NAME) TO <TC>.*&SPWIZARD: get the table, which belongs to the tc * CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body ASSIGN (L_TABLE_NAME) TO <TABLE>. "not headerline*&SPWIZARD: delete marked lines * DESCRIBE TABLE <TABLE> LINES <TC>-LINES. LOOP AT <TABLE> ASSIGNING <WA>.*&SPWIZARD: access to the component 'FLAG' of the table header * ASSIGN COMPONENT P_MARK_NAME OF STRUCTURE <WA> TO <MARK_FIELD>. IF <MARK_FIELD> = 'X'. DELETE <TABLE> INDEX SYST-TABIX. IF SY-SUBRC = 0. <TC>-LINES = <TC>-LINES - 1. ENDIF. ENDIF. ENDLOOP.ENDFORM. " FCODE_DELETE_ROW*&---------------------------------------------------------------------**& Form COMPUTE_SCROLLING_IN_TC*&---------------------------------------------------------------------** text*----------------------------------------------------------------------** -->P_TC_NAME name of tablecontrol* -->P_OK ok code*----------------------------------------------------------------------*FORM COMPUTE_SCROLLING_IN_TC USING P_TC_NAME P_OK.*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------* DATA L_TC_NEW_TOP_LINE TYPE I. DATA L_TC_NAME LIKE FELD-NAME. DATA L_TC_LINES_NAME LIKE FELD-NAME. DATA L_TC_FIELD_NAME LIKE FELD-NAME. FIELD-SYMBOLS <TC> TYPE CXTAB_CONTROL. FIELD-SYMBOLS <LINES> TYPE I.*&SPWIZARD: END OF LOCAL DATA------------------------------------------* ASSIGN (P_TC_NAME) TO <TC>.*&SPWIZARD: get looplines of TableControl * CONCATENATE 'G_' P_TC_NAME '_LINES' INTO L_TC_LINES_NAME. ASSIGN (L_TC_LINES_NAME) TO <LINES>.*&SPWIZARD: is no line filled? * IF <TC>-LINES = 0.*&SPWIZARD: yes, ... * L_TC_NEW_TOP_LINE = 1. ELSE.*&SPWIZARD: no, ... * CALL FUNCTION 'SCROLLING_IN_TABLE' EXPORTING ENTRY_ACT = <TC>-TOP_LINE ENTRY_FROM = 1 ENTRY_TO = <TC>-LINES LAST_PAGE_FULL = 'X' LOOPS = <LINES>

Page 53: Sap Abap  Dialog Programming

OK_CODE = P_OK OVERLAPPING = 'X' IMPORTING ENTRY_NEW = L_TC_NEW_TOP_LINE EXCEPTIONS* NO_ENTRY_OR_PAGE_ACT = 01* NO_ENTRY_TO = 02* NO_OK_CODE_OR_PAGE_GO = 03 OTHERS = 0. ENDIF.*&SPWIZARD: get actual tc and column * GET CURSOR FIELD L_TC_FIELD_NAME AREA L_TC_NAME. IF SYST-SUBRC = 0. IF L_TC_NAME = P_TC_NAME.*&SPWIZARD: et actual column * SET CURSOR FIELD L_TC_FIELD_NAME LINE 1. ENDIF. ENDIF.*&SPWIZARD: set the new top line * <TC>-TOP_LINE = L_TC_NEW_TOP_LINE.ENDFORM. " COMPUTE_SCROLLING_IN_TC*&---------------------------------------------------------------------**& Form FCODE_TC_MARK_LINES*&---------------------------------------------------------------------** marks all TableControl lines*----------------------------------------------------------------------** -->P_TC_NAME name of tablecontrol*----------------------------------------------------------------------*FORM FCODE_TC_MARK_LINES USING P_TC_NAME P_TABLE_NAME P_MARK_NAME.*&SPWIZARD: EGIN OF LOCAL DATA-----------------------------------------* DATA L_TABLE_NAME LIKE FELD-NAME. FIELD-SYMBOLS <TC> TYPE CXTAB_CONTROL. FIELD-SYMBOLS <TABLE> TYPE STANDARD TABLE. FIELD-SYMBOLS <WA>. FIELD-SYMBOLS <MARK_FIELD>.*&SPWIZARD: END OF LOCAL DATA------------------------------------------* ASSIGN (P_TC_NAME) TO <TC>.*&SPWIZARD: get the table, which belongs to the tc * CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body ASSIGN (L_TABLE_NAME) TO <TABLE>. "not headerline*&SPWIZARD: mark all filled lines * LOOP AT <TABLE> ASSIGNING <WA>.*&SPWIZARD: access to the component 'FLAG' of the table header * ASSIGN COMPONENT P_MARK_NAME OF STRUCTURE <WA> TO <MARK_FIELD>. <MARK_FIELD> = 'X'. ENDLOOP.ENDFORM. "fcode_tc_mark_lines*&---------------------------------------------------------------------**& Form FCODE_TC_DEMARK_LINES*&---------------------------------------------------------------------** demarks all TableControl lines*----------------------------------------------------------------------** -->P_TC_NAME name of tablecontrol*----------------------------------------------------------------------*FORM FCODE_TC_DEMARK_LINES USING P_TC_NAME P_TABLE_NAME P_MARK_NAME .*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------*

Page 54: Sap Abap  Dialog Programming

DATA L_TABLE_NAME LIKE FELD-NAME. FIELD-SYMBOLS <TC> TYPE CXTAB_CONTROL. FIELD-SYMBOLS <TABLE> TYPE STANDARD TABLE. FIELD-SYMBOLS <WA>. FIELD-SYMBOLS <MARK_FIELD>.*&SPWIZARD: END OF LOCAL DATA------------------------------------------* ASSIGN (P_TC_NAME) TO <TC>.*&SPWIZARD: get the table, which belongs to the tc * CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body ASSIGN (L_TABLE_NAME) TO <TABLE>. "not headerline*&SPWIZARD: demark all filled lines * LOOP AT <TABLE> ASSIGNING <WA>.*&SPWIZARD: access to the component 'FLAG' of the table header * ASSIGN COMPONENT P_MARK_NAME OF STRUCTURE <WA> TO <MARK_FIELD>. <MARK_FIELD> = SPACE. ENDLOOP.ENDFORM. "fcode_tc_mark_lines*&---------------------------------------------------------------------**& Module STATUS_2000 OUTPUT*&---------------------------------------------------------------------** text*----------------------------------------------------------------------*MODULE STATUS_2000 OUTPUT. SET PF-STATUS 'STATUS_2000'.

*  SET TITLEBAR 'xxx'.

ENDMODULE.                 " STATUS_2000  OUTPUT*&---------------------------------------------------------------------**&      Module  USER_COMMAND_2000  INPUT*&---------------------------------------------------------------------**       text*----------------------------------------------------------------------*MODULE USER_COMMAND_2000 INPUT.  CASE OK_CODE.    WHEN 'BACK'.      SET SCREEN 0.

Page 55: Sap Abap  Dialog Programming

    WHEN OTHERS.  ENDCASE.

ENDMODULE.                 " USER_COMMAND_2000  INPUT  

Output : Here the condition which I specify is on selecting Female as gender INPUT field of the  respective row will become enable for input and on selecting of Male as gender INPUT field of the respective row will become disable for input.  

Step-loops in Module Pool Programming

Step-loops in Module Pool Programming

Step-loops are actually the predecessors to Table Control concepts and from programming point of view they are quite similar. Step loops are objects for screen table display that are added to a screen in the Screen Painter. They are preferred in cases of Radio-frequency applications where ALV displays or table controls pose a hindrance with respect to small displays and navigational issues.

1. Introduction to Step Loops

Page 56: Sap Abap  Dialog Programming

This article throws light on the concept of Step-loops in Module screen programming. Step-loops are a very old concept and their use has been drastically reduced after the onset of Table control. But in certain applications such as Radio Frequency there is no other alternative than using step-loops.

The pre-requisite to understanding and design of step-loops is to have a fair idea over module pool programming.

Step-loops are of 2 types:

Fixed Step-loopsIncase of Fixed step-loops, the number of lines of records would be fixed as when designed. You can increase the number of records at runtime. Although the number of records can be decreased as per programming logic if number of records in table to be displayed are less than fixed number.

 Variable Step-loopsIn case of variable step-loops, at runtime we can increase the number of repetitive blocks depending on the size of the screen.

2. Requirement to be designed

We will look into a requirement where we have display records in a step-loop on screen in such a manner that we will keep the step-loop fixed to 5 rows for simplicity and based on the number of records; the records will flow onto the next screens.

Also if there are only 2 records to be displayed then only 2 rows will appear on the screen with no buttons for navigation. So the navigation buttons “Page Up” and “Page Down” would be handling dynamically based on the records to be displayed.

3. How to design Step-loops?

A step loop is defined in the screen painter transaction SE51; these are unlike the table control elements which can be spread over multiple lines and can be combined into one group which would be repeated within the step loop. It is important to note that whichever attributes we assign to the first group are replicated to the entire step loop.

In the screen painter, we can define whether the size of a step loop is fixed or variable. The vertical size of variable step loops changes if the user changes the vertical size of the window. For every screen, any number of fixed step loops can be defined but only one variable step loop. Every vertical size change triggers PAI if a variable step loop is defined on the screen. For fixed step loops the number of repetition groups has to be predefined.

To place step-loops in the module pool screen, we need to place input/output fields for the number of columns required and text-fields for the number of column headers. As described, we would first place the input-output fields and text-fields as per the number of columns to be displayed as shown below:

Page 57: Sap Abap  Dialog Programming

Later in order to convert these into step-loops, select the input/output fields together for all required columns and follow the steps as shown below in the screenshot with the menu path as Edit -> Grouping -> Step Loop -> Define.

Page 58: Sap Abap  Dialog Programming

In the below screenshot, Column1 and Column2 denote the column headers, Page up and Down are the buttons which would help us in scrolling the records. In this case we have kept step-loop as fixed up to 5 rows for simplicity. The column1 and column 2 are simple text fields.

Page 59: Sap Abap  Dialog Programming

On double Clicking you will find the following step-loop property where Height is restricted to 5 rows. See below screenshot.

Page 60: Sap Abap  Dialog Programming

The step-loop column field properties would be as below:

Page 61: Sap Abap  Dialog Programming

 

The buttons Page up and Page down would be given function codes as “PGUP “and “PGDN” and their properties would be as follows:

Page 62: Sap Abap  Dialog Programming

  

Page 63: Sap Abap  Dialog Programming

4. Flow-logic for Step-loops

Once the processing for the records to be displayed is done, then in the flow logic of the screen 0100 which we have designed we need to include the code shown below:

It’s important to note that the LOOP must exist for every step loop, both in the PBO and the PAI processing block. During the loops, the contents of the step loop are transported back and forth between identically-named fields of the ABAP program and the screen. Note that step loop fields defined with Dictionary reference must be defined in the ABAP program, as before, with TABLES as interface work areas. The order the step loops are processed in the individual loops of the flow logic depends on the step loop order on the screen. The order on the screen depends primarily on the lines and secondarily on the rows. The system fields SY-STPL and SY-LOOPC are also filled within the loops.

In the PBO module we have looped the cursor C from N1 to N2 since we want to display on screen only as many as rows as many number of records are there to be present on the screen. Thus if there are only 2 records then N1 = 1 and N2 =2; so that 2 step loops appear on the screen. This would ensure dynamicity of the step-loops.

The table structure for the records to be displayed in step-loops would be as follows:

Page 64: Sap Abap  Dialog Programming

a.     The module ‘STATUS_0100’ would contain the PF status and PF Title to be maintained in the screen.

            In the PF status needs to be activated for function keys “BACK”, “PGUP” and “PGDN” so that these buttons on the keyboard can be used and so also on the Radio-frequency (RF) application handset.

b.    The module ‘PGUP_DOWN’ contains the logic for navigation from one page to another depending on the number of records to be displayed.

This would basically contain the logic to hide/show the buttons for page up and down depending on the records which overflow on the page. For example, on first page the button for page up would be hidden and on last page the button for page down would be hidden.

c.     The module ‘TRANSP_ITAB_OUT’ contains the logic to transfer the contents of the internal table into the step-loop screen elements during PBO processing.

d.    The module ‘TRANSP_ITAB_IN’ contains the logic to transfer the contents from internal table into the step-loop screen elements during PAI processing.

Page 65: Sap Abap  Dialog Programming

e.     The module ‘USER_COMMAND_0100’ would help to handle the navigation and processing at the click on the buttons Page Up and Page Down. Please see source code extract for further details for handling the button clicks.

6. Source Code

Code is here   for the ABAP code that needs to be implemented. The screen 0100 needs to be designed as shown in section 3 above prior to activation of the program.

REPORT ystep_loop_test.* Number of records to be displayedPARAMETERS : p_num TYPE i.* Types to declare the internal table for recordsTYPES: BEGIN OF t_itab, col1 TYPE i, col2 TYPE i, END OF t_itab.* Internal table for the recordsDATA: itab TYPE STANDARD TABLE OF t_itab,* Work area for the records wa LIKE LINE OF itab.DATA:* Index of the row of step-loop idx TYPE i,* Current Line to be displayed line TYPE i,* Total Rows of step-loop to be displayed on single page lines TYPE i,* Final Limit of step loop rows that can be displayed limit TYPE i,* Cursor position c TYPE i,* Lower limit of the record index to be displayed on a page n1 TYPE i VALUE 1,* Upper limit of the record index to be displayed on a page n2 TYPE i,* Variable to handle next page navigation y_v_next TYPE i,* Variable to handle previous page navigation y_v_prev TYPE i, y_v_limit TYPE i.DATA: ok_code TYPE sy-ucomm, save_ok TYPE sy-ucomm.START-OF-SELECTION.* Building the records to be displayed as per the selection screen entry DO p_num TIMES. wa-col1 = sy-index. wa-col2 = sy-index ** 2. APPEND wa TO itab.

Page 66: Sap Abap  Dialog Programming

ENDDO. IF p_num < 0. n2 = p_num. ELSE. n2 = 5. ENDIF. CALL SCREEN 100.*----------------------------------------------------------------------** MODULE status_0100 OUTPUT*----------------------------------------------------------------------***----------------------------------------------------------------------*MODULE status_0100 OUTPUT. SET PF-STATUS 'STATUS_100'.ENDMODULE. "status_0100 OUTPUT*----------------------------------------------------------------------** MODULE transp_itab_out OUTPUT*----------------------------------------------------------------------***----------------------------------------------------------------------*MODULE transp_itab_out OUTPUT. idx = sy-stepl + line. READ TABLE itab INTO wa INDEX idx.ENDMODULE. "transp_itab_out OUTPUT*----------------------------------------------------------------------** MODULE transp_itab_in INPUT*----------------------------------------------------------------------***----------------------------------------------------------------------*MODULE transp_itab_in INPUT. lines = sy-loopc. idx = sy-stepl + line. MODIFY itab FROM wa INDEX idx.ENDMODULE. "transp_itab_in INPUT*----------------------------------------------------------------------** MODULE user_command_0100 INPUT*----------------------------------------------------------------------***----------------------------------------------------------------------*MODULE user_command_0100 INPUT. DATA : y_v_index TYPE sy-index. DATA : y_lv_d TYPE f, y_lv_div TYPE i, y_curr_p_num TYPE i. save_ok = ok_code. CLEAR ok_code. CASE save_ok. WHEN 'BACK'. LEAVE TO SCREEN 0.* When Page Down is Hit WHEN 'PGDN'.* Number of screens required for output if 5 records per screen y_lv_d = p_num / 5. y_lv_div = CEIL( y_lv_d ). y_curr_p_num = y_lv_div * 5. y_v_index = y_v_next + 1. IF y_v_next < y_lv_div. y_v_next = y_v_next + 1. ELSE. y_v_next = y_lv_div. ENDIF.

Page 67: Sap Abap  Dialog Programming

y_v_prev = y_v_next. IF y_v_next <> y_lv_div. n2 = p_num - 5 * y_v_next. IF n2 > 5. n2 = 5 * y_v_next. ENDIF. n1 = 1. line = line + lines. limit = y_curr_p_num - lines. IF line > limit. line = limit. ENDIF. ELSE. y_v_next = y_v_next - 1. ENDIF.* When Page Up is Hit WHEN 'PGUP'. n2 = 5 * y_v_next. IF n1 < 0. n1 = 1. ENDIF. IF y_v_next > 0. y_v_next = y_v_next - 1. ELSE. y_v_next = 0. ENDIF. y_v_prev = y_v_next. IF line NE 0 AND y_curr_p_num GT 5. line = y_v_next * 5. ELSE. line = 0. y_v_index = y_v_next - 1. ENDIF. IF line < 0. line = 0. ENDIF. ENDCASE.ENDMODULE. "user_command_0100 INPUT*----------------------------------------------------------------------** MODULE cancel INPUT*----------------------------------------------------------------------***----------------------------------------------------------------------*MODULE cancel INPUT. LEAVE PROGRAM.ENDMODULE. "cancel INPUT*&---------------------------------------------------------------------**& Module PGUP_DOWN OUTPUT*&---------------------------------------------------------------------** text*----------------------------------------------------------------------*MODULE pgup_down OUTPUT. DATA : y_v_div TYPE i, y_v_d TYPE f, y_v_temp TYPE i. DESCRIBE TABLE itab[] LINES p_num. y_v_d = p_num / 5. y_v_limit = CEIL( y_v_d ). y_v_temp = y_v_limit - 1. IF p_num LE 5. PERFORM y_f_hide_field USING 'RLMOB-PPGDN'.

Page 68: Sap Abap  Dialog Programming

PERFORM y_f_hide_field USING 'RLMOB-PPGUP'. ELSEIF y_v_next = y_v_limit . PERFORM y_f_hide_field USING 'RLMOB-PPGDN'. PERFORM y_f_show_field USING 'RLMOB-PPGUP'. ELSEIF y_v_prev IS INITIAL. PERFORM y_f_hide_field USING 'RLMOB-PPGUP'. ELSEIF y_v_next GT y_v_limit. PERFORM y_f_hide_field USING 'RLMOB-PPGDN'. ELSEIF y_v_temp = y_v_next. PERFORM y_f_hide_field USING 'RLMOB-PPGDN'. ENDIF.ENDMODULE. " PGUP_DOWN OUTPUT*&---------------------------------------------------------------------**& Form Y_F_HIDE_FIELD*&---------------------------------------------------------------------** text*----------------------------------------------------------------------** -->P_0372 text*----------------------------------------------------------------------*FORM y_f_hide_field USING value(p_name). LOOP AT SCREEN. IF screen-name = p_name. screen-active = '0'. screen-invisible = '1'. MODIFY SCREEN. EXIT. ENDIF. ENDLOOP.ENDFORM. " Y_F_HIDE_FIELD*&---------------------------------------------------------------------**& Form Y_F_SHOW_FIELD*&---------------------------------------------------------------------** text*----------------------------------------------------------------------** -->P_0388 text*----------------------------------------------------------------------*FORM y_f_show_field USING value(p_name). LOOP AT SCREEN. IF screen-name = p_name. screen-active = '1'. MODIFY SCREEN. EXIT. ENDIF. ENDLOOP.ENDFORM. " Y_F_SHOW_FIELD

Page 69: Sap Abap  Dialog Programming

Example: Dialog (103) - Table Control

Creating Dialog1. Open Abap Editor - SE38.

2. Copy Program "YPRACTICE_DIALOG_101" to "YPRACTICE_DIALOG_103"3. Select All Object

4. Change Program "YPRACTICE_DIALOG_103"5. Open Goto > Attributes, and change Title with "103 - Table Control"6. Modified Report Declaration

BeforeREPORT  ypractice_dialog_101                    .

 AfterREPORT  ypractice_dialog_103                    . 

7. Modified ""Before*----------------------------------------------------------------------**GLOBAL VARIABLE DECRALATION*----------------------------------------------------------------------* DATA : ok_code LIKE sy-ucomm,       save_ok LIKE sy-ucomm. DATA : gv_message1(100),       gv_message2(100). *----------------------------------------------------------------------* After*----------------------------------------------------------------------**GLOBAL VARIABLE DECRALATION*----------------------------------------------------------------------*

Page 70: Sap Abap  Dialog Programming

TYPES: BEGIN OF ty_header,         matkl LIKE mara-matkl,  " Material Group         matnr LIKE mara-matnr,  " Material Number         maktx LIKE makt-maktx,  " Material Description         bismt LIKE mara-bismt,  " Old material number         meins LIKE mara-meins,  " Base Unit of Measure         mseht LIKE t006a-mseht, " Unit of Measurement Text         Cek,       END OF ty_header. * Or You can using this code bellow*TYPES: BEGIN OF ty_header.*         INCLUDE STRUCTURE yta_header_101.*TYPES:   cek,*       END OF ty_header.

 * Deklarasi Internal TableDATA: gi_header TYPE STANDARD TABLE OF ty_header WITH HEADER LINE,      gi_makt  LIKE STANDARD TABLE OF makt WITH HEADER LINE,      gi_t006a LIKE STANDARD TABLE OF t006a WITH HEADER LINE. DATA: gv_matkl LIKE mara-matkl. DATA : ok_code LIKE sy-ucomm,       save_ok LIKE sy-ucomm. DATA : gv_message1(100),       gv_message2(100). *----------------------------------------------------------------------* 

8. Click " " and click " "9. Select "REPS", "CUAD" and "DYNP"

10.Click " " to activate the program

11.Click " "

Page 71: Sap Abap  Dialog Programming

12.Double click " " to open screen 2000

13.Click " " to start design layout (Screen Painter)

14.Click " " and then click to screen15.Set Label (Text Field) Name with "GV_LABEL1" and Text with "Material Group." like this bellow

 

16.Click " " and then click to screen17.Set TextBox (Input/Output Field) name with "GV_MATKL" with length "10" like this bellow

 

18.Double Click " " and set Search help with "H_T023"

 

19.After that the TextBox changed to " "

20.Click " " and then click to screen21.Set Button (PushButton) name with "GV_BUTTON" like this bellow

 

22.Double click " " and set Function Code with "DISPLAY"

Page 72: Sap Abap  Dialog Programming

 

23.After that the button color changed to gray like this " "

24.Click " " to save the screen

25.Click " " and drag it at screen painter26.After than Table Control Wizard will be run

 

27.Click " " Followed this steps bellowDisplay Steps

▪ Fill Name of table control with "ZTC_HEADER" and then click " "

Page 73: Sap Abap  Dialog Programming

 

▪ Select "Internal program table" and fill it with "GI_HEADER" and then click " "

 

▪ Select Field like this bellow and then click " "

Page 74: Sap Abap  Dialog Programming

 

Checklist "List selection col" and fill it with "CEK" like this bellow and then click "

"

 

▪ Checklist "Scroll" and then click " "

Page 75: Sap Abap  Dialog Programming

 

▪ Fill all Text Box with "YPRACTICE_DIALOG_103_HEADER" and then click " "

 

▪ Click " " to complete this wizard and generate source code and dialog object. Wizard Result

Page 76: Sap Abap  Dialog Programming

 

28.Click " " to save the screen and then close the screen painter29.Back to source code

30.Modified module "USER_COMMAND_2000 input"Before*&---------------------------------------------------------------------**&      Module  USER_COMMAND_2000  INPUT*&---------------------------------------------------------------------**       text*----------------------------------------------------------------------*module USER_COMMAND_2000 input.  save_ok = ok_code.  CLEAR ok_code.   CASE save_ok.    WHEN 'BACK'.      LEAVE TO SCREEN 0.    WHEN OTHERS.   ENDCASE.   CLEAR ok_code.endmodule.                 " USER_COMMAND_2000  INPUT After

Page 77: Sap Abap  Dialog Programming

*&---------------------------------------------------------------------**&      Module  USER_COMMAND_2000  INPUT*&---------------------------------------------------------------------**       text*----------------------------------------------------------------------*MODULE user_command_2000 INPUT.  save_ok = ok_code.  CLEAR ok_code.   CASE save_ok.    WHEN 'BACK'.      LEAVE TO SCREEN 0.    WHEN 'DISPLAY'.      CALL FUNCTION 'YFM_RFC_PRACTICE_101'       EXPORTING         gv_matkl         = gv_matkl*         GV_MATNR         =         gv_max_row       = 0       TABLES         gi_header        = gi_header                .    WHEN OTHERS.   ENDCASE.   CLEAR ok_code.ENDMODULE.                 " USER_COMMAND_2000  INPUT 

31.Click " " and click " "32.Select "REPS", "REPS" and "DYNP"

33.Click " " to activate the program34.Test and Run program35.Create T-Code "YPD103"36.Finished Result▪ Screen 2000

Page 78: Sap Abap  Dialog Programming

 ▪ After button "Display" clicked

YPRACTICE_DIALOG_101

*&---------------------------------------------------------------------**& Report  YPRACTICE_DIALOG_101                                        **&                                                                     **&---------------------------------------------------------------------*

Page 79: Sap Abap  Dialog Programming

*&                                                                     **&                                                                     **&---------------------------------------------------------------------* REPORT  ypractice_dialog_101                    . *----------------------------------------------------------------------**GLOBAL VARIABLE DECRALATION*----------------------------------------------------------------------*DATA : ok_code LIKE sy-ucomm,       save_ok LIKE sy-ucomm.  *----------------------------------------------------------------------**Set First Screen to Displayed*----------------------------------------------------------------------*call screen 2000. *&---------------------------------------------------------------------**&      Module  STATUS_2000  OUTPUT*&---------------------------------------------------------------------**       text*----------------------------------------------------------------------*module STATUS_2000 output.  SET PF-STATUS 'ST_2000'.  SET TITLEBAR 'TL_2000'. endmodule.                 " STATUS_2000  OUTPUT*&---------------------------------------------------------------------**&      Module  USER_COMMAND_2000  INPUT*&---------------------------------------------------------------------**       text*----------------------------------------------------------------------*module USER_COMMAND_2000 input.  save_ok = ok_code.  CLEAR ok_code.   CASE save_ok.    WHEN 'BACK'.      LEAVE TO SCREEN 0.    WHEN OTHERS.   ENDCASE.   CLEAR ok_code.endmodule.                 " USER_COMMAND_2000  INPUT

 

YPRACTICE_DIALOG_102

*&---------------------------------------------------------------------**& Report  YPRACTICE_DIALOG_102                                        **&                                                                     *

Page 80: Sap Abap  Dialog Programming

*&---------------------------------------------------------------------**&                                                                     **&                                                                     **&---------------------------------------------------------------------* REPORT  ypractice_dialog_102                    . *----------------------------------------------------------------------**GLOBAL VARIABLE DECRALATION*----------------------------------------------------------------------*DATA : ok_code LIKE sy-ucomm,       save_ok LIKE sy-ucomm. DATA : gv_text(32) VALUE 'TextBox'. *----------------------------------------------------------------------**Set First Screen to Displayed*----------------------------------------------------------------------*CALL SCREEN 2000. *&---------------------------------------------------------------------**&      Module  STATUS_2000  OUTPUT*&---------------------------------------------------------------------**       text*----------------------------------------------------------------------*MODULE status_2000 OUTPUT.  SET PF-STATUS 'ST_2000'.  SET TITLEBAR 'TL_2000'. ENDMODULE.                 " STATUS_2000  OUTPUT*&---------------------------------------------------------------------**&      Module  USER_COMMAND_2000  INPUT*&---------------------------------------------------------------------**       text*----------------------------------------------------------------------*MODULE user_command_2000 INPUT.  save_ok = ok_code.  CLEAR ok_code.   CASE save_ok.    WHEN 'BACK'.      LEAVE TO SCREEN 0.    WHEN 'CHANGE'.      IF gv_text = 'TextBox'.        gv_text = 'www.sap-interface.com'.      ELSE.        gv_text = 'TextBox'.      ENDIF.    WHEN OTHERS.   ENDCASE.   CLEAR ok_code.

ENDMODULE.                 " USER_COMMAND_2000  INPUT

YPRACTICE_DIALOG_103

*&---------------------------------------------------------------------**& Report  YPRACTICE_DIALOG_103                                        *

Page 81: Sap Abap  Dialog Programming

*&                                                                     **&---------------------------------------------------------------------**&                                                                     **&                                                                     **&---------------------------------------------------------------------* REPORT  ypractice_dialog_103                    . *----------------------------------------------------------------------**GLOBAL VARIABLE DECRALATION*----------------------------------------------------------------------*TYPES: BEGIN OF ty_header,        matkl LIKE mara-matkl,  " Material Group        matnr LIKE mara-matnr,  " Material Number        maktx LIKE makt-maktx,  " Material Description        bismt LIKE mara-bismt,  " Old material number        meins LIKE mara-meins,  " Base Unit of Measure        mseht LIKE t006a-mseht, " Unit of Measurement Text        cek,      END OF ty_header. * Or You can using this code bellow*TYPES: BEGIN OF ty_header.*        INCLUDE STRUCTURE yta_header_101.*TYPES:  cek,*       END OF ty_header. * Deklarasi Internal TableDATA: gi_header TYPE STANDARD TABLE OF ty_header WITH HEADER LINE,      gi_makt LIKE STANDARD TABLE OF makt WITH HEADER LINE,      gi_t006a LIKE STANDARD TABLE OF t006a WITH HEADER LINE. DATA: gv_matkl LIKE mara-matkl. DATA : ok_code LIKE sy-ucomm,       save_ok LIKE sy-ucomm. DATA : gv_message1(100),       gv_message2(100). *----------------------------------------------------------------------**Set First Screen to Displayed*----------------------------------------------------------------------*CALL SCREEN 2000. *&---------------------------------------------------------------------**&      Module  STATUS_2000  OUTPUT*&---------------------------------------------------------------------**       text*----------------------------------------------------------------------*MODULE status_2000 OUTPUT.  SET PF-STATUS 'ST_2000'.  SET TITLEBAR 'TL_2000'. ENDMODULE.                 " STATUS_2000  OUTPUT*&---------------------------------------------------------------------**&      Module  USER_COMMAND_2000  INPUT*&---------------------------------------------------------------------**       text*----------------------------------------------------------------------*MODULE user_command_2000 INPUT.  save_ok = ok_code.  CLEAR ok_code.   CASE save_ok.    WHEN 'BACK'.

Page 82: Sap Abap  Dialog Programming

      LEAVE TO SCREEN 0.    WHEN 'DISPLAY'.      CALL FUNCTION 'YFM_RFC_PRACTICE_101'       EXPORTING         gv_matkl         = gv_matkl*         GV_MATNR         =         gv_max_row       = 0       TABLES         gi_header        = gi_header                .    WHEN OTHERS.   ENDCASE.   CLEAR ok_code.ENDMODULE.                 " USER_COMMAND_2000  INPUT *&SPWizard: Data incl. inserted by SP Wizard. DO NOT CHANGE THIS LINE!

INCLUDE ypractice_dialog_103_header .

Flow LogicPROCESS BEFORE OUTPUT.*&spwizard: pbo flow logic for tablecontrol 'ZTC_HEADER'  module ZTC_HEADER_change_tc_attr.*&spwizard: module ZTC_HEADER_change_col_attr.  loop at   GI_HEADER       with control ZTC_HEADER       cursor ZTC_HEADER-current_line.    module ZTC_HEADER_get_lines.*&spwizard:   module ZTC_HEADER_change_field_attr  endloop. MODULE STATUS_2000.*PROCESS AFTER INPUT.*&spwizard: pai flow logic for tablecontrol 'ZTC_HEADER'  loop at GI_HEADER.    chain.      field GI_HEADER-MATKL.      field GI_HEADER-MATNR.      field GI_HEADER-MAKTX.      field GI_HEADER-BISMT.      field GI_HEADER-MEINS.      field GI_HEADER-MSEHT.    endchain.    field GI_HEADER-CEK      module ZTC_HEADER_mark on request.  endloop.  module ZTC_HEADER_user_command.*&spwizard: module ZTC_HEADER_change_tc_attr.*&spwizard: module ZTC_HEADER_change_col_attr. MODULE USER_COMMAND_200