Spool file help

IN THAT spool file i m getting header but i need to add 'TITLE' in this file before header.TITLE is like 'EMPLOYEE_ID NOT FOUND IN EMPLOYEE TEMP TABLE' AND then header that what i m getting in csv file.
WHENEVER SQLERROR EXIT FAILURE
WHENEVER OSERROR EXIT FAILURE
SET trimspool on
SET heading off
SET echo off
SET feedback off
SET verify off
SET termout off
SET newpage 1
SET space 0
SET PAGESIZE 0
SET LINESIZE 750
SPOOL C:\Users\Desktop\ERRRPT_&1..csv
SELECT 'EMPLOYEE_ID'
|| ','
|| 'FIRST_NAME'
|| ','
|| 'LAST_NAME'
|| ','
|| 'SALARY'
|| ','
|| 'DEPT_ID'
FROM DUAL;
SELECT DISTINCT getall.EMPLOYEE_ID
|| ','
|| getall.FIRST_NAME
|| ','
|| getall.LAST_NAME
|| ','
|| getall.SALARY
|| ','
|| getall.DEPT_ID
FROM (SELECT a.EMPLOYEE_ID,a.FIRST_NAME, a.LAST_NAME ,
a.SALARY,a.DEPT_ID
FROM EMPLOOYE_TEMP a
WHERE a.EMPLOYEE_ID IS NULL
)getall;
SPOOL OFF
Thanks

tom wrote:
you mean i need to write dual two time one for header and one for title .is it correct statement?What Frank means is simply add PROMPT to your script:
WHENEVER SQLERROR EXIT FAILURE
WHENEVER OSERROR EXIT FAILURE
SET trimspool on
SET heading off
SET echo off
SET feedback off
SET verify off
SET termout off
SET newpage 1
SET space 0
SET PAGESIZE 0
SET LINESIZE 750
SPOOL C:\Users\Desktop\ERRRPT_&1..csv
PROMPT   EMPLOYEE_ID NOT FOUND IN EMPLOYEE TEMP TABLE
SELECT 'EMPLOYEE_ID'
|| ','
|| 'FIRST_NAME'
|| ','
|| 'LAST_NAME'
|| ','
|| 'SALARY'
|| ','
|| 'DEPT_ID'
FROM DUAL;
SELECT DISTINCT getall.EMPLOYEE_ID
|| ','
|| getall.FIRST_NAME
|| ','
|| getall.LAST_NAME
|| ','
|| getall.SALARY
|| ','
|| getall.DEPT_ID
FROM (SELECT a.EMPLOYEE_ID,a.FIRST_NAME, a.LAST_NAME ,
a.SALARY,a.DEPT_ID
FROM EMPLOOYE_TEMP a
WHERE a.EMPLOYEE_ID IS NULL
)getall;
SPOOL OFF
/Just keep in mind, title
EMPLOYEE_ID NOT FOUND IN EMPLOYEE TEMP TABLE
Will appear in spool file regardless if SELECT returns any rows. If you want title to appear only if SELECT returns rows use:
WHENEVER SQLERROR EXIT FAILURE
WHENEVER OSERROR EXIT FAILURE
SET trimspool on
SET heading off
SET echo off
SET feedback off
SET verify off
SET termout off
SET newpage 1
SET space 0
SET PAGESIZE 0
SET LINESIZE 750
SPOOL C:\Users\Desktop\ERRRPT_&1..csv
PROMPT   EMPLOYEE_ID NOT FOUND IN EMPLOYEE TEMP TABLE
SELECT CASE ROWNUM
         WHEN 1 THEN 'EMPLOYEE_ID NOT FOUND IN EMPLOYEE TEMP TABLE' || CHR(10)
       END ||
'EMPLOYEE_ID'
|| ','
|| 'FIRST_NAME'
|| ','
|| 'LAST_NAME'
|| ','
|| 'SALARY'
|| ','
|| 'DEPT_ID'
FROM DUAL;
SELECT DISTINCT getall.EMPLOYEE_ID
|| ','
|| getall.FIRST_NAME
|| ','
|| getall.LAST_NAME
|| ','
|| getall.SALARY
|| ','
|| getall.DEPT_ID
FROM (SELECT a.EMPLOYEE_ID,a.FIRST_NAME, a.LAST_NAME ,
a.SALARY,a.DEPT_ID
FROM EMPLOOYE_TEMP a
WHERE a.EMPLOYEE_ID IS NULL
)getall;
SPOOL OFF
/SY.

