Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Modified Report required

Former Member
0 Kudos
133

hi guys am new to ABAP,

i have a report which prints information of a single customer for a particular period , can anybody modify my report and give me the code for displaying information of multiple customers at a time... and info of every customer should be printed in a fresh page.... i mean printing of next customer should should start in new page... plz check the code below

&----


*& Report ZFI_STMT_OF_ACC

*&

&----


*&

*&

&----


REPORT zfi_stmt_of_acc_new NO STANDARD PAGE HEADING LINE-COUNT 60

LINE-SIZE 224.

TABLES: kna1,

bseg,

bkpf,

bsid,

bsik,

vbrk,j_1iexcdtl.

  • zfi_cu_tran.

*INTERNAL TABLES DECLARATION

DATA: BEGIN OF it_bsid1 OCCURS 0,

belnr LIKE bsid-belnr,

blart LIKE bsid-blart,

budat LIKE bsid-budat,

bldat LIKE bsid-bldat,

xblnr LIKE bsid-xblnr,

sgtxt LIKE bsid-sgtxt,

kunnr LIKE bsid-kunnr,

umskz LIKE bsid-umskz,

shkzg LIKE bsid-shkzg,

wrbtr LIKE bsid-wrbtr,

vbeln LIKE bsid-vbeln,

END OF it_bsid1.

DATA: BEGIN OF it_bsid2 OCCURS 0,

belnr LIKE bsid-belnr,

blart LIKE bsid-blart,

budat LIKE bsid-budat,

bldat LIKE bsid-bldat,

xblnr LIKE bsid-xblnr,

sgtxt LIKE bsid-sgtxt,

kunnr LIKE bsid-kunnr,

umskz LIKE bsid-umskz,

shkzg LIKE bsid-shkzg,

wrbtr LIKE bsid-wrbtr,

vbeln LIKE bsid-vbeln,

END OF it_bsid2.

DATA: it_bsid3 LIKE it_bsid1 OCCURS 0 WITH HEADER LINE.

DATA: it_bsid4 LIKE it_bsid2 OCCURS 0 WITH HEADER LINE.

DATA: BEGIN OF it_bsik1 OCCURS 0,

belnr LIKE bsik-belnr,

blart LIKE bsik-blart,

budat LIKE bsik-budat,

bldat LIKE bsik-bldat,

xblnr LIKE bsik-xblnr,

sgtxt LIKE bsik-sgtxt,

lifnr LIKE bsik-lifnr,

umskz LIKE bsik-umskz,

shkzg LIKE bsik-shkzg,

wrbtr LIKE bsik-wrbtr,

ebeln LIKE bsik-ebeln,

END OF it_bsik1.

DATA: BEGIN OF it_bsik2 OCCURS 0,

belnr LIKE bsik-belnr,

blart LIKE bsik-blart,

budat LIKE bsik-budat,

bldat LIKE bsik-bldat,

xblnr LIKE bsik-xblnr,

sgtxt LIKE bsik-sgtxt,

lifnr LIKE bsik-lifnr,

umskz LIKE bsik-umskz,

shkzg LIKE bsik-shkzg,

wrbtr LIKE bsik-wrbtr,

ebeln LIKE bsik-ebeln,

END OF it_bsik2.

DATA it_final LIKE it_bsid1 OCCURS 0 WITH HEADER LINE.

DATA: BEGIN OF it_vbrp OCCURS 0,

vbeln LIKE vbrp-vbeln,

fkdat LIKE vbrk-fkdat,

matnr LIKE vbrp-matnr,

fkimg LIKE vbrp-fkimg,

meins LIKE vbrp-meins,

END OF it_vbrp.

DATA: BEGIN OF it_output OCCURS 0,

belnr LIKE bsid-belnr,

bldat LIKE bsid-bldat,

budat LIKE bsid-budat,

vbeln LIKE bsid-vbeln,

fkdat LIKE vbrk-fkdat,

blart LIKE bsid-blart,

dwrbtr LIKE bsid-wrbtr,

cwrbtr LIKE bsid-wrbtr,

cumil TYPE p DECIMALS 2,

matnr LIKE vbrp-matnr,

fkimg LIKE vbrp-fkimg,

meins LIKE vbrp-meins,

xblnr LIKE bsid-xblnr,

sgtxt LIKE bsid-sgtxt,

END OF it_output.

DATA: v_kunnr LIKE kna1-kunnr,

v_name1 LIKE kna1-name1,

v_ort01 LIKE kna1-ort01,

v_lifnr LIKE lfa1-lifnr,

v_belnr LIKE bsid-belnr,

v_exnum LIKE j_1iexcdtl-exnum.

DATA: v_budat LIKE bkpf-budat.

DATA: v_budat1 LIKE v_budat,

v_budat2 LIKE v_budat.

DATA: v_nwrbtr TYPE p DECIMALS 2,

v_swrbtr TYPE p DECIMALS 2,

v_vwrbtr TYPE p DECIMALS 2,

v_fwrbtr TYPE p DECIMALS 2,

v_cumil TYPE p DECIMALS 2,

v_debit TYPE p DECIMALS 2,

v_credit TYPE p DECIMALS 2.

DATA: v_xwrbtr TYPE p DECIMALS 2.

DATA: v_text(75),

v_date1(10),

v_date2(10).

DATA: it_output1 LIKE it_output OCCURS 0 WITH HEADER LINE.

DATA: it_output2 LIKE it_output OCCURS 0 WITH HEADER LINE.

SELECT-OPTIONS s_budat1 FOR bkpf-budat NO-DISPLAY.

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

SELECT-OPTIONS: s_kunnr FOR kna1-kunnr NO INTERVALS NO-EXTENSION

OBLIGATORY,

s_budat FOR bkpf-budat NO-EXTENSION OBLIGATORY.

SELECTION-SCREEN END OF BLOCK customer.

SELECTION-SCREEN BEGIN OF BLOCK type WITH FRAME TITLE text-002.

PARAMETERS: x_norm LIKE itemset-xnorm AS CHECKBOX DEFAULT 'X',

