Programme SAP RMGNL022 - Generate Material Master Accesses for Special Applications

Description
The program generates a function module called MATERIAL_READ_ fora user-defined function group. This function module can be used toimport the material master data that is assigned to the specifiedfunction group in table TVGVI. For this purpose, the program generatesthe specified function group if it does not exist already. If it doesalready exist, it will be deleted and then regenerated.
The function group control program is set up in the following way:
SAPLXXXX (XXXX = function group)

  • LXXXXTOP (RMMMGTOP is used as a reference for this Include.)

  • RMMMGTO1
    Contains general data definitions that are relevant for each functiongroup.
    LXXXXTAB
    Contains material master structures that, according to TVGVI, areassigned to the function group. It is generated in a similar way toLMATLTAB by program RMGNL021.
    • LXXXXUXX

    • LXXXXU01
      Contains coding that is almost identical for every function module tobe generated. RMMMGU01 is used as the reference for this Include.
      LXXXXCAS
      Contains the central Case loop of the function module. It is generatedin a similar way to LMATLCAS by program RMGNL021.
      LXXXXMTA
      Contains generated coding for determining the material type. This ishard-coded in SAPLMATL.
      Note:
      The "Move-art" field in TVGVI is used to generate this coding. Thisfield was not used in the material master record until now. If thefield contains the value X, the material type will be taken not fromMARA but from the specified DB view.
      • LXXXXFOR

      • Contains subroutines specific to function groups. It is generated in asimilar way to LMATLFOR by program RMGNL021.
        • RMMMGF00

        • Contains subroutines that are independent of function groups and havebeen taken from Include LMATLF01.
          • RMMMGF00

          • Contains subroutines that are independent of function groups and havebeen taken from Include LMATLF01.
            The interface to the function module is structured in a similar way toMATERIAL_READ. However, only those exceptions that are really needed inthe function module are generated.
            Call:
            CALL FUNCTION 'MATERIAL_READ_XXXX'
            EXPORTING SCHLUESSEL = MTCOM
            IMPORTING MATDATEN = Viewtabelle
            RETURN = MTCOR
            TABLES SEQMAT01 = Interne Tabelle
            ( EXCEPTIONS Material_not_found = 1
            . . . )
            Exceptions instruction applies only to required-entry tables (seebelow).
            Required-entry tables:
            If a table marked as a required-entry table does not exist, thefunction module terminates at this point and issues an error message.The error message can be suppressed using the EXCEPTIONS instruction,being replaced with a return code in SY-SUBRC. In both cases (with orwithout EXCEPTIONS), the function module does not produce any data ifan error occurs. You can switch off all required-entry tables for theview dynamically (not individually but as a whole) by setting theMTCOM-NOMUS flag.
            Return codes:
            If the function module runs without an error message, a return codeflag can be queried for each table in structure MTCOR; for example,MTCOR-RMARD = 'X' means that the function module has not succeeded inreading table MARD. If the flag is not set, either the table was readsuccessfully or no attempt was made to read table MARD. Possiblereasons for this are that the table is not in the view or that nostorage location has been defined.
            MTCOR-LVORM:
            This flag is set if the object is flagged for deletion.
            MTCOR-PSTAT/MTCOR-FSTAT:
            If you define a maintenance status in MTCOM, for example,MTCOM-PSTAT='BDE', the system will check whether the Accounting (B),MRP (D), and Purchasing (E) views on the object have been maintained.The results which appear in field MTCOR-PSTAT show which views on theobject are maintained. Thus, MTCOR-PSTAT = 'B' means that theAccounting view on the object is maintained, while MRP and Purchasingdata is not maintained. The results which appear in field MTCOR-FSTATshow which views are not maintained but could potentially be there;that is, the system checks to see whether the material type allows thisparticular view (you would have to do the same for the installed SAPcomponent and/or the selected plant).

            Note
            This check is performance-intensive; if it is not required, thefunction module should always be called up with MTCOM-PSTAT = Space.

            Further comments

            • MTCOM-NOVOR:

            • If a plant is set, but no valuation level or sales organization, thetwo last fields are set automatically by the function module from tableT001W. You can disactivate this function by setting the MTCOM-NOVORflag when you call up the program.
              • MTCOM-KZRFB

              • If this flag is set, the local memory of the function module is reset.This means that if a view with the same key fields is read severaltimes in succession, the relevant data will be retrieved from thedatabase afresh each time.