Hi,
Use the Control Break Statement for your requirement.
For the pre-requisite will that user fields i.e. "customer number" "country" " product category"
should follow the same sequence in the internal table also
CUst.No. - 1st field
country - 2nd filed
Prod Category - 3rd filed and so on.
After that sort internal table in ASCENDING ORDER based on the above 3 fields.
LOOP AT ITAB INTO WA1.
WA2 = WA1. " copy the data from WA1 to WA2
tot_sales_val = WA2-SALE_VALUE + tot_sales_val. " whatevar the logic of calculating the total sale
" and discount put here.
AT END OF PRODUCT_CATEGORY.
wa_final-cust_no = WA2-cust_no.
wa_final-country = wa2-country.
wa_final-prod_category = wa2-prod_category.
wa_fianl-total_sale = tot_sales_val.
.......
.......
.......
APPEND wa_final to IT_FINAL.
CLEAR : tot_sales_value,
wa_final.
END AT.
ENDLOOP.
For more information about the CONTROL BREAK STATEMENT search in the forum.