Tuesday, April 2, 2013

Classical Report of Single Table

The following program is displaying some useful information of material from table MARA based on the material number by a select option in the selection screen. 

Here we have created a custom structure of the internal table named it_mara. This structure ty_mara contains Material No, Creation Date, Name, Material Type and Group. Hence output will have only these fields. We have declared an work area wa_mara for internal table. Here the internal table is of standard table type.

Now under INITIALIZATION event we have initialized the Program name, date and user name which are to be displayed at the Top of page. TOP OF PAGE is another event where we are declaring the select option s_matnr in a selection screen for input of material no. 

Next we are declaring the START-OF-SELECTION event under which we mention a subroutine get_mara. Subroutine is declared by the key word perform. Under this perform we select required fields from MARA into internal table it_mara based on the where condition. So after getting proper data from the MARA table we shall prepare the output in the subroutine of get_output. 

Now on the next event END-OF-SELECTION we are declaring a subroutine get_output and inside there we are looping the internal table it_mara into wa_mara. Hence we fetch the data from internal table to the work area and then display it with simple write statement. Since this is a loop, so one by one record will be fetched into work area and then it will be displayed. 

Now we want to display the name of the fields heading at the beginning. To do this we call control break statement at first & endat inside the loop. At first statement will be triggered at the first time of the loop. Similarly when the listing will be completed then At Last - endat statement will be triggered to display ending of report message.

Next we raise the event TOP-OF-PAGE which is used to display the top message. On the top we can write program name, user name, date etc.

REPORT  zabap_gui.

*Declaring the line type of database table
TABLES: mara.

*------Declaring the local types for Internal table & Work area--------*
TYPES: BEGIN OF ty_mara,
        matnr TYPE mara-matnr, "Material No.
        ersda TYPE mara-ersda, "Creation Data
        ernam TYPE mara-ernam, "Created By
        mtart TYPE mara-mtart, "Material Type
        matkl TYPE mara-matkl, "Material Group
       END OF ty_mara.

*-----Declaring the Internal table & work area-------------------------*
DATA: wa_mara TYPE ty_mara,
      it_mara TYPE STANDARD TABLE OF ty_mara,
      v_repid TYPE sy-repid, "Program name
      v_date  TYPE sy-datum, "Current date
      v_user  TYPE sy-uname. "User name

*-------------Event initialization-------------------------------------*
INITIALIZATION.
  v_repid = sy-repid.
  v_date  = sy-datum.
  v_user  = sy-uname.

*-Declaring the selection screen & select option for input-------------*
  SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
  SELECT-OPTIONS   s_matnr FOR mara-matnr OBLIGATORY.
  SELECTION-SCREEN END OF BLOCK b1.

*-----Event start of selection-----------------------------------------*
START-OF-SELECTION.
  PERFORM get_mara.

*---Event end of selection---------------------------------------------*
END-OF-SELECTION.
  PERFORM get_output.

*---Event top of page--------------------------------------------------*
TOP-OF-PAGE.
  PERFORM top_page.
*&---------------------------------------------------------------------*
*&      Form  get_mara
*&---------------------------------------------------------------------*
*       Select data from MARA table
*----------------------------------------------------------------------*
FORM get_mara .

  SELECT matnr ersda ernam mtart matkl
  FROM mara INTO TABLE it_mara
  WHERE matnr IN s_matnr.

  IF sy-subrc <> 0.
    MESSAGE 'Material Doesn''t Exist.' TYPE 'I'.
    LEAVE LIST-PROCESSING.
  ENDIF.

ENDFORM.                    " get_mara
*&---------------------------------------------------------------------*
*&      Form  get_output
*&---------------------------------------------------------------------*
*       Preparing the classical output with WRITE statement
*----------------------------------------------------------------------*
FORM get_output .

  IF it_mara IS NOT INITIAL.
    LOOP AT it_mara INTO wa_mara.

      "Control break statement – it will display one time at first line
      AT FIRST.
        WRITE: /3 'Material No.',
               25 'Created By',
               40 'Group',
               55 'Type',
               70 'Creation Date'.
        ULINE.
        SKIP.
      ENDAT.

      WRITE: /  wa_mara-matnr,
             25 wa_mara-ernam,
             40 wa_mara-matkl,
             55 wa_mara-mtart,
             70 wa_mara-ersda.

      "Control break statement – it will display one time at last line
      AT LAST.
        ULINE.
        WRITE: /15 '~~End of Material Display~~'.
      ENDAT.

    ENDLOOP.
  ENDIF.

ENDFORM.                    " get_output
*&---------------------------------------------------------------------*
*&      Form  top_page
*&---------------------------------------------------------------------*
*       Top pf page to display top information
*----------------------------------------------------------------------*
FORM top_page .

  WRITE: / 'Material Details',
         / 'Date: ',   12 v_date DD/MM/YYYY,
         / 'User: ',   12 v_user,
         / 'Report: ', 12 v_repid.
  ULINE.
  SKIP.

