Skip to Content
0
Former Member
Feb 19, 2007 at 12:12 PM

How to modify variant QUANTI19

101 Views

Hi,

well i am supposed to modify the standard variant QUANTI19 (FM ISU_QUANTI19)

now the standard variant is defined so that it can clear the cumulative amount at the start of the year i.e. '0101', now i want to change the date on which the standard variant clears the cumulative value for billing to '0401'.

can anyone help me as to where all do i need to do the required changes.

Below i m copying the code of the standard variant and putting all the code in bold where i think changes must be done.

Please cross check and let me know if there is any other place where i need to do the changes too.

FUNCTION ISU_QUANTI19.

*"----


""Lokale Schnittstelle:

*" IMPORTING

*" REFERENCE(X_OP) TYPE ISU2A_VARIANT_PARAMETERS

*" REFERENCE(X_SS) TYPE ISU2A_SS

*" REFERENCE(X_RED) TYPE ISU2A_REDUCED_BILLING_DATA

*" CHANGING

*" REFERENCE(XY_OBJ) TYPE ISU2A_BILLING_DATA

*" REFERENCE(XY_SOBJ) TYPE ISU2A_DATA_COLLECTOR

*" EXCEPTIONS

*" GENERAL_FAULT

*" REGULAR_ERROR

*"----


INCLUDE IEVARBASIC.

INCLUDE IEAIFUPD.

DATA:

CHANGE_OF_YEAR LIKE REGEN-KENNZX,

S_TABIX LIKE SY-TABIX,

S_AB LIKE ERCHZ-AB,

FIRST_AB LIKE ERCHZ-AB,

LAST_BIS LIKE ERCHZ-BIS,

QNT_NEW_OF_PERIOD TYPE ISU2A_PACK16,

QNT_OLD_OF_PERIOD TYPE ISU2A_PACK16,

QNT_NEW_CURR TYPE ISU2A_PACK16,

QNT_OLD_CURR TYPE ISU2A_PACK16,

QNT_NEW_OF_PREV TYPE ISU2A_PACK16,

QNT_OLD_OF_PREV TYPE ISU2A_PACK16,

QNT_NEW_AFTER_SWITCH TYPE ISU2A_PACK16,

QNT_OLD_AFTER_SWITCH TYPE ISU2A_PACK16,

QNT_NEW_BEFORE_SWITCH TYPE ISU2A_PACK16,

QNT_OLD_BEFORE_SWITCH TYPE ISU2A_PACK16,

VALUE TYPE ISU2A_OPER_VALUES,

UPDTYPE TYPE ISU2A_FACTUPD-UPDTYPE,

AB TYPE ISU2A_VB-AB,

BIS TYPE ISU2A_VB-BIS,

wabrzeit type isu2a_abrzeit,

wzeit type isu2a_zeit,

WVB2 TYPE ISU2A_VB.

MAC_CONTROL_CHECK 2.

MAC_BELZART_CHECK 1.

LOOP AT X_RED-IVB INTO WVB.

IF WVB-OPERAND = X_OP-I1-OPERAND.

  • Calculate sum over previous consumption

ADD WVB-QNT_NEW TO QNT_NEW_OF_PREV.

ADD WVB-QNT_OLD TO QNT_OLD_OF_PREV.

ELSEIF WVB-OPERAND = X_OP-I2-OPERAND.

  • Save first AB and last Bis

IF FIRST_AB IS INITIAL.

FIRST_AB = WVB-AB.

ENDIF. "first_ab

LAST_BIS = WVB-BIS.

  • Calculate sum over current billing period

ADD WVB-QNT_NEW TO QNT_NEW_OF_PERIOD.

ADD WVB-QNT_OLD TO QNT_OLD_OF_PERIOD.

ENDIF. "operand

ENDLOOP. "x_red-ivb

MAC_ERR_READ 'x_red-ivb' 'ISU_QUANTI19' SPACE.

CLEAR S_AB.

MAC_INIT_OUTPUT X_SS-VARCONT2 X_OP-O1.

  • Find fitting billing period

LOOP AT XY_OBJ-IZEIT INTO WZEIT

WHERE LSNO = X_SS-LSNO.

LOOP AT XY_OBJ-IABRZEIT INTO WABRZEIT

WHERE NO_ABRZEIT = WZEIT-NO_ABRZEIT.

EXIT.

ENDLOOP."XY_OBJ-IABRZEIT

MAC_ERR_READ 'XY_OBJ-IABRZEIT' 'ISU_QUANTI19' SPACE.

EXIT.

ENDLOOP."XY_OBJ-IZEIT

MAC_ERR_READ 'XY_OBJ-IZEIT' 'ISU_QUANTI19' SPACE.

<u><b> if wabrzeit-ab(4) <> x_ss-ab(4).

  • after change of year change of rate category or new rate

clear: qnt_new_of_prev, qnt_old_of_prev.

  • Mark change of year

CHANGE_OF_YEAR = 'X'.

endif.</b></u>

<b><u><i>Here i have do some changes</i></u></b>

OUT_VB-QNT_NEW = QNT_NEW_OF_PREV.

OUT_VB-QNT_OLD = QNT_OLD_OF_PREV.

  • x_red-ivb must be sorted from old to new

LOOP AT X_RED-IVB INTO WVB

WHERE OPERAND = X_OP-I1-OPERAND.

  • Prepare update of installation facts

AB = WVB-AB.

BIS = WVB-BIS.

  • Start with sum of previous consumption

IF VALUE-QNT_NEW IS INITIAL

AND CHANGE_OF_YEAR IS INITIAL.

VALUE-QNT_NEW = QNT_NEW_OF_PREV.