x_shbv LIKE itemset-xshbv AS CHECKBOX,

x_apar LIKE itemset-xarit AS CHECKBOX.

SELECTION-SCREEN END OF BLOCK type.

MOVE s_budat-low TO v_budat.

IF s_budat-high LT '20060331'.

MESSAGE 'DATA NOT AVILABLE TO THE GIVEN DATE RANGE' TYPE 'E'.

ENDIF.

LOOP AT s_budat.

s_budat-low = '20060330'.

MODIFY s_budat.

ENDLOOP.

START-OF-SELECTION.

CLEAR: v_nwrbtr,

v_swrbtr,

v_vwrbtr,

v_fwrbtr.

SELECT SINGLE kunnr name1 ort01

FROM kna1 INTO (v_kunnr, v_name1, v_ort01)

WHERE kunnr IN s_kunnr.

SELECT SINGLE lifnr

FROM lfa1 INTO v_lifnr

WHERE kunnr IN s_kunnr.

IF x_norm EQ 'X'.

SELECT belnr blart budat bldat

xblnr sgtxt kunnr

umskz shkzg wrbtr vbeln

FROM bsid

INTO CORRESPONDING FIELDS OF TABLE it_bsid1

WHERE kunnr IN s_kunnr AND

budat IN s_budat AND

umskz EQ space.

SELECT belnr blart budat bldat

xblnr sgtxt kunnr

umskz shkzg wrbtr vbeln

FROM bsad

INTO CORRESPONDING FIELDS OF TABLE it_bsid2

WHERE kunnr IN s_kunnr AND

budat IN s_budat AND

umskz EQ space.

ENDIF.

IF x_shbv EQ 'X'.

SELECT belnr blart budat bldat

xblnr sgtxt kunnr

umskz shkzg wrbtr vbeln

FROM bsid

INTO CORRESPONDING FIELDS OF TABLE it_bsid3

WHERE kunnr IN s_kunnr AND

budat IN s_budat AND

umskz NE space AND

umskz NE 'C' AND

umskz NE 'D' AND

umskz NE 'S'.

SELECT belnr blart budat bldat

xblnr sgtxt kunnr

umskz shkzg wrbtr vbeln

FROM bsad

INTO CORRESPONDING FIELDS OF TABLE it_bsid4

WHERE kunnr IN s_kunnr AND

budat IN s_budat AND

umskz NE space AND

umskz NE 'C' AND

umskz NE 'D' AND

umskz NE 'S'.

ENDIF.

IF x_apar EQ 'X'.

SELECT belnr blart budat bldat

xblnr sgtxt lifnr

umskz shkzg wrbtr ebeln

FROM bsik

INTO CORRESPONDING FIELDS OF TABLE it_bsik1

WHERE lifnr EQ v_lifnr AND

budat IN s_budat.

SELECT belnr blart budat bldat

xblnr sgtxt lifnr

umskz shkzg wrbtr ebeln

FROM bsak

INTO CORRESPONDING FIELDS OF TABLE it_bsik2

WHERE lifnr EQ v_lifnr AND

budat IN s_budat.

ENDIF.

it_final[] = it_bsid1[].

LOOP AT it_bsid2.

MOVE: it_bsid2-belnr TO it_final-belnr,

it_bsid2-blart TO it_final-blart,

it_bsid2-budat TO it_final-budat,

it_bsid2-bldat TO it_final-bldat,

it_bsid2-xblnr TO it_final-xblnr,

it_bsid2-sgtxt TO it_final-sgtxt,

it_bsid2-kunnr TO it_final-kunnr,

it_bsid2-umskz TO it_final-umskz,

it_bsid2-shkzg TO it_final-shkzg,

it_bsid2-wrbtr TO it_final-wrbtr,

it_bsid2-vbeln TO it_final-vbeln.

APPEND it_final.

ENDLOOP.

LOOP AT it_bsid3.

MOVE: it_bsid3-belnr TO it_final-belnr,

it_bsid3-blart TO it_final-blart,

it_bsid3-budat TO it_final-budat,

it_bsid3-bldat TO it_final-bldat,

it_bsid3-xblnr TO it_final-xblnr,

it_bsid3-sgtxt TO it_final-sgtxt,

it_bsid3-kunnr TO it_final-kunnr,

it_bsid3-umskz TO it_final-umskz,

it_bsid3-shkzg TO it_final-shkzg,

it_bsid3-wrbtr TO it_final-wrbtr,

it_bsid3-vbeln TO it_final-vbeln.

APPEND it_final.

ENDLOOP.

LOOP AT it_bsid4.

MOVE: it_bsid4-belnr TO it_final-belnr,

it_bsid4-blart TO it_final-blart,

it_bsid4-budat TO it_final-budat,

it_bsid4-bldat TO it_final-bldat,

it_bsid4-xblnr TO it_final-xblnr,

it_bsid4-sgtxt TO it_final-sgtxt,

it_bsid4-kunnr TO it_final-kunnr,

it_bsid4-umskz TO it_final-umskz,

it_bsid4-shkzg TO it_final-shkzg,

it_bsid4-wrbtr TO it_final-wrbtr,

it_bsid4-vbeln TO it_final-vbeln.

APPEND it_final.

ENDLOOP.

LOOP AT it_bsik1.

MOVE: it_bsik1-belnr TO it_final-belnr,

it_bsik1-blart TO it_final-blart,

it_bsik1-budat TO it_final-budat,

it_bsik1-bldat TO it_final-bldat,

it_bsik1-xblnr TO it_final-xblnr,

it_bsik1-sgtxt TO it_final-sgtxt,

it_bsik1-lifnr TO it_final-kunnr,

it_bsik1-umskz TO it_final-umskz,

it_bsik1-shkzg TO it_final-shkzg,

it_bsik1-wrbtr TO it_final-wrbtr,

it_bsik1-ebeln TO it_final-vbeln.

APPEND it_final.

ENDLOOP.

LOOP AT it_bsik2.

MOVE: it_bsik2-belnr TO it_final-belnr,

it_bsik2-blart TO it_final-blart,

it_bsik2-budat TO it_final-budat,

