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 in select query

Former Member
0 Likes
1,526

Hi all,

Iam using a select query to check whether that material code exist or not.But even though material is created SY-SUBRC is coming 4.Iam doing this in one of my module pool program and this is working perfectly from more than a month in Production.This problem is coming for only few materials only not for all materials.The following is my select query :


SELECT COUNT( * ) FROM MARA WHERE MATNR = WA_BOQP-ZMATNR.

4 days back I had a report in that I was selecting Sales orders based on the given selection screen data.The select query should have selected 12 SO but it was giving only 8 SO.The same report when run after 7-8 hours(after transport),started giving 12 SO.I was Amazed,same thing happend in one more program also.

What might be the problem? is it a BASIS guy problem or what?

Hope my query is clear.

Thanks & Reagrds

Rock.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,485

It might be case of Conversion issue.

YOu have to use the fm CONVERSION_EXIT_MATNR_INPUT before the select query.

call function 'CONVERSION_EXIT_MATNR_INPUT'
exporting
INPUT = WA_BOQP-ZMATNR
Importing
OUTPUT = WA_BOQP-ZMATNR.
SELECT COUNT( * ) FROM MARA WHERE MATNR = WA_BOQP-ZMATNR.

Regards,

Ravi

11 REPLIES 11
Read only

Former Member
0 Likes
1,485

Hi

Please use a Conversion Exit before passing the material number to the "where" clause.

Cheers

Ravish

Read only

Former Member
0 Likes
1,485

Hi,

Ensure you that field WA_BOQP-ZMATNR is in internal format. (and in DB too).

Read only

Former Member
0 Likes
1,485

Hi...

i think No problem at all because you said its working perfactly after transport.

and if no records come from ur query then it will give subrc eq 4. and if material is available in table then first check no space is there in your workarea field ( WA_BOQP-ZMATNR ) value with the help of debugging and it must be of same type on which you are puting where condition.

may this helpful to you..

Regards,

Chintan

Edited by: Chintan_SAP on Apr 24, 2009 4:42 PM

Read only

Former Member
0 Likes
1,486

It might be case of Conversion issue.

YOu have to use the fm CONVERSION_EXIT_MATNR_INPUT before the select query.

call function 'CONVERSION_EXIT_MATNR_INPUT'
exporting
INPUT = WA_BOQP-ZMATNR
Importing
OUTPUT = WA_BOQP-ZMATNR.
SELECT COUNT( * ) FROM MARA WHERE MATNR = WA_BOQP-ZMATNR.

Regards,

Ravi

Read only

0 Likes
1,485

Thanks all,but I think all of u took me wrogly.

1)Iam using conversion exit b4 select query.

2)Ususally this problem is happening immediately after transport of program or immediately after creation of the material.

That SO numbers problem came immediately after transport and material problem is coming immediately after creation of the material.

Hope am clear in my question.

Thanks & regards,

Rock.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,485

Hello Rock,

Ususally this problem is happening immediately after transport of program or immediately after creation of the material

Can you please explain what this statement means ?

BR,

Suhas

Read only

0 Likes
1,485

Hi,

I clubbed 2 different things there,half of my statement is referring to one problem of any report when transported to Production,some select statements giving wrong results.

The second case is happening with material numbers,when u create material and immediately run any report system is unable to select that material.

Hop am clear in my questia.

Thanks & Regards,

Rock.

Read only

0 Likes
1,485

Hi Rock,

perhaps anybody implement any FM "in update task" and is not working fine.

When you create a material (or any other object) you receive the message that "Material saved succesfully" but if there are update process, custom or standard, the database is not updated instead all of this process finish.

If the problem is just after save the material, i think that this is the problem. A Z process that are not working fine in update mode, or that all update process in the system are full and the BD actualization have to wait.

regards,

Pepe

Read only

Former Member
0 Likes
1,485

Hi Rock...

Instead of SELECT COUNT.. better go for SELECT UP TO 1 ROWS......

The reason is that... certain database systems do not manage the number of lines in a table in their catalog and therefore must retrieve this number, the function COUNT( * ) is not suited to check whether a table contains lines at all. You should better use SELECT f ... FROM tab UP TO 1 ROWS for any table field f.

Cheers.....!!

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,485

Hi,

Try this

data l_count type i.

SELECT COUNT( * ) into l_count FROM MARA group by MATNR

having MATNR = '000000000000000001'.

write l_count.

endselect.

if sy-subrc eq 0.

write 'Entry exists'.

endif.

Read only

Former Member
0 Likes
1,485

Thanks all for u r precious time and good replies.