Skip to Content
author's profile photo Former Member
Former Member

Problem with select * into table

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

Add a comment
10|10000 characters needed characters exceeded

Related questions

8 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jul 21, 2009 at 07:11 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 21, 2009 at 12:29 PM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 21, 2009 at 01:32 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 26, 2009 at 08:34 PM

    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?

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      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

  • Posted on Jul 27, 2009 at 09:18 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 27, 2009 at 10:54 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 24, 2009 at 09:54 PM

    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é

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 25, 2009 at 07:26 AM
    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.