SAMPLE : how to create a alv report and a interactive button
Labels:
Add Title(heading) to ALV Grid,
button and alv report,
how to create a alv report and a interactive button,
HR reporting - defaulting value,
interactive alv report
REPORT ZSOLRMA047.
TYPE-POOLS: SLIS.
TABLES: PERNR, ZIT0762, PA0762, PA0761.
INFOTYPES : 0761, 0762, 9033, 0002, 0001.
*--------------------------------------------------------------------*
* Types
*--------------------------------------------------------------------*
TYPES: BEGIN OF TY_REPORT,
SKIP(1) TYPE C,
SEQNO TYPE I,
BUTXT TYPE T001-BUTXT, " Company name
PERNR TYPE P0761-PERNR, " PF No.
CNAME TYPE P0002-CNAME, " Name 2012 July 06
EXEDT TYPE P0762-BEGDA, " Exercise Date
CPLAN TYPE P0762-CPLAN, " Compensation Plan
CITEM TYPE P0762-CPLAN, " review item
EXENO TYPE P0762-EXENO, " No. of Shares Exercised
EXPRI TYPE P0762-EXPRI, " Option Price
CHKNO TYPE P0762-CHKNO, " Bank Draft/Cashier#s Order
EXETC TYPE P0762-EXETC, " Total Cost
PA0762 TYPE TEXT12, " PA0762 Status
ZIT0762 TYPE TEXT12, " ZIT0762 Status
REMARK TYPE C LENGTH 50, " Remarks
OBJPS TYPE PA0762-OBJPS,
* EXENO TYPE PA0762-EXENO,
SUBTY TYPE PA0762-SUBTY,
SPRPS TYPE PA0762-SPRPS,
BEGDA TYPE PA0762-BEGDA,
ENDDA TYPE PA0762-ENDDA,
SEQNR TYPE PA0762-SEQNR,
EXEON TYPE PA0762-EXEON,
EXEST TYPE PA0762-EXEST,
" gradt TYPE p0761-begda, " Grant Date
" begda TYPE p0762-begda, " Exercise Date
" pa0761 TYPE text12, " PA0761 Status
" cdsac_stat TYPE c LENGTH 50, " CDS Account Status
END OF TY_REPORT.
*--------------------------------------------------------------------*
* Variables
*--------------------------------------------------------------------*
DATA: T_REPORT TYPE STANDARD TABLE OF TY_REPORT WITH HEADER LINE INITIAL SIZE 0,
R_REPORT LIKE LINE OF T_REPORT,
R_P0762 TYPE P0762,
G_ERROR TYPE C,
R_ZIT0762 TYPE ZIT0762,
T_HEADER TYPE SLIS_T_LISTHEADER,
R_HEADER TYPE SLIS_LISTHEADER,
G_TOTAL_REC TYPE I,
G_ERROR_REC TYPE I,
G_EXPRI TYPE ECM_EXPRI,
" g_balance TYPE p0761-grano,
GV_PROCEED TYPE CHAR1,
GV_PA0762_BEGDA TYPE PA0762-BEGDA.
*--------------------------------------------------------------------*
* ALV
*--------------------------------------------------------------------*
DATA: R_FRAME TYPE SLIS_LAYOUT_ALV,
T_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
T_SORT TYPE SLIS_T_SORTINFO_ALV,
T_EVENT TYPE SLIS_T_EVENT,
R_EVENT TYPE SLIS_ALV_EVENT,
G_REPID TYPE SY-REPID.
CONSTANTS: C_SUCCESSFUL TYPE TEXT12 VALUE 'Successful',
C_UNSUCCESSFUL TYPE TEXT12 VALUE 'Unsuccessful',
C_CHEQUE_NOT_RECEIVED TYPE CHAR2 VALUE '09',
C_PENDING_PAYMENT TYPE CHAR2 VALUE '02'.
*--------------------------------------------------------------------*
* Selection Screen
*--------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK A1 WITH FRAME TITLE TEXT-001.
*SELECT-OPTIONS: s_rsu FOR pa0762-cplan NO INTERVALS, "RSU / SRSU Plan
* s_gradt FOR pa0761-begda NO INTERVALS NO-EXTENSION. "Grant Date
PARAMETERS: P_PRCDT TYPE BEGDA DEFAULT SY-DATUM OBLIGATORY. "Processing date
PARAMETERS: P_DAYS TYPE INTEGER DEFAULT 14 OBLIGATORY. "Number of days
SELECTION-SCREEN SKIP 1.
PARAMETERS: P_TEST TYPE C AS CHECKBOX DEFAULT 'X'. "Test Run
SELECTION-SCREEN END OF BLOCK A1.
*--------------------------------------------------------------------*
* Initialization
*--------------------------------------------------------------------*
INITIALIZATION.
G_REPID = SY-REPID.
*--------------------------------------------------------------------*
* START-OF-SELECTION.
*--------------------------------------------------------------------*
START-OF-SELECTION.
PERFORM GET_EXERCISE_START_DATE CHANGING GV_PA0762_BEGDA.
GET PERNR.
CLEAR GV_PROCEED.
PERFORM F_VALIDATE_9033 CHANGING GV_PROCEED.
CLEAR: R_P0762, R_REPORT, P0762.
CASE GV_PROCEED.
WHEN 'X'.
PROVIDE * FROM P0762 BETWEEN GV_PA0762_BEGDA AND GV_PA0762_BEGDA."p_prcdt.
CASE P0762-EXEST. "Exercise Status
WHEN '02'. "Pending Payment
PERFORM PREPARE_P0762.
PERFORM PREPARE_REPORT.
R_REPORT-SEQNO = G_TOTAL_REC.
APPEND R_REPORT TO T_REPORT.
ENDCASE.
ENDPROVIDE.
ENDCASE.
END-OF-SELECTION.
READ TABLE T_REPORT INTO R_REPORT INDEX 1.
IF SY-SUBRC = 0.
PERFORM DISPLAY_REPORT.
ELSE.
MESSAGE S002(SY) WITH 'No record found'.
EXIT.
ENDIF.
*&---------------------------------------------------------------------*
*& Form prepare_p0762
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM PREPARE_P0762.
CLEAR: G_EXPRI, R_P0762.
MOVE-CORRESPONDING P0762 TO R_P0762.
R_P0762-AEDTM = SY-DATUM.
R_P0762-UNAME = SY-UNAME.
R_P0762-BEGDA = P0762-BEGDA.
R_P0762-CPLAN = P0762-CPLAN.
IF P0762-EXPRI EQ '0.00' OR P0762-EXPRI IS INITIAL.
SELECT * FROM PA0761 WHERE CPLAN = P0762-CPLAN AND OBJPS = P0762-OBJPS AND PERNR = P0762-PERNR.
SELECT EXPRI FROM T71LTI03 INTO G_EXPRI WHERE CPLAN EQ P0762-CPLAN
AND BEGDA LE P0761-GRADT AND ENDDA GE P0761-GRADT.
ENDSELECT.
EXIT.
ENDSELECT.
ELSE.
G_EXPRI = R_P0762-EXPRI = P0762-EXPRI.
ENDIF.
R_P0762-CITEM = P0762-CITEM.
R_P0762-EXENO = P0762-EXENO.
R_P0762-CHKNO = P0762-CHKNO.
R_P0762-EXETC = P0762-EXETC.
ENDFORM. " prepare_p0762
FORM PREPARE_P0762_REPORT.
CLEAR: G_EXPRI, R_P0762.
SELECT SINGLE * FROM PA0762 WHERE PERNR EQ T_REPORT-PERNR AND
SUBTY EQ T_REPORT-SUBTY AND
OBJPS EQ T_REPORT-OBJPS AND
ENDDA EQ T_REPORT-ENDDA AND
SEQNR EQ T_REPORT-SEQNR.
MOVE-CORRESPONDING PA0762 TO R_P0762.
R_P0762-AEDTM = SY-DATUM.
R_P0762-UNAME = SY-UNAME.
R_P0762-BEGDA = T_REPORT-BEGDA.
R_P0762-CPLAN = T_REPORT-CPLAN.
IF T_REPORT-EXPRI EQ '0.00' OR T_REPORT-EXPRI IS INITIAL.
SELECT * FROM PA0761 WHERE CPLAN = T_REPORT-CPLAN AND OBJPS = T_REPORT-OBJPS AND PERNR = T_REPORT-PERNR.
SELECT EXPRI FROM T71LTI03 INTO G_EXPRI WHERE CPLAN EQ T_REPORT-CPLAN
AND BEGDA LE P0761-GRADT AND ENDDA GE P0761-GRADT.
ENDSELECT.
EXIT.
ENDSELECT.
ELSE.
G_EXPRI = T_REPORT-EXPRI = T_REPORT-EXPRI.
ENDIF.
R_P0762-CITEM = T_REPORT-CITEM.
R_P0762-EXENO = T_REPORT-EXENO.
R_P0762-CHKNO = T_REPORT-CHKNO.
R_P0762-EXETC = T_REPORT-EXETC.
ENDFORM. " prepare_p0762
*&---------------------------------------------------------------------*
*& Form UPDATE_ZIT0762
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_STATUS text
*----------------------------------------------------------------------*
FORM UPDATE_ZIT0762 USING P_STATUS.
CHECK P_TEST IS INITIAL.
DATA: R_RETURN TYPE BAPIRETURN1.
MOVE-CORRESPONDING PA0762 TO R_ZIT0762.
MOVE-CORRESPONDING R_P0762 TO R_ZIT0762.
R_ZIT0762-EXEDT = PA0762-BEGDA.
R_ZIT0762-EXPRI = G_EXPRI.
R_ZIT0762-EXEST = P_STATUS.
SELECT SINGLE EXFMV FROM ZFMVAL INTO R_ZIT0762-FMVVD WHERE DATUM EQ R_P0762-VESDT.
* INSERT INTO zit0762 VALUES r_zit0762.
* move-corresponding r_zit0762 to zit0762.
UPDATE ZIT0762
SET
EXEST = R_ZIT0762-EXEST
* 2012july18 changes to tag last changes by who and when
AEDTM = SY-DATUM
UNAME = SY-UNAME
* 2012july18 changes to tag last changes by who and when
WHERE
PERNR EQ R_ZIT0762-PERNR
AND EXEDT EQ R_ZIT0762-EXEDT
AND EXEON EQ R_ZIT0762-EXEON
AND CPLAN EQ R_ZIT0762-CPLAN
AND OBJPS EQ R_ZIT0762-OBJPS.
IF SY-SUBRC <> 0.
G_ERROR = 'X'.
G_ERROR_REC = G_ERROR_REC + 1.
R_REPORT-PA0762 = R_REPORT-ZIT0762 = C_UNSUCCESSFUL.
IF P_TEST IS INITIAL.
" Failed Update of ZIT0762
R_REPORT-REMARK = TEXT-E05.
ELSE.
" Failed Update of ZIT0762
CONCATENATE TEXT-S01 TEXT-E05 INTO T_REPORT-REMARK SEPARATED BY SPACE.
ENDIF.
" APPEND r_report TO t_report.
" CLEAR r_report.
ROLLBACK WORK.
CALL FUNCTION 'HR_EMPLOYEE_DEQUEUE'
EXPORTING
NUMBER = R_P0762-PERNR
IMPORTING
RETURN = R_RETURN.
ELSE.
COMMIT WORK AND WAIT.
R_REPORT-ZIT0762 = C_SUCCESSFUL.
R_REPORT-ZIT0762 = C_SUCCESSFUL.
ENDIF.
ENDFORM. " UPDATE_ZIT0762
*&---------------------------------------------------------------------*
*& Form UPDATE_INFOTYPE_0762
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM UPDATE_INFOTYPE_0762.
DATA: L_USER LIKE SY-UNAME,
R_RETURN TYPE BAPIRETURN1.
CALL FUNCTION 'HR_EMPLOYEE_ENQUEUE'
EXPORTING
NUMBER = R_P0762-PERNR
IMPORTING
RETURN = R_RETURN
LOCKING_USER = L_USER.
IF R_RETURN IS NOT INITIAL.
G_ERROR = 'X'.
G_ERROR_REC = G_ERROR_REC + 1.
R_REPORT-PA0762 = R_REPORT-ZIT0762 = C_UNSUCCESSFUL.
IF P_TEST IS INITIAL.
"PA0762 Locked by XXXXXXX
CONCATENATE TEXT-E03 L_USER INTO R_REPORT-REMARK SEPARATED BY SPACE.
ELSE.
"PA0762 Locked by XXXXXXX
CONCATENATE TEXT-S01 TEXT-E03 L_USER INTO R_REPORT-REMARK SEPARATED BY SPACE.
ENDIF.
APPEND R_REPORT TO T_REPORT.
CLEAR R_REPORT.
EXIT.
ENDIF.
CALL FUNCTION 'HR_INITIALIZE_BUFFER'
EXPORTING
PERNR = R_P0762-PERNR.
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
INFTY = '0762'
NUMBER = R_P0762-PERNR
SUBTYPE = R_P0762-SUBTY
OBJECTID = R_P0762-OBJPS
LOCKINDICATOR = R_P0762-SPRPS
VALIDITYEND = R_P0762-ENDDA
VALIDITYBEGIN = R_P0762-BEGDA
RECORDNUMBER = R_P0762-SEQNR
RECORD = R_P0762
"operation = 'INS'
OPERATION = 'MOD'
NOCOMMIT = 'X'
IMPORTING
RETURN = R_RETURN.
IF R_RETURN IS INITIAL.
R_REPORT-PA0762 = C_SUCCESSFUL.
IF P_TEST IS INITIAL.
"Successful Update of PA0762
R_REPORT-REMARK = TEXT-S02.
ELSE.
"Successful Update of PA0762
CONCATENATE TEXT-S01 TEXT-S02 INTO R_REPORT-REMARK SEPARATED BY SPACE.
ENDIF.
APPEND R_REPORT TO T_REPORT.
ELSE.
IF R_RETURN-TYPE EQ 'E'.
G_ERROR = 'X'.
G_ERROR_REC = G_ERROR_REC + 1.
R_REPORT-PA0762 = R_REPORT-ZIT0762 = C_UNSUCCESSFUL.
IF P_TEST IS INITIAL.
" Failed Update of PA0762
R_REPORT-REMARK = TEXT-E04.
ELSE.
" Failed Update of PA0762
CONCATENATE TEXT-S01 TEXT-E04 INTO R_REPORT-REMARK SEPARATED BY SPACE.
ENDIF.
APPEND R_REPORT TO T_REPORT.
CLEAR R_REPORT.
CALL FUNCTION 'HR_EMPLOYEE_DEQUEUE'
EXPORTING
NUMBER = R_P0762-PERNR
IMPORTING
RETURN = R_RETURN.
ENDIF.
ENDIF.
ENDFORM. " UPDATE_INFOTYPE_0762
*&---------------------------------------------------------------------*
*& Form PREPARE_REPORT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM PREPARE_REPORT.
MOVE-CORRESPONDING P0762 TO R_REPORT.
R_REPORT-EXEDT = P0762-BEGDA.
PROVIDE CNAME FROM P0002 BETWEEN SY-DATUM AND SY-DATUM.
R_REPORT-CNAME = P0002-CNAME.
EXIT.
ENDPROVIDE.
PROVIDE BUKRS FROM P0001 BETWEEN SY-DATUM AND SY-DATUM.
SELECT BUTXT FROM T001 INTO R_REPORT-BUTXT WHERE BUKRS EQ P0001-BUKRS.
ENDSELECT.
ENDPROVIDE.
R_REPORT-EXPRI = G_EXPRI.
G_TOTAL_REC = G_TOTAL_REC + 1.
ENDFORM. "prepare_report
*&---------------------------------------------------------------------*
*& Form DISPLAY_REPORT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DISPLAY_REPORT .
PERFORM F_SET_FRAME USING R_FRAME.
PERFORM SET_FIELDCAT.
PERFORM F_SET_EVENT.
PERFORM F_SHOW.
ENDFORM. " DISPLAY_REPORT
*&---------------------------------------------------------------------*
*& Form F_SET_FRAME
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GT_FRAME text
*----------------------------------------------------------------------*
FORM F_SET_FRAME USING GT_FRAME TYPE SLIS_LAYOUT_ALV.
CLEAR GT_FRAME.
GT_FRAME-COLWIDTH_OPTIMIZE = 'X'.
GT_FRAME-WINDOW_TITLEBAR = SY-TITLE.
ENDFORM. " F_SET_FRAME
*&---------------------------------------------------------------------*
*& Form SET_FIELDCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SET_FIELDCAT.
DATA: L_POS TYPE I.
CLEAR L_POS.
ADD 1 TO L_POS.
PERFORM F_CRTE_FCAT USING 'SKIP' 'Skip?' L_POS 'L'.
ADD 1 TO L_POS.
PERFORM F_CRTE_FCAT USING 'SEQNO' 'No.' L_POS 'L'.
ADD 1 TO L_POS.
PERFORM F_CRTE_FCAT USING 'BUTXT' TEXT-T01 L_POS 'L'.
"Company Name
ADD 1 TO L_POS.
PERFORM F_CRTE_FCAT USING 'PERNR' TEXT-T02 L_POS 'L'.
"PF No.
ADD 1 TO L_POS.
PERFORM F_CRTE_FCAT USING 'CNAME' TEXT-T03 L_POS 'L'.
"Name
ADD 1 TO L_POS.
PERFORM F_CRTE_FCAT USING 'EXEDT' TEXT-T04 L_POS 'L'.
"Exercise Date
ADD 1 TO L_POS.
PERFORM F_CRTE_FCAT USING 'CPLAN' TEXT-T05 L_POS 'L'.
"Offer changed from Compensation Plan
ADD 1 TO L_POS.
PERFORM F_CRTE_FCAT USING 'CITEM' TEXT-T06 L_POS 'L'.
"Tranche changed from Review Item
ADD 1 TO L_POS.
PERFORM F_CRTE_FCAT USING 'EXENO' TEXT-T07 L_POS 'L'.
"No. of Shares Exercised
ADD 1 TO L_POS.
PERFORM F_CRTE_FCAT USING 'EXPRI' TEXT-T08 L_POS 'L'.
"Option Price
ADD 1 TO L_POS.
PERFORM F_CRTE_FCAT USING 'EXETC' TEXT-T09 L_POS 'L'.
"Total Cost
ADD 1 TO L_POS.
PERFORM F_CRTE_FCAT USING 'CHKNO' TEXT-T10 L_POS 'L'.
"Bank Draft/Cashier's Order
* ADD 1 TO l_pos.
* PERFORM f_crte_fcat USING 'PA0762' text-t11 l_pos 'L'.
* " PA0762 Status
* ADD 1 TO l_pos.
* PERFORM f_crte_fcat USING 'ZIT0762' text-t12 l_pos 'L'.
* " ZIT0762 Status
ADD 1 TO L_POS.
PERFORM F_CRTE_FCAT USING 'REMARK' TEXT-T13 L_POS 'L'.
"Remarks
*
* ADD 1 TO l_pos.
* PERFORM f_crte_fcat USING 'EXEST' 'EXE STAT' l_pos 'L'.
* OBJPS TYPE PA0762-OBJPS,
* SUBTY TYPE PA0762-SUBTY,
* SPRPS TYPE PA0762-SPRPS,
* BEGDA TYPE PA0762-BEGDA,
* ENDDA TYPE PA0762-ENDDA,
* SEQNR TYPE PA0762-SEQNR,
* EXEON TYPE PA0762-EXEON,
* EXEST TYPE PA0762-EXEST,
ENDFORM. " SET_FIELDCAT
*&---------------------------------------------------------------------*
*& Form F_CRTE_FCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_0879 text
* -->P_TEXT_T01 text
* -->P_L_POS text
* -->P_0882 text
*----------------------------------------------------------------------*
FORM F_CRTE_FCAT USING SI_TP_FIELDNAME TYPE SLIS_FIELDNAME
SI_TP_TEXT TYPE DD03P-SCRTEXT_L
SI_POS TYPE I
SI_DDICTXT TYPE DDICTXT.
DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
CLEAR LS_FIELDCAT.
IF SI_POS EQ 1.
LS_FIELDCAT-NO_ZERO = 'X'.
LS_FIELDCAT-CHECKBOX = 'X'.
LS_FIELDCAT-INPUT = 'X'.
ENDIF.
LS_FIELDCAT-COL_POS = SI_POS.
LS_FIELDCAT-FIELDNAME = SI_TP_FIELDNAME.
LS_FIELDCAT-SELTEXT_L = SI_TP_TEXT.
LS_FIELDCAT-DDICTXT = SI_DDICTXT.
APPEND LS_FIELDCAT TO T_FIELDCAT.
ENDFORM. "f_create_fcat
*&---------------------------------------------------------------------*
*& Form f_set_event
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM F_SET_EVENT.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = T_EVENT.
"Top of Page
READ TABLE T_EVENT WITH KEY NAME = SLIS_EV_TOP_OF_PAGE
INTO R_EVENT.
IF SY-SUBRC = 0.
MOVE 'F_ALV_TOP_OF_PAGE' TO R_EVENT-FORM.
MODIFY T_EVENT FROM R_EVENT INDEX SY-TABIX.
ENDIF.
ENDFORM. "f_set_event
*&---------------------------------------------------------------------*
*& Form f_alv_top_of_page
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM F_ALV_TOP_OF_PAGE.
DATA: L_PROCESSED TYPE C LENGTH 5,
L_ERROR TYPE C LENGTH 5.
CLEAR T_HEADER.
L_PROCESSED = G_TOTAL_REC.
L_ERROR = G_ERROR_REC.
CLEAR R_HEADER.
R_HEADER-TYP = 'H'.
CONCATENATE SY-CPROG '-' SY-TITLE INTO R_HEADER-INFO SEPARATED BY SPACE.
APPEND R_HEADER TO T_HEADER.
CLEAR R_HEADER.
R_HEADER-TYP = 'S'.
R_HEADER-KEY = 'Date:'.
WRITE SY-DATUM TO R_HEADER-INFO.
APPEND R_HEADER TO T_HEADER.
CLEAR R_HEADER.
R_HEADER-TYP = 'S'.
R_HEADER-KEY = 'Time:'.
WRITE SY-UZEIT TO R_HEADER-INFO.
APPEND R_HEADER TO T_HEADER.
CLEAR R_HEADER.
R_HEADER-TYP = 'S'.
R_HEADER-KEY = 'Processed:'.
CONCATENATE L_PROCESSED 'record(s)' INTO R_HEADER-INFO SEPARATED BY SPACE.
APPEND R_HEADER TO T_HEADER.
CLEAR R_HEADER.
R_HEADER-TYP = 'S'.
R_HEADER-KEY = 'Error:'.
CONCATENATE L_ERROR 'record(s)' INTO R_HEADER-INFO SEPARATED BY SPACE.
APPEND R_HEADER TO T_HEADER.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = T_HEADER.
ENDFORM. "f_alv_top_of_page
*&---------------------------------------------------------------------*
*& Form F_SHOW
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM F_SHOW .
CASE P_TEST.
WHEN 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = G_REPID
IS_LAYOUT = R_FRAME
IT_FIELDCAT = T_FIELDCAT[]
IT_EVENTS = T_EVENT[]
I_DEFAULT = 'X'
I_SAVE = 'A'
TABLES
T_OUTTAB = T_REPORT
EXCEPTIONS
PROGRAM_ERROR = 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.
WHEN OTHERS.
DATA W_SELHIDE TYPE SLIS_SEL_HIDE_ALV.
W_SELHIDE-MODE = 'X'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = G_REPID
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_PF_STATUS_SET = 'SET_STAT'
IS_LAYOUT = R_FRAME
IT_FIELDCAT = T_FIELDCAT[]
IT_EVENTS = T_EVENT[]
I_SAVE = 'A'
TABLES
T_OUTTAB = T_REPORT
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC NE 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDCASE.
ENDFORM. " F_SHOW
*&---------------------------------------------------------------------*
*& Form F_VALIDATE_9033
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_GV_PROCEED text
*----------------------------------------------------------------------*
FORM F_VALIDATE_9033 CHANGING GV_PROCEED.
CLEAR GV_PROCEED.
TABLES PA9033.
SELECT * FROM PA9033 WHERE BEGDA LE SY-DATUM AND ENDDA GE SY-DATUM.
CASE P9033-METHD.
WHEN 01. "Self Funding
GV_PROCEED = 'X'.
EXIT.
ENDCASE.
ENDSELECT.
ENDFORM. " F_VALIDATE_9033
*&---------------------------------------------------------------------*
*& Form GET_EXERCISE_START_DATE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_GV_PA0762_BEGDA text
*----------------------------------------------------------------------*
FORM GET_EXERCISE_START_DATE CHANGING GV_PA0762_BEGDA.
CLEAR GV_PA0762_BEGDA.
* GV_PA0762_BEGDA = p_prcdt - p_days. "<-------- without checking working days
* CHECK working day of KL = MA
* The PA0762-BEGDA (Exercise Date) is "No. of Working Days" from "Processing Date" in the selection screen.
* get GV_PA0762_BEGDA
P_DAYS = P_DAYS * -1.
CALL FUNCTION 'BKK_ADD_WORKINGDAY'
EXPORTING
I_DATE = P_PRCDT
I_DAYS = P_DAYS
I_CALENDAR1 = 'ZE'"'MA'
"I_CALENDAR2 = 'MA'
IMPORTING
E_DATE = GV_PA0762_BEGDA
* E_RETURN =
.
ENDFORM. " GET_EXERCISE_START_DATE
*&---------------------------------------------------------------------*
*& Form DELETE_INFOTYPE_0762
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DELETE_INFOTYPE_0762 .
DATA: L_USER LIKE SY-UNAME,
R_RETURN TYPE BAPIRETURN1.
CALL FUNCTION 'HR_EMPLOYEE_ENQUEUE'
EXPORTING
NUMBER = R_P0762-PERNR
IMPORTING
RETURN = R_RETURN
LOCKING_USER = L_USER.
IF R_RETURN IS NOT INITIAL.
G_ERROR = 'X'.
G_ERROR_REC = G_ERROR_REC + 1.
T_REPORT-PA0762 = T_REPORT-ZIT0762 = C_UNSUCCESSFUL.
IF P_TEST IS INITIAL.
"PA0762 Locked by XXXXXXX
CONCATENATE TEXT-E03 L_USER INTO T_REPORT-REMARK SEPARATED BY SPACE.
ELSE.
"PA0762 Locked by XXXXXXX
CONCATENATE TEXT-S01 TEXT-E03 L_USER INTO T_REPORT-REMARK SEPARATED BY SPACE.
ENDIF.
"APPEND R_REPORT TO T_REPORT.
"CLEAR R_REPORT.
EXIT.
ENDIF.
CALL FUNCTION 'HR_INITIALIZE_BUFFER'
EXPORTING
PERNR = R_P0762-PERNR.
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
INFTY = '0762'
NUMBER = R_P0762-PERNR
SUBTYPE = R_P0762-SUBTY
OBJECTID = R_P0762-OBJPS
* lockindicator = r_p0762-sprps
VALIDITYEND = R_P0762-ENDDA
VALIDITYBEGIN = R_P0762-BEGDA
* recordnumber = r_p0762-seqnr
RECORD = R_P0762
OPERATION = 'DEL'
* nocommit = 'X'
IMPORTING
RETURN = R_RETURN.
IF R_RETURN IS INITIAL.
T_REPORT-PA0762 = C_SUCCESSFUL.
IF P_TEST IS INITIAL.
"Successful Update of PA0762
"t_report-REMARK = TEXT-S02.
ELSE.
"Successful Update of PA0762
"CONCATENATE TEXT-S01 TEXT-S02 INTO t_report-REMARK SEPARATED BY SPACE.
ENDIF.
"APPEND R_REPORT TO T_REPORT.
ELSE.
IF R_RETURN-TYPE EQ 'E'.
G_ERROR = 'X'.
G_ERROR_REC = G_ERROR_REC + 1.
T_REPORT-PA0762 = T_REPORT-ZIT0762 = C_UNSUCCESSFUL.
IF P_TEST IS INITIAL.
" Failed to Delete of PA0762
T_REPORT-REMARK = TEXT-E06.
ELSE.
" Failed Update of PA0762
CONCATENATE TEXT-S01 TEXT-E06 INTO T_REPORT-REMARK SEPARATED BY SPACE.
ENDIF.
" APPEND R_REPORT TO T_REPORT.
"CLEAR R_REPORT.
CALL FUNCTION 'HR_EMPLOYEE_DEQUEUE'
EXPORTING
NUMBER = R_P0762-PERNR
IMPORTING
RETURN = R_RETURN.
ENDIF.
ENDIF.
ENDFORM. " DELETE_INFOTYPE_0762
FORM SET_STAT USING RT_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'STANDARD' EXCLUDING RT_EXTAB.
ENDFORM. "SET_STAT
*&---------------------------------------------------------------------*
*& Form USER_COMMAND
*&---------------------------------------------------------------------*
FORM USER_COMMAND USING FU_UCOMM LIKE SY-UCOMM
FU_SELFIELD TYPE SLIS_SELFIELD.
CASE FU_UCOMM.
WHEN 'PROCESS'. "TYPE STANDARD TABLE OF
*--------------------------------------------------------------------
*--------------------------------------------------------------------
LOOP AT T_REPORT.
*--------------------------------------------------------------------
CASE T_REPORT-REMARK.
WHEN ''.
*--------------------------------------------------------------------
CASE T_REPORT-SKIP.
WHEN 'X'.
T_REPORT-REMARK = 'Skipped'.
WHEN OTHERS.
PERFORM PREPARE_P0762_REPORT.
PERFORM UPDATE_ZIT0762 USING C_CHEQUE_NOT_RECEIVED.
IF R_REPORT-ZIT0762 = C_UNSUCCESSFUL.
T_REPORT-REMARK = 'ZIT0762 fail'.
ELSE.
PERFORM DELETE_INFOTYPE_0762.
IF G_ERROR IS INITIAL.
T_REPORT-EXEST = '09'. "(No Cheque Received)
T_REPORT-REMARK = 'Processed'.
ELSE.
T_REPORT-REMARK = 'PA0762 fail'.
PERFORM UPDATE_ZIT0762 USING C_PENDING_PAYMENT.
ENDIF.
ENDIF.
ENDCASE.
*--------------------------------------------------------------------
WHEN 'Skipped'. "do nothing
WHEN 'Processed'. "do nothing
ENDCASE.
*--------------------------------------------------------------------
MODIFY T_REPORT.
ENDLOOP.
*--------------------------------------------------------------------
*--------------------------------------------------------------------
P_TEST = 'X'. "Remove button
PERFORM REFRESH_REPORT.
WHEN OTHERS.
ENDCASE.
* READ TABLE t_report INTO r_report INDEX 1.
* IF sy-subrc = 0.
* PERFORM display_report.
* endif.
ENDFORM. " USER_COMMAND
*&---------------------------------------------------------------------*
*& Form REFRESH_REPORT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM REFRESH_REPORT .
PERFORM F_SET_FRAME USING R_FRAME.
* PERFORM set_fieldcat.
PERFORM F_SET_EVENT.
PERFORM F_SHOW.
LEAVE TO SCREEN 0.
ENDFORM. " REFRESH_REPORT
Post a Comment