0% found this document useful (0 votes)
447 views

Sap Abap Sample Programs

This document contains code for creating a report in SAP that fetches and displays data from the MARA table. It defines a data structure for the MARA table fields and uses selection screens to allow the user to input a material type. When the report is executed, it selects the specified fields from MARA where the material type matches the user input. It then writes the field values to the output in a formatted table, including page headers and footers.

Uploaded by

dhivya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
447 views

Sap Abap Sample Programs

This document contains code for creating a report in SAP that fetches and displays data from the MARA table. It defines a data structure for the MARA table fields and uses selection screens to allow the user to input a material type. When the report is executed, it selects the specified fields from MARA where the material type matches the user input. It then writes the field values to the output in a formatted table, including page headers and footers.

Uploaded by

dhivya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

1. CREATE A REPORT WITH THE FOLLOWING DETAILS.

REQUIREMENTS:
SELECTION SCREEN CONTAIN THE FOLLOWING FIELDS
I.
II.

MARA-MTART AS INPUT FIELD


FETCH THE DATA OF THE FIELDS OF MARA TABLE MATNR,
ERSDA, ERNAM, LAEDA, AENAM, MTART, MATKL IN THE
REPORT OUT BASED ON MARA-MTART GIVEN AS INPUT.

CODING:

*&---------------------------------------------------------------------*
*& Report ZRPROJECT_1
*& PACKAGE NAME : ZRPROJECT
*&---------------------------------------------------------------------*
*& TRANSPORT REQUEST NUMBER : E01K901774
*& REPORT TO FETCH DATA FROM MARA TABLE
*&---------------------------------------------------------------------*
REPORT

zrproject_1 LINE-COUNT 22(1)


LINE-SIZE 255
MESSAGE-ID ztest_msg_1001.

**DATA DECLARATION**
TYPES: BEGIN OF ty_mara,
matnr TYPE matnr,
ersda TYPE ersda,
ernam TYPE ernam,
laeda TYPE laeda,
aenam TYPE aenam,
mtart TYPE mtart,
matkl TYPE matkl,
END OF ty_mara.

" MATERIAL NUMBER


" CREATED ON
" NAME OF THE PERSON CREATED
" DATE OF LAST CHANGE
" NAME OF THE PERSON WHO CHANGED THE OBJECT
" MATERIAL TYPE
" MATERIAL GROUP

DATA: ta_mara TYPE TABLE OF ty_mara,


wa_mara TYPE ty_mara.
DATA: g_mtart TYPE mara-mtart.
***SELECTION SCREEN***
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-000.

SELECT-OPTIONS so_mtart FOR g_mtart.


SELECTION-SCREEN END OF BLOCK b1.

***AT SELECTION SCREEN EVENT***


AT SELECTION-SCREEN ON so_mtart.

SELECT

mtart FROM t134 INTO g_mtart WHERE mtart IN so_mtart.

ENDSELECT.
IF sy-subrc NE 0.
MESSAGE e003.
ENDIF.

***START OF SELECTION EVENT***


START-OF-SELECTION.
SELECT matnr ersda ernam laeda aenam mtart matkl FROM mara INTO TABLE ta_mar
a
WHERE mtart IN so_mtart.
***END OF SELECTION EVENT***
END-OF-SELECTION.
IF ta_mara IS NOT INITIAL.
LOOP AT ta_mara INTO wa_mara.
WRITE:/ wa_mara-matnr, sy-vline , 20 wa_mara-ersda ,sy-vline , 40 wa_mar
a-ernam , sy-vline ,60 wa_mara-laeda ,
sy-vline , 80 wa_mara-aenam , sy-vline ,100 wa_mara-mtart
,sy-vline , 125 wa_mara-matkl.
ENDLOOP.
ENDIF.
***TOP OF PAGE EVENT***
TOP-OF-PAGE.

WRITE:/ 'MATERIAL NUMBER' , 20 'CREATED DATE' , 40 'CREATED BY' , 60


'LAST DATE OF CHANGE', 80 'CHANGED BY' ,100 'MATERIAL TYPE' ,
125
'MATERIAL GROUP'.
ULINE.
SKIP 1.

***END OF PAGE EVENT***


END-OF-PAGE.
WRITE:/ 'PAGE NUMBER' , sy-pagno , 25 'USERNAME = ' , sy-uname , 50
'DATE =' , sy-datum RIGHT-JUSTIFIED .

OUTPUT:
POSITIVE TESTING:

NEGATIVE TESTING:

You might also like