Sei sulla pagina 1di 8

Developing a Interactive report in SAP ABAP - Interactive Reporting in ...

1 of 8

https://www.sapnuts.com/courses/core-abap/interactive-reports/interactiv...

You are here / SAPNuts.com (/) / Courses (/courses/) / SAP ABAP (/courses/core-abap.html)
/ Interactive Reporting in SAP ABAP (/courses/core-abap/interactive-reports.html)
/ Developing a Interactive report in SAP ABAP

Developing a Interactive report in SAP


ABAP
Last Updated: November 18th 2013 by Admin

+ -

Requirement: Develop an interactive report to display material basic details in


basic list, material plant details in secondary list for a material type input and
display header and footer for primary and secondary list.
Requirement Analysis: In the above requirement we have to get material details for a material type input(Parameter input
for MTART eld), when ever user double clicks on any record of basic list, it will go to second screen and display list plants
for that material, display page header and footer for the report.
SAP Tables to be used are: MARA(Material Master), MARC(Material Plants).

Step1: De ne report heading.


Go to SE38, create a program ZSAPN_INTERACTIVE_REPORT.In order to display footer information we have to provide some
space for footer, it can be de ned at report de nition(First line of the report), to provide space for footer we use below
syntax.
REPORT ZSAPN_INTERACTIVE_REPORT LINECOUNT 34(2) NO STANDARD PAGE HEADING. "leave some pages for fo
oter and hide standard heading

