Skip to Content
author's profile photo
Former Member

Internal table field count.

Hi I have an internal table like this.

Invoice gross Group

161 1000 C

162 1200 C

162 1200 C

163 111 ABC

163 613 XYZ

163 613 PQR

Now I want to know the totel no. of group values for an invoice no.

Like, 161 -


1

162------1

163------3 etc.

How to do that.

Points are awaited for your answers.</b>

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

5 Answers

  • Posted on Sep 27, 2007 at 05:35 PM

    Hi

    Check this

    sort itab by invno group.
    * For Unique count you need to delete duplicates
    delete adjacent duplicates comparing invno group.
    sort itab by invno.
    
    loop at itab.
      at end of invno.
        move 'Y' to v_flg.
      endat.
      v_no = v_no + 1.
      if v_flg eq 'Y'.
         move itab-invno to itab1-invno.
         move v_no to itab1-count.
         append itab1.
         clear : v_flg, v_no.
      endif.
    endloop.
    

    After this loop your itab1 contains the invno wise total count of group.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Sep 27, 2007 at 05:30 PM

    Hi,

    Use AT NEW and AT END OF

    Try something like this:

    may need some tweaking..

    LOOP at the table.

    AT NEW invoice

    initialize the count.

    END AT.

    count+1.

    AT END OF invoice

    write invoice, count.

    ENDAT.

    ENDLOOP.

    Message was edited by:

    Sri Tayi

    Add comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 27, 2007 at 05:32 PM

    sort the itab & use control breaks ie

    data w_cnt type i.
    sort itab.
    loop at itab.
    w_cnt = w_cnt + 1.
    at end of invoice.
    write: / itab-invoice, w_cnt.
    clear w_cnt.
    endat.
    endloop.
    

    ~Suresh

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Sep 27, 2007 at 05:35 PM

    Hi Priya,

    In order to know the total number of group values for an invoice number,it is better to first store the invoce numbers(161,162,163 etc.) in a new internal table.

    Then loop at the internal table(tab) into wa.

    Inside it loop at the new internal table(itab1) nto wa1 which consists of the invoice numbers.

    if wa-invoice = wa1-invoice.

    counter = counter + 1.

    else.

    continue.

    endif.

    endloop.

    write : counter.

    endloop.

    In case you have any further clarifications,do let me know.

    Regards,

    Puneet Jhari.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Sep 27, 2007 at 05:40 PM

    Hi

    check the following code.

    data : v_cnt type i,

    v_cnt1 type i.

    data : begin of itab occurs 0,

    num type i,

    end of itab.

    itab-num = '1'.

    append itab.

    clear itab.

    itab-num = '161'.

    append itab.

    clear itab.

    itab-num = '162'.

    append itab.

    clear itab.

    itab-num = '162'.

    append itab.

    clear itab.

    itab-num = '163'.

    append itab.

    clear itab.

    itab-num = '163'.

    append itab.

    clear itab.

    itab-num = '163'.

    append itab.

    clear itab.

    sort itab by num.

    loop at itab.

    at new num.

    v_cnt1 = sy-tabix.

    endat.

    at end of num.

    v_cnt = sy-tabix - v_cnt1 + 1.

    write :/ itab-num , v_cnt.

    clear : v_cnt,v_cnt1.

    endat.

    endloop.

    Regards,

    Padmam.

    Add comment
    10|10000 characters needed characters exceeded