11-11-2010 4:10 AM
Hi Experts,
My requirement is to create view for existing material.
Eg : View Accounting1 should be created for some "X" material.
Please let me know which BAPI will hwlp in this regard.
Thank you,
Kavya
11-11-2010 4:48 AM
Hi,
You can use 'BAPI_MATERIAL_SAVEDATA' to update the Accounting View.
Note : This BAPI will create Material if it doensot exist and Update if any materila is exist, so before passing the data to BAPI you should check for the Material Code existaence then only pass the data, as you requirement is to update the Accounting View only.
Thanks & Regards,
Faheem.
11-11-2010 4:56 AM
Hi Faheem,
thanks for the replay.
Now for the material 69263391we have only Basic data1 and Basic data2 as views, but my requirement is to create view "Accounting1".
So i have done the coding as shown
st_headdata-material = '69263391'.
st_headdata-account_view = ca_x.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
HEADDATA = st_headdata
IMPORTING
RETURN = st_return.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
But after execution of this also we have only views Basic data1 and Basic data2, view Accounting1 is not created.
Please let me know how can i create view Accounting1
11-11-2010 1:11 PM
Hi Kavya,
The code which you have written will only select the accounting view, but where is the data you are saving in accounting view?. You have to supply Plant and accounting data like Valuation Class etc then only system will update the accounting view.
Thanks & Regards,
Faheem.
11-12-2010 4:45 AM
Hi Kavya...
You can refer the code below...
REPORT ZMM01_TEST.
TYPE-POOLS: truxs.
*----
T Y P E S
*----
TYPES: BEGIN OF t_master_data,
MATERIAL Type MATNR ,
IND_SECTOR Type MBRSH ,
MATL_TYPE Type MTART ,
PLANT Type WERKS ,
STGE_LOC Type LGORT_D ,
MATL_DESC Type MAKTX ,
BASE_UOM Type MEINS ,
MATL_GROUP Type MATKL ,
DIVISION Type SPART ,
ITEM_CAT Type MTPOS_MARA ,
GROSS_WT Type BRGEW ,
UNIT_OF_WT Type GEWEI ,
NET_WEIGHT Type NTGEW ,
VOLUME Type VOLUM ,
SIZE_DIM Type GROES ,
BASIC_MATL Type WRKST ,
DOCUMENT Type DZEINR ,
DOC_VERS Type DZEIVR ,
PO_UNIT Type BSTME ,
PUR_GROUP Type EKGRP ,
AUTO_P_ORD Type KAUTB ,
"BATCH_MGMT Type XCHPF ,
PUR_VALKEY Type EKWSL ,
"GR_PR_TIME Type WEBAZ ,
COMM_CODE Type STAWN ,
COUNTRYORI Type HERKL ,
MRP_TYPE Type DISMM ,
REORDER_PT Type MINBE ,
MRP_CTRLER Type DISPO ,
LOTSIZEKEY Type DISLS ,
MINLOTSIZE Type BSTMI ,
MAXLOTSIZE Type BSTMA ,
FIXED_LOT Type BSTFE ,
MAX_STOCK Type MABST ,
ROUND_VAL Type BSTRF ,
PROC_TYPE Type BESKZ ,
SPPROCTYPE Type SOBSL ,
ISS_ST_LOC Type LGPRO ,
SLOC_EXPRC Type LGFSB ,
PLND_DELRY Type PLIFZ ,
GR_PR_TIME Type WEBAZ ,
SM_KEY Type FHORI ,
SAFETY_STK Type EISBE ,
PLNG_PLANT Type PRWRK ,
AVAILCHECK Type MTVFP ,
DEP_REQ_ID Type SBDKZ ,
ISSUE_UNIT Type AUSME ,
STGE_BIN Type LGPBE ,
BATCH_MGMT Type XCHPF ,
STGEPERIOD Type MAXLZ ,
STGE_PD_UN Type LZEIH ,
MINREMLIFE Type MHDRZ ,
SHELF_LIFE Type MHDHB ,
PERIOD_IND_EXPIRATION_DATE Type DATTP ,
ROUND_UP_RULE_EXPIRATION_DATE Type RDMHD ,
STOR_PCT Type MHDLP ,
QM_AUTHGRP Type QMATAUTH ,
QM_PROCMNT Type QMPUR ,
CTRL_KEY Type SSQSS ,
Type ART ,
Type AKTIV ,
VAL_CAT Type BWTTY_D ,
VAL_CLASS Type BKLAS ,
PRICE_CTRL Type VPRSV ,
PRICE_UNIT Type PEINH ,
MOVING_PR Type VERPR ,
QTY_STRUCT Type CK_EKALREL ,
ORIG_GROUP Type HRKFT ,
ORIG_MAT Type HKMAT ,
VARIANCE_KEY Type AWSLS ,
PROFIT_CTR Type PRCTR ,
LANGU Type SPRAS,
END OF t_master_data.
*----
I N T E R N A L T A B L E S
*----
DATA:
Internal table of type t_master_data
ist_master_data TYPE TABLE OF t_master_data,
Internal table of type BAPIMATHEAD
ist_headdata TYPE TABLE OF BAPIMATHEAD,
Internal table of type BAPI_MAKT
ist_mat_desc TYPE TABLE OF BAPI_MAKT,
Internal table of type BAPI_MAKT
ist_uom TYPE TABLE OF BAPI_MARM,
Internal table of type BAPI_MAKTX
ist_uom_x TYPE TABLE OF BAPI_MARMX.
*----
G L O B A L V A R I A B L E S
*----
DATA:
Global variable of type truxs_t_text_data
it_raw TYPE truxs_t_text_data.
*----
W O R K A R E A S
*----
DATA:
Work area of type t_master_data
wa_master_data TYPE t_master_data,
Work area of type bapimathead
wa_bapimathead TYPE BAPIMATHEAD,
Work area of type bapi_mara
wa_client_data TYPE BAPI_MARA,
Work area of type bapi_marax
wa_client_data_x TYPE BAPI_MARAX,
Work area of type bapi_marc
wa_plant_data TYPE BAPI_MARC,
Work area of type bapi_marcx
wa_plant_data_x TYPE BAPI_MARCX,
Work area of type bapi_mard
wa_storage_location_data TYPE BAPI_MARD,
Work area of type bapi_mardx
wa_storage_location_data_x TYPE BAPI_MARDX,
Work area of type bapi_mbew
wa_valuation_data TYPE BAPI_MBEW,
Work area of type bapi_mbewx
wa_valuation_data_x TYPE BAPI_MBEWX,
Work area of type bapi_mard
wa_mat_desc TYPE BAPI_MAKT,
Work area of type bapi_marm
wa_uom TYPE BAPI_MARM,
Work area of type bapi_marmx
wa_uom_x TYPE BAPI_MARMX,
Work area of type mbapi_mpgd
wa_planning_data TYPE BAPI_MPGD,
Work area of type mbapi_mpgdx
wa_planning_data_x TYPE BAPI_MPGDX,
Work area of type mbapi_mpgd
wa_return TYPE BAPIRET2.
*----
P A R A M E T E R S
*----
PARAMETERS:
Parameter of type rlgrap-filename
p_file TYPE rlgrap-filename.
***********************************************************************
A T S E L E C T I O N S C R E E N
***********************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
field_name = 'P_FILE'
IMPORTING
file_name = p_file.
***********************************************************************
S T A R T - O F - S E L E C T I O N.
***********************************************************************
START-OF-SELECTION.
To upload data from flat file
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_line_header = 'X'
i_tab_raw_data = it_raw " WORK TABLE
i_filename = p_file
TABLES
i_tab_converted_data = ist_master_data[] "ACTUAL DATA
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc = 0.
LOOP AT ist_master_data INTO wa_master_data.
MOVE-CORRESPONDING wa_master_data to wa_bapimathead.
MOVE-CORRESPONDING wa_master_data to wa_client_data.
wa_client_data_x-MATL_GROUP = 'X'.
wa_client_data_x-BASE_UOM = 'X'.
wa_client_data_x-PO_UNIT = 'X'.
wa_client_data_x-DOCUMENT = 'X'.
wa_client_data_x-SIZE_DIM = 'X'.
wa_client_data_x-BASIC_MATL = 'X'.
wa_client_data_x-PUR_VALKEY = 'X'.
wa_client_data_x-NET_WEIGHT = 'X'.
wa_client_data_x-UNIT_OF_WT = 'X'.
wa_client_data_x-DIVISION = 'X'.
wa_client_data_x-BATCH_MGMT = 'X'.
wa_client_data_x-QM_PROCMNT = 'X'.
wa_client_data_x-MINREMLIFE = 'X'.
wa_client_data_x-SHELF_LIFE = 'X'.
wa_client_data_x-STOR_PCT = 'X'.
wa_client_data_x-ROUND_UP_RULE_EXPIRATION_DATE = 'X'.
wa_client_data_x-PERIOD_IND_EXPIRATION_DATE = 'X'.
wa_client_data_x-ITEM_CAT = 'X'.
MOVE-CORRESPONDING wa_master_data to wa_plant_data.
wa_plant_data_x-PLANT = wa_master_data-plant.
wa_plant_data_x-PUR_GROUP = 'X'.
wa_plant_data_x-ISSUE_UNIT = 'X'.
wa_plant_data_x-MRP_TYPE = 'X'.
wa_plant_data_x-MRP_CTRLER = 'X'.
wa_plant_data_x-PLND_DELRY = 'X'.
wa_plant_data_x-GR_PR_TIME = 'X'.
wa_plant_data_x-LOTSIZEKEY = 'X'.
wa_plant_data_x-PROC_TYPE = 'X'.
wa_plant_data_x-SPPROCTYPE = 'X'.
wa_plant_data_x-SAFETY_STK = 'X'.
wa_plant_data_x-MINLOTSIZE = 'X'.
wa_plant_data_x-MAXLOTSIZE = 'X'.
wa_plant_data_x-FIXED_LOT = 'X'.
wa_plant_data_x-ROUND_VAL = 'X'.
wa_plant_data_x-MAX_STOCK = 'X'.
wa_plant_data_x-DEP_REQ_ID = 'X'.
wa_plant_data_x-SM_KEY = 'X'.
wa_plant_data_x-STGEPERIOD = 'X'.
wa_plant_data_x-STGE_PD_UN = 'X'.
wa_plant_data_x-CTRL_KEY = 'X'.
wa_plant_data_x-BATCH_MGMT = 'X'.
wa_plant_data_x-AVAILCHECK = 'X'.
wa_plant_data_x-AUTO_P_ORD = 'X'.
wa_plant_data_x-COMM_CODE = 'X'.
wa_plant_data_x-COUNTRYORI = 'X'.
wa_plant_data_x-PROFIT_CTR = 'X'.
wa_plant_data_x-ISS_ST_LOC = 'X'.
wa_plant_data_x-VARIANCE_KEY = 'X'.
wa_plant_data_x-SLOC_EXPRC = 'X'.
wa_plant_data_x-QM_AUTHGRP = 'X'.
MOVE-CORRESPONDING wa_master_data to wa_planning_data.
wa_planning_data_x-PLANT = wa_master_data-plant.
wa_planning_data_x-PLNG_PLANT = 'X'.
MOVE-CORRESPONDING wa_master_data to wa_storage_location_data.
wa_storage_location_data_X-PLANT = wa_master_data-plant.
wa_storage_location_data_X-STGE_LOC = wa_master_data-stge_loc.
wa_storage_location_data_X-STGE_BIN = 'X'.
MOVE-CORRESPONDING wa_master_data to wa_valuation_data.
wa_valuation_data-VAL_AREA = '1000'.
wa_valuation_data_X-VAL_AREA = '1000'.
wa_valuation_data_X-PRICE_CTRL = 'X'.
wa_valuation_data_X-MOVING_PR = 'X'.
wa_valuation_data_X-PRICE_UNIT = 'X'.
wa_valuation_data_X-VAL_CLASS = 'X'.
wa_valuation_data_X-ORIG_GROUP = 'X'.
wa_valuation_data_X-QTY_STRUCT = 'X'.
wa_valuation_data_X-ORIG_MAT = 'X'.
MOVE-CORRESPONDING wa_master_data to wa_mat_desc.
APPEND wa_mat_desc to ist_mat_desc.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
HEADDATA = wa_bapimathead
CLIENTDATA = wa_client_data
CLIENTDATAX = wa_client_data_x
PLANTDATA = wa_plant_data
PLANTDATAX = wa_plant_data_X
PLANNINGDATA = wa_planning_data
PLANNINGDATAX = wa_planning_data_x
STORAGELOCATIONDATA = wa_storage_location_data
STORAGELOCATIONDATAX = wa_storage_location_data_x
VALUATIONDATA = wa_valuation_data
VALUATIONDATAX = wa_valuation_data_x
IMPORTING
RETURN = wa_return
TABLES
MATERIALDESCRIPTION = ist_mat_desc.
Write:/ wa_return-message.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDLOOP.
ELSE.
Write:/ text-001.
ENDIF.
11-12-2010 6:23 AM
Hi shraddha,
Thanks for your reply.
My requirement is to create view for already existing material.
if material "X" doesn't have ACCOUNTING 1 then i need to create view ACCOUNTING 1, but i was checking to create this by passing ACCOUNT_VIEW = X and to pass required data to Valuation Data from MBEW table.
But for the particular material "X" i don't have any records in MBEW table.
So can you please let me know how i can create accounting view for already existing material
Thank you
11-12-2010 7:16 AM
Hi Kavya,
You have a material that has already been created and for that you have to add a view...
This can be possible through this BAPI BAPI_MATERIAL_SAVEDATA
I am only telling you after trying this. Create a material in MM01 with only the Basic Data 1 and 2.
Now if you use this BAPI to enter data in any other view,the data will be added.
You use this BAPI to create new material master data or to change existing material master data.
Try using this...if you face any problem let me know
Regards,
Shraddha
11-12-2010 9:51 AM
>
>
> My requirement is to create view for already existing material.
> if material "X" doesn't have ACCOUNTING 1 then i need to create view ACCOUNTING 1, but i was checking to create this by passing ACCOUNT_VIEW = X and to pass required data to Valuation Data from MBEW table.
>
> Thank you
Accounting 1 view data is stored in table MBEW, but if you want create accounting 1 view, then it is obvious that MBEW has no record to pull the data from.
11-18-2010 10:14 AM
Hi Shraddha,
Thanks again for your reply, i solved my issue,
now i am facing another problem, please help me in the above issue
my requirement is to create only MRP 1 view and i am passing Min Lot Size,Rounding Val,MRP Type (MARC-DISMM)
Planning time fence (MARC-FXHOR),MRP Controller (MARC-DISPO) and Lot size (MARC-DISLS)
But the BAPI is showing the message to pass availabality check (can be seen in MRP4) and SchedMargin key(can be seen in MRP2).
If i don't pass the above then the view won't be created and if i pass then all MRP1, MRP2,MRP3 and MRP4 will be created
So do we have any other way to create only MRP1 view
Thank you,
Kavya
11-18-2010 12:53 PM
why do you try to do something with BAPI what cannot even be done manually in MM01 ?
11-19-2010 4:04 AM
Hi,
thanks for your reply,
can you please let me know what are the mandatory fields we need to have while creating MRP view
11-19-2010 4:19 AM
Hi Kavya,
Keeping fields Mandatory depends on custoizing, what Mandatory fields I have here in my system may/ may not match with your system. So, ask your functional consultant, what fields are mandatory.
Thanks & Regards,
Faheem.
11-19-2010 8:51 AM
easiest way to get knowledge about this is to execute the transaction manually before developing programs for mass maintenance.
Mandatory fields have a question mark, without entering a value SAP will not let you proceed to the next screen.
So just use MM01 to find it out.
MRP screens are highly dynamical. this means fields become mandatory or optional based on values entered in other fields.