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

collect statement can be used here?

In my internal table datatab_lst.

i have records like below.

Gsber, seqno, compname ,AMount

011a , 001 , PMBC , 1000

011a , 002 , PMBC1, 2000

011a , 003 , PMBC2, 3000

011a , 004 , PMBC3, 4000

011a , 005 , PMBC4, 5000

130B , 001 , PMBC , 2000

130B , 002 , PMBC1, 2000

130B , 003 , PMBC2, 2000

130B , 004 , PMBC3, 2000

130B , 005 , PMBC4, 2000

two set of records with GSBER(011A,130B)

now i want to merge both@record groups and

add respective amounts

Can we use COllect statement here..its not working

how to use. below code

loop at datatab_lst.

collect datatab_lst into xtab_lst.


not working.


Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Posted on Feb 14, 2005 at 03:16 AM


    Have an additional IntTab of fields GSBER and AMOUNT.

    Data: Begin of TOT_TAB occurs 0,

    GSBER like...

    AMT like...


    loop at DATATAB_LST.

    move-corresponding DATATAB_LST to TOT_TAB.

    collect TOT_TAB.


    The COLLECT statement cumulates the values. In the above case GSBER, SEQNO and COMPNAME being of CHAR Type, is considered as KEY fields.

    Hope this helps you.

    Regards, Murugesh AS

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member


      As Murugesh had said in his previous post, you should have a new internal table with two fields: GSBER and AMOUNT. Since your question was to were asking to merge the records to get the <i>respective</i> amounts, this is the way to do it.

      But if you are just bothered with finding out what the total amount is regardless of the GSBER value, then you will have to use the approach Murugesh had suggested in his second reply.

      The structure of the new internal table would therefore be determined by what the result you are seeking is.


      Anand Mandalika.

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.