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

Performance Issue

Former Member
0 Likes
902

Hi All,

please check and give the best to change the code for performance of the below code.

LOOP AT ITAB.

PERFORM GET_IR_AMTS_FOR_PO_LINE.

PERFORM FIGURE_COMMITMENTS_COOI.

APPEND ITAB.

ENDLOOP.

FORM GET_IR_AMTS_FOR_PO_LINE.

SELECT * FROM EKBE WHERE EBELN = ITAB-PO_NO

AND EBELP = ITAB-LINE

AND VGABE EQ '2'

AND ZEKKN EQ ITAB-ZEKKN.

IF EKBE-SHKZG = 'H'. "Credit

EKBE-MENGE = EKBE-MENGE * -1.

EKBE-DMBTR = EKBE-DMBTR * -1.

EKBE-WRBTR = EKBE-WRBTR * -1.

ENDIF.

ENDSELECT.

ENDFORM.

FORM FIGURE_COMMITMENTS_COOI.

SELECT * FROM COOI WHERE REFBT = '020'

AND REFBN = ITAB-PO_NO

AND RFPOS = ITAB-LINE

AND RFKNT = ITAB-ZEKKN.

ITAB-COMMIT_CO = ITAB-COMMIT_CO + COOI-WKGBTR.

ITAB-COMMIT_DOC = ITAB-COMMIT_DOC + COOI-WTGBTR.

ENDSELECT.

ENDFORM.

Thanks,

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
850

hi,

could be like this for your first form? if it's faster depends on the number of entries in your ITAB.

SELECT * FROM ekbe INTO TABLE gt_ekbe

for ALL entries of itab

WHERE ebeln = itab-po_no

AND ebelp = itab-line

AND vgabe EQ '2'

AND zekkn EQ itab-zekkn.

LOOP AT itab ASSIGNING <fs_itab>.

PERFORM get_ir_amts_for_po_line USING gt_ekbe.

PERFORM figure_commitments_cooi.

APPEND itab.

ENDLOOP.

&----


*& Form GET_IR_AMTS_FOR_PO_LINE

&----


  • text

----


  • -->GT_EKBE text

----


FORM get_ir_amts_for_po_line USING gt_ekbe type ... .

DATA: <fs_ekbe> LIKE LINE OF gt_ekbe.

READ TABLE gt_ekbe ASSIGNING <fs_ekbe>

WITH TABLE KEY ebeln = <fs_itab>-po_no

ebelp = <fs_itab>-line

vgabe = '2'

zekkn = <fs_itab>-zekkn.

IF <fs_ekbe>-shkzg = 'H'. "Credit

<fs_ekbe>-menge = ekbe-menge * -1.

<fs_ekbe>-dmbtr = ekbe-dmbtr * -1.

<fs_ekbe>-wrbtr = ekbe-wrbtr * -1.

ENDIF.

ENDFORM. "GET_IR_AMTS_FOR_PO_LINE

7 REPLIES 7
Read only

Former Member
0 Likes
850

hi,

1. Remove select ... endselect statements and use into table statement ..

2. Remove select between loop and endloop and select the data into an internal table at once...

3. Use all the primary key fields while selecting the data ..

Regards,

santosh

Read only

0 Likes
850

Hi Santhosh,

But how to write code without select and endselect. That is i want to know from your side. do you get any different logic please tell me,

Thanks.

Read only

Former Member
0 Likes
851

hi,

could be like this for your first form? if it's faster depends on the number of entries in your ITAB.

SELECT * FROM ekbe INTO TABLE gt_ekbe

for ALL entries of itab

WHERE ebeln = itab-po_no

AND ebelp = itab-line

AND vgabe EQ '2'

AND zekkn EQ itab-zekkn.

LOOP AT itab ASSIGNING <fs_itab>.

PERFORM get_ir_amts_for_po_line USING gt_ekbe.

PERFORM figure_commitments_cooi.

APPEND itab.

ENDLOOP.

&----


*& Form GET_IR_AMTS_FOR_PO_LINE

&----


  • text

----


  • -->GT_EKBE text

----


FORM get_ir_amts_for_po_line USING gt_ekbe type ... .

DATA: <fs_ekbe> LIKE LINE OF gt_ekbe.

READ TABLE gt_ekbe ASSIGNING <fs_ekbe>

WITH TABLE KEY ebeln = <fs_itab>-po_no

ebelp = <fs_itab>-line

vgabe = '2'

zekkn = <fs_itab>-zekkn.

IF <fs_ekbe>-shkzg = 'H'. "Credit

<fs_ekbe>-menge = ekbe-menge * -1.

<fs_ekbe>-dmbtr = ekbe-dmbtr * -1.

<fs_ekbe>-wrbtr = ekbe-wrbtr * -1.

ENDIF.

ENDFORM. "GET_IR_AMTS_FOR_PO_LINE

Read only

0 Likes
850

Hi Rob,

Is it correct code...i am not sure like...every entry of itab contains multiple entries in ekbe...so i want all those entries.

But based on your code we can get only single entry of ekbe with read statment.

Thanks,

Subbu.

Read only

0 Likes
850

Hi,

If ekbe has multiple entries then instead of Reading gt_ekbe, u can loop it...ie.e

LOOP AT gt_ekbe ASSIGNING <fs_ekbe> where.......

-


ENDLOOP.

Also i have one doubt...

LOOP AT itab ASSIGNING <fs_itab>.

PERFORM get_ir_amts_for_po_line USING gt_ekbe.

PERFORM figure_commitments_cooi.

APPEND itab.

ENDLOOP.

Here u are looping at 'itab' and to the same table u r appending the records,, then this is going to be an infinte loop rite !! Wht u say???

Rewards if useful..

Regards

ABAPer 007

Read only

0 Likes
850

That was not APPEND, it was MODIFY.

Read only

0 Likes
850

hi subramanyam,

the code was not correct because i don't how to type your gt_ekpe and your field-symbols, this is your turn

if your EKBE contains various entries for every entry of your itab you should try:

READ TABLE gt_ekbe ASSIGNING <fs_ekbe>

WITH TABLE KEY ebeln = <fs_itab>-po_no

ebelp = <fs_itab>-line

  • vgabe = '2' -> allready in the where statement

zekkn = <fs_itab>-zekkn.

now you have index of the first entry.

Then:

loop at gt-ekbe assigning <fs_ekbe> from index sy-tabix.

IF <fs_ekbe>-po_no NE <fs_itab>-po_no

OR <fs_ekbe>-ebelp NE <fs_itab>-line

OR <fs_ekbe>-zekkn NE <fs_itab>-zekkn.

EXIT.

ENDIF.

<in the loop your logic from your select-endselect>

endloop.

For the Modify you have to change your outer loop:

DATA: ld_index LIKE sy-tabix.

LOOP at itab assigning <fs_itab>.

ld_index = sy-tabix.

...

MODIFY itab from <fs_itab> INDEX ld_index.

ENDLOOP.

what i don't get are the following points:

>IF EKBE-SHKZG = 'H'. "Credit

>EKBE-MENGE = EKBE-MENGE * -1.

>EKBE-DMBTR = EKBE-DMBTR * -1.

>EKBE-WRBTR = EKBE-WRBTR * -1.

>ENDIF.

Why you don't use the "EKBE-SHKZG = 'H'" in the WHERE-condtition?

Why the multiplication? it has no effect on the data of itab.

what you also could keep in mind is the following: perhaps you don't need all the fields of your ekpe, then don't select them and type your gt_ekpe in the way, that you don't have to work with MOVE INTO CORRESPONDING FIELDS.

perhaps it's usefull.