I want to retrive data from KNVP table but it shows records in miss order.
Hello all,
I have written following query.
SELECT KPKUNNR KPKUNN2
INTO corresponding fields of table I_KUNZJ
FROM KNVP AS KP
WHERE KP~PARVW = 'ZJ'
AND KP~KUNN2 = 'C0100' .
KNVP table having following customers for my condition:-
Kunnr
100510
1150010
1166835
But it shows records in following order:-
Kunnr
1150010
100510
1166835
So it shows 1st record = 1150010 instead of 100510. I want to show 1st record as 100510. Can any one please tell me why it shows such miss order.
customers::Kunnr
100510
1150010
1166835
Actually I want to select 1st record only and insted of 100510 it shows 1150010 kunnr.
SELECT KUNNR KUNN2
INTO corresponding fields of table I_KUNZJ
FROM KNVP
up to 1 rows
WHERE PARVW = 'ZJ'
AND KUNN2 = 'C0100' .
Becoz
In KNVP table customers are in following order:-
Kunnr
100510
1150010
1166835
But after selection it shows records in following order:-
Kunnr
1150010
100510
1166835
Edited by: megha waykar on Jan 11, 2008 8:38 AM
Similar Messages
-
Hi ,
I have two tables, we want to retrive data from both the tables please see example below
Table 1
A B X Y Z
1 2
Table B
A B C
1 2 5
1 2 6
1 2 7
I want output like
A B C
1 2 5
Null Null 6
Null Null 7
Regards
Message was edited by:
rajib.sarkarCould you explain the logic behind that?
-
Retrive data from 4 tables without using joins
hi ,
i have to retrive data from 4 tables........but i donot want to use joins because of performance issues.
please guide me how to proceed further ?
thankshi manish,
CONSTANTS: c_act_plan(2) TYPE c VALUE 'U1' ,
c_person(1) TYPE c VALUE 'P' ,
p1_betid(8) TYPE c VALUE '50005316',
c_topdown(1) TYPE c VALUE 'A' ,
c_admnby(3) TYPE c VALUE '032' ,
c_bet_type(1) TYPE c VALUE 'Q' ,
c_firmed(1) TYPE c VALUE '1' ,
c_subtyp_mail(4) TYPE c VALUE '0001' .
TYPES: BEGIN OF ty_hrp1001,
objid TYPE hrp1001-objid,
END OF ty_hrp1001,
BEGIN OF ty_pa0001,
pernr TYPE pa0001-pernr,
subty TYPE pa0001-subty,
objps TYPE pa0001-objps,
sprps TYPE pa0001-sprps,
endda TYPE pa0001-endda,
begda TYPE pa0001-begda,
seqnr TYPE pa0001-seqnr,
werks TYPE pa0001-werks,
gsber TYPE pa0001-gsber,
btrtl TYPE pa0001-btrtl,
END OF ty_pa0001,
BEGIN OF ty_t500p,
persa TYPE t500p-persa,
name1 TYPE t500p-name1,
END OF ty_t500p,
BEGIN OF ty_t001p,
werks TYPE t001p-werks,
btrtl TYPE t001p-btrtl,
btext TYPE t001p-btext,
END OF ty_t001p,
BEGIN OF ty_pa0002,
pernr TYPE pa0002-pernr,
subty TYPE pa0002-subty,
objps TYPE pa0002-objps,
sprps TYPE pa0002-sprps,
endda TYPE pa0002-endda,
begda TYPE pa0002-begda,
seqnr TYPE pa0002-seqnr,
nachn TYPE pa0002-nachn,
vorna TYPE pa0002-vorna,
END OF ty_pa0002,
BEGIN OF ty_pa0105,
pernr TYPE pa0105-pernr ,
subty TYPE pa0105-subty ,
objps TYPE pa0105-objps ,
sprps TYPE pa0105-sprps ,
endda TYPE pa0105-endda ,
begda TYPE pa0105-begda ,
seqnr TYPE pa0105-seqnr ,
usrid_long TYPE pa0105-usrid_long,
END OF ty_pa0105,
BEGIN OF ty_output,
pernr TYPE pa0002-pernr ,
werks TYPE pa0001-werks ,
gsber TYPE pa0001-gsber ,
btrtl TYPE pa0001-btrtl ,
name1 TYPE t500p-name1 ,
btext TYPE t001p-btext ,
nachn TYPE pa0002-nachn ,
vorna TYPE pa0002-vorna ,
usrid_long TYPE pa0105-usrid_long,
END OF ty_output.
DATA: w_hrp1001 TYPE ty_hrp1001,
t_hrp1001 TYPE TABLE OF ty_hrp1001,
t_hrp1001_tmp TYPE TABLE OF ty_hrp1001,
w_pa0001 TYPE ty_pa0001 ,
t_pa0001 TYPE SORTED TABLE OF ty_pa0001
WITH NON-UNIQUE KEY pernr ,
t_pa0001_tmp TYPE TABLE OF ty_pa0001 ,
w_t500p TYPE ty_t500p ,
t_t500p TYPE HASHED TABLE OF ty_t500p
WITH UNIQUE KEY persa ,
w_t001p TYPE ty_t001p ,
t_t001p TYPE HASHED TABLE OF ty_t001p
WITH UNIQUE KEY werks btrtl ,
w_pa0002 TYPE ty_pa0002 ,
t_pa0002 TYPE SORTED TABLE OF ty_pa0002
WITH NON-UNIQUE KEY pernr ,
t_pa0002_tmp TYPE TABLE OF ty_pa0002 ,
w_pa0105 TYPE ty_pa0105 ,
t_pa0105 TYPE SORTED TABLE OF ty_pa0105
WITH NON-UNIQUE KEY pernr ,
w_output TYPE ty_output ,
t_output TYPE TABLE OF ty_output .
SELECT objid
FROM hrp1001
INTO TABLE t_hrp1001
WHERE otype EQ c_person
AND plvar EQ c_act_plan
AND rsign EQ c_topdown
AND relat EQ c_admnby
AND istat EQ c_firmed
AND begda LE sy-datum
AND endda GT sy-datum
AND sclas EQ c_bet_type
AND sobid EQ p1_betid.
IF sy-subrc EQ 0.
SORT t_hrp1001 BY objid.
ENDIF.
IF NOT t_hrp1001[] IS INITIAL.
t_hrp1001_tmp[] = t_hrp1001[].
DELETE ADJACENT DUPLICATES FROM t_hrp1001_tmp
COMPARING objid.
SELECT pernr
subty
objps
sprps
endda
begda
seqnr
werks
gsber
btrtl
FROM pa0001
INTO TABLE t_pa0001
FOR ALL ENTRIES IN t_hrp1001_tmp
WHERE pernr EQ t_hrp1001_tmp-objid
AND endda GT sy-datum
AND begda LE sy-datum.
SELECT pernr
subty
objps
sprps
endda
begda
seqnr
nachn
vorna
FROM pa0002
INTO TABLE t_pa0002
FOR ALL ENTRIES IN t_hrp1001_tmp
WHERE pernr EQ t_hrp1001_tmp-objid
AND endda GT sy-datum
AND begda LE sy-datum.
ENDIF.
IF NOT t_pa0001[] IS INITIAL.
t_pa0001_tmp[] = t_pa0001[].
SORT t_pa0001_tmp BY werks btrtl.
DELETE ADJACENT DUPLICATES FROM t_pa0001_tmp COMPARING werks btrtl.
SELECT werks
btrtl
btext
FROM t001p
INTO TABLE t_t001p
FOR ALL ENTRIES IN t_pa0001_tmp
WHERE werks EQ t_pa0001_tmp-werks
AND btrtl EQ t_pa0001_tmp-btrtl.
DELETE ADJACENT DUPLICATES FROM t_pa0001_tmp COMPARING werks.
SELECT persa
name1
FROM t500p
INTO TABLE t_t500p
FOR ALL ENTRIES IN t_pa0001_tmp
WHERE persa EQ t_pa0001_tmp-werks.
ENDIF.
IF NOT t_pa0002[] IS INITIAL.
t_pa0002_tmp[] = t_pa0002[].
DELETE ADJACENT DUPLICATES FROM t_pa0002_tmp COMPARING pernr.
SELECT pernr
subty
objps
sprps
endda
begda
seqnr
usrid_long
FROM pa0105
INTO TABLE t_pa0105
FOR ALL ENTRIES IN t_pa0002_tmp
WHERE pernr EQ t_pa0002_tmp-pernr
AND subty EQ c_subtyp_mail
AND endda GT sy-datum
AND begda LE sy-datum
AND usrty EQ c_subtyp_mail.
ENDIF.
REFRESH t_output.
LOOP AT t_hrp1001 INTO w_hrp1001.
LOOP AT t_pa0001 INTO w_pa0001
WHERE pernr EQ w_hrp1001-objid.
READ TABLE t_t500p INTO w_t500p WITH KEY persa = w_pa0001-werks
TRANSPORTING
name1.
CHECK sy-subrc EQ 0.
READ TABLE t_t001p INTO w_t001p WITH KEY werks = w_pa0001-werks
btrtl = w_pa0001-btrtl
TRANSPORTING
btext.
LOOP AT t_pa0002 INTO w_pa0002
WHERE pernr EQ w_hrp1001-objid.
LOOP AT t_pa0105 INTO w_pa0105
WHERE pernr EQ w_pa0002-pernr.
w_output-pernr = w_pa0002-pernr .
w_output-werks = w_pa0001-werks .
w_output-gsber = w_pa0001-gsber .
w_output-btrtl = w_pa0001-btrtl .
w_output-name1 = w_t500p-name1 .
w_output-btext = w_t001p-btext .
w_output-nachn = w_pa0002-nachn .
w_output-vorna = w_pa0002-vorna .
w_output-usrid_long = w_pa0105-usrid_long.
APPEND w_output TO t_output.
CLEAR w_output.
ENDLOOP.
ENDLOOP.
ENDLOOP.
ENDLOOP.
Reward if usful,
Thanks,
Srikanth.A -
Hi Experts,
How to retrive data from HR tables for custom screen & store in custom table? I need Employee number, employee name, department, their location & mail id. When employee number is given, all other details must be fetched. Can you give a solution for this problem?
Thanks,
KavithaHi Kavitha,
in HR you could get data from different tables based on infotypes. lets say if any data need to get from infotype 0001 (Org assignment), add "PA" before the infotype number so it would be PA0001.
you could get the Employee no, name, department, location(i guess personal area or personal subarea) from PA0001 table and email id from PA105 infotype.
Regards
Raju -
Retrive data from two tables into one internal table.
Hi SDN,
I am downloading the Assets data from two tables ANLA,ANLZ.
there is a common field ANL1in both tables and i have to retrive the data by using anl1 into the internal table.
can you please send me the SELECT Syntax for this probl.....
Thank you & Regards,
ManojHi manoj,
Please see the following sample code. But kindly don't use join as it may hamper ur performance. No trouble in using two select query.
data: begin of itab occurs 0,
BUKRS like anla-BUKRS,
ANLN1 like anla-ANLN1,
BDATU like anlz-BDATU,
end of itab.
select anlabukrs anlaANLN1 anlzBDATU into corresponding fields of table itab from anla inner join anlz on anlaanl1 eq anlz~anl1 where (logexp).
Please come back for any clarification.
Thanks and Regards,
saurabh -
Retriving data from backend tables
Hi All,
I have one requirement to retrive the data from backend tables.
Is there any code to retrive only the first row of table from backend.
Please provide me any solution for this.
Thanks in Advance!
Thanks & Regards,
Sreelakshmi.Hi,
create a remote enabled rfc with export parameter IT_RESULT TYPE ZSSHDR(transp. table).
use code :
DATA: itab type table of ZSSHDR .
select * from ZSSHDR into table itab .
Read table itab into it_result index 1.
in RFC.
use this rfc in ur DC.
Amit -
Retriving data from two tables at a time.
Please use this forum to provide feedback about OTN content/services. All other posts will be DELETED.
hi all,
Am using win98 and Oracle 7.
I have splitted a table into two tables having 10 and 9 fields respectively and records of 2000.Now in form builder I have put both tables in same block and on same canvas.
Now when I execute a query I retrieve records of 1st table and can navigate through records of 1st table only .To retrive records of 2nd table I have to put curser in 2nd table and query again for data retrival from 2nd table.This is bothering me to match coulmn of both tables.
Is there any way to execute the records of both tables at a time, so that matching coulmns of both tables would become easy to reach.
Thanks and Regardsheeeey mohammad
you have first to make master/detail block not one block only
then jion between them as pk and fk -
Want to fetch data from AFVU table with input of order number from AUFK table
Hi,
I have a requrement in report where in the user wil enter the order number from AUFK table and it should display detais like job code condition code (from AFVU table) along with other fields. There is no relation ship between AFVU and AUFK. Can anybody help me in getting the replation ship between 2 tables. What is the table that iam missing and where can i find that relationship and fetch records for that order number?Check if this helps..
AUFK -> AFKO -> AFVU
AUFK-AUFNR = AFKO-AUFNR
AFKO-AUFPL = AFVU-AUFPL
Hope this helps. -
Unable to retrive data from two tables using multiple joins
Hi,
Table: EMP mgr
eid name
eid mgrid
1
A 1
null
2
B 2
3
3
C 3
3
i need to get result as:
eid ename mgrname
thanks
AVSSai,
It would be very helpful if you could mention your table structures a bit more clearly. Would allow for effective replies from fellow users as well. :)
However, assuming that your structure would be as follows presenting the query as below:
DECLARE @Emp TABLE(Eid Int, ename Varchar(50))
DECLARE @Emp_Mgr TABLE(Eid int, mgrid int null )
INSERT INTO @Emp select 1,'Ram'
INSERT INTO @Emp select 2,'Shyam'
INSERT INTO @Emp_Mgr select 1,NULL
INSERT INTO @Emp_Mgr select 2,1
SELECT * FROM @Emp
SELECT * FROM @Emp_Mgr
Query to print results as EID, ENAME, MGRNAME
SELECT em.eid,e1.ename as ENAME,e2.ename as MGRNAME
FROM @Emp_Mgr em
JOIN @Emp e1 ON em.eid=e1.eid
JOIN @Emp e2 ON em.mgrid=e2.eid
However, as you see this approach of maintaining two tables for preserving the employee-manager data is redundant and makes the queries unnecessarily complex. So, you could opt for the widely used single table format as mentioned by Praveen as well. Check
if this helps you..
Recommended Structure
*Avoidance of redundant storage of data
*Lesser Joins in queries
DECLARE @Emp TABLE(Eid Int , Ename Varchar(50) , mgrid int null )
INSERT INTO @Emp(Eid , ename , mgrid) values(1 , 'Ram' , null) , (2 , 'Shyam' , 1)
SELECT * FROM @Emp
Query to print results as EID, ENAME, MGRNAME
SELECT e.Eid , e.Ename , m.Ename as MgrName
FROM @Emp e
JOIN @Emp m On a.mgrid = b.eid
Thanks,
Jay
<If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'> -
SQL Loader - want to access data from .txt file but don't want to insert
Hello,
I have situation where I have some data in .txt file and I have to load that data into one of my table.
My problem is I have fundtion get_id(a,b,c) in database which I have to call while loading the data to find out value of x.
I have value of a, b and c in txt file which I can access it using POSITION(N:M) in sql loader, but After accessing that value I just want to past to get_id() function and dont want to insert into sql loader.
any helpMy control file is as below
Following field is not in database but I need to pass the value to the function to get a ESC_USER_ID. any help
OFFICE_NUM filler POSITION(32:35) ,
STATION_DESK filler POSITION(45:48),
LOAD DATA
INFILE REFERRALs.TXT
BADFILE REFERRAL_LOAD.BAD
DISCARDFILE REFERRAL_LOAD.DIS
INSERT
INTO TABLE REFERRAL
EVALUATE CHECK_CONSTRAINTS REENABLE DISABLED_CONSTRAINTS
TRAILING NULLCOLS
ID sequence (1,1),
JOB_ID POSITION (16:22) "GET_JOB_ID(:JOB_ID)" ,
CUS_ID POSITION (23:31) "GET_CUS_ID(:CUS_ID)" ,
STATUS_LU CONSTANT 'F' ,
REQUEST_USER_TYPE_LU CONSTANT 'S' ,
OFFICE_NUM filler POSITION(32:35) ,
STATION_DESK filler POSITION(45:48),
REQUEST_USER_ID POSITION(143:149) "GET_ESCUSER_ID(OFFICE_NUM,STATION_DESK,:REQUEST_USER_ID)" ,
REQUEST_DT POSITION (37:44) "to_date(:REQUEST_DT,'YYYY/MM/DD')" ,
REVIEW_USER_ID FILLER ,
REVIEW_DT FILLER ,
REFUSE_REASON_LU FILLER ,
RESULT_LU POSITION (97:97) ,
NOTIFY_STATUS_LU FILLER ,
NOTIFY_DT FILLER ,
APPOINTMENT_DT POSITION (106:113) "to_date(:APPOINTMENT_DT,'YYYY/MM/DD')" ,
RESULT_DT POSITION (98:105) "to_date(:RESULT_DT,'YYYY/MM/DD')" ,
NO_MATCH_IND CONSTANT 'N'
) -
How to fetch data from 2 tables
Hi Experts,
I am using 2 Ztables.Let us assume that there are 2 fields in Table1 as a and b and 2nd Table contain c as field.I want to retrive data from these tables by combining the fields of Table1 with that of 2.
Eg: I want to compare a+b with c and fetch records.
Is there any logic to combine 2 fields and compare with 3rd field using a single select statement?
Regds,
Sam.Hi Sam,
if the tables have one or more common key fields, you can use a JOIN condition for the tables, i.e.
data:
begin of ls_target,
a like ztable1-a,
b like ztable1-b,
c like ztable2-c,
end of ls_target,
lt_target like table of ls_target.
select ztable1~a ztable1~b ztable2~c
into corresponding fields of table lt_target
from ztable1
join ztable2 ON ztable2~key = ztable1~key
where <your condition>.
Note ahead:
1) some people say select into corresponding fields is not good for performance. I think it is good to avoid errors and nobody ever gave a perfomance proof.
2) Most developers always use an alias such as ztable1AS a, ztable2 AS b. This is due to the fact that after table joins were introduced with release 3.1, the ABAP sample programs an documentation always used the ALIAS clause although it is not necessary nor does it establish transparency.
Kind regards
Clemens -
HOW to retrive data from SAP Tabel
Hi Friends,
1)Can you please explain how to retrive data from SAP table(example AFRU).
2) we had requriment based on the qunatity , Product name and date we need to display KPI's .KPI is based no products manfactured per day with some conditions
Regards
SrikanthHi Udayan,
I want to retrive SAP Table data from xMII.can you please explain elabarately how to call "RFC_READ_TABLE" from xMII.
please do the needful
Thanks
Srikanth -
How to extract data from 12 tables ?
Hi experts,
I want to extract data from 12 tables into bi.
How can we do this. And also can we extract some fields from
a structure?
Full points will be assigned.
Regards,
V N.Hi,
First you need to check if the tables are standard tables or custom tables. If they are standard tables check which extractors are using those tables.
If they are not being used by any of the standard extractors then you you need to create generic datasource for the same. The same hold true for custom tables as well. For custom tables, you'll need to create generic datasource. If you search the forum for generic datasources you'll get a lot of information.
Its very important that you understand the table relationships, data volumes, if delta is possible or not, data granularity, etc for your datasource design.
Cheers,
Kedar -
How to get data from a table in a condition between twomonth
hai friends
I have a query that is i want to get data from a table based on a condition between two months in a format of char column
Ex
I have a column called from_month in the format of 'mon/yyyy'(already converted from date')
then the second column is to_month in the same format 'mon/yyyy'
now i wiil select from_month and to_month like
from month jan/2009
to month mar/2010
how to use between of two months in the format of char.Please tell me how to get two different month between data.Hi,
This may be of help.
Remember Pointless has made a point ;) (worth millions)
If possible , DO NOT store dates as strings or numbers.Let dates be dates.
WITH dat AS
(SELECT ' THIS IS JAN' x,to_char(to_date('01-JAN-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
SELECT ' THIS IS FEB' x,to_char(to_date('01-FEB-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
SELECT ' THIS IS MAR' x,to_char(to_date('01-MAR-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
SELECT ' THIS IS APR' x,to_char(to_date('01-APR-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
SELECT ' THIS IS MAY' x,to_char(to_date('01-MAY-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
SELECT ' THIS IS JUN' x,to_char(to_date('01-JUN-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
SELECT ' THIS IS JUL' x,to_char(to_date('01-JUL-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
SELECT ' THIS IS AUG' x,to_char(to_date('01-AUG-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
SELECT ' THIS IS SEP' x,to_char(to_date('01-SEP-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
SELECT ' THIS IS OCT' x,to_char(to_date('01-OCT-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
SELECT ' THIS IS NOV' x,to_char(to_date('01-NOV-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual)
SELECT * FROM dat
WHERE to_date(y,'mon/yyyy') BETWEEN to_date('01 jan 2009','dd mon yyyy') AND to_date('01 mar 2009','dd mon yyyy')Cheers!!!
Bhushan -
Transfer data from a table to another table
Hello
I want to transfer data from a table in one server to another table in a different server, I want to do this on a nightly job, what will be the best way, please advise, thank you.Multiple options
1. Create linked server and use INSERT..SELECT * FROM [Server].[DB].dbo.Table
2. Use OPENROWSET
http://searchsqlserver.techtarget.com/tip/Using-the-OPENROWSET-function-in-SQL-Server
3. Use export import wizard
http://www.leniel.net/2011/07/import-export-data-sql-server-database.html#sthash.l4fgNNdV.dpbs
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs
Maybe you are looking for
-
HT4981 how many times can I burn a CD from my purchases
I like to make road music for my Harley, I camp and play while I am on trips. most of the time I lose or samage the disc. Some time I want to listen to different music Can I just burn a new disc each time
-
Changes in outline made from EAS are not reflected in EPMA dimension lib
I added member formulas to some members in the account dimension using Essbase Administration Services and save them, when i opened workspace, I didn't see the change reflected in my planning application though i refreshed database from workspace. An
-
How to craete a 'annual leave 1/2day-AM' in ESS leave request
Hi , I have created 2001- subtype 670 : "annual leave 1/2day-AM". I wanted to see "annual leave 1/2day-AM" in the ESS leave request list down box ( already we have few ) ... please let me know what are the steps i need to follow ... thanks, sunitha E
-
Password Sync Issue:JMS Listener: java.lang.ClassCastException
Hi, For AD Password sync implemetation, I have installed Sun IDM 8.0, Sun Message Queue 4.5, Open DS and Active Directory. While configuring the IDM JMS Listner Adapter, I am getting the below error during the Test connection: Test connection failed
-
My files disappered from icloud drive. is there a way to get them back??
Hi All, I'm using icloud drive for my files and everything was fine untill this morning. when I looked the drive I saw that most of my files was gone. I did not erase or move anything. is there a way to get them back??? thanks...