it_bsik2-bldat TO it_final-bldat,

it_bsik2-xblnr TO it_final-xblnr,

it_bsik2-sgtxt TO it_final-sgtxt,

it_bsik2-lifnr TO it_final-kunnr,

it_bsik2-umskz TO it_final-umskz,

it_bsik2-shkzg TO it_final-shkzg,

it_bsik2-wrbtr TO it_final-wrbtr,

it_bsik2-ebeln TO it_final-vbeln.

APPEND it_final.

ENDLOOP.

LOOP AT it_final.

IF it_final-vbeln EQ space.

IF it_final-shkzg = 'S'.

MOVE : it_final-belnr TO it_output-belnr,

it_final-budat TO it_output-budat,

it_final-bldat TO it_output-bldat,

it_final-blart TO it_output-blart,

it_final-wrbtr TO it_output-dwrbtr,

it_final-xblnr TO it_output-xblnr,

it_final-sgtxt TO it_output-sgtxt.

ELSEIF it_final-shkzg = 'H'.

MOVE : it_final-belnr TO it_output-belnr,

it_final-budat TO it_output-budat,

it_final-bldat TO it_output-bldat,

it_final-blart TO it_output-blart,

it_final-wrbtr TO it_output-cwrbtr,

it_final-xblnr TO it_output-xblnr,

it_final-sgtxt TO it_output-sgtxt.

ENDIF.

APPEND it_output.

CLEAR it_output.

DELETE it_final.

ENDIF.

ENDLOOP.

LOOP AT it_final.

IF it_final-shkzg = 'S'.

MOVE : it_final-belnr TO it_output-belnr,

it_final-budat TO it_output-budat,

it_final-bldat TO it_output-bldat,

it_final-blart TO it_output-blart,

it_final-wrbtr TO it_output-dwrbtr,

it_final-xblnr TO it_output-xblnr,

it_final-sgtxt TO it_output-sgtxt,

it_final-vbeln TO it_output-vbeln.

ELSEIF it_final-shkzg = 'H'.

MOVE : it_final-belnr TO it_output-belnr,

it_final-budat TO it_output-budat,

it_final-bldat TO it_output-bldat,

it_final-blart TO it_output-blart,

it_final-wrbtr TO it_output-cwrbtr,

it_final-xblnr TO it_output-xblnr,

it_final-sgtxt TO it_output-sgtxt,

it_final-vbeln TO it_output-vbeln.

ENDIF.

APPEND it_output.

CLEAR it_output.

ENDLOOP.

LOOP AT it_output.

IF it_output-budat LT v_budat.

v_fwrbtr = v_fwrbtr + it_output-dwrbtr - it_output-cwrbtr.

DELETE it_output.

ENDIF.

ENDLOOP.

SORT it_output BY belnr.

LOOP AT it_output WHERE blart EQ 'R2'.

MOVE it_output TO it_output1.

APPEND it_output1.

ENDLOOP.

SORT it_output1 BY belnr.

it_output2[] = it_output1[].

DELETE ADJACENT DUPLICATES FROM it_output1 COMPARING belnr.

LOOP AT it_output.

READ TABLE it_output2 WITH KEY belnr = it_output-belnr.

IF sy-subrc EQ 0.

DELETE it_output.

ENDIF.

ENDLOOP.

LOOP AT it_output1.

READ TABLE it_output2 WITH KEY belnr = it_output1-belnr.

CLEAR v_xwrbtr.

LOOP AT it_output2 WHERE belnr EQ it_output1-belnr.

v_xwrbtr = v_xwrbtr + it_output2-dwrbtr - it_output2-cwrbtr.

ENDLOOP.

CLEAR it_output.

MOVE: it_output1-belnr TO it_output-belnr,

it_output1-budat TO it_output-budat,

it_output1-bldat TO it_output-bldat,

'R2' TO it_output-blart,

it_output1-xblnr TO it_output-xblnr.

IF v_xwrbtr LT 0.

v_xwrbtr = v_xwrbtr * -1.

MOVE: v_xwrbtr TO it_output-cwrbtr.

ELSE.

MOVE: v_xwrbtr TO it_output-dwrbtr.

ENDIF.

APPEND it_output.

ENDLOOP.

SORT it_output BY budat belnr.

IF NOT it_final[] IS INITIAL.

SELECT vbrk~vbeln vbrp~matnr vbrp~fkimg vbrp~meins vbrk~fkdat

INTO CORRESPONDING FIELDS OF TABLE it_vbrp

FROM vbrk INNER JOIN vbrp ON vbrk~vbeln EQ vbrp~vbeln

FOR ALL entries IN it_final

WHERE vbrk~vbeln = it_final-vbeln.

ENDIF.

v_cumil = v_fwrbtr.

CLEAR: v_debit,

v_credit.

LOOP AT it_output.

IF NOT it_output-vbeln EQ space.

READ TABLE it_vbrp WITH KEY vbeln = it_output-vbeln.

MOVE: it_vbrp-matnr TO it_output-matnr,

it_vbrp-fkdat TO it_output-fkdat,

it_vbrp-fkimg TO it_output-fkimg,

it_vbrp-meins TO it_output-meins.

MODIFY it_output.

ENDIF.

v_cumil = v_cumil - it_output-cwrbtr + it_output-dwrbtr.

v_debit = v_debit + it_output-dwrbtr.

v_credit = v_credit + it_output-cwrbtr.

MOVE v_cumil TO it_output-cumil.

MODIFY it_output.

ENDLOOP.

WRITE:/001 sy-vline,

002 'Opening Balace as on', v_budat CENTERED,

034 sy-vline,

045 sy-vline,

056 sy-vline,

067 sy-vline,

072 sy-vline,

093 sy-vline,

114 sy-vline,

115(20) v_fwrbtr RIGHT-JUSTIFIED,

135 sy-vline,

154 sy-vline,

172 sy-vline,

176 sy-vline,

193 sy-vline,

224 sy-vline.

LOOP AT it_output.

CLEAR v_exnum.

SELECT SINGLE * FROM j_1iexcdtl

WHERE rdoc2 = it_output-vbeln

