String or binary data would be truncated.

Anyone know why I would get this error when trying to place binary data into a sql server 2000 db? The file's length is 5512, and the length of the field I'm putting it in is 8000.
Thanks

That returns the length in bytes. Is the database field defined in bytes or bits?

Similar Messages

  • Sporadically getting error "string or binary data would be truncated" in SQL server 2008 while inserting in a Table Type object

    I am facing a strange SQL exception:-
    The code flow is like this:
    .Net 4.0 --> Entity Framework --> SQL 2008 ( StoredProc --> Function {Exception})
    In the SQL Table-Valued Function, I am selecting a column (nvarchar(50)) from an existing table and (after some filtration using inner joins and where clauses) inserting the values in a Table Type Object having a column (nvarchar(50))
    This flow was working fine in SQL 2008 but now all of sudden the Insert into @TableType is throwing  "string or binary data would be truncated"  exception. 
    Insert Into @ObjTableType
    Select * From dbo.Table
    The max length of data in the source column is 24 but even then the insert statement into nvarchar temp column is failing.
    Moreover, the same issue started coming up few weeks back and I was unable to find the root cause, but back then it started working properly after few hours
    (issue reported at 10 AM EST and was automatically resolved post 8 PM EST). No refresh activity was performed on the database.
    This time however the issue is still coming up (even after 2 days) but is not coming up in every scenario. The data set, for which the error is thrown, is valid and every value in the function is fetched from existing tables. 
    Due to its sporadic nature, I am unable to recreate it now :( , but still unable to determine why it started coming up or how can i prevent such things to happen again.
    It is difficult to even explain the weirdness of this bug but any help or guidance in finding the root cause will be very helpful.
    I also Tried by using nvarchar(max) in the table type object but it didn't work.
    Here is a code similar to the function which I am using:
    BEGIN
    TRAN
    DECLARE @PID
    int = 483
    DECLARE @retExcludables
    TABLE
        PID
    int NOT
    NULL,
        ENumber
    nvarchar(50)
    NOT NULL,
        CNumber
    nvarchar(50)
    NOT NULL,
        AId
    uniqueidentifier NOT
    NULL
    declare @PSCount int;
    select @PSCount =
    count('x')
    from tblProjSur ps
    where ps.PID
    = @PID;
    if (@PSCount = 0)
    begin
    return;
    end;
    declare @ExcludableTempValue table (
            PID
    int,
            ENumber
    nvarchar(max),
            CNumber
    nvarchar(max),
            AId
    uniqueidentifier,
            SIds
    int,
            SCSymb
    nvarchar(10),
            SurCSymb
    nvarchar(10)
    with SurCSymbs as (
    select ps.PID,
                   ps.SIds,              
                   csl.CSymb
    from tblProjSur ps
                right
    outer join tblProjSurCSymb pscs
    on pscs.tblProjSurId
    = ps.tblProjSurId
    inner join CSymbLookup csl
    on csl.CSymbId
    = pscs.CSymbId 
    where ps.PID
    = @PID
        AssignedValues
    as (
    select psr.PID,
                   psr.ENumber,
                   psr.CNumber,
                   psmd.MetaDataValue
    as ClaimSymbol,
                   psau.UserId
    as AId,
                   psus.SIds
    from PSRow psr
    inner join PSMetadata psmd
    on psmd.PSRowId
    = psr.SampleRowId
    inner join MetaDataLookup mdl
    on mdl.MetaDataId
    = psmd.MetaDataId
    inner join PSAUser psau
    on psau.PSRowId
    = psr.SampleRowId
                inner
    join PSUserSur psus
    on psus.SampleAssignedUserId
    = psau.ProjectSampleUserId
    where psr.PID
    = @PID
    and mdl.MetaDataCommonName
    = 'CorrectValue'
    and psus.SIds
    in (select
    distinct SIds from SurCSymbs)         
        FullDetails
    as (
    select asurv.PID,
    Convert(NVarchar(50),asurv.ENumber)
    as ENumber,
    Convert(NVarchar(50),asurv.CNumber)
    as CNumber,
                   asurv.AId,
                   asurv.SIds,
                   asurv.CSymb
    as SCSymb,
                   scs.CSymb
    as SurCSymb
    from AssignedValues asurv
    left outer
    join SurCSymbs scs
    on    scs.PID
    = asurv.PID
    and scs.SIds
    = asurv.SIds
    and scs.CSymb
    = asurv.CSymb
    --Error is thrown at this statement
    insert into @ExcludableTempValue
    select *
    from FullDetails;
    with SurHavingSym as (   
    select distinct est.PID,
                            est.ENumber,
                            est.CNumber,
                            est.AId
    from @ExcludableTempValue est
    where est.SurCSymb
    is not
    null
    delete @ExcludableTempValue
    from @ExcludableTempValue est
    inner join SurHavingSym shs
    on    shs.PID
    = est.PID
    and shs.ENumber
    = est.ENumber
    and shs.CNumber
    = est.CNumber
    and shs.AId
    = est.AId;
    insert @retExcludables(PID, ENumber, CNumber, AId)
    select distinct est.PID,
    Convert(nvarchar(50),est.ENumber)
    ENumber,
    Convert(nvarchar(50),est.CNumber)
    CNumber,
                            est.AId      
    from @ExcludableTempValue est 
    RETURN
    ROLLBACK
    TRAN
    I have tried by converting the columns and also validated the input data set for any white spaces or special characters.
    For the same input data, it was working fine till yesterday but suddenly it started throwing the exception.

    Remember, the CTE isn't executing the SQL exactly in the order you read it as a human (don't get too picky about that statement, it's at least partly true enough to say it's partly true), nor are the line numbers or error messages easy to read: a mismatch
    in any of the joins along the way leading up to your insert could be the cause too.  I would suggest posting the table definition/DDL for:
    - PSMetadata, in particular PSRowID, but just post it all
    - tblProjectSur, in particularcolumns CSymbID and TblProjSurSurID
    - cSymbLookup, in particular column CSymbID
    - PSRow, in particular columns SampleRowID, PID,
    - PSAuser and PSUserSur, in particualr all the USERID and RowID columns
    - SurCSymbs, in particular colum SIDs
    Also, a diagnostic query along these lines, repeat for each of your tables, each of the columns used in joins leading up to your insert:
    Select count(asurv.sid) as count all
    , count(case when asurv.sid between 0 and 9999999999 then 1 else null end) as ctIsaNumber
    from SurvCsymb
    The sporadic nature would imply that the optimizer usually chooses one path to the data, but sometimes others, and the fact that it occurs during the insert could be irrelevant, any of the preceding joins could be the cause, not the data targeted to be inserted.

  • Synch Error: String or binary data would be truncated.

    I kicked off an inital synch for WebTools 2007 (may also be an issue in 596) and I had 1 synch error for SBOPartner:
    String or binary data would be truncated.
    The statement has been terminated.
       at netpoint.api.data.DataFunctions.Execute(String SQL, IDataParameter[] parameters, String connectionstring)
       at netpoint.api.NPBase.MarkSynched(String SynchID)
       at NetPoint.SynchSBO.SBOObjects.SBOPartner.SBOToNetPoint(SBOQueueObject qData)
       at NetPoint.SynchSBO.SynchObjectBase.Synch()
    I traced the sql log and found the problem was related to addresses. The synchid only allows 50 characters but my synchid was 51 characters (COMINF, Communication Infrastructure Corporation, S). Anyway, to fix I modified the table to allow 100 characters and reran the synch. I know an upgrade will set it back to 50 but at least it's working now.
    I tried to post this to support as a bug but I couldn't figure out how (as usual) or the authorization stuff changed so I figured I would post it here so hopefully the devs will see this and update the code.
    Steve

    Thanks Shawn ... My version of Netpoint is 2007.0.620.0 and the synch manager is 2007.0.620.35247. I'm not sure what patch level this means I am on though.
    Steve

  • String or binary data would be truncated - different service packs on publisher vs distributor

    We have transactional replication where the publisher is 10.0.4067 and the distributor is 10.0.4000.  The distribution agent will periodically will fail with the following error: String
    or binary data would be truncated
    SQLSTATE 22001] (Error 8152). The tables on the publisher and subscriber are all the same data type. Could the version difference be causing this issue?  Do we need
    to upgrade the distributor sql server (different server than the publication server)?

    Hello,
    Just as others post above, the difference service pack version between publisher and distributor should not cause this issue.The replication workfolw between publisher and distributor is through the Log Reader Agent which
    runs at the Distributor, it reads the publication transaction log in publisher and copies those transactions in batches to the distribution database at the Distributor.
    You can refer to the following thread which about the similar issue casused by a long stored procedure:
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/5bbf2c8c-a5c0-4a22-b30b-82b6ce4f1fea/an-error-prevents-replication-from-synchronizing-string-or-binary-data-would-be-truncated?forum=sqlreplication.
    Regards,
    Fanny Liu
    If you have any feedback on our support, please click here.
    Fanny Liu
    TechNet Community Support

  • "String or binary data would be truncated" and field specifications

    Hi all,
    i have "String or binary data would be truncated" error when i try to execute an insert statment.
    can i find witch field is affected by this error? (for return it to the user)
    thank's all

    As far as I am aware, there's no way to determine which column's length has been exceeded.
    You should add code into your stored procedure to check the lengths of variables before inserting their values into your tables, raising an error if necessary - see the example below.
    Again I stress that it would be better to modify the client application's code to either warn the user or to limit the number of characters they can enter into a field.
    Chris
    Code Snippet
    --This batch will fail with the SQL Server error message
    DECLARE @MyTable TABLE (MyID INT IDENTITY(1, 1), MyValue VARCHAR(10))
    DECLARE @MyParameter VARCHAR(100)
    --Create a string of 52 chars in length
    SET @MyParameter = REPLICATE('Z', 52)
    INSERT INTO @MyTable(MyValue)
    VALUES (@MyParameter)
    GO
    --This batch will fail with a custom error message
    DECLARE @MyTable TABLE (MyID INT IDENTITY(1, 1), MyValue VARCHAR(10))
    DECLARE @MyParameter VARCHAR(100)
    --Create a string of 52 chars in length
    SET @MyParameter = REPLICATE('Z', 52)
    IF LEN(@MyParameter) > 10
    BEGIN
         RAISERROR('You attempted to insert too many characters into MyTable.MyValue.', 16, 1)
    RETURN
    END
    ELSE
    BEGIN
         INSERT INTO @MyTable(MyValue)
         VALUES (@MyParameter)
    END
    GO

  • String or binary Data would be truncated. Error detected by database DLL

    Having problems generating two reports in Crystal Reports v8.5. I can run it on my machine and one on one of my Terminal Server(TermA). However when I tried to generate the same two reports on my second terminal server(TermB), it crashed and I get the following error messages: ODBC error: String or binary data would be truncated and Error detected by database DLL We have one set user ID and password to generate all of our Crystal Reports.
    Steps taken:
    Reinstall Crystal on TermB server and did a fresh installation of Crystal 8.5 on another workstation.  Ran the reports and the result were the same (unable to generate the report) same errors messages.
    Please HELP...
    Thanks.

    Terminal Server was not supported in CR 8.5

  • When i tried to insert data in a database the following error is displaying, error : String or binary data would be truncated

    Hi,
         can any anyone give me a solution for this.

    It is pretty old /famous error
    http://dimantdatabasesolutions.blogspot.co.il/2008/08/string-or-binary-data-would-be.html
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Getting the following error on one link on a specific website, Microsoft OLE DB Provider for ODBC Drivers error '80040e57' [Microsoft][ODBC SQL Server Driver][SQL Server]String or binary data would be truncated. /include/config.inc, line 131

    The link is to the forum page within the members login area. I have no trouble with anything else on this site and others do not have problems accessing the forum. They suggest it is an internet issue

    OK, well you usually need to wrap reserved words in double quotes. But I see that you are already using another reserved work "user" and wrapping that in square brackets so you could try that.
    MM_fldUserAuthorization = "[group]"
    If the person that built the data model is still there, let them know they've been using very common reserved words. Any word that is part of the SQL language itself should never be used.

  • - String or binary data would be truncated. ERROR

    was wondering if anyone is getting this error.  i created a new function and for 1 of the values i get this error.  i'm not sure if this is related to rounding issues but can anyone shed some light

    Hi Elmer,
    I would request you to first change the name of the variable.
    *function ACTBUD1(%MYACC%)
    (+(Account.%MYACC%,Scenario.Actual) - (Account.%MYACC%,Scenario.Budget))
    *endfunction

  • Extracting strings from binary data

    Hello,
    I am trying to extract string from a binary file.
    At the unix command line (sunos) I can just type;
    strings <filename>
    This is a nice way to get a list of the contents of a directory.
    Is there a way in pl/sql to extract strings from binary data ? An equiv to strings on unix/linux ?
    Thanks in advance.
    Ben

    Hi,
    If you do want to list the contents of a directory, there are other ways to do it. Here's a base implementation of a utility I wrote:
    create or replace and resolve java source named "Util" as
    import java.io.*;
    import java.sql.*;
    import oracle.sql.*;
    import oracle.jdbc.driver.*;
    public class Util {
        public static void listFiles(String directory, oracle.sql.ARRAY[] names)
            throws IOException, SQLException {
            File f = new File(directory);
            if(f==null)
                throw new IOException("Directory: "+directory+" does not exist.");
            String[] files = f.list(
                new FilenameFilter() {
                    public boolean accept(File dir, String name) {
                        // List all files
                        return true;
            Connection conn = new OracleDriver().defaultConnection();
            ArrayDescriptor descriptor = ArrayDescriptor.createDescriptor("VC_TAB_TYPE", conn);
            names[0] = new ARRAY(descriptor, conn, files);
            return;
    create or replace type vc_tab_type is table of varchar2(255);
    create or replace package util authid current_user as
        function list_files(p_directory in varchar2)
            return vc_tab_type;
    end;
    create or replace package body util as
        procedure list_files (
            p_directory in varchar2
            , p_filenames out nocopy vc_tab_type
        is
        language java
        name 'Util.listFiles(java.lang.String, oracle.sql.ARRAY[])';
        function list_files(p_directory in varchar2) return vc_tab_type
        is
            l_filenames vc_tab_type := vc_tab_type();
        begin
            list_files(p_directory, l_filenames);
            return l_filenames;
        end;
    end;
    /You can then query the filesystem as follows:
      1  select column_value as filename
      2  from table(util.list_files('c:\windows'))
      3  where column_value like '%.log'
      4* and rownum <= 10
    SQL> /
    FILENAME
    0.log
    AdfsOcm.log
    aspnetocm.log
    bkupinst.log
    certocm.log
    chipset.log
    cmsetacl.log
    comsetup.log
    DtcInstall.log
    FaxSetup.log
    10 rows selected.cheers,
    Anthony

  • How to set a string input to accept only 1 and 0 (binary data)

    Hi
    I want to write a program that is supposed to take only binary data from the user. So I put a string control onto the front panel, wanting the user to be able to only type 1 or 0 in it. Is there a way to do that?
    Thanks

    Jean-Pierre Drolet wrote:
    Another slight flaw is that the string accepts Enter for a new line. It is easily fixed by setting it to "Limit to single line".
    True, it allows any non-ASCII through. Another solution would be to use some logical combination of VKey and Char, but it could get complicated. One of the simpler ways is the use of scancode and shift, as in the attached modification. Now ENTER, etc. is also discarded.
    I also agree that none of this seems appropriate to enter 4000 "0/1" characters on a fromt panel.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    BinaryStringControl_III.vi ‏24 KB

  • Best way to put binary-data into string?

    Hi there!
    What I want to do is to transfer binary data via HTTP/GET so what I have to do is to transfer binary data into a string.
    Currently I do this the follwing way:
          byte[] rawSecData = new byte[4]; //any binary datas
          ByteArrayOutputStream secBOS = new ByteArrayOutputStream(4);
          DataOutputStream secDOS = new DataOutputStream(secBOS);
          for(int i=0; i < rawSecData.length; i++)
            secDOS.writeByte(rawSecData);
    secDOS.flush();
    String secData = secBOS.toString();
    System.err.println("Lenght of resulting String: "+secData.length());
    I know that this way already worked fine, however I now set up my system up again with another linux-distro and now strange things happen.
    e.g. the secData string differs in lenght from run-to-run between 2 and 4 and I don know at all why?
    Transferring the binary-stuff into string-stuff (e.g. short-binary 255 255, String: 65536) is not possible for me because of various reasons.
    The funny thing is that I remeber that this already worked some time ago and I can figure out why it now doesnt...
    Please help!

    First of all thanks a lot for your help!
    Yes, I already think its an encoding problem, but how can I specify the encoding in my application in a portable way. I dont have an idea what to do.
    My applikation should run as applet on many different 1.1+ VMS (msjvm, netscape-1.1.5, ...).
    Thanks again, lg Clemens

  • Convert Binary Data to string in MsSQL

    Hello,
    I am running a query for MSSQL database to get some file content which is stored in Binary data format in the database.
    I want to copy that file which is in the binary data format to a file in the text format.
    How can I do this?
    Regards,
    Sravanthi

    This is the expected result in the file that stores the data.
    ResultElement     
    WshOutputTest
    Errors/Failures     
    1 / -
    Incident     
    Error: some unexpected result     
    function main()     
    some additional info; eg. stacktrace
    Incident     
    Warning: some warning message     
    function main()
    some additional info; eg. stacktrace
    But I am getting the following stored in my file:::
    PK   FSH;
    output.xmlíT»NÃ@œ‰8¥‚
    *Æ)xH)      ‚R[ñÅ9AìȾðøy`nϖs1nBY>_vvfŸÊÏw„>±ÄÞ¡Q¢‚AWà§8ãWÉ1£=%š#ôÜá„^ü5BŒC ½+¬©iqËSSßñ-u&‚YŒù:»Ó™Ò²À#+9¯A©øDÔ*ù|¯y®E1fôìåN‘Ëëì»ü~¼ÕK{ ·0ßK֕2ÞbÞ*
    *©\‰–fŸW<gRyJk¹Ñ'—Ã6?T¦ÍOÈÐÿ‹x[³cwñCÌRÛ0^ˆy¼éù}–.y»|ýF(ÚéЎ%f—ÓÕu]›“¿Ù„õ§’§WNdÿLíy)û–q÷”¨'Ìá•ßRnZ"·ªa•Ãž:ÎßóûÏl?‚ÍQbm=w™k¸‹ûÙî>[‡ôÿyŸ_PKÙõ¡¬N    PK    FSH;Ùõ¡¬N  * 
    *output.xmlPK 8 †*
    I tried getting the Binary Stream with UTF-8 encoding style and no encoding style too but it didnt work.
    Thanks,
    Sravanthi.

  • I want to transform binary data in string

    Hello
    I want to convert a binary array of 10 Ai channel into a n array of double in order to be converted in spreadsheet files. I have try everything i could have understood with the LV Help and the NI site but anything is working right . So i have put you my code if you can take a look and tell me why when i simulte a sinus wave and save it in binary file i ca nfind the same wave after transformation in spreadsheet file.
    There is to code ( one with one AI channel and another with just an array ) both are save in binary data and after you use the tird VI to converts the files in spreadsheet format .
    Thank you if you could help . I f it possible answer me quickly because i'm in hurry but any answer will be he
    lpful so thank you !
    Attachments:
    Save_&_transform_binary_data.llb ‏99 KB

    Hi Romain.
    In your DAQ vi, you are writing file essai.dat as
    1D array of I16 (1 array per scan)
    When reading it, you try to read data as DBL, and that is not correct.
    There are different choices. The easiest one: use high level vi to read I16 data as 2D array.
    I tested for 5 channels and it works.
    Don´t know your Lv version, so see attached doc.
    Hope it helps
    Alipio
    "Qod natura non dat, Salmantica non praestat"
    Attachments:
    convert.doc ‏47 KB

  • Converting binary data into pdf and placing into application server

    Hi Friends,
    I am able to get PO details in binary format and then using GUI_DOWNLOAD  with file type with 'bin' and file name with 'sample.pdf' extension , got  PO in pdf  format.
    But i need to get with pdf extension in application server without using GUI_DOWNLOAD.
    Is there any functional modules for it?
    With Warm Regards,
    Madhu!!!

    Hi Madhu,
    Check this code.
    *& Report  ZSPOOLTOPDF                                                 *
    *& Converts spool request into PDF document and emails it to           *
    *& recipicant.                                                         *
    *& Execution                                                           *
    *& This program must be run as a background job in-order for the write *
    *& commands to create a Spool request rather than be displayed on      *
    *& screen                                                              *
    REPORT  zspooltopdf.
    PARAMETER: p_email1 LIKE somlreci1-receiver
                                        DEFAULT '[email protected]',
               p_sender LIKE somlreci1-receiver
                                        DEFAULT '[email protected]',
               p_delspl  AS CHECKBOX.
    *DATA DECLARATION
    DATA: gd_recsize TYPE i.
    Spool IDs
    TYPES: BEGIN OF t_tbtcp.
            INCLUDE STRUCTURE tbtcp.
    TYPES: END OF t_tbtcp.
    DATA: it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
          wa_tbtcp TYPE t_tbtcp.
    Job Runtime Parameters
    DATA: gd_eventid LIKE tbtcm-eventid,
          gd_eventparm LIKE tbtcm-eventparm,
          gd_external_program_active LIKE tbtcm-xpgactive,
          gd_jobcount LIKE tbtcm-jobcount,
          gd_jobname LIKE tbtcm-jobname,
          gd_stepcount LIKE tbtcm-stepcount,
          gd_error    TYPE sy-subrc,
          gd_reciever TYPE sy-subrc.
    DATA:  w_recsize TYPE i.
    DATA: gd_subject   LIKE sodocchgi1-obj_descr,
          it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          gd_sender_type     LIKE soextreci1-adr_typ,
          gd_attachment_desc TYPE so_obj_nam,
          gd_attachment_name TYPE so_obj_des.
    Spool to PDF conversions
    DATA: gd_spool_nr LIKE tsp01-rqident,
          gd_destination LIKE rlgrap-filename,
          gd_bytecount LIKE tst01-dsize,
          gd_buffer TYPE string.
    Binary store for PDF
    DATA: BEGIN OF it_pdf_output OCCURS 0.
            INCLUDE STRUCTURE tline.
    DATA: END OF it_pdf_output.
    CONSTANTS: c_dev LIKE  sy-sysid VALUE 'DEV',
               c_no(1)     TYPE c   VALUE ' ',
               c_device(4) TYPE c   VALUE 'LOCL'.
    *START-OF-SELECTION.
    START-OF-SELECTION.
    Write statement to represent report output. Spool request is created
    if write statement is executed in background. This could also be an
    ALV grid which would be converted to PDF without any extra effort
      WRITE 'Hello World'.
      new-page.
      commit work.
      new-page print off.
      IF sy-batch EQ 'X'.
        PERFORM get_job_details.
        PERFORM obtain_spool_id.
    Alternative way could be to submit another program and store spool
    id into memory, will be stored in sy-spono.
    *submit ZSPOOLTOPDF2
           to sap-spool
           spool parameters   %_print
           archive parameters %_print
           without spool dynpro
           and return.
    Get spool id from program called above
    IMPORT w_spool_nr FROM MEMORY ID 'SPOOLTOPDF'.
        PERFORM convert_spool_to_pdf.
        PERFORM process_email.
        if p_delspl EQ 'X'.
          PERFORM delete_spool.
        endif.
        IF sy-sysid = c_dev.
          wait up to 5 seconds.
          SUBMIT rsconn01 WITH mode   = 'INT'
                          WITH output = 'X'
                          AND RETURN.
        ENDIF.
      ELSE.
        SKIP.
        WRITE:/ 'Program must be executed in background in-order for spool',
                'request to be created.'.
      ENDIF.
          FORM obtain_spool_id                                          *
    FORM obtain_spool_id.
      CHECK NOT ( gd_jobname IS INITIAL ).
      CHECK NOT ( gd_jobcount IS INITIAL ).
      SELECT * FROM  tbtcp
                     INTO TABLE it_tbtcp
                     WHERE      jobname     = gd_jobname
                     AND        jobcount    = gd_jobcount
                     AND        stepcount   = gd_stepcount
                     AND        listident   <> '0000000000'
                     ORDER BY   jobname
                                jobcount
                                stepcount.
      READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
      IF sy-subrc = 0.
        message s004(zdd) with gd_spool_nr.
        gd_spool_nr = wa_tbtcp-listident.
        MESSAGE s004(zdd) WITH gd_spool_nr.
      ELSE.
        MESSAGE s005(zdd).
      ENDIF.
    ENDFORM.
          FORM get_job_details                                          *
    FORM get_job_details.
    Get current job details
      CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
           IMPORTING
                eventid                 = gd_eventid
                eventparm               = gd_eventparm
                external_program_active = gd_external_program_active
                jobcount                = gd_jobcount
                jobname                 = gd_jobname
                stepcount               = gd_stepcount
           EXCEPTIONS
                no_runtime_info         = 1
                OTHERS                  = 2.
    ENDFORM.
          FORM convert_spool_to_pdf                                     *
    FORM convert_spool_to_pdf.
      CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
           EXPORTING
                src_spoolid              = gd_spool_nr
                no_dialog                = c_no
                dst_device               = c_device
           IMPORTING
                pdf_bytecount            = gd_bytecount
           TABLES
                pdf                      = it_pdf_output
           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
                OTHERS                   = 12.
      CHECK sy-subrc = 0.
    Transfer the 132-long strings to 255-long strings
      LOOP AT it_pdf_output.
        TRANSLATE it_pdf_output USING ' ~'.
        CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
      ENDLOOP.
      TRANSLATE gd_buffer USING '~ '.
      DO.
        it_mess_att = gd_buffer.
        APPEND it_mess_att.
        SHIFT gd_buffer LEFT BY 255 PLACES.
        IF gd_buffer IS INITIAL.
          EXIT.
        ENDIF.
      ENDDO.
    ENDFORM.
          FORM process_email                                            *
    FORM process_email.
      DESCRIBE TABLE it_mess_att LINES gd_recsize.
      CHECK gd_recsize > 0.
      PERFORM send_email USING p_email1.
    perform send_email using p_email2.
    ENDFORM.
          FORM send_email                                               *
    -->  p_email                                                       *
    FORM send_email USING p_email.
      CHECK NOT ( p_email IS INITIAL ).
      REFRESH it_mess_bod.
    Default subject matter
      gd_subject         = 'Subject'.
      gd_attachment_desc = 'Attachname'.
    CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.
      it_mess_bod        = 'Message Body text, line 1'.
      APPEND it_mess_bod.
      it_mess_bod        = 'Message Body text, line 2...'.
      APPEND it_mess_bod.
    If no sender specified - default blank
      IF p_sender EQ space.
        gd_sender_type  = space.
      ELSE.
        gd_sender_type  = 'INT'.
      ENDIF.
    Send file by email as .xls speadsheet
      PERFORM send_file_as_email_attachment
                                   tables it_mess_bod
                                          it_mess_att
                                    using p_email
                                          'Example .xls documnet attachment'
                                          'PDF'
                                          gd_attachment_name
                                          gd_attachment_desc
                                          p_sender
                                          gd_sender_type
                                 changing gd_error
                                          gd_reciever.
    ENDFORM.
          FORM delete_spool                                             *
    FORM delete_spool.
      DATA: ld_spool_nr TYPE tsp01_sp0r-rqid_char.
      ld_spool_nr = gd_spool_nr.
      CHECK p_delspl <> c_no.
      CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
           EXPORTING
                spoolid = ld_spool_nr.
    ENDFORM.
    *&      Form  SEND_FILE_AS_EMAIL_ATTACHMENT
          Send email
    FORM send_file_as_email_attachment tables it_message
                                              it_attach
                                        using p_email
                                              p_mtitle
                                              p_format
                                              p_filename
                                              p_attdescription
                                              p_sender_address
                                              p_sender_addres_type
                                     changing p_error
                                              p_reciever.
      DATA: ld_error    TYPE sy-subrc,
            ld_reciever TYPE sy-subrc,
            ld_mtitle LIKE sodocchgi1-obj_descr,
            ld_email LIKE  somlreci1-receiver,
            ld_format TYPE  so_obj_tp ,
            ld_attdescription TYPE  so_obj_nam ,
            ld_attfilename TYPE  so_obj_des ,
            ld_sender_address LIKE  soextreci1-receiver,
            ld_sender_address_type LIKE  soextreci1-adr_typ,
            ld_receiver LIKE  sy-subrc.
    data:   t_packing_list like sopcklsti1 occurs 0 with header line,
            t_contents like solisti1 occurs 0 with header line,
            t_receivers like somlreci1 occurs 0 with header line,
            t_attachment like solisti1 occurs 0 with header line,
            t_object_header like solisti1 occurs 0 with header line,
            w_cnt type i,
            w_sent_all(1) type c,
            w_doc_data like sodocchgi1.
      ld_email   = p_email.
      ld_mtitle = p_mtitle.
      ld_format              = p_format.
      ld_attdescription      = p_attdescription.
      ld_attfilename         = p_filename.
      ld_sender_address      = p_sender_address.
      ld_sender_address_type = p_sender_addres_type.
    Fill the document data.
      w_doc_data-doc_size = 1.
    Populate the subject/generic message attributes
      w_doc_data-obj_langu = sy-langu.
      w_doc_data-obj_name  = 'SAPRPT'.
      w_doc_data-obj_descr = ld_mtitle .
      w_doc_data-sensitivty = 'F'.
    Fill the document data and get size of attachment
      CLEAR w_doc_data.
      READ TABLE it_attach INDEX w_cnt.
      w_doc_data-doc_size =
         ( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
      w_doc_data-obj_langu  = sy-langu.
      w_doc_data-obj_name   = 'SAPRPT'.
      w_doc_data-obj_descr  = ld_mtitle.
      w_doc_data-sensitivty = 'F'.
      CLEAR t_attachment.
      REFRESH t_attachment.
      t_attachment[] = it_attach[].
    Describe the body of the message
      CLEAR t_packing_list.
      REFRESH t_packing_list.
      t_packing_list-transf_bin = space.
      t_packing_list-head_start = 1.
      t_packing_list-head_num = 0.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE it_message LINES t_packing_list-body_num.
      t_packing_list-doc_type = 'RAW'.
      APPEND t_packing_list.
    Create attachment notification
      t_packing_list-transf_bin = 'X'.
      t_packing_list-head_start = 1.
      t_packing_list-head_num   = 1.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
      t_packing_list-doc_type   =  ld_format.
      t_packing_list-obj_descr  =  ld_attdescription.
      t_packing_list-obj_name   =  ld_attfilename.
      t_packing_list-doc_size   =  t_packing_list-body_num * 255.
      APPEND t_packing_list.
    Add the recipients email address
      CLEAR t_receivers.
      REFRESH t_receivers.
      t_receivers-receiver = ld_email.
      t_receivers-rec_type = 'U'.
      t_receivers-com_type = 'INT'.
      t_receivers-notif_del = 'X'.
      t_receivers-notif_ndel = 'X'.
      APPEND t_receivers.
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
           EXPORTING
                document_data              = w_doc_data
                put_in_outbox              = 'X'
                sender_address             = ld_sender_address
                sender_address_type        = ld_sender_address_type
                commit_work                = 'X'
           IMPORTING
                sent_to_all                = w_sent_all
           TABLES
                packing_list               = t_packing_list
                contents_bin               = t_attachment
                contents_txt               = it_message
                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.
    Populate zerror return code
      ld_error = sy-subrc.
    Populate zreceiver return code
      LOOP AT t_receivers.
        ld_receiver = t_receivers-retrn_code.
      ENDLOOP.
    ENDFORM.
    Hope this resolves your query.
    <b>Reward all the helpful answers.</b>
    Regards

Maybe you are looking for

  • How can I create an app without using a Mac?

    I want to create my own apps for my iPhone. How can I do that when I have a Windows computer?

  • My iPod nano has a lock on the screen.How can I unlock and use my nano?

    My iPod nano has a lock on the screen. How can I unlock and use my iPod?

  • How To: Use Like '*' with DoQuery

    As anyone who has tried to use a LIKE in their SELECT statement will know, if you are using the DoQuery method of the SAPbobsCOM.Recordset object, LIKE's are not supported.  Here is a workaround that seems to work fairly well for our needs. Code Samp

  • Calling Tcode 'CC04' with material number as default value.

    Hi I want to call transaction 'CC04' with material number as default, i used below code but it is not woking i.e even if i pass material number to the field material , the value is not defaulted in the screen. SET PARAMETER ID 'MAT' FIELD material. C

  • JavaFX 1.0 is out!

    On http://www.javafx.com Also: Danny Cowards blog http://blogs.sun.com/theplanetarium/entry/javafx_release_top_10_things My blog: http://weblogs.java.net/blog/terrencebarr/archive/2008/12/javafx_10_is_he.html Best, -- Terrence