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 Member
0 Likes
379

Hi,

I m new to modulepool.When i click the update radio button in report output then table control should open with table fields.

But 2 colums shld be disabled and other 3 colums shld be updatable.

User can change the existing values then update the new data in table.

Pls send step by step..

Regards,

Sudha.

3 REPLIES 3
Read only

Former Member
0 Likes
356

1) Create table control in screen.

2) Now put(drag and drop) input/output fields in the table control. While you define the name of these fields also at the bottom mention whether they are input fields or output fields. This way you can have the fields updatable.

3) Your screen flow logic should have a logic similar to this for your table control where FIELDS is your table control.

PROCESS BEFORE OUTPUT.

MODULE fields_change_tc_attr.

LOOP AT gt_fields

INTO gs_fields

WITH CONTROL fields

CURSOR fields-current_line.

MODULE fields_get_lines.

ENDLOOP.

*

PROCESS AFTER INPUT.

LOOP AT gt_fields.

CHAIN.

FIELD gs_fields-name.

FIELD gs_fields-desc.

ENDCHAIN.

ENDLOOP.

MODULE fields_user_command.

MODULE user_command_0100.

4) In these modules you can read and display desired data by filling data in an intermal table, here gt_fields.

<b>PS :- You may also create these table control using the SAP wizard, the icon is just under the icon for table control. It is very fast and saves a lot of work.</b>

Let me know if this is helpful, in case you dont understand something, I may help you with more information if required.

Read only

Former Member
0 Likes
356

Hello Sudha karan,

Please check the transaction ABAP DOCU with the example

REPORT demo_dynpro_tabcont_loop_at.

in ABAP userdialogs ->Screens -> complex screen elements -> eg:Table control with modifications

The output shows two colums as display mode and 2 as editable when using a button which is the same scenario you are requested to implement in SAP system

Please check the example

REPORT demo_dynpro_tabcont_loop_at.

<b>"Data and table control declarations</b>

CONTROLS flights TYPE TABLEVIEW USING SCREEN 100.

DATA: cols LIKE LINE OF flights-cols,

lines TYPE i.

DATA: ok_code TYPE sy-ucomm,

save_ok TYPE sy-ucomm.

DATA: itab TYPE TABLE OF demo_conn.

TABLES demo_conn.

<b>"Data fetching</b>

SELECT * FROM spfli INTO CORRESPONDING FIELDS OF TABLE itab.

<b>"Hiding the first 2 columns permenantly</b>

LOOP AT flights-cols INTO cols WHERE index GT 2.

cols-screen-input = '0'.

MODIFY flights-cols FROM cols INDEX sy-tabix.

ENDLOOP.

<b>"Calling screen with the table control</b>

CALL SCREEN 100.

<b>"PBO Of screen 100</b>

PROCESS BEFORE OUTPUT.

MODULE STATUS_0100.

LOOP AT ITAB INTO DEMO_CONN WITH CONTROL FLIGHTS.

ENDLOOP.

<b>"PAI of screen 100</b>

PROCESS AFTER INPUT.

MODULE CANCEL AT EXIT-COMMAND.

LOOP AT ITAB.

module read_table_control.

ENDLOOP.

module user_command_0100.

"PBO module

MODULE status_0100 OUTPUT.

SET PF-STATUS 'SCREEN_100'.

<b> "Counting the internal table lines</b>

DESCRIBE TABLE itab LINES lines.

flights-lines = lines.

ENDMODULE.

<b>"PAI MODULES for screen 100</b>

MODULE cancel INPUT. "Back button

LEAVE PROGRAM.

ENDMODULE.

<b>"Modify data of a line from screen if user changes it</b>

MODULE read_table_control INPUT.

MODIFY itab FROM demo_conn INDEX flights-current_line.

ENDMODULE.

<b>"Capturing user command</b>

MODULE user_command_0100 INPUT.

save_ok = ok_code.

CLEAR ok_code.

CASE save_ok.

WHEN 'TOGGLE'.<b> "the diplay-change mode button on the screen</b>

LOOP AT flights-cols INTO cols WHERE index GT 2.

IF cols-screen-input = '0'.

cols-screen-input = '1'.

ELSEIF cols-screen-input = '1'.

cols-screen-input = '0'.

ENDIF.

MODIFY flights-cols FROM cols INDEX sy-tabix.

ENDLOOP.

WHEN 'SORT_UP'.<b> "the sort up button action on the screen</b>

READ TABLE flights-cols INTO cols WITH KEY selected = 'X'.

IF sy-subrc = 0.

SORT itab STABLE BY (cols-screen-name+10) ASCENDING.

cols-selected = ' '.

MODIFY flights-cols FROM cols INDEX sy-tabix.

ENDIF.

WHEN 'SORT_DOWN'. <b> "the sort down button action on the screen</b>

READ TABLE flights-cols INTO cols WITH KEY selected = 'X'.

IF sy-subrc = 0.

SORT itab STABLE BY (cols-screen-name+10) DESCENDING.

cols-selected = ' '.

MODIFY flights-cols FROM cols INDEX sy-tabix.

ENDIF.

WHEN 'DELETE'. <b> "deleting a row from screen</b>

READ TABLE flights-cols INTO cols WITH KEY screen-input = '1'.

IF sy-subrc = 0.

LOOP AT itab INTO demo_conn WHERE mark = 'X'.

DELETE itab.

ENDLOOP.

ENDIF.

ENDCASE.

ENDMODULE.

Hope it gave you a clear picture

<b>Pls reward all helpful answers as an encouragement to thier commitment towards helping</b>

Regards

Byju

Read only

former_member196299
Active Contributor
0 Likes
356

hi Sudha,

This is only a suggestion : Y dt you try changing the attributes of table control columns as ' Inactive ' in the PAI event of your screen .

Regards,

Ranjita