Skip to Content
author's profile photo Former Member
Former Member

table controls

tell me the syntax for table controls and how to verticals seperators in table controls

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 03, 2007 at 04:20 AM

    <b>syntax:</b>

    CONTROLS <tab_ctrl_name> TYPE TABLEVIEW USING SCREEN <screen_no>.

    Have a look at the sample programs: RSDEMO_TABLE_CONTROL and DEMO_DYNPRO_TABCONT_LOOP

    Regards,

    Maha

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 03, 2007 at 04:31 AM

    check these links, it may be helpful to u.

    this link contains information about :

    1)Table Controls in ABAP Programs

    2)Looping Through an Internal Table

    3)Table Controls: Examples with Scrolling

    http://help.sap.com/saphelp_47x200/helpdata/en/9f/dbac1d35c111d1829f0000e829fbfe/frameset.htm

    Instead of using table control, use table control wizard...... very easy to populate the table.... bcoz it will automatically ask everything during its creation...ie from which database table , internal table and which all fields u want to select in the table control etc..

    This wizard allows you to create a working table control quickly and easily. It also lets you generate certain standard table maintenance functions.

    check this link....

    http://help.sap.com/saphelp_47x200/helpdata/en/6d/150d67da1011d3963800a0c94260a5/frameset.htm

    I have taken 2 screens 2nd one has table control

    code to be written in module pool is

    process before output.

    module populate_it.

    loop with control tab_ctrl.

    module status_0101.

    endloop.

    ****************************

    process after input.

    loop with control tab_ctrl.

    module modify_mod.

    endloop.

    module mod_del.

    module modify_ttab.

    *************************************************

    *Below is the code to be written in driver program

    **************************************************

    &----


    *& Module pool Z9_TBCTRL_PRASH *

    *& *

    &----


    *& *

    *& *

    &----


    program z9_tbctrl_prash.

    data: it_ekko type standard table of z9ekko_prash.

    data: it_ekpo type standard table of z9ekpo_prash.

    data: it_ekpo_del type standard table of z9ekpo_prash.

    data: wa_ekko type z9ekko_prash.

    data: wa_ekpo type z9ekpo_prash.

    data: wa_ekpo_del type z9ekpo_prash.

    data: ok_code_0100 like sy-ucomm.

    data: ok_code_0101 like sy-ucomm.

    controls: tab_ctrl type tableview using screen 0101.

    &----


    *& Module POPULATE_IT OUTPUT

    &----


    • text

    ----


    module populate_it output.

    clear it_ekpo.

    refresh it_ekpo.

    clear it_ekko.

    refresh it_ekko.

    select single ebeln bukrs aedat ernam lifnr ekorg ekgrp waers

    into corresponding fields of wa_ekko

    from z9ekko_prash where ebeln = wa_ekko-ebeln.

    append wa_ekko to it_ekko.

    • clear wa_ekko.

    select ebeln ebelp matnr werks lgort menge meins

    into corresponding fields of wa_ekpo

    from z9ekpo_prash where ebeln = wa_ekko-ebeln.

    append wa_ekpo to it_ekpo.

    clear wa_ekpo.

    endselect.

    *

    endmodule. " POPULATE_IT OUTPUT

    &----


    *& Module STATUS_0101 OUTPUT

    &----


    • text

    ----


    module status_0101 output.

    • SET PF-STATUS 'xxxxxxxx'.

    • SET TITLEBAR 'xxx'.

    read table it_ekpo into wa_ekpo index tab_ctrl-current_line.

    endmodule. " STATUS_0101 OUTPUT

    &----


    *& Module validate_ebeln INPUT

    &----


    • text

    ----


    module validate_ebeln input.

    if wa_ekko-ebeln <> ' '.

    call screen 0101.

    endif.

    endmodule. " validate_ebeln INPUT

    &----


    *& Module MODIFY_MOD INPUT

    &----


    • text

    ----


    module modify_mod input.

    modify it_ekpo from wa_ekpo index tab_ctrl-current_line.

    endmodule. " MODIFY_MOD INPUT

    &----


    *& Module MODIFY_TTAB INPUT

    &----


    • text

    ----


    module modify_ttab input.

    case ok_code_0101.

    when 'MODI'.

    modify z9ekpo_prash from table it_ekpo.

    call screen 0100.

    when 'DELE'.

    call screen 0100.

    endcase.

    endmodule. " MODIFY_TTAB INPUT

    &----


    *& Module MOD_DEL INPUT

    &----


    • text

    ----


    module mod_del input.

    case ok_code_0101.

    when 'DELE'.

    refresh it_ekpo_del.

    loop at it_ekpo into wa_ekpo.

    if wa_ekpo-mark = 'X'.

    move-corresponding wa_ekpo to wa_ekpo_del.

    append wa_ekpo_del to it_ekpo_del.

    endif.

    endloop.

    delete z9ekpo_prash from table it_ekpo_del.

    endcase.

    check this links.....

    http://help.sap.com/saphelp_nw04/helpdata/en/9f/dbac1d35c111d1829f0000e829fbfe/frameset.htm

    http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/dbac1d35c111d1829f0000e829fbfe/frameset.htm

    I hope it helps.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 03, 2007 at 07:20 AM

    check the code for it..

    In Top Include, define:

    CONTROLS <ctrl> TYPE TABLEVIEW USING SCREEN <scr>.

    (Where <ctrl> is name of table control on screen <scr>)

    Cursor Position in Table Controls

    At PBO Event

    SET CURSOR FIELD <f> LINE <lin> [OFFSET <off>].

    (For setting Cursor Position on Table Control row)

    At PAI Event

    GET CURSOR FIELD <f> LINE <lin> ...

    (For retrieving row of table control where cursor is.)

    To just get row of table control on which cursor is there:

    GET CURSOR LINE <lin>.

    Checking for Cursor Position

    SY-SUBRC allows you to check if the cursor is placed in a row of a table control.

    For getting the corresponding line of the internal table :

    GET CURSOR line <lin>.

    ind = <table_control>-top_line + <lin> - 1.

    Read table <itab> index ind.

    Add a table control element to your screen

    Give a name to the table control. In the ABAP program declare a structure with the same ( CONTROLS <tcl> type TABLEVIEW USING SCREEN <scrn >)

    To create fields go to the Dict./Program fields function.

    Enter the name of the structure whose fields you want. (If you want it to pick it from dictionary of your program click the relevant puhbutton).

    In the field list choose the fields you want and choose ok.

    Click in the table control area

    If you want a selection column , check the appropriate check box in the attributes and give it a name. Create the field in the ABAP program.

    In the PBO you should have the statement

    LOOP at <itab> USING CONTROL <cntrl_name>.

    ENDLOOP.

    In the PA I you should have.

    LOOP at <itab>.

    ENDLOOP.

    It is within the loops that data transfer happens between the screen and the internal table.

    When you populate the internal table use DESCRIBE TABLE <itab> LINES <cntrl_name>-lines, to store the total number of lines in the control.

    The FIELD statement can be used to control when the data transfer happens.

    check the sample code,it may help you:

    in top-include you declare table control as:

    CONTROLS TABSTRIPG8 TYPE TABSTRIP.

    CONTROLS ZG8TABLECONT TYPE TABLEVIEW USING SCREEN 202.

    CONTROLS ZG8TABLECONT2 TYPE TABLEVIEW USING SCREEN 203.

    IN PAI;

    module modify_line input.

    modify itabline index zg8tablecont-current_line.

    endmodule. " modify_line INPUT

    &----


    *& Module item_gen INPUT

    &----


    • text

    ----


    • generate item number automatically if not entered

    module item_gen input.

    loop at itabline.

    if itabline-ebelp is initial.

    itabline-ebelp = sy-tabix.

    endif.

    modify itabline.

    endloop.

    endmodule. " item_gen INPUT

    &----


    *& Module user_command_0202 INPUT

    &----


    • text

    ----


    module user_command_0202 input.

    data flag type c value '0'.

    case ok_code2.

    when 'ADDL'.

    • To insert or append an initial line into table control

    tabstripg8-activetab = 'LINE'.

    loop at itabline.

    if itabline-mark1 = 'X'.

    insert initial line into itabline.

    flag = '1'.

    endif.

    endloop.

    if flag <> '1'.

    append initial line to itabline.

    endif.

    clear ok_code2.

    when 'DELETEL'.

    • To delete the seleceted line from table control

    loop at itabline.

    if itabline-mark1 = 'X'.

    move-corresponding itabline to itabline_del.

    append itabline_del.

    delete itabline.

    endif.

    endloop.

    clear ok_code2.

    when 'SELECTL'.

    • To select all the rows of table control

    loop at itabline.

    itabline-mark1 = 'X'.

    modify itabline.

    endloop.

    when 'DESELECTL'.

    • To deselect the rows of table control

    loop at itabline.

    itabline-mark1 = ' '.

    modify itabline.

    endloop.

    endcase.

    endmodule. " user_command_0202 INPUT

    &----


    *& Module SCHEDULEITEMS INPUT

    &----


    • text

    ----


    module scheduleitems input.

    case ok_code2.

    when 'header'.

    • Activate TAB_ITEM tabstrip

    tabstripg8-activetab = 'header'.

    when 'LINE'.

    • Activate TAB_ITEM tabstrip

    tabstripg8-activetab = 'LINE'.

    when 'SCHEDULE'.

    • Activate TAB_ITEM tabstrip

    tabstripg8-activetab = 'SCHEDULE'.

    loop at itabline.

    clear itabschedule.

    if itabline-mark1 = 'X'.

    itabschedule-ebelp = itabline-ebelp.

    append itabschedule.

    itabline-mark1 = ' '.

    modify itabline.

    endif.

    endloop.

    loop at itabline_del.

    delete itabschedule where ebelp = itabline_del-ebelp.

    endloop.

    refresh itabline_del.

    endcase.

    endmodule. " SCHEDULEITEMS INPUT

    &----


    *& Module MODIFY INPUT

    &----


    • text

    ----


    module modify input.

    modify itabschedule index zg8tablecont2-current_line.

    endmodule. " MODIFY INPUT

    &----


    *& Module USER_COMMAND_0203 INPUT

    &----


    • text

    ----


    module user_command_0203 input.

    flag = '0'.

    case ok_code2.

    when 'ADDS'.

    • To insert or append an initial line into table control

    loop at itabschedule.

    if itabschedule-mark2 = 'X'.

    insert initial line into itabschedule.

    flag = '1'.

    endif.

    endloop.

    if flag <> '1'.

    append initial line to itabschedule.

    endif.

    when 'DELETES'.

    • To delete the seleceted line from table control

    loop at itabschedule.

    if itabschedule-mark2 = 'X'.

    move-corresponding itabschedule to itabschedule_del.

    append itabschedule_del.

    delete itabschedule.

    endif.

    endloop.

    when 'SELECTS'.

    • To select all the rows of table control

    loop at itabschedule.

    itabschedule-mark2 = 'X'.

    modify itabschedule.

    endloop.

    when 'DESELECTS'.

    • To deselect the rows of table control

    loop at itabschedule.

    itabschedule-mark2 = ' '.

    modify itabschedule.

    endloop.

    endcase.

    endmodule. " USER_COMMAND_0203 INPUT

    &----


    *& Module SORT INPUT

    &----


    • text

    ----


    module sort input.

    sort itabschedule by ebelp.

    endmodule. " SORT INPUT

    &----


    *& Module QUANTITYCHECK INPUT

    &----


    • text

    ----


    module quantitycheck input.

    IF TABSTRIPG8-activetab = 'SCHEDULE' AND

    ok_code2 <> 'ADDS' AND ok_code2 <> 'DELETES' AND

    ok_code2 <> 'SELECTS' AND ok_code2 <> 'DESELECTS'.

    • LOOP AT ITABLINE.

    • CLEAR ITABSCHEDULE-menge.

    • qty = 0.

    • LOOP AT ITABSCHEDULE WHERE ebelp = ITABLINE-ebelp.

    • qty = qty + ITABSCHEDULE-menge.

    • ENDLOOP.

    • CLEAR ITABSCHEDULE-menge.

    • IF qty <> ITABLINE-menge AND qty <> 0.

    • MESSAGE

    • 'Quantity must be equal to the item quatity ITABLINE-menge '

    *TYPE 'I'.

    • CLEAR ok_code2.

    *

    • ENDIF.

    • ENDLOOP.

    LOOP AT ITABSCHEDULE.

    IF ITABSCHEDULE-menge IS INITIAL .

    MESSAGE 'Quantity should not be initial' TYPE 'I'.

    CLEAR ok_code2.

    ENDIF.

    ENDLOOP.

    ENDIF.

    endmodule. " QUANTITYCHECK INPUT

    &----


    *& Module exit1 INPUT

    &----


    • text

    ----


    MODULE exit1 INPUT.

    LEAVE PROGRAM.

    ENDMODULE. " exit1 INPUT

    &----


    *& Module DATECHECK INPUT

    &----


    • text

    ----


    MODULE DATECHECK INPUT.

    IF ITABSCHEDULE-EINDT LT SY-DATUM.

    MESSAGE 'DELIVERY DATE IS INVALID' TYPE 'E'.

    ENDIF.

    ENDMODULE. " DATECHECK INPUT

    IN PBO:

    &----


    *& Include ZGR08O01 *

    &----


    &----


    *& Module STATUS_0100 OUTPUT

    &----


    • text

    ----


    module status_0100 output.

    set pf-status 'SCREEN100'.

    set titlebar 'TITLE100'.

    endmodule. " STATUS_0100 OUTPUT

    &----


    *& Module STATUS_0200 OUTPUT

    &----


    • text

    ----


    module status_0200 output.

    IF SY-TCODE EQ 'ZPURCH_GR8' OR SY-TCODE EQ 'ZPURCR_GR8'.

    set pf-status 'SCREEN200' EXCLUDING 'PRINT'.

    ELSE.

    set pf-status 'SCREEN200'.

    ENDIF.

    set titlebar 'TITLE200'.

    • TABSTRIPG8-ACTIVETAB = 'HEADER'.

    endmodule. " STATUS_0200 OUTPUT

    &----


    *& Module MODIFYSCREEN OUTPUT

    &----


    • text

    ----


    *modifying the screen layout according to the transaction called

    module modifyscreen output.

    case sy-tcode.

    when 'ZPURCR_GR8'.

    set titlebar 'TITLE1'.

    loop at screen.

    if screen-name eq 'DISPLAY' or screen-name eq 'MODIFY'.

    screen-input = 0.

    modify screen.

    endif.

    endloop.

    when 'ZPURDIS_GR8'.

    set titlebar 'TITLE2'.

    loop at screen.

    if screen-name ne 'ZG8_EKKO-EBELN' and screen-name ne 'DISPLAY'.

    screen-input = 0.

    modify screen.

    endif.

    endloop.

    when 'ZPURCH_GR8'.

    loop at screen.

    • To disable the create, display and print pushbutton.

    if screen-name = 'CREATE' or screen-name = 'DISPLAY'.

    screen-input = 0.

    modify screen.

    endif.

    endloop.

    endcase.

    endmodule. " MODIFYSCREEN OUTPUT

    &----


    *& Module INITIALIZATION OUTPUT

    &----


    • text

    ----


    *getting the net price from line item and showing it in header details *

    module initialization output.

    progname = sy-repid.

    dynnum = sy-dynnr.

    loop at itabline.

    if itabline-p_netpr is not initial.

    sum.

    zg8_ekko-netpr = itabline-NETPR.

    endif.

    endloop.

    endmodule. " INITIALIZATION OUTPUT

    &----


    *& Module PROCESS202 OUTPUT

    &----


    • text

    ----


    module process202 output.

    case sy-tcode.

    when 'ZPURCR_GR8' or 'ZPURCH_GR8'.

    • Check if the no of line is empty or not.

    if lin ne 0.

    loop at screen.

    • To make the screen editable.

    screen-input = 1.

    endloop.

    else.

    loop at screen.

    if screen-name cs 'ITABLINE'.

    • To make the screen non-editable.

    screen-input = 0.

    modify screen.

    endif.

    endloop.

    endif.

    when 'ZPURDIS_GR8'.

    loop at screen.

    • To make screen non editable .

    screen-input = 0.

    modify screen.

    endloop.

    endcase.

    endmodule. " PROCESS202 OUTPUT

    &----


    *& Module STATUS_0202 OUTPUT

    &----


    • text

    ----


    module status_0202 output.

    • SET PF-STATUS 'xxxxxxxx'.

    • SET TITLEBAR 'xxx'.

    describe table itabline lines lin.

    zg8tablecont-lines = lin.

    *deactivating the push buttons when display transaction is called

    if sy-tcode eq 'ZPURDIS_GR8'.

    loop at screen.

    if screen-group1 = 'GR1'.

    screen-active = 0.

    modify screen.

    endif.

    endloop.

    endif.

    endmodule. " STATUS_0202 OUTPUT

    &----


    *& Module PROCESS203 OUTPUT

    &----


    • text

    ----


    module process203 output.

    case sy-tcode.

    when 'ZPURCR_GR8' or 'ZPURCH_GR8'.

    • Check if the no of line is empty or not.

    if lins ne 0.

    loop at screen.

    • To make the screen editable.

    screen-input = 1.

    endloop.

    else.

    loop at screen.

    if screen-name cs 'ITABSCHEDULE'.

    • To make the screen non-editable.

    screen-input = 0.

    modify screen.

    endif.

    endloop.

    endif.

    when 'ZPURDIS_GR8'.

    loop at screen.

    • To make screen non editable .

    screen-input = 0.

    modify screen.

    endloop.

    endcase.

    endmodule. "process203 OUTPUT

    &----


    *& Module status_0203 OUTPUT

    &----


    • text

    ----


    module status_0203 output.

    *Sort the schedule internal table by item number .

    sort itabschedule by ebelp.

    • To find out the number of lines in internal table

    describe table itabschedule lines lins.

    zg8tablecont2-lines = lins.

    • deactivating the push buttons when called in display mode

    if sy-tcode eq 'ZPURDIS_GR8'.

    loop at screen.

    if screen-group1 = 'GR2'.

    screen-active = 0.

    modify screen.

    endif.

    endloop.

    endif.

    endmodule. " status_0203 OUTPUT

    &----


    *& Module STATUS_0201 OUTPUT

    &----


    • text

    ----


    module status_0201 output.

    • SET PF-STATUS '201STATUS'.

    • SET TITLEBAR 'xxx'.

    case sy-tcode.

    when 'ZPURDIS_GR8'.

    loop at screen.

    if screen-name cs 'ZG8_EKKO' .

    • To make screen element non editable in display mode.

    screen-input = 0.

    modify screen.

    endif.

    endloop.

    endcase.

    endmodule. " STATUS_0201 OUTPUT

    &----


    *& Module STATUS_0300 OUTPUT

    &----


    • text

    ----


    *MODULE STATUS_0300 OUTPUT.

    • SET PF-STATUS 'xxxxxxxx'.

    • SET TITLEBAR 'xxx'.

  • MODAL_PRICE = ITABLINE-P_NETPR.

  • MODAL_UNIT = ITABLINE-MEINS.

  • MODAL_CURRENCY = ITABLINE-P_WAERS.

  • CLEAR OK_CODEM.

  • *

    *ENDMODULE. " STATUS_0300 OUTPUT

Add a comment
10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 03, 2007 at 09:02 AM

    hi,

    syntax is

    CONTROLS: <Table Control Name> TYPE TABLEVIEW USING SCREEN <Screen Number>.

    For Separators, open property window of table control by double clicking on it,

    In Attribute there is one option, Separators..

    Tick that

    reward if useful..

    Add a comment
    10|10000 characters needed characters exceeded

  • Before answering

    You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
    You must be Logged in to submit an answer.

    Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.