‎2007 Mar 23 4:54 PM
hi folks,
I have an issue related to this query for quite sometime and tried to find what the problem is?
Can anyone help me understand what am I missing
data: begin of itab1 occurs 0,
employee(8) type n,
reason_type(2),
reason_code(2),
return_date like sy-datum,
end of itab1.
data: it_0019 like pa0019 occurs 0 with header line.
select single * from pa0019 into it_0019 where
pernr = itab1-employee and tmart ='z9' and termn = '20050707'
if sy-subrc = 0.
move-corresponding it_0019 to wa_0019.
endif.
I am getting -sy-subrc = 4 and I do see a record in the table for this.
I am not able to understand why it is returning the value as '4'.
It is avery simple query but giving a hard time.
Thanks in advance, would really appreciate it.
SK
‎2007 Mar 23 5:05 PM
Hi,
In your where condition your are using itab1 work area 'pernr = itab1-employee' check this if it has a value.
‎2007 Mar 23 5:25 PM
I checked the field value and there is am employee id number while running the query.
Thanks for the reply,
SK
‎2007 Mar 23 6:48 PM
There is problem with the select statement.
'select single * from pa0019 into it_0019'
In this case you are selecting single records from table pa0019. The selection is made on all the fields of table PA0019 but the internal table 'it_0019' has only four fields also the fields name in internal table are different then that of table pa0019.
This issue can be resolve with below steps.
(1) Change the internal table field names as what they appear in PA0019
(2) change the select statement as :
SELECT single * from PA0019 into CORRESPONDING fields of table it_0019
WHERE....
Regards,
Sandeep
‎2007 Mar 23 7:04 PM
Your WHERE clause <u>tmart = 'z9'</u> should be <u>tmart = 'Z9'</u> (in upper case).
‎2007 Mar 23 9:34 PM
One common advice I give for SELECT:
Just comment all the conditions in WHERE clause and keep one at a time. now, debug and see the SY-SUBRC value..... If this clause is fine, then uncomment the next clause..and so on......
This way, it is easy to catch the error..
By the way, just try by replacing the 'z' with 'Z' in 2nd WHERE clause.
Reward points if helpful
Regards
‎2007 Mar 23 9:40 PM
Hi,
Check if itab1-employee is having value in debug mode and if it has any zero prefix in it.
The database stores personnel numbers with zero prefix. If it is not there use conversion routine to insert the leading zeroes.
Regards,
Subramanian
‎2007 Mar 26 5:05 PM
Hi guys,
sorry for replying to this thread a bit late, I identified the problem. it was in a BDC program which the particular record was getting created in 0019. The query was fine, because I had tried everything that you guys had mentioned above even then the query was failing. But later identified that the record was getting created through a BDC program in a wrong way. I fixed that and rest was fine. It tooka while to figure that out.
Thanks anyway for your quick respnse, shall award points accordingly.
SK