ADD VALUE-QNT_NEW TO QNT_NEW_BEFORE_SWITCH.

ENDIF. "value-qnt_new.

IF VALUE-QNT_OLD IS INITIAL

AND CHANGE_OF_YEAR IS INITIAL.

VALUE-QNT_OLD = QNT_OLD_OF_PREV.

ADD VALUE-QNT_OLD TO QNT_OLD_BEFORE_SWITCH.

ENDIF. "value-qnt_old

  • Determine current consumption for later addition

LOOP AT X_RED-IVB INTO WVB2

WHERE OPERAND = X_OP-I2-OPERAND

AND AB >= WVB-AB

AND BIS <= WVB-BIS.

ADD WVB2-QNT_NEW TO QNT_NEW_CURR.

ADD WVB2-QNT_OLD TO QNT_OLD_CURR.

ENDLOOP. "x_red-ivb

CLEAR WVB2.

IF WVB-AB <> S_AB.

S_AB = WVB-AB.

S_TABIX = SY-TABIX.

MAC_INVOICE_LINE_QNT X_SS-VARCONT1 CO_DLTYP01.

OUT_VB-AB = WVB-AB.

OUT_VB-BIS = WVB-BIS.

  • Switch of year, if billing does not start with 0101

  • (s_tabix = 1)

  • Initialize values direct after year switch

<u><b> IF ( WVB-AB+4(4) = '0101'

AND NOT S_TABIX = 1 ).</b></u> CLEAR QNT_NEW_AFTER_SWITCH.

CLEAR QNT_OLD_AFTER_SWITCH.

CLEAR VALUE-QNT_NEW.

CLEAR VALUE-QNT_OLD.

CLEAR OUT_VB-QNT_NEW.

CLEAR OUT_VB-QNT_OLD.

ENDIF.

<u><b> IF ( WVB-AB+4(4) = '0101'

AND NOT S_TABIX = 1 )

OR NOT CHANGE_OF_YEAR IS INITIAL.</b></u>* Mark change of year

CHANGE_OF_YEAR = 'X'.

  • Save sum of quantity after switch

ADD QNT_NEW_CURR TO QNT_NEW_AFTER_SWITCH.

ADD QNT_OLD_CURR TO QNT_OLD_AFTER_SWITCH.

  • Update installation facts

  • Current facts

  • Take only current quant, clear only direct after year switch

ADD QNT_NEW_CURR TO VALUE-QNT_NEW.

ADD QNT_OLD_CURR TO VALUE-QNT_OLD.

  • Current period

UPDTYPE = CO_IFUPD_PERIOD.

  • Rounding

MAC_ROUND X_OP-O1-RUNDUNG X_OP-O1-RUNDART VALUE-QNT_NEW.

MAC_ROUND X_OP-O1-RUNDUNG X_OP-O1-RUNDART VALUE-QNT_OLD.

MAC_FACTS_WRITE X_OP-O2-OPERAND X_OP-O2-OPTYP.

  • Output processing

MAC_OUTPUT_IVB X_OP-O1.

ELSE.

  • Add current quant

ADD QNT_NEW_CURR TO QNT_NEW_BEFORE_SWITCH.

ADD QNT_OLD_CURR TO QNT_OLD_BEFORE_SWITCH.

VALUE-QNT_NEW = QNT_NEW_BEFORE_SWITCH.

VALUE-QNT_OLD = QNT_OLD_BEFORE_SWITCH.

  • Current period

UPDTYPE = CO_IFUPD_PERIOD.

MAC_FACTS_WRITE X_OP-O2-OPERAND X_OP-O2-OPTYP.

  • Output price determine quant

MAC_OUTPUT_IVB X_OP-O1.

ENDIF. "wvb-ab+4(4)

ENDIF. "wvb-ab

  • Update output quant for next loop.

ADD QNT_NEW_CURR TO OUT_VB-QNT_NEW.

ADD QNT_OLD_CURR TO OUT_VB-QNT_OLD.

CLEAR QNT_NEW_CURR.

CLEAR QNT_OLD_CURR.

ENDLOOP. "x_red-ivb

MAC_ERR_READ 'x_red-ivb' 'ISU_QUANTI19' SPACE.

CLEAR S_AB.

  • Future facts

UPDTYPE = CO_IFUPD_FUTURE.

AB = FIRST_AB.

BIS = LAST_BIS.

IF BIS+4(4) = '1231'

or wabrzeit-bis(4) <> x_ss-bis(4) "change of rate category

or wabrzeit-bis+4(4) = '1231'. "change of rate category

CLEAR VALUE-QNT_NEW.

CLEAR VALUE-QNT_OLD.

ELSEIF CHANGE_OF_YEAR IS INITIAL.

VALUE-QNT_NEW = QNT_NEW_OF_PERIOD + QNT_NEW_OF_PREV.

VALUE-QNT_OLD = QNT_OLD_OF_PERIOD + QNT_OLD_OF_PREV.

ELSE.

VALUE-QNT_NEW = QNT_NEW_AFTER_SWITCH.

VALUE-QNT_OLD = QNT_OLD_AFTER_SWITCH.

ENDIF. "BIS+4(4)

  • Rounding

MAC_ROUND X_OP-O1-RUNDUNG X_OP-O1-RUNDART VALUE-QNT_NEW.

MAC_ROUND X_OP-O1-RUNDUNG X_OP-O1-RUNDART VALUE-QNT_OLD.

MAC_FACTS_WRITE X_OP-O3-OPERAND X_OP-O3-OPTYP.

ENDFUNCTION.

<b></b><b></b><b></b><i></i>

Thanks in advance.