Skip to Content
0
Former Member
Aug 16, 2005 at 04:28 AM

regarding table control

18 Views

Regarding Table control.

I copied table control demo program from "abapdocu" and tried with my own table "vbak".

But Sort up and Sort down and delete control is not working with table control.

however "toggle" button displays/change function works fine.

Could you pls tell me the place to change my code...

ambichan.

Dynpro screen.

PROCESS BEFORE OUTPUT. "PBO

MODULE STATUS_0200.

LOOP AT ITAB INTO vbak WITH CONTROL tabctrl.

ENDLOOP.

-


PROCESS AFTER INPUT. "PAI

MODULE CANCEL AT EXIT-COMMAND.

LOOP AT ITAB.

module read_table_control.

ENDLOOP.

MODULE USER_COMMAND_0200.

-


***************************************************:

Main Report Program

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

REPORT ZTABLECONTROL .

TABLES VBAK.

CONTROLS tabctrl TYPE TABLEVIEW USING SCREEN 200.

DATA: cols LIKE LINE OF tabctrl-cols,

lines TYPE i.

DATA: ok_code TYPE sy-ucomm,

save_ok TYPE sy-ucomm.

DATA: itab TYPE TABLE OF vbak.

SELECT * FROM vbak INTO CORRESPONDING FIELDS OF TABLE itab.

LOOP AT tabctrl-cols INTO cols WHERE index GT 1.

cols-screen-input = '0'.

MODIFY tabctrl-cols FROM cols INDEX sy-tabix.

ENDLOOP.

CALL SCREEN 200.

MODULE status_0200 OUTPUT.

SET PF-STATUS 'SCREEN_200'.

DESCRIBE TABLE itab LINES lines.

tabctrl-lines = lines.

ENDMODULE.

MODULE read_table_control INPUT.

MODIFY itab FROM vbak INDEX tabctrl-current_line.

ENDMODULE.

&----


*& Module USER_COMMAND_0200 INPUT

&----


  • text

----


MODULE USER_COMMAND_0200 INPUT.

save_ok = ok_code.

CLEAR ok_code.

CASE save_ok.

WHEN 'TOGGLE'.

LOOP AT tabctrl-cols INTO cols WHERE index GT 1. IF

cols-screen-input = '0'.

cols-screen-input = '1'.

ELSEIF cols-screen-input = '1'.

cols-screen-input = '0'.

ENDIF.

MODIFY tabctrl-cols FROM cols INDEX sy-tabix.

ENDLOOP.

WHEN 'SORT_UP'.

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

IF sy-subrc = 0.

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

cols-selected = ' '.

MODIFY tabctrl-cols FROM cols INDEX sy-tabix.

ENDIF.

WHEN 'SORT_DOWN'.

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

IF sy-subrc = 0.

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

cols-selected = ' '.

MODIFY tabctrl-cols FROM cols INDEX sy-tabix.

ENDIF.

WHEN 'DELETE'.

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

IF sy-subrc = 0.

LOOP AT itab INTO vbak.

DELETE itab.

ENDLOOP.

ENDIF.

ENDCASE.

ENDMODULE. " USER_COMMAND_0200 INPUT

&----


*& Module read_table_control OUTPUT

&----


MODULE read_table_control OUTPUT.

MODIFY itab FROM vbak INDEX tabctrl-current_line.

ENDMODULE. " read_table_control OUTPUT

&----


*& Module CANCEL INPUT

&----


MODULE CANCEL INPUT.

LEAVE PROGRAM.

ENDMODULE. " CANCEL INPUT