Application Development 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: 

Improve performance

Former Member
0 Kudos

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

2 REPLIES 2

Former Member
0 Kudos

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.

andreas_mann3
Active Contributor
0 Kudos

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