ENDFORM.                    " top_page


Below is the output:



Output:

16 comments:

harishankar said...

Thanks

harishankar said...

would you provide some more basics information of abap data dictionary

Bhavya Kumar said...

Best blog.Got to learn new things.Thanks for this Blog SAP Success Factors Training in Chennai

magee said...

Fantastic Blog Mr.Sandip Roy. Extraordinary work.

Shalini said...


Hi, This is shalini from Chennai learned SAP Training in Chennai from mr.karthick. The training really was good and i got selected in leading mnc company as SAP Consultant.

You can contact 8122241286 for Best SAP Training in Chennai or reach www.thecreatingexperts.com

Bhavya Kumar said...

SAP Success Factors Real Time Hands on Training in Chennai...

Don't always Depend on Training Institute Alone and so please aware of Best Trainers too..

http://thecreatingexperts.com/sap-successfactors-training-in-chennai/

If You need a Best Trainer over SAP Success Factors Means??? Please ready for an DEMO From the Trainer MR.Karthick
CONTACT:8122241286

Both Classroom/Online Training is Available!!!!!!

Shruti Ramalingam said...


From My search…Creating Experts provides Best SAP Training with real time projects assistance.

Most of the modules are equipped with advance level topics which the student can learn from the basics to the advance level stage.

They also provide placement assistance in leading MNC companies across the globe according to the current requirements.

http://thecreatingexperts.com/sap-successfactors-training-in-chennai/

And these are the Best SAP training institute which provides Real Time Hands on Training…

codedion Technologies-9003085882

creating Experts-8122241286

http://thecreatingexperts.com/sap-mm-training-in-chennai/

sanayamohit said...

SAP Success Factors Real Time Hands on Training in Chennai…

Don’t always Depend on Training Institute alone.Please aware of Best Trainers too..

http://thecreatingexperts.com/sap-successfactors-training-in-chennai/

If You need a Best Trainer in SAP Success Factors??? Then be ready for a DEMO From the Trainer MR.Karthick
CONTACT:8122241286
http://thecreatingexperts.com/sap-mm-training-in-chennai/

Both Classroom/Online Training is Available!!!!!!

Shalini said...

SAP Success Factors Real Time Hands on Training in Chennai…

Don’t always Depend on Training Institute alone.Please aware of Best Trainers too..

http://thecreatingexperts.com/sap-successfactors-training-in-chennai/

If You need a Best Trainer in SAP Success Factors??? Then be ready for a DEMO From the Trainer MR.Karthick
CONTACT:8122241286
http://thecreatingexperts.com/sap-mm-training-in-chennai/

Both Classroom/Online Training is Available!!!!!!

Unknown said...

SAP Success Factors Real Time Hands on Training in Chennai…

Don’t always Depend on Training Institute alone.Please aware of Best Trainers too..

http://thecreatingexperts.com/sap-successfactors-training-in-chennai/

If You need a Best Trainer in SAP Success Factors??? Then be ready for a DEMO From the Trainer MR.Karthick
CONTACT:8122241286
http://thecreatingexperts.com/sap-mm-training-in-chennai/

Both Classroom/Online Training is Available!!!!!!

sanayamohit said...

Best SAP Success Factor Training in Chennai

http://thecreatingexperts.com/sap-training-in-chennai/
http://thecreatingexperts.com/sap-successfactors-training-in-chennai/
http://thecreatingexperts.com/sap-mm-training-in-chennai/
http://thecreatingexperts.com/sap-fico-training-in-chennai/

Priya Kannan said...

SAP Success Factors Real Time Hands on Training in Chennai…

Don’t always Depend on Training Institute alone.Please aware of Best Trainers too..

http://thecreatingexperts.com/sap-successfactors-training-in-chennai/

If You need a Best Trainer in SAP Success Factors??? Then be ready for a DEMO From the Trainer MR.Karthick
CONTACT:8122241286
http://thecreatingexperts.com/sap-mm-training-in-chennai/

Both Classroom/Online Training is Available!!!!!!

Unknown said...


Best SAP MM Material Managemnt Real time hands on Training in chennai

http://thecreatingexperts.com/sap-mm-training-in-chennai/

sushma said...

Informative Blog...For a long time I was craving for a career growth in programming and then I came to know that THE CREATING EXPERTS is the one who provide training with hands on training and real time scenarios

http://thecreatingexperts.com/sap-abap-training-in-chennai/

contact 8122241286

ragu varan said...

Best SAP HANA Training in Chennai by leading HANA Consultant.
Reach at 9003085882
http://thecreatingexperts.com/category/sap-hana-training-in-chennai/

gilledashivani said...

Great information. the information provided is of great use as i got to learn new things. If you are looking for real time training in SAP ABAP, kindly contact sieve software
Sieve software offers real time training by industry experts with live projects and placement support.
SAP ABAP TRAINING IN HYDERABAD