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

Sample Program in Abap

This document provides coding for an ABAP report to combine data from the MARA and MARC tables in SAP. The report joins the two tables on the common key of MARA-MATNR and MARC-MATNR. It selects specific fields from each table, stores them in an internal table, and outputs a report displaying the material number, creation date, name, last change date, plant, maintenance status, valuation category, and purchasing group.

Uploaded by

dhivya
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views

Sample Program in Abap

This document provides coding for an ABAP report to combine data from the MARA and MARC tables in SAP. The report joins the two tables on the common key of MARA-MATNR and MARC-MATNR. It selects specific fields from each table, stores them in an internal table, and outputs a report displaying the material number, creation date, name, last change date, plant, maintenance status, valuation category, and purchasing group.

Uploaded by

dhivya
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

1. CREATE A REPORT WITH FOLLOWING DETAILS.

REQUIREMENTS:
SOURCE OF DATABASE TABLES - MARA AND MARC.
COMMON KEY BETWEEN TWO TABLES - MARA-MATNR =
MARC-MATNR.
OUTPUT OF REPORT SHOULD CONTAIN BELOW FIELDS
MARA-MATNR, MARA-ERSDA, MARA-ERNAM,MARALAEDA
MARC- WERKS,MARC- PSTAT,MARC- LVORM,MARCBWTTY,MARC- EKGRP.
CODING:
*&---------------------------------------------------------------------*
*& Report ZRPROJECT_3
*&PACKAGE NAME : ZRPROJECT
*&---------------------------------------------------------------------*
*& TRANSPORT REQUEST NUMBER : E01K901774
*& REPORT TO COMBINE MARA FIELDS AND MARC FIELDS.
*&---------------------------------------------------------------------*
REPORT

zrproject_3 LINE-COUNT 22(1)


LINE-SIZE 255.
***DATA DECLARATIONS***
TYPES: BEGIN OF ty_table,
matnr TYPE mara-matnr,
ersda TYPE mara-ersda,
ernam TYPE mara-ernam,
laeda TYPE mara-laeda,
werks TYPE marc-werks,
pstat TYPE marc-pstat,
lvorm TYPE marc-lvorm,
bwtty TYPE marc-bwtty,
ekgrp TYPE marc-ekgrp,
END OF ty_table.

"MATERIAL NUMBER
"CREATED DATE
"NAME OF THE PERSON CREATED
"DATE OF LAST CHANGE
"PLANT
"MAINTENANCE STATUS
"FLAG MATERIAL FOR DELETION AT PLANT LEVEL
"VALUATION CATEGORY
"PURCHASING GROUP

DATA: ta_table TYPE TABLE OF ty_table,


wa_table TYPE ty_table.
***SELECTION SCREEN***

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.


SELECT-OPTIONS so_matnr FOR wa_table-matnr.
SELECTION-SCREEN END OF BLOCK b1.
***START OF SELECTION***
START-OF-SELECTION.
SELECT mara~matnr
mara~ersda
mara~ernam
mara~laeda
marc~werks
marc~pstat
marc~lvorm
marc~bwtty
marc~ekgrp
FROM mara INNER JOIN marc ON mara~matnr = marc~matnr
INTO TABLE TA_TABLE WHERE MARA~matnr IN so_matnr.

IF sy-subrc NE 0.
MESSAGE 'NO RECORDS CAN BE FOUND FOR GIVEN MATERIAL NUMBER' TYPE 'E'.
ENDIF.
***TOP OF PAGE***
ULINE.
WRITE:/ 'MATERIAL NUMBER' , 20 'CREATED DATE' , 40 'CREATED BY' , 60 'LAST
CHANGE DATE' ,
80 'PLANT' , 100 'MAINTENANCE STATURS', 120 'FLAG MATERIAL' ,140
'VALUATION CATEGORY' ,
160 'PURCHASING GROUP'.
ULINE.
SKIP 2.
***END OF SELECTION***
END-OF-SELECTION.
IF ta_table IS NOT INITIAL.
LOOP AT ta_table INTO wa_table.
WRITE:/ wa_table-matnr , 20 wa_table-ersda , 40 wa_table-ernam , 60 wa_t

able-laeda,
80 wa_table-pstat , 100 wa_table-lvorm , 120 wa_table-bwtty
, 140 wa_table-ekgrp.
ENDLOOP.
ENDIF.
***END OF PAGE
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