Skip to Content
0

abap change amount from periodic to ytd - error

Dec 12, 2017 at 12:10 AM

37

avatar image
Former Member

hello all,

i am not much of an abaper however i am trying to convert periodic amount to ytd and i am having some difficulties. Not all my account will be moved to ytd fashion, i have to do a master data lookup in my account to find attribute accountgroup and accounttype and match with 'B' and 'G'. for every other account type, the periodic amount remains the right one.

. period0 | period 1 | period 2 | period n

accountaa amount 100 | 75 | 25 | (x)

i want the result to be : period0 | period 1| period 2 | period n

accountaa amount (ytd) 100 | 175 | 200 | (x) + 200 where as you can see here the amount is cumulative.

below is the endroutine i have built but it is not working as per my requirement. any help is welcome.

ADSO_source ADSO1: Zacct | zamount | 0FISCPER | 0FISCVARNT

ADSO_target ADS02: zaccbal | zamount | 0FISCPER | 0FISCVARNT

MASTER DATA Zacct: zacct | zacctgrp | zacctype

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

data: it_target TYPE _ty_s_TG_1.
DATA: lv_fvariant TYPE CHAR2,
lv_period TYPE /BI0/OIFISCPER,
lv_loop_period TYPE /BI0/OIFISCPER,
lv_date TYPE sy-datum,
lv_year TYPE gjahr,
lv_month TYPE char3,
lv_account TYPE /bic/oizaccount,
lv_accgrp TYPE /bic/oizaccgroup,
lv_ccter TYPE /BIC/OIZSYSCCCTR,
lv_amount TYPE /B28/OISDATA,
lv_curr_amt TYPE /B28/OISDATA,
lv_ytd_amt TYPE /B28/OISDATA,
lv_trdptner TYPE /BIC/OIZSYSCTRDP.
if not RESULT_PACKAGE[] IS INITIAL.loop at RESULT_PACKAGE into it_target.

"YTD conversion
lv_period = it_target-fiscper.
lv_fvariant = it_target-FISCVARNT.
lv_year = lv_period+0(4).
lv_month = lv_period+4(3).

lv_amount = it_target-/BIC/ZAMOUNT.
lv_account = it_target-/BIC/zaccbal.
SELECT SINGLE /BIC/ZACCTGRP INTO lv_accgrp FROM /bic/pzacct WHERE /BIC/ZACCBAL EQ lv_account.

IF sy-subrc EQ 0 AND lv_accgrp EQ 'B' OR lv_accttype EQ 'G'.
CONCATENATE lv_year '000' INTO lv_loop_period.

IF lv_loop_period < lv_period.

DO.
lv_loop_period = lv_loop_period + 1.

IF lv_loop_period = lv_period.

EXIT.
ENDIF.
SELECT /BIC/ZAMOUNT INTO lv_curr_amt from /BIC/AADSO2

WHERE fiscper = lv_loop_period.

IF SY-SUBRC EQ 0.
lv_ytd_amt = lv_ytd_amt + lv_curr_amt.

ENDIF.

ENDSELECT.
ENDDO.

ENDIF.

ENDIF.
MODIFY RESULT_PACKAGE from it_target.

CLEAR it_target.

endloop.

ENDIF.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers