Application Development and Automation 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: 
Read only

Classical report

Former Member
0 Likes
868

Hi All,

I am trying to learn Reports, so can you please give me a simple classical report example which is easy to understand and follow.

Thanks,

Rajeev Gupta

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
796

check this... cut & paste and run..

REPORT ztest00 NO STANDARD PAGE HEADING.

TABLES : eban, makt.

DATA : BEGIN OF itab OCCURS 0,

matnr LIKE eban-matnr, "Material

maktx LIKE makt-maktx, "Material description

menge LIKE eban-menge, "Quantity

END OF itab.

SELECT-OPTIONS : s_matnr FOR eban-matnr.

PARAMETERS : no_rec TYPE i.

PARAMETERS : dis_tot RADIOBUTTON GROUP g,

dis_mat RADIOBUTTON GROUP g.

parameters : only_tot as checkbox.

PERFORM get_material.

IF dis_mat EQ 'X'.

PERFORM display_material.

ELSEIF dis_tot EQ 'X'.

PERFORM display_totals.

ENDIF.

&----


*& Form get_material

&----


FORM get_material.

SELECT ebanmatnr ebanmenge makt~maktx INTO CORRESPONDING FIELDS OF

itab FROM eban INNER JOIN makt ON ebanmatnr EQ maktmatnr

WHERE eban~matnr IN s_matnr.

IF sy-dbcnt EQ no_rec.

EXIT.

ENDIF.

APPEND itab.

ENDSELECT.

ENDFORM. "get_material

&----


*& Form display_material

&----


FORM display_material.

PERFORM write_header.

LOOP AT itab.

WRITE :/1 sy-vline,

(20) itab-matnr ,

21 sy-vline,

(20) itab-maktx ,

62 sy-vline,

(13) itab-menge DECIMALS 0 ,

76 sy-vline.

ENDLOOP.

ULINE /(76).

ENDFORM. "display_material

&----


*& Form display_totals

&----


FORM display_totals.

DATA : total LIKE eban-menge.

PERFORM write_header.

LOOP AT itab.

AT NEW matnr.

IF sy-tabix NE 1.

ULINE /(76).

WRITE :/1 sy-vline,

(20) 'Total ' COLOR 3, itab-matnr COLOR 3,

62 sy-vline,

(13) total DECIMALS 0 COLOR 3,

76 sy-vline.

CLEAR total.

ULINE /(76).

ENDIF.

ENDAT.

IF only_tot NE 'X'.

WRITE :/1 sy-vline,

(20) itab-matnr ,

21 sy-vline,

(20) itab-maktx ,

62 sy-vline,

(13) itab-menge DECIMALS 0 ,

76 sy-vline.

ENDIF.

total = total + itab-menge.

ENDLOOP.

ULINE /(76).

WRITE :/1 sy-vline,

(20) 'Total ' COLOR 3, itab-matnr COLOR 3,

62 sy-vline,

(13) total DECIMALS 0 COLOR 3,

76 sy-vline.

CLEAR total.

ULINE /(76).

ENDFORM. "display_totals

&----


*& Form write_header

&----


FORM write_header.

ULINE /(76).

FORMAT COLOR 4 INTENSIFIED ON.

WRITE :/1 sy-vline,

(20) 'Material' CENTERED ,

21 sy-vline,

(20) 'Material Description' CENTERED,

62 sy-vline,

(13) 'Quantity' CENTERED,

76 sy-vline.

ULINE /(76).

FORMAT COLOR OFF.

ENDFORM. "write_header

5 REPLIES 5
Read only

Former Member
0 Likes
797

check this... cut & paste and run..

REPORT ztest00 NO STANDARD PAGE HEADING.

TABLES : eban, makt.

DATA : BEGIN OF itab OCCURS 0,

matnr LIKE eban-matnr, "Material

maktx LIKE makt-maktx, "Material description

menge LIKE eban-menge, "Quantity

END OF itab.

SELECT-OPTIONS : s_matnr FOR eban-matnr.

PARAMETERS : no_rec TYPE i.

PARAMETERS : dis_tot RADIOBUTTON GROUP g,

dis_mat RADIOBUTTON GROUP g.

parameters : only_tot as checkbox.

PERFORM get_material.

IF dis_mat EQ 'X'.

PERFORM display_material.

ELSEIF dis_tot EQ 'X'.

PERFORM display_totals.

ENDIF.

&----


*& Form get_material

&----


FORM get_material.

SELECT ebanmatnr ebanmenge makt~maktx INTO CORRESPONDING FIELDS OF

itab FROM eban INNER JOIN makt ON ebanmatnr EQ maktmatnr

