Skip to Content

need the sum of qty flds and den update the same in 2 different standard tables


I have a requirement, where i have n number of records in ztable with f1 f2 f3 f4 f5...Fn fields

i have all records in ZTABLE, my requiremnet is to sum all qty flds (column wise) based on version number.(can be 00, 01, 02, 03, 04 , 05)

so once i sum up all qty flds. i need to update the same in 2 different standard tables.

please suggest with example code how to sum up and update standard tables.? with good program performance

i hav written like:

i have got data in ztable. then,

CLEAR: itab, watab.

select * from ztable into table itab.

SORT itab BY versb.(version fld) ""based on version i want "" can i use collect instead of SUM,

LOOP AT itab INTO watab.

** AT END OF versb.

** SUM.



here i m not sure how to update data in standard table.

please give some sample code to do this

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 Jan 08, 2013 at 10:25 AM

    Hi Ketan,

    Regarding updation of standard tables :-

    1. you have data in your internal table Itab. Declare 2 internal tables IT1 and IT2 based on the structure of your 2 standard tables which require to be updated.

    2. Set a flag and based on the flag values, append the field values from work area to the respective internal tables IT1 and IT2.

    3. to update the standard table you can use

    modify dbtab1 from table IT1.

    Regarding performance review of the code :

    we usually follow a checklist in a performance review.

    1. Perform the Modify / Update operation outside the loop

    2. Clear work Area and variables after they are no longer in use.

    Clear the work area after the loop ends.

    3. Do most of the processing in the internal tables rather than writing multiple queries like I suggested to filter and append the data in the internal tables based on a flag logic check.

    4. Try to avoid select * from dbtab ( in above case it's a requirement i guess ). Try to fetch required fields only.

    5.. Use " For all entries " in the query instead of " in the corresponding fields of itab "

    6. Sort the internal tables based on primary keys before performing any operations.

    Please let me know if this helps. Revert in case of any issues.


    Vivek Batta

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 08, 2013 at 10:44 AM

    data :begin of i_vbap occurs 0,

    vbeln type vbap-vbeln,

    kwmeng type vbap-kwmeng,

    end of i_vbap.

    suppose i have to select sum of kwmeng (quantity )field from vbap->sale order item table.

    need not to use loop etc,.

    also becoz of performance issues.

    see this select statement:

    select vbeln sum( kwmeng ) from vbap

    into table i_vbap

    up to 100 rows

    group by vbeln.

    Remember: Do Not use into corresponding fields of itab->> this wont work.;

    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.