Skip to Content
author's profile photo Former Member
Former Member

How to process internal table

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 31, 2007 at 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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 31, 2007 at 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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.