A Simple Program to find 1st and 3rd Saturday in a month .
*&---------------------------------------------------------------------*
*& Report ZHR_1N3SAT
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZHR_1N3SAT.
PARAMETERS : YEAR TYPE CHAR4.
TYPES : BEGIN OF STRUC_TAB,
YEAR TYPE CHAR4,
MONTH TYPE CHAR2,
DATE1 TYPE CHAR8,
DATE2 TYPE CHAR8,
END OF STRUC_TAB.
DATA : IT_TAB TYPE TABLE OF STRUC_TAB,
WA_TAB TYPE STRUC_TAB.
DATA : L_DAY TYPE CHAR2,
L_MON TYPE CHAR2,
L_YEAR TYPE CHAR4.
DATA: V_DATE1 TYPE SCAL-DATE,
V_DATE2 TYPE CHAR8,
V_DATE TYPE CHAR8.
DATA : V_DAY LIKE SCAL-INDICATOR.
DATA : V_MON TYPE CHAR2 VALUE '00',
V_I TYPE CHAR2 VALUE '00'.
DO 12 TIMES.
V_MON = v_mon + 1.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = V_MON
IMPORTING
OUTPUT = V_MON .
CONCATENATE YEAR V_MON '01' INTO V_DATE.
V_DATE1 = V_DATE.
CALL FUNCTION 'DATE_COMPUTE_DAY'
EXPORTING
DATE = V_DATE1
IMPORTING
DAY = V_DAY.
IF V_DAY <= 6.
V_I = 6 - V_DAY.
L_DAY = V_DATE1+6(2) + V_I.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = L_DAY
IMPORTING
OUTPUT = L_DAY.
L_MON = V_DATE1+4(2).
L_YEAR = V_DATE1+0(4).
CONCATENATE L_DAY L_MON L_YEAR INTO V_DATE2.
ELSEIF V_DAY = 7.
L_DAY = V_DATE1+6(2) + 6.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = L_DAY
IMPORTING
OUTPUT = L_DAY.
L_MON = V_DATE1+4(2).
L_YEAR = V_DATE1+0(4).
CONCATENATE L_DAY L_MON L_YEAR INTO V_DATE2.
ENDIF.
WA_TAB-YEAR = YEAR.
WA_TAB-MONTH = V_MON.
WA_TAB-DATE1 = V_DATE2.
CONCATENATE YEAR V_MON '15' INTO V_DATE.
V_DATE1 = V_DATE.
CALL FUNCTION 'DATE_COMPUTE_DAY'
EXPORTING
DATE = V_DATE1
IMPORTING
DAY = V_DAY.
IF V_DAY <= 6.
V_I = 6 - V_DAY.
L_DAY = V_DATE1+6(2) + V_I.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = L_DAY
IMPORTING
OUTPUT = L_DAY.
L_MON = V_DATE1+4(2).
L_YEAR = V_DATE1+0(4).
CONCATENATE L_DAY L_MON L_YEAR INTO V_DATE2.
ELSEIF V_DAY = 7.
L_DAY = V_DATE1+6(2) + 6.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = L_DAY
IMPORTING
OUTPUT = L_DAY.
L_MON = V_DATE1+4(2).
L_YEAR = V_DATE1+0(4).
CONCATENATE L_DAY L_MON L_YEAR INTO V_DATE2.
ENDIF.
WA_TAB-DATE2 = V_DATE2.
APPEND WA_TAB TO IT_TAB.
CLEAR WA_TAB.
ENDDO.
WRITE : 'YEAR : MONTH : FIRST SAT : THIRD SAT: '.
LOOP AT IT_TAB INTO WA_TAB.
WRITE :/ WA_TAB-YEAR,' : ',WA_TAB-MONTH,' : ',WA_TAB-DATE1 DD/MM/YYYY ,' : ',WA_TAB-DATE2 DD/MM/YYYY.
ENDLOOP.
*&---------------------------------------------------------------------*
*& Report ZHR_1N3SAT
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZHR_1N3SAT.
PARAMETERS : YEAR TYPE CHAR4.
TYPES : BEGIN OF STRUC_TAB,
YEAR TYPE CHAR4,
MONTH TYPE CHAR2,
DATE1 TYPE CHAR8,
DATE2 TYPE CHAR8,
END OF STRUC_TAB.
DATA : IT_TAB TYPE TABLE OF STRUC_TAB,
WA_TAB TYPE STRUC_TAB.
DATA : L_DAY TYPE CHAR2,
L_MON TYPE CHAR2,
L_YEAR TYPE CHAR4.
DATA: V_DATE1 TYPE SCAL-DATE,
V_DATE2 TYPE CHAR8,
V_DATE TYPE CHAR8.
DATA : V_DAY LIKE SCAL-INDICATOR.
DATA : V_MON TYPE CHAR2 VALUE '00',
V_I TYPE CHAR2 VALUE '00'.
DO 12 TIMES.
V_MON = v_mon + 1.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = V_MON
IMPORTING
OUTPUT = V_MON .
CONCATENATE YEAR V_MON '01' INTO V_DATE.
V_DATE1 = V_DATE.
CALL FUNCTION 'DATE_COMPUTE_DAY'
EXPORTING
DATE = V_DATE1
IMPORTING
DAY = V_DAY.
IF V_DAY <= 6.
V_I = 6 - V_DAY.
L_DAY = V_DATE1+6(2) + V_I.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = L_DAY
IMPORTING
OUTPUT = L_DAY.
L_MON = V_DATE1+4(2).
L_YEAR = V_DATE1+0(4).
CONCATENATE L_DAY L_MON L_YEAR INTO V_DATE2.
ELSEIF V_DAY = 7.
L_DAY = V_DATE1+6(2) + 6.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = L_DAY
IMPORTING
OUTPUT = L_DAY.
L_MON = V_DATE1+4(2).
L_YEAR = V_DATE1+0(4).
CONCATENATE L_DAY L_MON L_YEAR INTO V_DATE2.
ENDIF.
WA_TAB-YEAR = YEAR.
WA_TAB-MONTH = V_MON.
WA_TAB-DATE1 = V_DATE2.
CONCATENATE YEAR V_MON '15' INTO V_DATE.
V_DATE1 = V_DATE.
CALL FUNCTION 'DATE_COMPUTE_DAY'
EXPORTING
DATE = V_DATE1
IMPORTING
DAY = V_DAY.
IF V_DAY <= 6.
V_I = 6 - V_DAY.
L_DAY = V_DATE1+6(2) + V_I.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = L_DAY
IMPORTING
OUTPUT = L_DAY.
L_MON = V_DATE1+4(2).
L_YEAR = V_DATE1+0(4).
CONCATENATE L_DAY L_MON L_YEAR INTO V_DATE2.
ELSEIF V_DAY = 7.
L_DAY = V_DATE1+6(2) + 6.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = L_DAY
IMPORTING
OUTPUT = L_DAY.
L_MON = V_DATE1+4(2).
L_YEAR = V_DATE1+0(4).
CONCATENATE L_DAY L_MON L_YEAR INTO V_DATE2.
ENDIF.
WA_TAB-DATE2 = V_DATE2.
APPEND WA_TAB TO IT_TAB.
CLEAR WA_TAB.
ENDDO.
WRITE : 'YEAR : MONTH : FIRST SAT : THIRD SAT: '.
LOOP AT IT_TAB INTO WA_TAB.
WRITE :/ WA_TAB-YEAR,' : ',WA_TAB-MONTH,' : ',WA_TAB-DATE1 DD/MM/YYYY ,' : ',WA_TAB-DATE2 DD/MM/YYYY.
ENDLOOP.
No comments:
Post a Comment