# Computing the total number of shifts

Explain me with a sample coding.

My internal table is filled by as follows

ZKOSTL ZSHIFT 102 1 102 1 102 1 102 1 102 2 102 2 102 2 102 2 103 2 103 2 103 2 103 3

i want the ZSHIFT total number of shifts based on ZKOSTL

(i.e)

102 1 4 102 2 4 103 2 3 103 3 1

My coding is as follows:

REPORT Z16. TABLES: ZCT006_PRODUCT. TYPES: BEGIN OF TY_PROD, ZKOSTL TYPE ZCCID, ZSHIFT TYPE ZSHIFT, END OF TY_PROD. DATA: IT_PROD TYPE TABLE OF TY_PROD. SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001. SELECT-OPTIONS: SO_PLANT FOR ZCT006_PRODUCT-ZWERKS OBLIGATORY, SO_DATE FOR ZCT006_PRODUCT-ZDATE OBLIGATORY. SELECTION-SCREEN END OF BLOCK B1. AT SELECTION-SCREEN. ***FETCHING THE MATERIAL DETAILS FROM THE PRODUCT TABLE SELECT ZKOSTL ZSHIFT FROM ZCT006_PRODUCT INTO TABLE IT_PROD WHERE ZWERKS IN SO_PLANT AND ZDATE IN SO_DATE. WRITE: 'TEST'.

##### Former Member replied

TYPES: BEGIN OF ty_totals, ZKOSTL TYPE ZCCID, ZSHIFT TYPE ZSHIFT, count TYPE i, END OF ty_totals. DATA: ti_totals TYPE STANDARD TABLE of ty_totals, wa_totals TYPE ty_totals, wa_prod TYPE TY_PROD. LOOP AT IT_PROD INTO wa_prod. CLEAR wa_totals. wa_totals-zkostl = wa_prod-zkostl. wa_totals-zshift = wa_prod-zshift. wa_totals-count = 1. COLLECT wa_totals INTO ti_totals. ENDLOOP.

Regards,

Valter Oliveira.