Skip to Content
0
Former Member
Feb 12, 2007 at 01:39 PM

CHALLANGE : EXPLAIN THIS CODE!!!

43 Views

HELLO TO ALL EXPERTS,

HERE IS A PIECE OF SIMPLE CODE.

KINDLY EXPLAIN.

_____________________________________________________________________

<b>


*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(DATE1) LIKE  PA0000-BEGDA
*"     VALUE(MODIFY_INTERVAL) DEFAULT ' '
*"     VALUE(DATE2) LIKE  PA0000-BEGDA
*"  EXPORTING
*"     VALUE(YEARS_BETWEEN_DATES)
*"  EXCEPTIONS
*"      SEQUENCE_OF_DATES_NOT_VALID
*"----------------------------------------------------------------------

CASE MODIFY_INTERVAL.
  WHEN '+'. DATE1 = DATE1 - 1.
  WHEN '-'. DATE1 = DATE1 + 1.
  WHEN OTHERS.
ENDCASE.

IF DATE1+4(4)  EQ '0229' AND
   DATE2+4(4) EQ '0228'.
   DATE2 = DATE2 + 1.
  IF DATE2+4(4) EQ '0229'.
   DATE2 = DATE2 - 1.
  ENDIF.
ENDIF.


IF DATE1 LE DATE2.
  IF DATE1+4(4) LE DATE2+4(4).
    YEARS_BETWEEN_DATES = DATE2(4) - DATE1(4).
  ELSE.
    YEARS_BETWEEN_DATES = DATE2(4) - DATE1(4) - 1.
  ENDIF.
ELSE.
  YEARS_BETWEEN_DATES = 0.
  RAISE SEQUENCE_OF_DATES_NOT_VALID.
ENDIF.</b>

_____________________________________________________________________

THANKS!!