AND matnr = it_output-matnr.

IF sy-subrc = 0.

v_exnum = j_1iexcdtl-exnum.

ENDIF.

WRITE:/001 sy-vline,

002(10) it_output-belnr,

012 sy-vline,

013(10) it_output-bldat,

023 sy-vline,

024(10) it_output-budat,

034 sy-vline,

035(10) v_exnum,

045 sy-vline,

046(10) it_output-vbeln,

056 sy-vline,

057(10) it_output-fkdat NO-ZERO,

067 sy-vline,

068(4) it_output-blart CENTERED,

072 sy-vline,

073(20) it_output-dwrbtr RIGHT-JUSTIFIED NO-ZERO,

093 sy-vline,

094(20) it_output-cwrbtr RIGHT-JUSTIFIED NO-ZERO,

114 sy-vline,

115(20) it_output-cumil RIGHT-JUSTIFIED NO-SIGN,

135 sy-vline,

136(18) it_output-matnr,

154 sy-vline,

155(17) it_output-fkimg RIGHT-JUSTIFIED NO-ZERO,

172 sy-vline,

173(3) it_output-meins CENTERED,

176 sy-vline,

177(16) it_output-xblnr CENTERED,

193 sy-vline,

194(30) it_output-sgtxt CENTERED,

224 sy-vline.

ENDLOOP.

WRITE:/001(224) sy-uline.

SKIP.

WRITE:/ 'TOTALS AS ON', s_budat-high, ':',

040(19) v_fwrbtr RIGHT-JUSTIFIED, '+',

063(19) v_debit RIGHT-JUSTIFIED, '-',

084(19) v_credit RIGHT-JUSTIFIED, '=',

105(19) v_cumil RIGHT-JUSTIFIED.

*WRITE:/ 'Closing Balance for Customer', V_KUNNR, 'as on', S_BUDAT-,

  • 091 'Rs',

  • 093(20) V_CUMIL RIGHT-JUSTIFIED.

SKIP.

WRITE:/ '** BALANCE SUBJECT TO RECONCILIATION'.

TOP-OF-PAGE.

CONCATENATE v_budat+6(2)

v_budat+4(2)

v_budat+0(4) INTO v_date1 SEPARATED BY '.'.

CONCATENATE s_budat-high+6(2)

s_budat-high+4(2)

s_budat-high+0(4) INTO v_date2 SEPARATED BY '.'.

CONCATENATE 'STATEMENT OF CUSTOMER ACCOUNT FOR THE PERIOD FROM'

v_date1

'TO'

v_date2 INTO v_text SEPARATED BY space.

WRITE:/ 'REPORT ID:ZFI_STMT_OF_ACC_NEW',100 'INDIAN RAYON' CENTERED,

170 'Page No:',sy-pagno LEFT-JUSTIFIED.

WRITE:/001(213) '( A Unit of Aditya Birla Nuvo Limited )' CENTERED,

170 'Commonly used Document Types' .

WRITE:/001(213) 'VERAVAL-362266' CENTERED,

170 'RV = Invoice, RZ = Invoice Reversal'.

WRITE:/170 'R2 = Money Receipt, CN = Credit Note'.

WRITE:/001(213) v_text CENTERED,

170 'DN = Debit Note, HP = Payment Voucher-R'.

WRITE:/001 'PARTY CODE :',

020 v_kunnr,

170 'HR = Receipt Voucher-R, CP = Payment Voucher-C'.

WRITE:/001 'NAME OF PARTY:',

020 v_name1,170 'CR = Receipt Voucher-C, JV = Journal Voucher'.

WRITE:/001 'CITY :',

020 v_ort01,170 'AB = Clearing Document'.

WRITE:/001 sy-vline,

002(222) sy-uline,

224 sy-vline.

WRITE:/001 sy-vline,

002(10) 'Doc No.' CENTERED,

012 sy-vline,

013(10) 'Doc Dt.' CENTERED,

023 sy-vline,

024(10) 'Post Dt.' CENTERED,

034 sy-vline,

035(10) 'Excise No' CENTERED,

045 sy-vline,

046(10) 'Bill Doc.' CENTERED,

056 sy-vline,

057(10) 'Bill Dt.' CENTERED,

067 sy-vline,

068(4) 'VR' CENTERED,

072 sy-vline,

073(20) 'Debit' CENTERED,

093 sy-vline,

094(20) 'Credit' CENTERED,

114 sy-vline,

115(20) 'Cumulative' CENTERED,

135 sy-vline,

136(18) 'Material Code' CENTERED,

154 sy-vline,

155(17) 'Quantity' CENTERED,

172 sy-vline,

173(3) 'UOM',

176 sy-vline,

177(16) 'Reference' CENTERED,

193 sy-vline,

194(30) 'Narration' CENTERED,

224 sy-vline.

WRITE:/001 sy-vline,

012 sy-vline,

023 sy-vline,

034 sy-vline,

045 sy-vline,

056 sy-vline,

067 sy-vline,

068(4) 'Type' CENTERED,

072 sy-vline,

093 sy-vline,

114 sy-vline,

115(20) 'Balance' CENTERED,

135 sy-vline,

154 sy-vline,

172 sy-vline,

176 sy-vline,

193 sy-vline,

224 sy-vline.

WRITE:/001 sy-vline,

002(222) sy-uline,

224 sy-vline.

10 reward points will be given for solution.

regards,

naveen

4 REPLIES 4

Former Member
0 Kudos
83

Hi

Just change the declaration of Customer on selection-screen as follows

<b>SELECT-OPTIONS: s_kunnr FOR kna1-kunnr OBLIGATORY,</b>

it will accept multiple customers and works good

Reward points if useful

Regards

Anji

Former Member
0 Kudos
83

Hi,

Copy this.

&----


*& Report ZTEST

*&

&----


*&

*&

&----


&----


*& Report ZFI_STMT_OF_ACC

*&

&----


*&

*&

&----


REPORT ZTABLE_DOWNLOAD NO STANDARD PAGE HEADING LINE-COUNT 60

LINE-SIZE 224.

