MESSAGE-ID Z_MSGCLASS " Message class
LINE-SIZE 132. " Width of Report display
************************************************************************
* Report Name : Z_PM_RP_ELE_PERMIT_TO_WORK *
* Description : Plant Maintanence: Electrical Permit To Work *
* This report displays the following: *
* 1)Description of plant *
* 2)Work to be carried out *
* 3)Details of plant isolation and safety precaution*
* 4)Safety & Fire Manager *
* 5)General Manager *
* 6)Earths Applied *
* 7)Special Precautions to be taken *
* 8)Authorisation *
* 9)Reciept *
* 10)Detail of Work Completed *
* 11)Clearance *
* 12)Cancellation *
* based on Order No.Planning Plant & Requsted Date *
* *
* *
* Functional : *
* Developer : *
* Development class : *
************************************************************************
*----------------------------------------------------------------------*
* Request No. Created Date Developer name *
*----------------------------------------------------------------------*
* LD1K900757 21/03/2006 Harini.S
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
* INCLUDES *
*----------------------------------------------------------------------*
INCLUDE
*----------------------------------------------------------------------*
* DATABASE TABLES *
*----------------------------------------------------------------------*
TABLES: AUFK, " Order master data
T357G, " Permits
ZPMPERMITS. " PM Permits Log
*---------------------------------------------------------------------*
* INTERNAL TABLE DECLARATION *
*---------------------------------------------------------------------*
*---- Internal table to hold PM Permits Log 'ZPMPERMITS'
DATA: IT_PERMITS LIKE ZPMPERMITS OCCURS 0 WITH HEADER LINE,
*---- Internal table to hold Permit conditions from ZMNTTEXT
IT_MNTTEXT LIKE ZMNTTEXT OCCURS 0 WITH HEADER LINE.
*---- Internal table to hold Maintenance Order Header Data 'AFIH'
DATA: BEGIN OF IT_AFIH OCCURS 10,
AUFNR LIKE AFIH-AUFNR, " Order Number(WO NO)
EQUNR LIKE AFIH-EQUNR, " Equipment number
ILOAN LIKE AFIH-ILOAN, " Location and acct assignment for tech obj
QMNUM LIKE AFIH-QMNUM, " Notification Number(WR No)
END OF IT_AFIH.
*---- Internal table to hold Equipment Short Texts
DATA: BEGIN OF IT_EQKT OCCURS 0,
EQUNR LIKE EQKT-EQUNR, " Equipment number
EQKTX LIKE EQKT-EQKTX, " Description of technical object
END OF IT_EQKT.
*---- Internal table to hold Text for Table 357GT
DATA : BEGIN OF IT_T357G_T OCCURS 0,
PMSOG LIKE T357G_T-PMSOG, " Permit Key
GNTXT LIKE T357G_T-GNTXT, " Short Text for Permit
END OF IT_T357G_T.
*--- Internal table to hold texts
DATA: IT_TLINE LIKE TLINE OCCURS 0 WITH HEADER LINE.
*------Internal table to hold Functional Location
DATA : BEGIN OF IT_ILOA OCCURS 0,
ILOAN LIKE ILOA-ILOAN, " Location and acc assignment for tec obj
TPLNR LIKE ILOA-TPLNR, " Functional Location
END OF IT_ILOA.
*------ Internal table to hold Functional Location: Short Texts
DATA : BEGIN OF IT_IFLOTX OCCURS 0,
TPLNR LIKE IFLOTX-TPLNR, " Functional Location
PLTXT LIKE IFLOTX-PLTXT, " Desc of functional location
END OF IT_IFLOTX.
*--- Internal table to hold texts for splitting
DATA: BEGIN OF IT_TEXT OCCURS 0,
TEXT(132), " Text
END OF IT_TEXT.
*--- Internal table to hold split texts
DATA: BEGIN OF IT_RTEXT OCCURS 0,
TEXT(132), " Text
END OF IT_RTEXT.
*---------------------------------------------------------------------*
* GLOBAL VARIABLE DECLARATION *
*---------------------------------------------------------------------*
DATA: V_MESG TYPE STRING, " Message
V_NAME LIKE THEAD-TDNAME, " Field Name
V_ID LIKE THEAD-TDID, " Text ID
V_FIELD(30), " Field
V_AUFNR LIKE ZPMPERMITS-AUFNR, " Object No
V_PMSOG LIKE ZPMPERMITS-PMSOG. " Permit Key
*---- Variables used to display the Report footer
DATA: V_FOOT1(125) TYPE C, " Footer String1
V_FOOT2(125) TYPE C. " Footer String2
*---- Variables used for Excel file download
DATA: V_SOURCE_FILE TYPE RLGRAP-FILENAME VALUE 'C:\SAMPLE1.XLS',
V_DESTINATION_FILE TYPE RLGRAP-FILENAME, " File Name
V_TITLE LIKE SPOP-TITEL, " File Path
V_DESC(132) TYPE C. " Description of Plant
*--- Variables used for Long Text Splitting
DATA: V_LEN TYPE I, " Variable Length
V_LEN1 TYPE I, " Var Length
V_LN TYPE I,
V_TEXT(132), " Text
V_TXT(132), " Text
V_OFFSET1 TYPE I, " Offset
V_OFFSET TYPE I. " Offset
*---------------------------------------------------------------------*
* FLAGS *
*---------------------------------------------------------------------*
DATA : F_STOP.
*---------------------------------------------------------------------*
* CONSTANTS *
*---------------------------------------------------------------------*
CONSTANTS: C_OBJECT LIKE THEAD-TDOBJECT VALUE 'IHSG', " Object Id
C_ELEC LIKE T357G_T-PMSOG VALUE 'ELEC'. " Permit Key
*---------------------------------------------------------------------*
* SELECTION SCREEN *
*---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-111.
SELECT-OPTIONS: S_AUFNR FOR AUFK-AUFNR OBLIGATORY, " Order Number
S_REQDT FOR ZPMPERMITS-REQDT. " Requested Date
PARAMETERS : P_IWERK LIKE ZPMPERMITS-IWERK OBLIGATORY. " Planning Plant
SELECTION-SCREEN END OF BLOCK B1.
*---------------------------------------------------------------------*
* START-OF-SELECTION *
*---------------------------------------------------------------------*
START-OF-SELECTION.
*--- Perform to get the Permit log details from the table 'ZPMPERMITS'
PERFORM GET_PERMIT_LOG_DETAILS.
*--- Perform to get the conditions for the Permit Keys
PERFORM GET_PERMIT_CONDITIONS.
*--- Perform to get Maintenance Order Header Data
PERFORM GET_AFIH_DATA.
*--- Perform to get Functional Location
PERFORM GET_FUNC_LOC_DATA.
*--- Perform to get Functional Location: Short Texts
PERFORM GET_FUNC_LOC_TEXT_DATA.
*--- Perform to get Text for Table 357GT
PERFORM GET_T357G_T_DATA.
*--- Perform to get Equipment Short Texts
PERFORM GET_EQUI_TEXTS.
*---------------------------------------------------------------------*
* END-OF-SELECTION *
*---------------------------------------------------------------------*
END-OF-SELECTION.
IF F_STOP = SPACE.
*--- Perform display the permits report
PERFORM DISPLAY_PERMITS.
ENDIF.
*---------------------------------------------------------------------*
* AT LINE-SELECTION
*---------------------------------------------------------------------*
AT LINE-SELECTION.
GET CURSOR FIELD V_FIELD VALUE V_AUFNR.
*--- Restricting the generation of Secondary list to dbl click on AUFNR
IF V_FIELD = 'IT_PERMITS-AUFNR' OR V_FIELD = 'IT_PERMITS-PMSOG'.
V_PMSOG = IT_PERMITS-PMSOG.
*--- Perform to build the Header for the Report
PERFORM BUILD_HEADER.
*--- Set the PF-STATUS for creating a push button on app tool bar.
SET PF-STATUS 'ZGUIREPORT'.
*--- Perform to display the Report Output
PERFORM DISPLAY_REPORT.
*--- Perform to build the Footer for the Report
PERFORM BUILD_FOOTER.
ENDIF.
*---- At user command
AT USER-COMMAND.
CASE SY-UCOMM.
WHEN 'DOWNLOAD'.
*--- Perform to choose destination for downloading report to Excel
PERFORM CHOOSE_FILE CHANGING V_DESTINATION_FILE.
IF SY-SUBRC = 0 .
*--- Perform to call EXCEL download function
PERFORM CALL_EXCEL_DOWNLOAD.
*--- Success Message after Excel file download
V_MESG = 'File downloaded to'(001).
V_TITLE = 'File Path'(002).
CALL FUNCTION 'JVA_POPUP_TO_DISPLAY_TEXT'
EXPORTING
TITEL = V_TITLE
TEXTLINE1 = V_MESG
TEXTLINE2 = V_DESTINATION_FILE
START_COLUMN = 10
START_ROW = 20.
*--- Success Message on a popup after Excel file download
V_MESG = 'Successfully Downloaded Data'(003).
MESSAGE S002(ZLKPL_MSGCLASS) WITH V_MESG.
ENDIF.
*--- Navigation - to go back to Selection Screen
WHEN 'BACK' OR '%EX' OR 'RW'.
LEAVE PROGRAM.
ENDCASE.
*---------------------------------------------------------------------*
* END-OF-PAGE *
*---------------------------------------------------------------------*
END-OF-PAGE.
*---- Include for OLE controls
INCLUDE ZINCLUDE_OLE_EXCEL.
*&---------------------------------------------------------------------*
*& Form GET_PERMIT_LOG_DETAILS
*&---------------------------------------------------------------------*
*--- To get the Permit log details from the table 'ZPMPERMITS' based
* on the selection criteria.
*----------------------------------------------------------------------*
FORM GET_PERMIT_LOG_DETAILS.
*--- Select Construct to get the Permit log details
SELECT * FROM ZPMPERMITS
INTO TABLE IT_PERMITS
WHERE AUFNR IN S_AUFNR
AND IWERK = P_IWERK
AND PMSOG = C_ELEC
AND REQDT IN S_REQDT.
*--- Sorting by Order No
IF SY-SUBRC = 0.
SORT IT_PERMITS BY AUFNR.
ELSE.
MESSAGE S002(ZLKPL_MSGCLASS) WITH 'No Data Exists For The Selection Criteria'(072).
F_STOP = 'X'.
STOP.
ENDIF.
ENDFORM. " GET_PERMIT_LOG_DETAILS
*&---------------------------------------------------------------------*
*& Form GET_PERMIT_CONDITIONS
*&---------------------------------------------------------------------*
* To get the Permit conditions from the table ZMNTTEXT
*----------------------------------------------------------------------*
FORM GET_PERMIT_CONDITIONS.
IF NOT IT_PERMITS[] IS INITIAL.
*--- Select construct to get the permit conditions
SELECT * FROM ZMNTTEXT
INTO TABLE IT_MNTTEXT
FOR ALL ENTRIES IN IT_PERMITS
WHERE AUFNR = IT_PERMITS-AUFNR
AND COUNTER = IT_PERMITS-COUNTER.
IF SY-SUBRC = 0.
*--- Do nothing
ENDIF.
ENDIF.
ENDFORM. " GET_PERMIT_CONDITIONS
*&---------------------------------------------------------------------
*& Form GET_AFIH_DATA
*&---------------------------------------------------------------------
* To get the Maintenance Order Header Data
*----------------------------------------------------------------------
FORM GET_AFIH_DATA.
IF NOT IT_PERMITS[] IS INITIAL.
*--- Select construct to get the Maintenance Order Header Data
SELECT AUFNR EQUNR ILOAN QMNUM
FROM AFIH
INTO TABLE IT_AFIH
FOR ALL ENTRIES IN IT_PERMITS
WHERE AUFNR = IT_PERMITS-AUFNR.
IF SY-SUBRC = 0.
*--- Do Nothing
ENDIF.
ENDIF.
ENDFORM. " GET_AFIH_DATA
*&---------------------------------------------------------------------*
*& Form GET_T357G_T_DATA
*&---------------------------------------------------------------------*
* To get the Text for Table 357GT
*----------------------------------------------------------------------*
FORM GET_T357G_T_DATA.
*--- Internal table to hold Duplicate Permits
DATA: BEGIN OF LT_PERMIT OCCURS 0,
PMSOG LIKE T357G_T-PMSOG,
END OF LT_PERMIT.
IF NOT IT_PERMITS[] IS INITIAL.
*--- Looping at IT_PERMITS to get Text
LOOP AT IT_PERMITS.
LT_PERMIT-PMSOG = IT_PERMITS-PMSOG.
APPEND LT_PERMIT.
CLEAR LT_PERMIT.
ENDLOOP.
*--- Sorting
SORT LT_PERMIT.
DELETE ADJACENT DUPLICATES FROM LT_PERMIT COMPARING PMSOG.
*-- Select construct to get the Text for Table T357G
SELECT PMSOG GNTXT
FROM T357G_T
INTO TABLE IT_T357G_T
FOR ALL ENTRIES IN LT_PERMIT
WHERE PMSOG = LT_PERMIT-PMSOG
AND SPRAS = SY-LANGU.
IF SY-SUBRC <> 0.
*--- Do Nothing
ENDIF.
ENDIF.
ENDFORM. " GET_T357G_T_DATA
*&---------------------------------------------------------------------*
*& Form GET_EQUI_TEXTS
*&---------------------------------------------------------------------*
* To get the Equipment Texts
*----------------------------------------------------------------------*
FORM GET_EQUI_TEXTS .
IF NOT IT_AFIH[] IS INITIAL.
*--- Select construct to get the Equipment Details
SELECT EQUNR EQKTX
FROM EQKT
INTO TABLE IT_EQKT
FOR ALL ENTRIES IN IT_AFIH
WHERE EQUNR = IT_AFIH-EQUNR
AND SPRAS = SY-LANGU.
IF SY-SUBRC = 0.
*--- Do Nothing
ENDIF.
ENDIF.
ENDFORM. " GET_EQUI_TEXTS
*&---------------------------------------------------------------------*
*& Form GET_FUNC_LOC_DATA
*&---------------------------------------------------------------------*
* To get the Functional Location
*----------------------------------------------------------------------*
FORM GET_FUNC_LOC_DATA.
IF NOT IT_AFIH[] IS INITIAL.
*--- Select construct to get the Functional Location
SELECT ILOAN TPLNR
FROM ILOA
INTO TABLE IT_ILOA
FOR ALL ENTRIES IN IT_AFIH
WHERE ILOAN = IT_AFIH-ILOAN.
IF SY-SUBRC = 0.
*---Do Nothing
ENDIF.
ENDIF.
ENDFORM. " GET_FUNC_LOC_DATA
*&---------------------------------------------------------------------*
*& Form GET_FUNC_LOC_TEXT_DATA.
*&---------------------------------------------------------------------*
* To get Functional Location: Short Texts
*----------------------------------------------------------------------*
FORM GET_FUNC_LOC_TEXT_DATA..
IF NOT IT_ILOA[] IS INITIAL.
*-- Select construct Functional Location: Short Texts
SELECT TPLNR PLTXT
FROM IFLOTX
INTO TABLE IT_IFLOTX
FOR ALL ENTRIES IN IT_ILOA
WHERE TPLNR = IT_ILOA-TPLNR
AND SPRAS = SY-LANGU.
IF SY-SUBRC = 0.
*---Do nothing
ENDIF.
ENDIF.
ENDFORM. " GET_FUNC_LOC_TEXT_DATA.
*&---------------------------------------------------------------------*
*& Form DISPLAY_PERMITS
*&---------------------------------------------------------------------*
*--- To display the Permits report
*----------------------------------------------------------------------*
FORM DISPLAY_PERMITS.
DATA: LV_COLR_FLG.
WRITE: /05(127) SY-ULINE,
/05(01) SY-VLINE.
FORMAT COLOR 1 INTENSIFIED ON.
*--- Column Headings
WRITE: 06(12) 'Order'(006),
18(01) SY-VLINE,
19(30) 'Permit Description'(067),
49(01) SY-VLINE,
50(12) 'Requested on'(009),
62(01) SY-VLINE,
63(13) 'Required from'(010),
76(01) SY-VLINE,
77(11) 'Required to'(011),
88(01) SY-VLINE,
89(10) 'Valid from'(012),
99(01) SY-VLINE,
100(10) 'Valid to'(013),
110(01) SY-VLINE,
111(20) 'Requested By'(068),
131(01) SY-VLINE.
FORMAT RESET.
WRITE: /05(127) SY-ULINE.
*--- Looping at IT_PERMITS for data
LOOP AT IT_PERMITS.
WRITE: /05(01) SY-VLINE.
IF LV_COLR_FLG = SPACE.
FORMAT COLOR 2 INTENSIFIED OFF.
LV_COLR_FLG = 'X'.
ELSE.
FORMAT COLOR 4 INTENSIFIED OFF.
CLEAR LV_COLR_FLG.
ENDIF.
*--- Report Contents
*--- Checking if no data exists & displaying message
IF IT_PERMITS[] IS INITIAL.
WRITE: 06(120) 'No Data Exists For The Given Selection Criterion'(014),
131(01) SY-VLINE.
ELSE.
*--- If data exists, display report
WRITE: 06(12) IT_PERMITS-AUFNR HOTSPOT ON,
18(01) SY-VLINE.
READ TABLE IT_T357G_T WITH KEY PMSOG = IT_PERMITS-PMSOG.
IF SY-SUBRC = 0.
WRITE: 19(30) IT_T357G_T-GNTXT,
49(01) SY-VLINE.
ENDIF.
WRITE: 50(12) IT_PERMITS-REQDT,
62(01) SY-VLINE,
63(13) IT_PERMITS-FRDAT,
76(01) SY-VLINE,
77(11) IT_PERMITS-TODAT,
88(01) SY-VLINE,
89(10) IT_PERMITS-VALFROM,
99(01) SY-VLINE,
100(10) IT_PERMITS-VALTO,
110(01) SY-VLINE,
111(20) IT_PERMITS-NAME1,
131(01) SY-VLINE.
FORMAT RESET.
HIDE IT_PERMITS-AUFNR.
HIDE IT_PERMITS-PMSOG.
ENDIF.
ENDLOOP.
WRITE: /05(127) SY-ULINE.
ENDFORM. " DISPLAY_PERMITS
*&---------------------------------------------------------------------*
*& Form BUILD_HEADER
*&---------------------------------------------------------------------*
* To build the Header for the report
*----------------------------------------------------------------------*
FORM BUILD_HEADER.
*--- Displaying the Header Text
WRITE: /05(128) SY-ULINE.
WRITE: /05(01) SY-VLINE,
35(01) SY-VLINE,
05(01) SY-VLINE,
65(39) 'Genting Lanco Power (India) Private Ltd'(015) CENTERED,
132(01) SY-VLINE,
*--- Displaying the Header Text
/05(01) SY-VLINE,
35(01) SY-VLINE,
35(01) SY-VLINE,
132(01) SY-VLINE,
/05(01) SY-VLINE,
67(34) 'Lanco Kondapalli Power Plant'(016) CENTERED,
35(01) SY-VLINE,
132(01) SY-VLINE,
132(01) SY-VLINE,
/05(01) SY-VLINE,
35(97) SY-ULINE,
132(01) SY-VLINE.
*--- Displaying the Header Text
READ TABLE IT_PERMITS WITH KEY AUFNR = IT_PERMITS-AUFNR.
IF SY-SUBRC = 0.
*---- Read table IT_T357G_T
READ TABLE IT_T357G_T WITH KEY PMSOG = IT_PERMITS-PMSOG.
IF SY-SUBRC = 0.
WRITE: /05(01) SY-VLINE,
35(01) SY-VLINE,
70(30) IT_T357G_T-GNTXT CENTERED,
132(01) SY-VLINE,
35(01) SY-VLINE.
ENDIF.
ENDIF.
WRITE: 05(01) SY-VLINE,
35(01) SY-VLINE,
132(01) SY-VLINE,
/05(01) SY-VLINE,
35(01) SY-VLINE,
05(01) SY-VLINE,
132(01) SY-VLINE,
*--- To Display Notification No
/40(06) 'WR No:'(019).
*---- Read table IT_AFIH to get corresponding Notification No
READ TABLE IT_AFIH WITH KEY AUFNR = IT_PERMITS-AUFNR.
IF SY-SUBRC = 0.
WRITE: 48(18) IT_AFIH-QMNUM.
ENDIF.
*--- To Display Order No
WRITE: 112(06) 'WO No:'(020).
*---- Read table IT_PERMITS to get Order No
READ TABLE IT_PERMITS WITH KEY AUFNR = IT_PERMITS-AUFNR.
IF SY-SUBRC = 0.
WRITE: 120(10) IT_PERMITS-AUFNR.
ENDIF.
WRITE: 05(01) SY-VLINE,
35(01) SY-VLINE,
132(01) SY-VLINE.
WRITE: /05(128) SY-ULINE.
*--- Displaying the Header Text
WRITE: /05(01) SY-VLINE,
10(20) 'Responsible Person'(023),
37(01) SY-VLINE,
45(20) 'Revision No'(024),
65(01) SY-VLINE,
75(25) 'Revision Date'(025),
100(01) SY-VLINE,
113(05) 'Page'(027),
132(01) SY-VLINE,
/05(01) SY-VLINE,
37(01) SY-VLINE,
65(01) SY-VLINE,
100(01) SY-VLINE,
132(01) SY-VLINE.
*--- Displaying the Header Text
WRITE: /05(01) SY-VLINE,
10(20) 'Plant Shift Manager'(049),
37(01) SY-VLINE,
50(20) '0'(050),
65(01) SY-VLINE,
77(25) '14/10/00'(069),
100(01) SY-VLINE,
107(10) SY-PAGNO,
132(01) SY-VLINE.
WRITE : /05(128) SY-ULINE.
SKIP.
ENDFORM. " BUILD_HEADER
*&---------------------------------------------------------------------*
*& Form DISPLAY_REPORT
*&---------------------------------------------------------------------*
* To write the details report
*----------------------------------------------------------------------*
FORM DISPLAY_REPORT .
CLEAR: IT_TLINE,
IT_TLINE[].
DATA: LV_TEXT(132).
CLEAR IT_PERMITS.
*--- Conversion exit ALPHA, external->internal
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = V_AUFNR
IMPORTING
OUTPUT = V_AUFNR.
*---- Read to get the long text corresponding to the Order No
READ TABLE IT_PERMITS WITH KEY AUFNR = V_AUFNR
PMSOG = V_PMSOG.
IF SY-SUBRC = 0.
*--- Description Of Plant
CLEAR LV_TEXT.
LV_TEXT = 'Description Of Plant:'(028).
CONDENSE LV_TEXT.
*--- Displaying Description Of Plant
WRITE: /05(128) SY-ULINE.
WRITE: /05(01) SY-VLINE,
06(73) LV_TEXT,
132(01) SY-VLINE,
/5(01) SY-VLINE,
132(01) SY-VLINE.
CLEAR LV_TEXT.
*--- Read Table IT_AFIH to get Order No
READ TABLE IT_AFIH WITH KEY AUFNR = IT_PERMITS-AUFNR.
IF SY-SUBRC = 0.
*--- Read Table IT_ILOA to get Location and acc assignment for tec objfor Description Of Plant
READ TABLE IT_ILOA WITH KEY ILOAN = IT_AFIH-ILOAN.
IF SY-SUBRC = 0.
CLEAR V_DESC.
*--- Read Table IT_IFLOTX to get Functional Location for Description Of Plant
READ TABLE IT_IFLOTX WITH KEY TPLNR = IT_ILOA-TPLNR.
IF SY-SUBRC = 0.
*--- Read Table IT_EQKT to get
READ TABLE IT_EQKT WITH KEY EQUNR = IT_AFIH-EQUNR.
IF SY-SUBRC = 0.
CONCATENATE IT_IFLOTX-PLTXT ';' IT_EQKT-EQKTX INTO V_DESC separated by space.
ELSE.
V_DESC = IT_IFLOTX-PLTXT.
ENDIF.
ELSE .
V_DESC = IT_EQKT-EQKTX.
ENDIF.
ENDIF.
ENDIF.
WRITE: 06 V_DESC.
WRITE: 132 SY-VLINE,
/05 SY-VLINE,
132 SY-VLINE.
*--- Displaying Work to be Carried out
LV_TEXT = 'Work to be Carried out:'(029).
CONDENSE LV_TEXT.
WRITE: /05(01) SY-VLINE,
06(73) LV_TEXT,
132(01) SY-VLINE.
CLEAR LV_TEXT.
CLEAR V_ID.
V_NAME = IT_PERMITS-OBJNR.
V_NAME+22(10) = IT_PERMITS-COUNTER.
*--- Getting Long Text using Read_Text for Work to be carried out
V_ID = 'ZWCO'.
*--- Perform to get the longtext and split it
PERFORM SPLIT_TEXT.
*--- Looping at IT_TEXT to get for Work to be carried out
LOOP AT IT_TEXT.
WRITE: /05(01) SY-VLINE,
06(125) IT_TEXT-TEXT,
132(01) SY-VLINE.
ENDLOOP.
WRITE: /5(01) SY-VLINE,
132(01) SY-VLINE.
*--- Displaying Details Of Plant Isolation And Safety Precautions Taken
CLEAR LV_TEXT.
LV_TEXT = 'Details Of Plant Isolation And Safety Precautions Taken:'(030).
CONDENSE LV_TEXT.
WRITE: /06(73) LV_TEXT ,
05(01) SY-VLINE,
132(01) SY-VLINE.
CLEAR LV_TEXT.
*--- Getting Long Text using Read_Text for Details Of Plant Isolation And Safety Precautions Taken
CLEAR V_ID.
V_ID = 'ZDOI'.
*--- Perform to get the longtext and split it
PERFORM SPLIT_TEXT.
*--- Looping at IT_TEXT to get Details Of Plant Isolation And Safety Precautions Taken
LOOP AT IT_TEXT.
WRITE: /05(01) SY-VLINE,
06(125) IT_TEXT-TEXT,
132(01) SY-VLINE.
ENDLOOP.
WRITE: /5(01) SY-VLINE,
132(01) SY-VLINE.
*--- Displaying Safety and Fire Manager
CLEAR LV_TEXT.
LV_TEXT = 'Safety and Fire Manager:'(031).
CONDENSE LV_TEXT.
WRITE: /05(01) SY-VLINE,
06(30) LV_TEXT,
132(01) SY-VLINE.
CLEAR LV_TEXT.
*--- Getting Long Text using Read_Text for Safety and Fire Manager
V_ID = 'ZSFM'.
*--- Perform to get the longtext and split it
PERFORM SPLIT_TEXT.
*--- Looping at IT_TEXT to get Safety and Fire Manager
LOOP AT IT_TEXT.
WRITE: /05(01) SY-VLINE,
06(125) IT_TEXT-TEXT,
132(01) SY-VLINE.
ENDLOOP.
WRITE: /5(01) SY-VLINE,
132(01) SY-VLINE.
*--- Displaying General Manager
CLEAR LV_TEXT.
LV_TEXT = 'General Manager:'(032).
CONDENSE LV_TEXT.
WRITE: /05(01) SY-VLINE,
06(30) LV_TEXT,
132(01) SY-VLINE,
/05(01) SY-VLINE,
132(01) SY-VLINE,
/05(01) SY-VLINE,
132(01) SY-VLINE.
*--- Displaying Earths applied
CLEAR LV_TEXT.
LV_TEXT = 'Earths applied:'(033).
CONDENSE LV_TEXT.
WRITE: /05(01) SY-VLINE,
06(30) LV_TEXT,
132(01) SY-VLINE.
CLEAR LV_TEXT.
*--- Displaying Earths applied text
WRITE: /05(01) SY-VLINE,
06(10) ' '(034),
132(01) SY-VLINE,
/05(01) SY-VLINE,
132(01) SY-VLINE.
*--- Displaying Special Precautions to be taken
LV_TEXT = 'Special Precautions to be taken:'(035).
CONDENSE LV_TEXT.
WRITE: /05(01) SY-VLINE,
06(73) LV_TEXT,
132(01) SY-VLINE.
CLEAR LV_TEXT.
*--- Getting Long Text using Read_Text for Special Precautions to be taken
CLEAR V_ID.
V_ID = 'ZOPR'.
*--- Perform to get the longtext and split it
PERFORM SPLIT_TEXT.
*--- Looping at IT_TEXT to get Special Precautions to be taken
LOOP AT IT_TEXT.
WRITE: /05(01) SY-VLINE,
06(125) IT_TEXT-TEXT,
132(01) SY-VLINE.
ENDLOOP.
WRITE: /05(01) SY-VLINE,
132(01) SY-VLINE.
WRITE: /05(128) SY-ULINE.
*--- Displaying Authorization
LV_TEXT = 'AUTHORIZATION:'(036).
CONDENSE LV_TEXT.
WRITE: /05(01) SY-VLINE,
06(73) LV_TEXT,
132(01) SY-VLINE,
05(01) SY-VLINE,
40(20) 'Lock Out Bolt1 No:'(037),
62(15) IT_PERMITS-LOCKBN1,
85(21) 'Lock Out Key1 No:'(038),
106(15) IT_PERMITS-LOCKKN1,
132(01) SY-VLINE,
/05(01) SY-VLINE,
40(20) 'Lock Out Bolt2 No:'(070),
62(20) IT_PERMITS-LOCKBN2,
85(21) 'Lock Out Key2 No:'(071),
106(20) IT_PERMITS-LOCKKN2,
132(01) SY-VLINE,
/05(01) SY-VLINE,
132(01) SY-VLINE,
/05(01) SY-VLINE,
10(10) 'Signature:'(039),
21 SY-ULINE(17),
40(05) 'Name'(040),
46 SY-ULINE(20),
80(05) 'Time'(041),
87 SY-ULINE(15),
110(05) 'Date'(042),
116 SY-ULINE(15),
132(01) SY-VLINE,
132(01) SY-VLINE,
*--- Authorised Person
/05(01) SY-VLINE,
20(30) '(Authorised Person)'(043),
132(01) SY-VLINE,
/05(128) SY-ULINE.
*--- Displaying Receipt
CLEAR LV_TEXT.
LV_TEXT = 'RECEIPT:'(066).
CONDENSE LV_TEXT.
WRITE: /05(01) SY-VLINE,
06(73) LV_TEXT,
132(01) SY-VLINE.
WRITE: 15(106) 'I have read this form and understand the special precautions to be taken during the job execution'(062),
/05(01) SY-VLINE,
132(01) SY-VLINE,
/05(01) SY-VLINE,
132(01) SY-VLINE,
/05(01) SY-VLINE,
10(10) 'Signature:'(039),
21 SY-ULINE(17),
40(05) 'Name:'(040),
46 SY-ULINE(18),
65(08) 'Company:'(045),
74 SY-ULINE(20),
96(05) 'Time:'(041),
102 SY-ULINE(10),
114(05) 'Date:'(042),
121(10) SY-ULINE(10),
132(10) SY-VLINE,
*--- Competent Person in Charge of Work
/05(01) SY-VLINE,
20(80) '(Competent Person in Charge of Work)'(064),
132(01) SY-VLINE,
/05(128) SY-ULINE.
*--- Displaying Detail of Work Completed
CLEAR LV_TEXT.
LV_TEXT = 'Detail of Work Completed:'(047).
CONDENSE LV_TEXT.
WRITE: /05(01) SY-VLINE,
06(28) LV_TEXT,
132(01) SY-VLINE.
CLEAR LV_TEXT.
*--- Getting Long Text using Read_Text for Detail of Work Completed
CLEAR V_ID.
V_ID = 'ZMNT'.
*--- Perform to get the longtext and split it
PERFORM SPLIT_TEXT.
*--- Looping at IT_TEXT to get Detail of Work Completed
LOOP AT IT_TEXT.
WRITE: /05(01) SY-VLINE,
06(125) IT_TEXT-TEXT,
132(01) SY-VLINE.
ENDLOOP.
WRITE : 132(01) SY-VLINE,
/05(01) SY-VLINE,
132(01) SY-VLINE,
06 SY-ULINE(126).
*--- Displaying Clearance (Competent Person in Charge of Work)
WRITE: /05(01) SY-VLINE,
06(115) 'CLEARANCE: Work as above completed / stopped,all tools material removed, area cleaned and men in charge withdrawn'(048),
132(01) SY-VLINE,
/05(01) SY-VLINE,
132(01) SY-VLINE,
/05(01) SY-VLINE,
10(10) 'Signature:'(039),
21 SY-ULINE(17),
40(05) 'Name:'(040),
46 SY-ULINE(18),
65(08) 'Company:'(045),
74 SY-ULINE(20),
96(05) 'Time:'(041),
102 SY-ULINE(10),
114(05) 'Date:'(042),
121(10) SY-ULINE(10),
132(10) SY-VLINE,
/05(01) SY-VLINE,
20(80) '(Competent Person in Charge of Work)'(064),
132(01) SY-VLINE,
05(01) SY-VLINE,
/05(128) SY-ULINE(128),
132(01) SY-VLINE.
*--- Displaying CANCELLATION: All copies of this PERMIT TO WORK
*--- are hereby cancelled
LV_TEXT = 'CANCELLATION: All copies of this PERMIT TO WORK are hereby cancelled'(052).
CONDENSE LV_TEXT.
WRITE: /05(01) SY-VLINE,
06(73) LV_TEXT,
132(01) SY-VLINE,
/05(01) SY-VLINE,
132(01) SY-VLINE,
132(01) SY-VLINE,
/05(01) SY-VLINE,
132(01) SY-VLINE,
/05(01) SY-VLINE,
10(10) 'Signature:'(039),
21 SY-ULINE(17),
40(05) 'Name'(040),
46 SY-ULINE(20),
80(05) 'Time'(041),
87 SY-ULINE(15),
110(05) 'Date'(042),
116 SY-ULINE(15),
132(01) SY-VLINE,
/05 SY-VLINE,
20(100) '(Authorised Person)'(043),
132 SY-VLINE.
WRITE: /05(128) SY-ULINE.
CLEAR LV_TEXT.
CLEAR IT_PERMITS.
ENDIF.
ENDFORM. " DISPLAY_OUTPUT
*&---------------------------------------------------------------------
*
*& Form BUILD_FOOTER
*&---------------------------------------------------------------------
*
*--- Footer for the report
*----------------------------------------------------------------------
*
FORM BUILD_FOOTER.
*--- Assigining footer text to Variables
V_FOOT1 ='We reserve all rights of this document and the information therein. Reproduction, use or disclosure to third parties'(053).
V_FOOT2 ='without authority is strictly forbidden.Genting Lanco Power(India)Private Limited 1999'(054).
WRITE : /05(128) SY-ULINE.
WRITE: /05(01) SY-VLINE,
06(125) V_FOOT1 ,
132(01) SY-VLINE,
/05(01) SY-VLINE,
06(125) V_FOOT2 ,
132(01) SY-VLINE,
/05(01) SY-VLINE,
132(01) SY-VLINE.
WRITE : /05(128) SY-ULINE.
ENDFORM. " BUILD_FOOTER
*&---------------------------------------------------------------------*
*& Form GET_LONGTEXT
*&---------------------------------------------------------------------*
* To get the Long Text for the Permits
*----------------------------------------------------------------------*
FORM GET_LONGTEXT.
*---- Refreshing the Header and Contents of the table ITAB
CLEAR: IT_TLINE,
IT_TLINE[].
CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
ID = V_ID
LANGUAGE = SY-LANGU
NAME = V_NAME
OBJECT = C_OBJECT
* ARCHIVE_HANDLE = 0
* LOCAL_CAT = ' '
* IMPORTING
* HEADER =
TABLES
LINES = IT_TLINE
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8 .
ENDFORM. " GET_LONGTEXT
*&---------------------------------------------------------------------*
*& Form CALL_EXCEL_DOWNLOAD
*&---------------------------------------------------------------------*
* To Call EXCEL download function
*----------------------------------------------------------------------*
FORM CALL_EXCEL_DOWNLOAD.
DATA: LV_LINES TYPE I, "Number of lines
LV_MESG(50) TYPE C, "Message
LV_ROW TYPE I, "Current Row
LV_LINE1 TYPE I.
*------ Show progress of the download operation
LV_MESG = ' Initialising Excel...'(055).
PERFORM SHOW_PROGRESS USING LV_MESG.
*----- Perform to create an OLE Excel Object
PERFORM CREATE_OLE_OBJECTS.
*----- Perform to Open an Existing OLE Excel Template
PERFORM OPEN_OLE_TEMPLATE USING V_SOURCE_FILE.
*----- Perform to draw a border for the Header Data of Report
PERFORM BUILD_BORDER USING 5 2 12 1.
PERFORM BUILD_BORDER USING 1 2 12 2.
*------ Show progress of the download operation
LV_MESG = ' Downloading Data to Excel...'(056).
PERFORM SHOW_PROGRESS USING LV_MESG.
*----- Fill Header Information to active Excel sheet
PERFORM FILL_CELL USING 1 5 1 'Genting Lanco Power (India) Private Ltd'(015).
PERFORM FILL_CELL USING 2 5 1 ' Lanco Kondapalli Power Plant'(016).
PERFORM FILL_CELL USING 4 6 1 IT_T357G_T-GNTXT.
*--- Reading table IT_AFIH for WO No
READ TABLE IT_AFIH WITH KEY AUFNR = IT_PERMITS-AUFNR.
*----- To Display Notification Number
PERFORM FILL_CELL USING 5 3 1 'WR No'(019).
PERFORM FILL_CELL USING 5 4 1 IT_AFIH-QMNUM.
*----- To Display Order Number
PERFORM FILL_CELL USING 5 10 1 'WO No'(020).
PERFORM FILL_CELL USING 5 11 1 IT_AFIH-AUFNR.
*---To Display Additional Header Information on Excel sheet
PERFORM FILL_CELL USING 7 1 1 'Responsible Person'(023).
PERFORM FILL_CELL USING 9 1 0 'Plant Shift Manager'(049).
*----- Border for Responsible Person
PERFORM BUILD_BORDER USING 6 3 1 10.
*--- To Display Revision No
PERFORM FILL_CELL USING 7 5 1 'Revision No'(024).
PERFORM FILL_CELL USING 9 5 0 '0'(050) .
*----- Border for Revision No
PERFORM BUILD_BORDER USING 6 6 1 10.
*--- To Display Revision Date
PERFORM FILL_CELL USING 7 8 1 'Revision Date'(025).
PERFORM FILL_CELL USING 9 8 0 '14/10/00'(069).
*--- Border for Revision Date
PERFORM BUILD_BORDER USING 6 9 1 10.
*--- To Display Page no.
PERFORM FILL_CELL USING 7 11 1 'Page'(027).
PERFORM FILL_CELL USING 9 11 0 '1'(057).
*----- Border for Page
PERFORM BUILD_BORDER USING 6 12 1 10.
*---
LV_LINES = 12.
*------- Fill Columns & headings to active Excel sheet
*----- For Full content border
LV_LINE1 = LV_LINES.
*--- Incrementing Line count
LV_LINES = LV_LINES + 1.
*----- To Display Description Of Plant
PERFORM FILL_CELL USING LV_LINES 1 4 'Description Of Plant'(028).
*--- Incrementing Line count
LV_LINES = LV_LINES + 2.
PERFORM FILL_CELL USING LV_LINES 1 0 V_DESC.
*--- Incrementing Line count
LV_LINES = LV_LINES + 2.
*--- Getting Long Text using Read_Text for Work to be carried out
PERFORM FILL_CELL USING LV_LINES 1 4 'Work to be carried out:'(029).
*--- Incrementing Line count
LV_LINES = LV_LINES + 1.
*---- Read to get the long text corresponding to the Order No
READ TABLE IT_PERMITS WITH KEY AUFNR = V_AUFNR
PMSOG = V_PMSOG.
CLEAR V_ID.
V_ID = 'ZWCO'.
V_NAME = IT_PERMITS-OBJNR.
V_NAME+22(10) = IT_PERMITS-COUNTER.
*--- Perform to get the longtext and split it
PERFORM SPLIT_TEXT.
*--- Looping at IT_TEXT to get Work to be carried out
LOOP AT IT_TEXT.
LV_LINES = LV_LINES + 1.
PERFORM FILL_CELL USING LV_LINES 1 0 IT_TEXT-TEXT.
ENDLOOP.
*--- Incrementing Line count
LV_LINES = LV_LINES + 2.
*--- Getting Long Text using Read_Text for Details Of Plant Isolation
*--- And Safety Precautions Taken
PERFORM FILL_CELL USING LV_LINES 1 4 'Details Of Plant Isolation And Safety Precautions Taken'(030).
*--- Incrementing Line count
LV_LINES = LV_LINES + 1.
CLEAR V_ID.
V_ID = 'ZDOI'.
V_NAME = IT_PERMITS-OBJNR.
V_NAME+22(10) = IT_PERMITS-COUNTER.
*--- Perform to get the longtext and split it
PERFORM SPLIT_TEXT.
*--- Looping at IT_TEXT to get Details Of Plant Isolation And Safety Precautions Taken
LOOP AT IT_TEXT.
LV_LINES = LV_LINES + 1.
PERFORM FILL_CELL USING LV_LINES 1 0 IT_TEXT-TEXT.
ENDLOOP.
*--- Incrementing Line count
LV_LINES = LV_LINES + 2.
*--- Getting Long Text using Read_Text for Safety and Fire Manager:
PERFORM FILL_CELL USING LV_LINES 1 4 'Safety and Fire Manager:'(031).
*--- Incrementing Line count
LV_LINES = LV_LINES + 1.
CLEAR V_ID.
V_ID = 'ZSFM'.
V_NAME = IT_PERMITS-OBJNR.
V_NAME+22(10) = IT_PERMITS-COUNTER.
*--- Perform to get the longtext and split it
PERFORM SPLIT_TEXT.
*--- Looping at IT_TEXT to get Safety and Fire Manager
LOOP AT IT_TEXT.
LV_LINES = LV_LINES + 1.
PERFORM FILL_CELL USING LV_LINES 1 0 IT_TEXT-TEXT.
ENDLOOP.
*--- Incrementing Line count
LV_LINES = LV_LINES + 2.
*--- To Display General Manager
PERFORM FILL_CELL USING LV_LINES 1 4 'General Manager:'(032).
*--- Incrementing Line count
LV_LINES = LV_LINES + 2.
*--- To Display Earths applied
PERFORM FILL_CELL USING LV_LINES 1 4 'Earths applied:'(033).
*--- Incrementing Line count
LV_LINES = LV_LINES + 1.
PERFORM FILL_CELL USING LV_LINES 1 0 ' '(034).
*--- Incrementing Line count
LV_LINES = LV_LINES + 3.
*--- Getting Long Text using Read_Text for Special Precautions to be taken
PERFORM FILL_CELL USING LV_LINES 1 4 'Special Precautions to be taken:'(035).
*--- Incrementing Line count
LV_LINES = LV_LINES + 1.
CLEAR V_ID.
V_ID = 'ZOPR'.
V_NAME = IT_PERMITS-OBJNR.
V_NAME+22(10) = IT_PERMITS-COUNTER.
*--- Perform to get the longtext and split it
PERFORM SPLIT_TEXT.
*--- Looping at IT_TEXT to get Special Precautions to be taken
LOOP AT IT_TEXT.
LV_LINES = LV_LINES + 1.
PERFORM FILL_CELL USING LV_LINES 1 0 IT_TEXT-TEXT.
ENDLOOP.
*--- Incrementing Line count
LV_LINES = LV_LINES + 1.
*----- Border for the details box
PERFORM BUILD_BORDER USING LV_LINE1 1 12 LV_LINES.
LV_LINE1 = LV_LINES + 1.
*--- Incrementing Line count
LV_LINES = LV_LINES + 2.
*--- To Display Authorization box
PERFORM FILL_CELL USING LV_LINES 1 4 'AUTHORIZATION:'(036).
PERFORM FILL_CELL USING LV_LINES 5 4 'Lock Out Bolt1 No:'(037).
PERFORM FILL_CELL USING LV_LINES 7 4 IT_PERMITS-LOCKBN1.
PERFORM FILL_CELL USING LV_LINES 9 4 'Lock Out Key1 No:'(038).
PERFORM FILL_CELL USING LV_LINES 11 4 IT_PERMITS-LOCKKN1.
*--- Incrementing Line count
LV_LINES = LV_LINES + 1.
PERFORM FILL_CELL USING LV_LINES 5 4 'Lock Out Bolt2 No:'(070).
PERFORM FILL_CELL USING LV_LINES 7 4 IT_PERMITS-LOCKBN2.
PERFORM FILL_CELL USING LV_LINES 9 4 'Lock Out Key2 No:'(071).
PERFORM FILL_CELL USING LV_LINES 11 4 IT_PERMITS-LOCKKN2.
*--- Incrementing Line count
LV_LINES = LV_LINES + 3.
PERFORM FILL_CELL USING LV_LINES 1 4 'Signature: _________________ Name: ______________________'(058).
PERFORM FILL_CELL USING LV_LINES 9 4 'Time: __________ Date: _________'(059).
*--- Incrementing Line count
LV_LINES = LV_LINES + 1.
PERFORM FILL_CELL USING LV_LINES 2 4 '(Authorised Person)'(043).
LV_LINES = LV_LINES + 1.
*----- Border for the Authorisations box
PERFORM BUILD_BORDER USING LV_LINE1 1 12 LV_LINES.
*----- For Full content border
LV_LINE1 = LV_LINES + 1.
*--- Incrementing Line count
LV_LINES = LV_LINES + 2.
*--- To Display Receipt box
PERFORM FILL_CELL USING LV_LINES 1 4 'RECEIPT:'(066).
PERFORM FILL_CELL USING LV_LINES 2 4 'I have read this form and understand the special precautions to be taken during the job execution'(062).
*--- Incrementing Line count
LV_LINES = LV_LINES + 2.
PERFORM FILL_CELL USING LV_LINES 1 4 'Signature: _________________ Name: ______________________'(058).
PERFORM FILL_CELL USING LV_LINES 6 4 'Company: _________________ Time: __________ Date: _________'(060).
*--- Incrementing Line count
LV_LINES = LV_LINES + 1.
PERFORM FILL_CELL USING LV_LINES 2 4 '(Competent Person in Charge of Work)'(064).
*--- Incrementing Line count
LV_LINES = LV_LINES + 1.
*----- Border for the RECEIPT box
PERFORM BUILD_BORDER USING LV_LINE1 1 12 LV_LINES.
*----- For Full content border
LV_LINE1 = LV_LINES + 1.
*--- Incrementing Line count
LV_LINES = LV_LINES + 2.
*--- To Display Detail of Work Completed box
PERFORM FILL_CELL USING LV_LINES 1 4 'Detail of Work Completed:'(047).
*--- Incrementing Line count
LV_LINES = LV_LINES + 1.
CLEAR V_ID.
V_ID = 'ZMNT'.
V_NAME = IT_PERMITS-OBJNR.
V_NAME+22(10) = IT_PERMITS-COUNTER.
*--- Perform to get the longtext and split it
PERFORM SPLIT_TEXT.
*--- Looping at IT_TEXT to get Detail of Work Completed
LOOP AT IT_TEXT.
LV_LINES = LV_LINES + 1.
PERFORM FILL_CELL USING LV_LINES 1 0 IT_TEXT-TEXT.
ENDLOOP.
*--- Incrementing Line count
LV_LINES = LV_LINES + 1.
*----- Border for the Detail of work completed
PERFORM BUILD_BORDER USING LV_LINE1 1 12 LV_LINES.
*----- For Full content border
LV_LINE1 = LV_LINES + 1.
*--- Incrementing Line count
LV_LINES = LV_LINES + 2.
*--- To Display Clearance box
PERFORM FILL_CELL USING LV_LINES 1 4 'CLEARANCE: Work as above completed / stopped,all tools material removed, area cleaned and men in charge withdrawn'(048).
*--- Incrementing Line count
LV_LINES = LV_LINES + 3.
PERFORM FILL_CELL USING LV_LINES 1 4 'Signature: _________________ Name: ______________________'(058).
PERFORM FILL_CELL USING LV_LINES 6 4 'Company: ________________ Time: __________ Date: _________'(060).
*--- Incrementing Line count
LV_LINES = LV_LINES + 1.
*--- To Display Competent Person in Charge of Work
PERFORM FILL_CELL USING LV_LINES 2 4 '(Competent Person in Charge of Work)'(064).
*--- Incrementing Line count
LV_LINES = LV_LINES + 1.
*----- Border for the Detail of Clearance
PERFORM BUILD_BORDER USING LV_LINE1 1 12 LV_LINES.
*--- Incrementing Line count
LV_LINES = LV_LINES + 2.
*--- To Display Cancellation box
PERFORM FILL_CELL USING LV_LINES 1 4 'CANCELLATION: All copies of this PERMIT TO WORK are hereby cancelled'(052).
*--- Incrementing Line count
LV_LINES = LV_LINES + 3.
PERFORM FILL_CELL USING LV_LINES 1 4 'Signature: _________________ Name: ______________________'(058).
PERFORM FILL_CELL USING LV_LINES 9 4 'Time: __________ Date: _________'(059).
*--- Incrementing Line count
LV_LINES = LV_LINES + 1.
PERFORM FILL_CELL USING LV_LINES 2 6 '(Authorised Person)'(043).
*--- Incrementing Line count
LV_LINES = LV_LINES + 1.
*----- Border for the Detail of Cancellation
PERFORM BUILD_BORDER USING LV_LINE1 1 12 LV_LINES.
*--- Incrementing Line count
LV_LINES = LV_LINES + 2.
*----- For Full content border
LV_LINE1 = LV_LINES + 1.
*------ Fill the Footer Data into the Active Excel Object
LV_ROW = LV_LINES + 2.
*--- Filling the footer texts
V_FOOT1 = 'We reserve all rights of this document and the information therein. Reproduction, use or disclosure to third parties'(053).
V_FOOT2 = 'without authority is strictly forbidden.Genting Lanco Power(India)Private Limited 1999'(054).
*--- Incrementing Line count
LV_LINES = LV_LINES + 1.
*--- Row Incremanting
LV_ROW = LV_LINES + 2.
*----- Border for the Detail of Disclaimer
PERFORM BUILD_BORDER USING LV_LINES 12 1 LV_ROW.
PERFORM FILL_CELL USING LV_LINES 1 1 V_FOOT1.
*--- Incrementing Line count
LV_LINES = LV_LINES + 1.
PERFORM FILL_CELL USING LV_LINES 1 1 V_FOOT2.
*------ Show progress of the download operation
LV_MESG = 'Saving Excel File...'(061).
PERFORM SHOW_PROGRESS USING LV_MESG.
*----- Perform to Save the OLE Object to a destination File
PERFORM SAVE_OLE_OBJECT USING V_DESTINATION_FILE.
*----- Perform to free all the OLE Objects
PERFORM FREE_OLE_OBJECTS.
ENDFORM. " CALL_EXCEL_DOWNLOAD
*&---------------------------------------------------------------------*
*& Form CHOOSE_FILE *
*&---------------------------------------------------------------------*
* form to choose destination for downloading report to Excel *
*----------------------------------------------------------------------*
FORM CHOOSE_FILE CHANGING F_FILE TYPE RLGRAP-FILENAME.
DATA: IFILE TYPE FILETABLE.
DATA: XFILE LIKE LINE OF IFILE.
DATA: RC TYPE I.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
EXPORTING
* WINDOW_TITLE =
DEFAULT_EXTENSION = 'XLS'
DEFAULT_FILENAME = 'Electrical_Permit_To_Work'
FILE_FILTER = '*.XLS'
* WITH_ENCODING =
INITIAL_DIRECTORY = 'C:\'
* MULTISELECTION =
CHANGING
FILE_TABLE = IFILE
RC = RC
* USER_ACTION =
* FILE_ENCODING =
* exceptions
* file_open_dialog_failed = 1
* cntl_error = 2
* error_no_gui = 3
* not_supported_by_gui = 4
* others = 5
.
READ TABLE IFILE INTO XFILE INDEX 1.
IF SY-SUBRC = 0 .
F_FILE = XFILE-FILENAME.
ENDIF.
ENDFORM. " CHOOSE_FILE
*&---------------------------------------------------------------------*
*& Form SHOW_PROGRESS
*&---------------------------------------------------------------------*
* Indicate the progress of download process
*----------------------------------------------------------------------*
FORM SHOW_PROGRESS USING P_TEXT . "LV_COUNT.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
* PERCENTAGE = LV_COUNT
TEXT = P_TEXT
EXCEPTIONS
OTHERS = 1.
ENDFORM. " SHOW_PROGRESS
*&---------------------------------------------------------------------*
*& Form SPLIT_TEXT
*&---------------------------------------------------------------------*
* To Split Long text into lines
*----------------------------------------------------------------------*
FORM SPLIT_TEXT .
DATA: LV_TEXT(350),
LV_STRLEN TYPE I,
LV_TXT(255),
LV_RTEXT(350),
LV_LEN TYPE I,
LV_FLAG.
V_NAME = IT_PERMITS-OBJNR.
V_NAME+22(10) = IT_PERMITS-COUNTER.
CLEAR: IT_TLINE, IT_TLINE[], IT_TEXT, IT_TEXT[], IT_RTEXT, IT_RTEXT[].
*--- Perform to get Long Text
PERFORM GET_LONGTEXT." USING V_ID.
LV_LEN = 125.
LOOP AT IT_TLINE.
IF lv_flag = space.
LV_TEXT = IT_TLINE-TDLINE.
lv_flag = 'X'.
CONTINUE.
ENDIF.
LV_TXT = IT_TLINE-TDLINE.
*---To calculate string length
LV_STRLEN = STRLEN( LV_TEXT ).
IF IT_TLINE-TDFORMAT = SPACE.
*--- to concatenate lv_text with LV_TXT
CONCATENATE LV_TEXT LV_TXT INTO LV_TEXT SEPARATED BY SPACE.
LV_STRLEN = STRLEN( LV_TEXT ).
ELSEIF LV_TEXT IS NOT INITIAL AND LV_STRLEN < 125.
IT_TEXT-TEXT = LV_TEXT.
APPEND IT_TEXT.
CLEAR: IT_TEXT , LV_TEXT.
LV_STRLEN = 0.
LV_TEXT = LV_TXT.
CONTINUE.
ENDIF.
* ---Check whether the length is greater than the length of a single line
IF LV_STRLEN > 125 .
DO.
LV_LEN = LV_LEN - 1.
IF LV_TEXT+LV_LEN(1) = SPACE.
LV_LEN = LV_LEN + 1.
LV_STRLEN = LV_STRLEN - LV_LEN.
LV_RTEXT = LV_TEXT+LV_LEN(LV_STRLEN) .
IT_TEXT-TEXT = LV_TEXT+0(LV_LEN).
APPEND IT_TEXT.
CLEAR: IT_TEXT, LV_TEXT.
EXIT.
ENDIF.
ENDDO.
*----to calculate the string length
LV_STRLEN = STRLEN( LV_RTEXT ).
WHILE LV_STRLEN > 125.
IT_TEXT-TEXT = LV_RTEXT+0(125).
APPEND IT_TEXT.
CLEAR: IT_TEXT , LV_TEXT.
LV_STRLEN = LV_STRLEN - 125.
LV_RTEXT = LV_RTEXT+125(LV_STRLEN).
LV_STRLEN = STRLEN( LV_RTEXT ).
ENDWHILE.
LV_TEXT = LV_RTEXT.
ELSEIF IT_TLINE-TDFORMAT NE SPACE..
IT_TEXT-TEXT = LV_TEXT.
APPEND IT_TEXT.
CLEAR: IT_TEXT , LV_TEXT.
LV_TEXT = LV_TXT.
ENDIF.
*--- to initialise LV_LEN to 125
LV_LEN = 125.
ENDLOOP.
IT_TEXT-TEXT = LV_TEXT.
APPEND IT_TEXT.
CLEAR: IT_TEXT , LV_TEXT.
ENDFORM. " SPLIT_TEXT
No comments:
Post a Comment