Skip to Content
author's profile photo
Former Member

Selecting committed entries only from tablesa

Hi,

We are having problems with validation wherein whenever we select from the table, we also select uncommitted values in the table.

Our objective is to select only the committed entries (inside a BADI -> BADI_MATERIAL_CHECK). The problem is there are inserts or updates that are not yet committed as per LUW but when it gets selected, it's already reflecting there (while not reflecting in SE11).

Is there a way to do it? Thanks.

Add comment
10|10000 characters needed characters exceeded

2 Answers

  • Posted on May 03, 2011 at 03:11 PM

    I'm not sure there is a way, but if there was I don't think it would be a good practice to do it.

    If the data which you are trying to avoid has already been inserted/updated in the database, is it not reasonable to assume that it is valid data, and should be considered in your validation? For example, if you are trying to create Material A, and texts for Material A (which would require Material A to be valid) in the same LUW, than wouldn't you want to include Material A in your validation selection?

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on May 03, 2011 at 07:18 PM

    basically what we wanted to know is if the data was already existing before or not but not really related to the value. The operation in the BADI would differ when it's a new entry or a modification.

    Add comment
    10|10000 characters needed characters exceeded

    • In situations like these I tend to ask myself "What Would SAP Do?". In many cases, they will maintain a number of buffer tables in the global memory of a function group, each containing either records which have been read, records which have been created, records which have been updated, or records which have been deleted in this LUW. Usually there will be one function group per database table (for example, MG21 for table MARA; MG22 for table MARC; etc.).

      If you are using standard FMs to do the updates, you might want to look around in that FM's function group, or other function groups in the package, to see if there are any FMs which will return the buffer tables. (Although you should always use extra caution when calling non-released FMs).

      Otherwise if you are updating the DB directly, you can maintain such buffer tables in the BADI implementing class (or a custom FG would be especially helpful if you're updating custom table(s) that are used elsewhere).

      I know it sounds like a lot of work but it's worth it. The next guy to work on this code will thank you.