Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

*&---------------------------------------------------------------------

*& Report ZFI_DOC_STATUS_REPORT *

*& *

*&---------------------------------------------------------------------

*& *

*& *

*&---------------------------------------------------------------------REPORT zfi_doc_status_report LINE-SIZE 120

LINE-COUNT 60

MESSAGE-ID zz.************************************************************************TABLES *

***********************************************************************TABLES:

zfap_history ,

bkpf,

bseg,

t001.*************************************************************************TYPE POOLS *

************************************************************************TYPE-POOLS: slis.*************************************************************************TYPES *

************************************************************************TYPES: BEGIN OF ty_zfap_history,

zbukrs TYPE bukrs,

zbelnr TYPE belnr_d,

zapprlevel TYPE char10,

zdate TYPE crdat,

ztime TYPE cvdicrtime,

zsapuserid TYPE syuname,

zstatus TYPE char1,

END OF ty_zfap_history,

BEGIN OF ty_doc_data,

blart TYPE blart,

budat TYPE budat,

stblg TYPE stblg,

stodt TYPE stodt,

waers TYPE waers,

kzwrs TYPE kzwrs,

bukrs TYPE bukrs,

belnr TYPE belnr_d,

END OF ty_doc_data,

BEGIN OF ty_final_data,

zbelnr TYPE belnr_d,

blart TYPE blart,

budat TYPE budat,

waers TYPE waers,

wrbtr TYPE wrbtr,

kzwrs TYPE kzwrs,

dmbe2 TYPE dmbe2,

name TYPE char80,

zdate TYPE crdat,

zstatus TYPE char1,

stblg TYPE stblg,

stodt TYPE stodt,

writ TYPE char20,

time TYPE p decimals 2,

END OF ty_final_data,

BEGIN OF ty_sec_final,

zbelnr TYPE belnr_d,

name TYPE char80,

approver TYPE AGR_NAME,

date TYPE sydatum,

zstatus TYPE char1,

END OF ty_sec_final,

BEGIN OF ty_time,

zbukrs type bukrs,

zbelnr type belnr_d,

diff type p decimals 2,

END OF ty_time.

***********************************************************************

*I N T E R N A L T A B L E S *

***********************************************************************

DATA: it_zfap_history TYPE STANDARD TABLE OF ty_zfap_history,

wa_it_zfap_history TYPE ty_zfap_history,

it_temp1 TYPE STANDARD TABLE OF ty_zfap_history,

wa_it_temp1 TYPE ty_zfap_history,

it_temp2 TYPE STANDARD TABLE OF ty_zfap_history,

wa_it_temp2 TYPE ty_zfap_history,

it_zfap_hist TYPE STANDARD TABLE OF ty_zfap_history,

wa_it_zfap_hist TYPE ty_zfap_history,

it_doc_data TYPE STANDARD TABLE OF ty_doc_data,

wa_it_doc_data TYPE ty_doc_data,

it_final_data TYPE STANDARD TABLE OF ty_final_data,

wa_it_final_data TYPE ty_final_data,

it_sec_final TYPE STANDARD TABLE OF ty_sec_final,

wa_it_sec_final TYPE ty_sec_final,

it_time TYPE STANDARD TABLE OF ty_time,

wa_it_time TYPE ty_time,

it_fcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,

it_fcat_sec TYPE slis_t_fieldcat_alv WITH HEADER LINE.

*--Structure for layout settings

DATA: wa_layout TYPE slis_layout_alv.

*--Internal table and structure for events

DATA: it_events TYPE slis_t_event,

wa_events TYPE slis_alv_event.

**********************************************************************

*Variable Declaration

***********************************************************************

DATA : w_doc_no TYPE belnr_d ,

w_repid TYPE sy-repid ,

w_diff TYPE p decimals 2.

***********************************************************************

*S E L E C T I O N S C R E E N *

***********************************************************************

SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-t01.

SELECTION-SCREEN: SKIP.

SELECT-OPTIONS: s_bukrs FOR t001-bukrs,

s_blart FOR bkpf-blart,

