local_material
Module to prepare local material data for harmonization across systems.
derive_intra_and_inter_primary_key(df)
¶
Derive primary keys for harmonized data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
DataFrame
|
DataFrame with harmonized data. |
required |
Returns:
Name | Type | Description |
---|---|---|
DataFrame |
DataFrame
|
DataFrame with derived primary keys. |
Source code in code\modules\local_material.py
integration(sap_mara, sap_mbew, sap_marc, sap_t001k, sap_t001w, sap_t001)
¶
Integrate data from various SAP tables to create a comprehensive dataset.
DataFrames from the following SAP tables:
○ SAP MARA table (General Material Data) ○ SAP MBEW table (Material Valuation) ○ SAP MARC table (Plant Data for Material) ○ SAP T001K table (Valuation Area) ○ SAP T001W table (Plant/Branch) ○ SAP T001 table (Company Codes)
Transformation
○ Join operations: ▪ sap_marc left join sap_mara on MATNR. ▪ left join sap_t001w on MANDT and WERKS. ▪ left join sap_mbew on MANDT, MATNR, and BWKEY. ▪ left join sap_t001k on MANDT and BWKEY. ▪ left join sap_t001 on MANDT and BUKRS.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sap_mara
|
DataFrame
|
General Material Data. |
required |
sap_mbew
|
DataFrame
|
Material Valuation Data. |
required |
sap_marc
|
DataFrame
|
Plant Data for Material. |
required |
sap_t001k
|
DataFrame
|
Valuation Area Data. |
required |
sap_t001w
|
DataFrame
|
Plant and Branches Data. |
required |
sap_t001
|
DataFrame
|
Company Codes Data. |
required |
Returns:
Name | Type | Description |
---|---|---|
DataFrame |
DataFrame
|
Integrated DataFrame with all necessary information. |
Source code in code\modules\local_material.py
post_prep_local_material(df)
¶
Post-process the integrated DataFrame to create final local material data.
Input Data: Resulting DataFrame from the integration step.
Transformation
○ Create mtl_plant_emd: Concatenate WERKS and NAME1 with a hyphen. ○ Assign global_mtl_id from MATNR or the global material number, as appropriate. ○ Derive two Derive the following keys (intra represents the primary key of one system and inter the primary key the harmonized view.
▪ Primary Key (primary_key_intra): Concatenate MATNR and WERKS.
▪ Primary Key (primary_key_inter): Concatenate SOURCE_SYSTEM_ERP, MATNR, and WERKS.
○ Handle Duplicates: ▪ Add a temporary column no_of_duplicates indicating duplicate counts. ▪ Drop Duplicates based on SOURCE_SYSTEM_ERP, MATNR, and WERKS.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
DataFrame
|
Integrated DataFrame from the integration step. |
required |
Returns:
Name | Type | Description |
---|---|---|
DataFrame |
DataFrame
|
Final DataFrame with post-processed local material data. |
Source code in code\modules\local_material.py
prep_company_codes(df)
¶
Prepare Company Codes data for harmonization across systems.
Input Data: SAP T001 table (Company Codes)
Transformation
○ Select the required columns.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
DataFrame
|
DataFrame with Company Codes data. |
required |
Returns:
Name | Type | Description |
---|---|---|
DataFrame |
DataFrame
|
DataFrame with prepared Company Codes data. |
Raises:
Type | Description |
---|---|
TypeError
|
If the input DataFrame is not a DataFrame. |
Source code in code\modules\local_material.py
prep_general_material_data(df, col_mara_global_material_number, check_old_material_number_is_valid=True, check_material_is_not_deleted=True)
¶
Prepare General Material data for harmonization across systems.
Input Data: SAP MARA table (General Material Data)
Transformation
○ Filter materials: ▪ Old Material Number (BISMT) is not in ["ARCHIVE", "DUPLICATE", "RENUMBERED"] or is null. ▪ Deletion flag (LVORM) is null or empty. ○ Select the required columns. ○ Rename the global material number column to a consistent name, if necessary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
DataFrame
|
DataFrame with General Material data. |
required |
col_mara_global_material_number
|
str
|
Column name with the global material number. |
required |
check_old_material_number_is_valid
|
bool
|
Check if the old material number is valid. |
True
|
check_material_is_not_deleted
|
bool
|
Check if the material is not deleted. |
True
|
Returns:
Name | Type | Description |
---|---|---|
DataFrame |
DataFrame
|
DataFrame with prepared General Material data. |
Raises:
Type | Description |
---|---|
TypeError
|
If the input DataFrame is not a DataFrame. |
TypeError
|
If the column name with the global material number is not a string. |
TypeError
|
If the check for the old material number is not a boolean. |
TypeError
|
If the check for the material deletion flag is not a boolean. |
Source code in code\modules\local_material.py
prep_material_valuation(df)
¶
Prepare Material Valuation data for harmonization across systems.
Input Data: SAP MBEW table (Material Valuation)
Transformation
○ Filter out materials that are flagged for deletion (LVORM is null). ○ Filter for entries with BWTAR (Valuation Type) as null to exclude split valuation materials. ○ Deduplicate records: ▪ Rule take the record having highest evaluated price LAEPR (Last Evaluated Price) at MATNR and BWKEY level
Keep the first record per group. ○ Select the required columns. ○ Drop Duplicates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
DataFrame
|
DataFrame with Material Valuation data. |
required |
Returns:
Name | Type | Description |
---|---|---|
DataFrame |
DataFrame
|
DataFrame with prepared Material Valuation data. |
Raises:
Type | Description |
---|---|
TypeError
|
If the input DataFrame is not a DataFrame. |
Source code in code\modules\local_material.py
prep_plant_and_branches(df)
¶
Prepare Plant and Branches data for harmonization across systems.
Input Data: SAP T001W table (Plant/Branch)
Transformation
○ Select the required columns.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
DataFrame
|
DataFrame with Plant and Branches data. |
required |
Returns:
Name | Type | Description |
---|---|---|
DataFrame |
DataFrame
|
DataFrame with prepared Plant and Branches data. |
Raises:
Type | Description |
---|---|
TypeError
|
If the input DataFrame is not a DataFrame. |
Source code in code\modules\local_material.py
prep_plant_data_for_material(df, check_deletion_flag_is_null, drop_duplicate_records, additional_fields=None)
¶
Prepare Plant data for harmonization across systems.
Input Data: SAP MARC table (Plant Data for Material)
Transformation
○ Filter records where the deletion flag (LVORM) is null. ○ Select the required columns. ○ Drop Duplicates if drop_duplicate_records is True.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
DataFrame
|
DataFrame with Plant data for Material. |
required |
check_deletion_flag_is_null
|
bool
|
Check if the deletion flag is null. |
required |
drop_duplicate_records
|
bool
|
Drop duplicate records |
required |
additional_fields
|
list
|
Additional fields to include in the output DataFrame. |
None
|
Returns:
Name | Type | Description |
---|---|---|
DataFrame |
DataFrame
|
DataFrame with prepared Plant data. |
Raises:
Type | Description |
---|---|
TypeError
|
If the input DataFrame is not a DataFrame. |
TypeError
|
If the check for the deletion flag is not a boolean. |
TypeError
|
If the drop duplicate records flag is not a boolean. |
Source code in code\modules\local_material.py
prep_valuation_data(df)
¶
Prepare Valuation data for harmonization across systems.
Input Data: SAP T001K table (Valuation Area)
Transformation
○ Select the required columns. ○ Drop Duplicates to ensure uniqueness.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
DataFrame
|
DataFrame with Valuation data. |
required |
Returns:
Name | Type | Description |
---|---|---|
DataFrame |
DataFrame
|
DataFrame with prepared Valuation data. |
Raises:
Type | Description |
---|---|
TypeError
|
If the input DataFrame is not a DataFrame. |