09-24-2014 3:01 PM
Hi Gurus.
I need improve the program performance of INTERFACE coulg you suggest me( or bapi or other way the tuning the performance)?
Suggestions are welcome.
DATA: v_resposta(3) TYPE c,
v_tabix TYPE sy-tabix.
CLEAR:t_vbak1[],
t_kna1_1[],
t_adrc1[],
t_vbap1[],
t_marc1[].
SELECT vbeln
bstnk
kunnr
FROM vbak
INTO TABLE t_vbak1
WHERE erdat IN s_erdat
AND vkorg IN s_vkorg
AND vtweg IN s_vtweg.
IF sy-subrc = 0.
SELECT vbeln
matnr
FROM vbap
INTO TABLE t_vbap1
FOR ALL ENTRIES IN t_vbak1
WHERE vbeln = t_vbak1-vbeln.
IF sy-subrc = 0.
SELECT matnr
ladgr
FROM marc
INTO TABLE t_marc1
FOR ALL ENTRIES IN t_vbap1
WHERE matnr = t_vbap1-matnr.
IF sy-subrc = 0.
SORT: t_vbak1 BY vbeln ,
t_vbap1 BY vbeln
matnr,
t_marc1 BY matnr.
LOOP AT t_vbak1 INTO w_vbak1.
v_tabix = sy-tabix.
CLEAR v_resposta.
LOOP AT t_vbap1 INTO w_vbap1 WHERE vbeln = w_vbak1-vbeln.
READ TABLE t_marc1 INTO w_marc1 WITH KEY matnr = w_vbap1-matnr BINARY SEARCH.
IF sy-subrc = 0.
IF w_marc1-ladgr = '21'.
v_resposta = 'SIM'.
ENDIF.
ENDIF.
ENDLOOP.
IF v_resposta IS INITIAL.
DELETE t_vbak1[] INDEX v_tabix.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
ENDIF.
Thanks all
09-24-2014 3:09 PM
09-24-2014 3:09 PM
09-24-2014 3:12 PM
Hi Ronaldo,
(hi Philip !)
so, for my point of view, have a look to the VAPMA table
regards
Fred
09-24-2014 3:23 PM
Hi Ronaldo ,
For the loop parts i think you do not need to use first loop i mean this one
LOOP AT t_vbak1 INTO w_vbak1.
Because in the second one you just vbeln from this table and in select parts you re using this code
FOR ALL ENTRIES IN t_vbak1
WHERE vbeln = t_vbak1-vbeln.
so you doing this in select you can just delete first loop you looping that for nothing.
Should be like this i think.
LOOP AT t_vbap1 INTO w_vbap1.
READ TABLE t_marc1 INTO w_marc1 WITH KEY matnr = w_vbap1-matnr BINARY SEARCH.
IF sy-subrc = 0.
IF w_marc1-ladgr = '21'.
v_resposta = 'SIM'.
ENDIF.
ENDIF.
IF v_resposta IS INITIAL.
DELETE t_vbak1 where vbeln eq w_vbap1-vbeln.
ENDIF.
ENDLOOP.
09-24-2014 3:29 PM
loop at t_vbak1 into w_vbak1.
CLEAR v_resposta.
loop at t_vbap1 into w_vbap1 from v_index.
if w_vbak1-vbeln <> w_vbap1-vbeln.
v_index = sy-tabix.
exit.
else.
READ TABLE t_marc1 INTO w_marc1 WITH KEY matnr = w_vbap1-matnr BINARY SEARCH.
IF sy-subrc = 0.
IF w_marc1-ladgr = '21'.
v_resposta = 'SIM'.
ENDIF.
ENDIF.
endif.
endloop.
IF v_resposta IS INITIAL.
DELETE t_vbak1[] INDEX v_tabix.
ENDIF.
ENDLOOP.
replace with this code
09-24-2014 3:44 PM
Hi Vamshi ,
i think this is slower performance lets say t_vbak1 has 10.000 line and t_vbap1 has 10.000 line by your code it ll loop 10.000 * 10.000 = 100.000.000 times but in ronalde code only same vbeln will loop by using where in loop and in vbak vbeln is only key in vbak vbeln and posnr only key so 10.000 * 1 * posnr is so better performance than this.
09-24-2014 4:47 PM
Hi Asim,
try my code it is much faster. u can check in runtime analysis too.
if possible try and let me know.....
Vamshi A
09-24-2014 4:04 PM
TABLES: VBAK.
SELECT-OPTIONS: S_ERDAT FOR VBAK-ERDAT,
S_VKORG FOR VBAK-VKORG,
S_VTWEG FOR VBAK-VTWEG.
TYPES: BEGIN OF TY_TAB3,
VBELN TYPE VBAK-VBELN,
BSTNK TYPE VBAK-BSTNK,
KUNNR TYPE VBAK-KUNNR,
MATNR TYPE VBAP-MATNR,
LADGR TYPE MARC-LADGR,
END OF TY_TAB3.
DATA:INT_TAB3 TYPE SORTED TABLE OF TY_TAB3 WITH NON-UNIQUE KEY VBELN MATNR.
SELECT VBAK~VBELN
VBAK~BSTNK
VBAK~KUNNR
VBAP~MATNR
MARC~LADGR
FROM VBAK JOIN VBAP ON VBAK~VBELN = VBAP~VBELN JOIN MARC ON VBAP~MATNR = MARC~MATNR
INTO TABLE INT_TAB3
WHERE VBAK~ERDAT IN S_ERDAT
AND VBAK~VKORG IN S_VKORG
AND VBAK~VTWEG IN S_VTWEG AND MARC~LADGR = '21'.
Regards,
Philip.
09-24-2014 4:15 PM
09-24-2014 4:44 PM
You can trigger SQL trace and find out the duration for each query that ran.
09-24-2014 5:02 PM
Hi Ronaldo,
In selecting the data your select statements are enough (Take one temp table of structure vbap1 and delete duplicates of matnr then apply for all entries to marc), there are changes to be done in loops, try my code and let me know...
It will work......
Vamshi A
09-24-2014 5:12 PM