‎2020 Nov 16 10:36 AM
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.
‎2020 Nov 16 2:05 PM
‎2020 Nov 16 10:36 AM
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
‎2020 Nov 16 11:14 AM
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.
‎2020 Nov 16 12:26 PM
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
‎2020 Nov 16 2:05 PM
‎2020 Nov 16 6:35 PM
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 .
‎2020 Nov 17 6:32 AM
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.
‎2020 Nov 18 12:18 PM
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)
‎2020 Nov 16 5:17 PM
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.
‎2020 Nov 17 6:32 AM
Inner joins are very very rarely worse than FOR ALL ENTRIES. This has been demonstrated time and time again.
‎2020 Nov 16 7:44 PM
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! 🙂
‎2020 Nov 17 1:57 AM
Hi,
The best way to improve performance is to opt for CDS Views.
Refer:-
Thanks,
Tarun Gambhir
‎2020 Nov 17 9:47 AM
You should ask all your questions in the public forum. That way you will get more responses.
‎2020 Nov 17 9:48 AM
I think since the OP is a beginner, perhaps they should master the basics of ABAP before trying CDS views.
‎2020 Nov 17 6:40 PM
@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
‎2020 Nov 17 6:31 AM
First step:
When posting any code, use the CODE button in the editor here.
‎2020 Nov 17 9:45 AM