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

bad performance

former_member713390
Participant
0 Likes
4,063

how can i improve the performance
TYPE-POOLS SLIS.


*TABLES :MARA,MARC,MAKT,T001W,T023T.


DATA : BEGIN OF I_MARA ,
MATNR LIKE MARA-MATNR,
MATKL LIKE MARA-MATKL,
MAKTX LIKE MAKT-MAKTX,
SPRAS LIKE MAKT-SPRAS,
WGBEZ LIKE T023T-WGBEZ,
END OF I_MARA .
DATA : IT_MARA LIKE TABLE OF I_MARA .
DATA : BEGIN OF I_MARC ,
MATNR LIKE MARA-MATNR,
WERKS LIKE MARC-WERKS,
NAME1 LIKE T001W-NAME1,
SPRAS LIKE T001W-SPRAS,
END OF I_MARC.
DATA : IT_MARC LIKE STANDARD TABLE OF I_MARC .

DATA: BEGIN OF I_MARAFINAL ,
MATNR LIKE MARA-MATNR,
MAKTX LIKE MAKT-MAKTX,
WERKS LIKE MARC-WERKS,
NAME1 LIKE T001W-NAME1,
MATKL LIKE MARA-MATKL,
WGBEZ LIKE T023T-WGBEZ,
END OF I_MARAFINAL.
DATA : IT_MARAFINAL LIKE TABLE OF I_MARAFINAL .

DATA : IT_FCAT TYPE SLIS_T_FIELDCAT_ALV .
DATA : WA_FCAT TYPE SLIS_FIELDCAT_ALV.


SELECT-OPTIONS : S_MATNR FOR I_MARA-MATNR.
SELECT-OPTIONS : S_WERKS FOR I_MARC-WERKS.
SELECT-OPTIONS : S_MATKL FOR I_MARA-MATKL.


START-OF-SELECTION.
PERFORM GET_DATA.
PERFORM VALIDATE_FCAT.

END-OF-SELECTION.
PERFORM DISPLAY_ALV.


FORM GET_DATA.
CLEAR IT_MARAFINAL.
SELECT MARA~MATNR MARA~MATKL
MAKT~MAKTX MAKT~SPRAS
T023T~WGBEZ
INTO TABLE IT_MARA
FROM MARA
INNER JOIN MAKT ON MARA~MATNR = MAKT~MATNR
INNER JOIN T023T ON MARA~MATKL = T023T~MATKL
AND MAKT~SPRAS = T023T~SPRAS
WHERE MARA~MATNR IN S_MATNR
AND MARA~MATKL IN S_MATKL .

SELECT MARC~MATNR MARC~WERKS
T001W~NAME1 T001W~SPRAS
INTO TABLE IT_MARC
FROM MARC
INNER JOIN T001W ON MARC~WERKS = T001W~WERKS
FOR ALL ENTRIES IN IT_MARA
WHERE MATNR = IT_MARA-MATNR
AND SPRAS = IT_MARA-SPRAS
AND MARC~WERKS IN S_WERKS .





LOOP AT IT_MARC INTO I_MARC .
READ TABLE IT_MARA INTO I_MARA WITH KEY MATNR = I_MARC-MATNR
SPRAS = I_MARC-SPRAS .

IF sy-subrc = 0.

I_MARAFINAL-MATNR = I_MARA-MATNR.
I_MARAFINAL-MAKTX = I_MARA-MAKTX.
I_MARAFINAL-WERKS = I_MARC-WERKS.
I_MARAFINAL-NAME1 = I_MARC-NAME1.
I_MARAFINAL-MATKL = I_MARA-MATKL.
I_MARAFINAL-WGBEZ = I_MARA-WGBEZ.
APPEND I_MARAFINAL TO IT_MARAFINAL.

ENDIF.
* CLEAR IT_MARAFINAL.

ENDLOOP.
ENDFORM.

FORM DISPLAY_ALV.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IT_FIELDCAT = IT_FCAT
TABLES
T_OUTTAB = IT_MARAFINAL.
ENDFORM.

FORM VALIDATE_FCAT.

1 ACCEPTED SOLUTION
Read only

RaymondGiuseppi
Active Contributor
3,904

Could you add the MARC with a JOIN in the first select and remove the FOR ALL ENTRIES.

  • You could also remove T001W and T023T from the SELECT and enrich the internal table in a LOOP following the main SELECT. (small buffered tables)
  • Did you execute an Abap or SQL trace of your program?
16 REPLIES 16
Read only

