02-14-2008 5:37 AM
Hi,
Please could anyone tell me how can we capture a particular line that we have selected in a table control .
Regards,
Sushanth H.S.
02-14-2008 5:42 AM
Hi Sushanth,
DOUBLE CLICK IN TABLE CONTROL
Hi,
In your PF-STATUS enable F2 giving an okcode.
( You can find it in PF-STATUS -> Function keys -> Recommeneded function keys)
Once you enable this and activate any doubleclick on the screen will create the ok code you assign and control comes to PAI.
Where you write the statement
if sy-ucomm eq 'CLICK'.
GET CURSOR FIELD ws_field LINE ws_line.
endif.
If ws_field contains the field on which the user clicked and ws_line contains the line no. of ur table control.
GREY OUT ROWS IN TABLE CONTROL
demo_dynpro_tabcont_loop_at
<b>Reward points if this helps.
Manish</b>
02-14-2008 5:49 AM
See the following ex:
&----
*& Module DEL_REC INPUT
&----
text
----
MODULE DEL_REC INPUT.
data: txt(50) type c,
ans(1).
OK_CODE = SY-UCOMM.
S_CODE = OK_CODE.
CLEAR OK_CODE.
*SL is name given in Table Attricbue w/Selection col field.
**If SL = 'X' then that record is selected
IF SL = 'X' AND S_CODE = 'DEL'.
IF G_TC1_WA-ZSRNO <> SPACE.
clear: txt, ans.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
TITLEBAR = 'Confirm'
DIAGNOSE_OBJECT = ' '
TEXT_QUESTION = txt
TEXT_BUTTON_1 = 'YES'
ICON_BUTTON_1 = ' '
TEXT_BUTTON_2 = 'NO'
ICON_BUTTON_2 = ' '
DEFAULT_BUTTON = '1'
DISPLAY_CANCEL_BUTTON = ' '
USERDEFINED_F1_HELP = ' '
START_COLUMN = 25
START_ROW = 6
POPUP_TYPE =
IV_QUICKINFO_BUTTON_1 = ' '
IV_QUICKINFO_BUTTON_2 = ' '
IMPORTING
ANSWER = ans
TABLES
PARAMETER =
EXCEPTIONS
TEXT_NOT_FOUND = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
if ans = '1'.
CLEAR G_IDX.
DELETE TABLE G_TC1_ITAB FROM G_TC1_WA.
IF SY-SUBRC = 0.
DELETE FROM ZBRCODE_TEMP WHERE ZSRNO = G_TC1_WA-ZSRNO.
clear: SL, ans, S_CODE.
endif.
ENDIF.
ENDIF.
ENDMODULE. " DEL_REC INPUT
02-14-2008 6:31 AM
hi,
declare a variable..then/...
var1 = >tablecontrol>-current_line.
then
read table <itab used for tabcntrl> into wa index var1.
Hope this helps.
Regards,
Renjith Michael.
02-14-2008 7:10 AM
Hi Sushanth Srinivas,
Add a field of type char length 1 in your internal table like this
Data :
begin of itab occurs 0,
sel_box type c,
- - - - -
- - - -
end of itab.
In SE51 when you create a table control do this,
Give the selection box ( your field SEl_box ).
So in your program when looping in your table.
itab-sel_box = 'X' then this line is selected line in your table control.
See this example code:
FORM save_submit CHANGING pr_it_timesheet LIKE it_timesheet.
LOOP AT pr_it_timesheet INTO fs_timesheet
WHERE c_box EQ c_char_x. - - - - c_box is for recognise selected or not
To fill the complete record as the user entered record structure
varies from the actual database record structure
PERFORM fill_timesheet USING fs_timesheet
CHANGING fs_temp_ts.
MODIFY zcl_timesheet FROM fs_temp_ts.
IF sy-subrc EQ 0.
DELETE pr_it_timesheet INDEX sy-tabix.
IF sy-subrc EQ 0.
CASE w_okcode.
WHEN c_fcode_save.
MESSAGE s025 WITH text-015.
WHEN c_fcode_submit.
MESSAGE s025 WITH text-014.
ENDCASE. " CASE W_OKCODE
ENDIF. " IF SY-SUBRC EQ 0
ENDIF. " IF SY-SUBRC EQ 0
ENDLOOP. " LOOP AT PR_IT_TIMESHEET
ENDFORM. " SAVE_DATA
Reward if it is useful,
Mahi.