Application Development and Automation 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: 
Read only

Problem with select query.

Former Member
0 Likes
818

Hi Experts,

I need to modify a program which contains the below mentioned query.

SELECT * FROM yvw40 .

DELETE FROM yvw40 WHERE period IN s_month AND

fiscalyear IN s_year AND

comp_code IN compcode AND

acct_nbr IN gl_accts.

ENDSELECT.

YVW40 is a custom table for GL Extract.

The delete statement was not working properly hence i added COMMIT WORK statement after DELETE statement.

The problem is, after adding COMMIT WORK, i am getting dump sometimes and sometimes there is no dump.

Can somebody suggest the reason why this is happening and how to rectIfy the same.

Thanks in advance.

Regards

Balu

1 ACCEPTED SOLUTION
Read only

former_member156446
Active Contributor
0 Likes
786

try to use commit after endselect.

9 REPLIES 9
Read only

former_member156446
Active Contributor
0 Likes
787

try to use commit after endselect.

Read only

Former Member
0 Likes
786

Hi balu,

Before a database commit the system expects that all the database selections are complete.

So if we write a commit in between select and endselect the system throws a dump saying that the selection isnt yet complete and that there is an interruption in the select.

So do a commit. after the endselect statement .

Regards,

Vidya Chowdhary A.

Read only

0 Likes
786

Thanks for ur responses.

I know the query is not appropriate.

But the program was written long back, may in 1999 i suppose.

The requirement was to change another Select query in the same program.

While testing i found the above mentioned problem, i am just trying to fix it.

Regards

Balu

Read only

Former Member
0 Likes
786

Hi balu ,

As Vidya has said the the select statement should get completed before the commit . U can use the below logic .

Data: IT_YVW40 type standard table of YVW40.
REFRESH it_yvw40[].
SELECT  *  
    FROM yvw40  
    INTO TABLE            it_yvw40
    WHERE period         IN s_month AND
                 fiscalyear    IN s_year AND
                 comp_code  IN compcode AND
                 acct_nbr      IN gl_accts.. 
IF sy-subrc EQ 0.
    DELETE FROM yvw40 FROM TABLE it_yvw40.
    IF sy-subrc NE 0.
        MESSAGE 'Unable to delete the Records' TYPE 'E'.
    ENDIF
ENDIF

Hope this helps

Regards

Arun Thiyagarajan

Read only

Former Member
0 Likes
786

Hi,

1. I am not able to understand why you have used Delete from YVW40 statment inside Select and End select . This will not satisfy ur need.

2. Instead you can directly use delete from YVW40, after delete just do a commit work

3. perfomance wise this will be much better

Read only

Former Member
0 Likes
786

Hi Balu,

In Debugging mode if you enter into SELECT ...... ENDSELECT sometimes it will go to dump. Try to write SELECT single or UPTO one row. Avoid SELECT ...... ENDSELECT. You can check it out by putting break point before and after the loop. it wont go to dump.

Regards,

Subrahmanyam.

Read only

0 Likes
786

Thanks for all the replies.

I placed the commit work outside the Select.... End Select and there is dump now.

Thanks

Balu

Read only

0 Likes
786

It may "work" now, but it makes no sense at all. You might want to rethink the process.

Rob

Read only

Former Member
0 Likes
786

    DELETE   FROM yvw40  
                    WHERE period IN s_month AND
                    fiscalyear          IN s_year AND
                    comp_code        IN compcode AND
                    acct_nbr            IN gl_accts.. 
    IF sy-subrc NE 0.
        MESSAGE 'Unable to delete the Records' TYPE 'E'.
    ENDIF

this would also work,... but it dangerous, it can happen that it delete the whole table, if the

ranges are empty!

So it probably better to read the keys of the records which should be delete. But still your coding

can delete the whole table, just a bit slower than the coding above

what is the use of a refresh on a just created table?