cancel
Showing results for 
Search instead for 
Did you mean: 

Internal table on Start Routine

Former Member
0 Kudos

Hello

I have 5 key figures. They have an standard routine with a select statement. Basically they have to read an external DSO and get some fields values.

As all of them have the same SELECT statement I think it would be better to replace this with a select in the Start Routine, in order to improve performance. But unfortunatelly I'm not an abap programmer.

How could this be replaced in the Start routine ?

select single EXRATEXACC DOC_CURRCY NETVAL_INV

into (h_rate, h_dcurr, h_inv)

from /bic/azsdbiio100

where BILL_NUM eq SOURCE_FIELDS-/BIC/ZREFDOC

and BILL_ITEM eq SOURCE_FIELDS-/BIC/ZREFDOCLN

and COMP_CODE eq SOURCE_FIELDS-COMP_CODE.

if sy-subrc ne 0. " Not found

select single EXRATEXACC DOC_CURRCY NETVAL_INV

into (h_rate, h_dcurr, h_inv)

from /bic/azsdbiio100

where DOC_NUMBER eq SOURCE_FIELDS-DOC_NUMBER

and S_ORD_ITEM eq SOURCE_FIELDS-S_ORD_ITEM

and COMP_CODE eq SOURCE_FIELDS-COMP_CODE.

if sy-subrc eq 0.

h_flag = 'X'. " Document found

endif.

else.

h_flag = 'X'. "Document found.

endif.

if h_flag = 'X'.

if h_dcurr ne SOURCE_FIELDS-CURRENCY.

if h_rate lt 0.

h_rate = h_rate * ( -1 ).

clear h_amount.

if h_inv ne 0.

h_amount = h_inv.

else.

h_amount = SOURCE_FIELDS-/BIC/ZG_AVV104 * h_rate.

endif.

elseif h_rate gt 0.

if h_inv ne 0.

h_amount = h_inv.

else.

h_amount = SOURCE_FIELDS-/BIC/ZG_AVV104 / h_rate.

endif.

else.

h_amount = SOURCE_FIELDS-/BIC/ZG_AVV104.

endif.

else.

h_amount = SOURCE_FIELDS-/BIC/ZG_AVV104.

endif.

RESULT = h_amount.

CURRENCY = h_dcurr.

endif.

endif.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Use below select statements in your code.

Select single EXRATEXACC DOC_CURRCY NETVAL_INV

into (h_rate, h_dcurr, h_inv)

from /bic/azsdbiio100 for ALL ENTRIES in source_package

where BILL_NUM eq source_package-/BIC/ZREFDOC

and BILL_ITEM eq source_package-/BIC/ZREFDOCLN

and COMP_CODE eq source_package-COMP_CODE.

if sy-subrc ne 0. " Not found

select single EXRATEXACC DOC_CURRCY NETVAL_INV

into (h_rate, h_dcurr, h_inv)

from /bic/azsdbiio100 for ALL ENTRIES in source_package

where DOC_NUMBER eq source_package-DOC_NUMBER

and S_ORD_ITEM eq source_package-S_ORD_ITEM

and COMP_CODE eq source_package-COMP_CODE.

Regards,

-Vj

Former Member
0 Kudos

Hi,

what you need to do first is to define internal tables in the start routine for each individual routine with the key fields. So look at the different SELECT SINGLE statements and build up the internal table(s). So for the first one you need to define an internal table with fields BILL_NUM, BILL_ITEM, COMP_CODE (your key) and EXRATEXACC, DOC_CURRCY and NETVAL_INV. I don't know if you can combine the two select single statements, that will depend on if BILL_NUM is the same type of field as DOC_NUMBER.

After declaration of the internal tables you can fill the bales by doing a SELECT instead of select single INTO the internal table.

In the individual update rules you can do a READ TABLE (internal table) WITH KEY yyyyyy

In this way you only have to access the DB once per data package and read from the internal memory for each record, which will definitely improve performance.

Hope this helps!

shanthi_bhaskar
Active Contributor
0 Kudos

Use SOURCE_PACKAGE for SOURCE_FIELDS