s_crdat FOR zfap_history-zdate,

s_userid FOR zfap_history-zsapuserid,

s_budat FOR bkpf-budat.

SELECTION-SCREEN: END OF BLOCK b1.

***********************************************************************

*S T A R T O F S E L E C T I O N *

***********************************************************************

*START-OF-SELECTION.

*to get history data

PERFORM get_history_data.

*to get elpased time

PERFORM get_elapsed_time.

*to get document data

PERFORM get_doc_data.

*to move data to final table

PERFORM move_data.

***********************************************************************

*E N D O F S E L E C T I O N *

***********************************************************************

END-OF-SELECTION.

*to display data

PERFORM display_data.

*to list secondary list

PERFORM sec_list_data.

*&---------------------------------------------------------------------

*& Form GET_HISTORY_DATA

*&---------------------------------------------------------------------

*----------------------------------------------------------------------

FORM get_history_data .

SELECT zbukrs

zbelnr

zapprlevel

zdate

ztime

zsapuserid

zstatus

FROM zfap_history

INTO TABLE it_zfap_history

WHERE zbukrs IN s_bukrs AND

zdate IN s_crdat AND

zsapuserid IN s_userid AND

zstatus = 'Submitted'.

SELECT zbukrs

zbelnr

zapprlevel

zdate

ztime

zsapuserid

zstatus

FROM zfap_history

INTO TABLE it_zfap_hist

FOR ALL ENTRIES IN it_zfap_history

WHERE zbukrs = it_zfap_history-zbukrs

AND zbelnr = it_zfap_history-zbelnr.

ENDFORM. " GET_HISTORY_DATA

*&---------------------------------------------------------------------

*& Form GET_DOC_DATA

*&---------------------------------------------------------------------

FORM get_doc_data .

SELECT blart

budat

stblg

stodt

waers

kzwrs

bukrs

belnr

FROM bkpf

INTO TABLE it_doc_data

FOR ALL ENTRIES IN it_zfap_history

WHERE bukrs = it_zfap_history-zbukrs

AND belnr = it_zfap_history-zbelnr

AND blart IN s_blart

AND budat IN s_budat.

ENDFORM. " GET_DOC_DATA

*&---------------------------------------------------------------------

*& Form MOVE_DATA

*&---------------------------------------------------------------------

FORM move_data .

DATA : l_wrbtr TYPE wrbtr,

l_dmbe2 TYPE dmbe2,

l_persnumber TYPE ad_persnum,

l_name_first TYPE ad_namefir,

l_name_last TYPE ad_namelas.

LOOP AT it_zfap_history INTO wa_it_zfap_history.

READ TABLE it_doc_data INTO wa_it_doc_data

WITH KEY bukrs = wa_it_zfap_history-zbukrs

belnr = wa_it_zfap_history-zbelnr.

IF sy-subrc = 0.

wa_it_final_data-zbelnr = wa_it_zfap_history-zbelnr.

wa_it_final_data-blart = wa_it_doc_data-blart.

wa_it_final_data-budat = wa_it_doc_data-budat.

wa_it_final_data-waers = wa_it_doc_data-waers.

IF wa_it_doc_data-kzwrs is INITIAL.

wa_it_final_data-kzwrs = 'USD'.

ELSE.

wa_it_final_data-kzwrs = wa_it_doc_data-kzwrs.

ENDIF.

wa_it_final_data-zdate = wa_it_zfap_history-zdate.

wa_it_final_data-zstatus = wa_it_zfap_history-zstatus.

wa_it_final_data-stblg = wa_it_doc_data-stblg.

wa_it_final_data-stodt = wa_it_doc_data-stodt.

SELECT SINGLE wrbtr dmbe2

FROM bseg

INTO (l_wrbtr, l_dmbe2)

WHERE bukrs = wa_it_doc_data-bukrs

AND belnr = wa_it_doc_data-belnr.

wa_it_final_data-wrbtr = l_wrbtr.

wa_it_final_data-dmbe2 = l_dmbe2.

SELECT SINGLE persnumber

