Shared Top Border

Enterprise Resource
Planning Portal

 

Advertise | Founder BLOG

ERPGenie.COM ABAP Tips and Tricks Database

THE ultimate
ERP website

 

Forums | Vote for us |

Google    Other Search Options

Home arrow Tips and Tricks arrow ABAP Reports arrow How to add hours, minutes and seconds
How to add hours, minutes and seconds PDF Print E-mail
User Rating: / 1
PoorBest 
Written by Anon.   
Friday, 11 May 2007

Considering a table ztime with a field ztime of type tims and has 2 records.
To get the sum of the times of these records  plz  see the following code :

REPORT ZTIME .

DATA : IZTIME LIKE ZTIME OCCURS 0 WITH HEADER LINE.
DATA : TOTTIME LIKE SY-UZEIT.
DATA : N TYPE I, TOTHRS TYPE I.

START-OF-SELECTION.
PERFORM GET-DATA.
PERFORM CAL-TOT-TIME.
PERFORM WRITE.
END-OF-SELECTION.

*&--------------------------------------------------------------------
*&      Form  GET-DATA
*&--------------------------------------------------------------------
FORM GET-DATA.
SELECT * FROM ZTIME
INTO CORRESPONDING FIELDS
OF TABLE IZTIME.

ENDFORM.                    " GET-DATA

*&--------------------------------------------------------------------
*&      Form  CAL-TOT-TIME
*&--------------------------------------------------------------------
FORM CAL-TOT-TIME.


LOOP AT IZTIME.
TOTTIME = TOTTIME + IZTIME-ZTIME.
ENDLOOP.

LOOP AT IZTIME.
N = IZTIME-ZTIME+0(2).
TOTHRS = TOTHRS + N.
ENDLOOP.


ENDFORM.                    " CAL-TOT-TIME

*&--------------------------------------------------------------------
*&      Form  WRITE
*&--------------------------------------------------------------------
FORM WRITE.

DATA : HRS TYPE I, MIN TYPE I, SECS TYPE I.

LOOP AT IZTIME.
WRITE :/ IZTIME-ZTIME.
ENDLOOP.

SKIP 2.

HRS = TOTHRS.
MIN = TOTTIME+2(2).
SECS = TOTTIME+4(2).

WRITE :/ 'total time : ' , (2)HRS NO-GAP,
                       ':' NO-GAP,(2)MIN NO-GAP,
                       ':' NO-GAP,(2)SECS NO-GAP.


ENDFORM.                    " WRITE

Related Items:

 
< Prev   Next >

Google Search

Google Ads

Shared Bottom Border

Contact Us | Polls | Add URL | Contribute | Privacy | Terms | Feedback

Discussion Forum | BLOG | Consultants: Post your resume | Companies: Advertise on ERPGenie.COM | Post Job
Financials Consultant | Consultant Review | Gallia Consulting | Supply Chain Project | SAP Financials Forum
GenieHoldings.COM, Inc. | Genie Press | WorkflowGenie | ESAGenie | ERPTopSites | ABAP Tips and Tricks | SAP Solutions Database

EDIGenie | Searching Survivor