METHOD get_price.
DATA(l_priceid) = get_priceid(
i_price = i_price
i_preistuf = i_preistuf
).
CHECK l_priceid IS NOT INITIAL.
r_result = get_priceamount(
i_netprovider = i_netprovider
i_priceid = l_priceid
).
ENDMETHOD.
METHOD get_preisid.
r_result = reading_db->get_priceid(
i_price = i_price
i_preistuf = i_preistuf
).
ENDMETHOD.
METHOD zif_icos_reading_db~get_priceid.
SELECT SINGLE nb_preisid
INTO r_result
FROM /cronos/nb_preis
WHERE preis = i_price
AND preistuf = i_preistuf.
ENDMETHOD.
METHOD zif_icos_reading_db~get_price_amount.
CALL FUNCTION '/CRONOS/NB_GET_PRICE_AMOUNT'
EXPORTING
x_stichtag = sy-datum " Stichtag
x_preisid = i_priceid " Netbill Preisschlüssel ID
x_netznr = i_netprovider-netznr " Eindeutige Nummer des Netzgebietes
x_messgebiet_msb = i_netprovider-messgebiet_msb " Messgebiet des Standardmessstellenbetreibers
x_messgebiet_mdl = i_netprovider-messgebiet_mdl " Messgebiet des Standardmessdienstleisters
x_messgebiet_msys = i_netprovider-messgebiet_imsys " Messgebiet des Standard-MSB für intelligente Messsysteme
x_spebeneid = '1' " Internes Kennzeichen der Spannungsebene
TABLES
xy_epreih = r_result " Historientabelle für alle Preise
EXCEPTIONS
general_fault = 1
no_preisid = 2
no_net = 3
no_spebene = 4
OTHERS = 5.
ENDMETHOD.
METHOD zif_icos_reading_db~get_priceid.
r_result = COND #(
WHEN i_price = 'ZANDET1ZZZ' AND i_preistuf = '~NMSB' THEN '11753'
WHEN i_price = 'ZELMMT1MME' AND i_preistuf = '~MSB_Z25' THEN '18007'
WHEN i_price = 'ZELMMT1MME' AND i_preistuf = '~MSB_Z20' THEN '18013'
WHEN i_price = 'ZELMMT1MME' AND i_preistuf = '~MSB_Z18' THEN '18014'
).
ENDMETHOD.
METHOD zif_icos_reading_db~get_priceamount.
r_result = VALUE #(
( priceamount = SWITCH #(
i_preisid
WHEN '11753' THEN '8.00'
WHEN '18007' THEN '16.00'
WHEN '18013' THEN '80.00'
WHEN '18014' THEN '110.00'
ELSE '0.0'
)
)
).
ENDMETHOD.
METHOD constructor.
reading_db = COND #( WHEN i_reading_db IS BOUND "called by unit test
THEN i_reading_db "-> use this instance (the test double)
ELSE NEW zcl_icos_reading_db( ) "called by gateway -> create database access instance
).
ENDMETHOD.
METHOD setup.
cut = NEW zcl_icos_reading( NEW zcl_icos_reading_db_double( ) ).
ENDMETHOD.
METHOD messpreise_by_wrong_address.
TRY.
DATA(lt_readingprices) = cut->get_readingprice_by_address(
i_strasse = 'BlaBla'
i_hausnummer = '2'
i_pstlz = '55555'
i_ort = 'Köln'
).
cl_abap_unit_assert=>fail( msg = 'Wrong address should raise an error' ).
CATCH zcx_icos_meter ##no_handler.
ENDTRY.
ENDMETHOD.
FORM very_old_code.
some_code.
more_old_code.
new ZCL_MY_ISLAND_OF_HAPPINESS( )->my_new_method_already_tested_with_unit_tests( ).
even_older_code.
ENDFORM.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
4 | |
2 | |
2 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 |