FROM usr21

INTO l_persnumber

WHERE bname = wa_it_zfap_history-zsapuserid.

SELECT SINGLE name_first name_last

FROM adrp

INTO (l_name_first, l_name_last)

WHERE persnumber = l_persnumber.

CONCATENATE l_name_last l_name_first INTO wa_it_final_data-name

SEPARATED BY space.

if wa_it_final_data-name is initial.

wa_it_final_data-name = wa_it_zfap_history-zsapuserid.

endif.

wa_it_final_data-writ = ' '.

read table it_time into wa_it_time

with key zbukrs = wa_it_zfap_history-zbukrs

zbelnr = wa_it_zfap_history-zbelnr.

if sy-subrc = 0.

wa_it_final_data-time = wa_it_time-diff.

endif.

APPEND wa_it_final_data TO it_final_data.

ENDIF.

CLEAR : wa_it_zfap_history, wa_it_doc_data, wa_it_final_data,

l_wrbtr, l_persnumber, l_name_first, l_name_last, l_dmbe2.

ENDLOOP.

ENDFORM. " MOVE_DATA

*&---------------------------------------------------------------------

**& Form DISPLAY_DATA

*&---------------------------------------------------------------------

FORM display_data .

w_repid = sy-repid.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = w_repid

i_internal_tabname = 'IT_SRCTRANS'

i_inclname = w_repid

CHANGING

ct_fieldcat = it_fcat[]

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

IF NOT it_final_data[] IS INITIAL.

IF it_fcat[] IS INITIAL.

CLEAR it_fcat.

it_fcat-tabname = 'IT_FINAL_DATA'.

it_fcat-fieldname = 'ZBELNR'.

it_fcat-seltext_l = 'Document Number'.

it_fcat-col_pos = 1.

it_fcat-outputlen = 15.

it_fcat-key = 'X'.

APPEND it_fcat.

CLEAR it_fcat.

it_fcat-tabname = 'IT_FINAL_DATA'.

it_fcat-fieldname = 'BLART'.

it_fcat-seltext_l = 'Document Type'.

it_fcat-col_pos = 2.

it_fcat-outputlen = 13.

APPEND it_fcat.

CLEAR it_fcat.

it_fcat-tabname = 'IT_FINAL_DATA'.

it_fcat-fieldname = 'BUDAT'.

it_fcat-seltext_l = 'Posting Date'.

it_fcat-col_pos = 3.

it_fcat-outputlen = 12.

APPEND it_fcat.

CLEAR it_fcat.

it_fcat-tabname = 'IT_FINAL_DATA'.

it_fcat-fieldname = 'WAERS'.

it_fcat-seltext_l = 'Document Currency'.

it_fcat-col_pos = 4.

it_fcat-outputlen = 17.

APPEND it_fcat.

CLEAR it_fcat.

it_fcat-tabname = 'IT_FINAL_DATA'.

it_fcat-fieldname = 'WRBTR'.

it_fcat-seltext_l = 'Doc Curr Amt'.

it_fcat-col_pos = 5.

it_fcat-outputlen = 22.

APPEND it_fcat.

CLEAR it_fcat.

it_fcat-tabname = 'IT_FINAL_DATA'.

it_fcat-fieldname = 'KZWRS'.

it_fcat-seltext_l = 'Group Currency'.

it_fcat-col_pos = 6.

it_fcat-outputlen = 14.

APPEND it_fcat.

CLEAR it_fcat.

it_fcat-tabname = 'IT_FINAL_DATA'.

it_fcat-fieldname = 'DMBE2'.

it_fcat-seltext_l = 'Grp Curr Amt'.

it_fcat-col_pos = 7.

it_fcat-outputlen = 22.

APPEND it_fcat.

CLEAR it_fcat.

it_fcat-tabname = 'IT_FINAL_DATA'.

it_fcat-fieldname = 'NAME'.

it_fcat-seltext_l = 'Name of Submitter/Requestor'.

it_fcat-col_pos = 8.

it_fcat-outputlen = 60.

