Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

disable rows in table control

Former Member
0 Kudos

Hi ,

I want to disable the rows in table control . Here is the code I wrote to fill the table control .

Please advise .

LOOP WITH CONTROL table_TC.

MODULE FILL_CONTROL.

ENDLOOP.

MODULE FILL_CONTROL.

..

..

SELECT * INTO TABLE itab FROM ztable

WHERE WERKS = S_ztable_TMP-WERKS

AND NORMT = S_ztable__TMP-NORMT.

READ TABLE itabe

INDEX table_TC-CURRENT_LINE.

IF SY-SUBRC = 0.

MOVE-CORRESPONDING itab TO table.

ELSE.

EXIT FROM STEP-LOOP.

ENDIF.

For disabling the rows I tried this but get an error message

""LOOP" cannot be assigned to any field."

LOOP AT itab WITH CONTROL table_TC.

MODULE CLEAR_OUTPUT.

ENDLOOP.

Thanks !!

Teresa

Edited by: Teresa lytle on Apr 8, 2008 5:22 PM

Edited by: Alvaro Tejada Galindo on Apr 8, 2008 1:16 PM

1 ACCEPTED SOLUTION

Former Member
0 Kudos

in your PBO routine


*&spwizard: module TC_TEST1_change_tc_attr.
*&spwizard: module TC_TEST1_change_col_attr.
  loop at   g_TC_TEST1_itab
       into g_TC_TEST1_wa
       with control TC_TEST1
       cursor TC_TEST1-current_line.
    module TC_TEST1_change_field_attr   "<== Here change your screen attributes.
    module TC_TEST1_move.
  endloop.

4 REPLIES 4

Former Member
0 Kudos

hi.,,,,

Try this :

In PAI write :

loop at tablecontrol.

module modify_table_control.

endloop.

Module modify_table_control.

IF sy-tabix LE 3.

CASE sy-ucomm.

WHEN 'CHANGE'.

LOOP AT screen.

IF screen-name = tablecontrol-field.

Screen-input = 0.

modify screen.

ENDLOOP.

ENDIF.

<REMOVED BY MODERATOR>

rekha

Edited by: Alvaro Tejada Galindo on Apr 8, 2008 11:25 AM

Former Member
0 Kudos

in your PBO routine


*&spwizard: module TC_TEST1_change_tc_attr.
*&spwizard: module TC_TEST1_change_col_attr.
  loop at   g_TC_TEST1_itab
       into g_TC_TEST1_wa
       with control TC_TEST1
       cursor TC_TEST1-current_line.
    module TC_TEST1_change_field_attr   "<== Here change your screen attributes.
    module TC_TEST1_move.
  endloop.

0 Kudos

when i do this i still get this error message .

0 Kudos

Teresa,

I wrote a very simple program to test this. I have a single column table for just a salesperson number.

I made a simple module that while it was going thru the attr changing, I simply flipped the intesified flag on and off on alternating rows

of the table. This code worked on v4.6c.

I hope this can help you. The only thing I can't show you is the actual screen which only has the Table Control (which started the wizard by adding it on the screen) on it.. and I had the Wizard add the INSERT and DELETE buttons so I could prove the program.

The Flow Logic for the screen



PROCESS BEFORE OUTPUT.

  MODULE init_table.

*&spwizard: pbo flow logic for tablecontrol 'TC_TEST1'
  MODULE tc_test1_change_tc_attr.
*&spwizard: module TC_TEST1_change_col_attr.
  LOOP AT   it_wk
       INTO wk_rec
       WITH CONTROL tc_test1
       CURSOR tc_test1-current_line.

    MODULE tc_test1_get_lines.

    MODULE tc_test1_change_field_attr.   "<== here is the module call for the attribute setting
  ENDLOOP.


  MODULE status_0100.
*
PROCESS AFTER INPUT.
*&spwizard: pai flow logic for tablecontrol 'TC_TEST1'
  LOOP AT it_wk.
    CHAIN.
      FIELD wk_rec-spnum.

      MODULE tc_test1_modify ON CHAIN-REQUEST.
    ENDCHAIN.
    FIELD wk_rec-sel
      MODULE tc_test1_mark ON REQUEST.
  ENDLOOP.

  MODULE tc_test1_user_command.
*&spwizard: module TC_TEST1_change_tc_attr.
*&spwizard: module TC_TEST1_change_col_attr.


  MODULE exit_0100 AT EXIT-COMMAND.


  MODULE user_command_0100.

the _TOP Include


*&---------------------------------------------------------------------*
*& Include YPTC_SCREEN_TEST_TOP                                        *
*&                                                                     *
*&---------------------------------------------------------------------*

PROGRAM  yptc_screen_test              .

DATA:
  switch  TYPE c,
  ok_code LIKE sy-ucomm.

TABLES:   zsd_act_salespr.

DATA:
  BEGIN OF wk_rec.
        INCLUDE STRUCTURE zsd_act_salespr.
DATA:
    sel    TYPE c,
  END OF wk_rec,
  it_wk   LIKE STANDARD TABLE OF wk_rec.

*&spwizard: declaration of tablecontrol 'TC_TEST1' itself
controls: TC_TEST1 type tableview using screen 0100.

*&spwizard: lines of tablecontrol 'TC_TEST1'
data:     g_TC_TEST1_lines  like sy-loopc.

The _I01 include


*----------------------------------------------------------------------*
*   INCLUDE YPTC_SCREEN_TEST_I01                                       *
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Module  exit_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE exit_0100 INPUT.
  LEAVE TO SCREEN 0.
ENDMODULE.                 " exit_0100  INPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
  ok_code = ok_code.
  CASE ok_code.
    WHEN 'ENTER'.
    WHEN 'SAVE'.
  ENDCASE.
