Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

reports

Former Member
0 Likes
524

Hi Guys,

i have an internal table like this:-

company_code Region Salesoffice salesorder amount

xx1 E CAL 001 100.00

xx1 E CAL 002 70.00

xx1 E SIL 003 50.00

xx1 W MUM 004 700.00

xx1 E ASL 005 100.00

xx2 E CAL 006 200.00

xx2 S CHE 007 100.00

xx3 W MUM 008 400.00

xx3 E SIL 009 70.00

xx3 S CHE 010 300.00

I have generate a report like this

Company code : xx1

Region : E

Salesoffice Sales Order Amount

CAL 001 100.00

CAL 002 70.00

SIL 003 50.00

ASL 005 100.00

-


Net : 320.00

Region : W

Salesoffice Salesorder Amount

MUM 004 700.00

-


Net : 700.00

-


Company Code : Net amont

xx1 1020.00

I have successfully written a program using AT NEW,ON CHANGE,AT END ,

I want to write the same program using LOOP AT and READ TABLE . Plz

anyone help me to solve this and send me the exact code .

4 REPLIES 4
Read only

Former Member
0 Likes
494

null

Message was edited by:

SHIBA DUTTA

Read only

Former Member
0 Likes
494

check this code and get back if it doesn't work

sort itab. by ccode region soff sorder amount.

loop at itab

wa_table = itab.

at new ccode.

write:/'Company Code',wa_table-ccode.

endat.

at new region.

write:/'Region',wa_table-region.

endat.

write:/itab-soff, itab-sorder, itab-amont.

at end of region.

sum.

write:/itab-amount.

endat.

endloop.

Read only

0 Likes
494

Hi Rajesh,

please read the question carefully before answering it. I have already done this but now i want to do the same thisng using read table statement.

Read only

Former Member
0 Likes
494

hi Friend,

Please try the following logic:


data:  wa_temp type type_itab,
         wa_itab   type type_itab,
         itab        type table of type_itab,
         lv_flag ,
         lv_region_amount type ...,
         lv_ccode_amount type.....

loop at itab into wa_itab.
  if wa_temp is initial.
    write:/ 'Company Code' , wa_itab-company_code.
    write:/ 'Region'             , wa_itab-region.
    write:/ 'Sales office'      , 'Sales Order'       , 'Amount'.
    write:/ wa_itab-sales_office, wa_itab-sales_order, wa_itab-amount.
    lv_region_amount = lv_region_amount + wa_itab-amount.
    lv_ccode_amount = lv_ccode_amount + wa_itab-amount.
    lv_flag = 'X'.
  endif.
  if lv_flag is initial.
    if wa_itab-company_code <> wa_temp-company_code.
      write:/ 'Company code Net', lv_ccode_amount.
      clear lv_ccode_amount.
      clear lv_region_amount.
      write:/ 'Company Code' , wa_itab-company_code.
      write:/ 'Region'             , wa_itab-region.
      write:/ 'Sales office'      , 'Sales Order'       , 'Amount'.
      write:/ wa_itab-sales_office, wa_itab-sales_order, wa_itab-amount.
      lv_region_amount = lv_region_amount + wa_itab-amount.
      lv_ccode_amount = lv_ccode_amount + wa_itab-amount.
    else.
       if wa_itab-region <> wa_temp-region.
         write:/ 'Region Net', lv_region_amount.
         clear lv_region_amount.      
         write:/ 'Region'             , wa_itab-region.
         write:/ 'Sales office'      , 'Sales Order'       , 'Amount'.
         write:/ wa_itab-sales_office, wa_itab-sales_order, wa_itab-amount.
         lv_region_amount = lv_region_amount + wa_itab-amount.
         lv_ccode_amount = lv_ccode_amount + wa_itab-amount.

       endif
       write:/ wa_itab-sales_office, wa_itab-sales_order, wa_itab-amount.
       lv_region_amount = lv_region_amount + wa_itab-amount.
       lv_ccode_amount = lv_ccode_amount + wa_itab-amount.
    endif.
  endif.
  wa_temp = wa_itab.
  clear lv_flag.
endloop.
write:/ 'Company code Net', lv_ccode_amount.

.

Hope this helps,

Sajan Joseph.

Message was edited by:

Sajan Joseph