Similar Messages

  • Seek help to format spool file from SQL*PLUS

    I am running a Unix shell script to call a Oracle 11g SQL script from a Oracle database. In this SQL script, I need to connect to many different remote databases to select data, then sool these records as one big text file to a directory. Then email the file to related Group users. In the spool file, there is a line on the top of each page like this:
    DUMMY
    DB_NAME
    I know this is caused by connect to remote database in SQL*PLUS. My connection string is like this:
    Conn system/password@Oracle_SID
    How can I remove these lines or how to skip these lines into spool file? Please advise. Thanks in advnce. Wish all of you Happy New Year!!!

    Hi,
    It sounds like you have some kind of formatting (such as SQL*Plus TTITLE) producing the output you don't want. If that's the case, temporarily stopping the spooling might not help you. Find out what is causing the output that you don't want. You say that you know it is caused by the CONNECT statements, but it must be more than that. I've written scripts with CONNECT statements that don't have anything like what you reported at the top of each page; in fact, they don't even have pages: the output is one continuous stream. Find out what's putting the unwanted output there, and that will be a big clue as to how you can stop it.
    You say that you know the unwanted titles are there because of the CONNECT statements. If so, use database links instead of CONNECT. You don't have to use dbms_scheduler or utl_file; just eliminate the CONNECT statements. (I'm not saying that there's anything wrong with dbms_scheduler or utl_file; you should definitely investigate those tools. I'm just saying that using database links is independent of them.)
    What would happen if you did all your connecting to different databases at the OS level? Can you write a shell script that connects to each database in turn, and runs a SQL*Plus script in each one. Each SQL*Plus script would have a SPOOL or SPOOL ... APPEND command, or maybe you could build the SPOOL into a LOGIN.SQL script.

  • HELP!! Very Large Spooling / File Size after Data Merge

    My question is: If the image is the same and only the text is different why not use the same image over and over again?
    Here is what happens...
    Using CS3 and XP (P4 2.4Ghz, 1GB Ram, 256MB Video Card) I have taken a postcard pdf (the backside) placed it in a document, then I draw a text box. Then I select a data source and put the fields I wish to print (Name, address, zip, etc.) in the text box.
    Now, under the Create Merged Document menu I select Multiple Records and then use the Multiple Records Layout tab to adjust the placement of this postcard on the page. I use the preview multiple records option to lay out 4 postcards on my page. Then I merge the document (it has 426 records).
    Now that my merged document is created with four postcards per page and the mailing data on each card I go to print. When I print the file it spools up huge! The PDF I orginally placed in the document is 2.48 MB but when it spools I can only print 25 pages at a time and that still takes FOREVER. So again my question is... If the image is the same and only the text is different why not use the same image over and over again?
    How can I prevent the gigantic spooling? I have tried putting the PDF on the master page and then using the document page to create the merged document and still the same result. I have also tried createing a merged document with just the addresses then adding the the pdf on the Master page afterward but again, huge filesize while spooling. Am I missing something? Any help is appreciated :)

    The size of the EMF spool file may become very large when you print a document that contains lots of raster data
    View products that this article applies to.
    Article ID : 919543
    Last Review : June 7, 2006
    Revision : 2.0
    On This Page
    SYMPTOMS
    CAUSE
    RESOLUTION
    STATUS
    MORE INFORMATION
    Steps to reproduce the problem
    SYMPTOMS
    When you print a document that contains lots of raster data, the size of the Enhanced Metafile (EMF) spool file may become very large. Files such as Adobe .pdf files or Microsoft Word .doc documents may contain lots of raster data. Adobe .pdf files and Word .doc documents that contain gradients are even more likely to contain lots of raster data.
    Back to the top
    CAUSE
    This problem occurs because Graphics Device Interface (GDI) does not compress raster data when the GDI processes EMF spool files and generates EMF spool files.
    This problem is very prominent with printers that support higher resolutions. The size of the raster data increases by four times if the dots-per-inch (dpi) in the file increases by two times. For example, a .pdf file of 1 megabyte (MB) may generate an EMF spool file of 500 MB. Therefore, you may notice that the printing process decreases in performance.
    Back to the top
    RESOLUTION
    To resolve this problem, bypass EMF spooling. To do this, follow these steps:1. Open the properties dialog box for the printer.
    2. Click the Advanced tab.
    3. Click the Print directly to the printer option.
    Note This will disable all print processor-based features such as the following features: N-up
    Watermark
    Booklet printing
    Driver collation
    Scale-to-fit
    Back to the top
    STATUS
    Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.
    Back to the top
    MORE INFORMATION
    Steps to reproduce the problem
    1. Open the properties dialog box for any inbox printer.
    2. Click the Advanced tab.
    3. Make sure that the Print directly to the printer option is not selected.
    4. Click to select the Keep printed documents check box.
    5. Print an Adobe .pdf document that contains many groups of raster data.
    6. Check the size of the EMF spool file.

  • Please Help in ORACLE SPOOL File

    Hello All,
    I made oracle Spool file.Generally i m calling a FUNCTION which return a REFCURSOR.
    ----Package Spec------------------------
    CREATE OR REPLACE PACKAGE Axspointrpt IS
    TYPE return_cur IS REF CURSOR ;
    -- # Updates to the SOI and associated CARMA user ids
    FUNCTION F_UPDATION_USERID_RPT RETURN return_cur ;
    END Axspointrpt;
    ----Package Body------------------------
    CREATE OR REPLACE PACKAGE BODY Axspointrpt IS
    FUNCTION F_UPDATION_USERID_RPT
    RETURN return_cur IS
    VCur return_cur;
    BEGIN
    OPEN VCur FOR
    SELECT
    ID_SCTY,ID_SYMBOL,NM_SHORT,S.DT_MNT_LST,S.ID_MNT_LST,LTRIM(RTRIM(CARMA_FINAL.F_Getusername(S.ID_MNT_LST))) USERNAME,DECODE(IN_DELETED,'Y','YES','N','NO') ACTION
    FROM SOI_MASTER S,APP_USER A
    WHERE S.ID_MNT_LST=A.ID_MNT_LST;
    RETURN VCur;
    EXCEPTION
    WHEN OTHERS THEN
    IF (VCur%isOpen) THEN
    CLOSE VCur;
    END IF;
    END F_UPDATION_USERID_RPT ;
    -----------callRPT.sql ------------------
    SET MARKUP HTML ON SPOOL ON HEAD "<TITLE>SQL*Plus Report</title> -"
    SET ECHO OFF
    SET PAUSE OFF
    SET VERIFY OFF
    SET FEEDBACK OFF
    SET HEADING ON
    SET LINESIZE 150
    set PAGESIZE 85
    SET TRIMSPOOL ON PAGESIZE 50
    SPOOL D:\Avinash\employee.htm
    select Axspointrpt.F_UPDATION_USERID_RPT from DUAL;
    clear breaks
    TTITLE OFF
    SPOOL OFF
    SET MARKUP HTML OFF
    SET ECHO ON
    When i run this SQL file then i am getting the procedure name as well as CURSOR STATEMENT along with the table data.I want get Hide the procedure namd,and cursor statement.Please help in this.
    Regards,
    [email protected]

    Hi Avinash,
    Try this:
    create or replace package dump_refcursor_test is
    type return_cur is ref cursor;
    function get_data return return_cur;
    end dump_refcursor_test;
    create or replace package body dump_refcursor_test is
    function get_data return return_cur
    is
    l_cur return_cur;
    begin
    open l_cur for select 'qwerty' from dual;
    return l_cur;
    end get_data;
    end dump_refcursor_test;
    Create a file called spool.sql put it in c:\. Put his in the file:
    SET NEWPAGE 0
    SET SPACE 0
    SET LINESIZE 80
    SET PAGESIZE 0
    SET ECHO OFF
    SET FEEDBACK OFF
    SET HEADING OFF
    SET MARKUP HTML OFF SPOOL OFF
    set sqlprompt "".
    var res refcursor;
    exec :res:= dump_refcursor_test.get_data;
    spool c:\spool_output
    print res
    spool off
    Now go to sql*plus and type this:
    @c:\spool.sql
    This will give you a file with only the data, here "qwerty"
    Regards Pete

  • Need help for Scheduling a Spool file and FTP the file

    I have one requirement like below...
    1. Start Scheduling a job
    2. Generate a Spool file (.csv file)
    3. If Spool file generation is successful then start FTP the file
    Else End job
    4. After successful FTP process end the job.
    We need to create a log file also for this job.
    Can any body give some idea how will i proceed?
    Thanks in advance.

    Billy  Verreynne  wrote:
    BluShadow wrote:
    Chris' may be wrapped, but it includes the funky ability to query remote files directly in SQL due to it's use of pipelined functions. A feature I've also got in my own FTP package and very useful for monitoring logs on remote servers through our Apex applications. ;)Ditto - also rolled my own FTP package as doing wildcard file listing requires custom support depending on the type of FTP server you're dealing with. The text part of the responses differ (these are not RFC'ed) and makes parsing more complex than what it could have been.Yeah, the differing responses can be a pain, though fortunately they are far and few between. There was a bug in Chris' package in that it wasn't handling a two code response from a windows FTP server for one of the commands, but I emailed him and he fixed that. Not his fault, he didn't have a windows FTP server to test on at the time.
    FTP is a pretty straight forward protocol and easy to wrap a PL/SQL package around (using <i>UTL_TCP</i>).Absolutely. and the RFC details almost everthing you need to handle. It was quite quick to knock up a package, similar to the code hoek has linked to.
    I think there is a lot of common stuff that many of us do in this regard. Always wondered how well a proper GPL'ed open source project providing a PL/SQL development framework and libraries would do...I think there'd be a lot of arguments about what is the best way of doing things. :D

  • How to spool out put of multiple scripts and get a single spool file output

    Hi,
    I have one master script that calls three other scripts. The three scripts each produce their own spool files. But I would like to have the master script also produce one single output (in addition to the three indiviual output I mean). How to do that? Can you please help.
    Following are the scripts:
    --m.sql (master script)
    spool c:\m.log
    @1.sql
    @2.sql
    @3.sql
    spool off
    --1.sql
    spool c:\1.log
    insert into test values(1);
    commit;
    spool off
    --2.sql
    spool c:\2.log
    insert into test values(2);
    commit;
    spool off
    spool c:\3.log
    insert into test values(3);
    commit;
    spool off
    --table used
    SQL> desc test
    Name                                      Null?    Type
    A                                                  NUMBERWhen I run the above script m.sql it does produce the other 3 log files (1.log,2.log etc) but m.log (which is master log file which should have output of each of the three calling script) is empty file with 0 byte!
    Thanks
    Edited by: orausern on May 1, 2011 3:17 AM

    I have one master script that calls three other scripts. The three scripts each produce their own spool files. But I would like to have the master script also produce one single output (in addition to the three indiviual output I mean). How to do that? Can you please help. Not sure if that's possible directly with sqlplus spool option
    When you spool to a different file in a single session, sqlplus stops writing to earlier spool file and redirects the output to the file specified in last spool command.
    at the end of the script, however, below may help
    host type c:\1.log >> c:\m.log
    host type c:\2.log >> c:\m.log
    host type c:\3.log >> c:\m.log

  • How to get the number of rows written to the header of the spool file.

    Hi
    I need to create a header line for the spool file .
    the header line should include fixed length values .
    The header should include the number of records found in the table with a maximum begin date (begin_date is the column of the table)
    To get the header in the spool file , i wrote a select query has :-
    --SPOOL 'C:\Documents and Settings\abc\Desktop\output.TXT'
    select 'W'||to_char(sysdate,'MM/DD/YYYYMi:HH:SS')||lpad(max(rownum),9,'000000000') ||'R'||max(to_char(school_from_date,'MM/DD/YYYY')) ||
    rpad(' ',76,' ')
    from dad.school
    group by sysdate;
    SPOOL OFF
    which gets me all the rows in the table , but i only want the rows with the latest school_begin_date .
    how can i achieve that ...
    I know that a subquery should be written in the from clause to get the number of rows found with a maximum school_begin_date.
    select 'W'||to_char(sysdate,'MM/DD/YYYYMi:HH:SS')||lpad(max(rownum),9,'000000000') ||'R'||max(to_char(school_from_date,'MM/DD/YYYY')) ||
    rpad(' ',76,' ')
    from dad.school where
    select rownum from dad.school
    where school_begin_date = max(school_begin_date) ;
    the error i get is
    ORA-00934: group function is not allowed here
    I NEED HELP ..IN GETTING THE ROWNUM JUST FOR THE LATEST BEGIN_DATE ?
    PLS HELP ME IN WRITING THE QUERY .
    THANKS IN ADVANCE .

    Try this:
    select 'W'||to_char(sysdate,'MM/DD/YYYYMi:HH:SS')||lpad(max(rownum),9,'000000000')||'R'||max(to_char(school_from_date,'MM/DD/YYYY')) || rpad(' ',76,' ')
      from dad.school
    where school_begin_date = (select max(school_begin_date)
                                  from dad.school);

  • Can a spool file be sent as an attachment in the decision step?

    Hi,
    I have z program that runs in background and produces a spool file. Normally, I can use tcode SP01 to display this file. At the end of this z program, I call SWW_WI_START_SIMPLE to send a workflow into SAP inbox. I want to know if I somhow can send the spool file along also? I read about attachment and SOFM object but still can't figure out what I need to do yet. Please help.
    Thank you,
    TH

    Hi Th,
    Check this code if helpful.
    FORM pdf_conversion.
      CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
           EXPORTING
                src_spoolid              = spoolno
                no_dialog                = ' '
           IMPORTING
                pdf_bytecount            = numbytes
                pdf_spoolid              = pdfspoolid
                btc_jobname              = jobname
                btc_jobcount             = jobcount
           TABLES
                pdf                      = pdf
           EXCEPTIONS
                err_no_abap_spooljob     = 1
                err_no_spooljob          = 2
                err_no_permission        = 3
                err_conv_not_possible    = 4
                err_bad_destdevice       = 5
                user_cancelled           = 6
                err_spoolerror           = 7
                err_temseerror           = 8
                err_btcjob_open_failed   = 9
                err_btcjob_submit_failed = 10
                err_btcjob_close_failed  = 11.
    ENDFORM.                    " PDF_CONVERSION
          FORM SPOOL                                                    *
    FORM spool.
      PERFORM display.
      CALL FUNCTION 'GET_PRINT_PARAMETERS'
           EXPORTING
               destination            = 'LOCL'
                immediately            = ' '
                new_list_id            = 'X'
                expiration             = '9'
                in_parameters          = p_pripar
                layout                 = 'X_65_132'
                line_count             = 65
                line_size              = 132
                mode                   = 'DEFVALS'
                no_dialog              = 'X'
           IMPORTING
                out_parameters         = p_pripar
                valid                  = val
           EXCEPTIONS
                archive_info_not_found = 1
                invalid_print_params   = 2
                invalid_archive_params = 3
                OTHERS                 = 4.
      NEW-PAGE PRINT ON NEW-SECTION PARAMETERS p_pripar NO DIALOG.
      PERFORM display.
      NEW-PAGE PRINT OFF.
      CLEAR t_filename_tx.
      CONCATENATE 'c:\temp\' p_mat '.pdf' INTO t_filename_tx.
      CONDENSE t_filename_tx.
      SELECT * FROM tsp01 INTO TABLE t_tsp01
           WHERE rqowner EQ sy-uname.
      SORT t_tsp01  BY rqcretime DESCENDING.
      LOOP AT t_tsp01.
        spoolno = t_tsp01-rqident.
        EXIT.
      ENDLOOP.
      IF sy-subrc EQ 0.
        PERFORM pdf_conversion.
      ENDIF.
    sending that inernal to mail
    FUNCTION z_p_traveler_workflow.
    ""Local interface:
    *"  IMPORTING
    *"     REFERENCE(V_FILE_PATH) LIKE  RLGRAP-FILENAME
    *"     REFERENCE(DOKNR) LIKE  CRVD_A-DOKNR
    *"     REFERENCE(DOKVR) LIKE  CRVD_A-DOKVR
    *"  TABLES
    *"      PDF STRUCTURE  TLINE
    D A T A
      DATA: w_gd_doc_data LIKE sodocchgi1.
    internal table for body content of the email
      DATA: t_message LIKE solisti1 OCCURS 0 WITH HEADER LINE.
    internal table for receivers of email
      DATA: t_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE.
    internal table for attachment data
      DATA: t_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE.
    *internal table for Information about structure of data tables
      DATA: t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE.
    internal tables for attachment data
      DATA: t_xi_pdf LIKE tline OCCURS 0  WITH HEADER LINE,
            t_xi_temp LIKE bapiqcmime OCCURS 0  WITH HEADER LINE,
            t_xi_mime(255) TYPE c OCCURS 0  WITH HEADER LINE,
            t_html LIKE solisti1   OCCURS 0  WITH HEADER LINE.
    for splitting of the filepath
      DATA : BEGIN OF t_split OCCURS 0,
                row(50),
             END OF t_split.
      DATA:  w_tab_lines LIKE sy-tabix,
             w_subject TYPE so_obj_des,                " for email header
             w_file_path1 TYPE string.                 "file path
      DATA : w_lines       TYPE i,
             w_temp(500)   TYPE c,
             w_offset      TYPE p,
             w_lineslen(2) TYPE p,
             w_mimelen(2)  TYPE p,
             w_tabix       LIKE sy-tabix.
      DATA : w_len      TYPE i,
             w_index    LIKE sy-index,
             w_doc_type TYPE  so_obj_tp,
             w_filename TYPE  so_obj_des .
    internal table for gettting personal numbers of quality engineers
      DATA: BEGIN OF t_ztptwf2 OCCURS 0,
            pernr LIKE ztptwf2-pernr,        "personal number
            END OF t_ztptwf2.
    internal table for gettting userids of quality engineers
      DATA: BEGIN OF t_pa0105 OCCURS 0,
            usrid LIKE pa0105-usrid,       " user id of the quality engineer
            END OF t_pa0105.
    move file path to w_file_path
      w_file_path1 = v_file_path.
    *assign subject of the email
      w_subject = text-006.                  "Travaler Document to Approve
    refreshing the internal tables
      REFRESH : t_objbin, t_packing_list, t_split.
      CLEAR   : t_objbin, t_packing_list, t_split.
      CLEAR   : t_xi_pdf, t_xi_temp.
      REFRESH : t_xi_pdf, t_xi_temp.
      CLEAR: w_temp, w_offset, t_xi_temp.
    move attachment data to t_xi_pdf[].
      t_xi_pdf[] = pdf[].
    Reformat the line to 255 characters wide
      DESCRIBE TABLE t_xi_pdf   LINES  w_lines.
      DESCRIBE FIELD t_xi_pdf   LENGTH w_lineslen.
      DESCRIBE FIELD t_xi_temp  LENGTH w_mimelen.
      LOOP AT t_xi_pdf.
        w_tabix = sy-tabix.
        MOVE t_xi_pdf TO w_temp+w_offset.
        IF w_tabix = w_lines.
          w_lineslen = strlen( t_xi_pdf ).
        ENDIF.
        w_offset = w_offset + w_lineslen.
        IF w_offset GE w_mimelen.
          CLEAR t_xi_temp.
          t_xi_temp = w_temp(w_mimelen).
          APPEND t_xi_temp.
          SHIFT w_temp BY w_mimelen PLACES.
          w_offset = w_offset - w_mimelen.
        ENDIF.
        IF w_tabix = w_lines.
          IF w_offset GT 0.
            CLEAR t_xi_temp.
            t_xi_temp = w_temp(w_offset).
            APPEND t_xi_temp.
          ENDIF.
        ENDIF.
      ENDLOOP.
    *move data from t_xi_temp to t_xi_mime
      LOOP AT t_xi_temp.
        t_xi_mime(255) = t_xi_temp-line.
        APPEND t_xi_mime.
        CLEAR  t_xi_mime.
      ENDLOOP.
    *move data from t_xi_mime[] to t_html[]
      t_html[] = t_xi_mime[].
    *move data from t_html[] to t_objbin.
      LOOP AT t_html.
        t_objbin-line = t_html-line.
        APPEND t_objbin.
        CLEAR t_objbin.
      ENDLOOP.
    *fill the body of email
      t_message = text-005.                        "Mail with PDF attachment
      APPEND t_message.
      CLEAR t_message.
      t_message = text-004.    "Please double click the attachment to verify
      APPEND t_message.
      CLEAR t_message.
      concatenate 'COPY FOR VIEWING ONLY-NOT TO BE'
              'USED/PRINTED FOR PRODUCTION' into t_message separated by
    space.
      APPEND t_message.
      CLEAR t_message.
      IF NOT doknr IS INITIAL.
        CONCATENATE text-001                     "The Document
                    doknr
                    text-002                     "and Version
                    dokvr
                    text-003 INTO                "is changed
                t_message SEPARATED BY space.
        APPEND t_message.
        CLEAR t_message.
      ENDIF.
      DESCRIBE TABLE t_message LINES w_tab_lines.
      READ     TABLE t_message INDEX w_tab_lines.
      w_gd_doc_data-doc_size = ( w_tab_lines - 1 ) *
                                               255 + STRLEN( t_message ).
      w_gd_doc_data-obj_langu  = sy-langu.
      w_gd_doc_data-obj_name   = 'SENDFILE'.
      w_gd_doc_data-obj_descr  = w_subject.
      w_gd_doc_data-sensitivty = 'O'.
      CLEAR t_packing_list.
      t_packing_list-head_start = 1.
      t_packing_list-head_num   = 0.
      t_packing_list-body_start = 1.
      t_packing_list-doc_type   = 'RAW'.
      t_packing_list-body_num   = w_tab_lines.
      APPEND t_packing_list.
      IF NOT w_file_path1 IS INITIAL.
        w_len = strlen( w_file_path1 ) - 3.
        w_doc_type = w_file_path1+w_len(3) .
        TRANSLATE w_doc_type TO UPPER CASE .
        SPLIT w_file_path1 AT '\' INTO TABLE t_split .
        DESCRIBE TABLE t_split LINES w_index .
        READ TABLE t_split INDEX w_index .
        w_filename = t_split-row .
        w_len = strlen( w_filename ) - 4.
        w_filename = w_filename(w_len) .
        DESCRIBE TABLE t_objbin LINES w_tab_lines.
        t_packing_list-transf_bin = 'X'.
        t_packing_list-head_start = 1.
        t_packing_list-head_num   = 1.
        t_packing_list-body_start = 1.
        t_packing_list-doc_type   = w_doc_type.
        t_packing_list-body_num   = w_tab_lines.
        t_packing_list-doc_size   = w_tab_lines * 255.
        t_packing_list-obj_descr  = w_filename.
        APPEND t_packing_list.
      ENDIF.
    fill the Receivers
      SELECT * FROM ztptwf2 INTO TABLE t_ztptwf2.
      IF NOT t_ztptwf2[] IS INITIAL.
        SELECT usrid FROM pa0105 INTO TABLE t_pa0105 FOR ALL ENTRIES IN
      t_ztptwf2 WHERE pernr = t_ztptwf2-pernr AND subty = '0001' .
        LOOP AT t_pa0105.
          t_receivers-receiver = t_pa0105-usrid.
          t_receivers-rec_type = 'B'.
          APPEND t_receivers .
          CLEAR t_receivers.
        ENDLOOP.
      ENDIF.
      IF  NOT t_receivers[] IS INITIAL.
    Call the FM to post the message to SAPMAIL
        CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
             EXPORTING
                  document_data              = w_gd_doc_data
                  commit_work                = 'X'
             TABLES
                  packing_list               = t_packing_list
                  contents_txt               = t_message
                  contents_bin               = t_objbin
                  receivers                  = t_receivers
             EXCEPTIONS
                  too_many_receivers         = 1
                  document_not_sent          = 2
                  document_type_not_exist    = 3
                  operation_no_authorization = 4
                  parameter_error            = 5
                  x_error                    = 6
                  enqueue_error              = 7
                  OTHERS                     = 8.
      ENDIF.
      FREE: t_objbin,t_message,t_packing_list,t_receivers.
    i hope this code will solve your problem.
    Sankar

  • Creation of Spool File with Triggers

    Hi,
    I have created an OnUpdate trigger using the Essbase Console. I am using a calculation script to change the value of an account that is being used in the trigger. The trigger doesnot craete a spool file. Can anyone help me with it.

    Are you sure that the data value that should change did change?
    Here I am plugging Glenn's presentation twice in like five minutes. Check out this (unrelated) thread -- it explains how to get to his Kaleidoscope presentation.
    How to use a substitution variable in a load rule?
    FWIW, this part of the presentation was really good (it was all good, but I particularly enjoyed this bit).
    Regards,
    Cameron Lackpour

  • Need Spool file 255 characters for background HR Reports into Excel

    We have been looking for a solution for problem this for more than 2 years now.
    Problem:
    1.     Requirement is to run large HR reports – either standard or with Ad Hoc Query in background mode in a company with more than 50,000 employees.
    2.     Nobody wants printed reports these days.  We want to save the forests. Customers prefer to be emailed an Excel file so they can do further data analysis, filtering, pivot tables etc.
    3.     Reports are running OK in foreground for smaller sections of the organisation, where you send the output to Excel from ALV, or save as a local file in spreadsheet format.
    4.     But large reports for entire company are awkward, tie up your PCs resources, and complex reports accessing many tables can timeout before completion.
    5.     So scheduling these reports to run in background would be the ideal solution.
    6.     However when we access the report output from SP02, we find that most reports (say with more than 13 or so fields) have an output wider than 255 characters and the output of the spool file wraps to the next line in Excel.  It is very tricky to then parse the data back into one row for each employee.  And you have a problem if you output is for 50,000 or so employees, because then you file is 100,000 rows and will not load completely into Excel – limit problem of 65,536 characters.
    7.     We simply want a spool file that does not wrap the data to the next line after 255 characters.
    8.     But how to explain this simple requirement to some technical people. It seems a lot of posts on SDN think we always want to print a spool file.  NO – remember the forests!
    Possible Solutions:
    I see a lot of posts here that refer to OSS note 186603, but they don’t mention the target for the output of the spool is to import into an Excel File (i.e. spreadsheet format).  Just search for 186603 or ” Spool request with more than 255 columns”.  There is also a reference to OSS note 313566.  I am not sure if these will work?
    I have also seen the suggestions that you need to define a customer printer format that does not wrap the output after 255 characters (create a new format type in transaction SPAD).
    Can anyone help us!
    John McKee

    Hi,
    Can you please check whether you can use:
    CONSTANTS C_LF TYPE X VALUE '0A'.
    CONSTANTS C_CR TYPE X VALUE '0D'.
    Regards,
    Lakshmi.

  • What data is stored in the CC Background Job Spool File?

    What information is stored in the location referenced in the CC Configuration/Miscellaneous setting of 'Background Job Spool File Location'?  Our test and production versions of this system are configured the same, with both pointing to the same location on their respective servers.  However the test location shows a virsa/bgJobSpool folder in it containing multiple files while our production system shows this location as empty.
    Both versions seem to be working OK.  We are running backgrounds jobs in each (risk analysis, management reviews, rule generation, etc.) and seeing results.
    We updated to the GRC 5.2 a few months ago and are currently on SP9.  This issue came up during a system audit, so we need to come up with an explanation for the differences.
    Thanks.

    I had reviewed that SAP note previously, but it does not seem to help any with our situation.  We are running ad hoc background risk analysis jobs frequently and can always see the results.  Everything seems to work fine from the application side, we just don't see the logs where we thought they should be over on the server.
    From the outside, it looks like maybe it is ignoring the configuration setting and is still using the default location for the log.  Does it need to be on the same drive as the application?  I believe our application and the default location are both on our E drive, but we want to put the location for this and the Alert Log on the D drive.
    Thanks.

  • Time stamp for each DML in spool file

    Hi,
    I need to know how much time is taking for each delete statement in sql file.
    this is my sql file with dml statements.
    set serveroutput on;
    set time on;
    spool C:\PN\PN\temp_spool.log
    delete from tmp_test1;
    commit;
    delete from tmp_test21;
    commit;
    set time off;
    spool off;
    The spool file is creating as below.
    20 rows deleted.
    Commit complete.
    30 rows deleted.
    Commit complete.
    My requirement is to print time for each DML in the spool file. eg
    *17:31:03 SQL>*
    *20 rows deleted.*
    Commit complete.
    *17:31:33 SQL>*
    *30 rows deleted.*
    Commit complete.
    *17:31:53 SQL>*
    If I spool the file with time stamp I can get the timing for each DML.
    Appreciate your help.
    Thanks,

    I need to know how much time is taking for each delete statement in sql file.
    If I spool the file with time stamp I can get the timing for each DML. subtract the consecutive timestamps in the spool file.

  • Extra characters at end of line in spool file

    I am trying to generate csv files from SQL Developer using queries written to spool files.  I have embedded the queries and associated set commands in script files and call them, as advised elsewhere.  This gives csv files that look fine, with headings and data comma separated and enclosed with double quotes.  The problem is that the files seem to contain a lot of extra characters at the end of each line.  They seem to be spaces, but not sure.  This is causing problems for the person trying to load the data.
    I'm using version SQL Developer 3.1.07.42, Java 1.6.0_11.
    Any ideas on how to avoid the extra spaces appearing?  Thanks for any help.
    Ben.

    Jeff,
    The SQL in the script file is below.  To be honest, I have reduced it down to a simple select from dual and it still puts extra spaces at the end of the single line.
    col ord noprint
    spool test.csv
    SELECT  ' ' ord,
      'ZONE_ORDER_NUMBER'||','||
      'ZONE_NAME'||','||
      'ZONE_TYPE'||','||
      'DESCRIPTION'||','||
      'START_DATE'||','||
      'END_DATE'
    FROM dual
    UNION ALL
    SELECT zone_name ord,
      '"'||zone_order_number||'"'||','||
      '"'||zone_name||'"'||','||
      '"'||zone_type||'"'||','||
      '"'||description||'"'||','||
      '"'||TO_CHAR(start_date,'DD-MON-YY')||'"'||','||
      '"'||TO_CHAR(end_date,'DD-MON-YY')||'"'
    FROM zones
    ORDER BY ord;
    spool off

  • Multiple customer statement in one spool file

    Hi Experts,
    I am using f.27 to create a monthly customer statement. I would like to process all the customer in one time, which is able to create an spool request, but my requirement is to generate different pdf files from one spool file.
    Please help me
    Regards,
    Shoeb Kanpurwala

    Hello Friends,
    Looking for the same requirement, any update regarding to generate different spool for different vendors.. in F.27.
    As i need to send mail for different vendors separately.
    Regards
    vijay

  • Not getting correct output for smatform in spool file

    Hi All,
    I am using smartform to print some letter. In the smartform under main window I have put some layouts. For each layout I am displaying some particular fields in spool file. In the line editor I have given some conitions (if -elseif-else) to display different fields.
    <b>My code in line editor is like:</b>
    /: if <condition1>
    &var1&
    /: elseif <condition2>
    &var2&
    /: else
    &var3&
    So it should display diffent output according to the conditions. But when I am trying to execute form, its showing var1, var2 & var3 all in spool file.
    Does it  means there is no effect of if conition??
    Could u please help me in solving this issue.
    Thanks in advance.
    Regards,
    Vijay

    Why don't u try at Program lines instead of editor.

Maybe you are looking for