06-27-2006 6:35 PM
Hi,
I'm using "MATERIAL_MAINTAIN_DARK" and i'd like to activate some views "ACCOUNTING VIEW","PURCHASING VIEW","BASIC DATA","STORAGE VIEW","SALES1","SALES2","SALES/PLANT DATA VIEW" when creating a material. Any ideas ?
Thx in advance.
06-27-2006 6:39 PM
<b>FYI</b>
FU MATERIAL_MAINTAIN_DARK
____________________________________________________
Material Master Maintenance Without Screens
You can call up this function module from any application you like. Special initiators, such as material group maintenance or CAD, must identify themselves using the parameter CALL_MODE or CALL_MODE2. Special processing exists for these cases, for example, material number assignment.
The material data to be maintained is transferred using tables AMARA_UEB, AMARC_UEB, and so on, in internal format.
The data is processed in logical transactions; that is, only data that can be created or changed jointly in an online transaction is created or changed jointly.
An AMARA_UEB record must exist for each of these logical transactions.
For this reason, a transaction code (Create Material or Change Material) must also be transferred for each MARA record.
In addition, a unique transaction counter must also be transferred - also to dependent tables AMARC_UEB, and so on. This transaction counter groups together the related records in the tables. (The material number cannot do this with internal number assignment.)
All related MAKT and MARM records can be transferred for a record in AMARA_UEB as well as a
MARC record
MBEW record (must be consonant with MARC in accordance with the assignment of plant to valuation key)
MARD record for the MARC record
MVKE record and all MLAN records for the MVKE record
MLGN record
MLGT record for the MLGN record
With regard to MLAN, please note that MLAN records are logically linked to the combination of sales organization and distribution channel via the country. You can therefore maintain only those records that are consonant with the MVKE record (can be determined with function module Steuertab_Identify). To transfer MLAN data, MVKE must always be transferred.
For an AMARA_UEB record, you can also transfer all related
MVEG records (total consumption)
MVEU records (unplanned consumption)
LTX1 records (long texts)
MPRW records (forecast values)
Notes
The extension of a material previously created with an internal number is recognized as before by the special material number '0 '. In this case, the special material number is replaced with the previously determined internal number. The initiator must ensure that materials with an internal number are created and extended within a call package.
The commit work must be carried out by the initiator.
KZ_MATNR_RES is used to determine whether the material number has already been reserved. In this case, the material number is treated like an internal number; in particular, no check is made to see whether the material already exists.
Fields that are to be reset to their initial value are transferred using exception table AMFIELDRES.
The successfully updated records are removed from the transfer tables.
If you want to transfer the maintenance statuses to be maintained, you must fill field VPSTA in table MARA accordingly.
The maintenance statuses possible are as follows:
Maintenance status Description
A Work scheduling
B Accounting
C Classification
D MRP
E Purchasing
F Production resources/tools
G Costing
K Basic data
L Storage
P Forecasting
Q Quality management
S Warehouse management
V Sales
If you do not specify a maintenance status, the system determines it automatically from the maintenance status determination type.
The following data is not supported:
Document data
Execution of forecasts
Average plant stock
Scheduling of changes
Production versions
Classification
Joint production
Units of measure group
QM inspection data
Revision level
Sales price
Reference material
Customs tariff preferences and export licenses
Assignment of configurable material and respective variant configuration
Appendix
The material master "thinks" in the combinations of material master table and maintenance status. The combinations to be maintained are determined for each maintenance transaction from the data transferred. There are several maintenance status determination types (which can currently be specified for each transaction type in Customizing). For more information, see the documentation on the maintenance status determination type.
In the standard SAP R/3 System, the third determination type is currently used.
This has the following consequences:
A maintenance status is not created if a single status field has not been transferred for it and if all other fields for the status are already covered by the creation of other maintenance statuses. This can also result in a complete table entry not being created (for example, MLGN/MLGT - only a single maintenance status).
Normally, this has no effect since the maintained views of productively used materials contain sufficient entries.
If accounting data is transferred, the maintenance statuses Accounting and Costing are both created since all accounting fields have both maintenance statuses. (You must have sufficient authorization for this, otherwise only the status for which you are authorized will be created.)
This is of practical value since there are two separate maintenance statuses essentially for authorization reasons. The data maintained in the Costing view is only proposed in the Accounting view.
If warehouse management data is transferred in another transaction separately from the relevant plant, the corresponding MARC is not given the maintenance status Warehouse Management.
If document management is active and if document data fields are transferred, they are included in table MARA. This contrasts with the old batch input method, where this was not possible due to either the documents subscreen or the MARA drawing fields subscreen being active.
Reference data is used for all relevant tables/maintenance statuses (only for fields on the processed screen in the old material master). This concerns the following in particular:
Defaults from the MRP profile or forecast profile
Variance key from T001W for costing
Product hierarchy in MVKE from product hierarchy in MARA (general departure from the old material master)
Parameters
FLAG_MUSS_PRUEFEN
SPERRMODUS
MAX_ERRORS
P_KZ_NO_WARN
KZ_PRF
KZ_VERW
KZ_AEND
KZ_DISPO
KZ_TEST
NO_DATABASE_UPDATE
CALL_MODE
CALL_MODE2
USER
SUPPRESS_ARRAY_READ
FLG_MASS
MATNR_LAST
NUMBER_ERRORS_TRANSACTION
AMARA_UEB
AMAKT_UEB
AMARC_UEB
AMARD_UEB
AMFHM_UEB
AMARM_UEB
AMEA1_UEB
AMBEW_UEB
ASTEU_UEB
ASTMM_UEB
AMLGN_UEB
AMLGT_UEB
AMPGD_UEB
AMPOP_UEB
AMVEG_UEB
AMVEU_UEB
AMVKE_UEB
ALTX1_UEB
AMPRW_UEB
AE1CUCFG_UEB
AE1CUINS_UEB
AE1CUVAL_UEB
AE1CUCOM_UEB
AMFIELDRES
AMERRDAT
Exceptions
KSTATUS_EMPTY
TKSTATUS_EMPTY
T130M_ERROR
INTERNAL_ERROR
TOO_MANY_ERRORS
UPDATE_ERROR
Function Group
MGMD
Hope thisll give you idea!!
<b>Pl... award the points.</b>
Good luck
Thanks
Saquib Khan
"Some are wise and some are otherwise"
06-27-2006 6:39 PM
06-27-2006 6:45 PM
Thx for the answer, i'm not using the bapi 'caus we've aditional fields (not master) and need to fill them. I'm filling all the information needed by the views, the question is? Is that enough ?
06-27-2006 6:39 PM
<b>FYI</b>
FU MATERIAL_MAINTAIN_DARK
____________________________________________________
Material Master Maintenance Without Screens
You can call up this function module from any application you like. Special initiators, such as material group maintenance or CAD, must identify themselves using the parameter CALL_MODE or CALL_MODE2. Special processing exists for these cases, for example, material number assignment.
The material data to be maintained is transferred using tables AMARA_UEB, AMARC_UEB, and so on, in internal format.
The data is processed in logical transactions; that is, only data that can be created or changed jointly in an online transaction is created or changed jointly.
An AMARA_UEB record must exist for each of these logical transactions.
For this reason, a transaction code (Create Material or Change Material) must also be transferred for each MARA record.
In addition, a unique transaction counter must also be transferred - also to dependent tables AMARC_UEB, and so on. This transaction counter groups together the related records in the tables. (The material number cannot do this with internal number assignment.)
All related MAKT and MARM records can be transferred for a record in AMARA_UEB as well as a
MARC record
MBEW record (must be consonant with MARC in accordance with the assignment of plant to valuation key)
MARD record for the MARC record
MVKE record and all MLAN records for the MVKE record
MLGN record
MLGT record for the MLGN record
With regard to MLAN, please note that MLAN records are logically linked to the combination of sales organization and distribution channel via the country. You can therefore maintain only those records that are consonant with the MVKE record (can be determined with function module Steuertab_Identify). To transfer MLAN data, MVKE must always be transferred.
For an AMARA_UEB record, you can also transfer all related
MVEG records (total consumption)
MVEU records (unplanned consumption)
LTX1 records (long texts)
MPRW records (forecast values)
Notes
The extension of a material previously created with an internal number is recognized as before by the special material number '0 '. In this case, the special material number is replaced with the previously determined internal number. The initiator must ensure that materials with an internal number are created and extended within a call package.
The commit work must be carried out by the initiator.
KZ_MATNR_RES is used to determine whether the material number has already been reserved. In this case, the material number is treated like an internal number; in particular, no check is made to see whether the material already exists.
Fields that are to be reset to their initial value are transferred using exception table AMFIELDRES.
The successfully updated records are removed from the transfer tables.
If you want to transfer the maintenance statuses to be maintained, you must fill field VPSTA in table MARA accordingly.
The maintenance statuses possible are as follows:
Maintenance status Description
A Work scheduling
B Accounting
C Classification
D MRP
E Purchasing
F Production resources/tools
G Costing
K Basic data
L Storage
P Forecasting
Q Quality management
S Warehouse management
V Sales
If you do not specify a maintenance status, the system determines it automatically from the maintenance status determination type.
The following data is not supported:
Document data
Execution of forecasts
Average plant stock
Scheduling of changes
Production versions
Classification
Joint production
Units of measure group
QM inspection data
Revision level
Sales price
Reference material
Customs tariff preferences and export licenses
Assignment of configurable material and respective variant configuration
Appendix
The material master "thinks" in the combinations of material master table and maintenance status. The combinations to be maintained are determined for each maintenance transaction from the data transferred. There are several maintenance status determination types (which can currently be specified for each transaction type in Customizing). For more information, see the documentation on the maintenance status determination type.
In the standard SAP R/3 System, the third determination type is currently used.
This has the following consequences:
A maintenance status is not created if a single status field has not been transferred for it and if all other fields for the status are already covered by the creation of other maintenance statuses. This can also result in a complete table entry not being created (for example, MLGN/MLGT - only a single maintenance status).
Normally, this has no effect since the maintained views of productively used materials contain sufficient entries.
If accounting data is transferred, the maintenance statuses Accounting and Costing are both created since all accounting fields have both maintenance statuses. (You must have sufficient authorization for this, otherwise only the status for which you are authorized will be created.)
This is of practical value since there are two separate maintenance statuses essentially for authorization reasons. The data maintained in the Costing view is only proposed in the Accounting view.
If warehouse management data is transferred in another transaction separately from the relevant plant, the corresponding MARC is not given the maintenance status Warehouse Management.
If document management is active and if document data fields are transferred, they are included in table MARA. This contrasts with the old batch input method, where this was not possible due to either the documents subscreen or the MARA drawing fields subscreen being active.
Reference data is used for all relevant tables/maintenance statuses (only for fields on the processed screen in the old material master). This concerns the following in particular:
Defaults from the MRP profile or forecast profile
Variance key from T001W for costing
Product hierarchy in MVKE from product hierarchy in MARA (general departure from the old material master)
Parameters
FLAG_MUSS_PRUEFEN
SPERRMODUS
MAX_ERRORS
P_KZ_NO_WARN
KZ_PRF
KZ_VERW
KZ_AEND
KZ_DISPO
KZ_TEST
NO_DATABASE_UPDATE
CALL_MODE
CALL_MODE2
USER
SUPPRESS_ARRAY_READ
FLG_MASS
MATNR_LAST
NUMBER_ERRORS_TRANSACTION
AMARA_UEB
AMAKT_UEB
AMARC_UEB
AMARD_UEB
AMFHM_UEB
AMARM_UEB
AMEA1_UEB
AMBEW_UEB
ASTEU_UEB
ASTMM_UEB
AMLGN_UEB
AMLGT_UEB
AMPGD_UEB
AMPOP_UEB
AMVEG_UEB
AMVEU_UEB
AMVKE_UEB
ALTX1_UEB
AMPRW_UEB
AE1CUCFG_UEB
AE1CUINS_UEB
AE1CUVAL_UEB
AE1CUCOM_UEB
AMFIELDRES
AMERRDAT
Exceptions
KSTATUS_EMPTY
TKSTATUS_EMPTY
T130M_ERROR
INTERNAL_ERROR
TOO_MANY_ERRORS
UPDATE_ERROR
Function Group
MGMD
Hope thisll give you idea!!
<b>Pl... award the points.</b>
Good luck
Thanks
Saquib Khan
"Some are wise and some are otherwise"
06-27-2006 6:41 PM
also look at threads
http://projectmanagement.ittoolbox.com/groups/technical-functional/SAP-R3-LOG-MM/262781#
http://www.4ap.de/abap/material_maintain_dark.php
FYI
*Die itab_marc enthält die anzulegenden Lagerorte in den Werken.
*itab_marc-matnr
*itab_marc-werks
*itab_marc-lgort
Sie wird im Vorfeld gefüllt. Nachfolgend nur die wichtigsten
Datendeklarationen und das entscheidende Coding
*#############
Datendeklarationen
TABLES: marc.
DATA:
BEGIN OF itab_marc OCCURS 0,
matnr LIKE marc-matnr,
werks LIKE marc-werks,
lgfsb LIKE marc-lgfsb,
lgpro LIKE marc-lgpro,
lgort LIKE mard-lgort,
mtart like mara-mtart,
END OF itab_marc,
count_itab TYPE i.
Fehlerauswertung
DATA: BEGIN OF fehler_tab OCCURS 0, " Tabelle für Fehlermeldungen
line LIKE sy-lisel, " 255 Char
END OF fehler_tab,
returncode(2).
an den Fubau MATERIAL_MAINTAIN_DARK zu übergebende Daten
DATA:
amara_ueb LIKE mara_ueb OCCURS 0 WITH HEADER LINE,
amarc_ueb LIKE marc_ueb OCCURS 0 WITH HEADER LINE,
amard_ueb LIKE mard_ueb OCCURS 0 WITH HEADER LINE,
amerrdat LIKE merrdat OCCURS 0 WITH HEADER LINE,
vom Fubau MATERIAL_MAINTAIN_DARK beschriebene Daten
matnr_last LIKE mara-matnr,
matnr_last_save LIKE mara-matnr,
number_errors_transaction LIKE tbist-numerror,
blank,
fest_x VALUE 'X',
fest_e VALUE 'E',
zaehler LIKE amard_ueb-tranc. " jede Zeile = ein Material
<SNIP>
*----
*
Form lager_anlegen
*----
*
FORM lager_anlegen.
LOOP AT itab_marc.
erstmal alles löschen
clear:
amara_ueb, amarc_ueb, amard_ueb,
fehler_tab, amerrdat,
zaehler, matnr_last_save.
refresh:
amara_ueb, amarc_ueb, amard_ueb,
fehler_tab, amerrdat.
zaehler = zaehler + 1.
amara_ueb-mandt = sy-mandt.
amara_ueb-matnr = itab_marc-matnr.
amara_ueb-tcode = 'MM01'. " Transaktionscode nicht vergessen!!!
amara_ueb-tranc = zaehler. " Zuordnung Zeilen = Material
APPEND amara_ueb.
amarc_ueb-mandt = sy-mandt.
amarc_ueb-matnr = amara_ueb-matnr.
amarc_ueb-werks = itab_marc-werks.
amarc_ueb-tranc = zaehler.
es muss mindestens ein Feldinhalt geändert werden!!!
sonst wird ein weiteres Werk nicht angelegt
amarc_ueb-KZKRI = 'X'. " Kennzeichen: kritisches Teil
das Kennzeichen wird später wieder entfernt!
APPEND amarc_ueb.
amard_ueb-mandt = sy-mandt.
amard_ueb-matnr = amara_ueb-matnr.
amard_ueb-werks = amarc_ueb-werks.
amard_ueb-lgort = itab_marc-lgort.
amard_ueb-tranc = zaehler.
es muss mindestens ein Feldinhalt geändert werden!!!
sonst wird ein weiteres Lager nicht angelegt
amard_ueb-LFGJA = '2004'. " Geschäftsjahr der laufenden Periode
APPEND amard_ueb.
letze matnr speichern
matnr_last_save = amara_ueb-matnr.
*break-point.
Materialstammpflege ohne Bilder
Der Funktionsbaustein kann aus jeder beliebigen Anwendung heraus
aufgerufen werden.
Die Übergabe der zu pflegenden Materialdaten erfolgt mittels der
Tabellen AMARA_UEB, AMARC_UEB, ... im internen Format.
CALL FUNCTION 'MATERIAL_MAINTAIN_DARK'
EXPORTING
kz_activ_cad = blank
flag_muss_pruefen = fest_x
sperrmodus = fest_e
max_errors = 0 " Anzahl akzeptierte fehler
p_kz_no_warn = fest_x
kz_prf = blank
kz_verw = fest_x
kz_aend = fest_x
kz_dispo = fest_x
kz_test = blank
kz_mdip = blank
kz_mprp = blank
kz_ale = blank
kz_actv = blank
IMPORTING
matnr_last = matnr_last " letzte prozessierte MATNR
number_errors_transaction = number_errors_transaction
TABLES
amara_ueb = amara_ueb " Materialstamm: allgemeine Daten
AMAKT_UEB = AMAKT_UEB " Materialkurztexte
amarc_ueb = amarc_ueb " Materialstamm-C-Segment
amard_ueb = amard_ueb " Materialstamm-Lager/Chargen-Segment
AMFHM_UEB = " FHM-Felder im Materialstamm
AMARM_UEB = " Mengeneinheiten
AMEA1_UEB = " Verwaltung der EANs zum Material:DI
AMBEW_UEB = AMBEW_UEB " Materialbewertung
ASTEU_UEB = " für Steuern: Datenübernahme
ASTMM_UEB = "
AMLGN_UEB = " Materialdaten pro Lagernummer
AMLGT_UEB = " Materialdaten pro Lagertyp
AMPGD_UEB = " Änderungsbelegstruktur für Material-
stamm/Produktgruppe
AMPOP_UEB = " Prognoseparameter
AMVEG_UEB = " Materialstamm: Gesamtsverbräuche
AMVEU_UEB = " Materialstamm: ungeplante Verbräuche
AMVKE_UEB = AMVKE_UEB " Materialstamm: Verkaufsdaten
ALTX1_UEB = " Datenübernahme: Datenteil Langtexte
AMPRW_UEB = " Datenübernahme: Prognosewerte
AMFIELDRES = " Felder, die pro Transaktion zu
" initialisieren sind
amerrdat = amerrdat " Struktur für Rückgabe von Fehlermeld.
EXCEPTIONS
kstatus_empty = 1
tkstatus_empty = 2
t130m_error = 3
internal_error = 4
too_many_errors = 5
update_error = 6
OTHERS = 7.
Auswertung
IF sy-subrc NE 0.
MOVE sy-subrc TO returncode.
CONCATENATE 'MATERIAL_MAINTAIN_DARK:'(004)
returncode
INTO fehler_tab-line SEPARATED BY ' '.
APPEND fehler_tab.
ELSE.
COMMIT WORK.
ENDIF.
IF NOT matnr_last = matnr_last_save.
das darf eigentlich nicht passieren! Dann ganze Verarbeitung fehlerh.
CONCATENATE 'MATERIAL_MAINTAIN_DARK:'(004)
'Materialnummern ungleich'(005) itab_marc-matnr
itab_marc-mtart matnr_last
INTO fehler_tab-line SEPARATED BY ' '.
APPEND fehler_tab.
ELSE. " NOT matnr_last = matnr_last_save
das war also eine erfolgreiche Verbuchung!!!
Kennzeichen hart zurücksetzen
*TNT
*break-point.
SELECT SINGLE * FROM marc CLIENT SPECIFIED
WHERE mandt = sy-mandt
AND matnr = matnr_last_save
AND werks = itab_marc-werks.
clear: marc-KZKRI.
update marc.
ENDIF. " NOT matnr_last = matnr_last_save
IF NOT number_errors_transaction IS INITIAL.
CONCATENATE 'MATERIAL_MAINTAIN_DARK:'(004)
'Anzahl Fehler:'(007) number_errors_transaction
INTO fehler_tab-line SEPARATED BY ' '.
APPEND fehler_tab.
ENDIF. " number_errors_transaction is initial
IF NOT amerrdat[] IS INITIAL.
Auswertung der Antwort
CONCATENATE 'MATERIAL_MAINTAIN_DARK:'(004)
'Meldungsliste'(006)
itab_marc-matnr itab_marc-werks
itab_marc-mtart
itab_marc-lgfsb itab_marc-lgpro
itab_marc-lgort
INTO fehler_tab-line SEPARATED BY ' '.
APPEND fehler_tab.
DATA: amerrdat_index(3).
LOOP AT amerrdat.
MOVE sy-tabix TO amerrdat_index.
Fehlermeldung nachschlagen
CALL FUNCTION 'RPY_MESSAGE_COMPOSE'
EXPORTING
language = sy-langu
message_id = amerrdat-msgid
message_number = amerrdat-msgno
message_var1 = amerrdat-msgv1
message_var2 = amerrdat-msgv2
message_var3 = amerrdat-msgv3
message_var4 = amerrdat-msgv4
IMPORTING
message_text = sy-lisel " fehler_tab-line
tables
longtext =
EXCEPTIONS
message_not_found = 1
OTHERS = 2.
IF sy-subrc = 0.
CONCATENATE amerrdat_index sy-lisel
INTO fehler_tab-line SEPARATED BY blank.
APPEND fehler_tab.
ELSE.
CONCATENATE 'RPY_MESSAGE_COMPOSE'(008) amerrdat_index
amerrdat-msgid amerrdat-msgno amerrdat-msgv1(10)
amerrdat-msgv2(10) amerrdat-msgv3(10) amerrdat-msgv4(10)
INTO fehler_tab-line SEPARATED BY ' '.
APPEND fehler_tab.
ENDIF.
ENDLOOP. " at amerrdat
APPEND INITIAL LINE TO fehler_tab.
ENDIF. " not amerrdat[] is initial
LOOP AT fehler_tab.
WRITE / fehler_tab.
ENDLOOP.
uline.
*TNT
*break-point.
ENDLOOP. " at itab_marc
ENDFORM. " lager_anlegen
OR
message-id zkwm
line-count 64
LINE-SIZE 500.
data: tmara_ueb like mara_ueb occurs 100 with header line.
data: tmakt_ueb like makt_ueb occurs 100 with header line.
data: tamerrdat like merrdat occurs 100 with header line.
start-of-selection.
tmara_ueb-mandt = '500'.
tmara_ueb-matnr = 'XISCO2610'.
tmara_ueb-tcode = 'MM02'.
tmara_ueb-tranc = 1.
tmakt_ueb-mandt = '500'.
tmakt_ueb-matnr = 'XISCO2610'.
tmakt_ueb-spras = 'EN'.
tmakt_ueb-maktx = 'test description dark'.
tmakt_ueb-maktg = 'TEST DESCRIPTION DARK'.
tmakt_ueb-tranc = 1.
CALL FUNCTION 'MATERIAL_MAINTAIN_DARK'
EXPORTING
FLAG_MUSS_PRUEFEN = 'X'
SPERRMODUS = 'E'
MAX_ERRORS = 0
P_KZ_NO_WARN = 'N'
KZ_PRF = 'S'
KZ_VERW = 'X'
KZ_AEND = 'X'
KZ_DISPO = 'X'
KZ_TEST = ' '
NO_DATABASE_UPDATE = ' '
CALL_MODE = ' '
CALL_MODE2 = ' '
USER = SY-UNAME
SUPPRESS_ARRAY_READ = ' '
FLG_MASS = ' '
TABLES
AMARA_UEB = TMARA_UEB
AMAKT_UEB = TMAKT_UEB
AMERRDAT = TAMERRDAT
EXCEPTIONS
KSTATUS_EMPTY = 1
TKSTATUS_EMPTY = 2
T130M_ERROR = 3
INTERNAL_ERROR = 4
TOO_MANY_ERRORS = 5
UPDATE_ERROR = 6
ERROR_MESSAGE = 8
OTHERS = 7.
*TMERRDAT-TRANC = INIT_TRANC.
TMERRDAT-MATNR = HEADDATA-MATERIAL.
TMERRDAT-MSGTY = MESSAGE_ERROR.
TAMERRDAT-MSGID = SY-MSGID.
TAMERRDAT-MSGNO = SY-MSGNO.
TAMERRDAT-MSGV1 = SY-MSGV1.
TAMERRDAT-MSGV2 = SY-MSGV2.
TAMERRDAT-MSGV3 = SY-MSGV3.
TAMERRDAT-MSGV4 = SY-MSGV4.
APPEND TAMERRDAT.
IF SY-SUBRC NE 0.
ROLLBACK WORK.
ELSE.
CALL FUNCTION 'DB_COMMIT'.
ENDIF.</b>
Thanks
Saquib
02-16-2007 2:57 PM