WHERE eban~matnr IN s_matnr.

IF sy-dbcnt EQ no_rec.

EXIT.

ENDIF.

APPEND itab.

ENDSELECT.

ENDFORM. "get_material

&----


*& Form display_material

&----


FORM display_material.

PERFORM write_header.

LOOP AT itab.

WRITE :/1 sy-vline,

(20) itab-matnr ,

21 sy-vline,

(20) itab-maktx ,

62 sy-vline,

(13) itab-menge DECIMALS 0 ,

76 sy-vline.

ENDLOOP.

ULINE /(76).

ENDFORM. "display_material

&----


*& Form display_totals

&----


FORM display_totals.

DATA : total LIKE eban-menge.

PERFORM write_header.

LOOP AT itab.

AT NEW matnr.

IF sy-tabix NE 1.

ULINE /(76).

WRITE :/1 sy-vline,

(20) 'Total ' COLOR 3, itab-matnr COLOR 3,

62 sy-vline,

(13) total DECIMALS 0 COLOR 3,

76 sy-vline.

CLEAR total.

ULINE /(76).

ENDIF.

ENDAT.

IF only_tot NE 'X'.

WRITE :/1 sy-vline,

(20) itab-matnr ,

21 sy-vline,

(20) itab-maktx ,

62 sy-vline,

(13) itab-menge DECIMALS 0 ,

76 sy-vline.

ENDIF.

total = total + itab-menge.

ENDLOOP.

ULINE /(76).

WRITE :/1 sy-vline,

(20) 'Total ' COLOR 3, itab-matnr COLOR 3,

62 sy-vline,

(13) total DECIMALS 0 COLOR 3,

76 sy-vline.

CLEAR total.

ULINE /(76).

ENDFORM. "display_totals

&----


*& Form write_header

&----


FORM write_header.

ULINE /(76).

FORMAT COLOR 4 INTENSIFIED ON.

WRITE :/1 sy-vline,

(20) 'Material' CENTERED ,

21 sy-vline,

(20) 'Material Description' CENTERED,

62 sy-vline,

(13) 'Quantity' CENTERED,

76 sy-vline.

ULINE /(76).

FORMAT COLOR OFF.

ENDFORM. "write_header

Read only

Former Member
0 Likes
796

Thanks for the reply Perez, can you please tell me what exactly this report is doing??

Thanks,

Rajeev

Read only

0 Likes
796

just run this report...nothing complicated ...u'll understand very clearly...

report will display.. material number , and quantites from eban table.

material description from makt table.

and totals as well

very simple report.. have a look..

Read only

0 Likes
796

Thanks,

Will reward you with points.

Read only

Former Member
0 Likes
796

If report contains single list then we will be calling as Classical report :

Check the example one :

REPORT ZMM_YEAR_END no standard page heading

message-id zwave .

tables : mkpf,

mseg,

mara.

data v_lines type i.

DATA: begin of t_mseg occurs 0,

budat like mkpf-budat,

mblnr like mseg-mblnr,

end of t_mseg.

data : begin of t_output occurs 0,

matnr like mseg-matnr,

mblnr like mseg-mblnr,

budat like mkpf-budat,

end of t_output.

select-options s_matnr for mara-matnr no intervals obligatory.

  • Header

top-of-page.

skip 1.

format color 5 on.

write:/2 'Material',25 'Material Doc',45 'Receipt Date'.

format color 5 off.

skip 1.

  • Main Processing

start-of-selection.

if s_matnr-low is initial.

message i000 with 'Please enter material number'.

stop.

endif.

  • Loop the selection-screen materials

loop at s_matnr.

refresh : t_mseg.

clear : t_mseg.

SELECT MAX( budat ) a~mblnr

INTO TABLE t_mseg

FROM ( mkpf AS a INNER JOIN mseg AS b

ON amblnr = bmblnr AND

amjahr = bmjahr )

WHERE matnr = s_matnr-low and

bwart = '101' AND

werks = '1000' AND

lgort = '1000'

group by a~mblnr.

if sy-subrc eq 0.

sort t_mseg by budat descending.

read table t_mseg index 1.

move: t_mseg-budat to t_output-budat,

t_mseg-mblnr to t_output-mblnr,

s_matnr-low to t_output-matnr.

append t_output.

clear t_output.

endif.

endloop.

  • Output formatting

end-of-selection.

describe table t_output lines v_lines.

if v_lines = 0.

message i000 with ' No Data found for given selection'.

else.

loop at t_output.

write:/2 t_output-matnr,25 t_output-mblnr,45 t_output-budat.

endloop.

endif.

Thanks

Seshu