Skip to Content
0
Former Member
Aug 24, 2005 at 05:56 AM

Improve performance

73 Views

Here is the code to display Material Numbers based on part of Purchase Order Long Text entered. But code is bit slow. How it can be altered to improve performance.

-


REPORT ZAM1_MATERIAL_SEARCH_LONGTEXT LINE-SIZE 250.

Tables: MARA.

Parameters: POTEXT(132). "MATNR like MARA-MATNR,

DATA: BEGIN OF IT_TEXT OCCURS 100.

INCLUDE STRUCTURE TLINE.

DATA: END OF IT_TEXT.

DATA: BEGIN OF PO_TEXT OCCURS 1,

MATNR like MARA-MATNR,

POTEXT like TLINE,

END OF PO_TEXT.

DATA: READ_ERR LIKE SY-SUBRC.

DATA: TEMP_TEXT(72), T_TEMP_TEXT(72), flag(1).

IF POTEXT NE ''.

PERFORM MATSELECT.

ENDIF.

&----


*& Form READ_PO_TEXT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form READ_PO_TEXT USING P_MAT_NO P_ERR.

DATA : NAME LIKE THEAD-TDNAME.

REFRESH : IT_TEXT.

MOVE P_MAT_NO TO NAME.

CLEAR : P_ERR.

CALL FUNCTION 'READ_TEXT'

EXPORTING

ID = 'BEST'

LANGUAGE = SY-LANGU

NAME = NAME

OBJECT = 'MATERIAL'

TABLES

LINES = IT_TEXT

EXCEPTIONS

ID = 1

LANGUAGE = 2

NAME = 3

NOT_FOUND = 4

OBJECT = 5

REFERENCE_CHECK = 6

WRONG_ACCESS_TO_ARCHIVE = 7

OTHERS = 8.

MOVE SY-SUBRC TO P_ERR.

endform. " READ_PO_TEXT

&----


*& Form MATSELECT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form MATSELECT.

write: 'Material Number(s)', /.

select * from mara.

flag = 0.

PERFORM READ_PO_TEXT USING MARA-MATNR READ_ERR.

LOOP AT IT_TEXT.

IF IT_TEXT-TDLINE NE '**Legacy Data as follows***'.

SEARCH IT_TEXT-TDLINE FOR POTEXT .

if sy-subrc eq 0.

if flag = 0.

format color 3 on.

write: /.

write: / MARA-MATNR.

flag = 1.

format color off.

endif.

endif.

ENDIF.

if flag = 1.

loop at IT_TEXT.

write: / IT_TEXT-TDLINE.

endloop.

exit.

endif.

ENDLOOP.

APPEND PO_TEXT.

endselect.

endform. " MATSELECT