Skip to Content
0
Former Member
Oct 02, 2007 at 03:24 AM

GL report Printing problem..

14 Views

Hi SDN EXperts,

i have a problem to print the output. just see my code and let me know where i ve gone wrong.

in my report am trying 2 printing Opening balances for all accounts, but here for some accounts its printing 2 times, so plz rectify my problem where i did mistake.

i.e, in my report i ve calculated opening balance for given GL account. here GL account having 2 amounts like Credit(cr) and Debit(dr).

but for some accounts having only one amount, i.e either cr (or) dr.

but my problem is while printing output, for some accounts O.bal is printing 2 times for those GL ac having 2 amounts(cr & dr),

but i want 2 print one O.bal for one GL account.

if possible u can execute this report.

my O/P is printing like ..

GL account : A1F1309999

Comp code: SG02

Posting date: 28.02.2007

OPEnING Balance : 10,654,38.

GL account : A1F1309999

Comp code: SG02

Posting date: 28.02.2007

OPEnING Balance : 10,654,38.

GL account : A1F1350000

Comp code: SG02

Posting date: 28.02.2007

OPEnING Balance : 1,577,57.

GL account : A1F1350001

Comp code: SG02

Posting date: 28.02.2007

OPEnING Balance : 1,577,57.

GL account : A1F1400000

Comp code: SG02

Posting date: 28.02.2007

OPEnING Balance : 174.116,10.

GL account : A1F1400000

Comp code: SG02

Posting date: 28.02.2007

OPEnING Balance : 174.116,10.

but Required output is:

GL account : A1F1309999

Comp code: SG02

Posting date: 28.02.2007

OPEnING Balance : 10,654,38.

GL account : A1F1350000

Comp code: SG02

Posting date: 28.02.2007

OPEnING Balance : 1,577,57.

GL account : A1F1350001

Comp code: SG02

Posting date: 28.02.2007

OPEnING Balance : 1,577,57.

GL account : A1F1400000

Comp code: SG02

Posting date: 28.02.2007

OPEnING Balance : 174.116,10

&----


*& Report Y_TEST *

*& *

&----


*& *

*& *

&----


REPORT Y_TEST NO STANDARD PAGE HEADING .

  • table declaration ***

TABLES: glt0, " G/L account master record transaction figures "#EC *

bseg, " Accounting Document Segment for Line Items "#EC *

bkpf. " Accounting Document Header "#EC *

  • DATA declaration ***

DATA: count TYPE i,

l_len(4) TYPE n,

month(2) TYPE n,

value(4) type n,

debit LIKE glt0-hslvt,

credit LIKE glt0-hslvt,

result LIKE glt0-hslvt.

DATA: v_day(2) TYPE c,

v_dat1 TYPE p, "#EC *

v_mon(2) TYPE c,

v_year(4) TYPE c,

v_date LIKE sy-datum, "#EC NEEDED

f_date TYPE sy-datum,

l_date TYPE sydatum, "#EC NEEDED

v_total LIKE bseg-dmbtr,

sum0 LIKE glt0-hslvt,

sum1 LIKE glt0-hslvt,

sum2 LIKE glt0-hslvt,

sum3 LIKE glt0-hslvt,

add LIKE glt0-hslvt. "#EC *

  • GLT0 table for opening balance from 16 periods

Types: begin of g_data,

rclnt LIKE glt0-rclnt,

bukrs LIKE glt0-bukrs,

drcrk LIKE glt0-drcrk,

ryear LIKE glt0-ryear,

racct LIKE glt0-racct,

hslvt LIKE glt0-hslvt,

hsl01 LIKE glt0-hsl01,

hsl02 LIKE glt0-hsl02,

hsl03 LIKE glt0-hsl03,

hsl04 LIKE glt0-hsl04,

hsl05 LIKE glt0-hsl05,

hsl06 LIKE glt0-hsl06,

hsl07 LIKE glt0-hsl07,

hsl08 LIKE glt0-hsl08,

