SAP Query: Duplicte records after joining table CSKT
Guru's,
We have created a query in SQ02 for Z table which has fields with KOKRS and KOSTL as well.
Ztable fields:
PLAN_TYPE
PLAN_PROCESS
KOKRS
KOSTL
We want to display cost center description. SO joining this Z table with CSKT(KOKRS,KOSTL). We are getting duplicate records in output because CSKT has duplicate KOSTL.To solve this, we want fetch Latest KOSTL comparing DATBI GE SY-DATUM.
Can anybody help us how to code this logic in Query. I have gone thru most of the SDN threads but could not find the answer.
Please help us.
Thanks in Advace.
Shreyansh
Moderator message - Duplicate post locked
Similar Messages
-
Creation of SAP Query in SQ02 with Single Table With Condition
Hi All,
I want to Create SAP Query in SQ02 using single Table MCHA.
ii) I dont want all entries of MCHA Table I mean , I have to apply some Condition on this Table.
i.e Suppose I am having actual data in MCHA table is like this for Material M1.
Plant Material Batch BatchCreationdate
P1 M1 B1 20.06.2007
P2 M1 B1 04.05.2009
P3 M1 B1 04.05.2009
But I want the Output of SAP Query is like this:
Material Batch BatchCreationdate
M1 B1 20.06.2007
That is irrespective of Plant if Material & Batch are equal ---> 1st record with Lowest date shoud get at the output.
Please help me How write the code on single table in the SAP Query.
Thanks,
Kiran ManyamHi,
Your query should be like this:
Select MATNR CHARG HSDAT
from MCHA
into table t_mcha
where matnr = Materlal number from selection screen.
The structure of t_mcha should contain the fields that you select.
Then sort the table by date ascending
Sort t_mcha by HSDAT.
Hope this solves your problem.
Thanks,
Sowmya -
In SQ02 after joining table if we want write condition on other field how ?
In SQ03 after joining table if we want write condition on some fields
for filtering records then what is the procedure.Please check forum subject. This is not a right forum for your question. Close your thread and post it on a proper forum.
Thanks,
Gordon -
SAP QUERY/INFOSET with OUTER JOIN
Hi,
I have created an infoset (SQ02) using two tables for SAP query.
Table: AGR_TEXTS. Fields: AGR_NAME, SPRAS, LINE, TEXT.
TABLE: AGR_FLAGS. Fields: AGR_NAME, FLAG_TYPE, FLAG_VALUE.
Joined these two tables using outer join. Defined the join condition as AGR_NAME = AGR_NAME. Saved and Generated the infoset.
Created SAP Query (SQ01) using the above created infoset.
In the basic list,
Marked AGR_NAME (AGR_TEXTS), TEXT, FLAG_VALUE as listed fields.
Marked AGR_NAME (AGR_TEXTS), SPRAS, LINE, FLAG_TYPE as selection fields.
Save the query. When execute the query provided the inputs for all the selection fields in the selection screen as given below:
AGR_NAME=Z*
SPRAS=E
LINE=00000
FLAG_TYPE=LICENSE_01
Executed the Query.
Got the results only the matched records as per the selection field FLAG_TYPE.
But I want all the records from table AGR_TEXTS and matched records from table AGR_FLAGS.
I want the report (output) as below,
_AGR_NAME TEXT FLAG_VALUE_
ZCA_BASIC_ACCESS_GLOBAL Non-critical basic access for all users. 53
ZCA_BASIC_ENDUSER_ACCESS UK:CA Basic Enduser Access
ZCA_BASIC_ENDUSER_ACCESS_UK UK:CA Basic Enduser Access UK 52
ZCA_BASIC_ENDUSER_SU52_UK UK:CA Basic Enduser Access to change Parameter ID's
But I got the report (output) as below,
_AGR_NAME TEXT FLAG_VALUE_
ZCA_BASIC_ACCESS_GLOBAL Non-critical basic access for all users. 53
ZCA_BASIC_ENDUSER_ACCESS_UK UK:CA Basic Enduser Access UK 52
Apprecited your help. Thanks.
Code Formatted by: Alvaro Tejada Galindo on Dec 30, 2009 2:20 PMIdentify a KF for which there are non-zero values for all accounts in the cube.
Create the query with Account (from MP coming from both IO and cube) and this KF. KF will have 0 values for accounts not existing in the cube. Create a condition to show only the 0 value for the KF. This should show you all the accounts in the IO which are not in the cube. -
SAP QUERY using ASSHR and ASSOB tables
We currently have SAP query that reports on additional payments (Info type 0015). The user wants to report the cost center held on the cost assignment (Tables ASSOB and ASSHR).
The existing query uses infoset created using PNP logical database.
How do I add or join the ASSOB and ASSHR tables to Info type 0015 to report the cost center?
Thanks in advance
ShamshudinHi Sham
You may need to create custom fields in the infoset and create some code to pull out and display details from ASSHR and ASSOB corresponding to the ifnotype record. -
SAP Query PNPCE LDB with additional table.
Hi ABAP Gurus,
I am developing a SAP Query.
I have created an infoset with the custom infotype 9050 and added the table ZPA9050 into the Infoset.
The fields of ZPA9050 is not available as selection fields when I try to Query through SQ01.
(How do I input values to the ZPA9050 fields? A checkbox for making a Selection field is not available in the Query (SQ01).
For every pa9050 entry there exist multiple records of ZPA9050. I need to display the pa9050 fields in the 1st row and the corresponding zpa9050 fields in the subsequent rows.
What needs to be done in order to get them as Selection fields (Input Fields)
A quick reply is highly appreciated.
Useful answers will be rewarded.
Thanks
PradeepHello,
at the time of cretaing INFOSET using transaction SQ02. You can click on the Extra button nad than on the selection tab to add some fields on the selection screen.
Reward if useful
Mohit -
SAP Query not generated after upgrade
Hi All,
Our client has upgraded from 4.6c to ECC 6.0
In the upgraded server some SAP Queries have not been generated and others have generated. I wanted to know why all are not generated .
I also wanted to know if any table name exists which maintains query with generated program name
Please let me know your learnings on SAP Query if any
Thanks in advanceThese generated program names are stored in AQLDB for local area and AQGDB for global area. Usually these program names will include the infoset names and the query names.
-
Sap query not working after Upgradtion
Hi Experts,
We have recently done up gradation from 4.6 to Ecc 6.0. Since then my Sap query are not working.
Please help how to fix the issue.
Thanks in Advance for your support and time.Hi,
Do you have any custom indexes for tables in the affected queries that were deleted as part of the upgrade? (ones that didn't exist in the customer namespace? - something working looking into)
Regards,
Ryan Crosby -
Folks,
I have created a query which gives me a list with all open deliveries based on a certain route and postal code. We have multiple deliveries for the same ship-to so the list may show duplicate postal codes. I would like to have a list with only unique postal codes. How can this be achieved in SAP query?
Thanks,
MdZhi,
you can include the logic for unique postal code in Sq02 transaction.
goto sq02 transaction ,give your infoset name ,change,click on extras button in app tool bar .
there you have a button called code where you can incorporate your logic. -
Oracle Stored Procedure's TYPE IS RECORD for join table columns
Hi there,
I'm trying to use the type is record to setup all my output columns; However, these columns are joined from 2 or more tables. i.e.,
TYPE my_rec IS RECORD (
myColumn1 varchar2(50),
myColumn2 varchar2(20)
where myColumn1 is slected from a join of table1 and table2, and myColumn2 is selected from a join of table2 and table3.
as I tried to exec mySP, I got the error:
wrong number or types of arguments in call to 'mySP'
I know it is not "wrong number of arguments", but I don't know why these columns are wrong types? though I had TO_CHAR the new myColumn1 and myColumn2, I'm wondering if I should use %TYPE instead. If so, how do I do?
Meanwhile, I think it may help if I post the code here:
===========================================
create or replace package PHAStatusRpt is
type pha_type is record(
name varchar2(50),
pha_start varchar2(12),
current_step varchar2(50),
dates varchar2(25),
last_status varchar2(20)
pha_rec pha_type;
procedure PHAStatusData(ret_parm OUT pha_type);
end PHAStatusRpt;
create or replace package body PHAStatusRpt is
procedure PHAStatusData(ret_parm OUT pha_type) is
BEGIN
SELECT name,
TO_CHAR(DECODE(NVL(current_pha_step_name,'~'),'~',last_pha_date,current_pha_start),'mm/dd/yyyy') pha_start,
DECODE(NVL(current_pha_step_name,'~'),'~','Complete',current_pha_step_name) current_step,
DECODE(NVL(current_pha_step_name,'~'),'~',TO_CHAR(last_pha_date,'mm/dd/yyyy'),pp_date) dates,
DECODE(NVL(current_pha_step_name,'~'),'~',null,last_pha_status) last_status
INTO pha_rec
FROM (SELECT pfeed_name||' ('||TO_CHAR(pfeed_dob,'mm/dd/yyyy')||')' ||'('||SUBSTR(pers_ssn,5,4)||')' name,
current_pha_start,
current_pha_step_name,
last_pha_date,
last_pha_status,
TO_CHAR(pp.start_date,'mm/dd/yyyy')||'-'||NVL(TO_CHAR(pp.end_date,'mm/dd/yyyy'),'n/a') pp_date
FROM v_pers_unit pu, personnel_readiness pr, person_processes pp
WHERE pu.pers_pers_id=pr.pers_id AND pr.current_pha_step_pp_id=pp.pp_id(+) AND cmdstr_cs_id=95990)
ORDER BY name;
end PHAStatusData;
end PHAStatusRpt;
SQL> exec phastatusrpt.phastatusdata
BEGIN phastatusrpt.phastatusdata; END;
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'PHASTATUSDATA'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
============================================
Thanks in advance,
SCcase closed. I found the answer.
-
HELP needed to write a function returning 1 record from join tables
Hi,
I would like to have some help to write a function so It can return 1 result.
I post my question in the APEX Express sextion but I think it's belong here.
Mount Points and Home Directory
Also, can I move a thread in another forum?
thanks
Roseline
Edited by: user8772975 on 2009-09-19 21:43ok, I think I started to understand the functions. But I still can't figured out
CONTEXT
We are scanning pages and images from different newspaper. All the .tif, .jpg are on DVDs.
I'm trying to build a search page who will allow for all DVDs and All images name related to the search result. Let say I search for:
FIGARO
I have this SQL query and I want to make a function that will return the same thing as:
select
"DOSSIER"."ID" as "DOSSIERID",
"DOSSIER"."TITLE" as "TITLE",
"DVD"."ID" as "DVDID",
"DVD"."NAME" as "DVDNAME",
"DVD"."ID_DOSSIER" as "DVD_ID_DOSSIER",
"ELEMENTS"."ID" as "ELEMENTSID",
"ELEMENTS"."NAME" as "ELEMENTSNAME",
"ELEMENTS"."ID_DVD" as "ELEMENTS_ID_DVD"
from "DOSSIER" "DOSSIER",
"DVD" "DVD",
"ELEMENTS" "ELEMENTS"
where "DVD"."ID_DOSSIER"="DOSSIER"."ID"
and "ELEMENTS"."ID_DVD"="DVD"."ID"
and "DOSSIER"."TITLE" = :P3_SEARCH
ORDER BY "DVD".NAMEBasiccly, We are scanning pages and images from different newspaper. All the .tif, .jpg are on DVDs.
So we have someting like that:
TITLE: FIGARO
DVD: C2008-203
Elements: 12l10201.tif, 12l10202.tif, 12l11101.tif, 12l11102.tif, 12l11201.tif
12l11202.tif, 12l12101.tif, 12l12102.tif
DVD C2008-204
Elements: 12l12202.tif, 12l13101.tif, 12l13102.tif, 12l13201.tif, 12l13202.tif,
12l14101.tif, 12l14102.tif, 12l14201.tif, 12l14202.tif, 12l15101.tif,
12l15102.tif, 12l15201.tif
DVD: C2008-205
Elements: 12l15202.tif, 12l16101.tif, 12l16102.tif, 12l16201.tif, 12l16202.tif,
12m01101.tif, 12m01102.tif, 12m01201.tifBased on what people on the forum told me, I now know that I have to use Pl/SQL so I have to write a function that will return the same thing as the prvious query.
Is that exact?
Based on this example,
[http://plsql-tutorial.com/plsql-functions.htm|http://plsql-tutorial.com/plsql-functions.htm]
I would write something like:
CREATE FUNCTION my_super_function
RETURN VARCHAR(2000);
IS
details VARCHAR(2000);
BEGIN
select
"DOSSIER"."ID" as "DOSSIERID",
"DOSSIER"."TITLE" as "TITLE",
"DVD"."ID" as "DVDID",
"DVD"."NAME" as "DVDNAME",
"DVD"."ID_DOSSIER" as "DVD_ID_DOSSIER",
"ELEMENTS"."ID" as "ELEMENTSID",
"ELEMENTS"."NAME" as "ELEMENTSNAME",
"ELEMENTS"."ID_DVD" as "ELEMENTS_ID_DVD"
from "DOSSIER" "DOSSIER",
"DVD" "DVD",
"ELEMENTS" "ELEMENTS"
where "DVD"."ID_DOSSIER"="DOSSIER"."ID"
and "ELEMENTS"."ID_DVD"="DVD"."ID"
and "DOSSIER"."TITLE" = :P3_SEARCH
RETURN details;
END;
/ And then, use soemthing like:
select my_super_function("DOSSIER"."ID") from "DOSSIER" "DOSSIER" where "DOSSIER"."TITLE" = :P3_SEARCHI'm kinda of lost. I spent the last 6 hours but I think that programming is a working progress.
Any hint would be appreciated,
thanks
Roseline -
Query for records on single table
Hi experts,
I have table as below.
ID
DATE
BALANCE
1
1-Sep-13
50
2
1-Sep-13
60
3
1-Sep-13
65
4
1-Sep-13
70
5
1-Sep-13
40
6
1-Sep-13
35
1
2-Sep-13
55
2
2-Sep-13
65
3
2-Sep-13
45
4
2-Sep-13
75
5
2-Sep-13
45
6
2-Sep-13
30
1
3-Sep-13
78
5
3-Sep-13
86
6
3-Sep-13
75
Now I want to select ID's which are not in '3-Sep-13' and in '2-Sep-13' or '1-Sep-13' .
can any one help me out?Thej wrote:
Hi experts,
I have table as below.
ID
DATE
BALANCE
1
1-Sep-13
50
2
1-Sep-13
60
3
1-Sep-13
65
4
1-Sep-13
70
5
1-Sep-13
40
6
1-Sep-13
35
1
2-Sep-13
55
2
2-Sep-13
65
3
2-Sep-13
45
4
2-Sep-13
75
5
2-Sep-13
45
6
2-Sep-13
30
1
3-Sep-13
78
5
3-Sep-13
86
6
3-Sep-13
75
Now I want to select ID's which are not in '3-Sep-13' and in '2-Sep-13' or '1-Sep-13' .
can any one help me out?
Is the column you show as "DATE" really named "DATE"? If so, that's A Bad Thing (tm). Never use reserved or key words as object names. It should have a descriptive name, like CLOSING_DATE, or whatever is appropriate in the context of the application.
Second, what is the data type of your DATE column? It better be DATE. If not, you are starting from a very bad design. In any event, the solution will depend on the data type. -
SAP QUERY(SQ03/02/02) - how to join tables
Hi MM Wizards,
I would like to know how to join tables EINE & A017 through SAP Query?
Thanks,
KaveriHi Kaveri,
A017 is a pooled table. SAP Query does not support joins against Pooled tables. You should stick to transparent tables if you want to use Query.
You can do a direct read of A017, but you will just end up with a glorified SE16 display.
You could have a programmer write some ABAP and place it into the 'extras' section in SQ02 to grab the additional data that you want, but once you have decided to enlist the aid of an ABAPer, it is better just to write a custom Z program from scratch.
Regards,
DB49 -
Hi,
I badly need your help..
How can I link Table LIPS to VBEP using SAP QUERY? I have join these two tables using key field VGBEL = VBELN and VGPOS=POSNR but database access takes too long..
I need to get Schedule line delivery date(VBEP- EDATU ) where ETENR = '0001' only.
Please help me!
Thanks!Hi ,
get VBFA also in this loop ? or else search for LDB.
check LDB <b>ALV</b>
Regards
Prabhu
Message was edited by: Prabhu Peram -
Infoset data grouping for SAP Query
Hi,
I'm pretty new to SAP R/3 (4.7) and have a query that I think relates to Infoset rather that SAP Query.
I have two tables to join but the right hand table (it's a left outer join), needs to be summarised to reduce to unique records on each side of the join. In SQL Plus I would use a 'Group by' to perform this function .. is there a simple way to do this when building the Infoset ?
I am not an ABAP programmer, nor do I have access to ABAP so would prefer not to go down this route unless it's the only way.
Any assistance would be appreciated.Hi Guys,
Any ideas?
Maybe you are looking for
-
Why won't my ipad work after installing iOS 6???
I upgraddd to iOS 6 on my ipad 2, and got as far as signing into my yahoo in order to include icloud, etc, and it kept timing out. Eventually, it allowed me to skip that step, but I can't do anything with it anymore. I got the Ipad so I wouldn't ha
-
How do i download a movie from my sony handy cam to my macbook pro
how do i download a movie from my sony handycam to my macbook pro
-
Imported old family video, I seperated different events and named each event, how can I save event to put together in a menu like family, vacation, christmas to make a DVD
-
"Add to existing album" is missing in Photos app
The Photos app on my iPad 2 gives me the option to add photos from the Camera Roll to a new album, but there is no "Add to existing album" option. I know it should be there because I've used it before, and I can still see it on my iPhone 4. But it
-
Trying to sync photos to new 80GB Classic. I get the following error message "itunes cannot sync photos to the ipod "ipod name" because the folder "my pictures" cannot be found." I coincidentally got a a new computer a week ago and I get the same err