Performance problem: Converting rows to a comma separated column using STUFF() and self join
Hi,
This might be a really dumb one to ask but I am currently working on a table that has sequential data for steps that an invoice goes through in a particular system. Here is how it looks:
ID InvoiceID
InvoiceSteps
Timestamp
283403 0000210121_0002_2013
Post FI Invoice
2013-07-01 19:07:00.0000000
389871 0000210121_0002_2013
Clear Invoice
2013-08-25 14:02:00.0000000
Here is my extremely slow query that converts multiple rows of an invoice into a single one with 'InvoiceSteps' listed according to their timestamps in a sequential manner separated by commas.
SELECT [InvoiceID],
[InvoiceSteps] = STUFF((
SELECT ',' + ma.InvoiceSteps
FROM invoices ma
WHERE m.InvoiceID = ma.InvoiceID
ORDER BY [Timestamp]
FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)'), 1, 1, '')
FROM invoices m
GROUP BY InvoiceID
ORDER BY InvoiceID;
Here is the end result:
InvoiceID InvoiceSteps
0000210121_0002_2013
Post FI Invoice,Clear Invoice
My question: How can I improve the query so that it can process thousands of records as fast as possible (>600K in this case).
Thanks you!
There are many methods to concatenate the rows to columns. Assuming you have necessary indexes to support your query as Rishabh suggested, if you still find issues with performance, then you need to look at various other approaches as well. I have seen at
certain places(huge data), CLR outperformed . Having said, we need to assess each and come to a conclusion for your scenario.
Refer the below link for various approach, (please also look at the comment session as well):
https://www.simple-talk.com/sql/t-sql-programming/concatenating-row-values-in-transact-sql/
Similar Messages
-
Hello, I was wondering if you could convert the IMEI # into the serial number using letters and digits?
No the imei from what I understand is a randomly given number. to get serial number you must have it. you can try supportprofile.apple.com and login.
-
Comma separated column into rows for each value
experts,
I have a two column table. The second column has comma separated string values. How can I put the values separate for each comma separated and make one row for each value?
example,
column1 | StringColumn
s1 | test, joy, happy
s2 | USA, England, India
I want the result to be like below
column1 | StringColumn
s1 | test
s1 | joy
s1 | happy
s2 | USA
s2 | England
s2 | India
thanks in advance
ebroHello ebro,
See the following for a possible solution:
http://gallery.technet.microsoft.com/scriptcenter/Convert-Small-CSV-Value-to-ffc142ff
Olaf Helper
[ Blog] [ Xing] [ MVP] -
I have a requirement to take a String column that allows multiple fields i.e. "101;102,103,104",
and using a SPD 2013 workflow I want to split there values and then insert each Values into different list as separate items.
Eg:
I have a LIST A with the columns CustID, CustName and LIST B with the same Column Name with the below values
LIST A:
Cust ID
CustName
101
ABC, XYZ, CTSS, WIPROS, TCSS
I want to insert the above comma separated values in the below format(different Row)
LIST B:
CustID
CustName
101
ABC
101
XYZ
101
CTSS
101
WIPROS
101
TCSSHi,
Here is a codeplex solution can meet your reference:
Plumsail String Workflow Actions for SharePoint 2013 and SharePoint Online
http://spworkflowactions.codeplex.com/
We can use Split string workflow action to split the CustName value, then insert it to ListB.
More information:
http://www.codeproject.com/Articles/749471/String-processing-workflow-actions-for-SharePoint
Best Regards
Dennis Guo
TechNet Community Support -
Comma Separated columns - Search
Hi fellow,
I need to query my db with a comma separated list but the results are not correct...What is the reason?
My typical db problem_code column has valuas as :
Problem_code
1
2,3
5,6,7,8
5
And the list values I am sending as ("1","3")...etc
SELECT * from table
whereproblem_code in ('2','1')problem_code in ('2','1')
Thank you in advance..If you're sking SQL questions, you'd better off asking on a SQL forum. But here you are, so let's have a look at it.
Firstly, the other thing to always mention when raising an SQL question is to articulate what DB system you're using. Because all of them handle SQL differently, and have their own extensions.
In fact reading this is probably a good idea: http://www.catb.org/~esr/faqs/smart-questions.html
Problem_code
1
2,3
5,6,7,8
5
And the list values I am sending as ("1","3")...etc
SELECT * from table
whereproblem_code in ('2','1')problem_code in ('2','1')
Thank you in advance..
What are you seeing here that's not expected (I presume the double-up of problem_code in ('2','1') is a typo)?
Are you wanting to get any rows from TABLE which have either 1 or 2 in them? That's not what you're asking for in your WHERE statement though, is it?
Really, you should be normalising your data, because whilst you can write contorted logic to do what you need here, it will not perform well and certainly will not scale. So it for be somewhat poor practice to perpetuate the current situation if it's at all possible not to. The best thing to do is to normalise your data and refactor your code. Which will probably mean going to your boss and say "this DB schema is f*cked, and needs reworking. Needs reworking".
Depending on your DB system, you're probably going to need to loop over the list you want to filter on and do a "WHERE problem_code LIKE" on each element of the list. I think Oracle can do the sort of query you want to do - match elements of one list from another list - but I'm not sure.
Adam -
Comma separated values for input and return multiple values
Hello everyone,
I have this simple package. Can someone suggest a way to accept multiple empno as input (comma separated) and to return set of salary values for the set of employee numbers (compatible to work with lower Oracle versions). Thanks much!
CREATE OR REPLACE PACKAGE test_multi IS
FUNCTION GET_sal(P_empno IN emp.empno%TYPE) RETURN NUMBER;
END test_multi;
CREATE OR REPLACE PACKAGE BODY test_multi IS
FUNCTION GET_sal(P_empno IN emp.empno%TYPE) RETURN NUMBER IS
V_sal NUMBER(10,2);
MSG VARCHAR2(200);
BEGIN
SELECT sal
INTO V_sal
FROM emp
WHERE empno = p_empno;
RETURN V_sal;
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('No data found.');
IF (V_sal IS NULL OR V_sal = 0) THEN
V_sal := 0;
END IF;
RETURN V_sal;
WHEN OTHERS THEN
MSG := SUBSTR(SQLERRM, 1, 70);
DBMS_OUTPUT.PUT_LINE(MSG);
END GET_sal;
END test_multi; -- End packageA way to do this in 10g or above...
SQL> ed
Wrote file afiedt.buf
1 with e as (select '7499,7698,7654,7902' as enos from dual)
2 --
3 select empno, sal
4 from emp
5 where empno in (select regexp_substr(enos,'[^,]+',1,rownum)
6 from e
7* connect by rownum <= length(regexp_replace(enos,'[^,]'))+1)
SQL> /
EMPNO SAL
7902 3000
7698 2850
7654 1250
7499 1600
SQL>As for Oracle 8, .... well.... like Oracle, I no longer use unsupported versions, so I'd recommend you upgrade to something that is supported. -
SQL Select with comma separated column value
Hi All
ASP VBScript
I have a DB column named allowed_contracts that stores a
comma separated
list of of values e.g. 3, 5, 19, 44, 52
I need to select records based on a variable called
varContractList that
contains another comma separated list i.e. 5, 44, 52
I only want to select records where the allowed_contracts
column contains
each of the varContractList,
For example only return records that have 5 or 44 or 52 in
thier
allowed_contracts column.
My brain is now in a persistant vegetive state trying to work
this out so
any ideas would be much appreciated.
Regards
BrenHi Jules
Cheers for this.
I was trying to be a bit cute (lazy even) by storing the
project ID's as a
comma delimted string but as we see it doesn't always pay to
be lazy. Serves
me right for destroying brain cells by drinking the Welshpool
beer the other
week whilst visiting mates down that neck of the woods. :-))
Time for another table me thinks.
Rgds
Bren
"Julian Roberts" <[email protected]> wrote in message
news:e7i13f$mup$[email protected]..
> Fatal flaw here Bren. In a relational database, one
shouldn't really store
> foreign keys as a comma delimted string. One should have
a 3 table
> structure. eg
>
> Products:
> ProductID
> Product
>
> Categories:
> CategoryID
> Category
>
> ProductCategories:
> ProductID
> CategoryID
>
> So, from the table ProductCategories, a product can
belong to many
> categories. When doing a front end search to find
products in multiple
> categories, products can be shown thus:
>
> select * from Products where ProductID in (select
ProductID from
> ProductCategories where CategoryID in (5,44))
>
> --
> Jules
>
http://www.charon.co.uk/charoncart
> Charon Cart 3
> Shopping Cart Extension for Dreamweaver MX/MX 2004
>
>
>
>
> -
Problem in creating client side PDF with image using flex and AlivePD
I need a favor I am creating client side PDF with image using flex and AlivePDF for a web based application. Images have been generated on that pdf but it is creating problem for large size images as half of the image disappeared from that pdf.I am taking the image inside a canvas . How do i control my images so that they come fit on that pdf file for any image size that i take.
Thanks in advance
AtishayI am having a similar and more serious problem. It takes a
long time to execute, but even attaching a small image balloons the
pdf to 6MB plus. After a few images it gets up to 20MB. These are
100k jpeg files being attached. The resulting PDF is too large to
email or process effectively. Does anyone know how to reduce
size/processing? -
Performance problem creating rows on viewobject
Hi,
When a user pushes a button in my Oracle ADF 11.1.1.3.0 GUI,
he triggers a method in my backing bean.
This method is called insertNewForecastTable, that takes a (Tree)Map called forecastMap as input. (see below)
( The key of this map is a Timestamp,
the value of this map is an object ForecastEntry.
A ForecastEntry consists out of 10 ForecastParts, and each Forecastpart contains 4 long values. )
private void insertNewForecastTable(Map forecastMap) {
DCBindingContainer bc = (DCBindingContainer)getBindings();
DCIteratorBinding ForecastIter = bc.findIteratorBinding("ForecastViewIterator");
DCDataControl dc = ForecastIter.getDataControl();
ApplicationModule am = (ApplicationModule)dc.getDataProvider();
ViewObject forecastVO = am.findViewObject("ForecastView");
Set keys = forecastMap.keySet();
Iterator keyIter = keys.iterator();
RowSetIterator it = ForecastIter.getRowSetIterator();
while (keyIter.hasNext()) {
Long timestamp = (Long)keyIter.next();
Timestamp ts = new Timestamp(timestamp);
Row r = it.createRow();
r.setAttribute(0, ts);
ForecastEntry forecastentry = (ForecastEntry)forecastMap.get(timestamp);
int j = 1;
for (int i=0;i<10;i++) {
ForecastPart forecastPart = forecastentry.getForecastPart(i);
r.setAttribute(j,forecastPart.getHistory());
j++;
r.setAttribute(j,forecastPart.getForecast());
j++;
r.setAttribute(j,forecastPart.getTrend());
j++;
r.setAttribute(j,forecastPart.getLimit());
j++;
forecastVO.insertRow(r);
am.getTransaction().commit();
Configuration.releaseRootApplicationModule(am,true);
Problem is : for 3360 entries in this table or viewobject, it takes 10 minutes (!!!) to complete this code.
Bottleneck is the for-loop and the forecastVO.insertRow(r);
Both timings are rising from 15 msec in the beginning to 500 msec at the end.
Anyone has some ideas how to improve my performance ?
Am I doing something wrong trying to create and insert 3360 rows in this table ?
Thanks.Ok,
My binding is back ok, so the nullpointer is gone.
But the speed of processing 1000+ inserts into a table is still very poor.
This is my code at the moment :
+private void insertNewForecastTable(Map forecastMap) {+
+DCBindingContainer bc = (DCBindingContainer)getBindings();+
+DCIteratorBinding ForecastIter = bc.findIteratorBinding("ForecastViewIterator");+
+DCDataControl dc = ForecastIter.getDataControl();+
+ApplicationModule am = (ApplicationModule)dc.getDataProvider();+
+ViewObject forecastVO = am.findViewObject("ForecastView");+
+RowSetIterator it = ForecastIter.getRowSetIterator();+
+Set keys = forecastMap.keySet();+
+Iterator keyIter = keys.iterator();+
+List nameList = new ArrayList();+
+nameList.add("Timestamp");+
+for (int i=1 ; i<=10; i ++) {+
+String H = "H"+i;+
+String F = "F"+i;+
+String T = "T"+i;+
+String L = "L"+i;+
+nameList.add(H);+
+nameList.add(F);+
+nameList.add(T);+
+nameList.add(L);+
+}+
+long time_begin = System.currentTimeMillis();+
+int counter = 0;+
+// for each timestamp+
+while (keyIter.hasNext()) {+
+// Get the timestamp.+
+Long timestamp = (Long)keyIter.next();+
+// convert long to timestamp+
+Timestamp ts = new Timestamp(timestamp);+
+// create new row in table+
+Row r = it.createRow();+
+List valueList = new ArrayList();+
+valueList.add(ts);+
+ForecastEntry forecastentry = (ForecastEntry)forecastMap.get(timestamp);+
+for (int i=0;i<10;i++) {+
+ForecastPart forecastPart = forecastentry.getForecastPart(i);+
+valueList.add(forecastPart.getHistory());+
+valueList.add(forecastPart.getForecast());+
+valueList.add(forecastPart.getTrend());+
+valueList.add(forecastPart.getLimit());+
+}+
+r.setAttributeValues(nameList, valueList);+
+forecastVO.insertRow(r);+
+counter++;+
+if (counter % 100 == 0) {+
+am.getTransaction().commit();+
+System.out.println("Committing rows " + (counter-100) + " to " + counter );+
+}+
+}+
+long time_end = System.currentTimeMillis();+
+// commit+
+am.getTransaction().commit();+
+// Configuration.releaseRootApplicationModule(am,true);+
+System.out.println("Total time to insert all rows : " + (time_end-time_begin ));+
+}+It takes up to 500 seconds to insert 3000 rows !
I also changed the update batch value from 100 to 5, but no difference.
I'm now also committing every 100 rows.
And at the end, I get a nullpointer exception at RowDataManager.getRowIndex(RowDataManager.java:191)
All help welcome. -
Comma separated column values into row values
Hi all,
i am selecting the data from TABLE A ( id number ,rights varchar2 ). result set as
ID RIGHTS
1 M,P,Y,N,C,P
4 N,E,A
10 N,C,R,P
but i want the output as
ID RIGHTS
1 M
1 P
1 Y
1 N
1 C
1 P
4 N
4 E
4 A
10 N
10 C
10 R
10 P
kindly share your idea's to get the desired results.
thanks in advance
Edited by: 887268 on Nov 30, 2012 11:12 PMTry this
SQL> WITH a(id, rights) AS
2 (
3 SELECT 1, 'M,P,Y,N,C,P' FROM dual UNION ALL
4 SELECT 4, 'N,E,A' FROM dual UNION ALL
5 SELECT 10, 'N,C,R,P' FROM dual)
6 SELECT id, regexp_substr(rights, '[^,]+',1,level) res
7 FROM a
8 CONNECT BY level - 1 <= regexp_count(rights,',') /* regexp_count:- 11g */
9 AND prior id = id
10 AND prior sys_guid() IS NOT NULL /* sys_guid:- 11g */
11 ORDER BY id
12 /
ID RES
1 M
1 P
1 Y
1 N
1 C
1 P
4 N
4 A
4 E
10 N
10 R
ID RES
10 C
10 P
13 rows selected.Thanks!
Edited by: Ashu_Neo on Dec 1, 2012 9:43 PM
-- Added comment -
Comma separated output using report builder
Hi Experts,
I am working with EBS 11.5.10, database 9i, and report builder 6i. I have a XML Publisher report, with output type EXCEL, which is working fine. But if i get huge data like 1million, 2million, it's not able accommodate the output in EXCEL. Since it's EXCEL 2003, it can't handle data more than it's capacity(i think 60,000 rows).
So we thought, if we can generate the output in CSV file with comma separte, then we can open the file in EXCEL 2007. Could somebody help me how to generate the CSV output using report builder 6i.
or is there any work around to our problem, kindly help me, it's urgent.Hi,
Not sure if report builder can be made to generate csv output.
But you can create a PLSQL Report. Just use the query of Report Builder and write a Plsql procedure based on this query
-Idris -
Unable to load comma separated number using sqlldr
Hi
See the example below.
I have problem in loading “bonus” into my emp table.
Appreciate your help.
Here I have appended the following.
- demo04.ctl – controfile
- demo04.dat – datafile
- demo04.log - logfile
Error :
===============================
Record 1: Rejected - Error on table EMP, column BONUS.
ORA-01722: invalid number
sqlldr userid=scott/tiger@orcl , control=demo04.ctl , log=demo04.log
Create table emp
Empno number,
Ename varchar2(80),
Sal number(15,2),
bonus number
cat demo04.ctl
==========================
LOAD DATA
INFILE 'demo04.dat'
INTO TABLE emp
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
Empno INTEGER EXTERNAL,
Ename ,
Sal DECIMAL EXTERNAL,
bonus DECIMAL EXTERNAL ????
cat demo04.dat
==============================================
"1000", "*XXX,XXXX", "9820.760000","3,395"
"1001", "*XXX,XXXX", "9821.760000","88,883,395"
cat demo04.log
============================
SQL*Loader: Release 8.1.7.4.0 - Production on Fri Oct 13 17:58:31 2006
(c) Copyright 2000 Oracle Corporation. All rights reserved.
Control File: demo04.ctl
Data File: demo04.dat
Bad File: demo04.bad
Discard File: none specified
(Allow all discards)
Number to load: ALL
Number to skip: 0
Errors allowed: 50
Bind array: 64 rows, maximum of 65536 bytes
Continuation: none specified
Path used: Conventional
Table EMP, loaded from every logical record.
Insert option in effect for this table: INSERT
Column Name Position Len Term Encl Datatype
EMPNO FIRST * , O(") CHARACTER
ENAME NEXT * , O(") CHARACTER
SAL NEXT * , O(") CHARACTER
BONUS NEXT * , O(") CHARACTER
Record 1: Rejected - Error on table EMP, column BONUS.
ORA-01722: invalid number
Record 2: Rejected - Error on table EMP, column BONUS.
ORA-01722: invalid number
Table EMP:
0 Rows successfully loaded.
2 Rows not loaded due to data errors.
0 Rows not loaded because all WHEN clauses were failed.
0 Rows not loaded because all fields were null.
Space allocated for bind array: 65016 bytes(63 rows)
Space allocated for memory besides bind array: 0 bytes
Total logical records skipped: 0
Total logical records read: 2
Total logical records rejected: 2
Total logical records discarded: 0
Run began on Fri Oct 13 17:58:31 2006
Run ended on Fri Oct 13 17:58:32 2006
Elapsed time was: 00:00:01.14
CPU time was: 00:00:00.05Try
bonus CHAR "to_number(:bonus, '999G999G999')" -
How to convert rows of internal table to columns of another internal table?
Hi,
Experts,
test_data.xls:
one two three four five
one two three four
one two three
one two
one
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = 'c:/test_data.xls'
I_BEGIN_COL = '1'
I_BEGIN_ROW = '1'
I_END_COL = '10'
I_END_ROW = '10'
TABLES
INTERN = it_tab
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3
output:
0001 0001 one
0001 0002 two
0001 0003 three
0001 0004 four
0001 0005 five
0002 0001 one
0002 0002 two
0002 0003 three
0002 0004 four
0003 0001 one
0003 0002 two
0003 0003 three
0004 0001 one
0004 0002 two
0005 0001 one
but i want this format:
one two three four five
one two three four
one two three
one two
one
i don't want this type of output display i want to display in ABAP report as in file format how can i achieve this post some ideas on it.
Thank U,
Shabeer ahmed.Hi,
Use this piece of code :
parameters: p_flname type rlgrap-filename.
data:
li_filecontent type standard table of alsmex_tabline ,
lwa_filecontent type alsmex_tabline ,
lv_begin_col type i value 1,
lv_begin_row type i value 1,
lv_end_col type i value 17,
lv_end_row type i value 65000,
li_fieldlist type lvc_t_fcat,
li_data type ref to data,
dy_line type ref to data.
field-symbols:<dyntable> type standard table,
<fs_data> type ref to data,
<fs_1>,
<dyn_wa>,
<dyn_field>.
*Transfer excel file contents to internal table
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
filename = p_flname
i_begin_col = lv_begin_col
i_begin_row = lv_begin_row
i_end_col = lv_end_col
i_end_row = lv_end_row
tables
intern = li_filecontent
exceptions
inconsistent_parameters = 1
upload_ole = 2
error_message = 3
others = 4.
if sy-subrc = 0.
*Creating the list of fields in the table
perform f_create_tab_field tables li_fieldlist using 'BUKRS' 4 .
perform f_create_tab_field tables li_fieldlist using 'ZPOC_KUNNR' 10 .
perform f_create_tab_field tables li_fieldlist using 'RANL' 13.
perform f_create_tab_field tables li_fieldlist using 'ZPEDAT' 10 .
perform f_create_tab_field tables li_fieldlist using 'KWERT' 15 .
perform f_create_tab_field tables li_fieldlist using 'BONUS' 2 .
perform f_create_tab_field tables li_fieldlist using 'WAERS' 5 .
perform f_create_tab_field tables li_fieldlist using 'ZVAL' 15 .
perform f_create_tab_field tables li_fieldlist using 'ZQTY' 15 .
perform f_create_tab_field tables li_fieldlist using 'KMEIN' 3 .
assign li_data to <fs_data>.
*CREATING INTERNAL TABLE TO store data
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = li_fieldlist
importing
ep_table = <fs_data>
exceptions
generate_subpool_dir_full = 1
others = 2.
if sy-subrc = 0.
assign <fs_data>->* to <fs_1>.
assign <fs_1> to <dyntable>.
Create dynamic work area and assign to FS
create data dy_line like line of <dyntable>. " creating a line type of the table just created above
assign dy_line->* to <dyn_wa>. " creating the work area with reference to the line type
loop at li_filecontent into lwa_filecontent.
assign component lwa_filecontent-col "accessing corresponding field in the field catalog
of structure <dyn_wa> to <dyn_field>. "and assigning this field to a field symbol
if sy-subrc = 0.
<dyn_field> = lwa_filecontent-value. " filling value for this field
endif.
at end of row.
append <dyn_wa> to <dyntable>.
clear <dyn_wa>.
endat.
clear lwa_filecontent.
endloop.
i_input_file[] = <dyntable>.
endif.
elseif sy-subrc <> 0.
message s027 display like c_error with text-001.
stop.
endif.
form f_create_tab_field tables p_li_fieldlist structure lvc_s_fcat
using p_fname
p_lenght.
data:lwa_fieldlist type lvc_s_fcat.
lwa_fieldlist-fieldname = p_fname.
lwa_fieldlist-intlen = p_lenght.
append lwa_fieldlist to p_li_fieldlist.
clear lwa_fieldlist.
endform. " F_CREATE_TAB_FIELD
Regards,
Dev. -
Problems converting from MS Word 2007 to PDF using LiveCycle Designer 8
Hi all,
Hope anybody out there could assist me. have a Word document (we are using
Office 2007) and I'm trying to use Adobe Live Cycle Designer 8.0 to convert
a form from word to pdf. However, I get an error message (as shown in the
image below)
Is this a compatibility problem with Office 07?
Appreciate all the assistance.
Thanks and regards.Hi Peggy,
I found a solution in a tech note from the adobe site:
http://kb.adobe.com/selfservice/viewContent.do?externalId=329044&sliceId=2
2007 is a little tricky, since the instructions it gives are for Office 2003.
In 2007 I went into "Word Options" from that funky button at the top of the Word window.
From there, go into "Add Ins".
At the bottom where it says "Manage" select "Com Add Ins" then click "Go".
You should have a list that includes the Acrobat PDFMaker Office Add In. My Add In file is located at: \\Program Files\Adobe\Acrobat 8.0\PDFMaker\Office\PDFMOfficeAddin.dll
The document finally converted, but it couldn't autodetect any of the form fields I'd placed on the original Word Document (.docx). Still looking for an answer on that one.
Good luck.
Also posted this solution to: https://www.adobeforums.com/webx/.3bc400e4/4 -
Converting key figures from rows to column using DSO and start routine
Hi SDNer:
I need some help to convert key figures from rows to column.
The source is DSO 1 and I am thinking about writing ABAP in the start routine to do the conversion. The target is DSO2.
Below is the more detail information with example. Basically, for each record in DSO 1 I need to create 3 records (because there are 3 KF's) and output to DSO2.
I would really appreciate some help on this.Thank you.
Tony
DSO 1 data format (SOURCE)
Period ID KF1 KF2 KF3
200702 100 300 200 750
Output to DSO 2 (TARGET)
Period ID KF LABEL
200702 100 300 KF1
200702 100 200 KF2
200702 100 750 KF3This is the code in BI 7.0.
u need to put a field "Label" in DSO1. u dont need to populate this in DSO1 but it helps the code to populate the field in DSO2.
DATA: wa_result TYPE _ty_s_sc_1,
t_result TYPE STANDARD TABLE OF _ty_s_sc_1.
DATA:counter(2) TYPE n.
LOOP AT SOURCE_PACKAGE INTO wa_result.
counter =0.
while counter < 3 .
wa_result- Period = wa_result-Period.
wa_result- ID = wa_result-ID.
if counter = 0.
wa_result- KF1 = wa_result-KF1.
wa_result- Label = 'KF1'.
elseif counter = 1.
wa_result- KF1 = wa_result-KF2.
wa_result- Label = 'KF2'.
else.
wa_result- KF1 = wa_result-KF3.
wa_result- Label = 'KF3'.
endif.
APPEND wa_result TO t_result.
counter = counter+1.
endwhile.
endloop.
CLEAR: SOURCE_PACKAGE,wa_result.
LOOP AT t_result INTO wa_result.
APPEND wa_result TO SOURCE_PACKAGE.
ENDLOOP.
Maybe you are looking for
-
I can't get my itunes store to work, it keeps giving the error (-1202)
Hello, I'm really frustrated as I cannot get my itunes store to work, I've had problems with it for a while now and only just manged to get past one error, (error -9808), only to now get the error -1202. I'm running the most up to date version of itu
-
Not using my index !!!
i have 3 tables: customer (has over 120,000 rows) business workplace I'm doing a query which is blowing out (time wise) due to the fact that it's not using the index which i have specified on the customer table. The index which is specified on the cu
-
[Web Player][Playlists] Playlist sorting
A previous thread on this topic - https://community.spotify.com/t5/Closed-Ideas/Sort-Playlists-Alphabetically/idi-p/699414 - was incorrectly defined as a duplicate and can therefore no longer benefit from user kudos. Spotify, I'd urge you to pay cl
-
Featching Data From The Data Base Using DI API in Matrix
Hi All of u i am shahid i faced a problem when i retrive the selected data from the data base using matrix plz. Healp me!. Thanks Mohd Shahid. SAP Techinical Consultent Option Strict Off Option Explicit On Friend Class UseMatrix
-
Dictionary widget on dashboard stopped working?
This is what happens when I attempt to search/ define a word: This little cup looking silver thing comes down as opposed to the definition bit. Only started hapenning recently- worked find before. Please help and thank you!