Application Development and Automation 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: 
Read only

Table Control

former_member227596
Participant
0 Likes
847

Dear Ababpers,

I want to change the attributes of Table control Columns during programe run. Pl. help me. i.e when I make changes in row, it will allow me to block modification of 2 columns data.

regards Vikas

1 ACCEPTED SOLUTION
Read only

former_member196299
Active Contributor
0 Likes
822

hi Vikas ,

try like this ,

LOOP AT SCREEN.

IF screen-name = 'table_control screen field name1 ' and

IF screen-name = 'table_control screen field name2'

screen-input = 0. " for making the field display mode

ENDIF.

MODIFY SCREEN.

ENDLOOP.

Regards,

Ranjita

9 REPLIES 9
Read only

Former Member
0 Likes
822

Inside the PBO LOOP, write the following:

LOOP AT SCREEN.

IF screen-name = 'FIELD1'.

screen-input = 0. " Will make the field display only.

ENDIF.

MODIFY SCREEN.

ENDLOOP.

Hope this helps.

Sudha

Read only

former_member196299
Active Contributor
0 Likes
823

hi Vikas ,

try like this ,

LOOP AT SCREEN.

IF screen-name = 'table_control screen field name1 ' and

IF screen-name = 'table_control screen field name2'

screen-input = 0. " for making the field display mode

ENDIF.

MODIFY SCREEN.

ENDLOOP.

Regards,

Ranjita

Read only

0 Likes
822

Dear Ranjita,

In Table Control. One column is wfeature2-MARK1.

how I can use this field as non-updateable.

When my form opens, table control is non-updateable. When I click on Button, the Wfeature2-Mark1 should be as output & other fields are updateable.

Pl. help.

regards

Vikas

Read only

0 Likes
822

Vikas,

Do it like this ,

In PBO of your program , inside a module , write this logic ,

case sy-ucomm.

when 'PUSH-BUTTON' .

loop at screen .

if screen-name = ' WFEATURE2-MARK1' .

screen-output = 0. " to make WFEATURE2-MARK field display only

else.

screen-output = 1. "to make other fields input enebled .

endif.

modify screen .

endloop.

endcase.

This should solve your problem, else write back .

If your problem is solved then ,reward points and mark the thread as answered .

Regards,

Ranjita

Read only

0 Likes
822

Hi ranjita,

I have done same as u have written in Mail. But field still updateable.

regards

Vikas

Read only

0 Likes
822

Can u post your complete code here ...?

Regards,

Ranjita

Read only

0 Likes
822

Dear Ranjita,

Following is the souce code for the programe.

regards

Vikas

PROGRAM demo_dynpro_input_output .

tables : zfeature1,kna1.

*DATA:Wfeature type zfeature3 .

*DATA:Wfeature1 type zfeature3 .

data : begin of wfeature2 occurs 0,

VNUMBER like zfeature1-vnumber,

KUNNR like zfeature1-kunnr,

DOFEATURE like zfeature1-dofeature,

EXFEATURE like zfeature1-exfeature,

ETFEATURE like zfeature1-etfeature,

PRICE like zfeature1-price,

CURR like zfeature1-curr,

mark1 type C value ' ',

mark type C value ' '.

data : end of wfeature2.

data : begin of wfeature3 occurs 0.

include structure wfeature2.

data : end of wfeature3.

data:wtind type c.

DATA flag(1) TYPE c.

data: ww type c length 50.

CONTROLS: FLIGHTS TYPE TABLEVIEW USING SCREEN 0100.

DATA: cols LIKE LINE OF flights-cols,

lines TYPE i.

call screen 100.

*DATA: begin of wfeature2.

  • LIKE zfeature3 OCCURS 0 WITH HEADER LINE.

*CONTROLS flights TYPE TABLEVIEW USING SCREEN 100.

*&SPWIZARD: DECLARATION OF TABLECONTROL 'FLIGHTS' ITSELF

*&SPWIZARD: LINES OF TABLECONTROL 'FLIGHTS'

DATA: G_FLIGHTS_LINES LIKE SY-LOOPC.

DATA: OK_CODE LIKE SY-UCOMM.

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

*&SPWIZARD: UPDATE LINES FOR EQUIVALENT SCROLLBAR

MODULE FLIGHTS_CHANGE_TC_ATTR OUTPUT.

DESCRIBE TABLE WFEATURE2 LINES FLIGHTS-lines.

