Convert 1 row into multiple rows

Guys - I have a table with 6 columns and it looks like this:
1 2 3 4 5 6
1 XX Y A Z ABC
2 XX P AB CN CAB
Now I want my output to be:
1 2 3 4 5 6
1 XX Y AAA AAB ABC
2 XX Y AAC AAD ABC
3 XX Y AAE AAF ABC......
26 XX Y AAY AAZ ABC
27 XX P ABA ABB CAB
28 XX P ABC ABD CAB
9999 XX P CNY CNZ CAB
I am trying to do this in SQL , but without much luck. I can always do it with pl-sql but I want to keep that as my last option.
Please, let me know if I need to explain this further...
Thanks..

1. Its not that I cannot do with pl/sql, but would like to try this with pure sql than pl / sql, thats what I meant
2. for length( col4 and col5 ), its actually length(col4) =3 and length(col5) = 3, sorry if you miss understood it
3. You are making up your data for all the possible combinations you might have i the future, thats why you are adding 'A' till 'Z' to each and every row...
so for example if a row has
col1 col4 col5 col6
1 ZZX ZZZ john
Now I need to make this row as:
col1 col4 col5 col6
1 ZZX ZZY john
2 ZZZ ZZZ john
So in the future if john is replaced by jack...then all I have to do it update these 2 rows col6 to 'jack' instead of 'john'.
Now the col1 which is the primary key for my new table actually goes into another table as ID field (in my fact as a dimension key)....so I dont have to update both the tables rather I can live with just updating 1 table...
Let me know if you need further explanation...

