Skip to Content
author's profile photo Former Member
Former Member

Improve performance

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Aug 24, 2005 at 06:47 AM

    Hi Pratihba,

    There are some options to improve the performance:

    1. The search for the material in the text table can be done directly (not line by line): SEARCH IT_TEXT FOR POTEXT.

    2. You now retrieve one material from the database and then use the READ_TEXT to try to get the purchasing text. You'd better first get all material numbers into an internal table and then check in table STXH for which materials there is a purchasing text at all.

    Regards,

    John.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 24, 2005 at 07:16 AM

    Hi Prathiba,

    try that:

    -> all matnr in internal table

    1) select matnr from mara into table itab

    where...

    all texts to matnr in int. table

    2) select * from stxh into table text

    where tdobject = 'MATERIAL'

    and tdid = 'BEST'

    and tdspras = sy-langu.

    *loop itab and check 1st if text exists

    3) loop at itab.

    read table text with key tdname = mara-matnr...

    if sy-subrc = 0.

    -> fm read text

    ...

    Andreas

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.