08-13-2010 9:07 AM
Hi,
I have created a table control using the wizard and its working fine (save happening.0
the problem is that when I press 'ADD or INSR' records button, the new empty row gets created at last however, it shud occur at the top of the displayed records.
I am not able to find out the reason that why is it happening at the bottom of the displayed records.
can anybody help here?
thanks.,
Ravish
08-13-2010 11:05 AM
Hi Ravish,
" At table control level in Screen painter you need to create the Row selector ( I took Single row selector)
" In Flow Logic " After selecting row of table control then Click on insert button
PROCESS BEFORE OUTPUT.
MODULE status_0100.
LOOP AT itab WITH CONTROL tc.
ENDLOOP.
PROCESS AFTER INPUT.
LOOP AT itab.
MODULE MODIFY_TC. " This module Transfers the data from Screen to Program's ITab
ENDLOOP.
" In program
module status_100.
if ok_code = 'INS'
clear OK.
READ TABLE itab WITH KEY mark = 'X'. " If you want for multiple rows then replace the READ with LOOP AT key word
IF sy-subrc = 0.
INSERT INITIAL LINE INTO itab INDEX sy-tabix. " This is a test Code snippet
ENDIF.
ENDIF.
LOOP AT itab WHERE mark = 'X'.
itab-mark = ' '.
MODIFY itab INDEX sy-tabix.
ENDLOOP.
endloop.
module Modify_tc.
DESCRIBE TABLE itab LINES tc-lines.
IF tc-lines > tc-current_line.
MODIFY itab INDEX tc-current_line.
ELSE.
* APPEND itab.
ENDIF.
endmodule
" IF you dont have a Row selector and just place the Cursor in a row and Press INSERT button then follow below code
DATA : lv_line TYPE i.
DESCRIBE TABLE itab LINES tc-lines.
IF tc-lines > tc-current_line.
IF ok = 'INS'.
CLEAR ok.
GET CURSOR LINE lv_line.
lv_line = tc-top_line + lv_line - 1.
ENDIF.
* CLEAR itab-mark.
IF tc-current_line = lv_line.
itab-mark = 'X'.
ENDIF.
MODIFY itab INDEX tc-current_line.
ELSE.
* APPEND itab.
ENDIF.
Cheerz
Ram