‎2008 Mar 18 10:47 PM
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.
‎2008 Mar 18 11:12 PM
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
‎2008 Mar 19 12:03 AM
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.
‎2008 Mar 19 12:15 AM
‎2008 Mar 19 1:06 AM
‎2008 Mar 19 1:19 AM
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.
‎2008 Mar 19 4:08 AM
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
‎2008 Mar 19 4:32 AM
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
‎2008 Mar 19 4:43 AM
Hi Ganesh,
try this.
Data : lc_zspras TYPE SKAT-SPRAS VALUE 'EN',
Regards,
Chitra
‎2008 Mar 19 4:45 AM
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
‎2008 Mar 20 4:44 PM
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