In the above deceleration we have provided 34 lines for report and 2 lines for footer i:e 34(2), we don`t need standard page
heading so we used NO STANDARD PAGE HEADING.

Step2:Data decelerations and Selection screen.


Declare the required internal tables, work areas, variables etc and add selection screen element parameter for material type

5/22/2015 10:24 AM

Developing a Interactive report in SAP ABAP - Interactive Reporting in ...

2 of 8

https://www.sapnuts.com/courses/core-abap/interactive-reports/interactiv...

input.
DATA : IT_MARA
WA_MARA
IT_MARC
WA_MARC

TYPE
TYPE
TYPE
TYPE

TABLE
MARA,
TABLE
MARC.

OF MARA, "mara internal table


"mara work area
OF MARC, "marc internal table
"marc work area

PARAMETERS P_MTART TYPE MARAMTART. "selection screen element input field

Step3: Add code to get material basic details.


Add logic to get material details for the material type input under START-OF-SELECTION event.
STARTOFSELECTION.
SELECT * FROM MARA
INTO TABLE IT_MARA
WHERE MTART = P_MTART.

Display materials and use HIDE technique


Display materials and use HIDE technique( HIDE area) to store line data.
LOOP AT IT_MARA INTO WA_MARA.
WRITE:/ WA_MARAMATNR, WA_MARAMTART, WA_MARAMATKL, WA_MARAMBRSH.
HIDE WA_MARA. "store line details in HIDE area
ENDLOOP.

Step4: Get plant details using hide area


Get material plants from MARC table based on HIDE area storage under AT LINE-SELECTION event.
AT LINESELECTION.
SELECT * FROM MARC
INTO TABLE IT_MARC
WHERE MATNR = WA_MARAMATNR.

Step5: Display plant data


Display material plant data.
LOOP AT IT_MARC INTO WA_MARC.
WRITE :/ WA_MARCMATNR, WA_MARCWERKS.
ENDLOOP.

Step6:Display top of page for basic list and secondary list


Display page heading for basic list under TOP-OF-PAGE event and display secondary list heading under TOP-OF-PAGE
DURING LINE-SELECTION event.

5/22/2015 10:24 AM

Developing a Interactive report in SAP ABAP - Interactive Reporting in ...

3 of 8

https://www.sapnuts.com/courses/core-abap/interactive-reports/interactiv...

TOPOFPAGE.
WRITE : 'Material Basic Details' COLOR 5.
TOPOFPAGE DURING LINESELECTION.
WRITE: 'List of Plants for material:', WA_MARAMATNR COLOR 6.

Step7: Display footer for basic list


Display footer information for basic material list.
WRITE: 'Report Generated at:', SYDATUM COLOR 1.

Final report after modularization is below

5/22/2015 10:24 AM

Developing a Interactive report in SAP ABAP - Interactive Reporting in ...

4 of 8

https://www.sapnuts.com/courses/core-abap/interactive-reports/interactiv...

REPORT ZSAPN_INTERACTIVE_REPORT LINECOUNT 33(3) NO STANDARD PAGE HEADING. "leave some pages for fo
oter and hide standard heading
DATA : IT_MARA TYPE TABLE OF MARA, "mara internal table
WA_MARA TYPE MARA, "mara work area
IT_MARC TYPE TABLE OF MARC, "marc internal table
WA_MARC TYPE MARC. "marc work area
PARAMETERS P_MTART TYPE MARAMTART. "selection screen element input field
INITIALIZATION. "initialization event
AT SELECTIONSCREEN. "at selection screen event to validate inputs
PERFORM VALIDATE_INPUT. "Subroutine to validate input
STARTOFSELECTION.
PERFORM GET_MATERIAL_DATA.
PERFORM DISPLAY_MATERIALS.
TOPOFPAGE.
PERFORM DISPLAY_HEADER.
ENDOFPAGE.
PERFORM DISPLAY_FOOTER.
AT LINESELECTION.
PERFORM GET_PLANT_DATA.
PERFORM DISPLAY_PLANT_DATA.
TOPOFPAGE DURING LINESELECTION.
PERFORM DISPLAY_LIST_HEADER.
FORM VALIDATE_INPUT .
IF P_MTART IS INITIAL.
MESSAGE 'Please enter input' TYPE 'E'.
ENDIF.
ENDFORM.
" VALIDATE_INPUT
FORM GET_MATERIAL_DATA .
SELECT * FROM MARA
INTO TABLE IT_MARA
UP TO 50 ROWS
WHERE MTART = P_MTART .
ENDFORM.
" GET_MATERIAL_DATA
FORM DISPLAY_MATERIALS .
LOOP AT IT_MARA INTO WA_MARA.
WRITE:/ WA_MARAMATNR, WA_MARAMTART, WA_MARAMATKL, WA_MARAMBRSH.
HIDE WA_MARA. "store line details in HIDE area
ENDLOOP.

5/22/2015 10:24 AM

Developing a Interactive report in SAP ABAP - Interactive Reporting in ...

5 of 8

https://www.sapnuts.com/courses/core-abap/interactive-reports/interactiv...

ENDFORM.
" DISPLAY_MATERIALS
FORM DISPLAY_HEADER .
WRITE : 'Material Basic Details' COLOR 5.
ENDFORM.
" DISPLAY_HEADER
FORM DISPLAY_FOOTER .
WRITE: 'Report Generated at:', SYDATUM COLOR 1.
ENDFORM.
" DISPLAY_FOOTER
FORM GET_PLANT_DATA .
SELECT * FROM MARC
INTO TABLE IT_MARC
WHERE MATNR = WA_MARAMATNR.
ENDFORM.
" GET_PLANT_DATA
FORM DISPLAY_PLANT_DATA .
LOOP AT IT_MARC INTO WA_MARC.
WRITE :/ WA_MARCMATNR, WA_MARCWERKS.
ENDLOOP.
ENDFORM.
" DISPLAY_PLANT_DATA
FORM DISPLAY_LIST_HEADER .
WRITE: 'List of Plants for material:', WA_MARAMATNR COLOR 6.
ENDFORM.
" DISPLAY_LIST_HEADER

Unit Testing
To test the above report go to MARA table(SE11-MARA-DISPLAY-CONTENETS), get a material type ex: FERT, HALB etc,
execute the report, provide material type and execute. The list of materials will be displayed, double click on any record, the
corresponding material plants will be displayed in secondary list.
Was this lesson helpful to you? Yes

No 23 People out of 25 think this lesson helpful


Ask a Question ?

5/22/2015 10:24 AM

Developing a Interactive report in SAP ABAP - Interactive Reporting in ...

https://www.sapnuts.com/courses/core-abap/interactive-reports/interactiv...

Learn SAP Courses online, SAP Certi cation mock exams and SAP tutorials
SAP ABAP Tutorials, SAP ABAP Online Training, SAP Webdynpro for ABAP, Webdynpro for ABAP tutorials, Webdynpro for
ABAP online training, SAP Work ow training, SAP Online Training, SAP Certi cation, SAP Training, SAP mock exams, SAP
Exams, SAP ERP, SAP Interview questions, SAP ABAP interview Questions

SAP ABAP Course Content

6 of 8

SAP Introduction (/courses/core-abap/sap-intro.html)


SAP ABAP Consultant (/courses/core-abap/sap-abap-consultants.html)
System Landscape and Introduction to ABAP/4 (/courses/core-abap/system-landscape.html)
Data Dictionary (/courses/core-abap/data-dictionary.html)
Internal Tables and Work Areas (/courses/core-abap/internal-table-work-area.html)
Select Statements types (/courses/core-abap/select-statements.html)
Selection Screen Design using SAP ABAP (/courses/core-abap/selection-screen.html)
Modularization techniques in SAP ABAP (/courses/core-abap/modularization-in-abap.html)
Classical Reports in SAP ABAP (/courses/core-abap/classical-reports.html)
Interactive Reporting in SAP ABAP (/courses/core-abap/interactive-reports.html)

5/22/2015 10:24 AM

Developing a Interactive report in SAP ABAP - Interactive Reporting in ...

7 of 8

https://www.sapnuts.com/courses/core-abap/interactive-reports/interactiv...

Menu painter in SAP (/courses/core-abap/menu-screen-painter.html)


ALV Reports (/courses/core-abap/alv-reports.html)
Sapscripts (/courses/core-abap/sapscripts.html)
Smartforms (/courses/core-abap/smartforms.html)
Batch Data Communication (/courses/core-abap/bdc.html)
Open SQL Statements in SAP ABAP (/courses/core-abap/open-sql.html)
SAP memory and ABAP memory (/courses/core-abap/SAP-abap-memory.html)
Performance Tuning in SAP ABAP (/courses/core-abap/performce-tuning.html)
Control break statements in sap abap (/courses/core-abap/control-break-statements.html)
Enhancements in SAP (/courses/core-abap/sap-enhcements.html)
BADI in SAP (/courses/core-abap/badi-sap.html)
SD and MM ows in SAP (/courses/core-abap/sd-mm.html)
Dialog Module Pool Programming (/courses/core-abap/module-pool.html)
String Operations and eld symbols (/courses/core-abap/strg-operations.html)
SAP ABAP real-time scenarios (/courses/core-abap/sap-abap-real-time.html)
MM Basics for ABAP Consultants (/courses/core-abap/sap-mm.html)
SD Basics for ABAP Consultants (/courses/core-abap/sd-basics-for.html)

Lesson Navigation
Interactivereports and it`s events (/courses/core-abap/interactive-reports/interactive-events.html) Previous Chapter
Next Chapter Interactive report using HIDE technique (/courses/core-abap/interactive-reports/interactive-hide.html)

5/22/2015 10:24 AM

Developing a Interactive report in SAP ABAP - Interactive Reporting in ...

8 of 8

https://www.sapnuts.com/courses/core-abap/interactive-reports/interactiv...

2015 SAPNuts.com Contribute (/data/) Terms (/site/terms/) About (/site/about/) Contact (/site/contact/) Feedback
Developed byAshok Reddy (https://www.facebook.com/SAshokKumarReddy)

5/22/2015 10:24 AM

Potrebbero piacerti anche