Académique Documents
Professionnel Documents
Culture Documents
1. Report Listing
AT AT AT AT
FIRST NEW <Control Break field> END OF <Control Break field> LAST
ENDAT
SUM
Program Structure
LOOP AT tab. *Print Header AT FIRST. ENDAT. *Print Control Break Field AT NEW name. ENDAT. *Print Normal Data WRITE: / *Sub Total AT END OF name. ENDAT. *Report Total AT LAST. ENDAT. ENDLOOP.
tab
name
qty
Example I
sales
name qty
A
A A B B
10
20 30 5 10
Example I
LOOP AT SALES. *Print Header AT FIRST. FORMAT COLOR 1. WRITE: / 'Name', 23 'Qty', 35 ' '. ULINE: /(35). FORMAT COLOR OFF. ENDAT. *Print Control Break Field AT NEW NAME. WRITE: / SALES-NAME. ULINE: /(5). ENDAT. *Print Normal Data WRITE: /15 SALES-QTY.
Example I
*Print Total for each group data AT END OF NAME. ULINE: /(35). SUM. WRITE: /5 'Total' ,15 SALES-QTY COLOR 3. ENDAT. *Print Grand Total for the report AT LAST. ULINE: /(35). SUM. WRITE: /2 'Grand Total', 15 SALES-QTY COLOR 7. ULINE: /(35). ENDAT. ENDLOOP.
Example II
sales
name qty
A A A B B
10 20 30 5 10
Example II
LOOP AT SALES. AT FIRST. FORMAT COLOR 1. WRITE: / 'Name', 23 'Qty', 35 ' '. ULINE: /(35). FORMAT COLOR OFF. ENDAT. AT END OF NAME. SUM. WRITE: / SALES-NAME, 15 SALES-QTY. ULINE: /(35). ENDAT. AT LAST. SUM. WRITE: /5 'Total', 15 SALES-QTY. ULINE: /(35). ENDAT. ENDLOOP.
Exercise I
ZSALES
cust_id 1 prod_id A1 sale_date 20020318 qty 10
1
1 1 1 3
A1
A1 A2 A2 X1
20020319
20020329 20020318 20020329 20020321
100
50 50 200 90
Exercise I
ID
1 Product ID Quantity A1 10 A1 100 A1 50 A2 50 A2 200 -----------------------------Total 410 X1 90 -----------------------------Total 90 -----------------------------Grand Total 500 ----------------------------------
LH LH SQ
NY BK SQ
BK NY BK
Example III
Data flight like spfli occurs 0 with Header line. Select * from spfli into table flight. loop at flight. at new carrid. LH 0400 0402 ___________ write : / flight-carrid. SQ 0110 endat. ___________ write flight-connid. at end of carrid. uline / (25). endat. endloop.
1 1
A A
01 02
100.00 50.00
400.00 100.00
1,000.00 100.00
1
2 2
A
B B
03
02 03
100.00
100.00 100.00
100.00
100.00
ID
Name Month Y-T-D Accumulated Product No. -----------------------------------------------------------------------------------1 A ----------------01 100.00 400.00 1,000.00 02 50.00 100.00 100.00 03 100.00 100.00 100.00 ---------------------------------------------------250.00 600.00 1,200.00 2 B ----------------02 100.00 1,000.00 2,000.00 03 100.00 100.00 100.00 ---------------------------------------------------200.00 1,100.00 2,100.00 ---------------------------------------------------450.00 1,340.00 3,200.00 ----------------------------------------------------
Total
ABAP Program
... loop at tab. at first. write: / ID , 10 Name, 30 Month, 50 Y-T-D , 70 Accumulated. write: /5 Product No. uline /. endat. on change of tab-id. write: / tab-id, 10 tab-name. uline: /(20). endon. write: /5 tab-prodno, 30 tab-month, 50 tab-ytd, 70 tab-accum.
ABAP Program
at end of id. uline /30(60). sum. write: /30 tab-month, 50 tab-ytd, 70 tab-accum. skip. endat. at last. sum. uline /30(60). write: /10 Total, 30 tab-month, 50 tab-ytd, 70 tab-accum. uline /30(60). endat. endloop.
Exercise II
ZCUSTOMERS
id
1 2 3
name
John Peter David
city
New York London Singapore
ZSALES
cust_id
1 1 1
prod_id
A1 A1 A1
sale_date
20020318 20020319 20020329
qty
10 100 50
1
1 3
A2
A2 X1
20020318
20020329 20020321
50
200 90
Exercise II
ID Name ____Product ID Quantity 1 John A1 10 A1 100 A1 50 A2 50 A2 200 ---------------------------Total 410 3 Peter X1 90 ---------------------------Total 90 ---------------------------Grand Total 500 -------------------------------
f1 A A A B B B C
f2 1 1 2 2 2 3 3
f3 1 2 1 1 2 3 4
Loop at tab. Group Header Level 1 at new f1. Group Header Level 2 endat. at new f2. endat. write: / normal data at end of f2. Sub Total Level 2 endat. at end of f1. Sub Total Level 1 endat. Endloop.
A
A A
20070126
20070126 20070128
10
20 30
B
B
20070126
20070126
5
10
Exercise III
ZSALES
cust_id 1 1 1 1 prod_id A1 A1 A1 A2 sale_date 20020318 20020319 20020329 20020318 qty 10 100 50 50
1
3
A2
X1
20020329
20020321
200
90
Exercise III
ALV Report
ALV Report
ALV Report Listing using Function Module ALV Report using Control (ABAP Object)
*Column 3 ls_fieldcat-col_pos = pos. ls_fieldcat-fieldname = 'FLDATE'. ls_fieldcat-ref_fieldname = 'FLDATE'. ls_fieldcat-ref_tabname = 'SFLIGHT'. ls_fieldcat-key = 'X'. append ls_fieldcat to rt_fieldcat. clear ls_fieldcat. pos = pos + 1.
Exercise IV
ZCUSTOMERS
id
1 2 3
name
John Peter David
city
New York London Singapore
ZSALES
cust_id
1 1 1
prod_id
A1 A1 A1
sale_date
20020318 20020319 20020329
qty
10 100 50
ZPRODUCTS
p_id
A1 A2 B1 X1
A2
A2 X1
20020318
20020329 20020321
50
200 90
prod_name
Pen Pencil Ruler Tape
on_hand
100 125 80 120
1 3
zsales-sale_date zcustomers-id
zcustomers-name
zproducts-prod_name
zsales-qty
ALV Technique
ALV : Variant
ALV : Variant
REPORT ZALV06 NO STANDARD PAGE HEADING. type-pools slis. types: begin of i_structure, carrid like sflight-carrid, connid like sflight-connid, fldate like sflight-fldate, price like sflight-price, end of i_structure. data: gt_fieldcat type slis_t_fieldcat_alv, isvariant like DISVARIANT. "ADD gt_outtab type i_structure occurs 0 with header line. initialization. perform field_cat_init using gt_fieldcat[]. isvariant-report = 'ZALV06'. "ADD
ALV : Variant
START-OF-SELECTION. SELECT carrid connid fldate price FROM SFLIGHT INTO TABLE GT_OUTTAB. CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY' EXPORTING I_STRUCTURE_NAME = 'I_STRUCTURE' IT_FIELDCAT = gt_fieldcat[] IS_VARIANT = isvariant "ADD I_SAVE TABLES T_OUTTAB = 'A' "ADD A = user&Global,U = user,X = global = gt_outtab.
ALV : Zebra
ALV : Zebra
REPORT ZALV2 NO STANDARD PAGE HEADING. type-pools slis. types: begin of i_structure, carrid like sflight-carrid, connid like sflight-connid, fldate like sflight-fldate, price like sflight-price, end of i_structure. data: gt_fieldcat type slis_t_fieldcat_alv, GT_LAYOUT TYPE SLIS_LAYOUT_ALV, "ADD gt_outtab type i_structure occurs 0 with header line. initialization. perform field_cat_init using gt_fieldcat[]. GT_LAYOUT-ZEBRA = 'X'. "ADD
ALV : Zebra
START-OF-SELECTION. SELECT carrid connid fldate price FROM SFLIGHT INTO TABLE GT_OUTTAB. CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY' EXPORTING I_STRUCTURE_NAME = 'I_STRUCTURE' IT_FIELDCAT = gt_fieldcat[] IS_LAYOUT TABLES T_OUTTAB = GT_LAYOUT "ADD = gt_outtab.
ALV : Title
ALV : Title
REPORT ZALV2 NO STANDARD PAGE HEADING. type-pools slis. types: begin of i_structure, carrid like sflight-carrid, connid like sflight-connid, fldate like sflight-fldate, price like sflight-price, end of i_structure. data: gt_fieldcat type slis_t_fieldcat_alv, GT_GID_TITLE TYPE LVC_TITLE, "ADD gt_outtab type i_structure occurs 0 with header line. initialization. perform field_cat_init using gt_fieldcat[].
concatenate 'Flight Information' ' for ALV Report' into GT_GID_TITLE. "ADD
ALV : Title
START-OF-SELECTION. SELECT carrid connid fldate price FROM SFLIGHT INTO TABLE GT_OUTTAB. CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY' EXPORTING I_STRUCTURE_NAME = 'I_STRUCTURE' IT_FIELDCAT = gt_fieldcat[] I_GRID_TITLE TABLES T_OUTTAB = GT_GID_TITLE "ADD = gt_outtab.
Exercise
VBAP
vbak-vbeln
vbak-kunnr
kna1-name1
vbap-matnr
vbap-netwr