hsl09 LIKE glt0-hsl09,

hsl10 LIKE glt0-hsl10,

hsl11 LIKE glt0-hsl11,

hsl12 LIKE glt0-hsl12,

hsl13 LIKE glt0-hsl13,

hsl14 LIKE glt0-hsl14,

hsl15 LIKE glt0-hsl15,

hsl16 LIKE glt0-hsl16,

start_balance LIKE glt0-hslvt,

end_balance LIKE glt0-hslvt,

END OF g_data.

DATA : gt_data TYPE STANDARD TABLE OF g_data WITH HEADER LINE,

wa_gt_data TYPE g_data.

DATA : gt_data1 TYPE STANDARD TABLE OF g_data WITH HEADER LINE,

wa_gt_data1 TYPE g_data.

...selections.........................................................

SELECTION-SCREEN BEGIN OF BLOCK blk.

SELECT-OPTIONS: so_racct FOR glt0-racct, " NO INTERVALS NO-EXTENSION,

so_bukrs FOR glt0-bukrs NO INTERVALS NO-EXTENSION.

PARAMETERS: p_date LIKE sy-datum.

SELECTION-SCREEN END OF BLOCK blk.

START-OF-SELECTION.

v_day = '01'.

v_mon = p_date+4(2).

v_year = p_date+0(4).

value = '0.00'.

CONCATENATE v_year v_mon v_day INTO v_date.

month = v_mon.

IF NOT p_date IS INITIAL.

CALL FUNCTION 'HR_JP_MONTH_BEGIN_END_DATE'

EXPORTING

iv_date = p_date

IMPORTING

EV_MONTH_BEGIN_DATE = f_date

EV_MONTH_END_DATE = l_date.

ENDIF.

l_len = p_date+0(4).

CLEAR wa_gt_data.

SELECT * FROM GLT0 INTO CORRESPONDING FIELDS OF TABLE gt_data1

WHERE racct IN so_racct AND

bukrs IN so_bukrs AND

ryear = l_len.

SELECT rclnt

bukrs

drcrk

ryear

racct

hslvt

hsl01

hsl02

hsl03

hsl04

hsl05

hsl06

hsl07

hsl08

hsl09

hsl10

hsl11

hsl12

hsl13

hsl14

hsl15

hsl16

FROM glt0 INTO CORRESPONDING FIELDS OF TABLE gt_data

WHERE racct IN so_racct AND

bukrs IN so_bukrs AND

ryear = l_len.

LOOP AT gt_data1.

wa_gt_data1 = gt_data1.

at new racct.

IF sy-tabix NE 1.

NEW-PAGE.

ENDIF.

LOOP AT gt_data INTO wa_gt_data WHERE racct = gt_data1-racct.

CASE month.

WHEN '00'.

wa_gt_data-start_balance = wa_gt_data-hslvt.

PERFORM display_data.

WHEN '01'.

wa_gt_data-start_balance = wa_gt_data-hslvt.

PERFORM display_data.

WHEN '02'.

wa_gt_data-start_balance = wa_gt_data-hslvt +

wa_gt_data-hsl01.

PERFORM display_data.

WHEN '03'.

wa_gt_data-start_balance = wa_gt_data-hslvt +

wa_gt_data-hsl01 +

wa_gt_data-hsl02.

PERFORM display_data.

WHEN '04'.

wa_gt_data-start_balance = wa_gt_data-hslvt +

wa_gt_data-hsl01 +

wa_gt_data-hsl02 +

wa_gt_data-hsl03.

PERFORM display_data.

WHEN '05'.

wa_gt_data-start_balance = wa_gt_data-hslvt +

wa_gt_data-hsl01 +

wa_gt_data-hsl02 +

wa_gt_data-hsl03 +

wa_gt_data-hsl04.

PERFORM display_data.

WHEN '06'.

wa_gt_data-start_balance = wa_gt_data-hslvt +

wa_gt_data-hsl01 +

wa_gt_data-hsl02 +

