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

Internal table count of records - Control break processing

Hi ABAPers,

I got a scenario in an internal table where I need to use Control break processing.

There are 2 fields in my internal table VGBEL and VENUM. For each VGBEL there are more than one VENUMs as shown in the screenshot.

Now I want the count of VENUMs for a VGBEL in another table. I have tried using AT NEW and ON CHANGE OF statements. But am not getting the desired output. Please help me out how to do this. Are there any ways other than Control-break processing to do this??

Your suggestions are welcome. Thanks in advance..

IT_CASES.jpg (65.9 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Posted on Jul 23, 2014 at 02:41 PM

    Hi Aravindh,

    You can do like this

    types : begin of ty_typ,

    Venum type char10,

    count type i,

    end of ty_typ.

    data : itab type standard table of ty_typ,

    wa_tab type ty_tab.

    **Now loop your it_cases containing data

    sort it_cases by venum.

    LOOP AT it_cases into wa_cases.

    wa_tab = wa_cases-venum.

    wa_tab-count = 1.

    collect wa_tab into itab. " this will fill the number of vgbls for a venum by increasing the no of count

    clear : wa_tab.

    ENDLOOP.



    Regards,

    Pavan

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 23, 2014 at 03:22 PM

    Hi Aravindh,

    Control break statement only enough to full fill the requirement.

    Sort the internal table on VGBEL and use control break statement AT END OF VGBEL

    Thanks & Regards,

    Arun

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 23, 2014 at 03:24 PM

    Hello Aravindh,

    why AT NEW event isn't working for you?

    I would have suggested it myself...

    i.e.

    DATA: begin of it_count occurs 0,

    vgbel like it_cases-vgbel,

    vennr type i,

    end of it_count,

    sort it_cases by vgbel.

    loop at it_cases.

    at new vgbel.

    clear it_count.

    endat.

    add 1 to it_count-vennr.

    at end of vgbel.

    it_count-vgbel = it_cases-vgbel.

    append it_count.

    endat.

    endloop.

    Of course, if your second itab is simple as mine (only one numeric field) you may also follow a different solution as:

    loop at it_cases.

    it_count-vgbel = it_cases-vgbel.

    it_count-vennr = 1.

    collect it_count. clear it_count.

    endloop.

    I hope this may help you.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 24, 2014 at 05:50 AM

    Using Collect and adding up is cool and simple. It worked and in control break processing I have coded it wrongly. It should also work now. Thanks Pavan,Aruna and Moody for your time..

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 24, 2014 at 06:11 AM

    Hi friend,

    When you using At new statement the first field in the internal table should be VGBEL.

    then you can increment a variable for cound under the at new statement.

    g_cound type I value 0.

    loop at it_cases into wa_cases.

    g_cound =g_cound + 1.

    at-end-of vegbel.

    ****update your cound using wa_cases-vegbl and g_cound into second table here.

    clear g_cound.

    endloop.

    Regards

    Ashwin.kv

    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.