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

Select Statement is not working

Former Member
0 Likes
1,240

Hi All,

I am working on Master Data Text Datasource customer exit. Reading only restricted records using select statement if it is valid then those records move into I_T_DATA. If not they are not going to read.

I have written the following code .

Data : ls_rotextstr2 TYPE ROTEXTSTR2. '' Extrct Struct Name

*&Assigning values language and chart of accounts to variables

Data : lc_zspras TYPE SKAT-SPRAS VALUE 'E',

lc_Zktopl TYPE SKAT-KTOPL VALUE 'GCOA',

lc_zsaknr TYPE SKAT-SAKNR.

LOOP AT I_T_DATA INTO ls_rotextstr2.

gi_tabix = SY-TABIX.

SELECT SINGLE SPRAS KTOPL SAKNR FROM SKAT INTO

(lc_zspras, lc_Zktopl, lc_zsaknr)

WHERE SPRAS = lc_zspras

AND KTOPL = lc_Zktopl.

IF SY-SUBRC EQ 0.

MODIFY I_T_DATA FROM ls_rotextstr2.

ENDIF.

ENDLOOP.

Here select statement reading all records like other than 'EN" and 'GCOA' and going to Subrc condition.

Please some one take a look at the programme and tell me where I am making mistake. I just want the records that are language = 'EN' and Chart of Accounts = 'GCOA'.

Your suggestions are very help full to me,

Thanks

Ganesh.

10 REPLIES 10
Read only

Former Member
0 Likes
1,066

Hi

Change your query as

 
SELECT SINGLE SPRAS KTOPL SAKNR FROM SKAT INTO
(lc_zspras, lc_Zktopl, lc_zsaknr)
WHERE SPRAS = sy-langu
AND KTOPL = 'GCOA'. 

Regards,

Atish

Read only

0 Likes
1,066

Hi Atish,

Thanks for your quick reply, I need only language = 'EN'. Please could you tell me how can I restrict particular language.

Thanks

Dayaker Reddy.

Read only

0 Likes
1,066

SET LANGUAGE 'E'

Read only

0 Likes
1,066

Then change code

SPRAS = 'E'.

Regards,

Atish

Read only

0 Likes
1,066

Hi Atish/Sophie,

Please check my code in the begining, I already assigned 'E', becoz of our company policy we need to be used constant in where condition that is the reason I have used them in the declaration.

Thanks for your coordination, like when I am debuging select statement taking all records with all chart of accounts. If I filter with GCOA, 'E' I suppose to get only 2033 records but I am getting 36000 records

Please could you guide me in the right way

Thanks

Dayaker Reddy.

Read only

Former Member
0 Likes
1,066

Hi,

Avoid using select query within loop.

If u really have requirement to select based on the internal table, select it before and use read statement .Or u can also use 'for all entries'.

Regards,

ramya

Read only

Former Member
0 Likes
1,066

Hi,

Try this..

types : begin of s,

spras type skat-spras,

ktopl type skat-ktopl,

saknr type skat-saknr,

end of s.

data i_t_data type standard table of s with header line.

Data : ls_rotextstr2 TYPE ROTEXTSTR2. " Extrct Struct Name

*&Assigning values language and chart of accounts to variables

Data : lc_zspras TYPE SKAT-SPRAS VALUE 'E',

lc_Zktopl TYPE SKAT-KTOPL VALUE 'GCOA',

lc_zsaknr TYPE SKAT-SAKNR.

*gi_tabix = SY-TABIX.

SELECT SPRAS KTOPL SAKNR FROM SKAT INTO

table i_t_data

WHERE SPRAS = lc_zspras

AND KTOPL = lc_Zktopl.

Edited by: Kamini Rawat on Mar 19, 2008 5:56 AM

Read only

Former Member
0 Likes
1,066

Hi Ganesh,

try this.

Data : lc_zspras TYPE SKAT-SPRAS VALUE 'EN',

Regards,

Chitra

Read only

ashiqali_ratnani
Explorer
0 Likes
1,066

Hi Ganesh,

The select query is fine and working..

Just move it outside the loop and use the read statement within the loop..

Thanks,

Ashiq Ali

Read only

Former Member
0 Likes
1,066

Hi,

I found the answer for this logic,

here is the solution

data : it_rotextstr2 like rotextstr2 occurs 0 with header line.

it_rotextstr2[] = i_t_data[].

delete it_rotextstr2[] where key1 ne lc_zktopl or langu ne lc_zspras.

refresh i_t_data[].

i_t_data[] = it_rotextstr2[].

Thanks

Ganesh Reddy