02/03/2013

SAP Material Reports

Summary :

This Report Contains material according to the company .
---------------------------------------------------------------------------

*&--------------------------------------------------------
*& Report  ZCLASSICAL_REPORT                                           *  
*&                                                                     *
*&--------------------------------------------------------
*&  Author  tech.sap29@gmail.com                                                                   *
*&                                                                     *
*&--------------------------------------------------------
REPORT  ZCLASSICAL_REPORT                       .

TABLES: MARA,
        T001W.

SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-H01.
SELECT-OPTIONS: S_MATNR FOR MARA-MATNR.
PARAMETERS: P_WERKS LIKE MARD-WERKS.
SELECTION-SCREEN: END OF BLOCK B1.


INITIALIZATION.
  S_MATNR-LOW = '100-100'. S_MATNR-HIGH = '100-500'.
  S_MATNR-SIGN = 'I'. S_MATNR-OPTION = 'BT'.
  APPEND S_MATNR.
  P_WERKS = '1000'.


AT SELECTION-SCREEN.
  IF P_WERKS IS INITIAL.
    MESSAGE E000(Z00) WITH 'Pls Enter Plant'.
  ENDIF.

AT SELECTION-SCREEN ON S_MATNR.
  IF NOT S_MATNR[] IS INITIAL.
    PERFORM VALIDATE_S_MATNR.
  ENDIF.

AT SELECTION-SCREEN ON P_WERKS.
  IF NOT P_WERKS IS INITIAL.
    PERFORM VALIDATE_WERKS.
  ENDIF.

AT SELECTION-SCREEN OUTPUT.
  PERFORM CHANGE_FIELDS.


AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_WERKS.
  MESSAGE I000(Z00) WITH 'On value request is called'.

AT SELECTION-SCREEN ON HELP-REQUEST FOR P_WERKS.
  MESSAGE I000(Z00) WITH 'On Help request is called'.


*&---------------------------------------------------------------------*
*&      Form  VALIDATE_S_MATNR
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM VALIDATE_S_MATNR .
  SELECT MATNR
    FROM MARA
    INTO MARA-MATNR
    UP TO 1 ROWS
    WHERE MATNR IN S_MATNR.
  ENDSELECT.

  IF SY-SUBRC <> 0.
    MESSAGE E000(Z00) WITH 'Invalid Range of Material From'
    S_MATNR-LOW 'To' S_MATNR-HIGH.
  ENDIF.

ENDFORM.                    " VALIDATE_S_MATNR
*&---------------------------------------------------------------------*
*&      Form  VALIDATE_WERKS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM VALIDATE_WERKS .
  SELECT SINGLE WERKS
          FROM T001W
          INTO T001W-WERKS
          WHERE WERKS = P_WERKS.

  IF SY-SUBRC <> 0.
    MESSAGE E000(Z00) WITH 'Plant' P_WERKS 'Does not Exists'.
  ENDIF.

ENDFORM.                    " VALIDATE_WERKS
*&--------------------------------------------------------
*&      Form  CHANGE_FIELDS
*&--------------------------------------------------------
*       text
*---------------------------------------------------------
FORM CHANGE_FIELDS .
  LOOP AT SCREEN.
    IF SCREEN-NAME = 'P_WERKS'.
      SCREEN-REQUIRED = 1.
      MODIFY SCREEN.
    ENDIF.
  ENDLOOP.
ENDFORM.                    " CHANGE_FIELDS

No comments:

Post a Comment