Similar Messages

  • Converting spool request into multiple pdf formated documents

    Hi Guys,
                 I am designing a report with several pages of output and running it in background.
    Is there a possibility to convert each page into an separate pdf format document ?
    If I use ALV report as output, if its more than page, do I face any issue with pdf conversion.
    Thanks

    Check the Following code, This might be helpful:
    form rstxpdft4 using filename.
    * Read spool job contents (OTF or ABAP list) and convert
    * to PDF, download PDF
      data: download  value 'X'.
      data: lv_filename like rlgrap-filename.
      lv_filename = filename.
      data otf like itcoo occurs 100 with header line.
      data cancel.
      data pdf like tline occurs 100 with header line.
      data doctab like docs occurs 1 with header line.
      data: numbytes type i,
            arc_idx like toa_dara,
            pdfspoolid like tsp01-rqident,
            jobname like tbtcjob-jobname,
            jobcount like tbtcjob-jobcount,
            is_otf.
      data: client like tst01-dclient,
            name like tst01-dname,
            objtype like rststype-type,
            type like rststype-type.
      select single * from tsp01 where rqident = gt_rq-rqident.
      if sy-subrc <> 0.
        write: / 'Spool request does not exist', gt_rq-rqident
                color col_negative.
        exit.
      endif.
      client = tsp01-rqclient.
      name   = tsp01-rqo1name.
      call function 'RSTS_GET_ATTRIBUTES'
           exporting
                authority     = 'SP01'
                client        = client
                name          = name
                part          = 1
           importing
                type          = type
                objtype       = objtype
           exceptions
                fb_error      = 1
                fb_rsts_other = 2
                no_object     = 3
                no_permission = 4.
      if objtype(3) = 'OTF'.
        is_otf = 'X'.
      else.
        is_otf = space.
      endif.
      if is_otf = 'X'.
        call function 'CONVERT_OTFSPOOLJOB_2_PDF'
             exporting
                  src_spoolid              = gt_rq-rqident
                  no_dialog                = ' '
             importing
                  pdf_bytecount            = numbytes
                  pdf_spoolid              = pdfspoolid
                  btc_jobname              = jobname
                  btc_jobcount             = jobcount
             tables
                  pdf                      = pdf  .
      else.
        call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
             exporting
                  src_spoolid              = gt_rq-rqident
                  no_dialog                = ' '
             importing
                  pdf_bytecount            = numbytes
                  pdf_spoolid              = pdfspoolid
                  btc_jobname              = jobname
                  btc_jobcount             = jobcount
             tables
                  pdf                      = pdf
    *************** download PDF file ***********
    v_filename = lv_filename.
    *  call function 'WS_DOWNLOAD'
    *       exporting
    *            bin_filesize            = numbytes
    *            filename                = lv_filename
    *            filetype                = 'BIN'
    *       tables
    *            data_tab                = pdf
    *       exceptions
    *            file_open_error         = 1
    *            file_write_error        = 2
    *            invalid_filesize        = 3
    *            invalid_type            = 4
    *            no_batch                = 5
    *            unknown_error           = 6
    *            invalid_table_width     = 7
    *            gui_refuse_filetransfer = 8
    *            customer_error          = 9
    *            others                  = 10.
    *  if sy-subrc <> 0.
    ** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    **         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    *  else.
    *    gv_count = gv_count + 1.
    *  endif.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        BIN_FILESIZE                    = numbytes
        FILENAME                        = v_filename
        FILETYPE                        = 'BIN'
    *   APPEND                          = ' '
    *   WRITE_FIELD_SEPARATOR           = ' '
    *   HEADER                          = '00'
    *   TRUNC_TRAILING_BLANKS           = ' '
    *   WRITE_LF                        = 'X'
    *   COL_SELECT                      = ' '
    *   COL_SELECT_MASK                 = ' '
    *   DAT_MODE                        = ' '
    *   CONFIRM_OVERWRITE               = ' '
    *   NO_AUTH_CHECK                   = ' '
    *   CODEPAGE                        = ' '
    *   IGNORE_CERR                     = ABAP_TRUE
    *   REPLACEMENT                     = '#'
    *   WRITE_BOM                       = ' '
    *   TRUNC_TRAILING_BLANKS_EOL       = 'X'
    *   WK1_N_FORMAT                    = ' '
    *   WK1_N_SIZE                      = ' '
    *   WK1_T_FORMAT                    = ' '
    *   WK1_T_SIZE                      = ' '
    *   WRITE_LF_AFTER_LAST_LINE        = ABAP_TRUE
    *   SHOW_TRANSFER_STATUS            = ABAP_TRUE
    * IMPORTING
    *   FILELENGTH                      =
      TABLES
        DATA_TAB                        = pdf .
    *   FIELDNAMES                      =
    Thanks.

  • Trying to Batch Convert PPT Decks into Multiple PDFs, but ...

    In Acrobat Pro XI, I'm trying to convert about 20 PowerPoint slide decks into separate corresponding PDFs.  I used the File>Create>Batch Create Multiple Files and added all my files.
    However, Acrobat says it cannot open any of the documents.  Any ideas?  Thanks!

    Are you able to open the PPT files from the Open menu in Acrobat?   Nope.  The error message was a little more explicit - says the files are an unsupported format or may have been damaged.  (They were working files and then Dropbox-ed to me.)
    Have you tried doing a Repair of your Acrobat installation from under the Help menu?  Yes.
    At this point, my deadline is getting the best of me and I've been going into the presentations and saving them one by one.  I'm disappointed, as given the menu options, it seems like Acrobat thinks it has the functionality to do the batch convert. 

  • Transformation Routine to convert single record into multiple

    All,
    I need your help with ABAP Syntax.  My requirement is to take a single record and convert it to multiple records into a DSO with a condition to not create a record if a KF value is 0.
    R/3 Data Record:
    Employee | Date | Char1 | KF1 | Char2 | KF2 | Char3 | KF3 | Char4 | KF4
    Conversion Result into DSO:
    Employee | Date | Char1 | KF1
    Employee | Date | Char2 | KF2
    Employee | Date | Char3 | KF3
    Employee | Date | Char4 | KF4 (This record will not be written if no value is in KF4)
    I have read about the result table in update rules, however within BI 7.0 Transformations I am unfamiliar as to where the RESULT_TABLE function applies.  Has this been replaced by the Expert Routine?
    Could any ABAP expert provide sample code as to how I would perform this conversion in a Transformation Routine?
    Thanks,
    David

    Thanks Alex for your response.
    I did find a solution to this as it turns out to be fairly simple, however I executed the routine as an Expert Routine instead of a Start Routine.  I was advised to do the transformation here.
    The basic concept is defined below:
    Loop at source_package assigning -kf2.
              Append result_fields to result_package.
           Endif.
    -- Kf3u2026  and so on
    Endloop.
    Basically the APPEND statement is used to create the additional records.

  • Convert 2 columns into multiple column table

    Hi,
    I have table with two columns. See below. I need to create a kind of matrix presentation of the table, so that values in row B become column titles, see second table. Amount of data is too big to create this manually.
    TC1
    Req2
    TC2
    Req1
    TC3
    Req0
    TC4
    Req1
    TC5
    Req2
    TC6
    Req3
    TC7
    Req4
    TC8
    Req5
    TC9
    Req6
    TC10
    Req7
    TC11
    Req8
    TC12
    Req9
    TC13
    Req10
    TC14
    Req11
    TC15
    Req12
    TC16
    Req7
    TC17
    Req8
    TC18
    Req3
    TC19
    Req13
    TC20
    Req14
    TC21
    Req15
    TC22
    Req16
    Req1
    Req2
    Req3
    Req4
    Req5
    Req6
    Req7
    Req8
    TC1
    X
    TC2
    X
    TC3
    X
    TC4
    X
    TC5
    TC6
    X
    X
    TC7
    X
    TC8
    TC9
    X
    X
    TC10
    TC11
    X
    TC12
    X
    TC13
    X
    X
    TC14
    X
    X
    TC15
    X
    TC16
    TC17
    X
    TC18
    X
    TC19
    TC20
    X
    X
    x
    TC21
    X
    TC22
    X
    Any suggestions how to proceed are greatly appreciated!
    Question: Would Excel's PivotTable do the trick? No scripting needed?

    Hi and thanks for your reply! I added leading zeros. I tried the formula and the result looks like this from my first sample:
    Req01
    Req02
    Req03
    Req04
    Req05
    Req06
    Req07
    Req08
    Req09
    Req10
    Req11
    Req12
    Req13
    Req14
    Req15
    Req16
    TC1
    x
    TC2
    x
    TC3
    TC4
    TC5
    TC6
    x
    TC7
    x
    TC8
    x
    TC9
    x
    TC10
    x
    TC11
    x
    TC12
    x
    TC13
    x
    TC14
    x
    TC15
    x
    TC16
    TC17
    TC18
    TC19
    x
    TC20
    x
    TC21
    x
    TC22
    x
    So row value remain empty if column value has earlier been met. Eg. TC17. Any ideas?

  • Convert one string into multiple strings

    i have a column 'name' in which records are like 'shailesh singh negi','vipin kumar singh'...my requirement is to split this column into three columns like 'firstname','middlename','lastname' and string should insert respectively like 'shailesh' in 'firstname','singh' into 'middlename',and 'negi' into 'lastname' column. i have used a query for splitting into two column bt not able to do the same wid three columns...
    query for two columns is like this...
    select substr(name,1,instr(name,' ')-1) firstname,
    substr(name,instr(name,' ')+1) lastname
    from table;

    CREATE TABLE nm AS
    SELECT 'shailesh singh negi' NAME
      FROM DUAL
    UNION
    SELECT 'vipin kumar singh' NAME
      FROM DUAL
    SELECT   MAX (first_name) firstname, MAX (mid_name) middlename,
             MAX (last_name) lastname
        FROM (SELECT txt, token, l, CASE
                        WHEN l = 1
                           THEN token
                     END first_name, CASE
                        WHEN l = 2
                           THEN token
                     END mid_name, CASE
                        WHEN l = 3
                           THEN token
                     END last_name
                FROM (SELECT     txt,
                                 SUBSTR (txt,
                                         INSTR (txt, ' ', 1, LEVEL) + 1,
                                           INSTR (txt, ' ', 1, LEVEL + 1)
                                         - INSTR (txt, ' ', 1, LEVEL)
                                         - 1
                                        ) AS token,
                                 LEVEL l
                            FROM (SELECT ' ' || NAME || ' ' txt
                                    FROM nm)
                      CONNECT BY LEVEL <=
                                      LENGTH (txt)
                                    - LENGTH (REPLACE (txt, ' ', ''))
                                    + 1))
    GROUP BY txtRegards,
    Mahesh Kaila

  • Convert one record row into multiple rows

    Hi,
       I have small requirement.I have selected one data base record into an internal table.Now internal table has 1 record i.e 1 row(ex: 10 columns). Now i will convert this single row record into multiple  records i.e 10 rows( 10 columns wil; be converted into 10 rows). How i will convert this. Please give me any idea on this.
    Regards
    Geetha

    Hi Geetha,
    Search SCN using keyword,  " convert Rows into columns" or vice versa,,,
    U will get more answers & solutions,
    Look at Some of the Previous threads....
    Re: How to create a structure of itab as rows as colums and columns rows dy
    Re: Transpose rows and columns
    CONVERT ROWS INTO COLUMNS IN INTERNAL TABLE
    Convert Internal table Rows into columns of another internal table
    how to convert columns of an internal table to rows of another internal tab.
    Convert Columns into Rows (internal tables) - Urgent Help Pleasse..
    converting columns to rows
    Thanks & regards,
    Dileep .C

  • Splitting comma seperated column data into multiple rows

    Hi Gurus,
    Please help me for solving below scenario. I have multiple value in single column with comma seperated values and my requirement is load that data into multiple rows.
    Below is the example:
    Source Data:
    Product         Size                                 Stock
    ABC              X,XL,XXL,M,L,S                 1,2,3,4,5,6
    Target Data:
    Product         Size                                 Stock
    ABC              X                                     1
    ABC              XL                                   2
    ABC              XXL                                 3
    ABC              M                                    4
    ABC              L                                      5
    ABC             S                                        6
    Which transformation we need to use for getting this output?
    Thanks in advance !

    Hello,
    Do you need to do this tranformation through OWB mapping only? And can you please tell what type of source you are using? Is it a flat file or a table?
    Thanks

  • How do I divide a list in one cell into multiple rows?

    I have copied lists of data from a website - some lists pasted as I want them (in individual rows), but others pasted the list in one row.  Is there an easy way to split a list in a single cell into multiple cells so ultimately I can sort all the rows?  I've tried "split the selected cells into rows" in the inspector, but it's not working... seems like it's creating another column instead (?).  Any help would be amazing.

    K,
    I find that Pages has the friendliest Find and Replace dialog, so when I need to swap around the delimiters I go straight to Pages and do the fixes there. Replace whatever is there between columns in the original content with Tab characters and replace whatever is there now for delimiting the rows with the Return character. Since it's sometimes difficult to tell what has been used, just copy it from the content and Paste into the Find field. Choose the Tab or Return character from the Replace drop down menu.
    When you have it all fixed up, then paste into Numbers.
    Jerry

  • How to spool data into multiple Excel sheet if result is more then 65k rows

    Hi all,
    Wann spool data into multiple excel sheet bocz my resultant no of rows are more then 65k.
    Thanks to all in advance.....

    many choices
    1) migrate to a newer version of Excel
    2) split the files after spooling
    for instance with split
    split -l65000 file.txtor with perl, java, vb or what-so-ever
    3) do more than one report by using rownum
    spool f1
    select empno,ename  from (select rownum r,empno,ename from emp order by empno) where r<6 ;
    spool off
    spool f2
    select empno,ename  from (select * from (select rownum r,empno,ename from emp order by empno) where r<11) where r>5 ;
    spool off
    spool f3
    select empno,ename  from (select rownum r,empno,ename from emp order by empno) where r>10 ;
    spool off

  • How to Download data - exceeding 65000 rows into multiple spreadsheet

    Hi all,
    I am having some issues with the download.
    The user is trying to download certain reports generated in the application into an excel sheet. He is not able to download beyond 65000 records. What I need is a way to automatically download the data into multiple spreadsheet if it exceeds 65000 rows (limit for excel 2000).
    Please let me know if there is any web service which does this or any other solution to this problem.
    Regards,
    t

    Hi Arie,
    thank you for your suggestion.
    I am using almost a similar procedure to download the records into excel. But the problem is its only downloading 65000 records because of the limit excel has.
    I am pasting the code which will give you a idea.
    It would be great if you help me modifying the code such that if the records exceeds 65000, remaining data gets downloaded to sheet2.
    for example if there are 70000 records, the first 65000 records gets loaded into sheet1 and remaining 5000 into sheet2.
    begin
    -- Set the MIME type
    owa_util.mime_header( 'application/octet', FALSE );
    -- Set the name of the file
    htp.p('Content-Disposition: attachment; filename="emp.csv"');
    -- Close the HTTP Header
    owa_util.http_header_close;
    -- Loop through all rows in EMP
    for x in (select e.emp_id, e.s_id, e.emp_number
    from test2_csv_download1 e where rid between 1 and 65000 )
    loop
    -- Print out a portion of a row,
    -- separated by commas and ended by a CR
    htp.prn(x.emp_id ||','|| x.s_id ||','||
    x.emp_number || chr(13));
    end loop;
    -- Send an error code so that the
    -- rest of the HTML does not render
    htmldb_application.g_unrecoverable_error := true;
    end;
    thanks
    T

  • I need to divide selected row into multiple rows when i navigate  ADF 11g

    Hi
    I'm using jdeveloper 11.1.1.2.0 with ADF 11g.
    I need to divide selected row into multiple rows when i navigate to other page . Scenario - in first page i'm displaying some records with columns like empno , empstatus , empworkdepts ,curdepts
    Here empworkdepts gives the numeric number like no of departments work shifts 3 or 4 or 5. when i select any particular employee and fire next button to navigate next page.I have to divide the selected employee with same information into multiple times based on the empworkdepts value.
    empno empstatus empworkdepts curdept
    001 eds 2 TS
    002 hr 1 FO
    003 eds 4 TS
    *004 eds 3 TS*
    now i selected employee 004 , when i navigate to next page.
    Empno EmpStatus EmpWorkDepts CurDept
    004 eds 3 TS
    004 eds 3 TS
    004 eds 3 TS
    i did with java code in bean .but not stable .
    any help............
    thanks advance.............
    Edited by: user9010551 on May 5, 2010 10:48 PM
    Edited by: user9010551 on May 10, 2010 11:31 PM

    user9086775 wrote:
    Hi Experts,
    I have a requirment where i need to fetch parts of a single row into multiple rows from a singlt Query, i am sure it is possible using Pivots but just cant figure out an approach. Any help on this is highly appriciapted.
    Requirment:
    This is a sample set record in a table
    Product     Sub Product          Name    Age
    New Car    Nissan                   Tom        49
    New Car    Nissan                   Jack         36
    Old Car      Audi                     Sam         24
    Old Car      Jaguar                  Pint          26
    Old Car      Audi                     Smith       41
    I need to be able to fetch the above data in the below fashion
    Product     Sub Product          Name    Age
    New Car
    Nissan
    Tom        49
    Jack        36
    Old Car     
    Audi            
    Sam        24
    Smith      41
    Jaguar                   Pint         26Please help with ideas as to how can i achive the above without using PLSQL.
    Thanks in advance!You should be doing this in the client on not in the DB. Use the reporting tool that you use to do this.
    For example if you are in SQL Plus you can use the BREAK command.

  • How to convert a row into a column with the row headers displayed as column in javaFx?

    How do in convert a row of data into column of data to display as shown below:
    Column1|Column2|Column3|Column4
    C1          | C2          | C3           |  C4
    C5          | C6          | C7           |  C8
    How to convert the above default behavior to as below
    Column1| C1 | C5
    Column2| C2 | C6
    Column3| C3 | C7
    Column4| C4 | C8

    .

  • How to convert single column into single row

    I need to convert single column into single row having n no.of.values in a column. without using case or decode. I need a query to display as below.
    emp_id
    100
    101
    102
    102
    103
    200
    I need output like 100,101,102,103,104.........200.

    I assume you want to convert 200 rows with one column into one row with 200 columns. If so, this is called pivot. If you know number of rows (max possible number of rows) and you are on 11G you can use PIVOT operator (on lower versions GROUP BY + CASE). Otherwise, if row number isn't known, you can use dynamic SQL or assemble select on clent side. Below is example emp_id = 1,2,..5 (to give you idea) and you are on 11G:
    with emp as (
                 select  level emp_id
                   from  dual
                   connect by level <= 5
    select  *
      from  emp
      pivot(
            max(emp_id) for emp_id in (1 emp_id1,2 emp_id2,3 emp_id3,4 emp_id4,5 emp_id5)
       EMP_ID1    EMP_ID2    EMP_ID3    EMP_ID4    EMP_ID5
             1          2          3          4          5
    SQL>
    SY.

  • Easy Question: How to split concatenated string into multiple rows?

    Hi folks,
    this might be an easy question.
    How can I split a concatenated string into multiple rows using SQL query?
    INPUT:
    select 'AAA,BBB,CC,DDDD' as data from dualDelimiter = ','
    Expected output:
    data
    AAA
    BBB
    CCC
    DDDDI'm looking for something kind of "an opposite for 'sys_connect_by_path'" function.
    Thanks,
    Tomas

    Here is the SUBSTR/INSTR version of the solution:
    SQL> WITH test_data AS
      2  (
      3          SELECT ',' || 'AAA,BBB,CC,DDDD' || ',' AS DATA FROM DUAL
      4  )
      5  SELECT  SUBSTR
      6          (
      7                  DATA
      8          ,       INSTR
      9                  (
    10                          DATA
    11                  ,       ','
    12                  ,       1
    13                  ,       LEVEL
    14                  ) + 1
    15          ,       INSTR
    16                  (
    17                          DATA
    18                  ,       ','
    19                  ,       1
    20                  ,       LEVEL + 1
    21                  ) -
    22                  INSTR
    23                  (
    24                          DATA
    25                  ,       ','
    26                  ,       1
    27                  ,       LEVEL
    28                  ) - 1
    29          )       AS NEW_STRING
    30  FROM    test_data
    31  CONNECT BY LEVEL <= LENGTH(REGEXP_REPLACE(DATA,'[^,]','')) - 1
    32  /
    NEW_STRING
    AAA
    BBB
    CC
    DDDD

  • Split one row into multiple columns

    Hi,
    Data in one CLOB column in a table storing with delimiter, ##~~##. Ex. ##~~##abc##~~##defgh##~~##ijklm##~~##nopqr (data starts with delimiter). Please help me to split the data into multiple rows like below and it should be in the same order.
    abc
    defgh
    ijklm
    nopqr
    I am using Oracle 11g.
    Thanks.

    Thanks Hoek for your response. Before posting my question in the forum, I tried similar query. It is working with one character as delimiter.
    with test as (select 'ABC,DEF,GHI,JKL,MNO' str from dual )
    select regexp_substr (str, '[^,]+', 1, rownum) split
    from test
    connect by level <= length (regexp_replace (str, '[^,]+')) + 1;
    Above query is giving correct result by fetching 5 rows. I have modified the query like below...
    with test as (select 'ABC,,,DEF,,,GHI,,,JKL,,,MNO' str from dual )
    select regexp_substr (str, '[^,,,]+', 1, rownum) split
    from test
    connect by level <= length (regexp_replace (str, '[^,,,]+')) + 1;
    Above query resulting 13 rows and last 8 rows are nulls. Number of null rows are increasing, if I increase number of characters in delimiter. Could you please tell me how to avoid those null rows.
    Thanks.

Maybe you are looking for

  • Snow Leopard and Adobe Photoshop CS4

    Hi! I've recently switched from custom built PCs to a Mac workstation, mainly for professional photography and editing purposes. I use photoshop roughly 12 hours a day (if not more...sigh), so switching to Mac would, in my mind, streamline and enhanc

  • Time Machine backup gets stuck - Please help

    Hi all, I'm backing up my MBP via ethernet to a Time Capsule. The incremental backups take forever and are driving me nuts. The backups seem to be getting stuck midway. The disk sounds like it's spinning but the progress bar doesn't move. Also, it se

  • Mac OS X cannot open pdf files from online sites.

    Mac OS X cannot open pdf files from online sites.

  • Why can I not add certain "files to iPhone because iTunes match enable on this iPhone?"

    I have some files on my computer I tried to transfer to my iPhone 3GS. They are mp3s of talks/lectures. No copyright issues. But iTunes tells me that they cannot be added because I have iTunes match enabled on that phone. Any ideas?

  • Error while importing process

    Dear all: please advice for below errors come after importing all tables and then go throught packages and packages body ( some of them wraped) IMP-00003: ORACLE error 4030 encountered ORA-04030: out of process memory when trying to allocate 511744 b