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

unable get the table scroll for table control

hai

i unable get horizontal scrolling for table control when the output is dislayed

help me

very urgent

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jul 12, 2007 at 04:50 AM

    Hi,

    check out the sample program it might help you

    See the following simple ex

    *& Module pool ZTEST_TBLCTRL

    *&

    &----


    *&

    *&

    &----


    PROGRAM ZTEST_TBLCTRL.

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

    *&SPWIZARD: DEFINITION OF DDIC-TABLE

    TABLES: ZFG_SRNO, ZFIH0004.

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

    *TYPES: BEGIN OF T_TC1,

    • ZSRNO LIKE ZFG_SRNO-ZSRNO,

    • SCRNAME LIKE ZFIH0004-SCRNAME,

  • END OF T_TC1.

  • *TYPES: BEGIN OF T_TC1.

    • STRUCTURE ZFG_SRNO.

    • END OF T_TC1.

    *&SPWIZARD: INTERNAL TABLE FOR TABLECONTROL 'TC1'

    *DATA: G_TC1_ITAB TYPE T_TC1 OCCURS 0 WITH HEADER LINE,

    • G_TC1_WA TYPE T_TC1. "work area

    DATA: G_TC1_ITAB LIKE ZFG_SRNO OCCURS 0 WITH HEADER LINE,

    G_TC1_WA LIKE G_TC1_ITAB. "work area

    DATA: G_TC1_COPIED. "copy flag

    *&SPWIZARD: DECLARATION OF TABLECONTROL 'TC1' ITSELF

    CONTROLS: TC1 TYPE TABLEVIEW USING SCREEN 0100.

    *&SPWIZARD: LINES OF TABLECONTROL 'TC1'

    DATA: G_TC1_LINES LIKE SY-LOOPC.

    DATA: OK_CODE LIKE SY-UCOMM,

    S_CODE LIKE SY-UCOMM,

    MARK.

    DATA: T1(10).

    *&SPWIZARD: OUTPUT MODULE FOR TC 'TC1'. DO NOT CHANGE THIS LINE!

    *&SPWIZARD: COPY DDIC-TABLE TO ITAB

    MODULE TC1_INIT OUTPUT.

    • IF G_TC1_COPIED IS INITIAL.

    *&SPWIZARD: COPY DDIC-TABLE 'ZFG_SRNO'

    *&SPWIZARD: INTO INTERNAL TABLE 'g_TC1_itab'

    • SELECT * FROM ZFG_SRNO

    • INTO CORRESPONDING FIELDS

    • OF TABLE G_TC1_ITAB.

    • G_TC1_COPIED = 'X'.

    • REFRESH CONTROL 'TC1' FROM SCREEN '0100'.

    IF T1 <> SPACE.

    G_TC1_ITAB-ZSRNO = T1.

    CLEAR T1.

    APPEND G_TC1_ITAB.

    REFRESH CONTROL 'TC1' FROM SCREEN '0100'.

    ENDIF.

    *TC1-TOP_LINE = 1.

    • ENDIF.

    ENDMODULE.

    *&SPWIZARD: OUTPUT MODULE FOR TC 'TC1'. DO NOT CHANGE THIS LINE!

    *&SPWIZARD: MOVE ITAB TO DYNPRO

    MODULE TC1_MOVE OUTPUT.

    MOVE-CORRESPONDING G_TC1_WA TO ZFG_SRNO.

    • if sy-subrc ne 0.

    *append G_TC1_WA to G_TC1_ITAB.

    *endif.

    • READ TABLE G_TC1_ITAB INDEX TC1-CURRENT_LINE.

    • IF SY-SUBRC = 0.

    • G_TC1_WA-ZSRNO = G_TC1_ITAB-ZSRNO.

    • ENDIF.

    • MOVE-CORRESPONDING G_TC1_ITAB TO ZFG_SRNO.

    • REFRESH CONTROL 'TC1' FROM SCREEN '8001'.

    *******Below line is the logic for scrolling.

    tc1-lines = G_TC1_LINES + 100.

    ENDMODULE.

    *&SPWIZARD: OUTPUT MODULE FOR TC 'TC1'. DO NOT CHANGE THIS LINE!

    *&SPWIZARD: GET LINES OF TABLECONTROL

    MODULE TC1_GET_LINES OUTPUT.

    G_TC1_LINES = SY-LOOPC.

    ENDMODULE.

    *&SPWIZARD: INPUT MODULE FOR TC 'TC1'. DO NOT CHANGE THIS LINE!

    *&SPWIZARD: MODIFY TABLE

    MODULE TC1_MODIFY INPUT.

    *break-point.

    • MOVE-CORRESPONDING ZFG_SRNO TO G_TC1_ITAB.

    • MODIFY G_TC1_ITAB INDEX TC1-CURRENT_LINE.

    • G_TC1_COPIED = 'X'.

    • REFRESH CONTROL 'TC1' FROM SCREEN '8001'.

    MOVE-CORRESPONDING ZFG_SRNO TO G_TC1_WA.

    MODIFY G_TC1_ITAB

    FROM G_TC1_WA

    INDEX TC1-CURRENT_LINE.

    G_TC1_COPIED = 'X'.

    if sy-subrc ne 0.

    append G_TC1_WA to G_TC1_ITAB.

    endif.

    *modify G_TC1_ITAB INDEX TC1-CURRENT_LINE.

    ENDMODULE.

    *&SPWIZARD: INPUT MODULE FOR TC 'TC1'. DO NOT CHANGE THIS LINE!

    *&SPWIZARD: PROCESS USER COMMAND

    MODULE TC1_USER_COMMAND INPUT.

    OK_CODE = SY-UCOMM.

    PERFORM USER_OK_TC USING 'TC1'

    'G_TC1_ITAB'

    'FLAG'

    CHANGING OK_CODE.

    SY-UCOMM = OK_CODE.

    ENDMODULE.

    ----


    • 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 'L--'. "total left

    • PERFORM FCODE_TOTAL_LEFT USING P_TC_NAME.

    *

    • WHEN 'L-'. "column left

    • PERFORM FCODE_COLUMN_LEFT USING P_TC_NAME.

    *

    • WHEN 'R+'. "column right

    • PERFORM FCODE_COLUMN_RIGHT USING P_TC_NAME.

    *

    • WHEN 'R++'. "total right

    • PERFORM FCODE_TOTAL_RIGHT USING P_TC_NAME.

    *

    WHEN 'MARK'. "mark all filled lines

    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.

    • WHEN 'SASCEND' OR

    • 'SDESCEND'. "sort column

    • PERFORM FCODE_SORT_TC USING P_TC_NAME

    • l_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

    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>

    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----


    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 D20XX_INIT OUTPUT

    &----


    • text

    ----


    MODULE D20XX_INIT OUTPUT.

    *if screen-name = 'ZSRNO'.

    • SCREEN-INPUT = 0.

    • SCREEN-COLOR = 0.

    • MODIFY SCREEN.

    • endif.

    ENDMODULE. " D20XX_INIT OUTPUT

    &----


    *& Module STATUS_0100 OUTPUT

    &----


    • text

    ----


    MODULE STATUS_0100 OUTPUT.

    • SET PF-STATUS 'xxxxxxxx'.

    • SET TITLEBAR 'xxx'.

    *CLEAR R1_REF.

    • DO 30 TIMES.

    • APPEND G_TC1_ITAB.

    • ENDDO.

    DESCRIBE TABLE G_TC1_ITAB LINES TC1-LINES.

    ENDMODULE. " STATUS_0100 OUTPUT

    &----


    *& Module TAB1_INIT OUTPUT

    &----


    • text

    ----


    MODULE TAB1_INIT OUTPUT.

    ENDMODULE. " TAB1_INIT OUTPUT

    &----


    *& Module USER_COMMAND_0100 INPUT

    &----


    • text

    ----


    MODULE USER_COMMAND_0100 INPUT.

    ENDMODULE. " USER_COMMAND_0100 INPUT

    &----


    *& Module MESSAGE INPUT

    &----


    • text

    ----


    MODULE MESSAGE INPUT.

    OK_CODE = SY-UCOMM.

    S_CODE = OK_CODE.

    CLEAR OK_CODE.

    if S_CODE = 'DELE'.

    loop at G_TC1_ITAB.

    • if G_TC1_ITAB-scrname = 'X'.

    • delete g_tc1_itab.

    • endif.

    endloop.

    ELSEIF S_CODE = 'SAVE'.

    G_TC1_WA-ZSRNO = T1.

    MOVE-CORRESPONDING G_TC1_WA TO ZFG_SRNO.

    REFRESH CONTROL 'TC1' FROM SCREEN '0100'.

    ENDIF.

    ENDMODULE. " MESSAGE INPUT

    &----


    *& Module DELETE_RECORD INPUT

    &----


    • text

    ----


    MODULE DELETE_RECORD INPUT.

    IF MARK = 'X' AND S_CODE = 'DELE'.

    DELETE TABLE G_TC1_ITAB FROM ZFG_SRNO.

    DESCRIBE TABLE G_TC1_ITAB LINES TC1-LINES.

    ENDIF.

    ENDMODULE. " DELETE_RECORD INPUT

    *********************Screen modules*********************

    PROCESS BEFORE OUTPUT.

    *&SPWIZARD: PBO FLOW LOGIC FOR TABLECONTROL 'TC1'

    MODULE TC1_INIT.

    *&SPWIZARD: MODULE TC1_CHANGE_TC_ATTR.

    *&SPWIZARD: MODULE TC1_CHANGE_COL_ATTR.

    LOOP AT G_TC1_ITAB

    INTO G_TC1_WA

    WITH CONTROL TC1

    CURSOR TC1-CURRENT_LINE.

    *&SPWIZARD: MODULE TC1_CHANGE_FIELD_ATTR

    MODULE TC1_MOVE.

    • MODULE TAB1_INIT.

    • MODULE TC1_GET_LINES.

    ENDLOOP.

    MODULE D20XX_INIT.

    MODULE STATUS_0100.

    *

    PROCESS AFTER INPUT.

    *&SPWIZARD: PAI FLOW LOGIC FOR TABLECONTROL 'TC1'

    *BREAK POINT.

    LOOP AT G_TC1_ITAB.

    CHAIN.

    FIELD ZFG_SRNO-ZSRNO.

    MODULE TC1_MODIFY ON CHAIN-REQUEST.

    • MODULE TC1_MODIFY.

    ENDCHAIN.

    MODULE MESSAGE .

    MODULE DELETE_RECORD.

    ENDLOOP.

    MODULE TC1_USER_COMMAND.

    *&SPWIZARD: MODULE TC1_CHANGE_TC_ATTR.

    *&SPWIZARD: MODULE TC1_CHANGE_COL_ATTR.

    MODULE USER_COMMAND_0100.

    please check out the link below for more information it might help you

    http://help.sap.com/saphelp_sm32/helpdata/en/9f/dbac9f35c111d1829f0000e829fbfe/content.htm

    http://help.sap.com/saphelp_nw04/helpdata/en/d1/801c7b454211d189710000e8322d00/content.htm

    http://www.sapbrainsonline.com/REFERENCES/ABAP_SYNTAX/SAP_ABAP_SYNTAX.html

    *********please reward points if the information is helpful to you*************

Add a comment
10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 12, 2007 at 04:50 AM

    Hi

    Generally we don't keep radiobuttons in table control for selecting the records

    We keep check boxes for selecting the records

    Radio button is used to select a single from a group of records and at a time only one is selected, where as checkboxes at a time you can select a single or multiple.

    So use checkboxes and code correctly see the doc for Table control

    syntax:

    CONTROLS

    Regards

    Ashu

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 12, 2007 at 04:52 AM

    Hi shravan,

    In the screen painter, there is an option horizontal scrolling and vertical scrolling, select those checkboxex, that would reflect in your output.

    Regards,

    Prasanth

    *Kindly reward points, if helpful

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 12, 2007 at 04:54 AM
    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.