Problem with sub queries
Hi
I have 3 tables like,
LIST (ID NUMBER, NAME)
LIST_VERSION (ID NUMBER, VER NUMBER, STATE_CODE number)
STATE_CODES (CODE NUMBER, DESC VARCHAR2)
LIST to LIST_VERSION is one to many relation. I have a query like this,
SELECT LV.* from LIST_VERSION WHERE
LV.VER = (SELECT MAX(LV1.VER) FROM LIST_VERSION LV1 WHERE
LV1.ID = LV.ID)
OR LV.VER = (SELECT MAX(LV2.VER) FROM LIST_VERSION LV2 WHERE
LV2.ID = LV.ID and LV2.STATE_CODE=1)
LIST to LIST_VERSION and LIST_VERSION to STATE_CODES table is defined
in toplink mapping. To translate this into expression I have tried several possible combinations with out any luck. I was able to get the individual queries (the ones in OR) work, but not together. Here is what I did for individual queries
ExpressionBuilder bldr = new ExpressionBuilder(ListVersion.class);
ExpressionBuilder sub1 = new ExpressionBuilder ();
ExpressionBuilder sub2 = new ExpressionBuilder ();
ReportQuery subQ1 = new ReportQuery (ListVersion.class, sub1);
ReportQuery subQ2 = new ReportQuery (ListVersion.class, sub2);
subQ1.addMaximum ("listVer");
subQ1.setSelectionCriteria (sub1.get ("list").get ("id").equal (bldr.get ("list").get("id")));
subQ2.addMaximum ("listVer");
subQ2.setSelectionCriteria (sub2.get ("list").get ("id").equal (bldr.get ("list").get("list")).and (sub2.get ("stateCode").get ("code").equal (1)));
Expression exp1 = bldr.get("listVer").equal(subQ1);
Expression exp2 = bldr.get("listVer").equal(subQ2);
Each of the above expressions work fine independenty. However if I try to do some thing like,
exp1.or(exp2) I get very strange SQL generated and get SQL exceptions in code. The SQL it generates is
SELECT t0.ID, t0.VER, t0.STATE_CODE FROM LIST_VERSION t0 WHERE ((t0.VER = (SELECT MAX(t1.VER) FROM LIST t3, LIST t2, LIST_VERSION t1 WHERE ((t2.ID = t3.ID) AND ((t3.ID = t0.ID) AND (t2.ID = t1.ID))))) OR (t0.VER = (SELECT MAX(t4.VER) FROM LIST t5, LIST_VERSION t4, STATE_CODES t6 WHERE (((t5.ID = t3.ID) AND (t6.STATE_CODE = ?)) AND ((t6.STATE_CODE = t4.CODE) AND (t5.ID = t4.ID))))))
The problem occurs because the t3.ID in the second sub query is not correct. it should be t0.ID, but I can't figureout why this is happening. Any help or suggessions to achieve my objective?
Thanks
Bhaskar
Looking at your query that works at the bottom, I do not see any reason that you would need to include the Assignment table in the From list. Just use the same where clause in the form:
Where project.resources_maximum
> (Select Count(assignment.employee_ID)
From assignment
Where assignment.project_ID = project.project_ID
group by assignment.project_ID )
Similar Messages
-
Where clause problem with sub-queries in forms 6i
where is the best place to put a sub query?? I have been using the set block property, however when running a sub query an alternative method must be used. what are some other options?? I have tried to have the query directly in the data block property palette but to no avail...
There are 2 tables project and assignment
maximum resources cannot be exceeded therefore a count of employees
on the assignment table establishes that there are open spaces on the project.
This code Here is my code for my where clause on the data block
project.resources_maximum >
(Select Count(assignment.employee_ID)
From assignment
Where assignment.project_ID = project.project_ID
group by assignment.project_ID
and project.end_date>sysdate;
I was reading that the project table must be defined in the from clause
to have the query go row by row, otherwise multiple rows are returned
however I cannot define the project in the from,
could this be why this doesn't work???
original SQL that does work
Need to migrate this to forms
Select project.project_ID
from project
Where project.resources_maximum >
(Select Count(assignment.employee_ID)
From assignment
Where assignment.project_ID = project.project_ID
group by assignment.project_ID
and project.end_date>sysdate;Looking at your query that works at the bottom, I do not see any reason that you would need to include the Assignment table in the From list. Just use the same where clause in the form:
Where project.resources_maximum
> (Select Count(assignment.employee_ID)
From assignment
Where assignment.project_ID = project.project_ID
group by assignment.project_ID ) -
Problem with sub-screen actions on Cancel button
Hi all,
I have a problem with sub-screen.
I created a subscreen (screen sequence in MM01/MM02/MM03). When users leave this screen, I call POPUP_TO_CONFIRM to ask if they want to save the data.
1) My goal is: when they choose Cancel, no actions are performed and users will see the current screen. However, I cannot use command: SET SCREEN 0 or LEAVE TO SCREEN 0 because the system gives an error message:
*SET SCREEN not allowed in subscreens*.
2) How can we determine when the user leaves the screen? which value of SY-UCOMM will be used to check this?
Thanks in advance.for dis SET SCREEN is not required.
Consider d code given below as n eg:
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
titlebar = 'SAVE'
text_question = 'SOME _QUS'
text_button_1 = 'YES'
text_button_2 = 'NO'
default_button = '2'
display_cancel_button = ' '
IMPORTING
answer = l_ans
EXCEPTIONS
text_not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE e066.
ENDIF.
IF l_ans EQ '1'. " when yes is pressed
MODIFY db.
commit work.
leave program.
ELSEIF l_ans EQ '2'. "when no is pressed
leave program.
ELSE. " when cancel is pressed
ENDIF.
In above module when Yes is pressed it saves data den leave prog.
As no action is specified for cancel button it will remain on that screen only from which popup is called, in this way ur problem can be solved.
Reward properly. -
Can you pass parameters with sub queries
I have created a Custom folder within a Business Area using a sql query that has multi sub queries. I need to be able to pass date parameters at the top level and at each sub query levels. Is this possible, or how can it be done in Discoverer?
I have attached an example of the query below.
select T.title_type_code, T.title_number
from title_trans T
where T.title_type_code in ( 'A', 'AC', 'AN','AS','EL', 'ERL','SEL', 'MC', 'MCN', 'MCC', 'MCS', 'ML', 'MLN', 'MLC', 'MLS')
and T.trans_type_code = 'APPL'
and trunc(T.effective_date) between to_date('&start_date','DD/MM/YYYY') and to_date('&end_date','DD/MM/YYYY')
and exists
(select *
from title_land_status L
where T.title_type_code = L.title_type_code
and T.title_number = L.title_number
and L.trans_type_code in ('APPL', 'FLS', 'AVAR')
--FREEHOLD LAND
and L.land_status_id in ('15')
and L.date_completed = (select MAX(L.date_completed)
from title_land_status L
where T.title_type_code = L.title_type_code
and T.title_number = L.title_number
and trunc(L.date_completed) <= to_date('&end_date','DD/MM/YYYY')
and L.trans_type_code in ('APPL', 'FLS', 'AVAR')))
and not exists
(select *
from title_land_status L
where T.title_type_code = L.title_type_code
and T.title_number = L.title_number
and L.trans_type_code in ('APPL', 'FLS', 'AVAR')
--AB fREEHOLD LAND - NLC, CLC, TLC, ALC
and L.land_status_id in ('3', '4', '5', '6')
and L.date_completed = (select MAX(L.date_completed)
from title_land_status L
where T.title_type_code = L.title_type_code
and T.title_number = L.title_number
and trunc(L.date_completed) <= to_date('&end_date','DD/MM/YYYY')
and L.trans_type_code in ('APPL', 'FLS', 'AVAR')))
and not exists
(select * from title TIT
where T.title_type_code = TIT.title_type_code
and T.title_number = TIT.title_number
and TIT.purpose = 'EMPC')
order by T.title_type_code;Ok,
I just tried that and it still doesn't pass anything to the prompt.
I changed the prompt to an edit field and I made the following weblink but when i click the link from an account it doesn't put anything in the prompt and all data for all accounts is shown.
This is the URL maybe I messed something up...
https://secure-ausomx###.crmondemand.com/OnDemand/user/Dashboard?OMTHD=ShowDashboard&OMTGT=ReportIFrame&SelDashboardFrm.Dashboard Type=%2fshared%2fCompany_########_Shared_Folder%2f_portal%2f360+Report&Option=rfd&Action=Navigate&P0=1&P1=eq&P2=Account."Account Name"&P3=%%%Name%%%
thanks -
Problem with Join Queries using PHP and an Orcale Database
Ok, I am trying to build a simple php querying tool for my oracle database and for the most part it is working however I am having a problem getting data from my join queries. If I run the following query :
QUERY:
SELECT lastfirst,EnteredBy,Debit FROM students sts JOIN GLDetail gl ON gl.studentid=sts.id
RESULT SET:
Lastfirst EnteredBy Debit
caiu, test 204 1
But when I run the query correctly I get no results
QUERY:
SELECT sts.lastfirst,gl.EnteredBy,gl.Debit FROM students sts JOIN GLDetail gl ON gl.studentid=sts.id
RESULT SET:
sts.lastfirst gl.EnteredBy gl.Debit
and if I run the query combining the two above methods and adding a field (schoolid) that has the same name on both table I get the following result sets
QUERY:
SELECT lastfirst,EnteredBy,Debit,sts.schoolid FROM students sts JOIN GLDetail gl ON gl.studentid=sts.id
RESULT SET:
lastfirst EnteredBy Debit sts.schoolid
caiu, test 204 1
QUERY:
SELECT lastfirst,EnteredBy,Debit,schoolid FROM students sts JOIN GLDetail gl ON gl.studentid=sts.id
RESULT SET:
NONE
Therefore, I have to have something written incorrectly in my php code and I just can not figure it out. My entire code is pasted below please provide me with an assistance you might have to offer. I have change the odbc_connec line so I could post it to this forum. In addition, I had to phrase out the column headers there for when you write the column headers you have to use ~ instead of , as the separator and then I turn back into the correct format for sql.
//These scripts just open help windows if somone clicks on the icon
<script>
function submit()
{document.sqlform.submit();}
</script>
<script>
function colwin(){
window.open("colnames.php",null,"height=300,width=400,scrollbars=1");}
</script>
<script>
function tabwin(){
window.open("tablenames.php",null,"height=300,width=400,scrollbars=1");}
</script>
<script>
function help(){
window.open("http://www.w3schools.com/sql/default.asp",null,"height=500,width=700,scrollbars=1");}
</script>
<form method="post" action="<?php echo $PHP_SELF;?>" name="sqlform">
<?php
//Cookie to check for authorization to the site
if($_COOKIE['cookie']=="CheckCookieForAuth")
//These get the values of the textareas after the form has been submitted
$sqlSELECT = $_POST["SELECT"];
$sqlFROM = $_POST["FROM"];
$sqlJOIN = $_POST["JOIN"];
$sqlWHERE = $_POST["WHERE"];
$sqlOTHER = $_POST["OTHER"];
$sqlSELECTTYPE = $_POST["SELECTTYPE"];
//This is the variable used to parse out my headers the user entered
$sqlColNames = split('~',$sqlSELECT);
//This converts the ~ separator to , so I can actually use it as part of my sql string
$search = array('~');
$replace = array(',');
$mystring = $sqlSELECT;
$sqlString = str_replace($search, $replace, $mystring);
//These are the textareas and the drop down options that the end users has to create queries
echo "<table border=0>";
echo "<tr><td valign='top'>";
echo "<B>SELECT TYPE</B> <BR><SELECT NAME=SELECTTYPE>
<OPTION VALUE='SELECT' SELECTED>SELECT</OPTION>
<OPTION VALUE='SELECT DISTINCT'>SELECT DISTINCT</OPTION>
<OPTION VALUE='INSERT'>INSERT</OPTION>
<OPTION VALUE='UPDATE'>UPDATE</OPTION>
<OPTION VALUE='DELETE'>DELETE</OPTION>
</SELECT>";
echo "</td><td>";
echo "<textarea rows=2 cols=75 name=SELECT wrap=physical>$sqlSELECT</textarea>";
echo "</td><td valign='top'>";
echo "<img src='images/sqlC.jpg' width='25' height='25' onclick='colwin()'>";
echo "</td></tr>";
echo "<tr><td valign='top'>";
echo "<b>FROM</b>";
echo "</td><td>";
echo "<textarea rows=2 cols=75 name=FROM wrap=physical>$sqlFROM</textarea>";
echo "</td><td valign='top'>";
echo "<img src='images/sqlT.jpg' width='25' height='25' border=0 onclick='tabwin()'>";
echo "</td></tr>";
echo "<tr><td valign='top'>";
echo "<b>JOIN</b>";
echo "</td><td>";
echo "<textarea rows=2 cols=75 name=JOIN wrap=physical>$sqlJOIN</textarea>";
echo "</td></tr>";
echo "<tr><td valign='top'>";
echo "<b>WHERE</b>";
echo "</td><td>";
echo "<textarea rows=2 cols=75 name=WHERE wrap=physical>$sqlWHERE</textarea>";
echo "</td></tr>";
//This is where the end user would enter group by, having, order by, etc..
echo "<tr><td valign='top'>";
echo "<b>OTHER</b>";
echo "</td><td>";
echo "<textarea rows=2 cols=75 name=OTHER wrap=physical>$sqlOTHER</textarea>";
echo "</td></tr>";
This is a run query icon and a help icon
echo "<tr><td colspan=2 align=right>";
echo "<img src='images/RunQuery.jpg' width='30' height='28' onclick='submit()'> <img src='images/qm.jpg' border=0 width='25' height='25' onclick='help()'>";
echo "</td></tr></table>";
echo "<br>";
echo "<br>";
//This is where I connect to my remote oracle database
$conn=odbc_connect('ODBC_ConnectionName','USERNAME','PASSWORD');
//This is the sql string created by the end users
$sql="$sqlSELECTTYPE $sqlString FROM $sqlFROM $sqlJOIN $sqlWHERE $sqlOTHER";
//This executes the connection string and the sql string
$rs=odbc_exec($conn,$sql);
//This will display the query or a message if the query is empty
if($rs!=NULL){
echo "<table border=1>";
echo "<tr>";
//This loops through the string array the end user enter the field name text area to get column headers
for($i=0; $i<count($sqlColNames); $i++)
echo "<td>";
print_r($sqlColNames[$i]);
echo "</td>";
echo "</tr><tr>";
//This actually fetchs the rows from the statement and then display the data based on the column names the end user speificed
while (odbc_fetch_row($rs))
for($i=0; $i<count($sqlColNames); $i++)
$results=odbc_result($rs,$sqlColNames[$i]);
echo "<td>$results</td>";
echo "</tr>";
odbc_close($conn);
echo "</table>";}else{echo "Results will be displayed here";}
echo "<br><br>";
echo $sql;
else
echo "Not logged in";
?>
</form>This looks more like a SQL question than a PHP issue. There are a couple of JOIN examples at http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_10002.htm#i2066611 that might you work through the problem.
-
Problems with sub menus in Internet Explorer
My menu bars work great in Chrome and Firefox however my submenus are jacked up in Internet Explorer. Can someone please give me some direction? Thanks.
The website is www.aptyssolutions.comHave a look here http://www.dwcourse.com/dreamweaver/ten-commandments-spry-menubars.php#one
Then have a look at what you have got
BROWSER HACKS: the hacks below should not be changed unless you are an expert
/* HACK FOR IE: to make sure the sub menus show above form controls, we underlay each submenu with an iframe */
ul.MenuBarHorizontal iframe
position: absolute;
z-index: 1010;
filter:alpha(opacity:0.1);
/* HACK FOR IE: to stabilize appearance of menu items; the slash in float is to keep IE 5.0 from parsing */
@media screen, projection
ul.MenuBarHorizontal li.MenuBarItemIE
display: block;
f\loat: auto;
background:
and
/* Submenus should appear below their parent (top: 0) with a higher z-index, but they are initially off the left side of the screen (-1000em) */
ul.MenuBarHorizontal ul
margin: 0;
padding: 0;
list-style-type: none;
font-size: 100%;
cursor: default;
width: AUTO;
position: absolute;
left: -1000em;
top: 23px;
height: 35px;
background-image: url(/images/bluebar.png);
There is more, but the above is most likely what is causing the problem.
I suggest that you resurrect the original SpryMenuBarHorizontal.css and start again. -
Problems with BCS Queries Inconsistent Data
Hi BI Experts,
We recently had our BCS upgrade from 4.0 to 6.0 and BW upgrade from 3.5 to 7.0
We have created some consolidated queries and we didnt change them to 7.0 they are still in 3.5 version. The problem is that we are getting some inconsistent data every time we ran those queries.
The BWP is yet to under go upgrade process so we checked the data in BWP (3.5) production and BWD (7.0) this tells us that the data in the tables are right.
I ran the query in RSRT and gives inconsistent data.
We are on the support pack 10 for BCS and
support pack 14 for BI 7.0.Sorry guys....
I want to correct one statement up there ...when I run my queries with through RSRT i dont get any inconsistent data ..the data comes exactly the way we want ...the problem is only through the BEx.
Is it a upgrade bug or the support pack issue ..???
Your suggestions will be appreciated with lots of points
Thanks -
Problems with dynasight queries (Essbase goes fast)
Hi, we use dynasight tool to retrieve the data. The time of queries shown in app. window are fast, but we think dynaserver has problems, maybe in sharing the cache memory although this is up to 2 GB and essbase doesn't take more than 600 MbThanks a lot
Hello,in principle, the performance of dynaSight should be more or less identical to the performance you get from an equivalent query from within the Excel Add-In for example. Therefore, the performance problem is very likely due to the specific design of the dynaSight documents/screens.Please check the following:- hierarchy objects configuration:is 'request other levels when expanded' used for the vertical and horizontal hierarchy objects? Depending on the use and type of query this feature may speed up performance significantly.- are you using individual selections?If yes: are you using more than 99 members in an individual member selection (this is the limit on the Essbase Side: if you exceed that limit, dynaSight will query the complete hierarchy and filter out the selected members)- optimize the screens by for example consolidating multiple queries / database calls into one query / database call.=> these are just a few suggestions to look into. In general, I would strongly suggest to contact [email protected] and provide them with some application components and trace and log files so the design issues can be analysed and identified more specifically.Best RegardsAndreas [email protected] of Competence Center
-
Problems with sub-items and header attributes in complains
Hello Gurus!
I am relatively new to the enterprise services and I have a requirement to create a complain with one product and a child product (items 1000 and 1010) but I tried several ways the service and no matter what I do I always get 2 items without relationship between them. I have tried specifying the parent item ID during create (did not expect to work as parent has also not been created yet) and also tried the BusinessTransactionDocumentReference, but also did not work or did not use the content correctly, in the ES Workplace there is not much info about the possible values for this data segment and it's not returned when I read an existing complain (so I think it is not the way to go)
Finally, the question is... can I create a complain using the enterprise service CustomerComplaintCRMCreateRequ and with the header, item and subitem in the same step or must I create first and then update? (Like the manual process would be)
Thanks!Hi Milos,
If nothing at all has synchronized, I would first double check your connection settings and passwords.
If the synch appears to to be connecting correctly, you will need to look at the data that it is failing on.
The synch queue is the prx_transaction_queue table in the Business One database. The object_type column refers to a Business One object. 2 for business partner and 4 for items. The list_of_cols_val_tab_del is the key in the associated table. For business partners that is OCRD.CardCode and items OITM.ItemCode.
First determine that there is no bad data in the queue. Bad data is typically defined as null or empty strings in the list_of_cols_val_tab_del column.
Try running the following for business partners:
select *
from prx_transaction_queue
where object_type = 2 and (list_of_cols_val_tab_del is null or list_of_cols_val_tab_del = '')
And this for Items.
select *
from prx_transaction_queue
where object_type = 4 and (list_of_cols_val_tab_del is null or list_of_cols_val_tab_del = '')
If there are nulls or empty strings in the list_of_cols_val_tab_del column, delete them.
If not, take a look at the first records in the queue.
select top 1 *
from prx_transaction_queue
where object_type = 2
order by tmstmp
and for items:
select top 1 *
from prx_transaction_queue
where object_type = 4
order by tmstmp
Change the transaction_type to "X" (remember what is was, because you will need to change it back). Changing this value will remove the item from the synch.
Rerun the synch.
If it runs at this point, there is probably data in the records that the synch was not expecting. The business partner data will need to be examined. Tics in key values (CardCode, Address Name, contact name, itemcode) may cause problems.
If this is the case, you might want to contact support to try to track the problem down.
Another source of problems may be database collation. We can talk about that if none of the above works. -
Using CORR function with sub-queries
I need to compute the correlation of two datasets, however here is my problem:
The table stores responses to a questionnaire, with these columns:
RESPONSE_ID, QUES_ID, ANS_CD
What my query needs to get is the Correlation of 2 sets of ANS_CD, one with QUES_ID=x and one with QUES_ID=y. What I have looks like this:
SELECT CORR ((SELECT ans_cd
FROM fact_responses
WHERE ques_id=x) ,
(SELECT ans_cd
FROM fact_responses
WHERE ques_id=y)
FROM fact_responses
And i get a 'single row subquery returns more than one row' error. Can someone who has more experience with this help me out? I don't want to create a new table to store the data for this one reportThe short and sweet of it is that you are trying to correlate question x against question y. With three questions, you are looking for the correlation as such:
1,1
1,2
1,3
2,1
2,2
2,3
3,1
3,2
3,3
Is that correct? -
Problem with some queries after migration from MS Access
Hi everyone!
We've just finished a migration from a MS Access database and we notice some errors when running some queries like :
Query1:
SELECT A.field1, A.field2, B.field1 as FieldTmp
FROM A,B
where (B.field1 <=10);
Query2:
SELECT Query1.field1, Query1.field2, Query1.FieldTmp
FROM Query1 LEFT JOIN Table3
ON (Table3.field1 = Query1.Field2) AND
(Table3.field5 = Query1.FieldTmp)
WHERE ((Table3.field5) Is Null)
ORDER BY Query1.field1, Query1.FieldTmp;
The Query1 runs as expected, but when I try to run the Query2 I got a ORA-00904 error message. If I remove the (Table3.field5 = Query1.FieldTmp) statement or modify to compare with another field (as instance, field2) everything goes fine.
If I modify the first query to a make-table query, the Query2 request runs as desired too.
Is there anything that we can do to keep the queries statement as it is when using the MS Access DB?
Thanks in advance,
Elaine Viel DenadaiHi Turloch! Thanks for your help!
Those SQL Statements were extracted from the MS Access application that we will continue to use to access the data , now on an Oracle Database.
I don't know what I can do to make this kind of statements works as it is on Access database. The first query, that I called Query1 works fine on Oracle, I just mentioned it because the 2nd Query , named Query2, use it.
I'm not able to understand why when I change the 1st. query to a "make-table" query the Query2 works as desired, but if I keep the Query1 and Query2 as it is on the MS Access Application I got the ODBC error message and the ORA-00904 error message , related (I think!) to the FieldTmp field used on the LEFT JOIN statement (AND).
As I told before, if I change the AND clause to compare to another field, as instance, field1 :
FROM Query1 LEFT JOIN Table3
ON (Table3.field1=Query1.Field2) AND
(Table3.field5 = Query1.Field1)
it works.
Please, is there anything that I can do to keep the MS Access Application unchanged?
Oracle = 8.1.6
Oracle ODBC Driver = 8.1.6.4
Oracle Migration Workbench = 1.3.1
Thanks in advance,
Elaine Viel Denadai -
Dear Friends,
I have written the below select queries to get the shipment details for a given date range.
select vbeln lddat
into table itab
from likp
where lddat in l_r_date2 .
if not it_ldt[] is initial.
select fknum fkpos rebel
into table jtab
from vfkn
for all entries in itab
where
rebel = itab-vbeln.
endif.
First query is giving 82000 entries and second query is giving approx 60000 from the table VFKN( total entries in this table are 8 lakhs).
Here the problem is second select query(for all entries select query) is taking a time of 3 to 4 hours.
So please suggest me how can i reduce the time.
Thanks and RegardsHi,
Use FREE or PACKAGE size.
Some steps that might make FOR ALL ENTRIES more efficient:
Removing duplicates from the driver table Sorting the driver table
If possible, convert the data in the driver table to ranges so a BETWEEN statement is used instead of and OR statement:
FOR ALL ENTRIES IN i_tab
WHERE mykey >= i_tab-low and
mykey <= i_tab-high.
Regards
Krishna -
Problem with sub totals ALV Grid
Hi experts,
I got one requirement, I am using ALV GRID function modules technique. My requirement is, I want to display one value at subtotal line(i.e. like header value). How to display the table values in the subtotal line.
Please give any solution for this.
Thanks in advance.
Sandya.Hi Sandhya,
i will send a sample code for ur problem.And also i will send a entire program about subtotals.Check it once ok..Copy the below prog and execute it and debug it..
*SubTotal on the Field NETWR
wa_fieldcat-tabname = 'IT_SALESORDER'. "Internal
wa_fieldcat-fieldname = 'NETWR'. "Field Name
wa_fieldcat-do_sum = 'X'. "Sum
APPEND wa_fieldcat TO gt_fieldcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
i_callback_program = sy-repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT =
it_fieldcat = gt_fieldcat
SAMPLE PROGRAM:
*& Report YSALESORDER_ALV_SUBTOTALS *
*& DEVELOPER : KIRAN KUMAR.G *
*& PURPOSE : DISPLAYING SUBTOTALS FOR A PARTICULAR SALES DOC NO *
*& CREATION DT: 26/11/2007 *
*& REQUEST : ERPK900035 *
REPORT ysalesorder_alv_subtotals.
Type Pools
TYPE-POOLS:slis.
Tables
TABLES: vbak, "Sales Document: Header Data
vbap. "Sales Document: Item Data
Global Structures
DATA:gt_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE slis_fieldcat_alv,
gt_sortcat TYPE slis_t_sortinfo_alv,
wa_sortcat LIKE LINE OF gt_sortcat.
Internal Table
DATA: BEGIN OF gt_salesorder OCCURS 0,
vbeln LIKE vbak-vbeln, " Sales Document Number
posnr LIKE vbap-posnr, " Sales Doc Item
netwr LIKE vbap-netwr, " Net Value
END OF gt_salesorder.
SELECT OPTIONS
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_vbeln FOR vbak-vbeln. " Sales Document Number.
SELECTION-SCREEN END OF BLOCK b1.
Initialization
INITIALIZATION.
PERFORM initialization.
Start Of Selection
START-OF-SELECTION.
PERFORM field_catalog. "For Structure Creation
PERFORM fetch_data. "Get the Data From DB Table
PERFORM sorting USING gt_sortcat.
End Of Selection
END-OF-SELECTION.
PERFORM display_data.
*& Form initialization
text
--> p1 text
<-- p2 text
FORM initialization .
s_vbeln-sign = 'I'.
s_vbeln-option = 'BT'.
s_vbeln-low = '4969'.
s_vbeln-high = '5000'.
APPEND s_vbeln.
ENDFORM. " initialization
*& Form field_catalog
text
--> p1 text
<-- p2 text
FORM field_catalog .
REFRESH : gt_fieldcat.
CLEAR : wa_fieldcat.
wa_fieldcat-col_pos = '1'. "Column Position
wa_fieldcat-tabname = 'IT_SALESORDER'. "Internal Table
wa_fieldcat-fieldname = 'VBELN'. "Field Name
wa_fieldcat-key = 'X'. "Blue Color
wa_fieldcat-seltext_m = 'Sales Doc No'. "Display Text In Screen
APPEND wa_fieldcat TO gt_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '2'. "Column Position
wa_fieldcat-tabname = 'IT_SALESORDER'. "Internal Table Name
wa_fieldcat-fieldname = 'POSNR'. "Field Name
wa_fieldcat-seltext_m = 'Sales Doc Item'."Display Text In Screen
APPEND wa_fieldcat TO gt_fieldcat.
CLEAR wa_fieldcat.
*SubTotal on the Field NETWR
wa_fieldcat-col_pos = '3'. "Column Position
wa_fieldcat-tabname = 'IT_SALESORDER'. "Internal Table
wa_fieldcat-fieldname = 'NETWR'. "Field Name
wa_fieldcat-do_sum = 'X'. "Sum
wa_fieldcat-seltext_m = 'Net Value'. "Display Text In Screen
APPEND wa_fieldcat TO gt_fieldcat.
CLEAR wa_fieldcat.
ENDFORM. " field_catalog
*& Form sorting
text
-->P_IT_SORTCAT text
FORM sorting USING p_it_sortcat TYPE slis_t_sortinfo_alv.
CLEAR wa_sortcat.
wa_sortcat-fieldname = 'VBELN'.
wa_sortcat-up ='X'.
wa_sortcat-subtot = 'X'.
APPEND wa_sortcat TO p_it_sortcat.
ENDFORM. " sorting
*& Form display_data
text
--> p1 text
<-- p2 text
FORM display_data .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
i_callback_program = sy-repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT =
it_fieldcat = gt_fieldcat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
it_sort = gt_sortcat
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
I_HTML_HEIGHT_TOP =
I_HTML_HEIGHT_END =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = gt_salesorder
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " display_data
*& Form fetch_data
text
--> p1 text
<-- p2 text
FORM fetch_data .
REFRESH : gt_salesorder.
CLEAR : gt_salesorder.
SELECT a~vbeln
posnr
b~netwr
FROM vbak AS a
INNER JOIN vbap AS b ON avbeln = bvbeln
INTO TABLE gt_salesorder
WHERE a~vbeln IN s_vbeln.
ENDFORM. " fetch_data
Reward points if helpful.
Kiran Kumar.G.A
Have a Nice Day.. -
Hello, I am attempting to create a sub query to display certain information. On the form that the information is inputted, the user has the option of inputting a phone number extension if applicable. If this is the case I want the phone number to show as 555-867-5309 (x1234). However without the problem checks, the (x ) will show up regardless and looks sloppy. Here is the code I have, please advise.
There will be two spots this will be needed -- for the requester's contact number and the app manager (sme) contact information.
Thanks.
select
pm.pk_proj_master_id "Project Number",
pm.trackit_work_order "TrackIt Work Order",
pm.name "Project Name",
pm.status "Project Status",
req.last_name||', '||req.first_name||', '||req.middle_initial||'.' "Requestor Name",
rde.department_group_descr "Requestor Department Name",
req.department_descr "Requestor Division Name",
pm.requester_ext,
case
when pm.requester_ext in
select
pm.requester_phone|| '(x'||pm.requester_ext ||')' "Requesters Number"
from
protrac_master pm
where
pm.requester_ext is not null
else
select
pm.requester_phone "Requesters Number"
from
protrac_master pm
end as "Requester Number",
man.last_name||', '||man.first_name||', '||man.middle_initial||'.' "SME Name",
mdg.department_group_descr "SME Department Name",
man.department_descr "SME Division Name",
pm.app_manager_ext,
case
when pm.app_manager_ext in
select
pm.app_manager_phone|| '(x'||pm.app_manager_ext ||')' "SME Number"
from
protrac_master pm
where
pm.app_manager_phone is not null
else
select
pm.app_manager_phone "SME Number"
from
protrac_master pm
end as "Requester Number",
pm.createby_date "Date Entered",
pm.date_begin "Date Began",
pm.date_completed "Date Completed",
pm.estimated_date "Estimated Completion Date"
from
protrac_master pm,
cobr.vw_pps_payroll req, cobr.department_group rde,
cobr.vw_pps_payroll man, cobr.department_group mdg
where
pm.requester_id = req.emple_no and
pm.requester_dept_id = rde.pk_department_group_id and
pm.app_manager_id = man.emple_no and
pm.app_manager_dept_id = mdg.pk_department_group_id
order by
pm.pk_proj_master_idI think you can avoid the whole sub query thing just by using the NVL2 function:
select ...
, NVL2( pm.requester_ext
, pm.requester_phone|| '(x'||pm.requester_ext ||')'
, pm.requester_phone) "Requesters Number"
, NVL2( pm.app_manager_ext
, pm.app_manager_phone|| '(x'||pm.app_manager_ext ||')'
, pm.app_manager_phone) "Manager Number"
from protrac_master pm
, ... -
Hallo,
I have two tables: table1 and table2.
Table1 has a column str with datatype varchar2 and table2 has a column str_schl also with varchar2. In table1 is a list with all str and there in the list is every str only once listed. In table2 I have about 100000 records. Each record has a str_schl out of the range(str) of table1. So in table2 can be records that have the same str_schl. In table1 I have also a ref-column str_ref there I wanted to store the reference of str_schl out of table1. And this I wanted to achieve with a subselect but it does not work. Whats wrong?
update table1 g set g.str_ref=(select ref(s) from table2 s where s.str_schl=g.str);
ERROR at line 1:
ORA-01427: single-row subquery returns more than one row
ThanksHi,
In you case the subquery must always return exactly one row. As you said in table2 you have records which have the same str_schl so the subquery will not return always one row.
Regards,
Adi
Maybe you are looking for
-
Buttons not working in jTree cells
I have modified the defaultTreeCellRenderer to include a jButton and a Label on certain cells. Unfortunately I cannot click on the button. Clicking the button selects that row in the tree, which is fine, but it doesn't send the action on to the butto
-
Select from 4 tables but include data from 3 even if 4th is null
Hello - I'm quite new to oracle and apex, but enjoying learning - but sometimes I need a gentle nudge to know what I need to learn about. I have a select statement that works - selecting specific columns from 3 tables: SELECT "TERRITORIES"."TER_NAME"
-
I am at wits end... I have tried every solution to get the add-ons manager to load and nothing has worked. If you might know of a solution please let me know. I am running Firefox 11, Windows 7 and I have checked for and updated a plug-in. I even cli
-
You can put a html linked externally as the muse adobe indesign goes with? thanks,
-
Mail is unable to connect to the internet???
Mail has been working intermittently for the past couple of weeks, sometimes it worked perfectly for a while and suddenly for no apparent reason it would stop. I would be unable to send or receive mail, except from mac.com. At that time I was running