Application Development 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: 

Urgent Pls help

Former Member
0 Kudos

Hi SDN's

Pls help me to improve the performance of the following code

form get_data .

SELECT HKONT budat waers blart dmbtr sgtxt aufnr

INTO TABLE it_detail

FROM bsis

WHERE bukrs = p_bukrs

AND HKONT in S_HKONT

AND budat IN s_budat

AND blart IN s_blart

AND aufnr in S_aufnr

AND werks = p_werks.

SORT it_detail by budat .

IF p_waers IS NOT INITIAL.

LOOP AT it_detail.

CALL FUNCTION 'CONVERT_TO_FOREIGN_CURRENCY'

EXPORTING

date = p_xdate

foreign_currency = p_waers

local_amount = it_detail-dmbtr

local_currency = it_detail-waers

type_of_rate = p_kurst

IMPORTING

foreign_amount = it_detail-dmbtr

EXCEPTIONS

no_rate_found = 1

overflow = 2

no_factors_found = 3

OTHERS = 4.

IF sy-subrc = 0.

CLEAR it_detail-waers.

it_detail-waers = p_waers.

MODIFY it_detail. " transporting dmbtr.

ENDIF.

ENDLOOP.

ENDIF.

endform. " get_data

&----


*& Form get_sum

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form get_cost .

LOOP AT it_detail.

move-corresponding it_detail to it_sum.

IF it_detail-blart = 'GI' .

it_sum-raw = it_detail-dmbtr.

ELSEIF it_detail-blart = 'GG' AND it_detail-sgtxt(1) NE 'S' . .

it_sum-external = it_detail-dmbtr.

ELSEIF it_detail-blart = 'GG' AND it_detail-sgtxt(1) = 'S' .

it_sum-standard = it_detail-dmbtr.

ELSEIF it_detail-blart = 'SA' AND it_detail-sgtxt(2) = 'DR' .

it_sum-machine = it_detail-dmbtr.

ELSE.

it_sum-others = it_detail-dmbtr.

ENDIF.

APPEND it_sum.

CLEAR it_sum.

ENDLOOP.

  • Calculate Line item total for Summary Option

LOOP AT it_sum.

it_sum-total = it_sum-raw + it_sum-external + it_sum-standard + it_sum-machine + it_sum-others.

MODIFY it_sum INDEX sy-tabix TRANSPORTING total.

CLEAR it_sum.

ENDLOOP.

ENDFORM. " get_cost

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

join the loop conditions:

LOOP AT it_detail.

CALL FUNCTION 'CONVERT_TO_FOREIGN_CURRENCY'

..in this loop itself before the ENDLOOP,

put the code

move-corresponding it_detail to it_sum.

IF it_detail-blart = 'GI' .
it_sum-raw = it_detail-dmbtr.
ELSEIF it_detail-blart = 'GG' AND it_detail-sgtxt(1) NE 'S' . .
it_sum-external = it_detail-dmbtr.
ELSEIF it_detail-blart = 'GG' AND it_detail-sgtxt(1) = 'S' .
it_sum-standard = it_detail-dmbtr.
ELSEIF it_detail-blart = 'SA' AND it_detail-sgtxt(2) = 'DR' .
it_sum-machine = it_detail-dmbtr.
ELSE.
it_sum-others = it_detail-dmbtr.
ENDIF.
APPEND it_sum.
CLEAR it_sum.

Since it_sum was derived from it_detail, the calculation can also be done in the above loop itself.

so perform this calculation before the ENDLOOP of it_detail.

it_sum-total = it_sum-raw + it_sum-external + it_sum-standard + it_sum-machine + it_sum-others.

hope this helps....

regards,

madhumitha

2 REPLIES 2

Former Member
0 Kudos

Hi,

join the loop conditions:

LOOP AT it_detail.

CALL FUNCTION 'CONVERT_TO_FOREIGN_CURRENCY'

..in this loop itself before the ENDLOOP,

put the code

move-corresponding it_detail to it_sum.

IF it_detail-blart = 'GI' .
it_sum-raw = it_detail-dmbtr.
ELSEIF it_detail-blart = 'GG' AND it_detail-sgtxt(1) NE 'S' . .
it_sum-external = it_detail-dmbtr.
ELSEIF it_detail-blart = 'GG' AND it_detail-sgtxt(1) = 'S' .
it_sum-standard = it_detail-dmbtr.
ELSEIF it_detail-blart = 'SA' AND it_detail-sgtxt(2) = 'DR' .
it_sum-machine = it_detail-dmbtr.
ELSE.
it_sum-others = it_detail-dmbtr.
ENDIF.
APPEND it_sum.
CLEAR it_sum.

Since it_sum was derived from it_detail, the calculation can also be done in the above loop itself.

so perform this calculation before the ENDLOOP of it_detail.

it_sum-total = it_sum-raw + it_sum-external + it_sum-standard + it_sum-machine + it_sum-others.

hope this helps....

regards,

madhumitha

Former Member
0 Kudos

hi,

One more change is required ...

LOOP AT it_detail.

lv_tabix = sy-tabix.

CALL FUNCTION 'CONVERT_TO_FOREIGN_CURRENCY'

EXPORTING

date = p_xdate

foreign_currency = p_waers

local_amount = it_detail-dmbtr

local_currency = it_detail-waers

type_of_rate = p_kurst

IMPORTING

foreign_amount = it_detail-dmbtr

EXCEPTIONS

no_rate_found = 1

overflow = 2

no_factors_found = 3

OTHERS = 4.

IF sy-subrc = 0.

CLEAR it_detail-waers.

it_detail-waers = p_waers.

MODIFY it_detail index lv_tabix transporting dmbtr waers.

ENDIF.

Regards,

Santosh