Module Pool Details Wiki

Embed Size (px)

Citation preview

  • 7/22/2019 Module Pool Details Wiki

    1/13

    6/21/2014 Module pool - Application Server Infrastructure - SCN Wiki

    http://wiki.scn.sap.com/wiki/display/SI/Module+pool

    Getting Started Newsletters Store

    Search the Community Welcome, Guest Login Register

    Products Services & Support About SCN Downloads

    Industries Training & Education Partnership Developer Center

    Lines of Business University Alliances Events & Webinars Innovation

    Added by Venkat Sharma Gaddala, last edited by Alon Mizrahi on Nov 01, 2011

    Application Server Infrastructure

    Module pool

    Contents

    1. Basic Concepts

    a. Status Icon

    b. Context menu

    c. Methods

    d. Screen keyw ords

    e. Screen events

    f. GUI status and Title

    g. Screen fields and OK_CODE 2. Input Help

    * *a. DYNP_VALUE_READ

    b. F4IF_FIELD_VALUE_REQUEST

    c. F4IF_INT_TABLE_VALUE_REQUEST d. POPUP_WITH_TABLE_DISPLAY

    3. Step Loop

    a. Step loop types

    b. Step Loop screen creation

    c. Step Loop coding 4. Table Control

    a. Attributes and Creation

    b. CXTAB_CONTROL

    c. Modifications

    d. ABAP declarations

    e. PBO process ing

    f. PAI process ing

    5. List Box

    6. Sub scre en

    7. Tab Strip

    1.Basic Concepts :

    a). STATUS ICON

    Status icon is used in screens to indicate visually about the status of the program. Before the status icon can be used, it should be placed on the screen, it is a type of screen element. To use the stat

    icon w e have to w rite some abap code and also to change icons w henever required in the program. First step is to create a variable of type ICONS-TEXT.

    e.g. DATA: status TYPE ICONS-TEXT.

    The name of the variable in the abap program should be same as that of in the screen. Declaring it merely w on't show anything, w e have to use the function module ICON_CREATE to fill it with the

    required icon, generally PBO of the screen is used for this purpose. There are 3 parameters to be passed.

    CALL FUNCTION 'ICON_CREATE'

    EXPORTING

    NAME= 'icon name'

    TEXT = 'text to be displayed'

    INFO = 'tooltip text'

    http://wiki.scn.sap.com/wiki/display/SI/Module+poolhttp://wiki.scn.sap.com/wiki/display/SIhttp://scn.sap.com/community/uachttp://wiki.scn.sap.com/wiki/display/SI/Module+poolhttp://wiki.scn.sap.com/wiki/display/SIhttp://wiki.scn.sap.com/wiki/display/~xxsi20thttp://wiki.scn.sap.com/wiki/display/~jd8jznphttp://scn.sap.com/community/uachttp://scn.sap.com/community/developer-centerhttp://scn.sap.com/community/downloadshttp://wiki.scn.sap.com/wikihttp://wiki.scn.sap.com/wiki/login.jsp?os_destination=%2Fdisplay%2FSI%2FModule%2Bpoolhttp://scn.sap.com/welcomehttp://www.sapstore.com/http://scn.sap.com/community/newslettershttp://scn.sap.com/community/getting-started
  • 7/22/2019 Module Pool Details Wiki

    2/13

    6/21/2014 Module pool - Application Server Infrastructure - SCN Wiki

    http://wiki.scn.sap.com/wiki/display/SI/Module+pool 2

    Here name can be anything like ICON_RED_LIGHT,ICON_GREEN_LIGHT etc. Infact any icon can be show n that exists but w e should adhere to SAP

    recommended style guidelines

    b). CONTEXT M ENU

    Context menu can be used in relation w ith the various screen elements like I/O fields, sub screen, group box, table control but not w ith push buttons, radio, check buttons. It can be used to show relate

    options w hen the user right clicks on the screen elements. It is a type of s tatus. SAP automatically creates a default context menu for dialog statuses cons isting of all the function codes available. We ca

    create a context menu statically using the menu painter (SE41) or dynamically by using the methods of the global class CL_CTMENU. All context menus are objects of this global class. c). METHODS

    There are number of methods w hich can be used to create and modify contex t menu dynamically. These are:

    LOAD_GUI_STATUS

    This method is used to load a static context menu already defined using menu

    painter.The exporting parameters are PROGRAM ,STATUS and MENU. Where

    MENU indicates the menu to which the context menu w ill be attached .

    ADD_FUNCTION

    This method adds a function code to the menu ,The exporting parameters are FCODE

    and TEXT. These are used to s pecify the function code and the corresponding text in

    the men.

    ADD_MENU

    This method adds a context menu to another one.

    ADD_SEPARATOR

    This method adds a separator line.

    ADD_SUBMENU

    This method adds a menu to another one as a sub menu the exporting parameters are

    MENU and the TEXT that w ill be display ed.

    HIDE_FUNCTIONS

    SHOW_FUNCTIONS

    DISABLE_FUNCTIONS

    ENABLE_FUNCTIONS

    These functions are used to modify the context menu by hiding, enabling etc them.

    SET_DEFAULT_FUNCTION

    This method w ill mark a particular menu item as the default one, the corresponding

    function code is passed as an exporting parameter.

    The context menu should be linked to the screen element in the sc reen painter (SE51) by spec ifying an ID w hich is know n as CONTEXT in the context menu field. We can specify the same context f or

    different screen elements or different context for different elements. For each context specified in the screen painter a special call back subroutine is used in the abap program. the syntax of this special

    routine is:

    FORM ON_CTLMENU_context USING menu TYPE REF TO CL_CTMENU

    ...

    ENDFORM

    This subroutine can be used to modify or load or create a context menu at runtime w hen the user r ight clicks the screen element.

    In the above subroutine the context is the context assigned to the screen element and menu is the menu object that w as passed to this call back routine w hich is initially blank, we have to use method

    the class as stated above to cr eate a w orking menu or load an existing static context menu previously build in the menu painter.

    e.g. To load an existing context menu

    FORM on_ctm enu_text USING me nu TYPE REF TO cl_ctmenu.

    CALL METHOD me nu->load_gui_status EXPORTING program = prog

    status = 'CON_MENU'

    menu = menu .

    CALL METHOD m enu->set _default_function

    EXPORTING fcode = 'lis t'.

    ENDFORM.

    e.g . CREATING A NEW CONTEXT MENU DYNAMICALLY.

    FORM on_ctm enu_text USING me nu TYPE REF TO cl_ctmenu.

    DATA new_m enu TYPE REF TO cl_ctme nu.

    CREATE OBJECT new _me nu.

    CALL METHOD new _me nu->add_funct ion

    EXPORTING fcode = 'lis t'

    text = text-001.

    CALL METHOD new _me nu->add_funct ion

    EXPORTING fcode = 'add '

  • 7/22/2019 Module Pool Details Wiki

    3/13

    6/21/2014 Module pool - Application Server Infrastructure - SCN Wiki

    http://wiki.scn.sap.com/wiki/display/SI/Module+pool 3

    text = text-002. CALL METHOD new _menu->add_function

    EXPORTING fcode = 'de lete '

    text = text-003.

    CALL METHOD new _menu->add_subme nu

    EXPORTING me nu = new _me nu

    text = text-005.

    ENDFORM.

    The ABAP program should check f or the OK_CODE field to find out w hich menu item was selected by the user. Selecting a function code w ill trigger a PAI w hile right clicking w ill not trigger the PAI. d).

    SCREEN KEYWORDS

    Screen language is used to c reate Screen Flow Logic, It is similar to A BAP but w ith limited functionality .Only cer tain keywords can be used and these are:

    PROCESS

    MODULE

    FIELD

    ON

    LOOP

    ENDLOOP

    CHAIN

    ENDCHAIN

    CALL

    e). SCREEN EVENTS

    Screen Flow Logic serves as the container for sc reen process ing blocks. There are four events processing block supported out of which FIRST two are automatically inserted when w e create a ne

    screen. The 4 events are:

    PROCESS BEFORE OUTPUT

    This event is fired just before the screen is displayed.

    e.g. MODULE LOAD_STATUS_1000.

    PROCESSS AFTER INPUT

    This event is fired w hen user selects a function code or presses enter key

    e.g. MODULE USER_COMMAND_1000.

    PROCESS ON HELP-REQUEST

    This event is fired w hen the user presses F1 key.

    PROCESS ON VALUE-REQUEST

    This event is fired w hen the user presses F4 key.

    These events are triggered by the runtime environment. The ABAP program serves as the container for the processing blocks associated w ith these events. Each processing block in ABAP starts wthe keyw ord MODULE.

    PBO modules have OUTPUT keyw ord attached to them while for remaining 3 events there associated modules have INPUT keyw ord attached to them in the ABAP program.

    e.g. MODULE LOAD_STATUS_1000 OUTPUT.

    MODULE USER_COMMAND_1000 INPUT.

    MODULE name AT EXIT-COMMAND

    The specif ied module is called when the user selects a function code of type E like BACK,EXIT and CANCEL in PAI all other dialog modules are bypassed.

    f). GUI STATUS and TITLE

    SET PF-STATUS status OF PROGRAM prog EXCLUDING f statement is used to set the status of a ABAP program. The status provides user interface. It consists of standard toolbar, application toolbar and

    menu. When ever the user selects a f unction the f unction code is placed in the OK_CODE field and struc ture SYST-UCOMM. The status is set in PBO event.

    The title is set using SET TITLEBAR title OF PROGRAM program WITH p1 p2

    w here the values f or p1 p2 can be specif ied at run time. Menu Painter (SE41) is used to create GUI status and titlebar. g). SCREEN FIELDS and OK_CODE

    Screen fields are fields in the w orking memory of the screen, these are attached to the screen elements. There contents are passed to similarly named fields in abap program during PAI and vice vers a

    PBO.

    OK_CODE is a 20 c har field w hich is f ound in every s creen , it stores the f unction code selected by the user. Its contents are same as that of SY_UCOMM. It is a screen element.

    2. Input Help:

    Input help can be programmed in selection sc reen using event,

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR FIELD

    And for module pools in event

    PROCESS ON VA LUE_REQUEST using module call starting with FIELD

  • 7/22/2019 Module Pool Details Wiki

    4/13

    6/21/2014 Module pool - Application Server Infrastructure - SCN Wiki

    http://wiki.scn.sap.com/wiki/display/SI/Module+pool 4

    i.e. FIELD MODULE

    There are number of function modules that can be used for the purpose, but these

    can f ulfill the task easily or combination of them.

    DYNP_VALUE_READ

    F4IF_FIELD_VALUE_REQUEST

    F4IF_INT_TABLE_VALUE_REQUEST

    POPUP_WITH_TABLE_DISPLAY

    a). DYNP_VALUE_READ

    This function module is used to read values in the screen fields. Use of this FM causes forced transfer of data from screen fields to ABAP fields.

    There are 3 expor ting parameters DYNAME = progr am name = SY-CPROG

    DYNUMB = Screen number = SY-DYNNR

    TRANSLATE_TO_UPPER = 'X'

    and one importing TABLE parameter DYNPFIELDS = Table of TYPE DYNPREAD

    The DYNPFIELDS parameter is used to pass internal table of type DYNPREAD

    to this FM and the values read from the screen w ill be stored in this table.This

    table consists of two fields:

    FIELD NAME : Used to pass the name of screen f ield for w hich the value is to

    be read.

    FIELD VALUE : Used to read the value of the field in the screen.

    e.g.DATA: SCREEN_VALUES TYPE TABLE OF DYNPREAD ,

    SCREEN_VALUE LIKE LINE OF SCREEN_VALUES.

    SCREEN_VALUE-FIELDNAME = 'KUNNR' . * Field to be read

    APPEND SCREEN_VALUE TO SCREEN_VALUES. * Fill the table

    CALL FUNCTION 'DYNP_VALUES_READ'

    EXPORTING

    DYNAME = SY-CPROG

    DYNUMB = SY-DYNNR

    TRANSLATE_TO_UPPER = 'X'

    TABLES

    DYNPFIELDS = SCREEN_VALUES.

    READ TABLE SCREEN_VALUES INDEX 1 INTO SCREEN_VALUE.

    Now the scr een value f or f ield KUNNR is in the SCREEN_VALUE-FIELDVALUE and can be used for further pr ocessing like using it to fill the internal table to be used as parameter in

    F4IF_INT_TABLE_VALUE_REQUEST ETC. b). F4IF_FIELD_VALUE_REQUEST

    This FM is used to display value help or input from ABAP dictionary. We have to pass the name of the structure or table (TABNAME) along w ith the field name (FIELDNAME). The selection can be returne

    to the specified screen field if three parameters DYNPNR, DYNPPROG, DYNPROFIELD are also specified or to a table if RETRN_TAB is specified.

    CALL FUNCTION 'F4IF_FIELD_VALUE_REQUEST'

    EXPORTING

    TABNAME = table/st ructure

    FIELDNAME = 'f ield name'

    DYNPPROG = SY-CPROG

    DYNPNR = SY-DYNR

    DYNPROFIELD = 'sc reen f ield'

    IMPORTING

    RETURN_TAB = table of type DYNPREAD

    .

    c). F4IF_INT_TABLE_VALUE_REQUEST

    This FM is used to display values s tored in an internal table as input help.This FM is used to program our ow n custom help if no such input help exists in ABAP dictionary f or a particular f ield. The

    parameter VALUE_TAB is used to pass the internal table containing input values. The parameter RETFIELD is used to s pecify the internal table field w hose value w ill be returned to the s creen f ield or

    RETURN_TAB.

    If DYNPNR, DYNPPROG and DYNPROFIELD are specified than the user selection is passed to the screen field specified in the DYNPROFIELD. If RETURN_TAB is specified the selection is returned in a

    table.

    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

    EXPORTING

    RETFIELD = field from internal table w hose value w ill be returned

    DYNPPROG = SY-CPROG

    DYNPNR = SY-DYNNR

    DYNPROFIELD = 'sc reen f ield'

    VA LUE_ORG = 'S'

    TABLES

    VALUE_TAB = internal table w hose values w ill be show n.

    RETURN_TAB = internal table of type DDSHRETVAL

  • 7/22/2019 Module Pool Details Wiki

    5/13

  • 7/22/2019 Module Pool Details Wiki

    6/13

    6/21/2014 Module pool - Application Server Infrastructure - SCN Wiki

    http://wiki.scn.sap.com/wiki/display/SI/Module+pool 6

    A step loop can extend more than one line on the screen (see Table Control).A vertical scroll bar is automatically created to show step loops on the screen.

    Step loops have no name. We use LOOP ...ENDLOOP to program step loops in a screen in both PBO and PAI. Since the number of loop blocks in variable step loops can change the number of loop bloc

    at any moment is placed by the system in system field SY-LOOPC

    and the cur rent step loop pass number is placed in sys tem field SY-STEPL .

    Loop Type attribute is used to specif y the type of step loop and Loop Count attribute is used to specify the number of step loop blocks that w ill be displayed on the screen at a time. b). STEP LOOP

    SCREEN CREATION

    We create step loop in the sc reen painter (SE51). First w e define the sc reen elements that w ill be part of the s tep loop on the screen, they may extend to more than one line. Select all the elements as

    one group.Goto Edit menu and select Grouping->Step Loop->Define.

    To define a step loop as variable or f ixed.goto Edit->Grouping>Step Loops->Fix or Variable.To edit the Step Loop click on the border of the block and goto

    Edit->Grouping->Step Loop here w e can use define/undefine (delete) var iable fix options.

    Once created w e have to program step loops through screen key w ord LOOP...ENDLOOP in PBO and PAI as these events are used to transfer back and forth the data fr om the ABAP program. c). ST

    LOOP CODING

    We use tw o flavours of LOOP ... ENDLOOP in screen flow logic to program the step loops. We have to program both in PBO and PAI so that transfer of data can take place betw een screen and abap

    program.

    1) LOOP

    MODULE fi ll_data

    ENDLOOP.

    Here in PBO a module should be called that will transfer the data to the screen fields.

    In PAI the module call is not required only the empty LOOP...ENDLOOP w ill do or we can call a module to write the data to an internal table. In this method there is no automatic scrolling w e have to program

    in ABAP.

    2) LOOP AT int_table [Community :INTO w a] [Community :CURSOR line_number][Community:FROM n1 TO n2]

    ENDLOOP.

    Here in PBO a module call is not required to fill the step loop screen fields as the data is copied to the work are wa and from there to screen f ields in step loop automatically INTO wa is not required if

    use the int_table declared w ith a header line.

    In PAI the addition AT int_table is also required f or automatic sc rolling. The parameter CURSOR line_number w hich is of TYPE I is used to specify the that w ill be the first to be displayed, it is f illed in th

    ABAP program.

    NOTE:

    1) It is preferable to use TABLE CONTROL instead of STEP LOOPS.

    2) It is preferable to use LOOP AT int_table instead of plain LOOP..ENDLOOP.

    4. TABLE CONTROL

    These are the screen elements used to display tabular data they can be called as scr een tables (like STEP LOOP). To use table control w e have to create it on the scr een using SCREEN PAINTER (SE5

    and dec lare a c ontrol variable of TYPE TABLEVIEW using CONTROLS statement in the ABAP program. We have to use LOOP... ENDLOOP statement in both PBO and PAI with or w ithout AT int_table

    parameter. IF AT int_table parameter is not used than w e have to place a MODULE call betw een the LOOP...ENDLOOP statement to fill the screen table row s f rom the ABAP program in PBO and program

    ow n sc rolling functions 1using OK_CODE field.

    Having a parallel loop(at screen table row s and int table rows) by using parameter

    AT int_table makes the ABAP code simple.

    A special structure of type CXTAB_CONTROL is used to set/get various

    attributes of table control at runtime like CURRENT_LINE ,TOP_LINE.

    a) ATTRIBUTES and CREATION

    Table control can be created in tow w ays either by selecting the table control

    icon from the elements toolbar or by using table control w izard in SE51 and draw ing a table control area on the sc reen..

    If w e use table control w izard it takes mimimum of coding and effor t to create a w orkable table control.The wizard uses 7 dialogs .ABAP Code and screen f low logic statements are automatically

    generated for c ommon functions like inserting new lines,selecting rows etc.

    In table control attributes w e check/uncheck

    1) horizontal/vertical separators.

    2) w ith title ,if w ith title the name of the field.

    3) w ith column headers

    4) We have to s elect from single/multiple/none selection f or

    row s and columns.

    5) If Line selection column is to be used than the name of the Line Selection Column field is

    specified. This field is of type C(1) and can be used to determine which record(s) w ere

    selected by the user in PAI. A f ield of this name and type is generally the part of the

  • 7/22/2019 Module Pool Details Wiki

    7/13

    6/21/2014 Module pool - Application Server Infrastructure - SCN Wiki

    http://wiki.scn.sap.com/wiki/display/SI/Module+pool 7

    internal table w hich will be used to display the data if multiple row selection has been

    checked in the attribute box,for a single line row selection a declaration in ABAP program

    w ith the same name and type is sufficient.

    6) The number of f ixed columns can be specif ied.They can be changed dynamically in ABAP

    program using tab_con-FIXED_COLS attribute.

    Columns on Table Control

    The columns on table control are generally taken from the structure w hich is of same type as internal table used for displaying values in the ABAP program.

    b) CXTAB_CONTROL

    When we create a control var iable of type TABLEVIEW by using CONTROLS statement in ABAP to access table control from w ithin ABAP, the control variable created is of deep structure type

    CXTAB_CONTROL.This struc ture itself consists of a struc ture (or line) of type CXTAB_COLUMN w hich represents the columns f ound on the table control and can be used to modify c olumn properties.

    These structures are defined in type group CXTAB. By changing or reading various fields of these structures w e can modify the behavior of table control at run time in general and its columns.

    e.g.

    To make a particular record as the top record in the table control we can use the f ield TOP_LINE of the s tructure CXTAB_CONTROL.

    tab_con-TOP_LINE = 5 " here tab_con is the name of the table control.

    Some of the usef ul fields of the struc ture CXTAB_CONTROL are:

    LINES

    This field or attribute is used to s pecify the total number of records the table control w ill be show ing and according to SAP must be f illed explicitly before any LOOP ... ENDLOOP statement .LINES field hav

    a corr ect value ensures automatic and correct sc rolling. It is of TYPE I.

    TOP_LINE

    This field indicates the index of the record being show n in the top of the table control.It is of TYPE I.This f ield is used often f or extended or self s crolling functions.

    CURRENT_LINE

    This field specifies the index of the current record being process ed in the screen loop statement.It cannot be changed and its value is set by the system.It is of TYPE I.This f ield is used to determine the

    index and then used in PBO or PAI

    to read the internal table or to modify the internal table.e.g.

    READ TABLE itab INTO workar ea INDEX tab_con-CURRENT_LINE.

    MODIFY TABLE itab FROM w orkarea INDEX tab_con-CURRENT_LINE.

    FIXED_COLS

    This field is used to change the number of lead columns(f ixed) in table control at runtime.It is of TYPE I.

    LEFT_COL

    This field is used to speify the firs t column that can be hor izontallyy scrolled from the lead columns.It is of TYPE I.

    INVISIBLE

    This field can be used to hide or make visible the entire table control at run time.It is of TYPE C(1) and can have value of 'X' or ' '.

    COLS

    This field is used to modify various column attributes at run time and represents

    the collection of all the columns in the table control.It is of TYPE CXTAB_COLUMN w hich is an internal table w ithout header line.

    CXTAB_COLUMN

    To access and modify the columns of the table control at run time w have to use the fields of the structure CXTAB_COLUMN w hich is a line of the s tructure CXTAB_CONTROL..This struc ture has 5 f iel

    The fields of this structure are :

    SCREEN

    This filed is of TYPE SCREEN (screen table noramally used in ABAP) .It is

    used to modify and access v arious scr een element attributes that created the column .

    e.g. SCREEN-NAME w ill return the screen element that created the

    column ( e.g if the screen elemrnt ADDRESS-PHONE created the column PHONE than the SCREEN-NAME will return the value ADDRESS-PHONE

    and not PHONE ,so w e have to use of fset method to retr ieve the correct f ield name i.e SCREEN-NAME(+7) w ill give us the value PHONE ,This method can

    be used for example in dynamic sorting of the column fields w hen the name

    of the column selected is required and not its sc reen element name

    e.g SORT itab STABLE BY SCREEN-NAME(+7) .

    INDEX

    This field represents the position of the column in the table control.It is of TYPE I.

  • 7/22/2019 Module Pool Details Wiki

    8/13

    6/21/2014 Module pool - Application Server Infrastructure - SCN Wiki

    http://wiki.scn.sap.com/wiki/display/SI/Module+pool 8

    INVISIBLE

    This field is used to make a par ticular column invisible or visible.It is of TYPE C(1) and can have a vale of 'X' or ' '.

    VISLENGTH

    This field repres ents the visible length of the column.It is of TYPE I.

    SELECTED

    This field represents w hether the column is selected or not.It is of TYPE C(1) and can have a value of 'X' or ' '.

    c) MODIFICATION

    We can modify the table control at run time or w e can pr ovide additonal functionality to our A BAP Code like 'Inserting blank lines' , 'sorting by column', 'deleting selected row s' ,'hiding certain columns' etc b

    setting the various fields of the structure CXTAB_CONTROL in abap either in PBO or PAI.

    ADDING BLANK LINES

    To add blank lines to table control w e do not need to change any of the fields of the structure CXTAB_CONTROL simply adding blank lines to the internal table w ill do.

    INSERT INITIAL LINE INTO itab.

    SORTING BY COLUMN

    We have to f irst determine which c olumn of table control w as selected f or sor ting. Then w e have to determine the name of the field from this information to use in SORT itab STABLE BY f ield command.

    e.g.

    DATA: col LIKE LINE OF tab_con-COLS "tab_con is name of table control,

    "COLS field is an internal table of TYPE

    "CXTAB_COLUMN .This var iable w ill

    "be used to access column attributes of

    "the table control.

    *We w ill read the column properties of selected column into col variable from

    *collection of columns COLS.

    *SELECTED is the field of structure CXTAB_COLUMN and indicates selection.

    READ TABLE tab_con-COLS INTO col WITH KEY selec ted = 'X'.

    IF SY_SUBRC EQ 0.

    *col-SCREEN-NAME (+offset) is us ed to determine the actual field name (like *PHONE) as*col-SCREEN-NAME w ill return the screen name like ADDRESS-*PHONE.

    *the value of offset depends upon the length of the name of the structure.

    SORT itab STABLE BY col-SCREEN-NAME (+offset)

    ENDIF.

    DELETING SELECTED ROWS

    Deletion of selected row s is simple. To delete selected rows first w e w ill determine the row s w hich have been selected through selection column.

    FOR SINGLE ROW SELECTION

    IF mark EQ 'X'. "mark is the name of selection column field

    DELETE itab FROM w orkarea.

    ENDIF.

    FOR MULTIPLE ROW SELECTION

    *To deetermine the row s selected w e w ill use the selection column field to loop

    *through the internal table.

    LOOP AT itab WHERE mark EQ 'X'. "mark is the name of selection column field

    DELETE itab " and is part of the internal table .

    ENDLOOP.

    HIDING A COLUMN

    To hide a column w e w ill use the INVISIBLE field of the structure CXTABA_CONTROL and set its value to 'X'.

    e.g. To hide column number 3.

    DATA col LIKE LINE OF tab-con-COLS .

    READ TABLE tab_con-COLS INTO col WHERE index = 3. " tab_con is the name

    " of table control.

    col-INVISIBLE = 3.

    MODIFY tab-con-COLS FROM col INDEX 3. DISABLING INPUT

    To disable/enable fields of a column we w ill use the f ield SCREEN-INPUT of the

  • 7/22/2019 Module Pool Details Wiki

    9/13

    6/21/2014 Module pool - Application Server Infrastructure - SCN Wiki

    http://wiki.scn.sap.com/wiki/display/SI/Module+pool 9

    structure CXTAB_COLUMN and set its value to 0 or 1.

    e.g. To disable input at column 3 of the table control .

    DATA col LIKE LINE OF tab_con-COLS.

    READ TABLE tab_con-COLS INTO col INDEX 3.

    col-SCREEN-INPUT = 0.

    MODIFY tab_con-COLS FROM col INDEX 3. d) ABAP DECLARATION :

    CONTROLS: tab_con TYPE TABLEVIEW USING SCREEN nnnn

    Here tab_con is the same name we used in sc reen for the table control.This ABAP statement w ill declare a control variable that w ill be used to access the table control , and set it's various attributes lik

    number of fixed columns(tab_con-FIXED_COLS) ,total number of records it w ill display(tab_con-LINES).It is of type CXTAB_CONTROL and is a deep Structure (s tructure containing structures ).

    REFRESH CONTROL tab_con FROM SCREEN nnnn

    This A BAP statement w ill initialize the table control on the screen nnnn to its initial values.

    e) PBO PROCESSING:

    In PBO we have to us e the sc reen LOOP ...ENDLOOP statement , w ith or w ithout

    intenal table. LOOP WITH CONTROL tab_con.

    MODULE fill_tab_c on.

    ENDLOOP.

    Here a module should be called betw een the loop endloop s tatement to transf er data f rom the ABAP program to the screen table through a struc ture. This module should use the CURRENT_LINE attribute

    the table control variable to get the current screen table rec ord index to read the data f rom the internal table into a w ork area.e.g.

    READ TABLE int_table INDEX tab_con-CURRENT_LINE

    The record read w ill be placed in the header line of the internal table and w ill be available to the similarly named screen f ields or if these are dif ferent it can be w ritten explicitly.

    e.g.

    screen_f ield_name = int_table-f ield_name LOOP AT int_table INTO workarea WITH CONTROL tab_con CURSOR i FROM

    n1 TO n2.

    ENDLOOP.

    Here the module call is not required to f ill the screen table.The CURSOR parameter is a integer of type I indicating which absolute internal table line should be the f irst to display on the table control .FROM

    TO n2 can be used to restr ict the starting line and ending line number of the internal table , they are of type SY-TABIX.

    In both cases before the LOOP statement a module should be called which is generally for setting of s tatus ,in w hich w e should fill the LINES attribute (tab_con-LINES ) of the control w ith the total numbe

    internal table records,doing this ensures correc t and automatic scrolling.

    The ABAP statement DESCRIBE TABLE int_table LINES lines can be used to get the total lines in an int table. f) PAI PROCESSING:

    We have to use LOOP ... ENDLOOP in PAI so that data can transfer fro table control to ABAP program. If w e w ant to w rite changes to the data w e should

    call a module betw een the LOOP ... ENDLOOP. The MODULE call to process user commands ( SY-UCOM) should be called af ter the ENDLOOP statement.e.g.

    PROCESS AFTER INPUT

    MODULE mod AT EXIT-COMMAND.

    LOOP AT itab_table or LOOP "depending on whether w e are using AT int_table

    MODULE modify_int_table.

    ENDLOOP.

    MODULE user_command.

    In the MODULE call modify_int_table w e can use

    MODIFY int_table FROM w orkarea INDEX tab_con-CURRENT_LINE

    or w e can use

    int_table-field_name = screen_f ield_name. 5. LIST BOX

    Drop down list box can be created in a dialog screen(SE51) as w ell as selection screen. The sap list box allows to select a value from the list but we cannot enter our ow n value in the list box .The

    value list that w ill be displayed consists of tw o fields

    TEXT field of TYPE 80(C) and internal KEY field of TYPE 40(C).

    In screen painter to create a input/output field into list box w e use 'L" as a value for dropdow n attribute for the i/o field. In screen painter to determine the type of method that w ill be used to fill the va

    list w e use the attribute value list. If it is blank, the value list w ill be filled by the first column of the input help assigned to the screen f ield. This input help can be defined in the ABAP Dictionary, on sc reen

    using SELECT,VALUES screen statements or in event POV (PROCESS ON VALUE-REQUEST ) and the input help that w ill be passed to the f ield should consis ts of 2 columns ,the key c olumn is filled

    automatically by the sys tem. SAP recommends value list field s hould be blank.

    or

    The value can be 'A ' meaning that the value list w ill be filled in the event PBO(PROCESS BEFORE OUTPUT) or before the screen is display ed.In this method w e use f unction module VRM_SET_VALUES to

    the values and pass it to the i/o field. If a function code is attached to the list box the selection of a value triggers a PAI otherw ise PAI w ill not trigger. LIST BOX in SELECTION SCREEN

    List Box is created in selection screen using PARAMETERS statement w ith

  • 7/22/2019 Module Pool Details Wiki

    10/13

    6/21/2014 Module pool - Application Server Infrastructure - SCN Wiki

    http://wiki.scn.sap.com/wiki/display/SI/Module+pool 10

    AS LISTBOX addition other attributes like VISIBLE LENGTH (w idth of listbox) can be specified w ith the declaration. PARAMETERS name AS LISTBOX VISIBLE LENGTH n.

    Here n is an integer and name is the name of par ameter. To populate the value list w e use the FM VRM_SET_VA LUES and the selection screen event AT SELECTION-SCREEN OUTPUT is used to w rite th

    code to f ill it.

    VRM_SET_VALUES

    The function module VRM_SET_VALUES is used to fill the value list associated w ith a List Box .This FM uses types w hich are dec lared in type group VRM. So w e should declare TYPE-POOLS VRM

    before using this FM.

    Some important types declared in the VRM type group are

    VRM_ID

    It refers to the name of the input/output field associated w ith list box

    VRM_VALUES

    It refers to the internal table consisting of tw o fields TEXT(80C) and KEY(40)C

    that w ill be used to create the list values.

    CALL FUNCTION 'VRM_SET_VALUES'

    EXPORTING

    ID = name of scr een element, it is of TYPE VRM_ID

    VALUES = internal table containing values , of TYPE VRM_VALUES

    LIST BOX with value list fr om input help

    In this example the screen element attribute value list is set to blank as such the value list w ill be filled w ith the 1st column of the input help, We use PROCESS ON VALUE-EQUEST event to pass the

    value list to the listbox.In the MODULE call used to f ill the value list w e can use FM like F4IF_INT_TABLE_VA LUE_REQUEST to create input help as explained in the input help. The value of f irst column will

    show n in the field w hen selected.

    PROCESS ON VALUE-REQUEST

    FIELD list MODULE fill_list_100

    FIELD list MODULE fill_lis t_100 INPUT

    SELECT f1 f 2 FROM table INTO int

    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

    EXPORTING

    retfield = 'input/output screen field'

    value_org = 'S'

    TABLES

    value_tab = itab "it contains 2 fields that w ill be show n in the list box

    EXCEPTIONS

    parameter_error = 1

    no_values_found = 2

    OTHERS = 3.

    IF sy-s ubrc 0.

    ...

    ENDIF.

    ENDMODULE.

    VALUE LIST CREATED IN PBO

    In this method w e set the value list attribute to 'A'.The value list w ill be filled in the PBO by using FM VRM_SET_VALUES .

    TYPE-POOLS : VRM

    DATA: field_id TYPE VRM_ID ,

    values TYPE VRM_VALUES,

    value LIKE LINE OF values.

    PROCESS BEFORE OUTPUT

    MODULE lis t_f ill_100

    MODULE list_f ill_100 OUTPUT

    SELECT f1 f2 f 3 FROM tab WHERE condition.

    value-KEY = f 1.

    value-TEXT = f2

    APPEND value TO VALUES

    CALL FUNCTION 'VRM_SET_VA LUES'

    EXPORTING

    id = 'i/o screen field'

    values = values.

    ENDMODULE.

    LIST BOX with Selection Scree n

    For this the FM VRM_SET_VALUES is used to fill the value table and is passed to the parameter created w ith TYPE LISTBOX in the selection sc reen event

  • 7/22/2019 Module Pool Details Wiki

    11/13

    6/21/2014 Module pool - Application Server Infrastructure - SCN Wiki

    http://wiki.scn.sap.com/wiki/display/SI/Module+pool 1

    AT SELECTION-SCREEN.

    PROGRAM zlist

    TYPE-POOLS : VRM.

    DATA: par am TYPE vrm_id,

    values TYPE vrm_values,

    value LIKE LINE OF values.

    PARAMETERS: p_name(10) AS LISTBOX VISIBLE LENGTH 10.

    AT SELECTION-SCREEN OUTPUT.

    param = 'P_NAME'.

    value-key = '1'.

    value- text = 'JOHN'.

    APPEND value TO values.

    value-key = '2'.

    value-text = 'PETER'.

    APPEND value TO values.

    CALL FUNCTION 'VRM_SET_VA LUES'

    EXPORTING id = param

    values = values.

    6. Subscreen

    Subscreens are sc reens w hich can be embedded into another screen. These can be used and created w ith both selection screen as w ell as screen painter. They differ from normal screens in the w

    that that they don't have OK_CODE field of there ow n and there PBO and PAI transfer data to the ABAP program in which these sc reens w ere created and the cannot have module calls w hich change

    status or leave screen and module call AT EXIT-COMMAND AND E type function codes.

    In screen painter (SE51) choose the subscreen tool button and draw a subscreen area on the screen, this subscreen area w ill be used to hold the subscreen at run time. To make a subscreen selec

    the attribute screen type as subscreen and spec ify the size of the subscreen according to the size of the subscreen area in which it w ill be placed. We use ABAP statement to embed and start the flow

    logic of the subsc reen area in the PBO of a s creen. A subscreen can contain another subscreen. CALL SUBSCREEN subscreen_area INCLUDING program screen_number.

    A similar call should also exist in PAI of screen. It will also call the PAI modules of the subscreen and w ill transfer data from subscreen to ABAP program.

    CALL SUBSCREEN subscreen_area.

    Subscreen can be created in selection sc reen using ABAP statement and can be used w ith tabstrip defined on the selection scr een or w ith the screen def ined in the screen painter. SELECTION-SCRE

    BEGIN OF SCREEN screen_number AS SUBSCREEN NO-INTERVALS.

    ....

    ...

    SELECTION-SCREEN END OF SCREEN screen_number .

    To use such a subscreen w ith tabstrip defined on the selection screen w e should use the DYNNR component of the structure which is created when the tabstrip is created and specify ing the number

    the screen .We can also define the subscreen statically for such a tabstrip by using

    DEFAULT PROGRAM program SCREEN subscreen_number

    w hen declaring a tabstrip in selection screen.

    SELECTION-SCREEN BEGIN OF TABBED BLOCK tab_area FOR height LINES.

    SELECTION-SCREN TAB (w idth) tab_name USER_COMMAND funct_code DEFAULT program SCREEN subsc reen_no .

    ...

    END OF BLOCK tab_area .

    For each tabbed page TAB addition is used w ith SELECTION-SCREEN statement. At the initialization event w e can fill the tabstr ip structure to display the default s creen or specify it w ith DEFAULT additio

    tab_area-PROGRAM = SY-REPID.

    tab_area-DYNNR = subscreen_nummber.

    tab_area-ACTIVETAB = tabname. 7. Tabstrip

    This is a example code explaining the use of TabStrip in selection screen .

    *& Use of TabStrip and SubScree n explained

    *& ---- The report shows the material on one tab

    *& and plant on one tab.Pressing the execute button will show

    *& the description of the material or plant as the case is.

    *& TEXT-002 = Material Number

    *& TEXT-003 = Plant Number.

    REPORT znr1 NO STANDARD PAGE HEADING

    LINE-SIZE 80 LINE-COUNT 60.

    TABLES : sscrf ields.

    DATA activetab(6) TYPE c .

    DATA mat_des TYPE makt-maktx.

    DATA pl_des TYPE t001w -name1 .

    SELECTION-SCREEN BEGIN OF SCREEN 001 A S SUBSCREEN NO INTERVA LS.

    SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE text-002 NO

  • 7/22/2019 Module Pool Details Wiki

    12/13

    6/21/2014 Module pool - Application Server Infrastructure - SCN Wiki

    http://wiki.scn.sap.com/wiki/display/SI/Module+pool 12

    INTERVALS.

    SELECTION-SCREEN BEGIN OF LINE.

    SELECTION-SCREEN COMMENT 14(18) tex t-002 FOR FIELD matnr.

    PARAMETERS matnr TYPE mara-matnr.

    SELECTION-SCREEN END OF LINE.

    SELECTION-SCREEN END OF BLOCK block1.

    SELECTION-SCREEN END OF SCREEN 001.

    SELECTION-SCREEN BEGIN OF SCREEN 002 A S SUBSCREEN NO INTERVA LS.

    SELECTION-SCREEN BEGIN OF BLOCK block2 WITH FRAME TITLE text-003 NO

    INTERVALS.

    SELECTION-SCREEN BEGIN OF LINE.

    SELECTION-SCREEN COMMENT 14(18) tex t-003 FOR FIELD matnr.

    PARAMETERS werks TYPE t001w -w erks.

    SELECTION-SCREEN END OF LINE.

    SELECTION-SCREEN END OF BLOCK block2.

    SELECTION-SCREEN END OF SCREEN 002.

    SELECTION-SCREEN BEGIN OF TABBED BLOCK tabb1 FOR 5 LINES NO INTERVALS.

    SELECTION-SCREEN TAB (15) tabs1 USER-COMMAND ucomm1

    DEFAULT SCREEN 001.

    SELECTION-SCREEN TAB (15) tabs2 USER-COMMAND ucomm2.

    * DEFAULT SCREEN 002 .

    SELECTION-SCREEN END OF BLOCK tabb1.

    INITIALIZATION.

    tabs1 = text-002.

    tabs2 = text-003.

    activetab = 'TABS1'.

    AT SELECTION-SCREEN .

    CASE sscr fields-ucomm.

    WHEN 'UCOMM1'.

    tabb1-prog = sy-repid.

    tabb1-dynnr = 001.

    tabb1-activetab = 'TABS1'.

    activetab = 'TABS1' .

    WHEN 'UCOMM2'.

    tabb1-prog = sy-repid.

    tabb1-dynnr = 002.

    tabb1-activetab = 'TABS2'.

    activetab = 'TABS2'.

    ENDCASE.

    START-OF-SELECTION.

    CASE activetab.

    WHEN 'TABS1' .

    SELECT SINGLE maktx FROM makt INTO pl_des WHERE matnr = matnr .

    WRITE: 'Material ' , matnr , mat_des .

    WHEN 'TABS2'.

    SELECT SINGLE name1 FROM t001w INTO pl_des WHERE w erks = w erks .

    WRITE: 'Plant ' , w erks ,pl_des.

  • 7/22/2019 Module Pool Details Wiki

    13/13