TSQL Merge - Multiple statements after THEN

I'm using a MERGE statement to merge two tables.
When I have a match in keys, but the data is different I want to inactivate the old/existing record with an update statement where I fill the EndDate column with GetDate() and the Active active with false.... (No problem)
But I also want to insert a new record with the same key, new data, fill startdate with GetDate() and Active with true.
Is that possible?
--something like....
WHEN MATCHED AND NOT (
MySource.Hash = MyTarget.Hash
THEN
-- inactivate old record
UPDATE
SET MyTarget.Active = 0
, MyTarget.DateEnd = GetDate()
-- insert new version of record
INSERT (column1, column2, DateStart, Active)
VALUES (MySource.column1, MySource.column2, GetDate(), 1)
WHEN NOT MATCHED BY TARGET
THEN
-- etc. etc.
 

My old merge statement looks like:
MERGE HistoricalStaging.dbo.AddressType as MyTarget
USING (
SELECT AddressTypeID
, Name
, rowguid
, ModifiedDate
, HASHBYTES('MD5', Name + '|' + CAST(rowguid as varchar(60)) + '|' + CAST(ModifiedDate as varchar(24))) as Hash
FROM Staging.dbo.AddressType
) as MySource
ON MyTarget.AddressTypeID = MySource.AddressTypeID
-- WHEN FOUND IN SOURCE AND DESTINATION THEN UPDATE
-- BUT ONLY WHEN HASH IS DIFFERENT
WHEN MATCHED AND NOT (
MySource.Hash = ISNULL(MyTarget.Hash, '')
THEN
/* Need to change this part */
UPDATE
Set MyTarget.Name = MySource.Name
, MyTarget.rowguid = MySource.rowguid
, MyTarget.ModifiedDate = MySource.ModifiedDate
, MyTarget.Hash = MySource.Hash
, MyTarget.DateEnd = Null
, MyTarget.Active = 1
-- WHEN FOUND IN SOURCE, BUT NOT IN DESTINATION THEN INSERT
WHEN NOT MATCHED BY TARGET
THEN
INSERT (AddressTypeID, Name, rowguid, ModifiedDate, Hash, Active, DateFrom)
VALUES (MySource.AddressTypeID, MySource.Name, MySource.rowguid, MySource.ModifiedDate, MySource.Hash, 1, GetDate())
-- WHEN FOUND IN DESTINATION, BUT NOT IN SOURCE THEN INACTIVATE
-- BUT ONLY WHEN DATEEND IS NOT NULL
WHEN NOT MATCHED BY SOURCE AND (
MyTarget.DateEnd is null
THEN -- INACTIVATE INSTEAD OF DELETE
UPDATE
Set MyTarget.Active = 0
, MyTarget.DateEnd = GetDate()
OUTPUT $action
But in the in this part
WHEN MATCHED AND NOT (
MySource.Hash = ISNULL(MyTarget.Hash, '')
there is now an update statement that replaces all changed values... But I want to 'close' that old record and insert the new version. (So an update and insert at the same time).

Similar Messages

  • Executing multiple statements after another

    Helle guys!
    I was just wondering if it is not possible to execute several statements in a row using the Oracle SQL Developer!? Couldn't find any info on that!
    I have code like the following and about 200 statements:
    INSERT INTO TBL_MATRIX ("Baumart", "9110", "9110.M", "9110.1", "9110.2", "9110.3", "9110.4", "9111", "9130", "9130.M", "9130.1", "9130.2", "9130.3", "9130.4", "9131", "9140", "9150", "9150.15", "9151", "9152", "9160", "9170", "9180", "9190", "91D0", "91D1", "91D1.3", "91D2", "91D3", "91D4", "91E0", "91E0.A", "91E0.S", "91E0.11", "91E0.12", "91E0.13", "91E0.14", "91E0.15", "91E1", "91E2", "91F0", "91T0", "91U0", "9410", "9410.15", "9420")
    VALUES ('Flaumeiche', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG');
    INSERT INTO TBL_MATRIX ("Baumart", "9110", "9110.M", "9110.1", "9110.2", "9110.3", "9110.4", "9111", "9130", "9130.M", "9130.1", "9130.2", "9130.3", "9130.4", "9131", "9140", "9150", "9150.15", "9151", "9152", "9160", "9170", "9180", "9190", "91D0", "91D1", "91D1.3", "91D2", "91D3", "91D4", "91E0", "91E0.A", "91E0.S", "91E0.11", "91E0.12", "91E0.13", "91E0.14", "91E0.15", "91E1", "91E2", "91F0", "91T0", "91U0", "9410", "9410.15", "9420")
    VALUES ('Wacholder', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'hG', 'S');
    /Instead of carrying out each query individually there has to be a way to run each of them automatically. Even SQL Server features that function!
    Any hints you can give me?
    Regards,
    Sebastian

    Hi,
    You should ask this in the [SQL Developer Forum|http://forums.oracle.com/forums/forum.jspa?forumID=260].
    Just a quick thought. I think in SQL Dev, you have two options. 1. Run and 2. Run Script (next to the Run iconic button).
    Copy all the statements in the editor and hit the Run Script iconic button instead of Run iconic button.
    -Arun

  • TS1412 My iPod shuffle periodically skips across multiple songs...playing a song or two and then jumping forward or back multiple songs after playing only moments of a song. Please tell me what I can do to fix this. Thanks

    My iPod shuffle periodically skips across multiple songs...playing a song or two in full and then jumping forward or back multiple songs after playing only moments of a song. Please tell me what I can do to fix this situation. Thank you very much.

    This is in regards to a 4th gen 40gb clickwheel ipod.
    Hi, i've also been having a very similar problem with my ipod as well. I find that regardless of which windows-based pc i use (either my xp laptop @ home, or my win2000 desktop @ work) windows and itunes refuses to recognise my ipod. In windows explorer it will show it as a removable drive, but if i click on it, windows freezes. If I try to disconnect it, I cant because windows keeps reporting that 'the device is being used, try disconnecting later' and so then i shut down my laptop to disconnect it safely.
    Lately, like you, i've also noticed that clicking sound it makes. It happens when i connect my ipod to my computer - like the drive inside it is constantly restarting or something, and i get it when i'm playing / charging it in my dock. I've also noticed that when it's playing whilst charging, it just freezes on a song, then skips a couple of songs.
    I've just discovered the disgnostic tools on my ipod, so i think i'll run a couple of tests (ie HDD scan) and depending on the outcome, i'll go visit the apple store.

  • Why is some text not shown after merging multiple documents

    One of my clients is using Adobe Acrobat XI and they are merging multiple PDF documents (up to 1000 single PDF's!) to create one big PDF document.
    But somehow just some parts of the text are not shown after the merging (it is actually still there because you can copy and paste it in to Word and you will see it again)?
    Any suggestions?

    Hi Wunold van Drunen,
    Since you have identified the problematic pages, have you checked if the issue occurs with the same pdf when merged with a smaller number may be 10 pdfs.
    How are these pdfs created? It might be possible that the said document's pdf structure is incorrect.
    You may want to sanitize the said pdf's before combining and check.
    Regards,
    Rave

  • How to use multiple statements inside the "THEN" block of CASE statement?

    Below is the code:
    SET @strTempString = case @strKeyMode
    WHEN 'AUTO/CYCLE'
    THEN  @strRefID + '|' + @strRetID
    WHEN 'CYCLE'
    THEN  @strRefID + '|' + @strRetID
    WHEN 'COMMERCIAL'
    THEN  @strRefID + '|' + @strRetID
    WHEN 'ISNAP'
    THEN  set @strFName = ltrim(rtrim((Left(dbo.CleanTheStringAdv(@strFName + '  ', 2) + '  ', 2))))
    '' + @strRefID + '|' + @strLName + '|' + @strFName + '|' + @strZIPorPolType
    WHEN 'ASNAP'
    THEN  @strRefID + '|' + @strRetID
    WHEN 'MOAT'
    THEN  @strRefID + '|' + @strRetID
    else '0'
    end 
    The first 3 conditions are understandable. How to use multiple statements in 4th case?
    Here I first want to set the value as:
    set @strFName = ltrim(rtrim((Left(dbo.CleanTheStringAdv(@strFName + '  ', 2) + '  ', 2))))
    and then return the string '' + @strRefID + '|' + @strLName + '|' + @strFName + '|' + @strZIPorPolType to @strTempString. 
    Please help me remove the syntax errors.
    Thanks in advance.

    Try below SQL
    DECLARE @strKeyMode varchar(20) = 'ISNAP'
    DECLARE @SQL VARCHAR(MAX)
    DECLARE @strRefID int=1
    DECLARE @strRetID INT=2
    --FIRST WAY
    IF @strKeyMode ='AUTO/CYCLE'
    SELECT CAST(@strRefID as varchar(10))
    ELSE IF @strKeyMode ='CYCLE'
    SELECT @sql = CAST(@strRefID as varchar(10)) + '|' + CAST(@strRetID as varchar(10))
    ELSE IF @strKeyMode='ISNAP'
    SELECT @sql = CAST(@strRefID as varchar(10)) + '|' + CAST(@strRetID as varchar(10))+'test'+'abc'
    ELSE
    SELECT @SQL='ABC'
    print @sql
    ----SECOND WAY
    SELECT @SQL = CASE @strKeyMode
    WHEN 'AUTO/CYCLE' THEN CAST(@strRefID as varchar(10))
    WHEN 'CYCLE' THEN CAST(@strRefID as varchar(10)) + '|' + CAST(@strRetID as varchar(10))
    WHEN 'ISNAP' THEN CAST(@strRefID as varchar(10)) + '|' + CAST(@strRetID as varchar(10))+'test'+'abc'
    ELSE 'No Record'
    END
    PRINT (@SQL)
    --Prashanth

  • Cannot merge versioned instance after flush, getting OptimisticLockExceptio

    Using EclipseLink 2.0.2 I cannot merge versioned object after flush, getting OptimisticLockException.
    I get this:
    MergeManager.mergeChangesOfCloneIntoWorkingCopy(Object) line: 490     
    MergeManager.mergeChanges(Object, ObjectChangeSet) line: 267     
    RepeatableWriteUnitOfWork(UnitOfWorkImpl).mergeCloneWithReferences(Object, MergeManager) line: 3523     
    RepeatableWriteUnitOfWork.mergeCloneWithReferences(Object, MergeManager) line: 301     
    RepeatableWriteUnitOfWork(UnitOfWorkImpl).mergeCloneWithReferences(Object, int, boolean) line: 3483     
    RepeatableWriteUnitOfWork(UnitOfWorkImpl).mergeCloneWithReferences(Object, int) line: 3457     
    RepeatableWriteUnitOfWork(UnitOfWorkImpl).mergeCloneWithReferences(Object) line: 3438     
    Any known workaround?
    After the flush the versioned object version has increase of one, then the merge code compare with the increased version; however, the original version is still available in ObjectChangeSet.initialWriteLockValue.
    Since flush is an automatic thing depending of states that change often, even for similiar use case, it is expected to be transparent, so should have no effect on merge. In other words, functionality should be unchanged by the trigger of flush or by the use of other technique to get the right data like by using conform in memory.

    My understanding is that the behavior is incompatible with the old functionality of supporting multiple merges, which by definition would always give OptimisticLockException.
    Extract from: http://www.oracle.com/technology/products/ias/toplink/doc/1013/main/b13698/oracle/toplink/sessions/UnitOfWork.html
    setShouldNewObjectsBeCached
    public void setShouldNewObjectsBeCached(boolean shouldNewObjectsBeCached)ADVANCED: By default new objects are not cached until the exist on the database. Occasionally if mergeClone is used on new objects and is required to allow multiple merges on the same new object, then if the new objects are not cached, each mergeClone will be interpretted as a different new object. By setting new objects to be cached mergeClone can be performed multiple times before commit. New objects cannot be cached unless they have a valid assigned primary key before being registered. New object with non-null invalid primary keys such as 0 or '' can cause problems and should not be used with this option.
    I believe the current behavior come from Hibernate that have imposed many of their sematic/anti-patterns to JPA. Since Hibernate team have pushed a lot open session pattern, the current behavior is more likeable for them.
    Ideally both behaviors should be supported, and supporting multiple merges and flush followed by merge should be the default.

  • Data Merge: Multiple records in a Multiple Page Document

    I looked in the InDesign help and under Limitations for merging multiple records it reads:
    You cannot merge multiple records if the data fields appear on a document page in a document with multiple pages, or if data fields appear on multiple master pages.
    I'm using InDesign CS 5.5. I produce a 4-page newsletter printed on both sides as a booklet, folded and stapled and each folded page size is 8.5 x 11 (a four page booklet on 11×17 paper) I want to print our 250-name mailing list on the outer cover but have discovered that it only prints the whole thing then staples it or I need to manually print each issue per name.
    Is there a way around this? If we have to use a third party software, would you let me know what to look for? Any suggestions are appreciated.
    Thanks for your help.
    Amy

    How many names are you trying to put on each newsletter? I suspect only one, and that you've misiniterpreted the Help file. That warning applies to putting multiple records from the data file on the SAME page, like a sheet of labels.
    Just so you know, using Data Merge to do a mailing where you are addressing multiple copies of a static document is potentially VERY inefficent. Data Merge needs to make a page for every page that will be printed, so if you have a 4-page newsletter with 1,000 subscribers you will wind up with a 4,000 page document just to get the name and address on one page, and your printer will be re-processing all those duplicate pages for each newsletter. If you have a commercial grade copier/printer there may be a variable data printing module availble for it that will merge your list at print time so you need only send a 4-page file and print 1000 copies (or you can send the job out to a printer who can handle this kind of work), or if you want to print in-house anddon't have VDP capabilities, I recommend doing two files.
    The first file should be the side of the sheet that doesn't change. Print that first as a single page doing x plus a few extra copies (in case of jams in the printer when doing the second half) where x is the number of newsletters you need.  The second file is the other side of the sheet with the addresses, which you do as the Data Merge, and will end up as x pages. After printing the first side, flip the stack and reload so you are printing on the blank side, then send the merge document, asking for one copy.

  • "Merge into" statement doesn't work

    Hi Reader,
    It seems that in some of our installed machines merge into statement doesn't;t work. We've already experienced this issue on databases installed within virtual machines, but also found on other configurations sporadically.
    Using statement match a single/multiple records (according required logic)
    statement:
    MERGE INTO RNCATEGORIES CV
    USING dual ON
    ( CV.DESIGNCENTERID = in_DESIGNCENTERID
    AND CV.CADPACKAGENAME = in_CADPACKAGENAME
    WHEN MATCHED THEN
    UPDATE SET
    PKGCATEGORYID = in_PKGCATEGORYID,
         UserPackageType = in_UserPackageType
    WHEN NOT MATCHED THEN
    INSERT VALUES ( in_DESIGNCENTERID,
    in_CADPACKAGENAME, in_PKGCATEGORYID,in_UserPackageType );
    Table script:
    CREATE TABLE RNCATEGORIES
    DESIGNCENTERID RAW(16) NOT NULL,
    CADPACKAGENAME NVARCHAR2(64) NOT NULL,
    PKGCATEGORYID RAW(16),
    USERPACKAGETYPE NVARCHAR2(64)
    PK_RNCATEGORIES PRIMARY KEY (DESIGNCENTERID, CADPACKAGENAME)
    Thanks in advance,
    Amir

    After creating the table, your merge statement gives me
    SQL> MERGE INTO RNCATEGORIES CV
      2  USING dual ON
      3  ( CV.DESIGNCENTERID = in_DESIGNCENTERID
      4  AND CV.CADPACKAGENAME = in_CADPACKAGENAME
      5  )
      6  WHEN MATCHED THEN
      7  UPDATE SET
      8  PKGCATEGORYID = in_PKGCATEGORYID,
      9  UserPackageType = in_UserPackageType
    10  WHEN NOT MATCHED THEN
    11  INSERT VALUES ( in_DESIGNCENTERID,
    12  in_CADPACKAGENAME, in_PKGCATEGORYID,in_UserPackageType );
    AND CV.CADPACKAGENAME = in_CADPACKAGENAME
    ERROR at line 4:
    ORA-00904: "IN_CADPACKAGENAME": invalid identifierwhich is about what I expected. The USING clause requires a select statement, not just a table name. It looks to me like this merge statement is in some kind of stored procedure, and that the in_XXX are variables passed to that procedure. If this is correct, then your merge needs to be more like:
    MERGE INTO rncategories cv
    USING (SELECT in_designcenterid dcid, in_cadpackagename cpn,
                  in_pkgcategoryid pcid, in_userpackagetype upt
           FROM dual)
    ON (cv.designcenterid = dcid and
        cv.cadpackagename = cpn)
    WHEN MATCHED THEN
       UPDATE SET
       pkgcategoryid = pcid
       userpackagetype = upt
    WHEN NOT MATCHED THEN
       INSERT VALUES (dcid, cpn, pcid, upt);John

  • Why below MERGE sql statement is throwing error  on 10g?

    Version: Ora 10g R2
    Why below MERGE sql statement is throwing error on 10g?
    SQL> merge into sess_stats
    using
    select a.name, b.value from v$statname a, v$sesstat b where a.statistic#=b.statistic# and b.sid=:sid  and (a.name like '%ga %' or a.name like '%direct temp%')
    ) curr_stats
    on (sess_stats.name=curr_stats.name)
    when matched then
         update set diff=curr_stats.value-sess_stats.value, value=curr_stats.value
    when not matched then
         insert (name, value, diff) values (curr_stats.name, curr_stats.value, null)  2    3    4    5    6    7    8  SQL> SP2-0734: unknown command beginning "on (sess_s..." - rest of line ignored.
    SQL> SP2-0734: unknown command beginning "when match..." - rest of line ignored.
    SQL>   2    3

    First of all, thank you all for your feedback!
    first, I try remove the blank lines at those two places ( before curr_stats and after on) and it works.
    then, again I try to set sqlblanklines on, and it works as well!
    Edited by: PhoenixBai on Nov 10, 2009 10:54 PM

  • Merging multiple columns

    Hello Gurus,
    I use the following function in a SQL to merge multiple distinct values as comma separated values in one coloumn. But whenever data has a 'NULL', it throws out an error - ORA-06502 and ORA-06512. When I replace the 'NULL' values with a space in the actual data, the query works. I want the function to work for 'NULL' values as well. Please suggest. Appreciate your help in advance.
    Function -
    create or replace function transpose
    ( p_key_name in varchar2,
    p_key_val in varchar2,
    p_other_col_name in varchar2,
    p_tname in varchar2,
    p_sep in varchar2 default ','
    return clob
    as
    type rc is ref cursor;
    l_clob clob;
    l_str varchar2(32767);
    l_sep varchar2(1) := null;
    l_val varchar2(32767);
    l_cur rc;
    begin
    dbms_lob.createtemporary(l_clob,false);
    open l_cur for 'select distinct '||p_other_col_name||'
    from '|| p_tname || '
    where ' || p_key_name || ' = :x '
    using p_key_val;
    loop
    fetch l_cur into l_val;
    exit when l_cur%notfound;
    l_str := l_str || l_sep || l_val;
    l_sep := p_sep;
    if length(l_str) > 32000
    then
    dbms_lob.writeappend(l_clob, length(l_str), l_str);
    l_str := null;
    end if;
    end loop;
    dbms_lob.writeappend(l_clob, length(l_str), l_str);
    l_str := null;
    close l_cur;
    return l_clob;
    end;
    SQL -
    select transpose ( 's_num', s_num, 'letter_date','temp') letter_date
    ,t.s_num
    , transpose ('s_num', s_num, 'app','temp') app
    , transpose ('s_num', s_num, 'NITIATED_BY','temp') INITIATED_BY
    , transpose ('s_num', s_num, 'COMMENT','temp') comment
    from temp t
    group by t.s_num;

    A better approach to get an answer would be to
    1) post your Oracle version
    select * from v$version2) post your table description (DDL) with some create data (insert statements)
    3) describe your desired results based on that
    You'll likely get a much better (and quicker) useful answer than you will by posting unformatted code and queries. Speaking of which, please use the tags to preserve formatting on your code.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Why does RoboHelp 8 crash when compiling merged HTML help after deleting a child project in TOC

    Why does RoboHelp 8 crash when compiling merged HTML help after deleting a child project in TOC? I would be grateful for any assistance.
    Here's the situation:
    -- I recently upgraded from RoboHelp X5 to RoboHelp 8. I upgraded my projects to RoboHelp 8 projects.
    -- One large help system I manage is built such that there is one master project and about 25 child projects. Each of these is its own item in the master project TOC.
    -- In RoboHelp X5 I never had any trouble deleting these.
    -- However now in RoboHelp 8, whenever I delete one (by opening TOC pod, right-clicking on item in question, and clicking Delete), and proceed to "Generate Primary Layout" (MS HTML Help), the generation/compilation process proceeds as far as "Generating full-text search data" and then the whole program crashes!
    Am I doing something wrong? Is there a bug in the software? I have installed patches 8.0.1 and 8.0.2.
    Once again, I thank you in advance for any pointers.
    Matthew Keranen
    Jamsa, Finland

    That does help - thanks a lot.
    Wayne Kroger
    State Street Corporation
    SQA-Princeton
    (609) 580-6264
    mail to: [email protected]
    The information contained in this email and any attachments have been classified as limited access and/or privileged State Street information/communication and is intended solely for the use of the named addressee(s). If you are not an intended recipient or a person responsible for delivery to an intended recipient, please notify the author and destroy this email. Any unauthorized copying, disclosure, retention or distribution of the material in this email is strictly forbidden.

  • Is there a way to select MULTIPLE tabs and then copy ALL of the the URLs and titles/or URLs+titles+HTML links? This can be done with the Multiple Tab Handler add on; However, I prefer to use a Firefox feature rather than download an add on. Thanks.

    Currently, I can copy ONE tab's url and nothing else (not its name). Or I can bookmark all tabs that are open. However, I'd like to have the ability to select multiple tabs and then copy ALL of the the URLs AND their titles/or copy ALL of the URLs+titles+HTML links? This can be done with the Multiple Tab Handler add on; when I download the add on, I get a message saying that using the add on will disable Firefox's tab features. I prefer to use Firefox features rather than download and use an add on. Is there a way to do this without an add on?

    Hi LRagsdale517,
    You should definitely be able to upload multiple files by Shift-clicking or Ctrl-clicking the files you want to upload. Just to make sure you don't have an old version of the service cached, please clear the browser cache and then log in to https://cloud.acrobat.com/files. After clicking the File Upload icon in the upper-right corner, you should be able so select multiple files for upload.
    Please let us know how it goes.
    Best,
    Sara

  • How do I merge multiple subscriptions to the same podcast?

    In iTunes I have multiple subscriptions to the same identical podcast (same podcast name and same url) ... some of the subscriptions have duplicated entries and some have unique entries ... (how this happened I have no idea, but that is beside the point) ... my question is how do I merge these multiple subscriptions into a single podcast subscription? I have tried cut & paste in the hope that I could then delete (unsubscribe) to all of the redundant/repeated subscriptions, but that does not work ... in explorer I have found that ALL my podcast files from ALL my podcast subscriptions are found in a single folder .. so all the entries from my multiple subscriptions are there as well ... this smoked my hope that each podcast subscription would have it's own folder or sub-folder ... so I'm stuck ... does anyone know how I can merge multiple subscriptions to the same podcast into a single podcast subscription (without my losing the uniques scattered throuhout the mutiple subscriptions) ... ???

    I would love to be able to do exactly what you are suggesting .. the problem is, if I delete the duplicate subscriptions, I lose the unique files unique to the duplicate subscription I delete ... the problem is that I can't find a way to save/move the uniques (in advance of deleting the duplicate subscription) into a single subscription ... is there a way to do this ??? Does anyone know how to do this ??? Please help !!!

  • How to merge multiple spools in one PDF

    hi all,
    i have a requirement to merge multiple spools into one PDF.
    I have the code to merge 2 spools into one PDF but acc to my requirement this number can be any( say 100). hence i need  help to merge N number of spools in one PDF.
    Regards
    geeta gupta

    Take the data of all spools into a internal table then create a new spool with this data then downlad this data into pdf format.
    By this method you can download any number of spools into a single pdf file. Please see the below code
    Fetch spool number
    Select rqident from tsp01 into table g_t_data
    where...............
    Read sool data and take this data into a internal table
    Loop at g_t_data.
               Call program to read spool as follows
          SUBMIT rspolst2 EXPORTING LIST TO MEMORY AND RETURN
          WITH rqident = g_t_data-rqident
          WITH first = '1'
          Read memory where spool data is stored
          CALL FUNCTION 'LIST_FROM_MEMORY'
               TABLES
                    listobject = mem_tab
          Convert spool data to Ascii
          IF NOT mem_tab[] IS INITIAL.
            CALL FUNCTION 'LIST_TO_ASCI'
                 EXPORTING
                      list_index         = -1
                 TABLES
                      listasci           = g_t_text1(table type c length 10000)
                      listobject         = mem_tab(LIKE TABLE OF abaplist)
            APPEND LINES OF g_t_text1 TO g_t_text.
          ENDIF.
    ENDLOOP.
    Create new spool with internal table data
      NEW-PAGE PRINT ON
      KEEP IN SPOOL  l_keep(variable type c default u2018Xu2019)
      LINE-SIZE      300  
      LIST NAME      l_list (variable(30) TYPE c default 'combined_pdf')
      NO DIALOG.
      LOOP AT g_t_text.
        WRITE: g_t_text-data.
      ENDLOOP.
      NEW-PAGE PRINT OFF.
      COMMIT WORK.
    Fetch this spool number from TSP01
    SELECT rqident rqcretime FROM tsp01 INTO TABLE l_t_pdf(internal table having two fields rqident LIKE tsp01-rqident and rqcretime LIKE tsp01-rqcretime)
      WHERE   rqowner = sy-uname AND
                     rq2name = 'COMBINED_PDF'.
    Download spool data into pdf format
      CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
           EXPORTING
                src_spoolid   = l_t_pdf-rqident
           IMPORTING
                pdf_bytecount = l_size(variable type i)
           TABLES
                pdf           = g_pdf(table like table of tline)
      CALL FUNCTION 'GUI_DOWNLOAD'
           EXPORTING
                bin_filesize = l_size  "size
                filename     = l_data
                filetype     = 'BIN'
           TABLES
                data_tab     = g_pdf.
    Hope this will help you.

  • Merging Multiple Apple IDs

    As we all know, Apple will not merge multiple Apple IDs you may have used over the years. However this is the next best thing:
    But, using Family Share, you can share all of your Apple IDs with your primary account.
    In order to do this you'll need to change the e-mail addresses for all of your old Apple IDs you are no longer using in iTunes.
    Then, set up a user profile on your Mac for each of them. T
    hen invite all of them (up to 6) from your host Apple ID, and accept the invite for each user profile in its own iCloud settings on the Mac.
    Now all of the content for all of your Apple IDs will be available under the one Apple ID you are currently using on all of your devices.
    Took me a while to figure this out but it works like a charm.

    That post is 3 years old. Since nothing has been said about it officially or un-officially since, chances are its not going to happen.
    In reality, it would open a can of worms Apple and the Media rights holders are unlikely to want to open. 
    With that said, we really cannot speculate on Apple's plans. So if they ever decide they want to pursue this, we can only wait until they make an announcement for it.

Maybe you are looking for

  • MacBook/Firewire/ExternalDrive Question

    This is my first post on the forum, and I have kind of a convoluted question. I have a recent MacBook with Final Cut Pro. I usually save my scratch disks to my LaCie external hard drive. Since the MacBook does not have a FireWire port , I use a USB c

  • Oracle BAM license

    Hi, everyone: May name is Pablo, and I'm from Bolivia (Soth America). I've just started working for a Oracle Partner as account manager. We've detected and opportunity for selling Oracle BAM to a pharmaceutical company. But we dopnt really know how t

  • Using PAM for LDAP authentication

    Good Day All, I want to know how I can use PAM to enable users authenticate to my Solaris 9 Box using an existing LDAP server.I would appreciate if the explanation is simpler and more detailed as I am new to this stuff.Also is there any othe means li

  • OData with Filter

    Hi, i am working on displaying record value using UI5. The record should be retrieved via OData from HANA by entering the record ID and the attribute values should be displayed in different textview. My data looks as follows, Person [{ID: '001', Name

  • Apache's Tomcat4.1 on Windows XP

    Hi, I've downloaded Tomcat4.1 Standard and installed as per instructions. Could see the Apache Tomcat4.1 group added to StartMenu's Programs list. I tried running Start Tomcat which successfully opens Start Tomcat Server window and also was able to r