former_member30
Product and Topic Expert
Product and Topic Expert
3,904

Hi and welcome to the SAP Community!

Thank you for visiting SAP Community to get answers to your questions. Since you're asking a question here for the first time, I recommend that you familiarize yourself with https://community.sap.com/resources/questions-and-answers (if you haven't already), as it provides tips for preparing questions that draw responses from our members. For example, you can outline what steps you took to find answers (and why they weren't helpful). The more details you provide, the more likely it is that members will be able to assist you. Should you wish, you can revise your question by selecting Actions, then Edit (although once someone answers your question, you'll lose the ability to edit the question -- but if that happens, you can leave more details in a comment). Finally, if you're hoping to connect with readers, please consider adding a picture to your profile. Here's how you do it: https://www.youtube.com/watch?v=F5JdUbyjfMA&list=PLpQebylHrdh5s3gwy-h6RtymfDpoz3vDS. By personalizing your profile with a photo of you, you encourage readers to respond.

Cheers,

Julia SAP Community Moderator

Read only

jens_hoetger
Explorer
3,904

Hello,

to get the time-consuming parts of your program I suggest to start a trace in ST12 for it.

On a very first glance I recommend to define the table IT_MARA as sorted table with key components MATNR and SPRAS. With the current definition the READ TABLE has to iterate over the complete table for every record in table IT_MARC.

Alternatively you can sort IT_MARA by these fields and add a "BINARY SEARCH" to the READ TABLE statement.

Read only

FredericGirod
Active Contributor
3,904

Inner join with table T023T and T001W is strange for me. you should have very limited data in these tables. You could get the full entries of these tables outside of the SELECT statement, and compose your data from internal tables

Read only

RaymondGiuseppi
Active Contributor
3,905

Could you add the MARC with a JOIN in the first select and remove the FOR ALL ENTRIES.

  • You could also remove T001W and T023T from the SELECT and enrich the internal table in a LOOP following the main SELECT. (small buffered tables)
  • Did you execute an Abap or SQL trace of your program?
Read only

0 Likes
3,904

Thank you

But I Dont Want To Remove Any Table I want to Keep All Of Them And At Ahe Same Time Improve The Performance .

Read only

3,904

Try not to SHOUT. (I.e. please use mixed case).

As an ABAP beginner you should not be using PERFORMs and FORMs, you should be uses classes and methods. FORMs are obsolete, and are not to be used in the new programs.

Read only

0 Likes
3,904

Join is usually (much) better than FAE. Adding small (buffered) table in the main SELECT would generally generate more load on the data server than loading (completely, or partially if you have selection criteria in the program) these small tables and then enriching the final table. (use sorted type internal tables and update final table in a single loop)

Read only

Abinathsiva
Active Contributor
3,904

Hi afsane_salehi,

Instead of inner joins for these table - for all entries are best since all this tables will be having lesser amount of records - but make sure sy-subrc and is not intial checks before performing ALL Entires.

simple read inside loop and load final table through work area.

Read only

matt
Active Contributor
0 Likes
3,904

Inner joins are very very rarely worse than FOR ALL ENTRIES. This has been demonstrated time and time again.

Read only

Patrick_vN
Active Contributor
0 Likes
3,904

Question: Why do you use the SO_WERKS in the SELECT on MARC and not in the SELECT on MARA?

This means that if there are materials that do not exist for the plant(s) you've selected, you're loading them into the application layer for nothing and slowing down the READ TABLE statements as well since there is more data there then needed.

Anyway, what Raymond says! 🙂

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
3,904

Hi,

The best way to improve performance is to opt for CDS Views.

Refer:-

https://help.sap.com/viewer/f2e545608079437ab165c105649b89db/7.5.6/en-US/7c078765ec6d4e6b88b71bdaf8a...

Thanks,

Tarun Gambhir

Read only

matt
Active Contributor
3,904

You should ask all your questions in the public forum. That way you will get more responses.

Read only

matt
Active Contributor
3,904

I think since the OP is a beginner, perhaps they should master the basics of ABAP before trying CDS views.

Read only

0 Likes
3,904

@matthew.billingham

Dear Matthew Billingham

Thanks a lot for your useful instructions. Unfortunately I couldn't find the public platform. I would appreciate if I can get help from you and ask my questions regarding the problems I may face. Best regards

Read only

matt
Active Contributor
3,904

First step:

When posting any code, use the CODE button in the editor here.

Read only

matt
Active Contributor
0 Likes
3,904

Don't use BINARY SEARCH. Use a SORTED table.