Posted: Sun Feb 24, 2008 12:17 pm Post subject: Create Budgeted Income Statement reports
Author: Tjosvold
Code:
REPORT zfglr027.
* Program Title: zfglr027 - Create Budgeted Income Statement reports
* Description: Create Budgeted Income Statement reports as files by
* receiver(cost center manager).
*
* This program runs a report painter program and captures the output
* into an internal table. This internal table is used to capture all
* report detail for specified receivers into separate files on UNIX
* that are then FTPed to the Web server. Each receiver is sent an email
* to notify them that their file has been created.
*
* This is the high-level logic of the program.
* START-OF-ELECTION.
* PERFORM 0000_INITIALIZE_E_REPORT_TABLS.
* PERFORM 0500_PRINT_REPORT_HEADING.
* PERFORM 1000_RUN_REPORT_PAINTER.
* PERFORM 3000_CREATE_RECEIVER_FILES.
* PERFORM 9000_CLOSING_ROUTINE.
* END-OF-SELECTION.
*
* >>>>>>>> s e l e c t i o n s c r e e n o p t i o n s <<<<<<<
* P_PRTR printer
* P_PGM report painter program
* P_VAR report painter variant
* P_JOBNAM job name
* P_LINE1 Report Line 1 char 1-12 of each check page of
* Report painter program output
* P_PGMGRP ZEREPORT table records used in this program
* P_OUTPUT UNIX output file path
* P_FILE UNIX/Web filename
* P_FPATH1 Web file path
* P_FEXT Web file extension
* P_FPRT size of printing font
* P_BPRT bold printing font
* P_FVEW size of viewing font
* P_BVEW bold viewing font
* P_WAIT seconds to wait in loop when checking if painter
* program finished
* P_SERVR Web server name
* P_USER user name for Web server
* P_PSW password for Web server
*
*----------------------------------------------------------------------*
* *
*>>>>>>>>> T A B L E S <<<<<<<
TABLES: tsp01, " Spool Requests
tbtcp, " Background Job Step Overview
tbtcjob, " Structure for Passing Job Header Data (BI-API)
zereport, "Receivers and keys used in electronic report distrb
zemail. "Netware user name and email address
*>>>>>>>>> I N C L U D E S <<<<<<<
* Includes
INCLUDE zzisubrs. "SLG001
*>>>>>>>>> S E L E C T I O N S C R E E N O P T I O N S <<<<<<<
*
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETER: p_prtr(4) DEFAULT 'L9B' OBLIGATORY.
PARAMETER: p_pgm LIKE sy-repid OBLIGATORY
DEFAULT 'GP3F3L852RG4OCU1CEMSW4DHDNN200'.
PARAMETER: p_var LIKE rsvar-variantt DEFAULT 'CORP' OBLIGATORY.
PARAMETER: p_jobnam LIKE tbtcjob-jobname DEFAULT 'Budgeted_I_Stmnt'
OBLIGATORY.
SELECTION-SCREEN BEGIN OF BLOCK b1b WITH FRAME TITLE text-006.
PARAMETER: p_line1(12) DEFAULT 'Cost Center ' LOWER CASE OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1b.
SELECTION-SCREEN END OF BLOCK b1.
*start BCT007
*>> Used to select which records from ZEREPORT are used
SELECTION-SCREEN BEGIN OF BLOCK b1a WITH FRAME TITLE text-008.
PARAMETER: p_pgmgrp LIKE sy-repid DEFAULT
'BUDINCGA' OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1a.
*end BCT007
*
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-003.
PARAMETERS: p_output(120) DEFAULT '/home/ftp400/ereport/'
LOWER CASE OBLIGATORY.
PARAMETERS: p_file(25) DEFAULT 'budgetis' LOWER CASE OBLIGATORY.
PARAMETERS: p_fpath1(60) DEFAULT 'http://saprpts.gtfc.com/reports/'
LOWER CASE OBLIGATORY.
PARAMETERS: p_fext(12) DEFAULT 'htm' LOWER CASE OBLIGATORY.
* Start of BCT003 *
PARAMETERS: p_shell(60) DEFAULT '/home/ftp400/ereport/' LOWER CASE.
* End of BCT003 *
SELECTION-SCREEN END OF BLOCK b3.
SELECTION-SCREEN BEGIN OF BLOCK b4 WITH FRAME TITLE text-007.
PARAMETERS: p_fprt(2) DEFAULT '05'. " font size for printing
PARAMETERS: p_bprt AS CHECKBOX DEFAULT 'X'. " bold printing font
PARAMETERS: p_fvew(2) DEFAULT '09'. " font size for viewing
PARAMETERS: p_bvew AS CHECKBOX DEFAULT 'X'. " bold viewing font
SELECTION-SCREEN END OF BLOCK b4.
*
SELECTION-SCREEN SKIP 9.
SELECTION-SCREEN SKIP 9.
SELECTION-SCREEN SKIP 9.
*
SELECTION-SCREEN BEGIN OF BLOCK b5 WITH FRAME TITLE text-004.
SELECTION-SCREEN COMMENT 1(55) text-005.
PARAMETERS: p_wait(3) TYPE n DEFAULT 0300.
SELECTION-SCREEN END OF BLOCK b5.
*
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETERS: p_servr(12) DEFAULT 's????????'
LOWER CASE OBLIGATORY.
PARAMETERS: p_user(8) DEFAULT 'sXXXXXXXXX'
LOWER CASE OBLIGATORY.
PARAMETERS: p_psw(8) " default 'ZZZZZZZZZZZZZZZZZZ'
LOWER CASE OBLIGATORY. "BCT001
SELECTION-SCREEN END OF BLOCK b2.
*
*>>>>>>>>> D A T A D E F I N I T I O N S <<<<<<<
DATA w_jobcount LIKE tbtcjob-jobcount.
DATA: w_btcchar1(1).
DATA: w_jobhead LIKE tbtco.
DATA: int_job_read_steplist LIKE tbtcstep OCCURS 0 WITH HEADER LINE.
DATA: spool_list(255) OCCURS 0 WITH HEADER LINE.
DATA: w_rqident LIKE tsp01-rqident.
DATA: wf_while_check(1).
* electronic reporting data
DATA w_size(6). " _print or _view
DATA: e-wrbtr(7) TYPE p DECIMALS 2.
DATA: e_kostl LIKE csks-kostl OCCURS 0 WITH HEADER LINE.
DATA: e_zereport LIKE zereport OCCURS 0 WITH HEADER LINE.
DATA: e_receiver LIKE zereport-receiver OCCURS 0 WITH HEADER LINE.
DATA: e_sent LIKE zereport-receiver OCCURS 0 WITH HEADER LINE.
DATA: i_rpt(256) OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF e_report OCCURS 0 , " report line with keys
kostl LIKE csks-kostl,
line(200).
DATA: END OF e_report.
DATA: BEGIN OF e_email OCCURS 0 . "
INCLUDE STRUCTURE zemail.
DATA: END OF e_email.
RANGES: r_kostl FOR zereport-keylow. " cc's reported on
RANGES: r_receiver_kostl FOR zereport-keylow. " cc's for a receiver
DATA: w_address LIKE zemail-emailaddr.
DATA: w_lines TYPE i.
DATA: e_10(10). " shifting field
DATA: e_heading(1) VALUE 'Y'. " capture heading switch
DATA: e_output(120). " file directory
DATA: w_psw(8).
DATA: w_user(8).
DATA: w_index LIKE sy-tabix.
DATA: w_valid_key(1).
DATA: w_eof. " y is read past last spool_list row
DATA w_start LIKE sy-uzeit. " start time of Report Painter pgm
DATA w_code(40).
DATA: w_receiver LIKE zereport-receiver. " BCT003
DATA: v_comp_name(30). "SLG001
*EJECT
************************************************************************
*>>>>>>>>> E V E N T S <<<<<<<
************************************************************************
TOP-OF-PAGE. " E V E N T
** line 01
* write: /01 'CONSECO FINANCE CORP.', "SLG001
WRITE: /01 v_comp_name, "SLG001
32 'Create Budgeted Income Statement Files',
79 'RUN',
91 'TIME'.
** line 02
WRITE: /01 'REPORT : ', sy-repid,
79 sy-datum MM/DD/YYYY,
91 sy-uzeit USING EDIT MASK '__:__'.
** line 03 print system id - only if not 'PRD'
IF sy-sysid NE 'PRD'. "
WRITE: /01 'SYSTEM : ', sy-sysid,
21 'CLIENT: ', sy-mandt.
ELSE.
SKIP 1.
ENDIF.
WRITE: 79 'PAGE: ',
91 sy-pagno.
** line 04 Company and Cost Center Headings
ULINE.
SKIP 1.
*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
*
START-OF-SELECTION. " E V E N T
PERFORM get_company_name USING ' ' CHANGING v_comp_name. "SLG001
PERFORM 0000_initialize_e_report_tabls.
PERFORM 0500_print_report_heading.
PERFORM 1000_run_report_painter.
PERFORM 3000_create_receiver_files.
PERFORM 9000_closing_routine.
END-OF-SELECTION.
*>>>>>>>>> S T A R T O F F O R M S <<<<<<<
*&---------------------------------------------------------------------*
*& Form 0000_INITIALIZE_E_REPORT_TABLES
*&---------------------------------------------------------------------*
FORM 0000_initialize_e_report_tabls.
*>>>>
e_output = p_output.
*** load zereport into itab e_zereport
SELECT * FROM zereport
INTO TABLE e_zereport
WHERE zprogram = p_pgmgrp. " BCT007
SORT e_zereport.
* Start of BCT004 *
LOOP AT e_zereport.
*%% translate e_zereport-receiver to lower case. "BCT006
IF e_zereport-keylow+0(1) NE 'K'.
SHIFT e_zereport-keylow RIGHT DELETING TRAILING ' '.
TRANSLATE e_zereport-keylow USING ' 0'.
IF e_zereport-keyhigh+0(1) NE 'K' AND
e_zereport-keyhigh+0(1) NE ' '.
SHIFT e_zereport-keyhigh RIGHT DELETING TRAILING ' '.
TRANSLATE e_zereport-keyhigh USING ' 0'.
ENDIF.
MODIFY e_zereport INDEX sy-tabix.
ENDIF.
ENDLOOP.
* End of BCT004 *
*** load range table with cost centers that will be reported on
LOOP AT e_zereport.
MOVE e_zereport-keylow TO r_kostl-low.
MOVE e_zereport-keyhigh TO r_kostl-high.
MOVE 'I' TO r_kostl-sign.
MOVE 'EQ' TO r_kostl-option.
APPEND r_kostl.
ENDLOOP.
SORT r_kostl.
DELETE ADJACENT DUPLICATES FROM r_kostl.
*** load recievers into itab e_receiver
LOOP AT e_zereport.
MOVE e_zereport-receiver TO e_receiver.
*%% translate e_receiver to lower case. "BCT006
APPEND e_receiver.
ENDLOOP.
SORT e_receiver.
DELETE ADJACENT DUPLICATES FROM e_receiver.
ENDFORM. " 0000_INITIALIZE_E_REPORT_TABLES
*&---------------------------------------------------------------------*
*& Form 0500_PRINT_REPORT_HEADING
*&---------------------------------------------------------------------*
FORM 0500_print_report_heading.
DATA: BEGIN OF info OCCURS 20,
flag,
olength TYPE x,
line LIKE raldb-infoline,
END OF info.
w_user = p_user. p_user = '********'.
w_psw = p_psw. p_psw = '********'.
CALL FUNCTION 'RS_COVERPAGE_SELECTIONS'
EXPORTING
report = sy-cprog " Name of current program
variant = ''
no_import = 'X'
TABLES
infotab = info.
LOOP AT info.
WRITE: / info-line.
ENDLOOP.
ENDFORM. " 0500_PRINT_REPORT_HEADING
*&---------------------------------------------------------------------*
*& Form 1000_run_report_painter
*&---------------------------------------------------------------------*
FORM 1000_run_report_painter.
* Start BCT004 *
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = p_jobnam
IMPORTING
jobcount = w_jobcount
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
IF sy-subrc <> 0.
CASE sy-subrc.
WHEN 1.
w_code = 'cant_create_job'.
WHEN 2.
w_code = 'invalid_job_data'.
WHEN 3.
w_code = 'jobname_missing'.
WHEN 4.
w_code = 'others'.
ENDCASE.
MESSAGE i000 WITH 'JOB_OPEN Error ' w_code ' Program aborted'.
FORMAT COLOR COL_NEGATIVE.
SKIP 2.
WRITE: / 'Program aborted.'.
WRITE: / 'Function JOB_OPEN Error ', w_code.
STOP.
ENDIF.
FORMAT COLOR COL_NORMAL.
SKIP 2.
WRITE: / ' JOB_OPEN values after call:'.
WRITE: /4 'jobname ', p_jobnam.
WRITE: /4 'jobcount ', w_jobcount.
* End BCT004 *
TRANSLATE p_pgm TO UPPER CASE.
GET TIME FIELD w_start .
* submit gp3f3l852rg4ocu1cemsw4dhdnn200
SUBMIT (p_pgm)
TO SAP-SPOOL
DESTINATION p_prtr
IMMEDIATELY ' '
KEEP IN SPOOL 'X'
WITHOUT SPOOL DYNPRO
USER sy-uname VIA JOB p_jobnam NUMBER w_jobcount
USING SELECTION-SET p_var
USING SELECTION-SETS OF PROGRAM p_pgm
AND RETURN.
* Start BCT004 *
SKIP 2.
WRITE: / ' SUBMIT parameters after submit:'.
WRITE: /4 'user ', sy-uname.
WRITE: /4 'job ', p_jobnam.
WRITE: /4 'jobcount ', w_jobcount.
WRITE: /4 'program ', p_pgm.
WRITE: /4 'variant ', p_var.
* End BCT004 *
IF sy-subrc <> 0.
CASE sy-subrc.
WHEN 1.
w_code = 'cant_start_immediate'.
WHEN 2.
w_code = 'invalid_startdate'.
WHEN 3.
w_code = 'jobname_missing'.
WHEN 4.
w_code = 'job_close_failed'.
WHEN 5.
w_code = 'job_nosteps'.
WHEN 6.
w_code = 'job_notex'.
WHEN 7.
w_code = 'lock_failed'.
WHEN 8.
w_code = 'others'.
ENDCASE.
MESSAGE i000 WITH 'JOB_CLOSE Error ' w_code ' Program aborted'.
SKIP 2.
FORMAT COLOR COL_NEGATIVE.
WRITE: / 'Program aborted.'.
WRITE: / 'Function JOB_CLOSE Error ', w_code.
STOP.
ENDIF.
FORMAT COLOR COL_NORMAL.
SKIP 2.
WRITE: / ' JOB_CLOSE values after call:'.
WRITE: /4 'jobname ', p_jobnam.
WRITE: /4 'jobcount ', w_jobcount.
* End BCT003 *
* w_jobhead-status possible values
* btc_running like tbtco-status value 'R',
* btc_ready like tbtco-status value 'Y',
* btc_scheduled like tbtco-status value 'P',
* btc_released like tbtco-status value 'S',
* btc_aborted like tbtco-status value 'A',
* btc_finished like tbtco-status value 'F',
* btc_put_active like tbtco-status value 'Z',
* btc_unknown_state like tbtco-status value 'X'.
*
* Wait for a while so jobs can run
*
WHILE ( NOT w_jobhead-status = 'F' ) AND
( NOT w_jobhead-status = 'A' ).
CALL FUNCTION 'BP_JOB_READ'
EXPORTING
job_read_jobcount = w_jobcount
job_read_jobname = p_jobnam
job_read_opcode = '20'
IMPORTING
job_read_jobhead = w_jobhead
TABLES
job_read_steplist = int_job_read_steplist
EXCEPTIONS
invalid_opcode = 1
job_doesnt_exist = 2
job_doesnt_have_steps = 3
OTHERS = 4.
IF w_jobhead-status = 'F'. " F = Finished
EXIT.
ELSEIF w_jobhead-status = 'A'. " A = Aborted
MESSAGE e935 WITH 'BP_JOB_READ function Aborted.'
'Status is '
w_jobhead-status
'"'.
ELSE.
WAIT UP TO p_wait SECONDS.
ENDIF.
ENDWHILE.
IF w_jobhead-status <> 'F'.
WRITE: / 'status', w_jobhead-status.
MESSAGE e935 WITH
'BP_JOB_READ function did not complete successfully'
w_jobhead-status.
ELSE.
PERFORM 1111_calculate_job_time.
ENDIF.
*>>>> This select is not needed, used to show location of data.
* data: w_stepcount ike tbtcp-stepcount.
* w_stepcount = 1.
* select single * from tbtcp
* where jobname = P_jobnam and
* jobcount = w_jobcount and
* stepcount = w_stepcount.
w_rqident = int_job_read_steplist-listident.
CALL FUNCTION 'RSPO_RETURN_ABAP_SPOOLJOB'
EXPORTING
* rqident = int_job_read_steplist-listident
rqident = w_rqident
TABLES
buffer = spool_list
EXCEPTIONS
no_such_job = 1
not_abap_list = 2
job_contains_no_data = 3
selection_empty = 4
no_permission = 5
can_not_access = 6
read_error = 7
OTHERS = 8.
IF sy-subrc <> 0.
CASE sy-subrc.
WHEN 1.
w_code = 'no_such_job'.
WHEN 2.
w_code = 'not_abap_list'.
WHEN 3.
w_code = 'job_contains_no_data'.
WHEN 4.
w_code = 'selection_empty'.
WHEN 5.
w_code = 'no_permission'.
WHEN 6.
w_code = 'can_not_access'.
WHEN 7.
w_code = 'read_error'.
WHEN 8.
w_code = 'others'.
ENDCASE.
MESSAGE ID 'ZF' "sy-msgid
TYPE 'A' "sy-msgty
NUMBER '000' "sy-msgno
WITH
'RSPO_RETURN_ABAP_SPOOLJOB, error' "sy-msgv1
w_code . "sy-msgv2
ENDIF.
*
ENDFORM. " 1000_run_report_painter
*&---------------------------------------------------------------------*
*& Form 1111_CALCULATE_JOB_TIME
*&---------------------------------------------------------------------*
FORM 1111_calculate_job_time.
DATA: w_end LIKE sy-uzeit.
DATA: w_max(6) TYPE n.
DATA: w_time LIKE sy-uzeit.
DATA: w_use(6) TYPE c.
DATA: w_used_sec(6) TYPE n.
DATA: w_pct(3) TYPE n.
GET TIME FIELD w_end.
ENDFORM. " 1111_CALCULATE_JOB_TIME
*&---------------------------------------------------------------------*
*& Form 3000_CREATE_RECEIVER_FILES
*&---------------------------------------------------------------------*
FORM 3000_create_receiver_files.
* perform process by receiver in loop
LOOP AT e_receiver.
* load r_receiver_kostl range table
CLEAR r_receiver_kostl.
REFRESH r_receiver_kostl.
LOOP AT e_zereport WHERE receiver = e_receiver.
CHECK e_zereport-receiver = e_receiver.
MOVE e_zereport-keylow TO r_receiver_kostl-low.
SHIFT r_receiver_kostl-low LEFT DELETING LEADING ' '.
SHIFT r_receiver_kostl-low LEFT DELETING LEADING '0'.
MOVE e_zereport-keyhigh TO r_receiver_kostl-high.
SHIFT r_receiver_kostl-high LEFT DELETING LEADING ' '.
SHIFT r_receiver_kostl-high LEFT DELETING LEADING '0'.
IF e_zereport-keyhigh = ' '.
MOVE r_receiver_kostl-low TO r_receiver_kostl-high.
ENDIF.
MOVE 'I' TO r_receiver_kostl-sign.
MOVE 'BT' TO r_receiver_kostl-option.
APPEND r_receiver_kostl.
ENDLOOP.
* create the receiver file
CLEAR i_rpt.
REFRESH i_rpt.
*
*>>>> get all report lines for this receiver <<<<<<<
PERFORM 4000_process_spool_list.
*stop.
DESCRIBE TABLE i_rpt LINES w_lines.
IF w_lines > 0.
* create table of receivers that have a file sent
e_sent = e_receiver.
APPEND e_sent.
* open receiver file
w_size = '_view'.
w_receiver = e_receiver. " BCT006
TRANSLATE w_receiver TO LOWER CASE. " BCT006
CONCATENATE e_output w_receiver '_' p_file w_size
INTO p_output.
OPEN DATASET p_output FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
WRITE: text-z01, p_output. "Error opening file
STOP.
ENDIF.
* call program to convert to html format
PERFORM 3019_convert_to_html.
* close receiver file
CLOSE DATASET p_output.
* ftp file
PERFORM 3111_ftp_file.
*>>>>> create and send 2nd file
w_size = '_print'.
w_receiver = e_receiver. " BCT006
TRANSLATE w_receiver TO LOWER CASE. " BCT006
CONCATENATE e_output w_receiver '_' p_file w_size
INTO p_output.
OPEN DATASET p_output FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
WRITE: text-z01, p_output. "Error opening file
STOP.
ENDIF.
* call program to convert to html format
PERFORM 3019_convert_to_html_2.
* close receiver file
CLOSE DATASET p_output.
* ftp file
PERFORM 3111_ftp_file.
*>>>>>
* send email to receiver
PERFORM 3222_send_email.
ENDIF. " w_lines > 0.
ENDLOOP. " loop at e_receiver.
ENDFORM. " 3000_CREATE_RECEIVER_FILES
*&---------------------------------------------------------------------*
*& Form 3019_CONVERT_TO_HTML
*&---------------------------------------------------------------------*
FORM 3019_convert_to_html.
DATA: htmtab LIKE zhtml-line OCCURS 0 WITH HEADER LINE.
DATA: w_headkey LIKE bseg-sgtxt VALUE space.
w_headkey = p_line1.
CLEAR htmtab.
REFRESH htmtab.
CALL FUNCTION 'Z_LISTASCI_TO_HTML'
EXPORTING
textfont = p_fvew
headfont = p_fvew
* TEXTCOLOR =
* HEADCOLOR =
* BACKCOLOR =
* HEADULINE =
* PAGETITLE =
boldtext = p_bvew
headkey = w_headkey " 1st line of page, char 1-12
TABLES
listasci = i_rpt
htmtab = htmtab.
LOOP AT htmtab.
TRANSFER htmtab TO p_output.
ENDLOOP.
ENDFORM. " 3019_CONVERT_TO_HTML
*&---------------------------------------------------------------------*
*& Form 3111_FTP_FILE
*&---------------------------------------------------------------------*
FORM 3111_ftp_file.
DATA: w_repid(25).
*
*
w_receiver = e_receiver. " BCT006
TRANSLATE w_receiver TO LOWER CASE. " BCT006
CONCATENATE p_file w_size INTO w_repid.
SUBMIT zuftpput
WITH p_repid = w_repid
* with p_luser = e_receiver
WITH p_luser = w_receiver
WITH p_lpath = p_output
WITH shelldir = p_shell " BCT006
WITH p_ftype = p_fext
WITH p_prt = ' '
WITH p_server = p_servr
WITH p_ruser = w_user
WITH p_pw = w_psw
* with p_server = 'sp9'
* with p_ruser = 'ftp-sap'
* with p_pw = 'sap'
AND RETURN.
ENDFORM. " 3111_FTP_FILE
*&---------------------------------------------------------------------*
*& Form 3019_CONVERT_TO_HTML_2
*&---------------------------------------------------------------------*
FORM 3019_convert_to_html_2.
DATA: htmtab LIKE zhtml-line OCCURS 0 WITH HEADER LINE.
DATA: w_headkey LIKE bseg-sgtxt VALUE space.
w_headkey = p_line1.
CLEAR htmtab.
REFRESH htmtab.
CALL FUNCTION 'Z_LISTASCI_TO_HTML'
EXPORTING
textfont = p_fprt
headfont = p_fprt
* TEXTCOLOR =
* HEADCOLOR =
* BACKCOLOR =
* HEADULINE =
* PAGETITLE =
boldtext = p_bprt
* headkey = 'CONSECO FINANCE CORP.' " BCT007
headkey = w_headkey " 1st line of page, char 1-12
TABLES
listasci = i_rpt
htmtab = htmtab.
LOOP AT htmtab.
TRANSFER htmtab TO p_output.
ENDLOOP.
ENDFORM. " 3019_CONVERT_TO_HTML_2
*&---------------------------------------------------------------------*
*& Form 3222_SEND_EMAIL
*&---------------------------------------------------------------------*
FORM 3222_send_email.
*
DATA: objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
DATA: objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE.
DATA: objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE.
DATA: objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE.
DATA: reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE.
DATA: doc_chng LIKE sodocchgi1.
DATA: tab_lines LIKE sy-tabix.
*
* Creation of the document to be sent
DATA: w_line(80).
CONSTANTS: w_24(24) VALUE space.
doc_chng-obj_name = 'BI_RPT'.
doc_chng-obj_descr = 'Budgeted Income Statement Report'.
*DOC_CHNG-obj_prio = 1.
*DOC_CHNG-priority = 1.
*
objtxt = 'The Budgeted Income Statement report is available.'.
APPEND objtxt. CLEAR objtxt.
objtxt = ' '.
APPEND objtxt. CLEAR objtxt.
objtxt = 'To view the report:'.
APPEND objtxt. CLEAR objtxt.
objtxt = ' 1. Copy this link to the windows clipboard by highligh'.
objtxt+59(60) = 'ting and pressing Control and C'.
APPEND objtxt. CLEAR objtxt.
objtxt+8 = 'keys simultaneously.'.
APPEND objtxt. CLEAR objtxt.
w_receiver = e_receiver. " BCT006
TRANSLATE w_receiver TO LOWER CASE. " BCT006
CONCATENATE p_fpath1 w_receiver '/' INTO w_line.
*concatenate p_fpath1 w_receiver '/' into w_line. " BCT006
objtxt+21 = w_line.
APPEND objtxt. CLEAR objtxt.
objtxt = ' 2. Start the program Internet Explorer.'.
APPEND objtxt. CLEAR objtxt.
objtxt = ' 3. Paste the contents of the windows clipboard in the l'.
objtxt+60(51) = 'ocation window by pressing'.
APPEND objtxt. CLEAR objtxt.
objtxt+8 = 'Control and V keys simultaneously.'.
APPEND objtxt. CLEAR objtxt.
objtxt = ' 4. Press the Enter key.'.
APPEND objtxt. CLEAR objtxt.
objtxt =
' 5. Create a bookmark in Internet Explorer that can be used'.
objtxt+63(51) = ' in the future.'.
APPEND objtxt. CLEAR objtxt.
objtxt = ' '.
APPEND objtxt. CLEAR objtxt.
objtxt = 'If a bookmark exists, steps 2 and 5 can be used to access'.
objtxt+58(59) = ' the report.'.
APPEND objtxt. CLEAR objtxt.
objtxt = ' '.
APPEND objtxt. CLEAR objtxt.
objtxt = 'When printing, make sure the print orientation is Landscape'.
objtxt+58(59) = 'e. '.
APPEND objtxt. CLEAR objtxt.
objtxt = ' '.
APPEND objtxt. CLEAR objtxt.
objtxt = 'If you have any problems, call the SAP helpdesk at extensio'.
objtxt+59(59) = 'n 43650.'.
APPEND objtxt. CLEAR objtxt.
*
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
* Creation of the entry for the compressed document
CLEAR objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'RAW'.
APPEND objpack.
DESCRIBE TABLE objbin LINES tab_lines.
*
* Completing the recipient list
w_receiver = e_receiver. " BCT005
TRANSLATE w_receiver TO UPPER CASE. " BCT005
SELECT * FROM zemail INTO TABLE e_email
WHERE receiver = w_receiver. " BCT005
* where receiver = e_receiver. " BCT005
IF sy-subrc = 0.
READ TABLE e_email INDEX 1.
w_address = e_email-emailaddr .
ENDIF.
reclist-receiver = w_address .
reclist-rec_type = 'U'.
reclist-express = 'X'.
APPEND reclist.
*
* Sending the document
*
*>> Start of BCT008
*
*call function 'SO_NEW_DOCUMENT_ATT_SEND_MAPI'
* exporting
* document_data = doc_chng
* put_in_outbox = 'X'
* commit_work = 'X'
* tables
* packing_list = objpack
** OBJECT_HEADER = OBJHEAD
* contents_bin = objbin
* contents_txt = objtxt
* receivers = reclist.
DATA: i_documents TYPE zemail_documents. " itab
DATA: w_documents TYPE zemail_documents_row. " structure
DATA: i_recipients TYPE zemail_recipients. " itab
DATA: w_recipients TYPE zemail_recipients_row. " structure
*
***********************************************************************
* Build documents itab
***********************************************************************
* 1st record contains body of email
*
CLEAR w_documents.
w_documents-type = 'RAW'.
w_documents-subject = 'Budgeted Income Statement Report'.
LOOP AT objtxt.
APPEND objtxt-line TO w_documents-content_text.
ENDLOOP.
APPEND w_documents TO i_documents.
*
* Build recipients itab
LOOP AT reclist.
w_recipients-c_address = reclist-receiver.
w_recipients-i_express = 'X'.
* w_recipients-i_copy = ' '.
* w_recipients-i_blind = 'X'.
* w_recipients-i_no_forward = 'X'.
APPEND w_recipients TO i_recipients.
ENDLOOP.
*
CALL FUNCTION 'Z_620_SEND_EMAIL_BCS'
EXPORTING
* REQUESTED_STATUS = 'E'
documents = i_documents
recipients = i_recipients.
*
*>> End of BCT008
*
ENDFORM. " 3222_SEND_EMAIL
*&---------------------------------------------------------------------*
*& Form 4000-PROCESS_SPOOL_LIST
*&---------------------------------------------------------------------*
FORM 4000_process_spool_list.
ENDFORM. " 4000-PROCESS_SPOOL_LIST
*&---------------------------------------------------------------------*
*& Form 4222_CHECK_KEY
*&---------------------------------------------------------------------*
FORM 4222_check_key.
w_valid_key = 'N'.
IF spool_list+12(10) IN r_receiver_kostl.
w_valid_key = 'Y'.
ENDIF.
ENDFORM. " 4222_CHECK_KEY
*&---------------------------------------------------------------------*
*& Form 4444_READ_TILL_NEW_KEY
*&---------------------------------------------------------------------*
FORM 4444_read_till_new_key.
READ TABLE spool_list INDEX w_index .
IF sy-subrc NE 0.
w_eof = 'Y'.
ENDIF.
w_index = w_index + 1.
w_valid_key = 'N'.
DO.
IF w_eof = 'Y'. EXIT. ENDIF.
* if spool_list(12) = 'Cost Center '.
IF spool_list(11) = p_line1.
EXIT.
ELSE.
READ TABLE spool_list INDEX w_index .
IF sy-subrc NE 0.
w_eof = 'Y'.
ENDIF.
w_index = w_index + 1.
ENDIF.
ENDDO.
ENDFORM. " 4444_READ_TILL_NEW_KEY
*&---------------------------------------------------------------------*
*& Form 4466_WRITE_TILL_NEW_KEY
*&---------------------------------------------------------------------*
FORM 4466_write_till_new_key.
DO.
i_rpt = spool_list.
APPEND i_rpt.
READ TABLE spool_list INDEX w_index .
IF sy-subrc NE 0.
w_eof = 'Y'.
EXIT.
ENDIF.
w_index = w_index + 1.
* if spool_list(12) = 'Cost Center '.
IF spool_list(11) = p_line1.
EXIT.
ENDIF.
ENDDO.
*
ENDFORM. " 4466_WRITE_TILL_NEW_KEY
*&---------------------------------------------------------------------*
*& Form 9000_CLOSING_ROUTINE
*&---------------------------------------------------------------------*
FORM 9000_closing_routine.
SKIP 2.
FORMAT COLOR OFF.
WRITE: /12 'These receivers were sent a file'.
SKIP 1.
FORMAT COLOR COL_NORMAL.
LOOP AT e_sent.
WRITE: /2 e_sent.
ENDLOOP.
SKIP 2.
FORMAT COLOR OFF.
WRITE: /12 'Program completed'.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.