‎2006 Nov 05 9:08 AM
In this report I added Ranges for G/L Account In this report i excute .that report showing the openning balance is 0.00.any body slove my problem?and h to solve the problem Its urgent for me
Regards
vijayreddy
&----
*& Report ZRPT_FI_028 *
*& *
&----
*& *
*& *
&----
REPORT ZRPT_FI_028 LINE-SIZE 250 .
----
Dev. Class : *
Report Name : *
Program Type : Report *
Created by : *
Created on : *
Transaction Code : *
Module Name : *
Object ID : *
Description : *
SAP Release : *
Change Request : *
Modified on : *
Func and tech details of the program. *
*
----
*type-pools :
*include :
tables : bkpf, bseg, glt0, skat, lfa1, kna1, SKA1, bsis, bsas, t001,t074t.
selection-screen : begin of block s1 with frame title text-001.
PARAMETERS : P_bukrs LIKE bkpf-bukrs,
P_gjahr LIKE bkpf-gjahr.
SELECT-OPTIONS : s_blart FOR bkpf-blart ,
p_HKONT for BSEG-HKONT,
s_budat FOR bkpf-budat OBLIGATORY,
s_belnr FOR bkpf-belnr.
*PARAMETERS : P_saknr FOR ska1-saknr OBLIGATORY.
s_saknr FOR skat-saknr OBLIGATORY.
S_SAKNR FOR SKA1-SAKNR.
selection-screen : end of block s1.
data : it_bkpf like bkpf occurs 0 with header line,
it_bseg like bseg occurs 0 with header line,
it_glt0 like glt0 occurs 0 with header line.
DATA : BEGIN OF ITAB OCCURS 0,
BUDAT LIKE BKPF-BUDAT,
BELNR LIKE BKPF-BELNR,
BLART LIKE BKPF-BLART,
koart like bseg-koart,
umskz like bseg-umskz,
ltext like t074t-ltext,
hkont like bseg-hkont,
txt50 like skat-txt50,
XBLNR LIKE BKPF-XBLNR,
ZUONR LIKE BSEG-ZUONR,
SGTXT LIKE BSEG-SGTXT,
KOSTL LIKE BSEG-KOSTL,
DMBTR_S LIKE BSEG-DMBTR,
DMBTR_H LIKE BSEG-DMBTR,
END OF ITAB.
data : gs_bal like BAPI1028_4,
gt_bal like BAPI1028_4 occurs 0 with header line .
data : wa_bal like bapi1028_0.
DATA : GV_OPEN_BAL LIKE BSEG-DMBTR.
data : it_bsis like bsis occurs 0 with header line.
data : v_butxt type butxt.
*at selection-screen :
*initialization.
START-OF-SELECTION.
perform get_data.
perform process_data.
perform display_data.
END-OF-SELECTION.
AT LINE-SELECTION.
AT USER-COMMAND.
&----
*& Form get_data
&----
text
----
--> p1 text
<-- p2 text
----
form get_data .
select * from bsis
into table it_bsis
where bukrs = p_bukrs and
hkont = p_hkont and
gjahr = p_gjahr and
blart in s_blart and
budat in s_budat.
select * from bsas
appending table it_bsis
where bukrs = p_bukrs and
hkont = p_hkont and
gjahr = p_gjahr and
blart in s_blart and
budat in s_budat.
check not it_bsis[] is initial.
select * from bkpf
into table it_bkpf
for all entries in it_bsis
where bukrs = it_bsis-bukrs and
belnr eq it_bsis-belnr and
gjahr eq it_bsis-gjahr and
blart eq it_bsis-blart AND
BUDAT eq it_bsis-BUDAT.
CHECK NOT IT_BKPF[] IS INITIAL.
SELECT * FROM BSEG
INTO TABLE IT_BSEG
FOR ALL ENTRIES IN IT_BKPF
WHERE hkont in p_hkont and
BUKRS = IT_BKPF-BUKRS AND
BELNR = IT_BKPF-BELNR AND
GJAHR = IT_BKPF-GJAHR.
*delete it_bseg where hkont = p_hkont.
endform. " get_data
&----
*& Form process_data
&----
text
----
--> p1 text
<-- p2 text
----
form process_data .
SORT : IT_BKPF, IT_BSEG.
LOOP AT IT_BSEG.
CLEAR : ITAB, IT_BKPF.
READ TABLE IT_BKPF
WITH KEY BUKRS = IT_BSEG-BUKRS
BELNR = IT_BSEG-BELNR
GJAHR = IT_BSEG-GJAHR.
MOVE-CORRESPONDING IT_BKPF TO ITAB.
MOVE-CORRESPONDING IT_BSEG TO ITAB.
IF IT_BSEG-SHKZG = 'H'.
it_bseg-dmbtr = it_bseg-dmbtr * - 1.
MOVE IT_BSEG-DMBTR TO ITAB-DMBTR_H.
ELSE.
MOVE IT_BSEG-DMBTR TO ITAB-DMBTR_S.
ENDIF.
case it_bseg-koart.
when 'S'.
select single * from skat
where spras = sy-langu and
ktopl = '9000' and
saknr = itab-hkont.
move skat-txt50 to itab-txt50.
when 'K'.
select single * from lfa1
where lifnr = it_bseg-lifnr.
move it_bseg-lifnr to itab-hkont.
move lfa1-name1 to itab-txt50.
when 'D'.
select single * from kna1
where kunnr = it_bseg-kunnr.
move it_bseg-kunnr to itab-hkont.
move kna1-name1 to itab-txt50.
when 'A'.
when 'M'.
endcase.
select single * from t074t
where spras = sy-langu and
koart = it_bseg-koart and
shbkz = it_bseg-umskz.
if sy-subrc = 0.
move t074t-ltext to itab-ltext.
endif.
APPEND ITAB.
ENDLOOP.
endform. " process_data
&----
*& Form display_data
&----
text
----
--> p1 text
<-- p2 text
----
form display_data .
select single * from skat
where spras = sy-langu and
ktopl = '9000' and
saknr = p_hkont.
perform write_header.
data : lv_total_budat like bseg-dmbtr,
lv_total like bseg-dmbtr.
sort itab by budat belnr.
perform get_opening_balance.
write :/182 'Opening Balance : ', 217 gv_open_bal..
write :/196 'Opening Balance : ', gv_open_bal.
clear lv_total_budat.
move gv_open_bal to lv_total_budat.
LOOP AT ITAB.
WRITE 😕 ITAB-BUDAT,
ITAB-BELNR,
ITAB-BLART,
itab-ltext,
itab-hkont,
itab-txt50,
ITAB-XBLNR,
ITAB-ZUONR,
ITAB-SGTXT,
ITAB-KOSTL,
ITAB-DMBTR_H,
ITAB-DMBTR_S.
at end of budat.
sum.
lv_total_budat = lv_total_budat + itab-dmbtr_h - itab-dmbtr_s.
skip 1.
uline.
write :/185 'Daywise total :' , itab-dmbtr_h, itab-dmbtr_s,
/174 'Day wise closing Balance :' , lv_total_budat.
write :/188 'Daywise total :' , 217 itab-dmbtr_h, itab-dmbtr_s,
/179 'Day wise closing Balance :' , 217 lv_total_budat.
uline.
endat.
at last.
sum.
lv_total = gv_open_bal + itab-dmbtr_h - itab-dmbtr_s.
skip 1.
uline.
write :/200 'GL Totals :' , 217 itab-dmbtr_h, itab-dmbtr_s,
/179 'GL Closing Balance :' , 217 lv_total.
write :/200 'GL Totals' , itab-dmbtr_h, itab-dmbtr_s,
/170 'GL Closinge closing Balance :' , lv_total.
endat.
ENDLOOP.
endform. " display_data
&----
*& Form get_opening_balance
&----
text
----
--> p1 text
<-- p2 text
----
form get_opening_balance .
data : comp_code like BAPI1028_0-COMP_CODE,
gl_account like BAPI1028_0-GL_ACCOUNT,
FISCALYEAR LIKE BAPI1028_4-FISC_YEAR,
CURRENCYTYPE LIKE BAPI1028_5-CURR_TYPE.
data : v_RETURN LIKE BAPIRETURN .
data : v_perio type monat.
move p_bukrs to comp_code.
move p_hkont to gl_account.
move p_gjahr to fiscalyear.
move '10' to currencytype.
CALL FUNCTION 'BAPI_GL_GETGLACCPERIODBALANCES'
EXPORTING
companycode = comp_code
glacct = gl_account
fiscalyear = fiscalyear
currencytype = '10'
IMPORTING
BALANCE_CARRIED_FORWARD = gs_bal-balance
RETURN = v_return
tables
account_balances = gt_bal.
DELETE GT_BAL WHERE DEBITS_PER IS INITIAL AND CREDIT_PER IS INITIAL.
sort gt_bal.
if s_budat-low+4(2) GE 4.
v_perio = s_budat-low+4(2) - 3.
else.
v_perio = s_budat-low+4(2) + 9.
endif.
case v_perio.
when '01'.
gv_open_bal = gs_bal-balance.
when others.
v_perio = v_perio - 1.
read table gt_bal
with key fis_period = v_perio.
gv_open_bal = gt_bal-balance.
endcase.
perform compute_open_balance.
endform. " get_opening_balance
&----
*& Form write_header
&----
text
----
--> p1 text
<-- p2 text
----
form write_header .
select single * from t001
where bukrs = p_bukrs.
write : t001-butxt to sy-tvar0.
write : sy-uname to sy-tvar1.
write : sy-tcode to sy-tvar2.
write : s_budat-low to sy-tvar3.
write : s_budat-high to sy-tvar4.
write : 'GL Account ' to sy-tvar5.
write : p_hkont to sy-tvar6.
write : skat-txt20 to sy-tvar7.
endform. " write_header
&----
*& Form compute_open_balance
&----
text
----
--> p1 text
<-- p2 text
----
form compute_open_balance .
data : lv_first_date type budat,
lv_last_date type budat.
DATA : BEGIN OF temp_ITAB OCCURS 0,
BUDAT LIKE BKPF-BUDAT,
BELNR LIKE BKPF-BELNR,
BLART LIKE BKPF-BLART,
hkont like bseg-hkont,
txt50 like skat-txt50,
XBLNR LIKE BKPF-XBLNR,
ZUONR LIKE BSEG-ZUONR,
SGTXT LIKE BSEG-SGTXT,
KOSTL LIKE BSEG-KOSTL,
DMBTR_S LIKE BSEG-DMBTR,
DMBTR_H LIKE BSEG-DMBTR,
END OF temp_ITAB.
data : temp_bsis like bsis occurs 0 with header line,
temp_bkpf like bkpf occurs 0 with header line,
temp_bseg like bseg occurs 0 with header line.
data : lv_dmbtr type dmbtr.
move s_budat-low to lv_first_date.
move '01' to lv_first_date+6(2).
lv_last_date = s_budat-low - 1.
select * from bsis
into table temp_bsis
where bukrs = p_bukrs and
hkont = p_hkont and
gjahr = p_gjahr and
blart in s_blart and
( budat between lv_first_date and lv_last_date ).
select * from bsas
appending table temp_bsis
where bukrs = p_bukrs and
hkont = p_hkont and
gjahr = p_gjahr and
blart in s_blart and
( budat between lv_first_date and lv_last_date ).
check not temp_bsis[] is initial.
select * from bkpf
into table temp_bkpf
for all entries in temp_bsis
where bukrs = temp_bsis-bukrs and
belnr eq temp_bsis-belnr and
gjahr eq temp_bsis-gjahr and
blart eq temp_bsis-blart AND
BUDAT eq temp_bsis-BUDAT.
CHECK NOT Temp_BKPF[] IS INITIAL.
SELECT * FROM BSEG
INTO TABLE Temp_BSEG
FOR ALL ENTRIES IN Temp_BKPF
WHERE BUKRS = Temp_BKPF-BUKRS AND
BELNR = Temp_BKPF-BELNR AND
GJAHR = Temp_BKPF-GJAHR.
*delete temp_bseg where hkont = p_hkont.
SORT : Temp_BKPF, Temp_BSEG.
LOOP AT Temp_BSEG.
CLEAR : temp_ITAB, Temp_BKPF.
READ TABLE Temp_BKPF
WITH KEY BUKRS = temp_BSEG-BUKRS
BELNR = temp_BSEG-BELNR
GJAHR = temp_BSEG-GJAHR.
MOVE-CORRESPONDING temp_BKPF TO temp_ITAB.
MOVE-CORRESPONDING temp_BSEG TO temp_ITAB.
IF temp_BSEG-SHKZG = 'H'.
it_bseg-dmbtr = it_bseg-dmbtr * - 1.
MOVE temp_BSEG-DMBTR TO temp_ITAB-DMBTR_H.
ELSE.
MOVE temp_BSEG-DMBTR TO temp_ITAB-DMBTR_S.
ENDIF.
APPEND temp_ITAB.
ENDLOOP.
clear lv_dmbtr.
loop at temp_itab.
at last.
sum.
lv_dmbtr = temp_itab-dmbtr_h - temp_itab-dmbtr_s.
endat.
endloop.
gv_open_bal = gv_open_bal + lv_dmbtr.
endform. " compute_open_balance
‎2006 Nov 06 4:49 AM
check or ref.report of FS10N.
i am not happy with ur logic what u put for Opening balance.
regards
Prabhu
‎2006 Nov 06 5:08 AM
hi
good
i tryid the same report but for me it is showing the correct result, check out the field value from which table you r taking the value, that value might be 0.00 that is the reason it is whosing 0.00 for you.
thanks
mrutyun^