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

report

hi experts

i have a problem plse help me.

iam fetching data from the DB tables to the internal table.now i want to find the no of rows for the perticular field, not the entire internal table .

ex: eatch material have many packaging types , for eatch packing type there will be multiple components.

i want to find the no of components in the internal table , i.e .field wise records.

if the no of records are 1 need not to do the sum,if no of records are more than 1 then i have to do the sum for the quantity.

plse help me.....

with regards

aaryaa

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2008 at 06:03 AM

    Hi,

    Set counter at AT NEW/AT END statements.

    like:

    LOOP AT itab result ...

    [AT FIRST.

    ...

    ENDAT.]

    [AT NEW comp1.

    ...

    ENDAT.

    [AT NEW comp2.

    ...

    ENDAT.

    AT END OF comp2.

    ...

    ENDAT.]

    AT END OF comp1.

    ...

    ENDAT.]

    [AT LAST.

    ...

    ENDAT.]

    ENDLOOP.

    the above given is the general syntax... u may write it according to ur requirement.

    Regards,

    Renjith Michael.

    Edited by: Renjith Michael on Jan 29, 2008 11:33 AM

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi,

      Instead of using SUM, better sum it outside AT END OF.

      SORT itab BY matnr atwrt.

      LOOP AT itab INTO wa_itab.

      at new matnr

      WRITE: /05 wa_itab-matnr,

      /25 wa_itab-maktx,

      / .

      endat.

      at new atwrt.

      WRITE: /05 wa_itab-atwrt,

      25 wa_itab-ojtxp,

      45 wa_itab-factor.

      endat.

      sum = sum + wa_itab-factor.

      AT END OF atwrt.

      WRITE: /05 sy-uline(134),

      /05 'total',

      65 sum.

      sum = 0.

      endat.

      clear:itab,

      wa_itab.

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.