TABLES: kna1,

bseg,

bkpf,

bsid,

bsik,

vbrk,j_1iexcdtl.

  • zfi_cu_tran.

*INTERNAL TABLES DECLARATION

DATA: BEGIN OF it_bsid1 OCCURS 0,

belnr LIKE bsid-belnr,

blart LIKE bsid-blart,

budat LIKE bsid-budat,

bldat LIKE bsid-bldat,

xblnr LIKE bsid-xblnr,

sgtxt LIKE bsid-sgtxt,

kunnr LIKE bsid-kunnr,

umskz LIKE bsid-umskz,

shkzg LIKE bsid-shkzg,

wrbtr LIKE bsid-wrbtr,

vbeln LIKE bsid-vbeln,

END OF it_bsid1.

DATA: BEGIN OF it_bsid2 OCCURS 0,

belnr LIKE bsid-belnr,

blart LIKE bsid-blart,

budat LIKE bsid-budat,

bldat LIKE bsid-bldat,

xblnr LIKE bsid-xblnr,

sgtxt LIKE bsid-sgtxt,

kunnr LIKE bsid-kunnr,

umskz LIKE bsid-umskz,

shkzg LIKE bsid-shkzg,

wrbtr LIKE bsid-wrbtr,

vbeln LIKE bsid-vbeln,

END OF it_bsid2.

DATA: it_bsid3 LIKE it_bsid1 OCCURS 0 WITH HEADER LINE.

DATA: it_bsid4 LIKE it_bsid2 OCCURS 0 WITH HEADER LINE.

DATA: BEGIN OF it_bsik1 OCCURS 0,

belnr LIKE bsik-belnr,

blart LIKE bsik-blart,

budat LIKE bsik-budat,

bldat LIKE bsik-bldat,

xblnr LIKE bsik-xblnr,

sgtxt LIKE bsik-sgtxt,

lifnr LIKE bsik-lifnr,

umskz LIKE bsik-umskz,

shkzg LIKE bsik-shkzg,

wrbtr LIKE bsik-wrbtr,

ebeln LIKE bsik-ebeln,

END OF it_bsik1.

DATA: BEGIN OF it_bsik2 OCCURS 0,

belnr LIKE bsik-belnr,

blart LIKE bsik-blart,

budat LIKE bsik-budat,

bldat LIKE bsik-bldat,

xblnr LIKE bsik-xblnr,

sgtxt LIKE bsik-sgtxt,

lifnr LIKE bsik-lifnr,

umskz LIKE bsik-umskz,

shkzg LIKE bsik-shkzg,

wrbtr LIKE bsik-wrbtr,

ebeln LIKE bsik-ebeln,

END OF it_bsik2.

DATA it_final LIKE it_bsid1 OCCURS 0 WITH HEADER LINE.

DATA: BEGIN OF it_vbrp OCCURS 0,

vbeln LIKE vbrp-vbeln,

fkdat LIKE vbrk-fkdat,

matnr LIKE vbrp-matnr,

fkimg LIKE vbrp-fkimg,

meins LIKE vbrp-meins,

END OF it_vbrp.

DATA: BEGIN OF it_output OCCURS 0,

belnr LIKE bsid-belnr,

bldat LIKE bsid-bldat,

budat LIKE bsid-budat,

vbeln LIKE bsid-vbeln,

fkdat LIKE vbrk-fkdat,

blart LIKE bsid-blart,

dwrbtr LIKE bsid-wrbtr,

cwrbtr LIKE bsid-wrbtr,

cumil TYPE p DECIMALS 2,

matnr LIKE vbrp-matnr,

fkimg LIKE vbrp-fkimg,

meins LIKE vbrp-meins,

xblnr LIKE bsid-xblnr,

sgtxt LIKE bsid-sgtxt,

END OF it_output.

DATA: v_kunnr LIKE kna1-kunnr,

v_name1 LIKE kna1-name1,

v_ort01 LIKE kna1-ort01,

v_lifnr LIKE lfa1-lifnr,

v_belnr LIKE bsid-belnr,

v_exnum LIKE j_1iexcdtl-exnum.

DATA: v_budat LIKE bkpf-budat.

DATA: v_budat1 LIKE v_budat,

v_budat2 LIKE v_budat.

DATA: v_nwrbtr TYPE p DECIMALS 2,

v_swrbtr TYPE p DECIMALS 2,

v_vwrbtr TYPE p DECIMALS 2,

v_fwrbtr TYPE p DECIMALS 2,

v_cumil TYPE p DECIMALS 2,

v_debit TYPE p DECIMALS 2,

v_credit TYPE p DECIMALS 2.

DATA: v_xwrbtr TYPE p DECIMALS 2.

DATA: v_text(75),

v_date1(10),

v_date2(10).

DATA: it_output1 LIKE it_output OCCURS 0 WITH HEADER LINE.

DATA: it_output2 LIKE it_output OCCURS 0 WITH HEADER LINE.

SELECT-OPTIONS s_budat1 FOR bkpf-budat NO-DISPLAY.

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

SELECT-OPTIONS: s_kunnr FOR kna1-kunnr OBLIGATORY,

s_budat FOR bkpf-budat NO-EXTENSION OBLIGATORY.

SELECTION-SCREEN END OF BLOCK customer.

SELECTION-SCREEN BEGIN OF BLOCK type WITH FRAME TITLE text-002.

PARAMETERS: x_norm LIKE itemset-xnorm AS CHECKBOX DEFAULT 'X',

x_shbv LIKE itemset-xshbv AS CHECKBOX,

x_apar LIKE itemset-xarit AS CHECKBOX.

SELECTION-SCREEN END OF BLOCK type.

MOVE s_budat-low TO v_budat.

IF s_budat-high LT '20060331'.

MESSAGE 'DATA NOT AVILABLE TO THE GIVEN DATE RANGE' TYPE 'E'.

ENDIF.

LOOP AT s_budat.

s_budat-low = '20060330'.

MODIFY s_budat.

ENDLOOP.

START-OF-SELECTION.

CLEAR: v_nwrbtr,

v_swrbtr,

