07-04-2008 10:19 AM
Hi all,
My requirement is to fetch data from MSEG which is not present in Z table.
I think i should use for all entries.
common fields for these tables are mblnr and mjahr.
But its not clear with exact code ...
can u please help me with the same.
Points will be rewarded.
Regards,
Siddhi
07-04-2008 10:24 AM
Hi Siddi,
You said the requirement is to fetch data from MSEG which is not present in Z table. Can you be more clear on this?
Regards,
Swapna.
07-04-2008 10:24 AM
Hi,
You Can Select the data from MSEG Like
First Select the records from ztable into intrernal table itab1.
After -
Select * from MSEG
into table itab2
for all entries in itab1
where mblnr = itab1-mblnr
and mjahr = itab1-mjahr.
Hop it will solve your problem.
Regards,
Sujit
07-04-2008 10:25 AM
Fetch the Data from Ztable.
Fetch the data from MSEG.
Loop on MSEG Itable and Read the Ztable.
If sy-subrc = 0.
delete the entry from MSEG ITAB.
end if.
The For all entries could be used if you want data from MSEG for all matching emtries in ZTABLE.
But yorus is the reverse case.
Thanks
07-04-2008 10:26 AM
07-04-2008 10:26 AM
hi,
If you have to pick data which is not present in Z_table then i think For All Entries is not a good idea.
For All Entries Pick the entries for the Records which are Present in eithe rof the table but which are not present in one table.
Please try other option or use Simple Select Query and Check the record is present in Z_table or not.
Hope this will Help.
Reward if Useful.
Sumit Agarwal
07-04-2008 10:26 AM
Hi,
select * from mseg into table t_mseg where mblnr = p_mblnr .
if t_mseg[] is not initial.
*select * from mseg*
into table ztable for all entires in
t_mseg where mblnr = t_mesg-mblnr and mjahr = t_mseg-mjahr.
endif.
Reward if helpful.
Best Wishes,
Chandralekha
07-04-2008 10:30 AM
Hello dost,
First of all i want to tell you about For all entires:
We use this to take all the corresponding data from the database table in comparision of some internal table which is allready filed with some fields.
That means you require more field in corresponding of your allready filed fields.
data itab type table of mseg.
IF itab1 is not initial.
SELECT * from MSEG
into table itab
for all entries in itab1
where mblnr = itab1-mblnr
and mjahr = itab1-mjahr.
endif.
****itab1 should not be empty.
I think this is more clear for you.
please rewards if think this fine.
07-04-2008 10:33 AM
Hi,
When you want to get records related to ZTABLE from MSEG then we can use FOR ALL ENTRIES of Ztable. But here you want is records that are not present in Ztable.
First you SELECT data from both tables.
Select mblnr
mjahr
from ztab
into table t_ztab.
select mblnr
mjahr
zeile
bwart
from mseg
into table t_mseg.
Loop at t_ztable.
read table t_mseg with key mblnr = t_ztable-mblnr
mjahr = t_ztable-mjahr.
if sy-subrc eq 0.
delete t_mseg.
endif.
endloop.
loop at t_mseg.
write : / mblnr,
mjahr,
zeile,
bwart.
endloop.
noe the records which are not ther in t_ztable will be displayed .
Regards,
Rajitha.