Single row query and convert
greetings,
Data tables and intended output are on the bottom.
Process tables contains different store id that process the fabric. 1 single order will have 2 ( at most) or 1 different process store(s). Need to create a query list out all order no along with process store names , work. It also requires to convert each numeric fieldto 0 if null. I was able to create a query as the following but stuck on don't knwo how to make the order number listed as single row plus that numeric field conversion when there are 2 different process no . Can you help ? I know there are many gurus out here that can give me a lift. Thanks.
select
B.porderno,
decode(pprocessno,1,A.name,null) as "1st storename",
decode(pprocessno,2,A.name,null) as "2nd storename",
decode(pprocessno,1,nvl(B.plength,0),null) as "1st length",
decode(pprocessno,2,nvl(B.plength,0),null) as "2nd length"
from test_store2 A,test_process B
where A.storeid=B.pstoreid.....
CREATE TABLE test_store2
( storeid NUMBER(3,0) not null,
name VARCHAR2(20)not null,
addr VARCHAR2(30)not null
CREATE TABLE test_process
( porderno NUMBER(10,0) not null,
pstoreid number(3,0) not null,
pprocessno number(3,0) not null,
plength number(3,0),
pwork VARCHAR2(30)
INSERT INTO test_store2(storeid, name, addr)
VALUES (001, 'papas', '123 Road1')
INSERT INTO test_store2(storeid, name, addr)
VALUES (002, 'tcbi', '652 heaven st')
INSERT INTO test_store2(storeid, name, addr)
VALUES (003, 'tutu club', '888 big ave')
INSERT INTO test_store2(storeid, name, addr)
VALUES (004, 'stinkys', '432 bobo st')
INSERT INTO test_process(porderno, pstoreid,pprocessno,plength, pwork)
VALUES (811, 2,1,null,'prepNdye')
INSERT INTO test_process(porderno, pstoreid,pprocessno,plength, pwork)
VALUES (811, 1,2,30,'trimming')
INSERT INTO test_process(porderno, pstoreid,pprocessno,plength, pwork)
VALUES (812, 1,1,10,'dye')
INSERT INTO test_process(porderno, pstoreid,pprocessno,plength, pwork)
VALUES (813, 3,1,40, 'prep')
INSERT INTO test_process(porderno, pstoreid,pprocessno,plength, pwork)
VALUES (813, 4,2,null, 'dye')
look for result layout
order 1st storename 2nd storename 1st length 2ndlength 1stwork 2nd work
811 tcbi papas 0 30 prepNdye trimming
812 papas 10 0 dye
813 tutu club stinks 40 0 prep dye
Hi,
Please don't post unformatted code. If you want people to read you code, don't make it difficult for them
When posting formatted text on this site, type these 6 characters:
{code}
(small letters only, inside curly brackets) before and after sections of formatted text, to preserve spacing.
In the query I posted,
AND p2.pprocessno = 2was part of the outer-join condition between p1 and (the optional) p2.
When using -notation, you need a sign after all references to columns from the table that could be missing (p2 in this case), so you should have siad:
where ( p1.pstoreid = s1.storeid
and p1.pprocessno = 1
and ( p1.porderno = p2.porderno (+)
AND p2.pprocessno (+) = 2 -- (+) sign needed here
and (p2.pstoreid = s2.storeid (+) -- Cascading outer join
)A rule of thumb: if any WHERE-clause reference to p2 has a -sign, then all references to p2 must have a -sign, otherwise the effect will be an inner join. There is one exception, a cascading outer join , where a another table (s2 in this case) is outer-joined to the optional table (p2). You can't have -signs on both sides of a condition. In a cascading outer join, only the distal+ table (the one farther removed from the required table, p1 in this case) is marked with a +-sign.
Similar Messages
-
Single-row query return more than one row
Hi all,
Whne i run the following command it is giving me the
The following error has occurred:
Details:
ORA-01427: single-row subquery returns more than one row
UPDATE MRCH.MRC_TEMP_PAY A
SET OFFSET_PH = (SELECT PHASE FROM MRCH.MRC_TEMP_PAY B
WHERE A.PROJECT_ID = B.PROJECT_ID
AND A.MUNI = B.MUNI
AND A.OFFSET = B.NEW_PAY)
WHERE A.PAY_IND = 'Y'
AND OFFSET IS NOT NULL;
any helpI tried max and min
they both give the duplicate row
1 SELECT A.PROJECT_ID,A.PINSUB,
A.MUNI,A.RATED_COST,
A.OLD_COST
FROM MRCH.MRC_TEMP_PAY A
2 WHERE OFFSET_PH = (SELECT max(PHASE) FROM MRCH.MRC_TEMP_PAY B
3 WHERE A.PROJECT_ID = B.PROJECT_ID
4 AND A.MUNI = B.MUNI
5 AND A.OFFSET = B.NEW_PAY
6 )
7 AND A.PAY_IND = 'Y'
8* AND OFFSET IS NOT NULL
SQL> /
PROJEC PIN MUNI RATED_COST OLD_COST
075395 221 070000 159435.45 1062300
175299 399 150000 312397.65 0
175299 399 170000 312397.65 0
SQL> ED
Wrote file afiedt.buf
1 SELECT A.PROJECT_ID,A.PINSUB,
A.MUNI,A.RATED_COST,
A.OLD_COST
FROM MRCH.MRC_TEMP_PAY A
2 WHERE OFFSET_PH = (SELECT mIN(PHASE) FROM MRCH.MRC_TEMP_PAY B
3 WHERE A.PROJECT_ID = B.PROJECT_ID
4 AND A.MUNI = B.MUNI
5 AND A.OFFSET = B.NEW_PAY
6 )
7 AND A.PAY_IND = 'Y'
8* AND OFFSET IS NOT NULL
SQL> /
PROJEC PIN MUNI RATED_COST OLD_COST
075395 221 070000 159435.45 1062300
175299 399 150000 312397.65 0
175299 399 170000 312397.65 0
175315 321 180000 167004.45 1113363
175320 321 130000 273639.45 1824263 -
Running a background query and converting to csv
Hello All,
We are currently running 3.1 BW. What is the best way to achieve a csv file from a BW query and move that file to another non sap external system. All of the above should have very minimum manual interruption. Please advice.
XenaHi Ram,
I found your suggestion very useful, but have a small doubt. While extracting the Query, it is asking for Technical name of extract. Could you please guide me, what to input in that field. If you have any document, kindly pass on.
Thanks
Madhu
[email protected] -
Connecting JDBC Single Row Query to SQL Server 2008
Hello,
I am new to workbench and am having a very dificult time accessing a database and running a query on it. I have searched a lot on the internet for suggestion on how to accomplish this but nothing has worked. The LiveCycle was intaled on the same server that the SQL Server is sintalled, and was installed by an administrator who is no longer at our company. So I am trying to have the user input an account number into the form I have created, then take that account number and use an xpath expression to query the database and extract the information for that account. Could anyone please help me set this up.
I Changed my my-db2-ds.xml to the following:
<local-tx-datasource>
<jndi-name>SQLDB_IMACS</jndi-name>
<connection-url>jdbc:sqlserver://CBS-SQL-001;databaseName=DB_IMACS;integratedSecurity=tru e;</connection-url>
<driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
</local-tx-datasource>
and I get the following error message:
Exception: Could not create connection; - nested throwable: (org.jboss.resource.JBossResourceException: Failed to register driver for: com.microsoft.sqlserver.jdbc.SQLServerDriver; - nested throwable: (java.lang.ClassNotFoundException: No ClassLoaders found for: com.microsoft.sqlserver.jdbc.SQLServerDriver)); - nested throwable: (org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (org.jboss.resource.JBossResourceException: Failed to register driver for: com.microsoft.sqlserver.jdbc.SQLServerDriver; - nested throwable: (java.lang.ClassNotFoundException: No ClassLoaders found for: com.microsoft.sqlserver.jdbc.SQLServerDriver)))
I have the following file sqljdbc.jar in my Adobe LiveCycle ES2\jboss\server\lc_turnkey\lib\ folder.
If you could please let me know what I can do to connect that would be very useful.
Thanks,
sgarciacode19You will need to use the UNPIVOT operator:
DECLARE @example TABLE
Id int NOT NULL IDENTITY(1,1),
Quantity1 int,
Quantity2 int,
Quantity3 int
INSERT INTO @example VALUES (1000, 2000, 3000), (4000, 5000, 6000);
SELECT * FROM @example;
SELECT Id, Quantity, QuantityType
FROM @example
UNPIVOT
Quantity FOR QuantityType IN (Quantity1, Quantity2, Quantity3)
) AS u;
Output:
(2 row(s) affected)
Id Quantity1 Quantity2 Quantity3
1 1000 2000 3000
2 4000 5000 6000
(2 row(s) affected)
Id Quantity QuantityType
1 1000 Quantity1
1 2000 Quantity2
1 3000 Quantity3
2 4000 Quantity1
2 5000 Quantity2
2 6000 Quantity3
(6 row(s) affected) -
Single row query returns more than one row
Hi all,
I have a simple update query problem. I have four tables
activist(activist_id,first_name,last_name,c_state),
membership(activist_id,g_n_id),
group_network(g_n_id,g_n_type_id),
school_grop_det(g_n_id,state). For some records in activist table the c_state column is null, i want to update that column with state column of school_group_det table.
Here is the query for the states which are null
select distinct a.activist_id,a.first_name,a.last_name,
a.c_state,sd.state from activist a,membership m,
group_network g,school_group_det sd where
a.activist_id=m.activist_id and g.g_n_id=m.g_n_id and
g.g_n_id=sd.g_N_id and a.c_state is null and g.g_n_type_id='1001'
order by a.activist_id
I got the activist_id,first_name,last_name,c_state from activist and state from school_group_det. now i as i told you want to update the c_state with state column of school_group_Det table.
Pleae any one help me
Thanks
SrinivasYes, the ROWNUM is never predictive. You won't know which row will be returned if you have multiple rows against a key.
But according to your table structure, If you are getting multiple values, it means your membership table has primary key composed of (activist_id,g_n_id). And every g_n_id has a state associated with it.
If an activitst_id has more than one g_n_id (which means more than one states) then which state of that you want to use for update?
Either you'll have to have only one g_n_id for each activist_id, or you'll have to decide which state you want to use for update and change your update statement accordingly.
Looking at your table structure, if the first column of each table would be a primary key then you will not get multiple values returned by the subquery.
activist(activist_id,first_name,last_name,c_state),
membership(activist_id,g_n_id),
group_network(g_n_id,g_n_type_id),
school_grop_det(g_n_id,state) -
Interactive Report's Column Definition - Single Row View Label Bug?
Hello,
I have an Interactive report that I've added a Blue background to certain column headings (done by giving Column Heading a background color), this works fine except for the Single Row view - it displays the <....> code I used to get the background color and the column heading. I've tried to change the Single Row View Label by unchecking the 'Use Same Text for Single Row View' on the Column Definition and giving a different label, it just ignores whatever I put in and shows the Column Heading with the < .... > code. Is this a Bug or am I doing something wrong?
Thanks,
AnnaHi Anna,
I believe that it is a bug.
If the 'Use Same Text for Single Row View' checkbox is unticked and some text is entered in the 'Single Row View Label' field it gets ignored completely when viewed in the single row view and the existing value in 'Column Heading' is used.
I wanted to do something similar to you, colouring some of the Interactive Report column headers, and it works fine in the IR report itself but shows the code (span style:color etc) in the single row query. I am using Apex 3.1.1 and the Sand Theme.
I created a simple application on apex.oracle.com using the red theme and in single row view it still ignores the 'Single Row View Label' but interestingly shows the Column Heading text without the code. This indicates that there could be a work-around by altering the theme.
Regards,
Chris -
My company is using APEX 4.1 but I'm an APEX newbie (I have a Oracle Forms background). My user wants an APEX app that displays a couple of fields to enter search criteria and then display a single record report based on the search criteria. The query would return a bunch of columns so they would like to see them in a page format rather than on a single row. This would be read only data. Does anyone know if there are any examples of doing something like this?
There is a vertical report template for the most of the clasic reports. As far as I know there is no such template for Interactive Report. However, you can use Interactive Report for the purpose you described. Interactive Report can use "Link to Single Row View" and it will display all the columns included in the query below each other - just like a form does it. Look under Report Attributes > Link Column
Denes Kubicek
http://deneskubicek.blogspot.com/
http://www.apress.com/9781430235125
http://apex.oracle.com/pls/apex/f?p=31517:1
http://www.amazon.de/Oracle-APEX-XE-Praxis/dp/3826655494
------------------------------------------------------------------- -
Single Row Subquery Howto ?
In some situation i need to design a query witch give's me the possibility to bring subvalues in a single row. And this not as an object.
Example :
The output should by.
NAME OWNS_PROJECT
Clac Oracle migration, New Department Server,Creation financing
The output must be in a single Row.
The Name comes from one table and the OWNS_PROJECTS list is in a other table.
I found a soloution witch is able to give me the user and this information in the SQL*Plus program. But the OWNS_PROJECTS column is the returned as an object.
I need to get the list back as one entry in the column OWNS_PROJECT.
nullTry something like this (PL/SQL):
---BEGIN---
CREATE OR REPLACE FUNCTION getcolumn RETURN VARCHAR2
IS CURSOR c1 IS SELECT OWNS_PROJECT from PROJECTS_TABLE;
OUT VARCHAR(4000) := '';
BEGIN
FOR acct IN c1 LOOP
OUT := OUT| |', '| |acct.OWNS_PROJECT;
END LOOP;
RETURN OUT;
END;
---END---
With
select getcolumn from dual;
you get all rows concatenated to one row.
Hope this helps,
Bernhard
null -
Unable to reorder/change column names on interactive single row view
I have created an interactive report and grouped my columns to display nicely in a single row view report. However, once I initially add the columns to a group, I am unable to reorder them. I can move them up and down the list, but the changes don't save. Also, I have gone through column by column and unchecked the box that says Use Same Text for Single Row View and expanded the column name. However, the single row view still displays what is in the master report. I've tried closing out my browser completely and reopening, but I am still not seeing my changes. Any suggestions?
I also just stumbled about the "Use Same Text for Single Row View" option actually doing nothing - in Single Row View I still get the label text from "Column Heading", no matter what I enter in "Single Row View Label".
I had to adjust a column width using a span tag in the heading (as this seems to be the only way to do that - any other suggestions I found adding style information to the region header had no effect), and now that tag is displayed in the Single Row View label.
I can live with that for now, but it's not really nice.
Is this a known bug? Didn't find anything else in the forum regarding this problem so far.
Holger -
Function return boolean with combine query and validation
Wondering how would you combine a query and the condition together...
Right now i have a computation that would do a single sql query.
and in my validation i would use a function return boolean call the result from the computation to do some if statements
wondering how would you combine the two in the validation? ( tried pasting both in the validation but it doesn't seem to work.)
Select count(NAME_ID)
FROM table
WHERE to_char(NAME_ID) = :P1_NAME_ID;
IF :P1_results = 1 THEN
RETURN TRUE;
END IF;
RETURN FALSE;OK, then does this work for you as validation on your item; P1_NAME_ID ?
DECLARE
l_rowcount PLS_INTEGER;
BEGIN
SELECT COUNT (name_id)
INTO l_rowcount
FROM my_table
WHERE TO_CHAR (name_id) = :P1_NAME_ID;
IF l_rowcount = 1
THEN
RETURN TRUE;
ELSE
RETURN FALSE;
END IF;
END;Jeff -
Simple SQL Query and Parameters and LOV
Newbie and trying to work thru building a simple sql query with a single table query and use a parameter and lov.
Can anyone point me to an example.
simple query:
select cust_id, name_desc, name_add1, name_add2, name_city
from customer_table
where cust_id = :cust_parm
This works in straight sql and in the query builder by prompting for the customer ID. When building a parameter using LOV or search, it doesn't seem to detect the variable.
Thanks..
DDIf you are using version 11g, then as soon as you save the query in the data model, it should notice the parameter and ask if you want to add the parameter to the data model. What version of BIP are you using?
What happens if you exclude the parameter from the query and simply hard-code the criteria? Can you generate XML data?
From your wording, it sounds like you're trying to create a parameter from the LOV dialog. LOVs and parameters are totally distinct. After each are created separately, then you configure the parameter to use the LOV. -
MULTIPLE-ROW drag and drop between 2 ALV grids
Hi,
Can anybody help me with acheiving MULTIPLE-ROW drag and drop functionality between 2 ALV grids.hi Prakash,
Actually I'm trying to develop multiple drag and drop between 2 ALV's. To understand the events properly, I started working on this sample program where it uses 1 ALV and splits it into 2 and uses single row drag and drop between them. Now I'm making it to work for multiple drag and drop, so that I can use it on my application. This is the code which I'm working on..
*& Report Z_ALV_GRID_CONTROLS_DRAG_DROP *
REPORT z_alv_grid_controls_drag_drop.
DATA : i_ztransactions TYPE TABLE OF ztransactions
WITH HEADER LINE.
DATA : i_ztransactions2 TYPE TABLE OF ztransactions
WITH HEADER LINE.
DATA : ok_code LIKE sy-ucomm .
DATA : mcontainer TYPE REF TO cl_gui_custom_container .
DATA : mcontleft TYPE REF TO cl_gui_container .
DATA : mcontright TYPE REF TO cl_gui_container .
DATA : msplitcont TYPE REF TO
cl_gui_easy_splitter_container .
DATA : malv_left TYPE REF TO cl_gui_alv_grid .
DATA : malv_right TYPE REF TO cl_gui_alv_grid .
DATA : mrow TYPE lvc_s_row .
DATA : gt_outtab_source TYPE ztransactions.
DATA : gt_outtab_target TYPE ztransactions.
DATA : g_repid LIKE sy-repid.
DATA: gs_layout TYPE lvc_s_layo ,
g_behaviour_alv TYPE REF TO cl_dragdrop .
DATA : mlines TYPE i .
CLASS lcl_dragdropobj DEFINITION
This is the Class of Drag Drop Object .
This Object is used as a temporary storage means
of the information extracted with drag
CLASS lcl_dragdropobj DEFINITION.
PUBLIC SECTION.
DATA: i_ztransactions TYPE ztransactions ,
index TYPE i ,
original_table(5) TYPE c ,
proceed_trans(1) TYPE c .
ENDCLASS. "lcl_dragdropobj DEFINITION
DATA : mdata TYPE REF TO lcl_dragdropobj .
CLASS DND_TOOLS DEFINITION
This class contains the methods responding to the
events ONDRAG , ONDROP , ONDROPCOMPLETE
of the ALV Grid Controls
CLASS dnd_tools DEFINITION .
PUBLIC SECTION .
METHODS:handle_user_command
FOR EVENT user_command OF
cl_gui_alv_grid
IMPORTING
e_ucomm.
METHODS : handle_drag_from_left
FOR EVENT ondrag OF
cl_gui_alv_grid
IMPORTING
e_row
e_dragdropobj .
METHODS : handle_dropcomplete_from_left
FOR EVENT ondropcomplete OF
cl_gui_alv_grid
IMPORTING
e_row
e_dragdropobj .
METHODS : handle_drag_from_right
FOR EVENT ondrag OF
cl_gui_alv_grid
IMPORTING
e_row
e_dragdropobj .
METHODS : handle_dropcomplete_from_right
FOR EVENT ondropcomplete OF
cl_gui_alv_grid
IMPORTING
e_row
e_dragdropobj .
METHODS : handle_drop_to_left
FOR EVENT ondrop OF
cl_gui_alv_grid
IMPORTING
e_dragdropobj .
METHODS : handle_drop_to_right
FOR EVENT ondrop OF
cl_gui_alv_grid
IMPORTING
e_dragdropobj .
ENDCLASS . "DND_TOOLS DEFINITION
CLASS DND_TOOLS IMPLEMENTATION
CLASS dnd_tools IMPLEMENTATION .
METHOD handle_drag_from_left .
METHOD handle_user_command.
DATA: lt_rows TYPE lvc_t_row.
DATA: lt_rows TYPE lvc_t_roid.
DATA: lt_row TYPE lvc_s_roid.
DATA: mdata TYPE REF TO lcl_dragdropobj .
DATA: dragdropobj TYPE REF TO lcl_dragdropobj .
get selected row
CALL METHOD malv_left->get_selected_rows
IMPORTING
et_row_no = lt_rows.
CALL METHOD cl_gui_cfw=>flush.
IF sy-subrc NE 0.
add your handling, for example
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = g_repid
txt2 = sy-subrc
txt1 = 'Error in Flush'(500).
ENDIF.
CREATE OBJECT mdata.
LOOP AT lt_rows INTO lt_row.
mrow = lt_row .
READ TABLE i_ztransactions INDEX lt_row-row_id INTO
i_ztransactions.
MOVE i_ztransactions TO mdata->i_ztransactions .
MOVE lt_row-row_id TO mdata->index.
MOVE 'LEFT' TO mdata->original_table .
e_dragdropobj->object = mdata .
ENDLOOP.
ENDMETHOD. "handle_user_command
METHOD handle_dropcomplete_from_left .
NB : the following data object MDATA is local to
the method and contains the information from the
import parameter of the method E_DRAGDROPOBJ
DATA : mdata TYPE REF TO lcl_dragdropobj .
DATA: lt_rows TYPE lvc_t_roid.
DATA: lt_row TYPE lvc_s_roid.
CALL METHOD malv_left->get_selected_rows
IMPORTING
et_row_no = lt_rows.
CALL METHOD cl_gui_cfw=>flush.
IF sy-subrc NE 0.
add your handling, for example
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = g_repid
txt2 = sy-subrc
txt1 = 'Error in Flush'(500).
ENDIF.
LOOP AT lt_rows INTO lt_row.
mdata ?= e_dragdropobj->object .
CHECK mdata->proceed_trans = 'X' .
mrow = mdata->index.
DELETE i_ztransactions INDEX mrow .
APPEND mdata->i_ztransactions TO i_ztransactions2 .
SORT i_ztransactions2 BY kunnr belnr .
DELETE i_ztransactions2 WHERE kunnr IS INITIAL .
DESCRIBE TABLE i_ztransactions LINES mlines .
IF mlines EQ 0 .
CLEAR i_ztransactions .
APPEND i_ztransactions TO i_ztransactions .
ENDIF .
ENDLOOP.
CALL METHOD malv_left->refresh_table_display.
CALL METHOD malv_right->refresh_table_display.
ENDMETHOD . "HANDLE_DROPCOMPLETE_FROM_LEFT
METHOD handle_drag_from_right.
mrow = e_row-index .
READ TABLE i_ztransactions2 INDEX mrow INTO
i_ztransactions2 .
CREATE OBJECT mdata .
MOVE i_ztransactions2 TO mdata->i_ztransactions .
MOVE mrow TO mdata->index .
MOVE 'RIGHT' TO mdata->original_table .
e_dragdropobj->object = mdata .
ENDMETHOD . "HANDLE_DRAG_FROM_RIGHT
METHOD handle_dropcomplete_from_right .
DATA : mdata TYPE REF TO lcl_dragdropobj .
mdata ?= e_dragdropobj->object .
CHECK mdata->proceed_trans = 'X' .
mrow = mdata->index .
DELETE i_ztransactions2 INDEX mrow .
APPEND mdata->i_ztransactions TO i_ztransactions .
SORT i_ztransactions BY kunnr belnr .
DELETE i_ztransactions WHERE kunnr IS INITIAL .
DESCRIBE TABLE i_ztransactions2 LINES mlines .
IF mlines EQ 0 .
CLEAR i_ztransactions2 .
APPEND i_ztransactions2 TO i_ztransactions2 .
ENDIF .
CALL METHOD malv_left->refresh_table_display.
CALL METHOD malv_right->refresh_table_display.
ENDMETHOD . "HANDLE_DROPCOMPLETE_FROM_RIGHT
METHOD handle_drop_to_left .
DATA : mdata TYPE REF TO lcl_dragdropobj .
mdata ?= e_dragdropobj->object .
IF mdata->original_table = 'RIGHT' .
mdata->proceed_trans = 'X' .
ELSE .
mdata->proceed_trans = ' ' .
ENDIF .
e_dragdropobj->object = mdata .
ENDMETHOD . "HANDLE_DROP_TO_LEFT
METHOD handle_drop_to_right .
DATA : mdata TYPE REF TO lcl_dragdropobj .
DATA: lt_rows TYPE lvc_t_roid.
DATA: lt_row TYPE lvc_s_roid.
CALL METHOD malv_left->get_selected_rows
IMPORTING
et_row_no = lt_rows.
CALL METHOD cl_gui_cfw=>flush.
IF sy-subrc NE 0.
add your handling, for example
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = g_repid
txt2 = sy-subrc
txt1 = 'Error in Flush'(500).
ENDIF.
LOOP AT lt_rows INTO lt_row.
mdata ?= e_dragdropobj->object .
IF mdata->original_table = 'LEFT' .
mdata->proceed_trans = 'X' .
ELSE .
mdata->proceed_trans = ' ' .
ENDIF .
e_dragdropobj->object = mdata .
ENDLOOP.
ENDMETHOD . "HANDLE_DROP_TO_RIGHT
ENDCLASS . "DND_TOOLS IMPLEMENTATION
DATA : mlistener TYPE REF TO dnd_tools .
======================================================
START OF SELECTION
======================================================
START-OF-SELECTION .
PERFORM get_data .
CALL SCREEN 100 .
The screen 100 has the custom control MCONTAINER and
on the flow logic has the following modules :
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
MODULE PREPARE_SCREEN .
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0100.
(Off course not commented out in the real flow logic)
FORM GET_DATA *
FOR THIS EXAMPLE THE DATA SELECTION IS HARD CODED
FORM get_data .
CLEAR : i_ztransactions , i_ztransactions[] .
i_ztransactions-mandt = sy-mandt .
i_ztransactions-waers = 'EUR ' .
i_ztransactions-kunnr = '0000000001' .
i_ztransactions-belnr = '0000000001' .
i_ztransactions-bldat = '20030101' .
i_ztransactions-dmbtr = '1000' .
APPEND i_ztransactions .
i_ztransactions-belnr = '0000000002' .
i_ztransactions-bldat = '20030202' .
i_ztransactions-dmbtr = '1010' .
APPEND i_ztransactions .
i_ztransactions-belnr = '0000000003' .
i_ztransactions-bldat = '20030323' .
i_ztransactions-dmbtr = '1020' .
APPEND i_ztransactions .
i_ztransactions-belnr = '0000000004' .
i_ztransactions-bldat = '20030404' .
i_ztransactions-dmbtr = '1030' .
APPEND i_ztransactions .
i_ztransactions-belnr = '0000000005' .
i_ztransactions-bldat = '20030505' .
i_ztransactions-dmbtr = '1040' .
APPEND i_ztransactions .
i_ztransactions-belnr = '0000000006' .
i_ztransactions-bldat = '20030606' .
i_ztransactions-dmbtr = '1050' .
APPEND i_ztransactions .
i_ztransactions-belnr = '0000000007' .
i_ztransactions-bldat = '20030707' .
i_ztransactions-dmbtr = '1060' .
APPEND i_ztransactions .
i_ztransactions-belnr = '0000000008' .
i_ztransactions-bldat = '20030808' .
i_ztransactions-dmbtr = '1070' .
APPEND i_ztransactions .
i_ztransactions-belnr = '0000000009' .
i_ztransactions-bldat = '20030909' .
i_ztransactions-dmbtr = '1080' .
APPEND i_ztransactions .
i_ztransactions-belnr = '0000000010' .
i_ztransactions-bldat = '20031010' .
i_ztransactions-dmbtr = '1090' .
APPEND i_ztransactions .
CLEAR : i_ztransactions2 , i_ztransactions2[] .
APPEND i_ztransactions2 .
ENDFORM . "GET_DATA
*& Module STATUS_0100 OUTPUT
The PF STATUS STATUS100 called from the module below,
has on the Standard toolbar the buttons
BACK , EXIT and CANCEL .
These buttons are provided with function code = 'EXIT'
MODULE status_0100 OUTPUT.
SET TITLEBAR 'TITLEDRAGDROP' .
SET PF-STATUS 'STATUS100'.
ENDMODULE. " STATUS_0100 OUTPUT
Module USER_COMMAND_0100 INPUT
The following module checks the User Command and ends
the program
MODULE user_command_0100 INPUT.
IF ok_code = 'EXIT' .
CLEAR : mcontainer ,
mcontleft ,
mcontright ,
msplitcont ,
malv_left ,
malv_right .
LEAVE TO SCREEN 0 .
ENDIF .
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Module PREPARE_SCREEN OUTPUT
MODULE prepare_screen OUTPUT.
IF mcontainer IS INITIAL .
CREATE OBJECT mcontainer
EXPORTING
container_name = 'MCONTAINER' .
CREATE OBJECT msplitcont
EXPORTING
parent = mcontainer
orientation = 1 .
mcontleft = msplitcont->top_left_container .
mcontright = msplitcont->bottom_right_container .
CREATE OBJECT malv_left
EXPORTING i_parent = mcontleft .
gs_layout-sel_mode = 'D'.
CREATE OBJECT malv_right
EXPORTING i_parent = mcontright .
gs_layout-sel_mode = 'D'.
PERFORM set_layout_capable_of_drag_dro
USING 'X' 'X' .
CALL METHOD malv_left->set_table_for_first_display
EXPORTING
i_structure_name = 'ZTRANSACTIONS'
is_layout = gs_layout
CHANGING
it_outtab = i_ztransactions[].
CALL METHOD malv_right->set_table_for_first_display
EXPORTING
i_structure_name = 'ZTRANSACTIONS'
is_layout = gs_layout
CHANGING
it_outtab = i_ztransactions2[].
CREATE OBJECT mlistener .
CALL METHOD malv_left->set_toolbar_interactive.
SET HANDLER mlistener->handle_drag_from_left
FOR malv_left .
SET HANDLER mlistener->handle_dropcomplete_from_left
FOR malv_left .
SET HANDLER mlistener->handle_drag_from_right
FOR malv_right.
SET HANDLER mlistener->handle_dropcomplete_from_right
FOR malv_right .
SET HANDLER mlistener->handle_drop_to_right
FOR malv_right .
SET HANDLER mlistener->handle_drop_to_left
FOR malv_left .
ENDIF .
ENDMODULE. " PREPARE_SCREEN OUTPUT
Form SET_LAYOUT_CAPABLE_OF_DRAG_DRO
Definition of a Drag & Drop behaviour for the ALV
grid
FORM set_layout_capable_of_drag_dro USING drag drop.
DATA : effect TYPE i ,
handle_alv TYPE i .
CREATE OBJECT g_behaviour_alv.
effect = cl_dragdrop=>move + cl_dragdrop=>copy .
CALL METHOD g_behaviour_alv->add
EXPORTING
flavor = 'Line'
dragsrc = drag
droptarget = drop
effect = effect.
CALL METHOD g_behaviour_alv->get_handle
IMPORTING
handle = handle_alv.
gs_layout-s_dragdrop-row_ddid = handle_alv.
ENDFORM. " SET_LAYOUT_CAPABLE_OF_DRAG_DRO -
Need query to convert Single Row Multiple Columns To Multiple rows
Hi,
I have a table with single row like below
Column0 | Column1 | Column2 | Column3 | Column4|
Value0 | Value1 | Value2 | Value3 | Value4 |
Am looking for a query to convert above table data to multiple rows having column name and its value in each row as shown below
Column0 | Value0
Column1 | Value1
Column2 | Value2
Column3 | Value3
Column4 | Value4
Thanks in advance.
MohanHi ykMohan,
Dynamic UNPIVOT can be applied in this case as well.
CREATE TABLE dbo.T(ID INT,Column0 VARCHAR(99),Column1 VARCHAR(99),Column2 VARCHAR(99),Column3 VARCHAR(99),Column4 VARCHAR(99))
INSERT INTO T VALUES
(1,'Value0','Value1','Value2','Value3','Value4'),
(2,'Value0','Value1','Value2','Value3','Value4');
DECLARE @columns VARCHAR(MAX)
SELECT @columns=
STUFF(
SELECT ','+ COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME ='T' AND TABLE_SCHEMA='dbo' AND Column_name NOT IN('ID') FOR XML PATH('')
),1,1,'')
DECLARE @Sql NVARCHAR(MAX)
SET @Sql =
'SELECT ID, UPT.col,UPT.val FROM T
UNPIVOT
(val FOR col IN('+@columns+')) AS UPT'
EXEC sp_executeSQL @Sql
DROP TABLE T
If you have any feedback on our support, you can click
here.
Eric Zhang
TechNet Community Support -
Oracle query - Merging multiple rows into a single row output
Hi All,
I have to have a multiple row output to be converted into a single row output.My current output looks as follows:
ID YR INC_CODE OFFN SCHOOLNO
8006 2002 00175 SC03 12
8006 2002 00175 DC06 12
8006 2002 00175 DC03 12
8006 2002 00175 DC02 12
ID,INCIDENT CODE,OFFENSE are all Primary keys
So I need the output as follows:(IN ONE ROW)
ID YR INC_CODE OFFN1 OFFN2 OFFN3 OFFN4 SCHOOLNO
8006 2002 00175 SC03 DC06 DC03 DC02 12
Can you help me on this since have been spinning the wheel and this has to be a query since will have couple of tables join to produce a materialized view.
Thanks in advanceHi Nigel,
Thanks for the reply I tested out the portion having the decode and I get the output as follows:
ID YR INC_CODE OFFN1 OFFN2 OFFN3 OFFN4 OFFN5
8982 2002 2175 DOC01 -----------------------
8982 2002 2175 DOC02-------------------
8982 2002 2175 DOC03------------
8982 2002 2175 DOC06-------
8982 2002 2175 SCV03
There is no value as max for OFFN and each INC_CODE MAY HAVE UP TO A MAX OF 5 OFFN.My query is as follows:
select distinct STU_STUDENT_ID, INC_BEG_SCH_YR,INC_INCIDENT_CODE
, decode(rank() over (partition by INC_CODE order by OFFN),1,OFFN,null) as offn1
, decode(rank() over (partition by INC_CODE order by OFFN),2,OFFN,null) as offn2
, decode(rank() over (partition by INC_CODE order by OFFN),3,OFFN,null) as offn3
, decode(rank() over (partition by INC_CODE order by OFFN),4,OFFN,null) as offn4
, decode(rank() over (partition by INC_CODE order by OFFN),5,OFFN,null) as offn5
from stu_offn where
stu_offn.ID = '8982' and stu_offn.INC_CODE = '2175'
(****Where clause is just given to just check a value)
So as you know I need to just have all the OFFN in a single row ie as follows:
ID YR INC_CODE OFFN1 OFFN2 OFFN3 OFFN4 OFFN5
8982 2002 2175 DOC01 DOC02 DOC03 DOC06 SCV03
Can you just give me a step by step procedure to go through this and the table in this case is just 'STU_OFFN'
Thanks for the earlier reply appreciate it!
****Sending this again to show the exact way the output is coming -
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.
Maybe you are looking for
-
"Remote" App Has Become Sluggish, Slow to Respond
I've searched this and other forums and have yet to see the issue I'm having addressed. After successfully installing and using the iPhone "Remote" app to control my Apple TV, its performance has become erratic. While selecting and/or swiping actions
-
ITunes reinstallation brings ''error 7 - Windows error 126'
I had to de-install and re-install iTunes (version 11.1.4 64bit) on Windows-8.1. At the end of the installation process I got the message: "Service 'Apple mobile device' could not be started. Please check wheather you have sufficient authorization t
-
Error on timesheet submission "An error occurred while communicating with the server.
Hello, we have many users who are encountering errors submitting timesheets following our migration to Project Server 2013 (SP1 April 2014 CU). The error is: An error occurred while communicating with the server. Check connectivity with your administ
-
Livecycle forms irratic when trying to email
All I need to do is the following. Create a form in Livecycle. Link to it via a weblink and the user opens it fills it out, saves it on their machine and then return it as an attachment. I do not want a Submit button, as we use Lotus Notes 6.5 (due t
-
How find out the URL of a Transaction like se80 called by an iview
Hi Everybody, instead of a transaction-iview i want to use only the URL in the browser to call the screen of a ITS-Transcation. How can i find out the needed URL without using a transaction ivew? regards, Sid Edited by: sid_mopo on Mar 23, 2009 2:18