APPEND it_fcat.

CLEAR it_fcat.

it_fcat-tabname = 'IT_FINAL_DATA'.

it_fcat-fieldname = 'ZDATE'.

it_fcat-seltext_l = 'Creation Date'.

it_fcat-col_pos = 9.

it_fcat-outputlen = 13.

APPEND it_fcat.

CLEAR it_fcat.

it_fcat-tabname = 'IT_FINAL_DATA'.

it_fcat-fieldname = 'ZSTATUS'.

it_fcat-seltext_l = 'Status'.

it_fcat-col_pos = 10.

it_fcat-outputlen = 6.

APPEND it_fcat.

CLEAR it_fcat.

it_fcat-tabname = 'IT_FINAL_DATA'.

it_fcat-fieldname = 'TIME'.

it_fcat-seltext_l = 'Elpsed time in Mins'.

it_fcat-col_pos = 11.

it_fcat-outputlen = 20.

APPEND it_fcat.

CLEAR it_fcat.

it_fcat-tabname = 'IT_FINAL_DATA'.

it_fcat-fieldname = 'STBLG'.

it_fcat-seltext_l = 'Reversal No'.

it_fcat-col_pos = 12.

it_fcat-outputlen = 12.

APPEND it_fcat.

CLEAR it_fcat.

it_fcat-tabname = 'IT_FINAL_DATA'.

it_fcat-fieldname = 'STODT'.

it_fcat-seltext_l = 'Reversal Posting Date'.

it_fcat-col_pos = 13.

it_fcat-outputlen = 20.

APPEND it_fcat.

CLEAR it_fcat.

it_fcat-tabname = 'IT_FINAL_DATA'.

it_fcat-fieldname = 'WRIT'.

it_fcat-seltext_l = 'Work Item'.

it_fcat-col_pos = 14.

it_fcat-outputlen = 20.

APPEND it_fcat.

ENDIF.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = it_events

EXCEPTIONS

list_type_wrong = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

wa_layout-colwidth_optimize = 'X'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = w_repid

is_layout = wa_layout

i_callback_user_command = 'USER_COMMAND_ACCT'

i_grid_title = 'Document Status Report'

it_fieldcat = it_fcat[]

* IT_SORT = IT_SORT[]

it_events = it_events

TABLES

t_outtab = it_final_data[]

EXCEPTIONS

program_error = 1

OTHERS = 2.

ENDIF.

ENDFORM. " DISPLAY_DATA

*&--------------------------------------------------------------------

**& Form user_command_acct

*&--------------------------------------------------------------------

*

*

*text

*---------------------------------------------------------------------

*

*-->P_UCOMM text

*-->P_SELFLD text

*---------------------------------------------------------------------

FORM user_command_acct USING p_ucomm TYPE sy-ucomm

p_selfld TYPE slis_selfield.

CASE p_ucomm.

*when double clicked on ALV grid , report id is passed to transaction

WHEN '&IC1'. "Double click

clear p_ucomm.

IF p_selfld-fieldname = 'ZBELNR'.

w_doc_no = p_selfld-value.

*--Form to get second list records based on Doc number

PERFORM sec_list_data.

IF NOT it_sec_final IS INITIAL .

*--Form to get the second list fieldcatolog

PERFORM fill_fieldcat_sec.

.

*Perform to display the Second ALV report

PERFORM display_sec_list.

ENDIF.

ELSE.

MESSAGE i001(zz) WITH text-004.

ENDIF.

ENDCASE.

ENDFORM. "user_command_acct

*&---------------------------------------------------------------------

**& Form SEC_LIST_DATA

*&---------------------------------------------------------------------

*

*

*text

*----------------------------------------------------------------------

*

*--> p1 text

*<-- p2 text

*----------------------------------------------------------------------

FORM sec_list_data .

DATA: l_role_id TYPE AGR_NAME,

l_zrole_desc TYPE AGR_NAME,

l_persnumber TYPE ad_persnum,

l_name_first TYPE ad_namefir,

l_name_last TYPE ad_namelas.

CLEAR : it_sec_final .