v_vwrbtr,

v_fwrbtr.

SELECT SINGLE kunnr name1 ort01

FROM kna1 INTO (v_kunnr, v_name1, v_ort01)

WHERE kunnr IN s_kunnr.

SELECT SINGLE lifnr

FROM lfa1 INTO v_lifnr

WHERE kunnr IN s_kunnr.

IF x_norm EQ 'X'.

SELECT belnr blart budat bldat

xblnr sgtxt kunnr

umskz shkzg wrbtr vbeln

FROM bsid

INTO CORRESPONDING FIELDS OF TABLE it_bsid1

WHERE kunnr IN s_kunnr AND

budat IN s_budat AND

umskz EQ space.

SELECT belnr blart budat bldat

xblnr sgtxt kunnr

umskz shkzg wrbtr vbeln

FROM bsad

INTO CORRESPONDING FIELDS OF TABLE it_bsid2

WHERE kunnr IN s_kunnr AND

budat IN s_budat AND

umskz EQ space.

ENDIF.

IF x_shbv EQ 'X'.

SELECT belnr blart budat bldat

xblnr sgtxt kunnr

umskz shkzg wrbtr vbeln

FROM bsid

INTO CORRESPONDING FIELDS OF TABLE it_bsid3

WHERE kunnr IN s_kunnr AND

budat IN s_budat AND

umskz NE space AND

umskz NE 'C' AND

umskz NE 'D' AND

umskz NE 'S'.

SELECT belnr blart budat bldat

xblnr sgtxt kunnr

umskz shkzg wrbtr vbeln

FROM bsad

INTO CORRESPONDING FIELDS OF TABLE it_bsid4

WHERE kunnr IN s_kunnr AND

budat IN s_budat AND

umskz NE space AND

umskz NE 'C' AND

umskz NE 'D' AND

umskz NE 'S'.

ENDIF.

IF x_apar EQ 'X'.

SELECT belnr blart budat bldat

xblnr sgtxt lifnr

umskz shkzg wrbtr ebeln

FROM bsik

INTO CORRESPONDING FIELDS OF TABLE it_bsik1

WHERE lifnr EQ v_lifnr AND

budat IN s_budat.

SELECT belnr blart budat bldat

xblnr sgtxt lifnr

umskz shkzg wrbtr ebeln

FROM bsak

INTO CORRESPONDING FIELDS OF TABLE it_bsik2

WHERE lifnr EQ v_lifnr AND

budat IN s_budat.

ENDIF.

it_final[] = it_bsid1[].

LOOP AT it_bsid2.

MOVE: it_bsid2-belnr TO it_final-belnr,

it_bsid2-blart TO it_final-blart,

it_bsid2-budat TO it_final-budat,

it_bsid2-bldat TO it_final-bldat,

it_bsid2-xblnr TO it_final-xblnr,

it_bsid2-sgtxt TO it_final-sgtxt,

it_bsid2-kunnr TO it_final-kunnr,

it_bsid2-umskz TO it_final-umskz,

it_bsid2-shkzg TO it_final-shkzg,

it_bsid2-wrbtr TO it_final-wrbtr,

it_bsid2-vbeln TO it_final-vbeln.

APPEND it_final.

ENDLOOP.

LOOP AT it_bsid3.

MOVE: it_bsid3-belnr TO it_final-belnr,

it_bsid3-blart TO it_final-blart,

it_bsid3-budat TO it_final-budat,

it_bsid3-bldat TO it_final-bldat,

it_bsid3-xblnr TO it_final-xblnr,

it_bsid3-sgtxt TO it_final-sgtxt,

it_bsid3-kunnr TO it_final-kunnr,

it_bsid3-umskz TO it_final-umskz,

it_bsid3-shkzg TO it_final-shkzg,

it_bsid3-wrbtr TO it_final-wrbtr,

it_bsid3-vbeln TO it_final-vbeln.

APPEND it_final.

ENDLOOP.

LOOP AT it_bsid4.

MOVE: it_bsid4-belnr TO it_final-belnr,

it_bsid4-blart TO it_final-blart,

it_bsid4-budat TO it_final-budat,

it_bsid4-bldat TO it_final-bldat,

it_bsid4-xblnr TO it_final-xblnr,

it_bsid4-sgtxt TO it_final-sgtxt,

it_bsid4-kunnr TO it_final-kunnr,

it_bsid4-umskz TO it_final-umskz,

it_bsid4-shkzg TO it_final-shkzg,

it_bsid4-wrbtr TO it_final-wrbtr,

it_bsid4-vbeln TO it_final-vbeln.

APPEND it_final.

ENDLOOP.

LOOP AT it_bsik1.

MOVE: it_bsik1-belnr TO it_final-belnr,

it_bsik1-blart TO it_final-blart,

it_bsik1-budat TO it_final-budat,

it_bsik1-bldat TO it_final-bldat,

it_bsik1-xblnr TO it_final-xblnr,

it_bsik1-sgtxt TO it_final-sgtxt,

it_bsik1-lifnr TO it_final-kunnr,

it_bsik1-umskz TO it_final-umskz,

it_bsik1-shkzg TO it_final-shkzg,

it_bsik1-wrbtr TO it_final-wrbtr,

it_bsik1-ebeln TO it_final-vbeln.

APPEND it_final.

ENDLOOP.

LOOP AT it_bsik2.

MOVE: it_bsik2-belnr TO it_final-belnr,

it_bsik2-blart TO it_final-blart,

it_bsik2-budat TO it_final-budat,

it_bsik2-bldat TO it_final-bldat,

it_bsik2-xblnr TO it_final-xblnr,

it_bsik2-sgtxt TO it_final-sgtxt,

it_bsik2-lifnr TO it_final-kunnr,

it_bsik2-umskz TO it_final-umskz,

it_bsik2-shkzg TO it_final-shkzg,

it_bsik2-wrbtr TO it_final-wrbtr,

it_bsik2-ebeln TO it_final-vbeln.

APPEND it_final.

ENDLOOP.

LOOP AT it_final.

IF it_final-vbeln EQ space.

IF it_final-shkzg = 'S'.

