‎2008 Dec 17 10:18 AM
I have created a table control with selection column. How do I detect when a row is selected using the selection column? Must the selection column created as pushbutton so that I could make use of ok code? My current settings is table_control_name-LINE_SEL_MODE = 1. Please advise. Thank you
‎2008 Dec 17 10:33 AM
hi,
the internal table that you use for table control fields ,take a field in internal table BOX TYPE C.
when you define selection clm you write the name of this box there.
now you can use as
if <itab-box> eq 'X'.
endif.
‎2008 Dec 17 10:42 AM
Hi Big Mug,
Use this code, to use the selection column in the table control.
TOP Module
program sapmz_tabctrl message-id zmsg.
CONTROLS : po_tab TYPE TABLEVIEW USING SCREEN '8002'. "table control
TYPES : BEGIN OF t_ekpo,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
matnr TYPE ekpo-matnr,
werks TYPE ekpo-werks,
menge TYPE ekpo-menge,
netpr TYPE ekpo-netpr,
flag(1), "flag for selection column in table control
END OF t_ekpo.
"check the select column for the table in attributes and name it as wa_ekpo-flag
DATA : it_ekpo TYPE STANDARD TABLE OF t_ekpo, "internal table
wa_ekpo TYPE t_ekpo. "work area
At screen flow logic
PROCESS BEFORE OUTPUT.
MODULE status_8002.
LOOP WITH CONTROL po_tab. "po_tab is the name of table control on screen
MODULE pass_data. "pass data from internal table into table control on screen
ENDLOOP.
PROCESS AFTER INPUT.
MODULE user_command_8002.
LOOP WITH CONTROL po_tab. "po_tab is the name of table control on screen
MODULE modify_data. "modify data into the internal table from table control
ENDLOOP.
PBO Module
MODULE status_8002 OUTPUT.
SET PF-STATUS 'ZTG_SELTB'.
DATA : line_count TYPE i.
DESCRIBE TABLE it_ekpo
LINES line_count.
po_tab-lines = line_count + 5.
ENDMODULE. " STATUS_8002 OUTPUT
MODULE pass_data OUTPUT.
READ TABLE it_ekpo into wa_ekpo INDEX po_tab-current_line.
ENDMODULE. " PASS_DATA OUTPUT
PAI Module
MODULE USER_COMMAND_8002 INPUT.
OK_CODE = SY-UCOMM.
CASE OK_CODE.
WHEN 'BACK'.
LEAVE TO SCREEN 8001.
WHEN 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_8002 INPUT
MODULE MODIFY_DATA INPUT.
MODIFY IT_EKPO INDEX PO_TAB-CURRENT_LINE FROM WA_EKPO.
ENDMODULE. " MODIFY_DATA INPUT
Hope this solves your problem.
Thanks & Regards
Tarun Gambhir
‎2008 Dec 17 11:26 AM
I think I have created wrongly during the table control creation using wizard. I did it like this:
1) define at TOP
TYPES: BEGIN OF gty_item,
line(1) type c,
maktx type goitem-maktx,
take_it type goitem-take_it,
erfmg type goitem-erfmg,
lgobe type goitem-lgobe,
END OF gty_item.
DATA: gt_item TYPE STANDARD TABLE OF gty_item,
gwa_item LIKE LINE OF gt_item.
2) create table control with wizard
I entered gt_item for table and gwa_item for work area. Then at fields selection, i select all the above fields. When I need to set the selection column, I typed in gwa_item-line, but it returned message of no such field in table. What does that mean? Therefore I typed in line instead.. but now it doesn't seem to work. I guess I have defined the wrong selection column. Please advise.
Edited by: big mug on Dec 18, 2008 2:52 AM
‎2008 Dec 18 3:01 AM
Hi,
Use current_line:
MODULE check INPUT.
MODIFY it_zmara INDEX t_ctrl-current_line.
IF t_ctrl-current_line GT ln.
READ TABLE it_zmara WITH KEY matnr = it_zmara-matnr.
IF sy-subrc NE 0.
*INSERTING REC IF IT DOES NOT EXIST
APPEND it_zmara.
ELSE.
MESSAGE i005 WITH 'MATERIAL NO.' it_zmara-matnr
'ALREADY EXIST'.
ENDIF.
ENDIF.
ENDMODULE. " CHECK INPUT
Thanks,
Krishna...
‎2008 Dec 18 3:02 AM