REFRESH : it_sec_final .

LOOP AT it_zfap_hist INTO wa_it_zfap_hist WHERE zbelnr = w_doc_no.

IF wa_it_zfap_hist-zstatus = 'Submitted'.

CLEAR : wa_it_sec_final.

wa_it_sec_final-zbelnr = wa_it_zfap_hist-zbelnr.

SELECT SINGLE persnumber

FROM usr21

INTO l_persnumber

WHERE bname = wa_it_zfap_hist-zsapuserid.

SELECT SINGLE name_first name_last

FROM adrp

INTO (l_name_first, l_name_last)

WHERE persnumber = l_persnumber.

CONCATENATE l_name_last l_name_first INTO wa_it_sec_final-name

SEPARATED BY space.

ENDIF.

IF wa_it_zfap_hist-zstatus NE 'Submitted'. " 'Approve'.

wa_it_sec_final-date = wa_it_zfap_hist-zdate.

wa_it_sec_final-zstatus = wa_it_zfap_hist-zstatus.

SELECT SINGLE persnumber

FROM usr21

INTO l_persnumber

WHERE bname = wa_it_zfap_hist-zsapuserid.

SELECT SINGLE name_first name_last

FROM adrp

INTO (l_name_first, l_name_last)

WHERE persnumber = l_persnumber.

CONCATENATE l_name_last l_name_first INTO wa_it_sec_final-approver

SEPARATED BY space.

APPEND wa_it_sec_final TO it_sec_final.

CLEAR : l_role_id, l_zrole_desc.

ENDIF.

CLEAR : wa_it_zfap_hist.

ENDLOOP.

sort it_sec_final by zbelnr .

delete adjacent duplicates from it_sec_final .

ENDFORM. " SEC_LIST_DATA

*&---------------------------------------------------------------------

**& Form fill_fieldcat_sec

*&---------------------------------------------------------------------

*

*text

*----------------------------------------------------------------------

*

*--> p1 text

*<-- p2 text

*----------------------------------------------------------------------

FORM fill_fieldcat_sec .

CLEAR : it_fcat_sec[] .

REFRESH : it_fcat_sec[].

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = w_repid

i_internal_tabname = 'IT_SEC_FINAL'

i_inclname = w_repid

CHANGING

ct_fieldcat = it_fcat_sec[]

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

IF NOT it_sec_final[] IS INITIAL.

IF it_fcat_sec[] IS INITIAL.

CLEAR it_fcat_sec.

it_fcat_sec-tabname = 'IT_SEC_FINAL'.

it_fcat_sec-fieldname = 'ZBELNR'.

it_fcat_sec-seltext_l = 'Document Number'.

it_fcat_sec-col_pos = 1.

it_fcat_sec-outputlen = 15.

it_fcat_sec-key = 'X'.

APPEND it_fcat_sec.

CLEAR it_fcat_sec.

it_fcat_sec-tabname = 'IT_SEC_FINAL'.

it_fcat_sec-fieldname = 'NAME'.

it_fcat_sec-seltext_l = 'Name'.

it_fcat_sec-col_pos = 2.

it_fcat_sec-outputlen = 40.

APPEND it_fcat_sec.

CLEAR it_fcat_sec.

it_fcat_sec-tabname = 'IT_SEC_FINAL'.

it_fcat_sec-fieldname = 'APPROVER'.

it_fcat_sec-seltext_l = 'Approver'.

it_fcat_sec-col_pos = 3.

it_fcat_sec-outputlen = 12.

APPEND it_fcat_sec.

CLEAR it_fcat_sec.

it_fcat_sec-tabname = 'IT_SEC_FINAL'.

it_fcat_sec-fieldname = 'DATE'.

it_fcat_sec-seltext_l = 'Date'.

it_fcat_sec-col_pos = 4.

it_fcat_sec-outputlen = 17.

APPEND it_fcat_sec.

CLEAR it_fcat_sec.

it_fcat_sec-tabname = 'IT_SEC_FINAL'.

it_fcat_sec-fieldname = 'ZSTATUS'.

