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

Do I Need to Commit

I am new to ABAP, and have written the following to update a BW ODS table.

Do I need to add a commit statement? It works without it, but I am wondering what the best practice is.

Any other comments or suggestions about the code would be welcomed, too.

report zz_update_ods.

data: itab type standard table of /bic/az_ods00,
      wa like line of itab.

parameters: p_ordr  like /bic/az_ods00-/bic/z_order_n obligatory,
            p_new_s like /bic/az_ods00-/bic/zsalesorg obligatory.

select /bic/z_order_n /bic/zsalesorg
into   corresponding fields of table itab
from   /bic/az_ods00
where /bic/z_order_n = p_ordr.

if sy-subrc eq 0.
  loop at itab into wa.

    update /bic/az_ods00
       set /bic/zsalesorg = p_new_s
       where /bic/z_order_n = p_ordr.

    write: / wa-/bic/z_order_n,
           ' salesorg changed to ',
           p_new_s,
           ' from ',
           wa-/bic/zsalesorg.
  endloop.
endif.

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 Jul 25, 2005 at 04:20 PM

    you don't need.

    let the system care for that.

    if you commit and after your program crash, you cannot rollback

    http://help.sap.com/saphelp_erp2004/helpdata/en/41/7af4b9a79e11d1950f0000e82de14a/frameset.htm

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 25, 2005 at 04:50 PM

    Hi Jerry,

    Two things -

    1. If you expect number of records to be too large then it is advisable to add commit.

    2. You can simplify this by just one update statement (you can avoid ITAB and LOOP) with following -

    update /bic/az_ods00

    set /bic/zsalesorg = p_new_s

    where /bic/z_order_n = p_ordr

    and /bic/zsalesorg <> p_new_s.

    Cheers,

    Sanjeev

    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.