Flipkart.com

Tuesday, March 8, 2011

Logical Units of Work in ABAP, (LUWs in SAP)

LUWs are one of the least understood concept in ABAP, even by experienced ABAPers. More over it is one of the most important concept in ABAP.

Knowledge of SAP Transactions, SAP LUW and Database LUW is crucial in ensuring that your database updates does not result in inconsistent data.

Let us take an example: 
Consider a Transaction (ABAP program), where intention is to Debit Rs 50 from account A, and credit those Rs 50 into account B.
Say debit from account A is successful. But when there was a credit of Rs 50 to account B, an error happens hence crediting did not happen. Bust as you have noticed, debiting from account A is already odne, and now this Rs 50 is lost. ( Neither in Account A, nor in Account B )

Transaction: An application transaction, possibly containing multiple screens, where multiple tables need to be updated.


Database LUW: System's approach of updating database. Either an update happens completely or does not happen at all. System has fixed rules, based on which a DB LUW ends/starts.

SAP LUW: A series of logically related updates. Ideally an SAP LUW should contain only one DB LUW, to enure that data in consistent. If a SAP LUW is spread across several DB LUWs, it can result in inconsistent data.

Rules related to Database LUW
Current DB LUW ends, and new one starts:
1. While moving form one screen to another screen (as soon a dialog step completes).
2. While calling a RFC
3. While exiting from and RFC
4. When encouters a WAIT statement
5. When any message is sent to dialogue. (Information, warning, error)
6. When COMMIT WORK statement is encountered
7. When function module DB_COMMIT is called.


Example of defective programming.
<-------------------------------SAP Transaction----------------------------------->
<---------------SAP LUW-------------><-------------SAP LUW----------------->
<--DB LUW--><--DB LUW--><--DB LUW--><--DB LUW--><--- DB LUW-->


Example of right programming technique.
<-------------------------------SAP Transaction----------------------------------->
<---------------SAP LUW-------------><-------------SAP LUW----------------->
<--------------DB LUW---------------><-----------------DB LUW--------------->

Why cant I use ROLLBACK statement?
ROLLBACK statement scope in only within a DBLUW. I.e. only the changes done within the current DB LUW will be undone. Changes done in previous DB LUWs will not be undone.

How to ensure that an SAP LUW contains only one DB LUW?
There are two approaches
1. Using CALL FUNCTION  ............... IN UPDATE TASK statement.
2. Using PERFORM ....... ON COMMIT statement.

Other approach
This approach can be specially used/needed in HR Function modules.
Example: Creating a Org Unit and relationships. Requirement is that either Org Unit and all its relationships should get created, else nothing should get created.

In this approach we use FMs that provide option to handle buffers. These FMs have an import parameter VTASK, If VTASK is passed as 'B', update will happen only in buffer, not in DB. Once all update FMs are called with VTASK = B, call the FM RH_UPDATE_DATABASE to update the database.

Hope the article was helpful. Please let me know if you have any questions or comments.

22 comments:

  1. Hello, i believe that i noticed you visited my site thus i got here to go back the prefer?

    .I am trying to in finding issues to enhance my website!
    I suppose its adequate to make use of a few of
    your concepts!!

    Also visit my blog post ... real work at home jobs for free

    ReplyDelete
  2. My brother suggested I may like this web site. He used
    to be totally right. This submit actually made my day.
    You can not consider just how much time I had spent for this information!
    Thank you!

    Feel free to visit my web page; http hop clickbank net

    ReplyDelete
  3. Ridiculous quest there. What occurred after? Take care!


    my web-site best mortgage loans for bad credit

    ReplyDelete
  4. Right here is the right webpage for everyone who wants to find out about this
    topic. You understand a whole lot its almost tough to argue with
    you (not that I personally would want to…HaHa).
    You certainly put a new spin on a topic which has been discussed for decades.
    Excellent stuff, just great!

    my blog ... möbel outlet online

    ReplyDelete
  5. My partner and I stumbled over here coming from a different page and thought I should check things out.
    I like what I see so i am just following you. Look forward to looking over
    your web page repeatedly.

    My website :: wechsel von privater zu gesetzlicher krankenversicherung

    ReplyDelete
  6. My partner and I stumbled over here coming
    from a different page and thought I should check things out.
    I like what I see so i am just following you. Look forward to looking
    over your web page repeatedly.

    my weblog: wechsel von privater zu gesetzlicher krankenversicherung

    ReplyDelete
  7. Hello, I enjoy reading through your article post. I
    like to write a little comment to support you.

    Here is my web blog :: anwartschaft private krankenversicherung

    ReplyDelete
  8. I am actually glad to glance at this blog posts which carries plenty of valuable information, thanks for
    providing these statistics.

    Here is my web-site :: taschen outlet online

    ReplyDelete
  9. Please let me know if you're looking for a writer for your site. You have some really good articles and I feel I would be a good asset. If you ever want to take some of the load off, I'd love
    to write some material for your blog in exchange for a
    link back to mine. Please send me an e-mail if interested.
    Thanks!

    My web site :: reseller hosting provider

    ReplyDelete
  10. Excellent website. Lots of useful info here.
    I am sending it to some pals ans also sharing in delicious.

    And of course, thanks for your effort!

    Here is my web blog - pkv angebot

    ReplyDelete
  11. What i don't realize is in truth how you're no longer actually a lot more well-preferred than you may be now.
    You are so intelligent. You understand therefore significantly
    with regards to this topic, made me personally believe it from numerous numerous
    angles. Its like women and men aren't involved except it's one thing to accomplish with Woman gaga!
    Your own stuffs great. Always maintain it up!


    Also visit my web blog :: search engine optimization seo

    ReplyDelete
  12. Attractive part of content. I just stumbled
    upon your blog and in accession capital to claim that
    I get in fact enjoyed account your weblog posts. Any way I'll be subscribing to your feeds and even I success you get right of entry to consistently fast.

    my homepage ... can you get a home loan with bad credit

    ReplyDelete
  13. I visited many websites however the audio quality for audio songs current at this web page is really superb.



    Also visit my website - günstige pkv

    ReplyDelete
  14. Hi to all, the contents present at this web page are in fact remarkable for people knowledge, well, keep up the
    nice work fellows.

    Here is my blog post ... simply click the next internet site

    ReplyDelete
  15. There is definately a great deal to find out about this topic.
    I love all of the points you have made.

    Feel free to visit my website make money online with clickbank

    ReplyDelete
  16. Hello! I know this is kind of off-topic but I needed to
    ask. Does managing a well-established blog such as yours require a
    massive amount work? I'm brand new to writing a blog but I do write in my diary every day. I'd like to start a blog so I will be able to share my experience and
    feelings online. Please let me know if you have any suggestions or tips for new aspiring
    blog owners. Thankyou!

    Visit my web blog ... mortgage refinance bad credit

    ReplyDelete
  17. Are you looking for in favour of an valuable and secure way to
    results lasting or do they disappear really dissipated?
    This really also the Magnification Of Penis that has equaled proven to make
    the convinced consequences and help oneself in bringing rearward
    what you feature blanked out in your lifetime. It makes the endeavours of your jelqing actions
    is something you want to debar.

    my web site penis advantage reviews

    ReplyDelete
  18. It was very nice article and useful to SAP learners. we also provide SAP SR course online training our Cubtraining is leader in providing Software Training

    ReplyDelete