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

After INSERTING entry into database table, the table is not sorted by keys

Does anybody know why when I insert a record into a database table from workarea, the record is inserted into the database table but the table is no longer sorted by the keys? The workarea is defined using:

<i>data: wa type dbtable.</i>

After populating the fields in wa:

<i>insert dbtable from wa</i>

The key for database table is a sequencial counter number <b>(INT4)</b>. For instance, after the insert, counter number equals to 10 is inserted into the dbtable <u>between</u> 8 and 9 instead of <u>after</u> 9. (Table content is displayed thru SE16) Also, I realized that all other fields besides the key, are sorted and according to that sorting, entry with counter number 10 is supposed to be between #8 and #9 but theologically if the database table is supposed to be sorted by key fields, shouldn't the entry be inserted after #9?

Any advice is appreciated. Thank you.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 08, 2005 at 06:10 PM

    Hi guys,

    Thanks for all the responses. Apparently our requirements is to use SE16 to display the table entry and determine which records has problem based on the sequence number, i.e. the key field. Thus, the table entry displayed in SE16 has to be sorted in the key field. There is a work around by using the "sorting" function in SE16 everytime when displaying the table entry but it is not the first preference.

    With looking at the situation on how the table entries are appearing on SE16 after being inserted by the INSERT command, it is always appearing in SE16 that the table is 'sorted' order of the non-primary key fields. We are also trying to debug the program of SE16 to see if there is any special 'sorting' before it displayed the data onto the screen.

    Again, thanks for the responses.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 08, 2005 at 03:44 AM

    Minami,

    I am not clear what exactly you are expecting. Are you expecting to see the data in the database table to be sorted? If that is the case, I don't think that would be the case.

    When ever you fetch the data into a internal table, you can fetch that into a sorted internal table and that will SORTED. The data inside the database table will NOT be sorted.

    Regards

    Ravi

    Note : Please reward the posts that help you.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 08, 2005 at 04:00 AM

    Hi Minami,

    I think what you should do is do a select on the table and see if you get it in the sorted order. For all you know, SE16 or SM30 is only a GUI to view the DB entries. Even if this gives it to you in sorted order, that doesnt gurantee in what order it is stored in the DB.

    And how does the order in which it is stored in the DB matter anyway ?

    Pls reward points and close this thread, if your Q is answered.

    Rgds,

    Prabhu.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 08, 2005 at 04:44 AM

    Hi Minami,

    1. Welcome to SDN.

    2. Even though a table has a primary key,

    it does not mean that after inserting a record

    in a database table,

    then after viewing it in SE16 / SE11

    it will appear in a sorted manner !!!

    3. No, it won't appear sorted.

    (Try any table, for eg. MARA)

    4. The DATABASE stores the records,

    in its own fashion.

    While retireiving thru SQL, however,

    we can specify the sorting order.

    5. Since u are new to the forum, let me introduce

    to the forum etiquette.

    If u find any answer useful, u may award

    points by clicking on the STAR which appears

    to the left of the reply .

    U may please award points to the repliy(s)

    which u found useful.

    Regards,

    Amit M.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 08, 2005 at 04:37 AM

    Hi Minami,

    please give us the table layout (indicating key fields) and list the first few entries to demonstrate how the 'sort' is occurring and indicate how you would expect it to be. Does the table have a MANDT before your key field?

    Regards

    Neil

    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.