ENDMODULE.

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

*&SPWIZARD: GET LINES OF TABLECONTROL

MODULE FLIGHTS_GET_LINES OUTPUT.

G_FLIGHTS_LINES = SY-LOOPC.

ENDMODULE.

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

*&SPWIZARD: PROCESS USER COMMAND

MODULE FLIGHTS_USER_COMMAND INPUT.

OK_CODE = SY-UCOMM.

PERFORM USER_OK_TC USING 'FLIGHTS'

'WFEATURE2'

' '

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

&----


  • text

----


MODULE USER_COMMAND_0100 INPUT.

  • CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'

  • EXPORTING

  • PERCENTAGE = 0

  • TEXT = ' '.

*message i003(003) with sy-ucomm.

CASE SY-UCOMM.

.

  • message i001(006) with sy-ucomm.

WHEN 'CANCEL' or 'BACK'.

LEAVE PROGRAM.

WHEN 'ADD'.

select * from zfeature1 into corresponding fields of TABLe wfeature2.

WHEN 'REFRESH'.

refresh wfeature2.

clear wfeature2.

WHEN 'NEWENTRY'.

loop at wfeature2.

concatenate wfeature2-dofeature wfeature2-exfeature wfeature2-etfeature into wfeature2-dofeature.

modify wfeature2.

endloop.

if screen-input = '1'.

move ' ' to wfeature2.

  • cols-screen-input = '0'.

append wfeature2.

endif.

.

WHEN 'DELETE'.

  • data: ww type c length 50.

  • READ TABLE wfeature2 with key wtind = 'X'.

  • CHECK SY-SUBRC EQ 0.

  • clear ww.

  • concatenate wfeature2-vnumber ' - ' wfeature2-kunnr wtind into ww.

  • message s001(005) with ww. .

DELETE wfeature2 where mark1 = 'X'.

when 'DDC'.

WHEN 'SELECTED'.

MESSAGE i888(sabapdocu) WITH wfeature2-vnumber..

.

<b> WHEN 'TOGGLE'.

IF flag = ' '.

flag = 'X'.

ELSEIF flag = 'X'.

flag = ' '.

ENDIF.

loop at screen.

if screen-name = 'WFEATURE2-MARK1'.

message s100(100) with 'Help'.

screen-output = 0.

ELSE.

message s100(100) with 'Help1'.

screen-output = 1.

endif.

modify screen.

endloop.</b>

WHEN 'PICK'.

  • message s001(005) with wfeature3-kunnr wfeature3-vnumber screen-input.

  • mark1-input = 0.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

At line-selection.

message s100(100) with 'Line Selection'.

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE STATUS_0100 OUTPUT.

SET PF-STATUS 'PF001'.

SET TITLEBAR 'T01'.

LOOP AT SCREEN.

  • IF screen-group1 = 'MOD'.

IF flag = ' '.

screen-input = '0'.

ELSEIF flag = 'X'.

screen-input = '1'.

ENDIF.

MODIFY SCREEN.

  • ENDIF.

ENDLOOP.

ENDMODULE. " STATUS_0100 OUTPUT

INCLUDE Z_VIKAS_DIALOG112_CHECK_MARI01.

&----


*& Module check_mark INPUT

&----


  • text

----


MODULE check_mark INPUT.

wfeature2-mark1 = wfeature2-mark.

MODIFY wfeature2 INDEX flights-CURRENT_LINE.

ENDMODULE. " check_mark INPUT

&----


*& Module CREATE_DROPDOWN_BOX INPUT

&----


  • text

----


MODULE CREATE_DROPDOWN_BOX INPUT.

SELECT vnumber dofeature

FROM zfeature1

INTO CORRESPONDING FIELDS OF TABLE wfeature3.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'VNUMBER'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = WFEATURE3

EXCEPTIONS

PARAMETER_ERROR = 1

NO_VALUES_FOUND = 2

OTHERS = 3.

IF SY-SUBRC <> 0.

...

ENDIF.

ENDMODULE. " CREATE_DROPDOWN_BOX INPUT

Read only

0 Likes
822

hi Vikas ,

Try with this ... remove the loop at stmt ..

In your screen-field , double click on the field , in the attributes tab , in program tabstrip, change to Output only .This makes your screen field input disabled . I guess this might be the problem ...

Regards,

Ranjita

Read only

0 Likes
822

Thanks Ranjita, it works

Vikas