2008 Jan 02 9:50 AM
How to do coding for classical reports?please get me a simple program which can clearly explain this coding part to me.
2008 Jan 02 10:04 AM
Hi,
Normally we use reports to see the data after some processing in the program fetched from database tables.
just check the below program to fetch Purchase order number and material data from EKPO and EKKO tables.
******************************************
REPORT zstemp_qty2 .
DATA:it_ekko LIKE ekko OCCURS 0 WITH HEADER LINE.
DATA:it_ekpo LIKE ekpo OCCURS 0 WITH HEADER LINE.
START-OF-SELECTION.
SELECT * FROM ekko INTO TABLE it_ekko
UP TO 10 ROWS.
IF NOT it_ekko[] IS INITIAL.
SELECT * FROM ekpo INTO TABLE it_ekpo
FOR ALL ENTRIES IN it_ekko
WHERE ebeln = it_ekko-ebeln.
ENDIF.
SORT it_ekpo BY ebeln.
LOOP AT it_ekko.
READ TABLE it_ekpo WITH KEY ebeln = it_ekko-ebeln
BINARY SEARCH.
IF sy-subrc = 0.
WRITE:/ it_ekko-ebeln,it_ekpo-matnr.
ENDIF.
ENDLOOP.
******************************************
First we have to declare intrenal tables and variables.
Second we have to check for selection screen parameters and their types.
Third data fetching and data processing according to client requirements.
Fourth data display in the required format for client.
*******************************************
Regds
Sivaparvathi
Please reward points if helpful...
2008 Jan 02 9:57 AM
Hi,
Implement the following report.
&----
*& Report ZSA_MM_1
*&
&----
*&
*&
&----
REPORT ZSA_MM_PO_HISTORY.
TABLES: EKKO, EKPO, EKKN, EKBE.
PARAMETERS: PO TYPE EKKO-EKORG OBLIGATORY.
SELECT-OPTIONS: PG FOR EKKO-EKGRP OBLIGATORY,
DT FOR EKKO-BEDAT OBLIGATORY.
DATA: BEGIN OF ITAB1 OCCURS 0,
PONO TYPE EKKO-EBELN,
END OF ITAB1,
BEGIN OF ITAB2 OCCURS 0,
PONO TYPE EKPO-EBELN,
ITNO TYPE EKPO-EBELP,
END OF ITAB2,
BEGIN OF ITAB3 OCCURS 0,
PONO TYPE EKKN-EBELN,
ITNO TYPE EKKN-EBELP,
IONO TYPE EKKN-AUFNR,
END OF ITAB3,
BEGIN OF ITAB4 OCCURS 0,
PONO TYPE EKBE-EBELN,
ITNO TYPE EKBE-EBELP,
VGABE TYPE EKBE-VGABE,
IONO TYPE EKKN-AUFNR,
AMT1 TYPE EKBE-DMBTR,
AMT2 TYPE EKBE-DMBTR,
AMT3 TYPE EKBE-DMBTR,
AMT4 TYPE EKBE-DMBTR,
END OF ITAB4,
BEGIN OF IT_CURR_S OCCURS 0,
PONO TYPE EKBE-EBELN,
ITNO TYPE EKBE-EBELP,
AMT1 TYPE EKBE-DMBTR,
AMT2 TYPE EKBE-AREWR,
ATYPE TYPE EKBE-SHKZG,
END OF IT_CURR_S,
WA_CURR LIKE LINE OF IT_CURR_S,
WA_ITAB4 LIKE LINE OF ITAB4,
WA_ITAB3 LIKE LINE OF ITAB3,
AMTS TYPE EKBE-DMBTR,
AMTH TYPE EKBE-DMBTR,
FINAL_AMT TYPE EKBE-DMBTR.
SELECT EBELN FROM EKKO
INTO TABLE ITAB1
WHERE EKORG = PO
AND EKGRP IN PG
AND BEDAT IN DT.
SELECT EBELN EBELP FROM EKPO
INTO TABLE ITAB2
FOR ALL ENTRIES IN ITAB1
WHERE EBELN = ITAB1-PONO.
SELECT EBELN EBELP AUFNR FROM EKKN
INTO TABLE ITAB3
FOR ALL ENTRIES IN ITAB2
WHERE EBELN = ITAB2-PONO
AND EBELP = ITAB2-ITNO.
************EKBE*************************
SELECT EBELN EBELP VGABE FROM EKBE
INTO TABLE ITAB4
FOR ALL ENTRIES IN ITAB3
WHERE EBELN = ITAB3-PONO AND
EBELP = ITAB3-ITNO AND
( VGABE = 1 OR VGABE = 2 ).
LOOP AT ITAB3 INTO WA_ITAB3.
WA_ITAB4-IONO = WA_ITAB3-IONO.
MODIFY ITAB4 FROM WA_ITAB4 TRANSPORTING IONO
WHERE PONO = WA_ITAB3-PONO AND ITNO = WA_ITAB3-ITNO.
ENDLOOP.
SELECT EBELN EBELP DMBTR AREWR SHKZG FROM EKBE
INTO TABLE IT_CURR_S
FOR ALL ENTRIES IN ITAB3
WHERE EBELN = ITAB3-PONO AND
EBELP = ITAB3-ITNO AND
SHKZG = 'S' OR
SHKZG = 'H'.
LOOP AT IT_CURR_S INTO WA_CURR.
IF WA_CURR-ATYPE = 'S'.
AMTS = WA_CURR-AMT1 + AMTS.
ENDIF.
IF WA_CURR-ATYPE = 'H'.
AMTH = WA_CURR-AMT1 + AMTH.
ENDIF.
READ TABLE ITAB4 INTO WA_ITAB4 WITH KEY PONO = WA_CURR-PONO ITNO = WA_CURR-ITNO.
IF WA_ITAB4-VGABE = 1.
WA_CURR-AMT1 = -1 * ( AMTS - AMTH ).
WA_ITAB4-AMT1 = WA_CURR-AMT1.
MODIFY ITAB4 FROM WA_ITAB4 TRANSPORTING AMT1
WHERE PONO = WA_CURR-PONO AND ITNO = WA_CURR-ITNO.
elseif WA_ITAB4-VGABE = 2.
WA_CURR-AMT2 = AMTS - AMTH.
WA_ITAB4-AMT2 = WA_CURR-AMT2.
MODIFY ITAB4 FROM WA_ITAB4 TRANSPORTING AMT2
WHERE PONO = WA_CURR-PONO AND ITNO = WA_CURR-ITNO.
endif.
CLEAR AMTS.
CLEAR AMTH.
ENDLOOP.
SELECT EBELN EBELP VGABE FROM EKBZ
APPENDING TABLE ITAB4
FOR ALL ENTRIES IN ITAB3
WHERE EBELN = ITAB3-PONO AND
EBELP = ITAB3-ITNO AND
( VGABE = 1 OR VGABE = 2 ) .
LOOP AT ITAB3 INTO WA_ITAB3.
WA_ITAB4-IONO = WA_ITAB3-IONO.
MODIFY ITAB4 FROM WA_ITAB4 TRANSPORTING IONO
WHERE PONO = WA_ITAB3-PONO AND ITNO = WA_ITAB3-ITNO.
ENDLOOP.
SELECT EBELN EBELP DMBTR AREWR SHKZG FROM EKBZ
INTO TABLE IT_CURR_S
FOR ALL ENTRIES IN ITAB3
WHERE EBELN = ITAB3-PONO AND
EBELP = ITAB3-ITNO AND
SHKZG = 'S' OR
SHKZG = 'H'.
LOOP AT IT_CURR_S INTO WA_CURR.
IF WA_CURR-ATYPE = 'S'.
AMTS = WA_CURR-AMT1 + AMTS.
ENDIF.
IF WA_CURR-ATYPE = 'H'.
AMTH = WA_CURR-AMT1 + AMTH.
ENDIF.
READ TABLE ITAB4 INTO WA_ITAB4 WITH KEY PONO = WA_CURR-PONO ITNO = WA_CURR-ITNO.
IF WA_ITAB4-VGABE = 1.
WA_CURR-AMT1 = AMTS - AMTH.
WA_ITAB4-AMT3 = WA_CURR-AMT1.
MODIFY ITAB4 FROM WA_ITAB4 TRANSPORTING AMT3
WHERE PONO = WA_CURR-PONO AND ITNO = WA_CURR-ITNO.
ELSEIF WA_ITAB4-VGABE = 2.
WA_CURR-AMT2 = AMTS - AMTH.
WA_ITAB4-AMT4 = WA_CURR-AMT2.
MODIFY ITAB4 FROM WA_ITAB4 TRANSPORTING AMT4
WHERE PONO = WA_CURR-PONO AND ITNO = WA_CURR-ITNO.
ENDIF.
CLEAR AMTS.
CLEAR AMTH.
ENDLOOP.
LOOP AT ITAB4 INTO WA_ITAB4.
FINAL_AMT = WA_ITAB4-AMT1 + WA_ITAB4-AMT2 + WA_ITAB4-AMT3 + WA_ITAB4-AMT4.
WRITE:/ WA_ITAB4-IONO,
WA_ITAB4-PONO,
WA_ITAB4-ITNO,
WA_ITAB4-AMT1,
WA_ITAB4-AMT2,
WA_ITAB4-AMT3,
WA_ITAB4-AMT4,
FINAL_AMT.
ENDLOOP.
Hope this help you out.
Regards,
DS
2008 Jan 02 10:02 AM
Hi Ayushi,
Classical Reports :
These are the most simple reports. Programmers learn this one first. It is just an output of data using the Write statement inside a loop.
Classical reports are normal reports. These reports are not having any sub reports. IT IS HAVING ONLY ONE SCREEN/LIST FOR OUTPUT.
Events In Classical Reports.
INTIALIZATION: This event triggers before selection screen display.
AT-SELECTION-SCREEN: This event triggers after proccesing user input still selection screen is in active mode.
START OF SELECTION: Start of selection screen triggers after proceesing selection screen.
END-OF-SELECTION : It is for Logical Database Reporting.
for Example refer to link
http://www.sapmaterial.com/?gclid=CN322K28t4sCFQ-WbgodSGbK2g
check these links...
http://www.sapgenie.com/abap/reports.htm
http://www.allsaplinks.com/material.html
http://www.sapdevelopment.co.uk/reporting/reportinghome.htm
http://www.sapfans.com/forums/viewtopic.php?t=58286
http://www.sapfans.com/forums/viewtopic.php?t=76490
http://www.sapfans.com/forums/viewtopic.php?t=20591
http://www.sapfans.com/forums/viewtopic.php?t=66305
http://www.sapbrain.com/FAQs/TECHNICAL/SAP_ABAP_REPORTS_FAQ.html
http://www.sapdevelopment.co.uk/reporting/rep_submit.htm
http://www.kabai.com/abaps/q.htm
http://www.guidancetech.com/people/holland/sap/abap/
Reports : extracting,collectiing and formating data which is stored in database is done by
report program.
the program which is written to retrieve and display data is report program and the list which is displayed on the screen when you ecectue the program is called as LIST (output of the report.
SAP has provided thousand of preprogrammed reports.User just selects a menu option or just one click here and there and the report is displayed.
you want to display the data which user needs.
for ex: user wants to see the all the employee record who have joined after 13 jan 1998.
in this case you have to pass the information to the system that he needs only those employee where joining date is greater than 13 jan 1998.
SELECTION-CRITERIA : (ACCEPTS INPUT FROM USER).
SELECT-OPTIONS : SMARA FOR MARA-MATNR.
WE HAVE TWO TYPES OF REPORTS:
CLASSICAL REPORTS
INTERACTIVE REPORTS
CLASSICAL REPORTS (EVENTS IN CLASSICAL REPORT).
INITIALIZATION.(TRIGGERED WHEN YOU EXECUTE YOUR PROGRAM FOR FIRST TIME.
AT SELECTION-SCREEN (WHEN USER ENTERS THE VALUES IN THE FIELDS OF SELECTION SCREEN AND CLICK ON EXECUTE BUTTON THIS EVENT IS TRIGGERED.(DATA VALIDITY CHECKING)
AT SELECTION-SCREEN OUTPUT.(SAME,THIS EVENT IS FOR CHECKING INDIVIDUAL FIELDS)
START-OF-SELECTION
TOP-OF-PAGE(ITS TRIGGERED FOR THE FIRST WRITE STATEMENT)
END-OF-PAGE(WHEN YOU REACH END PAGE)
END-OF-SELECTION.
AT SELECTION-SCREEN:
IF SMARA-LOW NE 'LH' AND SMARA-HIGH NE 'SQ'.
HERE SYSTEM WILL NOT PROCEED IF VALUES ENTERED ARE WRONG.
START-OF-SELECTION.
DATA DECLARTION CAN BE DONE,AND ACTUALLY CODING WILL START.
TOP-OF-PAGE : APPLICABLE TO ALL THE PAGES
EX: WRITE THE COMPANY NAME,COLUMN HEADERS FOR ALL THE PAGES)
INTERACTIVE REPORT CONSISTS OF ONE BASIC LIST AND 20 SECONDARY LIST.BASIC LIST IS PRODUCED BY START-OF-SELECTION.
WHEN THE USER DOUBLE CLICKS SECONDARY LIST IS PRODUCED.
INTERACTIVE REPORT
AT LINE SELECTION
AT USER-COMMAND.
atline selection
http://help.sap.com/saphelp_di471/helpdata/EN/9f/dba3ae35c111d1829f0000e829fbfe/content.htm
See this link,
http://help.sap.com/saphelp_di471/helpdata/EN/9f/dba3ae35c111d1829f0000e829fbfe/content.htm
Event in interactive reporting
This event is processed whenever the user chooses a valid line in the list (i.e. a line generated by statements such as WRITE , ULINE or SKIP ) with the cursor and presses the function key which has the function PICK in the interface definition. This should normally be the function key F2 , because it has the same effect as double-clicking the mouse, or single-clicking in the case of a hotspot .
The processing for the event AT LINE-SELECTION usually generates further list output (the details list) which completely covers the current list display. If the latter is still visible (to aid user orientation), this may be due to the key word WINDOW .
In most cases, the information is from the selected line is used to retrieve more comprehensive information by direct reading. When displaying the original list, you store the key terms needed for this in the HIDE area of the output line.
at line selection event is mainly used when u r using a drill down list.
that is,
when u click on the list in the output it triggers or navigates us into another output i.e another list.
consider this code.it can be helpful.
TYPES : BEGIN OF TY_A1,
VBELN TYPE VBAK-VBELN,
ERNAM TYPE VBAK-ERNAM,
ERDAT TYPE VBAK-ERDAT,
NAME1 TYPE KNA1-NAME1,
END OF TY_A1,
BEGIN OF TY_A2,
MATNR TYPE VBAP-MATNR,
MAKTX TYPE MAKT-MAKTX,
CHARG TYPE VBAP-CHARG,
POSNR TYPE VBAP-POSNR,
END OF TY_A2.
&*********************************************************************
&*********************************************************************
DATA : IT_A1 TYPE TABLE OF TY_A1,
IT_A2 TYPE TABLE OF TY_A2.
DATA : WA_A1 TYPE TY_A1,
WA_A2 TYPE TY_A2.
AT LINE-SELECTION.
PERFORM F1.
TOP-OF-PAGE.
ULINE 1(100).
WRITE : 100 SY-VLINE.
WRITE 😕 SY-VLINE, 02 TEXT-000,SY-VLINE,
15 TEXT-001,SY-VLINE,
40 TEXT-002,SY-VLINE,
60 TEXT-003, 100 SY-VLINE.
WRITE :/100 SY-VLINE.
WRITE AT 1(100) SY-ULINE.
WRITE : 100 SY-VLINE.
END-OF-PAGE.
TOP-OF-PAGE DURING LINE-SELECTION.
ULINE 1(100).
WRITE : 100 SY-VLINE.
WRITE 😕 SY-VLINE, 02 TEXT-004,SY-VLINE,
25 TEXT-005, 56 SY-VLINE,
65 TEXT-006,SY-VLINE,
85 TEXT-007,
100 SY-VLINE.
WRITE :/100 SY-VLINE.
WRITE AT 1(100) SY-ULINE.
WRITE : 100 SY-VLINE.
START-OF-SELECTION .
PERFORM F2.
END-OF-SELECTION .
&----
*& Form F2
&----
text
-
FORM F2 .
IF P_DATE-LOW IS NOT INITIAL AND P_DATE-HIGH IS NOT INITIAL.
SELECT VBAK~VBELN
VBAK~ERNAM
VBAK~ERDAT
KNA1~NAME1
FROM VBAK INNER JOIN KNA1
ON VBAKKUNNR = KNA1KUNNR
INTO CORRESPONDING FIELDS OF TABLE IT_A1
WHERE VBAKERDAT > P_DATE-LOW AND VBAKERDAT < P_DATE-HIGH.
ELSEIF P_DATE IS INITIAL.
MESSAGE E000(ZTH_TEST).
ELSEIF P_DATE-LOW IS NOT INITIAL AND P_DATE-HIGH IS INITIAL.
SELECT VBAK~VBELN
VBAK~ERNAM
VBAK~ERDAT
KNA1~NAME1
FROM VBAK INNER JOIN KNA1
ON VBAKKUNNR = KNA1KUNNR
INTO CORRESPONDING FIELDS OF TABLE IT_A1
WHERE VBAK~ERDAT = P_DATE-LOW.
ELSEIF P_DATE-HIGH IS NOT INITIAL AND P_DATE-LOW IS INITIAL.
SELECT VBAK~VBELN
VBAK~ERNAM
VBAK~ERDAT
KNA1~NAME1
FROM VBAK INNER JOIN KNA1
ON VBAKKUNNR = KNA1KUNNR
INTO CORRESPONDING FIELDS OF TABLE IT_A1
WHERE VBAK~ERDAT < P_DATE-HIGH.
ENDIF.
IF SY-SUBRC <> 0.
MESSAGE E001(ZTH_TEST).
ELSE.
*SKIP 2.
LOOP AT IT_A1 INTO WA_A1.
WRITE : / SY-VLINE, 03 WA_A1-VBELN,14 SY-VLINE.
HIDE WA_A1-VBELN. WRITE: 20 WA_A1-ERNAM,34 SY-VLINE,
36 WA_A1-ERDAT,54 SY-VLINE,
60 WA_A1-NAME1,100 SY-VLINE.
ENDLOOP.
WRITE AT 1(100) SY-ULINE.
ENDIF.
ENDFORM. "F2
&----
*& Form F1
&----
text
-
FORM F1.
SELECT VBAP~MATNR
MAKT~MAKTX
VBAP~CHARG
VBAP~POSNR
FROM VBAP INNER JOIN MAKT
ON VBAPMATNR = MAKTMATNR
INTO CORRESPONDING FIELDS OF TABLE IT_A2
WHERE VBAP~VBELN = WA_A1-VBELN AND SPRAS = 'EN'.
*SKIP 2.
LOOP AT IT_A2 INTO WA_A2.
WRITE : / SY-VLINE, WA_A2-MATNR, 14 SY-VLINE,
16 WA_A2-MAKTX, 56 SY-VLINE,
65 WA_A2-CHARG, 78 SY-VLINE,
85 WA_A2-POSNR, 100 SY-VLINE.
ENDLOOP.
WRITE AT 1(100) SY-ULINE.
ENDFORM. "F1
AT USER-COMMAND:
If the user chooses a function code during list processing that is neither processed by the system, or PICK or PF<nn>, the system triggers the event AT USER-COMMAND. For this event, you must define your own GUI status for a list. To react to your own function codes in a program, you must define the following event block:
AT USER-COMMAND.
<statements>.
In this event block, you can use an IF or CASE structure to tell the function codes apart. They are available in the system field SY-UCOMM. There are further system fields that are filled in list events, such as SY-LSIND and SY-PFKEY, that allow you to make further case distinctions.
REPORT Test_program.
START-OF-SELECTION.
SET PF-STATUS 'TEST'.
WRITE: 'Basic list, SY-LSIND =', sy-lsind.
AT LINE-SELECTION.
WRITE: 'LINE-SELECTION, SY-LSIND =', sy-lsind.
AT USER-COMMAND.
CASE sy-ucomm.
WHEN 'TEST'.
WRITE: 'TEST, SY-LSIND =', sy-lsind.
ENDCASE.
With this code double click on 'TEST' and define your own PF status and give user command as TEST and check out this useful programe.
Reward Points, if useful....
Regards,
Nitin.
2008 Jan 02 10:04 AM
Hi,
Normally we use reports to see the data after some processing in the program fetched from database tables.
just check the below program to fetch Purchase order number and material data from EKPO and EKKO tables.
******************************************
REPORT zstemp_qty2 .
DATA:it_ekko LIKE ekko OCCURS 0 WITH HEADER LINE.
DATA:it_ekpo LIKE ekpo OCCURS 0 WITH HEADER LINE.
START-OF-SELECTION.
SELECT * FROM ekko INTO TABLE it_ekko
UP TO 10 ROWS.
IF NOT it_ekko[] IS INITIAL.
SELECT * FROM ekpo INTO TABLE it_ekpo
FOR ALL ENTRIES IN it_ekko
WHERE ebeln = it_ekko-ebeln.
ENDIF.
SORT it_ekpo BY ebeln.
LOOP AT it_ekko.
READ TABLE it_ekpo WITH KEY ebeln = it_ekko-ebeln
BINARY SEARCH.
IF sy-subrc = 0.
WRITE:/ it_ekko-ebeln,it_ekpo-matnr.
ENDIF.
ENDLOOP.
******************************************
First we have to declare intrenal tables and variables.
Second we have to check for selection screen parameters and their types.
Third data fetching and data processing according to client requirements.
Fourth data display in the required format for client.
*******************************************
Regds
Sivaparvathi
Please reward points if helpful...
2008 Jan 02 10:05 AM
Hi,
Refer This Code,
***Data Declaration
data: name(10) type c,
subject(10) type c,
marks type i,
total type i.
***Declaring Field Group
field-groups: header, fg1.
insert marks into fg1.
insert name subject into header.
***Initializing the Data
name = 'Raja'.
subject = 'PHYSICS'.
marks = 80.
extract fg1.
name = 'Raja'.
subject = 'CHEMISTRY'.
marks = 60.
extract fg1.
name = 'Raja'.
subject = 'BIOLOGY'.
marks = 20.
extract fg1.
name = 'Kumar'.
subject = 'MATHS'.
marks = 70.
extract fg1.
name = 'Kumar'.
subject = 'CHEMISTRY'.
marks = 30.
extract fg1.
name = 'Ravi'.
subject = 'MATHS'.
marks = 76.
extract fg1.
name = 'Ravi'.
subject = 'TAMIL'.
marks = 29.
extract fg1.
name = 'Ravi'.
subject = 'CHEMISTRY'.
marks = 80.
extract fg1.
***sorting data by name and subject
sort by name subject.
***Looping for displaying the Data
loop.
at first.
format color 5 .
write / 'MARK LIST'.
uline.
endat.
at new name.
uline /(82).
format color 4 .
write: / sy-vline ,
2(25) 'STUDENT NAME' centered ,
27 sy-vline ,
28(25) 'SUBJECT NAME' centered ,
54 sy-vline ,
55(25) 'MARKS' centered,
82 sy-vline.
uline /(82).
write: / sy-vline, name,
27 sy-vline ,
54 sy-vline ,
82 sy-vline.
endat.
format color 2.
write: / sy-vline, 27 sy-vline, 28(25) subject, 54 sy-vline,
55(25) marks, 82 sy-vline.
at end of name.
uline /(82).
format color 7.
write: / 'TOTAL' ,55(25) sum(marks).
uline /.
write : / 'NO OF SUBJECT FOR ', name , ' : ' , (6) cnt(subject).
uline.
skip.
endat.
at last.
write : / 'NO OF STUDENT:', (6) cnt(name).
uline.
endat.
endloop.
Thanks.
2008 Mar 13 9:40 AM
hi,
I am not able to activate the main table I have created n getting the errors
1.technical settings not consistent
2.Enhancement categpry missing
plz help me out with this....................
thanks
2008 Mar 13 10:11 AM
hi,
I am not able to activate the main table I have created n getting the errors
1.technical settings not consistent
2.Enhancement categpry missing
plz help me out with this....................
thanks
2008 Mar 13 10:32 AM
hi,
I am not able to activate the main table I have created n getting the errors
1.technical settings not consistent
2.Enhancement categpry missing
plz help me out with this....................
thanks