‎2007 Jan 31 11:30 PM
Hi friends/experts,
My case is:
1. A dialog screen 100 to display/ update some fields of an internal table itab, Records are processed one by one on the screen
2. Need UPDATE, DELETE, PREV. NEXT buttons to process records.
I have made the screen with fields and buttons. What I like to know is how to code DELETE, PREV. and NEXT buttons. Could you kindly provide a sample to do that?
Thanks.
Yu
‎2007 Jan 31 11:40 PM
Hi,
check this sample code..
***Create a global variable for storing the current index that is getting displayed..
***I am assuming V_CURRENT_INDEX TYPE SYINDEX.
CASE SY-UCOMM.
WHEN 'NEXT'.
INcrement the index.
V_CURRENT_INDEX = V_CURRENT_INDEX + 1.
DESCRIBE TABLE ITAB.
IF V_CURRENT_INDEX > SY-TFILL.
If the current index is greater than the number of rows.
set the sy-tfill.
V_CURRENT_INDEX = SY-TFILL.
MESSAGE S208(00) WITH 'Last record reached'.
LEAVE SCREEN.
ENDIF.
Read the internal table with the current index.
READ TABLE ITAB INDEX V_CURRENT_INDEX.
Move the values to the screen variables from the header line of ITAB.
WHEN 'PREV'.
Decrement the counter.
V_CURRENT_INDEX = V_CURRENT_INDEX - 1.
IF V_CURRENT_INDEX < 0.
If the current index is Lesser than zero set 1.
V_CURRENT_INDEX = 1.
MESSAGE S208(00) WITH 'First record reached'.
LEAVE SCREEN.
ENDIF.
Read the internal table with the current index.
READ TABLE ITAB INDEX V_CURRENT_INDEX.
Move the values to the screen variables from the header line of ITAB.
*
ENDCASE.
Thanks,
Naren
‎2007 Jan 31 11:58 PM
Hi,
Check this for delete logic..
CASE SY-UCOMM.
WHEN 'DELETE'.
**Get the number of rows..
DESCRIBE TABLE ITAB.
IF SY-TFILL = 1.
**delete the record.
DELETE ITAB INDEX 1.
MESSAGE S208(00) WITH 'All records deleted'.
LEAVE PROGRAM.
ENDIF.
**Delete the record and decrement the index.
DELETE ITAB INDEX V_CURRENT_INDEX.
MESSAGE S208(00) WITH 'Record deleted'.
Decrement the counter.
V_CURRENT_INDEX = V_CURRENT - 1.
READ TABLE ITAB INDEX V_CURRENT_INDEX.
***Move the values from ITAB header line to screen work area..
ENDCASE.
Thanks,
Naren