wa_gt_data-hsl03 +

wa_gt_data-hsl04 +

wa_gt_data-hsl05.

PERFORM display_data.

WHEN '07'.

wa_gt_data-start_balance = wa_gt_data-hslvt +

wa_gt_data-hsl01 +

wa_gt_data-hsl02 +

wa_gt_data-hsl03 +

wa_gt_data-hsl04 +

wa_gt_data-hsl05 +

wa_gt_data-hsl06.

PERFORM display_data.

WHEN '08'.

wa_gt_data-start_balance = wa_gt_data-hslvt +

wa_gt_data-hsl01 +

wa_gt_data-hsl02 +

wa_gt_data-hsl03 +

wa_gt_data-hsl04 +

wa_gt_data-hsl05 +

wa_gt_data-hsl06 +

wa_gt_data-hsl07.

PERFORM display_data.

WHEN '09'.

wa_gt_data-start_balance = wa_gt_data-hslvt +

wa_gt_data-hsl01 +

wa_gt_data-hsl02 +

wa_gt_data-hsl03 +

wa_gt_data-hsl04 +

wa_gt_data-hsl05 +

wa_gt_data-hsl06 +

wa_gt_data-hsl07 +

wa_gt_data-hsl08.

PERFORM display_data.

WHEN '10'.

wa_gt_data-start_balance = wa_gt_data-hslvt +

wa_gt_data-hsl01 +

wa_gt_data-hsl02 +

wa_gt_data-hsl03 +

wa_gt_data-hsl04 +

wa_gt_data-hsl05 +

wa_gt_data-hsl06 +

wa_gt_data-hsl07 +

wa_gt_data-hsl08 +

wa_gt_data-hsl09.

PERFORM display_data.

WHEN '11'.

wa_gt_data-start_balance = wa_gt_data-hslvt +

wa_gt_data-hsl01 +

wa_gt_data-hsl02 +

wa_gt_data-hsl03 +

wa_gt_data-hsl04 +

wa_gt_data-hsl05 +

wa_gt_data-hsl06 +

wa_gt_data-hsl07 +

wa_gt_data-hsl08 +

wa_gt_data-hsl09 +

wa_gt_data-hsl10.

PERFORM display_data.

WHEN '12'.

wa_gt_data-start_balance = wa_gt_data-hslvt +

wa_gt_data-hsl01 +

wa_gt_data-hsl02 +

wa_gt_data-hsl03 +

wa_gt_data-hsl04 +

wa_gt_data-hsl05 +

wa_gt_data-hsl06 +

wa_gt_data-hsl07 +

wa_gt_data-hsl08 +

wa_gt_data-hsl09 +

wa_gt_data-hsl10 +

wa_gt_data-hsl11.

wa_gt_data-end_balance = wa_gt_data-hsl13 +

wa_gt_data-hsl14 +

wa_gt_data-hsl15 +

wa_gt_data-hsl16.

MOVE wa_gt_data-end_balance TO sum3.

PERFORM display_data.

ENDCASE.

ENDLOOP.

WRITE: /50 'GL ACCOUNT :', wa_gt_data-racct COLOR 7.

WRITE: /50 'COMP CODE :', wa_gt_data-bukrs COLOR 7.

WRITE: /50 'POSTING DATE:',p_date COLOR 7.

WRITE: /123 'OPENING BALANCE ' , result COLOR 3. "#EC UOM_IN_MES

write: /'hi -


'.

write: /'hi Line items here'.

write: /' -


'.

write: /'hi closing bal here'.

CLEAR: debit,

credit,

result.

ENDAT.

ENDLOOP.

  • ENDLOOP.

&----


*& Form display_data

&----


  • text

----


FORM display_data.

IF wa_gt_data-drcrk = 'H'.

debit = debit + wa_gt_data-start_balance.

ELSE.

credit = credit + wa_gt_data-start_balance.

ENDIF.

result = debit + credit.

ENDFORM. "display_data

-