Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to process internal table

Former Member
0 Likes
475

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

2 REPLIES 2
Read only

Former Member
0 Likes
432

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

Read only

Former Member
0 Likes
432

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