MOVE : it_final-belnr TO it_output-belnr,

it_final-budat TO it_output-budat,

it_final-bldat TO it_output-bldat,

it_final-blart TO it_output-blart,

it_final-wrbtr TO it_output-dwrbtr,

it_final-xblnr TO it_output-xblnr,

it_final-sgtxt TO it_output-sgtxt.

ELSEIF it_final-shkzg = 'H'.

MOVE : it_final-belnr TO it_output-belnr,

it_final-budat TO it_output-budat,

it_final-bldat TO it_output-bldat,

it_final-blart TO it_output-blart,

it_final-wrbtr TO it_output-cwrbtr,

it_final-xblnr TO it_output-xblnr,

it_final-sgtxt TO it_output-sgtxt.

ENDIF.

APPEND it_output.

CLEAR it_output.

DELETE it_final.

ENDIF.

ENDLOOP.

LOOP AT it_final.

IF it_final-shkzg = 'S'.

MOVE : it_final-belnr TO it_output-belnr,

it_final-budat TO it_output-budat,

it_final-bldat TO it_output-bldat,

it_final-blart TO it_output-blart,

it_final-wrbtr TO it_output-dwrbtr,

it_final-xblnr TO it_output-xblnr,

it_final-sgtxt TO it_output-sgtxt,

it_final-vbeln TO it_output-vbeln.

ELSEIF it_final-shkzg = 'H'.

MOVE : it_final-belnr TO it_output-belnr,

it_final-budat TO it_output-budat,

it_final-bldat TO it_output-bldat,

it_final-blart TO it_output-blart,

it_final-wrbtr TO it_output-cwrbtr,

it_final-xblnr TO it_output-xblnr,

it_final-sgtxt TO it_output-sgtxt,

it_final-vbeln TO it_output-vbeln.

ENDIF.

APPEND it_output.

CLEAR it_output.

ENDLOOP.

LOOP AT it_output.

IF it_output-budat LT v_budat.

v_fwrbtr = v_fwrbtr + it_output-dwrbtr - it_output-cwrbtr.

DELETE it_output.

ENDIF.

ENDLOOP.

SORT it_output BY belnr.

LOOP AT it_output WHERE blart EQ 'R2'.

MOVE it_output TO it_output1.

APPEND it_output1.

ENDLOOP.

SORT it_output1 BY belnr.

it_output2[] = it_output1[].

DELETE ADJACENT DUPLICATES FROM it_output1 COMPARING belnr.

LOOP AT it_output.

READ TABLE it_output2 WITH KEY belnr = it_output-belnr.

IF sy-subrc EQ 0.

DELETE it_output.

ENDIF.

ENDLOOP.

LOOP AT it_output1.

READ TABLE it_output2 WITH KEY belnr = it_output1-belnr.

CLEAR v_xwrbtr.

LOOP AT it_output2 WHERE belnr EQ it_output1-belnr.

v_xwrbtr = v_xwrbtr + it_output2-dwrbtr - it_output2-cwrbtr.

ENDLOOP.

CLEAR it_output.

MOVE: it_output1-belnr TO it_output-belnr,

it_output1-budat TO it_output-budat,

it_output1-bldat TO it_output-bldat,

'R2' TO it_output-blart,

it_output1-xblnr TO it_output-xblnr.

IF v_xwrbtr LT 0.

v_xwrbtr = v_xwrbtr * -1.

MOVE: v_xwrbtr TO it_output-cwrbtr.

ELSE.

MOVE: v_xwrbtr TO it_output-dwrbtr.

ENDIF.

APPEND it_output.

ENDLOOP.

SORT it_output BY budat belnr.

IF NOT it_final[] IS INITIAL.

SELECT vbrk~vbeln vbrp~matnr vbrp~fkimg vbrp~meins vbrk~fkdat

INTO CORRESPONDING FIELDS OF TABLE it_vbrp

FROM vbrk INNER JOIN vbrp ON vbrk~vbeln EQ vbrp~vbeln

FOR ALL entries IN it_final

WHERE vbrk~vbeln = it_final-vbeln.

ENDIF.

v_cumil = v_fwrbtr.

CLEAR: v_debit,

v_credit.

LOOP AT it_output.

IF NOT it_output-vbeln EQ space.

READ TABLE it_vbrp WITH KEY vbeln = it_output-vbeln.

MOVE: it_vbrp-matnr TO it_output-matnr,

it_vbrp-fkdat TO it_output-fkdat,

it_vbrp-fkimg TO it_output-fkimg,

it_vbrp-meins TO it_output-meins.

MODIFY it_output.

ENDIF.

v_cumil = v_cumil - it_output-cwrbtr + it_output-dwrbtr.

v_debit = v_debit + it_output-dwrbtr.

v_credit = v_credit + it_output-cwrbtr.

MOVE v_cumil TO it_output-cumil.

MODIFY it_output.

ENDLOOP.

WRITE:/001 sy-vline,

002 'Opening Balace as on', v_budat CENTERED,

034 sy-vline,

045 sy-vline,

056 sy-vline,

067 sy-vline,

072 sy-vline,

093 sy-vline,

114 sy-vline,

115(20) v_fwrbtr RIGHT-JUSTIFIED,

135 sy-vline,

154 sy-vline,

172 sy-vline,

176 sy-vline,

193 sy-vline,

224 sy-vline.

LOOP AT it_output.

CLEAR v_exnum.

SELECT SINGLE * FROM j_1iexcdtl

WHERE rdoc2 = it_output-vbeln

AND matnr = it_output-matnr.

IF sy-subrc = 0.

v_exnum = j_1iexcdtl-exnum.

ENDIF.

WRITE:/001 sy-vline,

002(10) it_output-belnr,

012 sy-vline,

013(10) it_output-bldat,

023 sy-vline,

024(10) it_output-budat,

034 sy-vline,

035(10) v_exnum,

045 sy-vline,

046(10) it_output-vbeln,

056 sy-vline,

057(10) it_output-fkdat NO-ZERO,

067 sy-vline,

068(4) it_output-blart CENTERED,

