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

Expensive statement

Former Member
0 Likes
759

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.

7 REPLIES 7
Read only

Former Member
0 Likes
721

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

Read only

Former Member
0 Likes
721

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

Read only

Former Member
0 Likes
721

Hi,

Try to remove corresponding fields.

Thanks,

Read only

Former Member
0 Likes
721

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.

Read only

Former Member
0 Likes
721

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.

Read only

Former Member
0 Likes
721

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 .

Read only

Former Member
0 Likes
721

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