REPORT z_gl_prctr_bal MESSAGE-ID zzfmog.
TABLES: faglflext, bseg.
*--------------------------------------------------------------*
* Include Declaration
*--------------------------------------------------------------*
"Include for global data declaration
INCLUDE Z_GL_PRCTR_BAL_TOP.
"Include for Selection screen
INCLUDE Z_GL_PRCTR_BAL_SEL.
"Include for Subroutines.
INCLUDE Z_GL_PRCTR_BAL_FORMS.
*--------------------------------------------------------------*
* AT SELECTION-SCREEN
*--------------------------------------------------------------*
AT SELECTION-SCREEN ON p_bukrs.
PERFORM f_val_bukrs.
AT SELECTION-SCREEN ON s_bupla.
PERFORM f_val_bupla.
AT SELECTION-SCREEN ON s_prctr.
PERFORM f_val_prctr.
*--------------------------------------------------------------*
* START-OF-SELECTION
*--------------------------------------------------------------*
START-OF-SELECTION.
*Fetch data
PERFORM f_get_data.
*Process data
PERFORM f_process_data.
*Final table
PERFORM f_build_final_table.
*--------------------------------------------------------------*
* END-OF-SELECTION
*--------------------------------------------------------------*
*Prepare field catalogue
PERFORM f_field_catalogue.
*Data display
PERFORM f_display_alv.
*&---------------------------------------------------------------------*
*& Include ZGLPRCTR_TOP
*&---------------------------------------------------------------------*
TYPES : BEGIN OF ty_data,
rbukrs TYPE bukrs,
racct TYPE racct,
prctr TYPE prctr,
rfarea TYPE fkber,
drcrk TYPE shkzg,
account_text TYPE string,
zzaltkt TYPE altkt,
hslvt TYPE hslvt12,
hsl01 TYPE hslxx12,
hsl02 TYPE hslxx12,
hsl03 TYPE hslxx12,
hsl04 TYPE hslxx12,
hsl05 TYPE hslxx12,
hsl06 TYPE hslxx12,
hsl07 TYPE hslxx12,
hsl08 TYPE hslxx12,
hsl09 TYPE hslxx12,
hsl10 TYPE hslxx12,
hsl11 TYPE hslxx12,
hsl12 TYPE hslxx12,
hsltotal TYPE hslxx12,
debit_in_period
TYPE fagl_debit_in_period,
credit_in_period
TYPE fagl_credit_in_period,
debit_to_period
TYPE fagl_debit_to_period,
credit_to_period
TYPE fagl_credit_to_period,
xbilk TYPE xbilk,
END OF ty_data.
TYPES: BEGIN OF ty_outtab_acc,
bukrs TYPE bukrs,
account TYPE hkont,
rfarea TYPE fkber,
prctr TYPE prctr,
currency TYPE waers,
zzaltkt TYPE altkt,
account_text TYPE char50,
debit_in_period
TYPE fagl_debit_in_period,
credit_in_period
TYPE fagl_credit_in_period,
debit_to_period
TYPE fagl_debit_to_period,
credit_to_period
TYPE fagl_credit_to_period,
xbilk TYPE xbilk,
END OF ty_outtab_acc.
TYPES : BEGIN OF ty_final,
ktnra TYPE saknr,
glname TYPE char50,
rfarea TYPE fkber,
hypcode TYPE char10,
pc1 TYPE dmbtr,
pc2 TYPE dmbtr,
pc3 TYPE dmbtr,
pc4 TYPE dmbtr,
pc5 TYPE dmbtr,
pc6 TYPE dmbtr,
pc7 TYPE dmbtr,
pc8 TYPE dmbtr,
pc9 TYPE dmbtr,
pc10 TYPE dmbtr,
pc11 TYPE dmbtr,
pc12 TYPE dmbtr,
pc13 TYPE dmbtr,
pc14 TYPE dmbtr,
pc15 TYPE dmbtr,
pc16 TYPE dmbtr,
pc17 TYPE dmbtr,
pc18 TYPE dmbtr,
pc19 TYPE dmbtr,
pc20 TYPE dmbtr,
pc21 TYPE dmbtr,
pc22 TYPE dmbtr,
pc23 TYPE dmbtr,
pc24 TYPE dmbtr,
pc25 TYPE dmbtr,
pc26 TYPE dmbtr,
pc27 TYPE dmbtr,
pc28 TYPE dmbtr,
total_debit_balance
TYPE fagl_total_debit_balance,
total_credit_balance
TYPE fagl_total_credit_balance,
balance
TYPE wertv12 ,
END OF ty_final.
TYPES : BEGIN OF ty_ska1,
ktopl TYPE ktopl,
saknr TYPE saknr,
xbilk TYPE xbilk,
END OF ty_ska1.
TYPES: tt_fieldlist TYPE STANDARD TABLE OF char30,
tt_grouplist TYPE STANDARD TABLE OF char30.
DATA gt_data TYPE TABLE OF ty_data.
DATA gt_final TYPE TABLE OF ty_final.
DATA gk_final TYPE ty_final.
DATA gt_outtab_acc TYPE TABLE OF ty_outtab_acc.
DATA gt_fieldcatalog TYPE slis_t_fieldcat_alv.
DATA gt_sort TYPE slis_t_sortinfo_alv.
DATA gv_flag(1) TYPE c.
DATA: gv_racct TYPE racct,
gv_rpmax TYPE rpmax,
gv_prctr TYPE prctr,
gv_bupla TYPE bupla.
DATA: gv_tslvt_debit TYPE tslvt12,
gv_hslvt_debit TYPE hslvt12.
DATA: gv_aknr TYPE racct.
CONSTANTS : gc_e TYPE char1 VALUE 'E',
gc_x TYPE char1 VALUE 'X',
gc_xxxx TYPE char4 VALUE 'XXXX'.
*&---------------------------------------------------------------------*
*& Include ZGLPRCTR_SEL
*&---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK b1 with frame.
SELECT-OPTIONS : s_saknr FOR gv_racct. "faglflext-racct.
PARAMETERS : p_bukrs TYPE bukrs OBLIGATORY.
PARAMETERS : p_gjahr TYPE gjahr OBLIGATORY. "faglflext-rpmax
SELECT-OPTIONS : s_per FOR gv_rpmax OBLIGATORY.
SELECT-OPTIONS : s_bupla FOR gv_bupla. "bseg-bupla.
SELECT-OPTIONS : s_prctr FOR gv_prctr. "faglflext-prctr.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 with frame title text-001.
PARAMETERS : r_rad1 RADIOBUTTON GROUP rad1,
r_rad2 RADIOBUTTON GROUP rad1,
r_rad3 RADIOBUTTON GROUP rad1 DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK b2.
*&---------------------------------------------------------------------*
*& Include ZGLPRCTR_FORMS
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f_get_data .
DATA: lt_fieldlist TYPE TABLE OF char30,
lt_grouplist TYPE TABLE OF char30.
DATA lt_ska1 TYPE TABLE OF ty_ska1.
DATA ls_ska1 TYPE ty_ska1.
DATA ls_texte TYPE skat.
DATA lv_konto TYPE skb1-saknr.
CONSTANTS:lc_0l TYPE char2 VALUE '0L',
lc_0 TYPE char1 VALUE '0',
lc_001 TYPE char3 VALUE '001'.
FIELD-SYMBOLS: <ls_data> TYPE ty_data.
*Prepare fieldlist (lt_fieldlist)
PERFORM f_build_fieldlist CHANGING lt_fieldlist.
*Prepare group list
PERFORM f_build_grouplist CHANGING lt_grouplist.
*Fetch data from FAGLFLEXT
SELECT (lt_fieldlist)
FROM faglflext
INTO CORRESPONDING FIELDS OF TABLE gt_data
WHERE rldnr EQ lc_0l
AND rrcty EQ lc_0
AND rvers EQ lc_001
AND rbukrs EQ p_bukrs
AND ryear EQ p_gjahr
AND racct IN s_saknr
AND prctr IN s_prctr
GROUP BY (lt_grouplist).
IF sy-subrc = 0.
* SORT gt_data BY racct rfarea prctr drcrk.
SORT gt_data BY racct prctr rfarea drcrk.
ENDIF.
*Fetch P&L Indicator, Balance Sheet Indicator
IF gt_data IS NOT INITIAL.
SELECT ktopl saknr xbilk
INTO TABLE lt_ska1
FROM ska1
FOR ALL ENTRIES IN gt_data
WHERE saknr = gt_data-racct.
ENDIF.
LOOP AT gt_data ASSIGNING <ls_data>.
lv_konto = <ls_data>-racct.
*Get Indicators
READ TABLE lt_ska1 INTO ls_ska1 WITH KEY saknr = lv_konto.
IF sy-subrc = 0.
<ls_data>-xbilk = ls_ska1-xbilk.
ENDIF.
*Get amount for one period
PERFORM f_get_amount_current_period CHANGING <ls_data>.
*Get amount for all periods
PERFORM f_get_amount_all_periods CHANGING <ls_data>.
PERFORM f_get_racct_desc USING lv_konto
CHANGING ls_texte.
IF ls_texte-txt20 NE space.
<ls_data>-account_text = ls_texte-txt50.
ELSE.
<ls_data>-account_text = ls_texte-txt20.
ENDIF.
ENDLOOP.
ENDFORM. " GET_DATA
*&---------------------------------------------------------------------*
*& Form PROCESS_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f_process_data.
DATA ls_outtab_acc TYPE ty_outtab_acc.
FIELD-SYMBOLS <ls_data> TYPE ty_data.
CONSTANTS: lc_s TYPE char1 VALUE 'S',
lc_h TYPE char1 VALUE 'H'.
*Loop on table to transfer credit and debit amount of period
LOOP AT gt_data ASSIGNING <ls_data>.
gv_hslvt_debit = <ls_data>-hslvt + gv_hslvt_debit.
IF <ls_data>-drcrk = lc_s.
ls_outtab_acc-debit_in_period = ls_outtab_acc-debit_in_period + <ls_data>-debit_in_period.
ls_outtab_acc-debit_to_period = ls_outtab_acc-debit_to_period + <ls_data>-debit_to_period.
ELSEIF <ls_data>-drcrk = lc_h.
ls_outtab_acc-credit_in_period = ls_outtab_acc-credit_in_period + <ls_data>-credit_in_period.
ls_outtab_acc-credit_to_period = ls_outtab_acc-credit_to_period + <ls_data>-credit_to_period.
ENDIF.
AT END OF prctr.
* Append single line for one profit center
IF gv_tslvt_debit > 0.
ls_outtab_acc-debit_to_period = ls_outtab_acc-debit_to_period + gv_tslvt_debit .
ELSE.
ls_outtab_acc-credit_to_period = ls_outtab_acc-credit_to_period + gv_tslvt_debit .
ENDIF.
IF gv_hslvt_debit > 0.
ls_outtab_acc-debit_to_period = ls_outtab_acc-debit_to_period + gv_hslvt_debit.
ELSE.
ls_outtab_acc-credit_to_period = ls_outtab_acc-credit_to_period + gv_hslvt_debit.
ENDIF.
*Transferring data to cumulative amount profit center table
MOVE: <ls_data>-account_text TO ls_outtab_acc-account_text,
<ls_data>-rbukrs TO ls_outtab_acc-bukrs,
<ls_data>-racct TO ls_outtab_acc-account,
<ls_data>-prctr TO ls_outtab_acc-prctr,
<ls_data>-rfarea TO ls_outtab_acc-rfarea,
<ls_data>-zzaltkt TO ls_outtab_acc-zzaltkt,
<ls_data>-xbilk TO ls_outtab_acc-xbilk.
APPEND ls_outtab_acc TO gt_outtab_acc.
CLEAR: ls_outtab_acc,gv_tslvt_debit, gv_hslvt_debit.
ENDAT.
ENDLOOP.
*Filter data based on radio button selected
IF r_rad1 = gc_x.
DELETE gt_outtab_acc WHERE xbilk EQ gc_x.
IF gt_outtab_acc IS INITIAL.
MESSAGE s037 DISPLAY LIKE gc_e.
LEAVE LIST-PROCESSING.
ENDIF.
ELSEIF r_rad2 = gc_x.
DELETE gt_outtab_acc WHERE xbilk NE gc_x.
IF gt_outtab_acc IS INITIAL.
MESSAGE s037 DISPLAY LIKE gc_e.
LEAVE LIST-PROCESSING.
ENDIF.
ENDIF.
ENDFORM. "process_data
*&---------------------------------------------------------------------*
*& Form BUILD_FINAL_TABLE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f_build_final_table .
*Now transferring the data to final table
*Coverting Internal table into horizontal table i.e for every Profit Center map the data to final table
SORT gt_outtab_acc BY bukrs account rfarea.
*Build p&l accounts
IF r_rad1 EQ gc_x.
PERFORM f_build_pl_accounts.
*Build balance sheet
ELSEIF r_rad2 EQ gc_x.
PERFORM f_build_balance_sheet_accounts.
*Populating data for All accounts Radio button
ELSEIF r_rad3 EQ gc_x.
* Check for P&L accounts
PERFORM f_build_all_accounts.
ENDIF.
ENDFORM. " BUILD_FINAL_TABLE
*&---------------------------------------------------------------------*
*& Form DISPLAY_ALV
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f_display_alv .
DATA lv_repid LIKE sy-repid.
DATA lt_evt TYPE slis_t_event.
DATA wa_evt TYPE slis_alv_event.
DATA lt_sort TYPE slis_t_sortinfo_alv .
DATA wa_sort LIKE LINE OF lt_sort .
CONSTANTS: lc_i TYPE c VALUE 'I'.
lv_repid = sy-repid.
* Get Event table
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
IMPORTING
et_events = lt_evt.
* Add pointer to custom top_of_list event handler
READ TABLE lt_evt INTO wa_evt
WITH KEY name = slis_ev_top_of_list .
wa_evt-form = text-008. ""'TOP_OF_LIST' .
MODIFY lt_evt FROM wa_evt INDEX sy-tabix .
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = lv_repid
i_callback_user_command = 'F_USER_COMMAND'
it_fieldcat = gt_fieldcatalog
i_save = gc_x
it_events = lt_evt
* it_sort = lt_sort
TABLES
t_outtab = gt_final
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE text-003 TYPE lc_i.
ENDIF.
ENDFORM. " DISPLAY_ALV
*&---------------------------------------------------------------------*
*& Form USER_COMMAND
*&---------------------------------------------------------------------*
FORM f_user_command USING ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
DATA : ok_code TYPE sy-ucomm.
ok_code = ucomm.
CASE ok_code.
WHEN '&IC1'. "for double click on alv grid line
IF rs_selfield-fieldname = 'KTNRA'.
SET PARAMETER ID 'SAK' FIELD rs_selfield-value.
CALL TRANSACTION 'FAGLL03' AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
ENDFORM. "user_command
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDLIST
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_LT_FIELDLIST text
*----------------------------------------------------------------------*
FORM f_build_fieldlist CHANGING p_lt_fieldlist TYPE tt_fieldlist.
DATA ls_fieldlist TYPE char30.
ls_fieldlist = 'RCLNT'.
APPEND ls_fieldlist TO p_lt_fieldlist.
ls_fieldlist = 'RLDNR'.
APPEND ls_fieldlist TO p_lt_fieldlist.
ls_fieldlist = 'RRCTY'.
APPEND ls_fieldlist TO p_lt_fieldlist.
ls_fieldlist = 'RVERS'.
APPEND ls_fieldlist TO p_lt_fieldlist.
ls_fieldlist = 'RBUKRS'.
APPEND ls_fieldlist TO p_lt_fieldlist.
ls_fieldlist = 'RYEAR'.
APPEND ls_fieldlist TO p_lt_fieldlist.
ls_fieldlist = 'RACCT'.
APPEND ls_fieldlist TO p_lt_fieldlist.
ls_fieldlist = 'DRCRK'.
APPEND ls_fieldlist TO p_lt_fieldlist.
ls_fieldlist = 'RPMAX'.
APPEND ls_fieldlist TO p_lt_fieldlist.
ls_fieldlist = 'PRCTR'.
APPEND ls_fieldlist TO p_lt_fieldlist.
ls_fieldlist = 'RFAREA'.
APPEND ls_fieldlist TO p_lt_fieldlist.
ls_fieldlist = 'ZZALTKT'.
APPEND ls_fieldlist TO p_lt_fieldlist.
ls_fieldlist = 'SUM( HSLVT ) AS HSLVT'.
APPEND ls_fieldlist TO p_lt_fieldlist.
ls_fieldlist = 'SUM( HSL01 ) AS HSL01'.
APPEND ls_fieldlist TO p_lt_fieldlist.
ls_fieldlist = 'SUM( HSL02 ) AS HSL02'.
APPEND ls_fieldlist TO p_lt_fieldlist.
ls_fieldlist = 'SUM( HSL03 ) AS HSL03'.
APPEND ls_fieldlist TO p_lt_fieldlist.
ls_fieldlist = 'SUM( HSL04 ) AS HSL04'.
APPEND ls_fieldlist TO p_lt_fieldlist.
ls_fieldlist = 'SUM( HSL05 ) AS HSL05'.
APPEND ls_fieldlist TO p_lt_fieldlist.
ls_fieldlist = 'SUM( HSL06 ) AS HSL06'.
APPEND ls_fieldlist TO p_lt_fieldlist.
ls_fieldlist = 'SUM( HSL07 ) AS HSL07'.
APPEND ls_fieldlist TO p_lt_fieldlist.
ls_fieldlist = 'SUM( HSL08 ) AS HSL08'.
APPEND ls_fieldlist TO p_lt_fieldlist.
ls_fieldlist = 'SUM( HSL09 ) AS HSL09'.
APPEND ls_fieldlist TO p_lt_fieldlist.
ls_fieldlist = 'SUM( HSL10 ) AS HSL10'.
APPEND ls_fieldlist TO p_lt_fieldlist.
ls_fieldlist = 'SUM( HSL11 ) AS HSL11'.
APPEND ls_fieldlist TO p_lt_fieldlist.
ls_fieldlist = 'SUM( HSL12 ) AS HSL12'.
APPEND ls_fieldlist TO p_lt_fieldlist.
ENDFORM. " BUILD_FIELDLIST
*&---------------------------------------------------------------------*
*& Form BUILD_GROUPLIST
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_LT_GROUPLIST text
*----------------------------------------------------------------------*
FORM f_build_grouplist CHANGING p_lt_grouplist TYPE tt_grouplist.
DATA: ls_grouplist TYPE char30.
ls_grouplist = 'RCLNT'.
APPEND ls_grouplist TO p_lt_grouplist.
ls_grouplist = 'RLDNR'.
APPEND ls_grouplist TO p_lt_grouplist.
ls_grouplist = 'RRCTY'.
APPEND ls_grouplist TO p_lt_grouplist.
ls_grouplist = 'RVERS'.
APPEND ls_grouplist TO p_lt_grouplist.
ls_grouplist = 'RBUKRS'.
APPEND ls_grouplist TO p_lt_grouplist.
ls_grouplist = 'RYEAR'.
APPEND ls_grouplist TO p_lt_grouplist.
ls_grouplist = 'RACCT'.
APPEND ls_grouplist TO p_lt_grouplist.
ls_grouplist = 'DRCRK'.
APPEND ls_grouplist TO p_lt_grouplist.
ls_grouplist = 'RPMAX'.
APPEND ls_grouplist TO p_lt_grouplist.
ls_grouplist = 'PRCTR'.
APPEND ls_grouplist TO p_lt_grouplist.
ls_grouplist = 'RFAREA'.
APPEND ls_grouplist TO p_lt_grouplist.
ls_grouplist = 'ZZALTKT'.
APPEND ls_grouplist TO p_lt_grouplist.
ENDFORM. " BUILD_GROUPLIST
" PROCESS_DATA
*&---------------------------------------------------------------------*
*& Form GET_RACCT_DESC
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_<LS_DATA>_RACCT text
*----------------------------------------------------------------------*
FORM f_get_racct_desc USING p_lv_konto TYPE skb1-saknr
CHANGING p_ls_texte TYPE skat.
DATA ls_t001 TYPE t001.
SELECT SINGLE * FROM t001 INTO ls_t001
WHERE bukrs = p_bukrs.
CALL FUNCTION 'READ_HAUPTBUCH_TEXT'
EXPORTING
kontenplan = ls_t001-ktopl
sachkonto = p_lv_konto
sprache = sy-langu
IMPORTING
text_wa = p_ls_texte
EXCEPTIONS
text_not_found = 01.
IF sy-subrc NE 0.
* Handle message here.
ENDIF.
ENDFORM. " GET_RACCT_DESC
*&---------------------------------------------------------------------*
*& Form BUILD_PL_ACCOUNTS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f_build_pl_accounts .
DATA: lv_hyp1 TYPE altkt,
lv_hyp2 TYPE altkt,
lv_hyp TYPE altkt.
FIELD-SYMBOLS <ls_outtab_acc> TYPE ty_outtab_acc.
* LOOP AT gt_outtab_acc_temp ASSIGNING <ls_outtab_acc>.
LOOP AT gt_outtab_acc ASSIGNING <ls_outtab_acc>.
IF gv_flag = gc_x.
PERFORM f_get_prctr_amount_all_periods USING <ls_outtab_acc>.
ELSE.
PERFORM f_get_prctr_amount_one_period USING <ls_outtab_acc>.
ENDIF.
*Populate P&L Accounts
AT END OF rfarea.
*Get the balance field amount
Perform f_get_balance CHANGING gk_final.
gk_final-ktnra = <ls_outtab_acc>-account.
gk_final-glname = <ls_outtab_acc>-account_text.
gk_final-rfarea = <ls_outtab_acc>-rfarea.
IF <ls_outtab_acc>-zzaltkt+0(4) = gc_xxxx.
lv_hyp1 = <ls_outtab_acc>-rfarea+0(4).
lv_hyp2 = <ls_outtab_acc>-zzaltkt+4(6).
CONCATENATE lv_hyp1 lv_hyp2 INTO lv_hyp.
ELSE.
lv_hyp = lv_hyp2 = <ls_outtab_acc>-zzaltkt.
ENDIF.
gk_final-hypcode = lv_hyp.
APPEND gk_final TO gt_final.
CLEAR gk_final.
ENDAT.
ENDLOOP.
ENDFORM. " BUILD_PL_ACCOUNTS
*&---------------------------------------------------------------------*
*& Form BUILD_BALANCE_SHEET_ACCOUNTS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f_build_balance_sheet_accounts .
FIELD-SYMBOLS <ls_outtab_acc> TYPE ty_outtab_acc.
LOOP AT gt_outtab_acc ASSIGNING <ls_outtab_acc>.
IF gv_flag = gc_x.
PERFORM f_get_prctr_amount_all_periods USING <ls_outtab_acc>.
ELSE.
PERFORM f_get_prctr_amount_one_period USING <ls_outtab_acc>.
ENDIF.
AT END OF account.
*Get the balance field amount
Perform f_get_balance CHANGING gk_final.
gk_final-ktnra = <ls_outtab_acc>-account.
gk_final-glname = <ls_outtab_acc>-account_text.
gk_final-rfarea = <ls_outtab_acc>-rfarea.
gk_final-hypcode = <ls_outtab_acc>-zzaltkt.
APPEND gk_final TO gt_final.
CLEAR gk_final.
ENDAT.
ENDLOOP.
ENDFORM. " BUILD_BALANCE_SHEET_ACCOUNTS
*&---------------------------------------------------------------------*
*& Form BUILD_ALL_ACCOUNTS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f_build_all_accounts .
DATA: lv_hyp1 TYPE altkt,
lv_hyp2 TYPE altkt,
lv_hyp TYPE altkt.
DATA: gt_outtab_acc_temp TYPE STANDARD TABLE OF ty_outtab_acc.
FIELD-SYMBOLS <ls_outtab_acc> TYPE ty_outtab_acc.
gt_outtab_acc_temp = gt_outtab_acc.
DELETE gt_outtab_acc_temp WHERE xbilk EQ gc_x.
LOOP AT gt_outtab_acc_temp ASSIGNING <ls_outtab_acc>. "WHERE xbilk NE 'X'.
IF gv_flag = gc_x.
PERFORM f_get_prctr_amount_all_periods USING <ls_outtab_acc>.
ELSE.
PERFORM f_get_prctr_amount_one_period USING <ls_outtab_acc>.
ENDIF.
*If cost center is not needed then make at end of rfarea
AT END OF rfarea.
*Get the balance field amount
Perform f_get_balance CHANGING gk_final.
gk_final-ktnra = <ls_outtab_acc>-account.
gk_final-glname = <ls_outtab_acc>-account_text.
gk_final-rfarea = <ls_outtab_acc>-rfarea.
IF <ls_outtab_acc>-zzaltkt+0(4) = gc_xxxx.
lv_hyp1 = <ls_outtab_acc>-rfarea+0(4).
lv_hyp2 = <ls_outtab_acc>-zzaltkt+4(6).
CONCATENATE lv_hyp1 lv_hyp2 INTO lv_hyp.
ELSE.
lv_hyp = <ls_outtab_acc>-zzaltkt.
ENDIF.
gk_final-hypcode = lv_hyp.
APPEND gk_final TO gt_final.
CLEAR gk_final.
ENDAT.
ENDLOOP.
* Check for Balance sheet accounts
REFRESH gt_outtab_acc_temp.
gt_outtab_acc_temp = gt_outtab_acc.
DELETE gt_outtab_acc_temp WHERE xbilk NE gc_x.
LOOP AT gt_outtab_acc_temp ASSIGNING <ls_outtab_acc>. "WHERE xbilk EQ 'X'.
IF gv_flag = gc_x.
PERFORM f_get_prctr_amount_all_periods USING <ls_outtab_acc>.
ELSE.
PERFORM f_get_prctr_amount_one_period USING <ls_outtab_acc>.
ENDIF.
AT END OF account.
*Get the balance field amount
Perform f_get_balance CHANGING gk_final.
gk_final-ktnra = <ls_outtab_acc>-account.
gk_final-glname = <ls_outtab_acc>-account_text.
gk_final-rfarea = <ls_outtab_acc>-rfarea.
gk_final-hypcode = <ls_outtab_acc>-zzaltkt.
APPEND gk_final TO gt_final.
CLEAR gk_final.
ENDAT.
ENDLOOP.
ENDFORM. "build_all_accounts
*&---------------------------------------------------------------------*
*& Form GET_AMOUNT_CURRENT_PERIOD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_<ls_data> text
*----------------------------------------------------------------------*
FORM f_get_amount_current_period CHANGING p_ls_data TYPE ty_data.
CONSTANTS: lc_s TYPE char1 VALUE 'S',
lc_h TYPE char1 VALUE 'H'.
IF p_ls_data-drcrk = lc_s.
CASE s_per-low.
WHEN 1.
MOVE p_ls_data-hsl01 TO p_ls_data-debit_in_period.
WHEN 2.
MOVE p_ls_data-hsl02 TO p_ls_data-debit_in_period.
WHEN 3.
MOVE p_ls_data-hsl03 TO p_ls_data-debit_in_period.
WHEN 4.
MOVE p_ls_data-hsl04 TO p_ls_data-debit_in_period.
WHEN 5.
MOVE p_ls_data-hsl05 TO p_ls_data-debit_in_period.
WHEN 6.
MOVE p_ls_data-hsl06 TO p_ls_data-debit_in_period.
WHEN 7.
MOVE p_ls_data-hsl07 TO p_ls_data-debit_in_period.
WHEN 8.
MOVE p_ls_data-hsl08 TO p_ls_data-debit_in_period.
WHEN 9.
MOVE p_ls_data-hsl09 TO p_ls_data-debit_in_period.
WHEN 10.
MOVE p_ls_data-hsl10 TO p_ls_data-debit_in_period.
WHEN 11.
MOVE p_ls_data-hsl11 TO p_ls_data-debit_in_period.
WHEN 12.
MOVE p_ls_data-hsl12 TO p_ls_data-debit_in_period.
ENDCASE.
ELSEIF p_ls_data-drcrk = lc_h.
CASE s_per-low.
WHEN 1.
MOVE p_ls_data-hsl01 TO p_ls_data-credit_in_period.
WHEN 2.
MOVE p_ls_data-hsl02 TO p_ls_data-credit_in_period.
WHEN 3.
MOVE p_ls_data-hsl03 TO p_ls_data-credit_in_period.
WHEN 4.
MOVE p_ls_data-hsl04 TO p_ls_data-credit_in_period.
WHEN 5.
MOVE p_ls_data-hsl05 TO p_ls_data-credit_in_period.
WHEN 6.
MOVE p_ls_data-hsl06 TO p_ls_data-credit_in_period.
WHEN 7.
MOVE p_ls_data-hsl07 TO p_ls_data-credit_in_period.
WHEN 8.
MOVE p_ls_data-hsl08 TO p_ls_data-credit_in_period.
WHEN 9.
MOVE p_ls_data-hsl09 TO p_ls_data-credit_in_period.
WHEN 10.
MOVE p_ls_data-hsl10 TO p_ls_data-credit_in_period.
WHEN 11.
MOVE p_ls_data-hsl11 TO p_ls_data-credit_in_period.
WHEN 12.
MOVE p_ls_data-hsl12 TO p_ls_data-credit_in_period.
ENDCASE.
ENDIF.
ENDFORM. " GET_AMOUNT_CURRENT_PERIOD
*&---------------------------------------------------------------------*
*& Form GET_AMOUNT_ALL_PERIODS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_<LS_DATA> text
*----------------------------------------------------------------------*
FORM f_get_amount_all_periods CHANGING p_ls_data TYPE ty_data.
* Credit amount
DATA : lv_count TYPE i,
n TYPE i.
CONSTANTS: lc_s TYPE char1 VALUE 'S',
lc_h TYPE char1 VALUE 'H'.
IF s_per-high IS NOT INITIAL.
IF p_ls_data-drcrk = lc_s.
lv_count = 1.
WHILE lv_count <= s_per-high.
n = lv_count.
CASE n.
WHEN 1.
p_ls_data-hsltotal = p_ls_data-hsltotal + p_ls_data-hsl01.
WHEN 2.
p_ls_data-hsltotal = p_ls_data-hsltotal + p_ls_data-hsl02.
WHEN 3.
p_ls_data-hsltotal = p_ls_data-hsltotal + p_ls_data-hsl03.
WHEN 4.
p_ls_data-hsltotal = p_ls_data-hsltotal + p_ls_data-hsl04.
WHEN 5.
p_ls_data-hsltotal = p_ls_data-hsltotal + p_ls_data-hsl05.
WHEN 6.
p_ls_data-hsltotal = p_ls_data-hsltotal + p_ls_data-hsl06.
WHEN 7.
p_ls_data-hsltotal = p_ls_data-hsltotal + p_ls_data-hsl07.
WHEN 8.
p_ls_data-hsltotal = p_ls_data-hsltotal + p_ls_data-hsl08.
WHEN 9.
p_ls_data-hsltotal = p_ls_data-hsltotal + p_ls_data-hsl09.
WHEN 10.
p_ls_data-hsltotal = p_ls_data-hsltotal + p_ls_data-hsl10.
WHEN 11.
p_ls_data-hsltotal = p_ls_data-hsltotal + p_ls_data-hsl11.
WHEN 12.
p_ls_data-hsltotal = p_ls_data-hsltotal + p_ls_data-hsl12.
ENDCASE.
lv_count = lv_count + 1.
ENDWHILE.
MOVE p_ls_data-hsltotal TO p_ls_data-debit_to_period.
* Debit amount
ELSEIF p_ls_data-drcrk = lc_h.
lv_count = 1.
WHILE lv_count <= s_per-high.
n = lv_count.
CASE n.
WHEN 1.
p_ls_data-hsltotal = p_ls_data-hsltotal + p_ls_data-hsl01.
WHEN 2.
p_ls_data-hsltotal = p_ls_data-hsltotal + p_ls_data-hsl02.
WHEN 3.
p_ls_data-hsltotal = p_ls_data-hsltotal + p_ls_data-hsl03.
WHEN 4.
p_ls_data-hsltotal = p_ls_data-hsltotal + p_ls_data-hsl04.
WHEN 5.
p_ls_data-hsltotal = p_ls_data-hsltotal + p_ls_data-hsl05.
WHEN 6.
p_ls_data-hsltotal = p_ls_data-hsltotal + p_ls_data-hsl06.
WHEN 7.
p_ls_data-hsltotal = p_ls_data-hsltotal + p_ls_data-hsl07.
WHEN 8.
p_ls_data-hsltotal = p_ls_data-hsltotal + p_ls_data-hsl08.
WHEN 9.
p_ls_data-hsltotal = p_ls_data-hsltotal + p_ls_data-hsl09.
WHEN 10.
p_ls_data-hsltotal = p_ls_data-hsltotal + p_ls_data-hsl10.
WHEN 11.
p_ls_data-hsltotal = p_ls_data-hsltotal + p_ls_data-hsl11.
WHEN 12.
p_ls_data-hsltotal = p_ls_data-hsltotal + p_ls_data-hsl12.
ENDCASE.
lv_count = lv_count + 1.
ENDWHILE.
MOVE p_ls_data-hsltotal TO p_ls_data-credit_to_period.
ENDIF.
* Flag to determine wheather we need all period amount or current period amount
gv_flag = 'X'.
ENDIF.
ENDFORM. " GET_AMOUNT_ALL_PERIODS
*&---------------------------------------------------------------------*
*& Form GET_PRCTR_AMOUNT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f_get_prctr_amount_one_period USING p_outtab_acc TYPE ty_outtab_acc.
DATA lv_var(15) TYPE c.
CONSTANTS : lc_pc1(9) TYPE c VALUE 'P63118206',
lc_pc2(9) TYPE c VALUE 'P63118207',
lc_pc3(9) TYPE c VALUE 'P63118209',
lc_pc4(9) TYPE c VALUE 'P63118211',
lc_pc5(9) TYPE c VALUE 'P63118213',
lc_pc6(9) TYPE c VALUE 'P63118214',
lc_pc7(9) TYPE c VALUE 'P63118215',
lc_pc8(9) TYPE c VALUE 'P63118216',
lc_pc9(9) TYPE c VALUE 'P63118217',
lc_pc10(9) TYPE c VALUE 'P63118218',
lc_pc11(9) TYPE c VALUE 'P63118219',
lc_pc12(9) TYPE c VALUE 'P63118220',
lc_pc13(9) TYPE c VALUE 'P63118221',
lc_pc14(9) TYPE c VALUE 'P63118222',
lc_pc15(9) TYPE c VALUE 'P63118223',
lc_pc16(9) TYPE c VALUE 'P63118224',
lc_pc17(9) TYPE c VALUE 'P63118225',
lc_pc18(9) TYPE c VALUE 'P63118226',
lc_pc19(9) TYPE c VALUE 'P63118238',
lc_pc20(9) TYPE c VALUE 'P63118239',
lc_pc21(9) TYPE c VALUE 'P63118240',
lc_pc22(9) TYPE c VALUE 'P63110000',
lc_pc23(9) TYPE c VALUE 'P63110010',
lc_pc24(9) TYPE c VALUE 'P63110020',
lc_pc25(9) TYPE c VALUE 'DUMMY',
lc_pc26(9) TYPE c VALUE 'DUMMY2',
lc_pc28(9) TYPE c VALUE 'P63118241'.
CASE p_outtab_acc-prctr.
WHEN lc_pc1. "'P63118206'.
gk_final-pc1 = gk_final-pc1 + p_outtab_acc-debit_in_period + p_outtab_acc-credit_in_period.
WHEN lc_pc2. "'P63118207'.
gk_final-pc2 = gk_final-pc2 + p_outtab_acc-debit_in_period + p_outtab_acc-credit_in_period.
WHEN lc_pc3. "'P63118209'.
gk_final-pc3 = gk_final-pc3 + p_outtab_acc-debit_in_period + p_outtab_acc-credit_in_period.
WHEN lc_pc4. "'P63118211'.
gk_final-pc4 = gk_final-pc4 + p_outtab_acc-debit_in_period + p_outtab_acc-credit_in_period.
WHEN lc_pc5. "'P63118213'.
gk_final-pc5 = gk_final-pc5 + p_outtab_acc-debit_in_period + p_outtab_acc-credit_in_period.
WHEN lc_pc6. "'P63118214'.
gk_final-pc6 = gk_final-pc6 + p_outtab_acc-debit_in_period + p_outtab_acc-credit_in_period.
WHEN lc_pc7. "'P63118215'.
gk_final-pc7 = gk_final-pc7 + p_outtab_acc-debit_in_period + p_outtab_acc-credit_in_period.
WHEN lc_pc8. "'P63118216'.
gk_final-pc8 = gk_final-pc8 + p_outtab_acc-debit_in_period + p_outtab_acc-credit_in_period.
WHEN lc_pc9. "'P63118217'.
gk_final-pc9 = gk_final-pc9 + p_outtab_acc-debit_in_period + p_outtab_acc-credit_in_period.
WHEN lc_pc10. "'P63118218'.
gk_final-pc10 = gk_final-pc10 + p_outtab_acc-debit_in_period + p_outtab_acc-credit_in_period.
WHEN lc_pc11. "'P63118219'.
gk_final-pc11 = gk_final-pc11 + p_outtab_acc-debit_in_period + p_outtab_acc-credit_in_period.
WHEN lc_pc12. "'P63118220'.
gk_final-pc12 = gk_final-pc12 + p_outtab_acc-debit_in_period + p_outtab_acc-credit_in_period.
WHEN lc_pc13. "'P63118221'.
gk_final-pc13 = gk_final-pc13 + p_outtab_acc-debit_in_period + p_outtab_acc-credit_in_period.
WHEN lc_pc14. "'P63118222'.
gk_final-pc14 = gk_final-pc14 + p_outtab_acc-debit_in_period + p_outtab_acc-credit_in_period.
WHEN lc_pc15. "'P63118223'.
gk_final-pc15 = gk_final-pc15 + p_outtab_acc-debit_in_period + p_outtab_acc-credit_in_period.
WHEN lc_pc16. "'P63118224'.
gk_final-pc16 = gk_final-pc16 + p_outtab_acc-debit_in_period + p_outtab_acc-credit_in_period.
WHEN lc_pc17. "'P63118225'.
gk_final-pc17 = gk_final-pc17 + p_outtab_acc-debit_in_period + p_outtab_acc-credit_in_period.
WHEN lc_pc18. "'P63118226'.
gk_final-pc18 = gk_final-pc18 + p_outtab_acc-debit_in_period + p_outtab_acc-credit_in_period.
WHEN lc_pc19. "'P63118238'.
gk_final-pc19 = gk_final-pc19 + p_outtab_acc-debit_in_period + p_outtab_acc-credit_in_period.
WHEN lc_pc20. "'P63118239'.
gk_final-pc20 = gk_final-pc20 + p_outtab_acc-debit_in_period + p_outtab_acc-credit_in_period.
WHEN lc_pc21. "'P63118240'.
gk_final-pc21 = gk_final-pc21 + p_outtab_acc-debit_in_period + p_outtab_acc-credit_in_period.
WHEN lc_pc22. "'P63110000'.
gk_final-pc22 = gk_final-pc22 + p_outtab_acc-debit_in_period + p_outtab_acc-credit_in_period.
WHEN lc_pc23. "'P63110010'.
gk_final-pc23 = gk_final-pc23 + p_outtab_acc-debit_in_period + p_outtab_acc-credit_in_period.
WHEN lc_pc24. "'P63110020'.
gk_final-pc24 = gk_final-pc24 + p_outtab_acc-debit_in_period + p_outtab_acc-credit_in_period.
WHEN lc_pc25. "'DUMMY'.
gk_final-pc25 = gk_final-pc25 + p_outtab_acc-debit_in_period + p_outtab_acc-credit_in_period.
WHEN lc_pc26. "'DUMMY2'.
gk_final-pc26 = gk_final-pc26 + p_outtab_acc-debit_in_period + p_outtab_acc-credit_in_period.
WHEN ' '.
gk_final-pc27 = gk_final-pc27 + p_outtab_acc-debit_in_period + p_outtab_acc-credit_in_period.
WHEN lc_pc28. "'P63110041'
gk_final-pc28 = gk_final-pc28 + p_outtab_acc-debit_to_period + p_outtab_acc-credit_to_period.
ENDCASE.
ENDFORM. "get_prctr_amount
*&---------------------------------------------------------------------*
*& Form GET_PRCTR_AMOUNT_ALL_PERIODS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_<LS_OUTTAB_ACC> text
*----------------------------------------------------------------------*
FORM f_get_prctr_amount_all_periods USING p_outtab_acc TYPE ty_outtab_acc.
DATA lv_var(15) TYPE c.
CONSTANTS : lc_pc1(9) TYPE c VALUE 'P63118206',
lc_pc2(9) TYPE c VALUE 'P63118207',
lc_pc3(9) TYPE c VALUE 'P63118209',
lc_pc4(9) TYPE c VALUE 'P63118211',
lc_pc5(9) TYPE c VALUE 'P63118213',
lc_pc6(9) TYPE c VALUE 'P63118214',
lc_pc7(9) TYPE c VALUE 'P63118215',
lc_pc8(9) TYPE c VALUE 'P63118216',
lc_pc9(9) TYPE c VALUE 'P63118217',
lc_pc10(9) TYPE c VALUE 'P63118218',
lc_pc11(9) TYPE c VALUE 'P63118219',
lc_pc12(9) TYPE c VALUE 'P63118220',
lc_pc13(9) TYPE c VALUE 'P63118221',
lc_pc14(9) TYPE c VALUE 'P63118222',
lc_pc15(9) TYPE c VALUE 'P63118223',
lc_pc16(9) TYPE c VALUE 'P63118224',
lc_pc17(9) TYPE c VALUE 'P63118225',
lc_pc18(9) TYPE c VALUE 'P63118226',
lc_pc19(9) TYPE c VALUE 'P63118238',
lc_pc20(9) TYPE c VALUE 'P63118239',
lc_pc21(9) TYPE c VALUE 'P63118240',
lc_pc22(9) TYPE c VALUE 'P63110000',
lc_pc23(9) TYPE c VALUE 'P63110010',
lc_pc24(9) TYPE c VALUE 'P63110020',
lc_pc25(9) TYPE c VALUE 'DUMMY',
lc_pc26(9) TYPE c VALUE 'DUMMY2',
lc_pc28(9) TYPE c VALUE 'P63118241'.
CASE p_outtab_acc-prctr.
WHEN lc_pc1. " 'P63118206'.
gk_final-pc1 = gk_final-pc1 + p_outtab_acc-debit_to_period + p_outtab_acc-credit_to_period.
WHEN lc_pc2. " 'P63118207'.
gk_final-pc2 = gk_final-pc2 + p_outtab_acc-debit_to_period + p_outtab_acc-credit_to_period.
WHEN lc_pc3. " 'P63118209'.
gk_final-pc3 = gk_final-pc3 + p_outtab_acc-debit_to_period + p_outtab_acc-credit_to_period.
WHEN lc_pc4. " 'P63118211'.
gk_final-pc4 = gk_final-pc4 + p_outtab_acc-debit_to_period + p_outtab_acc-credit_to_period.
WHEN lc_pc5. " 'P63118213'.
gk_final-pc5 = gk_final-pc5 + p_outtab_acc-debit_to_period + p_outtab_acc-credit_to_period.
WHEN lc_pc6. " 'P63118214'.
gk_final-pc6 = gk_final-pc6 + p_outtab_acc-debit_to_period + p_outtab_acc-credit_to_period.
WHEN lc_pc7. " 'P63118215'.
gk_final-pc7 = gk_final-pc7 + p_outtab_acc-debit_to_period + p_outtab_acc-credit_to_period.
WHEN lc_pc8. " 'P63118216'.
gk_final-pc8 = gk_final-pc8 + p_outtab_acc-debit_to_period + p_outtab_acc-credit_to_period.
WHEN lc_pc9. " 'P63118217'.
gk_final-pc9 = gk_final-pc9 + p_outtab_acc-debit_to_period + p_outtab_acc-credit_to_period.
WHEN lc_pc10. " 'P63118218'.
gk_final-pc10 = gk_final-pc10 + p_outtab_acc-debit_to_period + p_outtab_acc-credit_to_period.
WHEN lc_pc11. " 'P63118219'.
gk_final-pc11 = gk_final-pc11 + p_outtab_acc-debit_to_period + p_outtab_acc-credit_to_period.
WHEN lc_pc12. " 'P63118220'.
gk_final-pc12 = gk_final-pc12 + p_outtab_acc-debit_to_period + p_outtab_acc-credit_to_period.
WHEN lc_pc13. " 'P63118221'.
gk_final-pc13 = gk_final-pc13 + p_outtab_acc-debit_to_period + p_outtab_acc-credit_to_period.
WHEN lc_pc14. " 'P63118222'.
gk_final-pc14 = gk_final-pc14 + p_outtab_acc-debit_to_period + p_outtab_acc-credit_to_period.
WHEN lc_pc15. " 'P63118223'.
gk_final-pc15 = gk_final-pc15 + p_outtab_acc-debit_to_period + p_outtab_acc-credit_to_period.
WHEN lc_pc16. " 'P63118224'.
gk_final-pc16 = gk_final-pc16 + p_outtab_acc-debit_to_period + p_outtab_acc-credit_to_period.
WHEN lc_pc17. " 'P63118225'.
gk_final-pc17 = gk_final-pc17 + p_outtab_acc-debit_to_period + p_outtab_acc-credit_to_period.
WHEN lc_pc18. " 'P63118226'.
gk_final-pc18 = gk_final-pc18 + p_outtab_acc-debit_to_period + p_outtab_acc-credit_to_period.
WHEN lc_pc19. " 'P63118238'.
gk_final-pc19 = gk_final-pc19 + p_outtab_acc-debit_to_period + p_outtab_acc-credit_to_period.
WHEN lc_pc20. " 'P63118239'.
gk_final-pc20 = gk_final-pc20 + p_outtab_acc-debit_to_period + p_outtab_acc-credit_to_period.
WHEN lc_pc21. " 'P63118240'.
gk_final-pc21 = gk_final-pc21 + p_outtab_acc-debit_to_period + p_outtab_acc-credit_to_period.
WHEN lc_pc22. " 'P63110000'.
gk_final-pc22 = gk_final-pc22 + p_outtab_acc-debit_to_period + p_outtab_acc-credit_to_period.
WHEN lc_pc23. " 'P63110010'.
gk_final-pc23 = gk_final-pc23 + p_outtab_acc-debit_to_period + p_outtab_acc-credit_to_period.
WHEN lc_pc24." 'P63110020'.
gk_final-pc24 = gk_final-pc24 + p_outtab_acc-debit_to_period + p_outtab_acc-credit_to_period.
WHEN lc_pc25. " 'DUMMY'.
gk_final-pc25 = gk_final-pc25 + p_outtab_acc-debit_to_period + p_outtab_acc-credit_to_period.
WHEN lc_pc26. " 'DUMMY2'.
gk_final-pc26 = gk_final-pc26 + p_outtab_acc-debit_to_period + p_outtab_acc-credit_to_period.
WHEN ' '.
gk_final-pc27 = gk_final-pc27 + p_outtab_acc-debit_to_period + p_outtab_acc-credit_to_period.
WHEN lc_pc28. "P63110041
gk_final-pc28 = gk_final-pc28 + p_outtab_acc-debit_to_period + p_outtab_acc-credit_to_period.
ENDCASE.
ENDFORM. " GET_PRCTR_AMOUNT_ALL_PERIODS
*&---------------------------------------------------------------------*
*& Form FIELD_CATALOGUE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f_field_catalogue .
DATA ls_fieldcatalog TYPE slis_fieldcat_alv.
DATA: lv_f_name TYPE slis_fieldname,
lv_f_text TYPE dd03p-scrtext_m,
lv_pos TYPE sy-cucol,
lv_outlen TYPE dd03p-outputlen.
DATA wa_sort TYPE slis_sortinfo_alv.
ls_fieldcatalog-fieldname = 'KTNRA'.
ls_fieldcatalog-seltext_m = text-005.
ls_fieldcatalog-col_pos = 1.
ls_fieldcatalog-outputlen = 10.
ls_fieldcatalog-emphasize = 'X'.
ls_fieldcatalog-key = 'X'.
* ls_fieldcatalog-do_sum = 'X'.
* ls_fieldcatalog-no_zero = 'X'.
APPEND ls_fieldcatalog TO gt_fieldcatalog.
CLEAR ls_fieldcatalog.
lv_f_name = 'GLNAME'. lv_f_text = text-006. lv_pos = '2'. lv_outlen = '50'.
PERFORM f_set_field_catalogue USING lv_f_name lv_f_text lv_pos lv_outlen.
lv_f_name = 'RFAREA'. lv_f_text = text-043. lv_pos = '3'. lv_outlen = '10'.
PERFORM f_set_field_catalogue USING lv_f_name lv_f_text lv_pos lv_outlen.
lv_f_name = 'HYPCODE'. lv_f_text = text-007. lv_pos = '3'. lv_outlen = '10'.
PERFORM f_set_field_catalogue USING lv_f_name lv_f_text lv_pos lv_outlen.
lv_f_name = 'PC1'. lv_f_text = text-pc1. lv_pos = '4'. lv_outlen = '15'. "'P63118206'
PERFORM f_set_field_catalogue USING lv_f_name lv_f_text lv_pos lv_outlen.
lv_f_name = 'PC2'. lv_f_text = text-pc2. lv_pos = '5'. lv_outlen = '15'. "'P63118207'
PERFORM f_set_field_catalogue USING lv_f_name lv_f_text lv_pos lv_outlen.
lv_f_name = 'PC3'. lv_f_text = text-pc3. lv_pos = '6'. lv_outlen = '15'. "'P63118209'
PERFORM f_set_field_catalogue USING lv_f_name lv_f_text lv_pos lv_outlen.
lv_f_name = 'PC4'. lv_f_text = text-pc4. lv_pos = '7'. lv_outlen = '15'. "'P63118211'
PERFORM f_set_field_catalogue USING lv_f_name lv_f_text lv_pos lv_outlen.
lv_f_name = 'PC5'. lv_f_text = text-pc5. lv_pos = '8'. lv_outlen = '15'. "'P63118213'
PERFORM f_set_field_catalogue USING lv_f_name lv_f_text lv_pos lv_outlen.
lv_f_name = 'PC6'. lv_f_text = text-pc6. lv_pos = '9'. lv_outlen = '15'. "'P63118214'
PERFORM f_set_field_catalogue USING lv_f_name lv_f_text lv_pos lv_outlen.
lv_f_name = 'PC7'. lv_f_text = text-pc7. lv_pos = '10'. lv_outlen = '15'. "'P63118215'
PERFORM f_set_field_catalogue USING lv_f_name lv_f_text lv_pos lv_outlen.
lv_f_name = 'PC8'. lv_f_text = text-pc8. lv_pos = '11'. lv_outlen = '15'. "'P63118216'
PERFORM f_set_field_catalogue USING lv_f_name lv_f_text lv_pos lv_outlen.
lv_f_name = 'PC9'. lv_f_text = text-pc9. lv_pos = '12'. lv_outlen = '15'. "'P63118217'
PERFORM f_set_field_catalogue USING lv_f_name lv_f_text lv_pos lv_outlen.
lv_f_name = 'PC10'. lv_f_text = text-c10. lv_pos = '13'. lv_outlen = '15'. "'P63118218'
PERFORM f_set_field_catalogue USING lv_f_name lv_f_text lv_pos lv_outlen.
lv_f_name = 'PC11'. lv_f_text = text-c11. lv_pos = '14'. lv_outlen = '15'. "'P63118219'
PERFORM f_set_field_catalogue USING lv_f_name lv_f_text lv_pos lv_outlen.
lv_f_name = 'PC12'. lv_f_text = text-c12. lv_pos = '15'. lv_outlen = '15'. "'P63118220'
PERFORM f_set_field_catalogue USING lv_f_name lv_f_text lv_pos lv_outlen.
lv_f_name = 'PC13'. lv_f_text = text-c13. lv_pos = '16'. lv_outlen = '15'. "'P63118221'
PERFORM f_set_field_catalogue USING lv_f_name lv_f_text lv_pos lv_outlen.
lv_f_name = 'PC14'. lv_f_text = text-c14. lv_pos = '17'. lv_outlen = '15'. "'P63118222'
PERFORM f_set_field_catalogue USING lv_f_name lv_f_text lv_pos lv_outlen.
lv_f_name = 'PC15'. lv_f_text = text-c15. lv_pos = '18'. lv_outlen = '15'. "'P63118223'
PERFORM f_set_field_catalogue USING lv_f_name lv_f_text lv_pos lv_outlen.
lv_f_name = 'PC16'. lv_f_text = text-c16. lv_pos = '19'. lv_outlen = '15'. "'P63118224'
PERFORM f_set_field_catalogue USING lv_f_name lv_f_text lv_pos lv_outlen.
lv_f_name = 'PC17'. lv_f_text = text-c17. lv_pos = '20'. lv_outlen = '15'. "'P63118225'
PERFORM f_set_field_catalogue USING lv_f_name lv_f_text lv_pos lv_outlen.
lv_f_name = 'PC18'. lv_f_text = text-c18. lv_pos = '21'. lv_outlen = '15'. "'P63118226'
PERFORM f_set_field_catalogue USING lv_f_name lv_f_text lv_pos lv_outlen.
lv_f_name = 'PC19'. lv_f_text = text-c19. lv_pos = '22'. lv_outlen = '15'. "'P63118238'
PERFORM f_set_field_catalogue USING lv_f_name lv_f_text lv_pos lv_outlen.
lv_f_name = 'PC20'. lv_f_text = text-c20. lv_pos = '23'. lv_outlen = '15'. "'P63118239'
PERFORM f_set_field_catalogue USING lv_f_name lv_f_text lv_pos lv_outlen.
lv_f_name = 'PC21'. lv_f_text = text-c21. lv_pos = '24'. lv_outlen = '15'. "'P63118240'
PERFORM f_set_field_catalogue USING lv_f_name lv_f_text lv_pos lv_outlen.
lv_f_name = 'PC22'. lv_f_text = text-c22. lv_pos = '25'. lv_outlen = '15'. "'P63110000'
PERFORM f_set_field_catalogue USING lv_f_name lv_f_text lv_pos lv_outlen.
lv_f_name = 'PC23'. lv_f_text = text-c23. lv_pos = '26'. lv_outlen = '15'. "'P63110010'
PERFORM f_set_field_catalogue USING lv_f_name lv_f_text lv_pos lv_outlen.
lv_f_name = 'PC24'. lv_f_text = text-c24. lv_pos = '27'. lv_outlen = '15'. "'P63110020'
PERFORM f_set_field_catalogue USING lv_f_name lv_f_text lv_pos lv_outlen.
lv_f_name = 'PC25'. lv_f_text = text-c25. lv_pos = '28'. lv_outlen = '15'. "'DUMMY'
PERFORM f_set_field_catalogue USING lv_f_name lv_f_text lv_pos lv_outlen.
lv_f_name = 'PC26'. lv_f_text = text-c26. lv_pos = '29'. lv_outlen = '15'. "'DUMMY2'
PERFORM f_set_field_catalogue USING lv_f_name lv_f_text lv_pos lv_outlen.
lv_f_name = 'PC27'. lv_f_text = text-c27. lv_pos = '30'. lv_outlen = '15'. "'BLANK'
PERFORM f_set_field_catalogue USING lv_f_name lv_f_text lv_pos lv_outlen.
lv_f_name = 'PC28'. lv_f_text = text-c28. lv_pos = '31'. lv_outlen = '15'. "'P63118241'
PERFORM f_set_field_catalogue USING lv_f_name lv_f_text lv_pos lv_outlen.
ls_fieldcatalog-fieldname = 'BALANCE'.
ls_fieldcatalog-seltext_m = text-004.
ls_fieldcatalog-col_pos = 32.
ls_fieldcatalog-outputlen = 18.
ls_fieldcatalog-do_sum = 'X'.
APPEND ls_fieldcatalog TO gt_fieldcatalog.
CLEAR ls_fieldcatalog.
ENDFORM. " FIELD_CATALOGUE
* Custom event handler to write group-level header
* Changing the length and spaces will change header 1 sync with header 2
FORM f_top_of_list .
DATA lv_records(3) TYPE n.
DATA lt_list_comments TYPE slis_t_listheader.
DATA ls_list_comments TYPE slis_listheader.
DATA: lv1 TYPE string,
lv2 TYPE string,
lv3 TYPE string,
lv4 TYPE string.
CONSTANTS: lc_s TYPE c VALUE 'S'.
DESCRIBE TABLE gt_final LINES lv_records.
lv1 = text-009.
lv2 = text-010.
lv3 = text-011.
lv4 = text-012.
ls_list_comments-typ = lc_s.
CONCATENATE lv1 sy-uname INTO lv1 SEPARATED BY space.
CONCATENATE lv2 sy-datum INTO lv2 SEPARATED BY space.
CONCATENATE lv1 lv2 INTO ls_list_comments-info SEPARATED BY space.
APPEND ls_list_comments TO lt_list_comments.
ls_list_comments-typ = lc_s.
CONCATENATE lv3 lv_records INTO lv3 SEPARATED BY space.
CONCATENATE lv4 sy-uzeit INTO lv4 SEPARATED BY space.
CONCATENATE lv3 lv4 INTO ls_list_comments-info SEPARATED BY space.
APPEND ls_list_comments TO lt_list_comments.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = lt_list_comments.
ULINE AT 1(552) .
FORMAT COLOR = 7 .
WRITE: / sy-vline ,
86 sy-vline ,
87 text-013, "' GUJRAT ' ,
102 sy-vline ,
103 text-014, "' KARNATAKA ' ,
118 sy-vline ,
119 text-015, "' TAMIL NADU ',
134 sy-vline,
135 text-016, "' ORISSA ',
150 sy-vline,
151 text-017, "' DELHI ',
166 sy-vline,
167 text-018, "' UP ',
182 sy-vline ,
183 text-019, "' HARAYANA ',
198 sy-vline,
199 text-020, "' ASSAM ',
214 sy-vline,
215 text-021, "' MP ',
230 sy-vline,
231 text-022, "' RAJASTHAN ',
246 sy-vline ,
247 text-023, "' WB ',
262 sy-vline,
263 text-024, "' PUNJAB ',
278 sy-vline,
279 text-025, "' MAHARASTRA ',
294 sy-vline,
295 text-026, "' BIHAR ',
310 sy-vline,
311 text-027, "' CHATTISGARH ',
326 sy-vline,
327 text-028, "' JHARKHAND ',
342 sy-vline,
343 text-029, "' HARYANA ',
358 sy-vline,
359 text-030, "' TG ',
374 sy-vline,
375 text-031, "' Patodi ',
390 sy-vline,
391 text-032, "' Palwal ',
406 sy-vline,
407 text-033, "' HO HARYANA ',
422 sy-vline,
423 text-034, "' P63110000',
438 sy-vline,
439 text-035, "' P63110010',
454 sy-vline,
455 text-036, "' P63110020',
470 sy-vline,
471 text-037, "' DUMMY ',
486 sy-vline,
487 text-038, "' DUMMY2 ',
502 sy-vline,
503 text-039, "' BLANK ',
518 sy-vline,
519 text-039, "' ISD ',
534 sy-vline,
553 sy-vline.
ENDFORM. "MY_TOP_OF_LIST
*&---------------------------------------------------------------------*
*& Form VAL_BUKRS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f_val_bukrs .
DATA ls_bukrs TYPE t001.
SELECT SINGLE * FROM t001 INTO ls_bukrs WHERE bukrs EQ p_bukrs.
IF sy-subrc <> 0.
SET CURSOR FIELD 'P_BUKRS-LOW'.
MESSAGE text-002 TYPE gc_e.
ENDIF.
ENDFORM. " VAL_BUKRS
*&---------------------------------------------------------------------*
*& Form F_VAL_BUPLA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f_val_bupla .
DATA ls_bupla TYPE gsber.
IF s_bupla IS NOT INITIAL.
SELECT SINGLE gsber FROM tgsb INTO ls_bupla WHERE gsber EQ s_bupla-low.
IF ls_bupla IS INITIAL.
SET CURSOR FIELD 'S_BUPLA-LOW'.
MESSAGE text-040 TYPE gc_e.
ENDIF.
ENDIF.
ENDFORM. " F_VAL_BUPLA
*&---------------------------------------------------------------------*
*& Form F_VAL_PRCTR
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f_val_prctr .
DATA ls_cepc LIKE cepc.
IF s_prctr IS NOT INITIAL.
SELECT * UP TO 1 ROWS FROM cepc INTO ls_cepc WHERE prctr IN s_prctr.
ENDSELECT.
IF ls_cepc IS INITIAL.
SET CURSOR FIELD 'S_PRCTR-LOW'.
MESSAGE text-041 TYPE gc_e.
ENDIF.
ENDIF.
ENDFORM. "f_val_prctr
" F_VAL_PRCTR
*&---------------------------------------------------------------------*
*& Form F_SET_FIELD_CATALOGUE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LV_F_NAME text
* -->P_LV_F_TEXT text
* -->P_LV_POS text
* -->P_LV_OUTLEN text
*----------------------------------------------------------------------*
FORM f_set_field_catalogue USING p_lv_f_name TYPE slis_fieldname
p_lv_f_text TYPE dd03p-scrtext_m
p_lv_pos TYPE sy-cucol
p_lv_outlen TYPE dd03p-outputlen.
DATA ls_fieldcatalog TYPE slis_fieldcat_alv.
ls_fieldcatalog-fieldname = p_lv_f_name.
ls_fieldcatalog-seltext_l = p_lv_f_text.
ls_fieldcatalog-col_pos = p_lv_pos.
ls_fieldcatalog-outputlen = p_lv_outlen.
APPEND ls_fieldcatalog TO gt_fieldcatalog.
CLEAR ls_fieldcatalog.
ENDFORM. " F_SET_FIELD_CATALOGUE
*&---------------------------------------------------------------------*
*& Form F_GET_BALANCE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_GK_FINAL text
*----------------------------------------------------------------------*
FORM f_get_balance CHANGING p_gk_final TYPE ty_final.
* Summing up all profit center amounts
p_gk_final-balance = p_gk_final-pc1 + p_gk_final-pc2 + p_gk_final-pc3 + p_gk_final-pc4 + p_gk_final-pc5 +
p_gk_final-pc6 + p_gk_final-pc7 + p_gk_final-pc8 + p_gk_final-pc9 + p_gk_final-pc10 +
p_gk_final-pc11 + p_gk_final-pc12 + p_gk_final-pc13 + p_gk_final-pc14 + p_gk_final-pc15 +
p_gk_final-pc16 + p_gk_final-pc17 + p_gk_final-pc18 + p_gk_final-pc19 + p_gk_final-pc20 +
p_gk_final-pc21 + p_gk_final-pc22 + p_gk_final-pc23 + p_gk_final-pc24 + p_gk_final-pc25 +
p_gk_final-pc26 + p_gk_final-pc27 + p_gk_final-pc28.
ENDFORM. " F_GET_BALANCE