Using BAPI to Mass change the MRP indicator

The MRP indicator for storage location does not change the MRP indicator in the material master that have already been saved before the change.  This ABAP BAPI (Business Application Programming Interfaces) program was created to mass change all the material master MRP indicator whenever the user want to.

REPORT ZMRPIND.
*
*  Author by  : SAP ABAP/4 Programming, Basis Administration, Configuration Hints and Tips
*              https://www.gotothings.com
*
TABLES: T001L,
        MARD.

DATA: BAPI_HEAD   LIKE BAPIMATHEAD,
      BAPI_MARD1  LIKE BAPI_MARD,
      BAPI_MARDX1 LIKE BAPI_MARDX,
      BAPI_RETURN LIKE BAPIRET2.

SELECT-OPTIONS:
            PLANT    FOR  MARD-WERKS OBLIGATORY MEMORY ID M01,
            MATERIAL FOR  MARD-MATNR MEMORY ID M02.

SELECT * FROM T001L WHERE WERKS IN PLANT.
   SELECT * FROM MARD WHERE WERKS  = T001L-WERKS
                        AND LGORT  = T001L-LGORT
                        AND MATNR IN MATERIAL.

    IF T001L-DISKZ = MARD-DISKZ.
       CONTINUE.
    ENDIF.

    BAPI_HEAD-MATERIAL   = MARD-MATNR.
    BAPI_HEAD-MRP_VIEW   = 'X'.

    BAPI_MARD1-PLANT     = MARD-WERKS.
    BAPI_MARD1-STGE_LOC  = MARD-LGORT.
    BAPI_MARD1-MRP_IND   = T001L-DISKZ.

    BAPI_MARDX1-PLANT    = MARD-WERKS.
    BAPI_MARDX1-STGE_LOC = MARD-LGORT.
    BAPI_MARDX1-MRP_IND  = 'X'.

    WRITE:/ BAPI_HEAD, BAPI_MARD1.

    call function 'BAPI_MATERIAL_SAVEDATA'
      exporting
        headdata                   = BAPI_HEAD
*       CLIENTDATA                 =
*       CLIENTDATAX                =
*       PLANTDATA                  =
*       PLANTDATAX                 =
*       FORECASTPARAMETERS         =
*       FORECASTPARAMETERSX        =
*       PLANNINGDATA               =
*       PLANNINGDATAX              =
        STORAGELOCATIONDATA        = BAPI_MARD1
        STORAGELOCATIONDATAX       = BAPI_MARDX1
*       VALUATIONDATA              =
*       VALUATIONDATAX             =
*       WAREHOUSENUMBERDATA        =
*       WAREHOUSENUMBERDATAX       =
*       SALESDATA                  =
*       SALESDATAX                 =
*       STORAGETYPEDATA            =
*       STORAGETYPEDATAX           =
      IMPORTING
        RETURN                     = BAPI_RETURN
*     TABLES
*       MATERIALDESCRIPTION        =
*       UNITSOFMEASURE             =
*       UNITSOFMEASUREX            =
*       INTERNATIONALARTNOS        =
*       MATERIALLONGTEXT           =
*       TAXCLASSIFICATIONS         =
*       RETURNMESSAGES             =
*       PRTDATA                    =
*       PRTDATAX                   =
*       EXTENSIONIN                =
*       EXTENSIONINX               =
          .

IF BAPI_RETURN-TYPE = 'E'.
   WRITE:/ BAPI_RETURN.
ENDIF.

   ENDSELECT.
ENDSELECT.

More Function Module
Functions / SAP Script / ALV

Tables
Database Table

ABAP Books List
ABAP/4 Certification, Programming, Smartforms, Sapscripts and Object Oriented Programming Books

Smart Forms
SAP Smartforms

ABAP Menu:
ABAP Example Hints and Tips

Return to Index:-
SAP ABAP/4 Programming, Basis Administration, Configuration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.  The site www.gotothings.com is in no way affiliated with SAP AG.
Any unauthorised copying or mirroring is prohibited.