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

experts plz do smthng help me

i have an internal table itab

which contains22 rows now i want to exchange the position of row no 22 with row p

plz write the code 4 it

plz help me

thanx in advance

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jul 11, 2007 at 07:43 AM

    Hi,

    read table itab into wa1 index 22.

    read table itab into wa2 index p.

    w = wa1.

    wa1 = wa2.

    wa2 = w.

    modify itab by wa1.

    modify itab by wa2.

    Reward if useful!

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 11, 2007 at 08:06 AM

    I think the code below will help u..

    check it .. some modification may be required.. let me know it helps u..

    <b>

    DATA: BEGIN OF itab OCCURS 0,

    fld TYPE i,

    END OF itab,

    wa LIKE LINE OF itab.

    FIELD-SYMBOLS: <fs_wa> LIKE itab.

    INITIALIZATION.

    DO 22 TIMES.

    wa-fld = sy-index.

    APPEND wa TO itab.

    ENDDO.

    START-OF-SELECTION.

    LOOP AT itab ASSIGNING <fs_wa>.

    READ TABLE itab INTO wa INDEX 22.

    MODIFY itab INDEX 22 FROM <fs_wa>.

    <fs_wa> = wa.

    ENDLOOP.</b>

    Reward points if useful

    regards

    Prax

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 11, 2007 at 08:22 AM

    MODIFY ITAB FROM WA.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      bro thanx 4 rply

      it is helpful

      but what it is doin it is deleting the entry at 5th position and replacing it with entry at index 22

      i want to insert the entry at index 22 to the index 5.

      plz help me

      reward points will b awarded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 11, 2007 at 09:21 AM

    Hi,

    please check this :

    data : begin of itab occurs 0,

    field(1),

    end of itab.

    data wa like itab-field.

    data n type i.

    data idx type i value 2.

    *ITAB contains :

    *A

    *B

    *C

    move 'A' to itab-field.

    append itab.

    move 'B' to itab-field.

    append itab.

    move 'C' to itab-field.

    append itab.

    *Getting index of last entry from ITAB

    describe table itab lines n.

    *Reading last entry of ITAB

    read table itab index n into wa.

    *Inserting it to wished position

    insert wa into itab index idx.

    *Deleting last entry (don't forget to increment the index as there is 1 more entry in ITAB now)

    n = n + 1.

    delete itab index n.

    *ITAB now contains

    *A

    *C

    *B

    loop at itab.

    write :/ itab-field.

    endloop.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 11, 2007 at 10:16 AM

    thank u all u guys r experts

    thank u very much

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 11, 2007 at 09:09 AM

    check this

    
    tables : mara.
    data : begin of itab occurs 0,
           matnr like mara-matnr,
           matkl like mara-matkl,
           end of itab.
    data : wtab like itab.
    select matnr mtart into table itab from mara up to 22 rows.
    
    read table itab into wtab index 22.
    
    insert  wtab into itab index 5.
    
    delete itab index 23.
    
    loop at itab.
    write : / itab-matnr, itab-matkl.
    endloop.
    

    regards

    shiba dutta

    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.