‎2009 Apr 03 1:02 PM
Hi,
The following statement is taking more time in the database. Kindly provide suggest me the change which can improve the performance
DATA: begin of wa_t001,
bukrs like t001-bukrs,
butxt like t001-butxt,
end of wa_t001,
it_t001 like standard table of wa_t001.
SELECT SINGLE butxt FROM t001
INTO CORRESPONDING FIELDS OF wa_t001
WHERE bukrs = p0001-bukrs.
IF sy-subrc = 0.
MOVE wa_t001-butxt TO i_output-butxt.
ENDIF.
READ TABLE it_t001 INTO wa_t001
WITH KEY bukrs = p0001-bukrs BINARY SEARCH.
IF sy-subrc = 0.
MOVE wa_t001-butxt TO i_output-butxt.
ENDIF.
‎2009 Apr 03 1:07 PM
Hi,
You have used READ TABLE it_t001 INTO wa_t001.
But before u use the statement
sort the internal table as
sort it_t001 by bukrs.
Thanks
‎2009 Apr 03 1:07 PM
Hi,
The READ statement mentioned by you at the end can replace the select statement.
Or Am I not getting your point correctly?
BR/Manas
‎2009 Apr 03 1:12 PM
‎2009 Apr 03 1:13 PM
HI,
You can use this way...It first check's in the internal table not found then hit the DB. You can reduce the DB hits. If you are processing for one company code then one DB hit .
DATA: begin of wa_t001,
bukrs like t001-bukrs,
butxt like t001-butxt,
end of wa_t001,
it_t001 like standard table of wa_t001.
SORT it_0001 BY bukrs.
READ TABLE it_t001 INTO wa_t001
WITH KEY bukrs = p0001-bukrs BINARY SEARCH.
IF sy-subrc = 0.
MOVE wa_t001-butxt TO i_output-butxt.
ELSE.
SELECT SINGLE * FROM t001
INTO CORRESPONDING FIELDS OF wa_t001
WHERE bukrs = p0001-bukrs.
IF sy-subrc = 0.
APPEND wa_t001 TO it_t001 .
ENDIF.
ENDIF.ENDIF.
‎2009 Apr 03 1:14 PM
Hi ,
Try following code -
DATA: begin of wa_t001,
bukrs like t001-bukrs,
butxt like t001-butxt,
end of wa_t001,
it_t001 like standard table of wa_t001.
SELECT SINGLE butxt FROM t001
INTO wa_t001-butxt
WHERE bukrs = p0001-bukrs.
IF sy-subrc = 0.
MOVE wa_t001-butxt TO i_output-butxt.
ENDIF.
Sort it_t001 by bukrs.
READ TABLE it_t001 INTO wa_t001
WITH KEY bukrs = p0001-bukrs BINARY SEARCH.
IF sy-subrc = 0.
MOVE wa_t001-butxt TO i_output-butxt.
ENDIF.
‎2009 Apr 03 1:22 PM
Hi Try this code
REPORT ztest1 .
TABLES: t001.
DATA: BEGIN OF wa_t001,
bukrs LIKE t001-bukrs,
butxt LIKE t001-butxt,
END OF wa_t001,
it_t001 LIKE STANDARD TABLE OF wa_t001.
DATA: i_output_butxt TYPE t001-butxt.
PARAMETERS: p_bukrs TYPE t001-bukrs.
SELECT SINGLE bukrs butxt FROM t001
INTO CORRESPONDING FIELDS OF wa_t001
WHERE bukrs = p_bukrs.
APPEND wa_t001 TO it_t001.
READ TABLE it_t001 INTO wa_t001 WITH KEY bukrs = p_bukrs
BINARY SEARCH.
IF sy-subrc = 0.
MOVE wa_t001-butxt TO i_output_butxt.
ENDIF.
WRITE:/ i_output_butxt .
‎2009 Apr 03 1:24 PM
use the f1 key before u use the syntax in the program and just try to know what is the purpose of the
syntax used.
regds
sachhi