Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with select * into table

Former Member
0 Kudos

Hi expert.

i have a question about select into syntax.

my problem is , i write zreport use data from mseg , mkpf table . i know if any transaction occur with these table in processing report , i never get a correct report. so, my solution is use "select * into table" retrieve data that meet with my condition into my other create table ( like : wa_mseg). and use data in this table only.



***declaration***

DATA:  wa_mseg TYPE STANDARD TABLE OF mseg WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 100,
             i_mseg TYPE mseg.

***select into***

select  * into table wa_mseg from mseg where X = Y A = C.

***use***

loop at wa_mseg into i_mseg where X = Y
........
......
........
.....


but result still incorrect.

so i think , is possible that transaction occur with mseg table has effect with data i retreive into my table?

anyone please tell me?

Best Regards

Kittisak

Edited by: Kittisak B on Jul 21, 2009 8:38 AM

11 REPLIES 11

Former Member
0 Kudos

if there has long interval within retrieve data from mseg to end the report,

i think there has not good sultion to solve your issue.

former_member218674
Contributor
0 Kudos

Hello,

Once you select data from some table into internal table then it has nothing to do with what changes happens in

database table.

In your case may be you can put some more filter to make the data more specific so database response time will be less.

By the way what is the issue you are facing in the selected data?

Thanks,

Augustin.

0 Kudos

By the way what is the issue you are facing in the selected data?

because in this report, i'm select data from mbew and mard table into my create table for calculate BF Qty. of Each material in each month. but result change every time when run this report. some material qty is correct , some not .

0 Kudos

hi..

u proper clearing work area in loop endloop process??

regards,

Praveen

former_member194613
Active Contributor
0 Kudos

please read more in the helpportal or wikipedia about transactions, consistent data, locks etc.

You should always read the committed data at the point t when you start your program, and not at the point t + epsilon.

Siiegfried

former_member194613
Active Contributor
0 Kudos

what do you mean with CORECT,

either you are not able to do correct calculations

or you compare it with something, what is it waht you use for comparison?

0 Kudos

u proper clearing work area in loop endloop process??

yes , i do.

what do you mean with CORECT,

either you are not able to do correct calculations

or you compare it with something, what is it waht you use for comparison?

i have a hard copy of material qty. result from checking stock in end of month to compare with report.

Edited by: Kittisak B on Jul 27, 2009 5:30 AM

Edited by: Kittisak B on Jul 27, 2009 5:30 AM

former_member194613
Active Contributor
0 Kudos

It does not help much, if you say the quantity if incorrect, you must find out, what is different.

Is the hardcopy created at a different time, or whatever. What is different, then you will find

out the reason.

The reason should not be the statement, but the way how it is used.

Siegfried

ThomasZloch
Active Contributor
0 Kudos

SAP ERP is based on real time data integration, the moment somebody posts a goods movement you have updated stock levels, and each time you run your program with data selections you might have a different result.

If you must work with fixed snapshots, use a BI/BW system or select by past posting or even better CPU dates, like MKPF-CPUDT.

SELECT * INTO TABLE ... has nothing to do with this.

Thomas

Former Member
0 Kudos

Hi Kittisak B ,

Try with SELECT FOR UPDATE * to lock the records that will be handled and prevent updates on the tables while running the report.

Additionally:

- Check the internal table structure because when using "select * into table" the internal table must be identical to the database table, all fields must exist in the same order, otherwise it will store data in fields that do not match and this could change the result.

- Do "CLEAR" and "REFRESH" of the internal table and the work area before populate.

Hope this information is help to you.

Regards,

José

former_member194613
Active Contributor
0 Kudos

DATA:  

 lt_mseg TYPE SORT TABLE OF mseg 
               WITH NON-UNIQUE KEY X,
wa_mseg TYPE mseg.
 
***select into***
 
select  * into table lt_mseg from mseg where X = Y A = C.
 
***use***
 
loop at lt_mseg into wa_mseg
         where X = Y

Please look again into the ABAP documentation, it is much better than you think

+ wa_ is a structure and not a table, you should not use widely used naming conventions in a different way,

+ the table is lt_

+ together with LOOP ... WHERE ... you should not use a standard table but a SORTED TABLE

+ and a default key is for lazy guys .... who are highly fault-tolerant, not really recommended

Siegfried