Skip to Content
0
Former Member
Nov 22, 2013 at 03:42 AM

How to get all the entries of accounting doc number in bseg table?

724 Views

Hi,

I have created a report which i need to display all the entries of accounting doc number(belnr) from bseg and link the belnr to bseg table to get all data of bkpf-budat, bseg-hkont,bseg- belnr, bseg-dmbtr and bseg-shkzg.

I have a parameter: bseg-bukrs and

select-options: bseg-hkont (entries of belnr in bseg table)

bkpf-blart

bkpf budat.

REQUIREMENT: (To display all the line items of BELNR)

The output should look like this:

DATE HKONT BELNR DEBIT CREDIT

11/02/2010 10402000 81007760 97,000

11/02/2010 10402025 81007760 97,000

Grand Total: 97,000 97,000

The problem is when I'm using these example parameter

parameter: bseg-bukrs -4000

select-options: bseg-hkont -10402000

bkpf-blart -jv

bkpf budat. 11/01/2010 to 11/30/2010

My output goes like this

DATE HKONT BELNR DEBIT CREDIT

11/02/2010 10402000 81007760 97,000

Grand Total: 97,000

My output only shows one entry of belnr, which is the hkont i entered only in parameter.

MY PROBLEM IS HOW TO DISPLAY THE HKONT 10402000 AND 10402025? I WANT THE BOTH ENTRIES OF BELNR WILL BE DISPALYED EVEN IF THERE'S HKONT PARAMETER.

Please help.

Here's my codes:

*&---------------------------------------------------------------------*

*& Report ZFI_GJOURNAL_ENTRY_2

*&

*&---------------------------------------------------------------------*

*&

*&

*&---------------------------------------------------------------------*

REPORT ZFI_GJOURNAL_ENTRY_2

LINE-SIZE 350

NO STANDARD PAGE HEADING

MESSAGE-ID rf.

TABLES: bkpf,bseg, skat.

DATA: bkpftab LIKE bkpf OCCURS 0 WITH HEADER LINE,

bsegtab like bseg occurs 0 with header line.

data:

begin of itab occurs 0,

budat like bkpf-budat,

hkont like bseg-hkont,

belnr like bseg-belnr,

dmbtr like bseg-dmbtr,

shkzg like bseg-shkzg,

end of itab.

DATA: DMBTR_C LIKE bseg-DMBTR,

DMBTR_D LIKE bseg-DMBTR,

SWTCH TYPE C.

ranges: rangebelnr for bkpf-belnr.

SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE text-001.

PARAMETERS: bukrs LIKE bseg-bukrs OBLIGATORY.

SELECT-OPTIONS: p_hkont FOR bseg-hkont OBLIGATORY.

SELECT-OPTIONS: p_blart FOR bkpf-blart OBLIGATORY.

SELECT-OPTIONS: p_budat FOR bkpf-budat OBLIGATORY.

SELECTION-SCREEN END OF BLOCK a.

start-of-selection.

perform getdata.

perform processdata.

perform writedata.

PERFORM GRAND-TOTAL.

*&---------------------------------------------------------------------*

*& Form getdata

*&---------------------------------------------------------------------*

form getdata.

data tempbelnr type c.

select * from bkpf into corresponding fields of table bkpftab

where bukrs eq bukrs

and blart in p_blart

* and hkont in p_hkont

and budat in p_budat.

loop at bkpftab.

rangebelnr-SIGN = 'I'.

rangebelnr-OPTION = 'EQ'.

rangebelnr-LOW = bkpftab-belnr.

collect rangebelnr. clear rangebelnr.

endloop.

sort rangebelnr by low ascending.

" select * from bseg into corresponding fields of table itab

" where bukrs eq BUKRS

" and hkont in p_hkont

"and belnr in rangebelnr.

endform. " getdata

*&---------------------------------------------------------------------*

*& Form processdata

*&---------------------------------------------------------------------*

form processdata.

loop at bkpftab. " where belnr eq bkpftab-belnr.

clear bsegtab.

SELECT * FROM bseg INTO CORRESPONDING FIELDS OF TABLE bsegtab

WHERE bukrs = bukrs

AND hkont in p_hkont

AND belnr = bkpftab-belnr.

* move-corresponding bkpftab to itab.

* collect itab. clear itab.

loop at bsegtab.

move-corresponding bsegtab to itab.

itab-budat = bkpftab-budat.

collect itab. clear itab.

endloop.

endloop.

endform.

" processdata

*&---------------------------------------------------------------------*

*& Form writedata

*&---------------------------------------------------------------------*

form writedata.

data a type i.

sort itab by belnr budat.

format color 1 intensified on.

write:/01(4)'Date' centered,

12(12)'Particulars ' centered,

65(10)'Ref #' centered,

80(10)'Debit' centered,

100(10)'Credit' centered.

format color off intensified off.

loop at itab.

select single * from skat where saknr eq itab-hkont.

if a eq 7.

a = 2.

format color 2 on.

else.

a = 7.

endif.

write:/01 itab-budat,

12 skat-txt50,

65 itab-belnr.

IF ITAB-SHKZG EQ 'S'.

WRITE: 80 ITAB-DMBTR.

DMBTR_D = DMBTR_D + ITAB-DMBTR.

ELSE.

WRITE: 100 ITAB-DMBTR.

DMBTR_C = DMBTR_C + ITAB-DMBTR.

ENDIF.

format color off.

ENDLOOP.

endform.

"writedata

*--------------------------------------------------------------------*

*& Form GRAND-TOTAL

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* --> p1 text

* <-- p2 text

*----------------------------------------------------------------------*

FORM GRAND-TOTAL.

RESERVE 6 LINES.

SWTCH = 'N'.

WRITE AT /01(116) SY-ULINE.

WRITE:/01 'Grand Total:',

80 DMBTR_D,

100 DMBTR_C.

WRITE:/80 '====================================='.

SKIP 2.

ENDFORM. " GRAND-TOTAL