Summary :
This is classical report which contain material tables and Displaying Material and plant Details
*&---------------------------------------------------------------------*
*& Report ZCLASSICAL_REPORT *
*&Author tech.sap29@gmail.com *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT ZCLASSICAL_REPORT
NO STANDARD PAGE HEADING
LINE-SIZE 120
LINE-COUNT 10(1).
*----------------------------------------------------------------------*
* TYPES DECLARATIONS
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
* TABLES DECLARATIONS
*----------------------------------------------------------------------*
TABLES: MARA, "Material Master
T001W. "Plant Master
*----------------------------------------------------------------------*
* DATA DECLARATIONS
*----------------------------------------------------------------------*
DATA: V_LINE TYPE I.
*----------------------------------------------------------------------*
* CONSTANTS DECLARATIONS
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
* INTERNAL TABLE DECLARATIONS
*----------------------------------------------------------------------*
DATA: BEGIN OF IT_MARD OCCURS 1,
MATNR LIKE MARA-MATNR,
MAKTX LIKE MAKT-MAKTX,
WERKS LIKE MARD-WERKS,
LGORT LIKE MARD-LGORT,
LABST LIKE MARD-LABST,
END OF IT_MARD.
*----------------------------------------------------------------------*
* SELECTION SCREEN DESIGN
*----------------------------------------------------------------------*
SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-H01.
SELECT-OPTIONS: S_MATNR FOR MARA-MATNR,
S_WERKS FOR T001W-WERKS.
PARAMETERS: P1 TYPE I.
SELECTION-SCREEN: END OF BLOCK B1.
*----------------------------------------------------------------------*
* INITIALIZATION
*----------------------------------------------------------------------*
INITIALIZATION.
S_MATNR-LOW = '100-100'. S_MATNR-HIGH = '100-500'.
S_MATNR-SIGN = 'I'. S_MATNR-OPTION = 'BT'.
APPEND S_MATNR.
S_WERKS-LOW = '0001'. S_WERKS-HIGH = '3800'.
S_WERKS-SIGN = 'I'. S_WERKS-OPTION = 'BT'.
APPEND S_WERKS.
*----------------------------------------------------------------------*
* AT SELECTION SCREEN OUTPUT
*----------------------------------------------------------------------*
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF SCREEN-NAME = 'S_WERKS-LOW'.
SCREEN-REQUIRED = 1.
* SCREEN-INPUT = 0.
* SCREEN-INVISIBLE = 1.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
*----------------------------------------------------------------------*
* AT SELECTION SCREEN
*----------------------------------------------------------------------*
AT SELECTION-SCREEN.
*----------------------------------------------------------------------*
* AT SELECTION SCREEN
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON S_WERKS.
IF NOT S_WERKS[] IS initial.
PERFORM VALIDATE_PLANT.
ENDIF.
*----------------------------------------------------------------------*
* AT SELECTION SCREEN ON VALUE REQUEST
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_WERKS-LOW.
MESSAGE I000(Z00) WITH 'On Value Request'.
*----------------------------------------------------------------------*
* AT SELECTION SCREEN ON HELP REQUEST
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON HELP-REQUEST FOR P1.
MESSAGE I000(Z00) WITH 'On Help Request'.
*----------------------------------------------------------------------*
* START-OF-SELECTION
*----------------------------------------------------------------------*
START-OF-SELECTION.
PERFORM GET_DATA.
*----------------------------------------------------------------------*
* END-OF-SELECTION
*----------------------------------------------------------------------*
END-OF-SELECTION.
PERFORM SHOW_LIST.
*----------------------------------------------------------------------*
* TOP-OF-PAGE
*----------------------------------------------------------------------*
TOP-OF-PAGE.
PERFORM BUILD_PAGE_HEADER.
*----------------------------------------------------------------------*
* END-OF-PAGE
*----------------------------------------------------------------------*
END-OF-PAGE.
PERFORM BUILD_PAGE_FOOTER.
*&---------------------------------------------------------------------*
*& Form VALIDATE_PLANT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM VALIDATE_PLANT .
SELECT WERKS
FROM T001W
INTO T001W-WERKS
UP TO 1 ROWS
WHERE WERKS IN S_WERKS.
ENDSELECT.
IF SY-SUBRC <> 0.
MESSAGE E000(Z00) WITH 'Invalid Range of Plants' S_WERKS-LOW 'And'
S_WERKS-HIGH.
ENDIF.
ENDFORM. " VALIDATE_PLANT
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM GET_DATA .
SELECT A~MATNR
B~MAKTX
C~WERKS
C~LGORT
C~LABST
INTO TABLE IT_MARD
FROM MARA AS A
INNER JOIN MAKT AS B
ON B~MATNR = A~MATNR
INNER JOIN MARD AS C
ON C~MATNR = A~MATNR
WHERE A~MATNR IN S_MATNR
AND C~WERKS IN S_WERKS
AND SPRAS = SY-LANGU.
ENDFORM. " GET_DATA
*&---------------------------------------------------------------------*
*& Form BUILD_PAGE_HEADER
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM BUILD_PAGE_HEADER .
FORMAT INTENSIFIED ON COLOR COL_HEADING.
ULINE AT (105).
WRITE:/ SY-VLINE,
'Material No',
20 SY-VLINE,
'Material Desc',
62 SY-VLINE,
'Plant',
72 SY-VLINE,
'Str.Loc',
81 SY-VLINE,
'Qty',
105 SY-VLINE.
ULINE AT (105).
FORMAT RESET.
ENDFORM. " BUILD_PAGE_HEADER
*&---------------------------------------------------------------------*
*& Form SHOW_LIST
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM SHOW_LIST .
LOOP AT IT_MARD.
WRITE:/ SY-VLINE,
IT_MARD-MATNR,
20 SY-VLINE,
IT_MARD-MAKTX,
62 SY-VLINE,
IT_MARD-WERKS,
72 SY-VLINE,
IT_MARD-LGORT,
81 SY-VLINE,
IT_MARD-LABST,
105 SY-VLINE.
ENDLOOP.
ULINE AT (105).
*--footer for last page conditionally
V_LINE = ( SY-LINCT - SY-LINNO ) - 1.
SKIP V_LINE.
ENDFORM. " SHOW_LIST
*&---------------------------------------------------------------------*
*& Form BUILD_PAGE_FOOTER
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM BUILD_PAGE_FOOTER .
WRITE:/90 'Page :', SY-PAGNO.
ENDFORM. " BUILD_PAGE_FOOTER
I Have post new content using factory Pattern try and use it more
ReplyDeleteawesome blog
ReplyDelete