ENDMODULE.                 " USER_COMMAND_0100  INPUT

*&spwizard: input module for tc 'TC_TEST1'. do not change this line!
*&spwizard: modify table
MODULE tc_test1_modify INPUT.
  MODIFY it_wk
    FROM wk_rec
    INDEX tc_test1-current_line.
ENDMODULE.

*&spwizard: input modul for tc 'TC_TEST1'. do not change this line!
*&spwizard: mark table
MODULE tc_test1_mark INPUT.
  DATA: g_tc_test1_wa2 LIKE LINE OF it_wk.
  IF tc_test1-line_sel_mode = 1.
    LOOP AT it_wk INTO g_tc_test1_wa2
      WHERE sel = 'X'.
      g_tc_test1_wa2-sel = ''.
      MODIFY it_wk
        FROM g_tc_test1_wa2
        TRANSPORTING sel.
    ENDLOOP.
  ENDIF.
  MODIFY it_wk
    FROM wk_rec
    INDEX tc_test1-current_line
    TRANSPORTING sel.
ENDMODULE.

*&spwizard: input module for tc 'TC_TEST1'. do not change this line!
*&spwizard: process user command
MODULE tc_test1_user_command INPUT.
  ok_code = sy-ucomm.
  PERFORM user_ok_tc USING    'TC_TEST1'
                              'IT_WK'
                              'SEL'
                     CHANGING ok_code.
  sy-ucomm = ok_code.
ENDMODULE.

The O01 Include


***INCLUDE YPTC_SCREEN_TEST_O01 .
*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'STAT_0100'.
*  SET TITLEBAR 'xxx'.

ENDMODULE.                 " STATUS_0100  OUTPUT


*&---------------------------------------------------------------------
*&      Module  TC_TEST1_change_field_attr  OUTPUT
*&---------------------------------------------------------------------
MODULE tc_test1_change_field_attr OUTPUT.

  LOOP AT SCREEN.
    IF screen-name EQ 'WK_REC-SPNUM'.
      IF switch EQ 'X'.
        screen-intensified = 1.
        CLEAR switch.
      ELSE.
        screen-intensified = 0.
        switch = 'X'.
      ENDIF.
      MODIFY SCREEN.
    ENDIF.
  ENDLOOP.
ENDMODULE.                 " TC_TEST1_change_field_attr  OUTPUT

*&spwizard: output module for tc 'TC_TEST1'. do not change this line!
*&spwizard: update lines for equivalent scrollbar
module TC_TEST1_change_tc_attr output.
  describe table IT_WK lines TC_TEST1-lines.
endmodule.

*&spwizard: output module for tc 'TC_TEST1'. do not change this line!
*&spwizard: get lines of tablecontrol
module TC_TEST1_get_lines output.
  g_TC_TEST1_lines = sy-loopc.
endmodule.
*&---------------------------------------------------------------------*
*&      Module  init_table  OUTPUT
*&---------------------------------------------------------------------*
module init_table output.

  if it_wk is initial.
    select * into table it_wk
      from ZSD_ACT_SALESPR.
  endif.

endmodule.                 " init_table  OUTPUT

The F01 Include


*----------------------------------------------------------------------*
*   INCLUDE YPTC_SCREEN_TEST_F01                                       *
*----------------------------------------------------------------------*

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

*-BEGIN OF LOCAL DATA--------------------------------------------------*
   DATA: L_OK              TYPE SY-UCOMM,
         L_OFFSET          TYPE I.
*-END OF LOCAL DATA----------------------------------------------------*

* Table control specific operations                                    *
*   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.
* 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             .

*-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.
*-END OF LOCAL DATA----------------------------------------------------*

   ASSIGN (P_TC_NAME) TO <TC>.

* 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

* get looplines of TableControl
   CONCATENATE 'G_' P_TC_NAME '_LINES' INTO L_LINES_NAME.
   ASSIGN (L_LINES_NAME) TO <LINES>.

* 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 and new cursor 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.
* insert initial line
   INSERT INITIAL LINE INTO <TABLE> INDEX L_SELLINE.
   <TC>-LINES = <TC>-LINES + 1.
* 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   .

*-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>.
*-END OF LOCAL DATA----------------------------------------------------*

   ASSIGN (P_TC_NAME) TO <TC>.

* 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

* delete marked lines                                                  *
   DESCRIBE TABLE <TABLE> LINES <TC>-LINES.

   LOOP AT <TABLE> ASSIGNING <WA>.

*   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.
*-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.
*-END OF LOCAL DATA----------------------------------------------------*

   ASSIGN (P_TC_NAME) TO <TC>.
* get looplines of TableControl
   CONCATENATE 'G_' P_TC_NAME '_LINES' INTO L_TC_LINES_NAME.
   ASSIGN (L_TC_LINES_NAME) TO <LINES>.


* is no line filled?                                                   *
   IF <TC>-LINES = 0.
*   yes, ...                                                           *
     L_TC_NEW_TOP_LINE = 1.
   ELSE.
*   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.

* 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.
*     set actual column                                                *
       SET CURSOR FIELD L_TC_FIELD_NAME LINE 1.
     ENDIF.
   ENDIF.

* 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.
*-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>.
*-END OF LOCAL DATA----------------------------------------------------*

  ASSIGN (P_TC_NAME) TO <TC>.

* 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

* mark all filled lines                                                *
  LOOP AT <TABLE> ASSIGNING <WA>.

*   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 .
*-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>.
*-END OF LOCAL DATA----------------------------------------------------*

  ASSIGN (P_TC_NAME) TO <TC>.

* 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

* demark all filled lines                                              *
  LOOP AT <TABLE> ASSIGNING <WA>.

*   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

Edited by: Paul Chapman on Apr 8, 2008 7:15 PM