it_fcat_sec-seltext_l = 'Status'.

it_fcat_sec-col_pos = 5.

it_fcat_sec-outputlen = 40.

APPEND it_fcat_sec.

ENDIF.

ENDIF.

ENDFORM. " fill_fieldcat_sec

*&---------------------------------------------------------------------

**& Form display_sec_list

*&---------------------------------------------------------------------

*

*

*text

*----------------------------------------------------------------------

*

*--> p1 text

*<-- p2 text

*----------------------------------------------------------------------

FORM display_sec_list .

wa_layout-colwidth_optimize = 'X'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = w_repid

is_layout = wa_layout

i_grid_title = 'Document Status Report - Approver'

it_fieldcat = it_fcat_sec[]

* IT_SORT = IT_SORT[]

it_events = it_events

TABLES

t_outtab = it_sec_final[]

EXCEPTIONS

program_error = 1

OTHERS = 2.

ENDFORM. " display_sec_list

*&---------------------------------------------------------------------

**& Form get_elapsed_time

*&---------------------------------------------------------------------

*

*

*text

*----------------------------------------------------------------------

*

*--> p1 text

*<-- p2 text

*----------------------------------------------------------------------

form get_elapsed_time .

DATA: date1 type d,

date2 type d,

time1 type t,

time2 type t,

date type p,

time type p.

it_temp1[] = it_zfap_hist[].

it_temp2[] = it_zfap_hist[].

delete it_temp1 where zstatus NE 'Submitted'.

delete it_temp2 where zstatus NE 'Approve'.

sort it_temp1 by zbukrs zbelnr zdate ztime descending.

delete adjacent duplicates from it_temp1 comparing zbukrs zbelnr.

sort it_temp2 by zbukrs zbelnr zdate ztime descending.

delete adjacent duplicates from it_temp1 comparing zbukrs zbelnr.

loop at it_temp1 into wa_it_temp1.

read table it_temp2 into wa_it_temp2

with key zbukrs = wa_it_temp1-zbukrs

zbelnr = wa_it_temp1-zbelnr.

if sy-subrc = 0.

date1 = wa_it_temp1-zdate.

date2 = wa_it_temp2-zdate.

time1 = wa_it_temp1-ztime.

time2 = wa_it_temp2-ztime.

PERFORM datetime_diff using date1 date2 time1 time2

changing time date.

IF DATE > 0.

DATE = DATE * 86400.

TIME = DATE + TIME.

w_DIFF = TIME / 60.

ELSE.

w_diff = TIME / 60.

ENDIF.

else.

w_diff = space.

endif.

wa_it_time-zbukrs = wa_it_temp1-zbukrs.

wa_it_time-zbelnr = wa_it_temp1-zbelnr.

wa_it_time-diff = w_diff.

append wa_it_time to it_time.

clear : wa_it_temp1, wa_it_temp2, date1, date2, time1, time2,

date, time, w_diff, wa_it_time.

endloop.

endform. " get_elapsed_time

*&---------------------------------------------------------------------

**& Form datetime_diff

*&---------------------------------------------------------------------

*

*text

*----------------------------------------------------------------------

*

*-->P_DATE1 text

*-->P_DATE2 text

*-->P_TIME1 text

*-->P_TIME2 text

*<--P_TIME text

*<--P_DATE text

*----------------------------------------------------------------------

form datetime_diff using date1 type d

date2 type d

time1 type t

time2 type t

changing time type p

date type p.

DATA: D1 TYPE D, D2 TYPE D, T1 TYPE T, T2 TYPE T.

D1 = DATE1.

T1 = TIME1.

D2 = DATE2.

T2 = TIME2.

* Calculate hours difference

TIME = T2 - T1.

* If no date difference then exit

IF D2 = D1.

DATE = 0.

EXIT.

ENDIF.

* Check for time underflow and correct second date

IF TIME > T2.

D2 = D2 - 1.

ENDIF.

* Calculate date difference

DATE = D2 - D1.

endform. " datetime_diff

  • No labels