‎2006 Aug 15 10:19 AM
friends, need help once again.
i have created one structre which is based on table pa0000 and pa0001. where pernr is primary key on both table. i have seen both table data and there is more then 5000 records for same key. my datasource ias based on this structre and program but when i am checking in bw it is fetch only one recortd. please check my below code and suggest me where i am worng
code -
Tables: pa0000,
pa0001,
ztest12.
Data: begin of itab_pa0000 occurs 0.
include structure ztest12.
Data : end of itab_pa0000.
Data tab type i.
*<query_head>
select * from pa0000 into corresponding fields of table itab_pa0000.
Select * from pa0001 into corresponding fields of table itab_pa0000 where pernr = itab_pa0000-pernr.
append itab_pa0000.
Loop at itab_pa0000.
move-corresponding itab_pa0000 to ztest12.
*<query_body>.
endloop.
please let me know if yopu need any more information
regards
‎2006 Aug 15 10:24 AM
put ur query outside the loop after appending the itab..
Loop at itab_pa0000.
move-corresponding itab_pa0000 to ztest12.
append ztest12.
endloop.
*<query_body>.
~Suresh
‎2006 Aug 15 10:27 AM
ztest12 is not an internal table, it is structre where in some fields are from pa0000 and pa0001 table.
Regards
‎2006 Aug 15 10:38 AM
Write the code in this way...
Tables: pa0000,
pa0001,
ztest12.
Data: begin of itab_pa0000 occurs 0.
include structure ztest12.
Data : end of itab_pa0000.
Data tab type i.
*<query_head>
select *
into corresponding fields of table itab_pa0000
from pa0000
join pa0001
on pa0000pernr = pa0001pernr.
Loop at itab_pa0000.
move-corresponding itab_pa0000 to ztest12.
*<query_body>.
endloop.
‎2006 Aug 15 10:32 AM
Please use the below code.
Tables: pa0000,
pa0001,
ztest12.
Data: begin of itab_pa0000 occurs 0.
include structure ztest12.
Data : end of itab_pa0000.
Data tab type i.
*<query_head>
select {list of fields from pa0000 and pa0001}
into corresponding fields of table itab_pa0000
from pa0000 as a inner join pa0001 as b
on apernr = bpernr.
Loop at itab_pa0000.
move-corresponding itab_pa0000 to ztest12.
insert/update ztest112. "depending on your requirement.
*<query_body>.
endloop.
Regards
Anurag
‎2006 Aug 15 10:33 AM
HI,
Tables: pa0000,
pa0001,
ztest12.
Data: begin of itab_pa0000 occurs 0.
include structure ztest12.
Data : end of itab_pa0000.
Data tab type i.
*<query_head>
<b>*here you fill the itab_pa0000 with values from pa0000
*its ok</b>
select * from pa0000 into corresponding fields of table
itab_pa0000.
<b>*here you are overwritting the old values and just
*using header value that the reason it is giving one row.
*check the bold code.</b>
Select * from pa0001 into corresponding fields of table
itab_pa0000 where pernr = <b>itab_pa0000-pernr</b>.
<b>*saving the values into another itab OR use APPENDING * option
Select * from pa0001 into Table itab_pa0001
FOR ALL ENTERIES IN itab_pa0000
WHERE pernr = itab_pa0000-pernr.</b>
append itab_pa0000.
Loop at itab_pa0000.
move-corresponding itab_pa0000 to ztest12.
*<query_body>.
endloop.Regards,
HRA
‎2006 Aug 15 10:34 AM
Hi
Try if this works for you. Have changed few portions of your code.
Tables: pa0000,
pa0001,
ztest12.
data: itab_pa0000 like ztest12 occurs 0 with header line.
data: itab_pa0001 like ztest12 occurs 0 with header line.
*<query_head>
select * from pa0000 into corresponding fields of table itab_pa0000.
Select * from pa0001 into corresponding fields of table itab_pa0001
for all entries in itab_pa0000
where pernr = itab_pa0000-pernr.
Loop at itab_pa0001.
move-corresponding itab_pa0001 to ztest12.
*<query_body>.
endloop.
Kind Regards
Eswar
‎2006 Aug 15 10:42 AM
Hi jain,
i have tried with this examples:
REPORT ZGRO_TESTT.
*
TABLES: MARA.
*
DATA: BEGIN OF IMARA OCCURS 0.
INCLUDE STRUCTURE MARA.
DATA: END OF IMARA.
*
SELECT * FROM MARA INTO CORRESPONDING FIELDS OF TABLE IMARA.
*
break-point.
*
SELECT * FROM MARA INTO CORRESPONDING FIELDS OF TABLE IMARA
where matnr = imara-matnr.
*
BREAK-POINT.
the Problem is, that the 2 select refresh the itab and find no Record, because tzhe Headerline of imara will not
be filled.
Use select ... endselect.
Regards, Dieter
‎2006 Aug 15 11:11 AM
Hellofreinds, thanks for your help. <program is working fine now but it is extractin double entries. i have seent the entry for empl no 1277 , and there are v2 entries in both table. so by default my datasource should alos fetch 2 entries but now any how it is fetch 4 entries.
is there some thing worng in my code ..? please advice.
‎2006 Aug 15 11:17 AM
clear internal table headers and try
Loop at itab_pa0001.
move-corresponding itab_pa0001 to ztest12.
<b>clear :itab_pa0001,ztest12.</b>
*<query_body>.
endloop.
‎2006 Aug 15 11:17 AM
Hi Jain,
are your sure, that in PA0000 are only one Record for 1277 or more? Test it with SE16 or SE16N.
Perhaps you have to select with the actual date?
Regards, Dieter
‎2006 Aug 15 11:20 AM
please note that there are BEGDA and ENDDA in both tables. so data should come based on time dependancy.
entries are like this in both table for empl no 1277
Table Pa0000 -
empl no begda endda
1277 01.01.1994 31.03.1998
1277 01.04.1998 31.12.9999
table pa0001
1277 01.01.1994 31.12.1996
1277 01.01.1997 31.12.9999
so my datasource shld fetch entries in following way
1277 01.01.1994 31.12.1996
1277 01.01.1997 31.03.1998
1277 01.04.1998 31.12.9999
but where as my datasource is fetching the entries is following way and it is wrong.
1277 01.01.1994 31.12.1996
1277 01.01.1994 31.12.1996
1277 01.01.1997 31.12.9999
1277 01.01.1997 31.12.9999
please suggest me ...thanks in advance
regards
‎2006 Aug 15 11:24 AM
Hi
Try this way.
Tables: pa0000,
pa0001,
ztest12.
data: itab_pa0000 like ztest12 occurs 0 with header line,
itab_pa0001 like ztest12 occurs 0 with header line.
Data tab type i.
*<query_head>
select * into corresponding fields of table itab_pa0000
from pa0000 as a
left outer join pa0001 as b
on b~pernr = a~pernr
and b~begda = a~begda.
Loop at itab_pa0001.
move-corresponding itab_pa0001 to ztest12.
*<query_body>.
endloop.
Kind Regards
Eswar
Message was edited by: Eswar Rao Boddeti
‎2006 Aug 15 11:29 AM
Hi eswar,
Thanks for yr responce, but do it will check time depenadancy..it should check and modify the date automatically.
it should give me only 3 records by updaing the endda and begda.
thanks
‎2006 Aug 15 11:31 AM
Hi Akshay
I have changed my code now with the start date also to be considered. Check if this works.
Kind Regards
Eswar
‎2006 Aug 15 11:39 AM
it is fetching only one record
1277 01.01.1994 31.12.1996
other 2 reocrds are missing
regard
‎2006 Aug 15 11:55 AM
Hello Akshay,
If you use the code given in my replies and once you have got the data in the internal table itab.
U can use DELETE from itab comparing fields command to delete the adjacent duplicates. (Please use the sort on the fields). Hence you would have unique records in your itab.
Regards
Anurag
‎2006 Aug 15 11:55 AM
can we check the tme dependancy through perform statement..can any one please help me in below code,
regards
‎2006 Aug 15 12:01 PM
Anurag, but how time dependancy will be there..i am accpecting below data from my code...
please note that there are BEGDA and ENDDA in both tables. so data should come based on time dependancy.
entries are like this in both table for empl no 1277
Table Pa0000 -
empl no begda endda
1277 01.01.1994 31.03.1998
1277 01.04.1998 31.12.9999
table pa0001
1277 01.01.1994 31.12.1996
1277 01.01.1997 31.12.9999
so my datasource shld fetch entries in following way
1277 01.01.1994 31.12.1996
1277 01.01.1997 31.03.1998
1277 01.04.1998 31.12.9999
but where as my datasource is fetching the entries is following way and it is wrong.
1277 01.01.1994 31.12.1996
1277 01.01.1994 31.12.1996
1277 01.01.1997 31.12.9999
1277 01.01.1997 31.12.9999
‎2006 Aug 15 12:05 PM
Hi Akshay
I guess this should work for you. Please try and let us know.
Tables: pa0000,
pa0001,
ztest12.
data: itab_pa0000 like ztest12 occurs 0 with header line,
itab_pa0001 like ztest12 occurs 0 with header line.
Data tab type i.
*<query_head>
select * into corresponding fields of table itab_pa0000
from pa000.
select * into corresponding fields of table itab_pa0001
from pa0001.
loop at itab_pa0000.
clear: itab_pa0001.
read table itab_pa0001 with key pernr = itab_pa0000-pernr
begda = itab_pa0000-begda.
if sy-subrc eq 0.
move-corresponding itab_pa0001 to itab_pa0000.
modify itab_pa0000.
delete itab_pa0001 index sy-tabix.
endif.
endloop.
append lines of itab_pa0001 to itab_pa0000.
Loop at itab_pa0001.
move-corresponding itab_pa0001 to ztest12.
*<query_body>.
endloop.
Kind Regards
Eswar
‎2006 Aug 15 12:28 PM
‎2006 Aug 15 12:41 PM
Tables: pa0000,
pa0001,
ztest12.
data: itab_pa0000 like ztest12 occurs 0 with header line,
itab_pa0001 like ztest12 occurs 0 with header line,
itab_final like ztest12 occurs 0 with header line.
Data tab type i.
*<query_head>
select * into corresponding fields of table itab_pa0000
from pa000.
select * into corresponding fields of table itab_pa0001
from pa0001.
loop at itab_pa0000.
clear: itab_pa0001.
read table itab_pa0001 with key
pernr = itab_pa0000-pernr begda = itab_pa0000-begda.
if sy-subrc eq 0 and itab_pa0000-endda > itab_pa0001-endda.
move-corresponding itab_pa0001 to itab_final.
else.
move-corresponding itab_pa0000 to itab_final.
endif.
append itab_final.
endloop.
Loop at itab_final.
move-corresponding itab_final to ztest12.
*<query_body>.
endloop.
Regards
Anurag
Message was edited by: Anurag Bankley
‎2006 Aug 15 1:54 PM
Akshay
I guess the code given by Anurag after modifications should work for your case.
Check the same and revert back incase of problems.
Kind Regards
Eswar
‎2006 Aug 15 2:15 PM
Thanks Anurag, code is working now but ut us fetching only 2 entries as below -
1277 1.1.1994 31.12.1996
1277 1.4.1998 31.12.9999
where as it shld fetch the entries in following way
1277 01.01.1994 31.12.1996
1277 01.01.1997 31.03.1998
1277 01.04.1998 31.12.9999
Please advice
Regards
‎2006 Aug 15 2:19 PM
Sorry missed one of your criteria..check the below now it should work
Tables: pa0000,
pa0001,
ztest12.
data: itab_pa0000 like ztest12 occurs 0 with header line,
itab_pa0001 like ztest12 occurs 0 with header line,
itab_final like ztest12 occurs 0 with header line.
Data tab type i.
*<query_head>
select * into corresponding fields of table itab_pa0000
from pa000.
select * into corresponding fields of table itab_pa0001
from pa0001.
loop at itab_pa0000.
clear: itab_pa0001.
read table itab_pa0001 with key
pernr = itab_pa0000-pernr begda = itab_pa0000-begda.
if sy-subrc eq 0.
if itab_pa0000-endda > itab_pa0001-endda.
move-corresponding itab_pa0001 to itab_final.
else.
move-corresponding itab_pa0000 to itab_final.
endif.
delete itab_pa0001 index sy-index.
endif.
append itab_final.
endloop.
loop at itab_pa0001.
move-corresponding itab_pa0001 to itab_final.
append itab_final.
endloop.
Loop at itab_final.
move-corresponding itab_final to ztest12.
*<query_body>.
endloop.
Regards
Anurag
Message was edited by: Anurag Bankley
‎2006 Aug 15 2:37 PM
Hi Anurag, i am getting short dump while fetching the data in RSA3. the short dump is due to worng statement and it is near delete statement (delete itab_pa0001 index sy-index.)
please check and let me know
regards
‎2006 Aug 15 2:45 PM
‎2006 Aug 15 2:56 PM
Anurag, luckliy this time 3 record has been extracted but second record is duplication of first record. the entries are as below,
1277 01.01.1994 31.12.1996
1277 01.01.1994 31.12.1996
1277 01.04.1997 31.12.9999
regards
‎2006 Aug 15 3:15 PM
I think the below should work...
empl no begda endda
1277 01.01.1994 31.03.1998
1277 01.04.1998 31.12.9999
table pa0001
1277 01.01.1994 31.12.1996
1277 01.01.1997 31.12.9999
so my datasource shld fetch entries in following way
1277 01.01.1994 31.12.1996
1277 01.01.1997 31.03.1998
1277 01.04.1998 31.12.9999
-
XXX----
Tables: pa0000,
pa0001,
ztest12.
data: itab_pa0000 like ztest12 occurs 0 with header line,
itab_pa0001 like ztest12 occurs 0 with header line,
itab_final like ztest12 occurs 0 with header line.
Data tab type i.
*<query_head>
select * into corresponding fields of table itab_pa0000
from pa000.
select * into corresponding fields of table itab_pa0001
from pa0001.
loop at itab_pa0000.
clear: itab_pa0001, itab_final.
loop at itab_pa0001 where pernr = itab_pa0000-pernr
and begda = itab_pa0000-begda.
if itab_pa0000-endda > itab_pa0001-endda.
move-corresponding itab_pa0001 to itab_final.
else.
move-corresponding itab_pa0000 to itab_final.
endif.
delete itab_pa0001.
exit.
endloop.
if sy-subrc ne 0.
move-corresponding itab_pa0000 to itab_final.
endif.
append itab_final.
endloop.
loop at itab_pa0001.
move-corresponding itab_pa0001 to itab_final.
append itab_final.
endloop.
Loop at itab_final.
move-corresponding itab_final to ztest12.
*<query_body>.
endloop.
Regards
Anurag