cancel
Showing results for 
Search instead for 
Did you mean: 

SAP ABAP Optimization Help

berkantA
Discoverer
0 Kudos
242

Dear all,

Could someone help me to optimize this ABAP CODE? It works in dev System however, after I move it to the live; Thi

REPORT ZBI0005.
tables: vbap , zbi_vbap_atwrt .

DATA: lt_zbi_vbap TYPE TABLE OF zbi_vbap_atwrt,
ls_zbi_vbap TYPE zbi_vbap_atwrt.

TYPES: BEGIN OF gty_list,
vbeln TYPE VBELN_VA,
posnr TYPE POSNR_VA,
cuobj TYPE CUOBJ_VA,
ATWRT TYPE atwrt,
END OF gty_list.


DATA: iv_cuobj TYPE inob-cuobj,
lt_data TYPE TABLE OF conf_out,
ls_data TYPE conf_out,
lt_atwrt TYPE TABLE OF char20
.

DATA: gt_data TYPE TABLE OF gty_list,
gs_data TYPE gty_list.

select p~vbeln , p~posnr, p~cuobj
from vbap as p inner join vbak as k on p~vbeln = k~vbeln
INTO CORRESPONDING FIELDS OF TABLE @GT_data
where p~erdat >= '20240101'
and k~VBTYP = 'C'.

DELETE FROM zbi_vbap_atwrt.

LOOP AT gt_data INTO gs_data.
CLEAR: lt_data, lt_atwrt.
iv_cuobj = gs_data-cuobj.

CALL FUNCTION 'VC_I_GET_CONFIGURATION'
EXPORTING
instance = iv_cuobj
TABLES
configuration = lt_data
EXCEPTIONS
instance_not_found = 1
internal_error = 2
no_class_allocation = 3
instance_not_valid = 4
others = 5.

IF sy-subrc = 0.

DELETE lt_data WHERE atnam <> 'H_FYT_KTG_KON'.

LOOP AT lt_data INTO ls_data.
READ TABLE gt_data WITH KEY vbeln = gs_data-vbeln posnr = gs_data-posnr cuobj = gs_data-cuobj INTO gs_data.
IF sy-subrc = 0.
gs_data-atwrt = ls_data-atwrt.

CLEAR ls_zbi_vbap.
ls_zbi_vbap-mandt = sy-mandt.
ls_zbi_vbap-vbeln = gs_data-vbeln.
ls_zbi_vbap-posnr = gs_data-posnr.
ls_zbi_vbap-cuobj = gs_data-cuobj.
ls_zbi_vbap-atwrt = gs_data-atwrt.

APPEND ls_zbi_vbap TO lt_zbi_vbap.
ENDIF.
ENDLOOP.

ELSE.

ENDIF.
ENDLOOP.


INSERT zbi_vbap_atwrt FROM TABLE lt_zbi_vbap.
COMMIT WORK.

s program doesn't finish.

Sandra_Rossi
Active Contributor
Please use the buttons "..." and "</>" to display your code nicely. See how to do it here: https://community.sap.com/t5/questions-about-sap-websites/how-to-post-code-in-sap-community-gt-2024/...
Sandra_Rossi
Active Contributor
0 Kudos
(Run an ABAP Trace on your code with a small data set, and show us what is the top 10 of time %)
Sandra_Rossi
Active Contributor
0 Kudos
The whole time is spent in VC_I_GET_CONFIGURATION, not in your program. I don't know this standard function module. Maybe you may call it differently to avoid the loop? Or another way to call the standard process? Possibly contact SAP support if you can run the same function module in a standard way and can reproduce the slowness. Note that your trace doesn't show the number of calls in each line, and it's also missing a lot of lines, impossible to see what is slow in each function module/method.

Accepted Solutions (0)

Answers (1)

Answers (1)

berkantA
Discoverer
0 Kudos

I think you want this pic.

berkantA_0-1725627197149.png

 Thank you for your support. I am waiting for your answer.

 

Sandra_Rossi
Active Contributor
0 Kudos
Please don't post an answer, which is reserved to propose a solution. Instead click on "Replies" (either on Question or on an existing REAL answer) and then "Comment". Thank you.