072 sy-vline,

073(20) it_output-dwrbtr RIGHT-JUSTIFIED NO-ZERO,

093 sy-vline,

094(20) it_output-cwrbtr RIGHT-JUSTIFIED NO-ZERO,

114 sy-vline,

115(20) it_output-cumil RIGHT-JUSTIFIED NO-SIGN,

135 sy-vline,

136(18) it_output-matnr,

154 sy-vline,

155(17) it_output-fkimg RIGHT-JUSTIFIED NO-ZERO,

172 sy-vline,

173(3) it_output-meins CENTERED,

176 sy-vline,

177(16) it_output-xblnr CENTERED,

193 sy-vline,

194(30) it_output-sgtxt CENTERED,

224 sy-vline.

ENDLOOP.

WRITE:/001(224) sy-uline.

SKIP.

WRITE:/ 'TOTALS AS ON', s_budat-high, ':',

040(19) v_fwrbtr RIGHT-JUSTIFIED, '+',

063(19) v_debit RIGHT-JUSTIFIED, '-',

084(19) v_credit RIGHT-JUSTIFIED, '=',

105(19) v_cumil RIGHT-JUSTIFIED.

*WRITE:/ 'Closing Balance for Customer', V_KUNNR, 'as on', S_BUDAT-,

  • 091 'Rs',

  • 093(20) V_CUMIL RIGHT-JUSTIFIED.

SKIP.

WRITE:/ '** BALANCE SUBJECT TO RECONCILIATION'.

TOP-OF-PAGE.

CONCATENATE v_budat+6(2)

v_budat+4(2)

v_budat+0(4) INTO v_date1 SEPARATED BY '.'.

CONCATENATE s_budat-high+6(2)

s_budat-high+4(2)

s_budat-high+0(4) INTO v_date2 SEPARATED BY '.'.

CONCATENATE 'STATEMENT OF CUSTOMER ACCOUNT FOR THE PERIOD FROM'

v_date1

'TO'

v_date2 INTO v_text SEPARATED BY space.

WRITE:/ 'REPORT ID:ZFI_STMT_OF_ACC_NEW',100 'INDIAN RAYON' CENTERED,

170 'Page No:',sy-pagno LEFT-JUSTIFIED.

WRITE:/001(213) '( A Unit of Aditya Birla Nuvo Limited )' CENTERED,

170 'Commonly used Document Types' .

WRITE:/001(213) 'VERAVAL-362266' CENTERED,

170 'RV = Invoice, RZ = Invoice Reversal'.

WRITE:/170 'R2 = Money Receipt, CN = Credit Note'.

WRITE:/001(213) v_text CENTERED,

170 'DN = Debit Note, HP = Payment Voucher-R'.

WRITE:/001 'PARTY CODE :',

020 v_kunnr,

170 'HR = Receipt Voucher-R, CP = Payment Voucher-C'.

WRITE:/001 'NAME OF PARTY:',

020 v_name1,170 'CR = Receipt Voucher-C, JV = Journal Voucher'.

WRITE:/001 'CITY :',

020 v_ort01,170 'AB = Clearing Document'.

WRITE:/001 sy-vline,

002(222) sy-uline,

224 sy-vline.

WRITE:/001 sy-vline,

002(10) 'Doc No.' CENTERED,

012 sy-vline,

013(10) 'Doc Dt.' CENTERED,

023 sy-vline,

024(10) 'Post Dt.' CENTERED,

034 sy-vline,

035(10) 'Excise No' CENTERED,

045 sy-vline,

046(10) 'Bill Doc.' CENTERED,

056 sy-vline,

057(10) 'Bill Dt.' CENTERED,

067 sy-vline,

068(4) 'VR' CENTERED,

072 sy-vline,

073(20) 'Debit' CENTERED,

093 sy-vline,

094(20) 'Credit' CENTERED,

114 sy-vline,

115(20) 'Cumulative' CENTERED,

135 sy-vline,

136(18) 'Material Code' CENTERED,

154 sy-vline,

155(17) 'Quantity' CENTERED,

172 sy-vline,

173(3) 'UOM',

176 sy-vline,

177(16) 'Reference' CENTERED,

193 sy-vline,

194(30) 'Narration' CENTERED,

224 sy-vline.

WRITE:/001 sy-vline,

012 sy-vline,

023 sy-vline,

034 sy-vline,

045 sy-vline,

056 sy-vline,

067 sy-vline,

068(4) 'Type' CENTERED,

072 sy-vline,

093 sy-vline,

114 sy-vline,

115(20) 'Balance' CENTERED,

135 sy-vline,

154 sy-vline,

172 sy-vline,

176 sy-vline,

193 sy-vline,

224 sy-vline.

WRITE:/001 sy-vline,

002(222) sy-uline,

224 sy-vline.

Thanks,

Anitha

0 Kudos
83

Anitha Hi,

i have already tried it and the information is getting displayed... thing is the information of second customer should be displayed from new page and the cumulative balance of each and every customer should be displayed aftre the data is printed and page heading should be printed for each and every page before data is printed.... can you plz help me out... i have to submit it tommorow....

you can mail me to tiramdasu@gmail.com...

do not worry about rewards,

regards,

naveen kumar T

Former Member
0 Kudos
83

hi

use <b>On change of</b> statement or <b>at new</b> statement

Consider the following simple code-snippet which will solve your problem very efficiently.

========================================

data t_mara type table of mara.

field-symbols: <fs_mara> type mara.

select * from mara into table t_mara.

sort t_mara by matnr.

loop at t_mara assigning <fs_mara>.

at new matnr.

write: / <fs_mara>-matnr,

<fs_mara>-mtart,

<fs_mara>-matkl.

endat.

endloop.

========================================

Normally, you will not be able to use the fields MTART and MATKL within the AT NEW....ENDAT block. But as you can see here, if you use field-symbols, there's no problem at all. Moreover, though most people have some resistance to using field-symbols, it offers the best performance and the highest degree of flexibility.

Hope this solution can be satisfactorily applied in your case.

Regards,

regards

ravish

<b>plz dont forget to reward points if helpful</b>