BAPI上传物料主数据

本方法是利用BAPI:BAPI_MATERIAL_SAVEDATA 来上传物料。
?? 按照SAP物料主数据视图进行切割上传文件,将待上传的主数据分别放在多个文件进行上传。
????源代码如下:
????
????TABLES : mara,mbew,marc,mard,mvke,marm.
????DATA f_file LIKE rlgrap-filename.
????CONSTANTS c(1) VALUE 'X' .
????DATA : result LIKE sy-subrc .
????DATA : view_n TYPE string.
????CONSTANTS :
???? f_basic LIKE rlgrap-filename VALUE 'MM_IM_Basic.txt',
???? f_plant LIKE rlgrap-filename VALUE 'MM_IM_Plant.txt',
???? f_sales LIKE rlgrap-filename VALUE 'MM_IM_Sales.txt',
???? f_storage LIKE rlgrap-filename VALUE 'MM_IM_Storage.txt',
???? f_valuation LIKE rlgrap-filename VALUE 'MM_IM_Valuation.txt',
???? f_uom LIKE rlgrap-filename VALUE 'MM_IM_UOM.txt',
???? f_tax LIKE rlgrap-filename VALUE 'MM_IM_Tax.txt',
???? f_classification LIKE rlgrap-filename
???? VALUE 'MM_IM_CLASSIFICATION.txt'.
????DATA: bapi_head LIKE bapimathead,
???? bapi_makt LIKE bapi_makt, "Material Description
???? bapi_mara1 LIKE bapi_mara, "Client Data
???? bapi_marax LIKE bapi_marax,
???? bapi_mvke1 LIKE bapi_mvke, "Sales view
???? bapi_mvkex1 LIKE bapi_mvkex,
???? bapi_marc1 LIKE bapi_marc, "Plant View
???? bapi_marcx1 LIKE bapi_marcx,
???? bapi_mbew1 LIKE bapi_mbew, "Accounting View
???? bapi_mbewx1 LIKE bapi_mbewx,
???? bapi_mpgd1 LIKE bapi_mpgd, "Planning view
???? bapi_mpgdx1 LIKE bapi_mpgdx,
???? bapi_mard1 LIKE bapi_mard, "Storage location
???? bapi_mardx1 LIKE bapi_mardx,
???? bapi_return LIKE bapiret2, "Return Parameter
???? bapi_return1 LIKE bapireturn1.
????DATA : longtext(130) TYPE c .
????*material descriptions.
????DATA: BEGIN OF int_makt OCCURS 100.
???? INCLUDE STRUCTURE bapi_makt.
????DATA: END OF int_makt.
????*units of measure .
????DATA: BEGIN OF int_marm OCCURS 100.
???? INCLUDE STRUCTURE bapi_marm.
????DATA: END OF int_marm.
????*information on updata for units of measue
????DATA: BEGIN OF int_marmx OCCURS 100.
???? INCLUDE STRUCTURE bapi_marmx.
????DATA: END OF int_marmx.
????*international acticle numbers
????DATA: BEGIN OF int_mean OCCURS 100.
???? INCLUDE STRUCTURE bapi_mean.
????DATA: END OF int_mean.
????*long text
????DATA: BEGIN OF int_mltx OCCURS 100.
???? INCLUDE STRUCTURE bapi_mltx.
????DATA: END OF int_mltx.
????*Tax classification
????DATA: BEGIN OF int_mlan OCCURS 100.
???? INCLUDE STRUCTURE bapi_mlan.
????DATA: END OF int_mlan.
????* Classification view
????DATA : BEGIN OF return_line OCCURS 10.
???? INCLUDE STRUCTURE bapiret2.
????DATA : END OF return_line.
????
????DATA : BEGIN OF alloc_values_num OCCURS 10.
???? INCLUDE STRUCTURE bapi1003_alloc_values_num.
????DATA : END OF alloc_values_num.
????
????DATA : BEGIN OF alloc_values_char OCCURS 10.
???? INCLUDE STRUCTURE bapi1003_alloc_values_char.
????DATA : END OF alloc_values_char.
????
????DATA : BEGIN OF alloc_values_curr OCCURS 10.
???? INCLUDE STRUCTURE bapi1003_alloc_values_curr.
????DATA : END OF alloc_values_curr.
????* DEFINE COLUMNS FOR INTERAL TABEL .
????DATA: BEGIN OF int_mat_base OCCURS 100,
????* Initial Screen
???? industrysector(1) ,
???? materialtype(4) ,
????* Basic Data 1
???? description(38) ,
???? longtext1(130) ,
???? longtext2(130) ,
???? baseunitofmeasure(3) ,
???? externalmaterialgroup(18) ,
???? materialgroup(9) ,
???? division(2) ,
???? producthierarchy(18) ,
???? oldmaterialnumber(18) ,
???? formappingprodhieritdept(18) ,
???? xplantmatlstatus(2) ,
???? basicvalidfrom(10) ,
???? itemcategorygroup(4) ,
???? grossweight(13) ,
???? netweight(13) ,
???? weightunit(3) ,
???? volume(13) ,
???? volumeunit(3) ,
???? sizedimensions(32) ,
???? packingmaterial(4) ,
???? skueanupc(18) ,
???? skueanupclength(13) ,
???? skueanupcwidth(13) ,
???? skueanupcheight(13) ,
???? eancategory(2) ,
???? unitofdimension(3) ,
???? materialnumber(18) ,
???? END OF int_mat_base.
????
????DATA: BEGIN OF int_mat_plant OCCURS 100,
????* Key fields
????
???? plant(4) ,
????* Purchasing
???? purchasinggroup(3) ,
???? plantspecificmaterialstatus(2) ,
???? automaticpurchaseorderallowed(1) ,
???? purchasingvaluekey(4) ,
???? purgrprocessingtime(3) ,
???? oldmodelnumber(18) ,
???? primarystoragebin(20) , "update by manual
???? secondarystoragebin(20) , " update by manual
????* MRP1
???? mrpcontroller(3) ,
???? mrpgroup(4) ,
???? mrptype(2) ,
???? lotsize(2) ,
???? reorderpoint(13) ,
???? minimumlotsize(13) ,
???? maximumlotsize(13) ,
???? fixedlotsize(13) ,
???? assemblyscrapinpercent(10) ,
????* MRP2
???? procurementtype(1) ,
???? specialprocurementkey(2) ,
???? planneddeliverytime(3) ,
???? inhouseproduction(3) ,
???? mrpgrprocessingtime(3) ,
???? schedulemarginkey(3) ,
???? issuestoragelocation(4) ,
???? proposedsupplyarea(10) ,
???? backflush(1) ,
???? safetystock(13) ,
???? minimumsafetystock(13) ,
????* MRP3
???? periodindicator(1) ,
???? strategygroup(2) ,
???? consumptionmode(1) ,
???? fwdconsumptionper(3) ,
???? bwdconsumptionper(3) ,
???? mrpavailabilitycheck(2) ,
???? totreplleadtime(3) ,
???? planningplant(4) , "for mpgd
???? planningmaterial(18) , "for mpgd
???? convfactorfplngmaterial(10), "for mpgd
????* MPR4
???? individualandcollreqmts(1) ,
???? componentscrapinpercent(10) ,
???? discontinuationindicator(1) ,
???? effectiveoutdate(10) ,
???? followupmaterial(18) ,
???? repetitivemfgallowed(1) ,
???? repetitivemanufacturingprofile(4) ,
????
????* Work scheduling
???? productionscheduler(3) ,
???? setupandteardowntime(10) ,
???? interoperationtime(10) ,
???? processingtime(10) ,
???? basequantity(13) ,
????
????*Sales: General/Plant
???? saleavailabilitycheck(2) ,
???? transgroup(4) ,
???? loadinggroup(4) ,
???? materialgrouppackagingmaterial(4) ,
???? profitcenter(10) ,
???? commimpcodeno(17) ,
???? productionschedulerprofile(6),
???? roundingprofile(4),
???? roundingvalue(13),
???? materialnumber(18) ,
???? END OF int_mat_plant.
????
????* DEFINE SALES VIEW DATA.
????DATA : BEGIN OF int_mat_sales OCCURS 100,
????*Sales: Sales Org. 1
????
???? salesorg(4) ,
???? distrchannel(2) ,
???? minorderqty(13) ,
???? mindelyqty(13) ,
???? deliveryunit(13) ,
???? salesunit(4) ,
???? xdistributionchainstatus(2) ,
???? salevalidfrom1(10) ,
???? dchainspecificstatus(2) ,
???? salevalidfrom2(10) ,
???? cashdiscountindicator(1) ,
????*Sales: Sales Org. 2
???? matstatgroup(1) ,
???? rebategroup(2) ,
???? acctassigngroup(2) ,
???? genitemcateggroup(4) ,
???? itemcatgroup(4) ,
???? materialgroup1(3),
???? materialgroup2(3),
???? materialgroup3(3),
???? materialgroup4(3),
???? materialgroup5(3),
???? materialnumber(18) ,
????
???? END OF int_mat_sales.
????
????DATA : BEGIN OF int_mat_storage OCCURS 100,
????
???? plant(4) ,
????* General Plant Data / Storage 1
???? plantstoragelocation(4),
???? unitofissue(3) ,
???? storagebin(10),
???? materialnumber(18) ,
???? END OF int_mat_storage.
????
????DATA : BEGIN OF int_mat_uom OCCURS 100,
????
????
????* Unit of Mesaure Conversion
???? innerconversiontosku(5) ,
???? innercartonunit(3) ,
???? innercartoneanupc(18) ,
???? innercartonlength(13) ,
???? innercartonwidth(13) ,
???? innercartonheight(13) ,
???? innercartoneancategory(2) ,
???? innerunitofdimension(3) ,
???? innervolume(13) ,
???? innervolumeofunit(3) ,
???? innergrossweight(13) ,
???? innerweightunit(3) ,
???? outerconversiontosku(5) ,
???? outercartonunit(3) ,
???? outercartoneanupc(18) ,
???? outercartonlength(13) ,
???? outercartonwidth(13) ,
???? outercartonheight(13) ,
???? outercartoneancategory(2) ,
???? outerunitofdimension(3) ,
???? outervolume(13) ,
???? outervolumeofunit(3) ,
???? outergrossweight(13) ,
???? outerweightunit(3) ,
???? materialnumber(18) ,
???? END OF int_mat_uom.
????
????DATA : BEGIN OF int_mat_tax OCCURS 100,
???? salesorg(4) ,
???? distrchannel(2) ,
???? country(3) ,
???? category(4) ,
???? tax1classification(1) ,
???? materialnumber(18) ,
???? END OF int_mat_tax.
????
????DATA : BEGIN OF int_mat_valuation OCCURS 100,
????
???? plant(4) ,
????*Accounting 1
???? valuationcategory1(1) ,
???? valuationclass1(4) ,
???? pricecontrol1(1) ,
???? priceunit(5) ,
???? standardprice1(11) ,
???? movingaverageprice1(11) ,
????*Accounting 1 (Prime)
???? valuationcategory2(1) ,
???? valuationclass2(4) ,
???? pricecontrol2(1) ,
???? standardprice2(11) ,
???? movingaverageprice2(11) ,
????*Accounting 1 (Grade B)
???? valuationcategory3(1) ,
???? valuationclass3(4) ,
???? pricecontrol3(1) ,
???? standardprice3(11) ,
???? movingaverageprice3(11) ,
????*Accounting 1 (Zero value)
???? valuationcategory4(1) ,
???? valuationclass4(4) ,
???? pricecontrol4(1) ,
???? standardprice4(11) ,
???? movingaverageprice4(11) ,
????*Accounting 2
???? taxprice1(11) ,
???? commercialprice1(11) ,
????* Cost Estimate 1
???? matlcostqtystruc(1) ,
???? origingroup(4) ,
???? materialorigin(1) ,
???? costingoverheadgroup(10) ,
???? variancekey(6) ,
???? lotsizeforproductcosting(13) ,
???? materialnumber(18) ,
????
????
???? END OF int_mat_valuation.
????* classification
????DATA : BEGIN OF int_mat_classification OCCURS 100,
???? objectkey LIKE bapi1003_key-object,
???? descprition LIKE bapi1003_alloc_values_char-charact_descr,
???? uom LIKE bapi1003_alloc_values_num-unit_from,
???? classtype LIKE bapi1003_key-classtype,
???? classnum LIKE bapi1003_key-classnum,
???? charactername LIKE bapi1003_alloc_values_char-charact,
???? charactervalue LIKE bapi1003_alloc_values_char-value_char,
???? END OF int_mat_classification.
????* START-OF-SCREEN.
????
????SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME. TITLE text-001 NO
????INTERVALS .
????PARAMETERS: f_dir LIKE rlgrap-filename DEFAULT 'C:\DATA\'
???? MEMORY ID f_dir VISIBLE LENGTH 20 OBLIGATORY .
????SELECTION-SCREEN END OF BLOCK blk1.
????
????
????SELECTION-SCREEN BEGIN OF BLOCK blk2 WITH FRAME. TITLE text-002 NO
????INTERVALS .
????PARAMETERS:
????
???? create RADIOBUTTON GROUP rad2 ,
???? modify RADIOBUTTON GROUP rad2 .
????
????SELECTION-SCREEN END OF BLOCK blk2.
????
????SELECTION-SCREEN BEGIN OF BLOCK blk3 WITH FRAME. TITLE text-003 NO
????INTERVALS .
????PARAMETERS:
???? basic RADIOBUTTON GROUP rad1,
???? plant RADIOBUTTON GROUP rad1,
???? sale RADIOBUTTON GROUP rad1,
???? tax RADIOBUTTON GROUP rad1,
???? storage RADIOBUTTON GROUP rad1,
???? m_valu RADIOBUTTON GROUP rad1,
???? classifi RADIOBUTTON GROUP rad1,
???? uom RADIOBUTTON GROUP rad1,
???? all RADIOBUTTON GROUP rad1.
????SELECTION-SCREEN END OF BLOCK blk3.
????
????* END-OF-SCREEN.
????
????**************** program logic begin ****************************
????
????IF basic = 'X' .
???? result = 0 .
???? PERFORM. save_basic_data.
????ENDIF.
????IF plant = 'X' .
???? result = 0 .
???? PERFORM. save_plant_data.
????ENDIF.
????IF sale = 'X' .
???? result = 0 .
???? PERFORM. save_sales_data.
????ENDIF.
????IF storage = 'X' .
???? result = 0 .
???? PERFORM. save_storage_data.
????ENDIF.
????IF uom = 'X' .
???? result = 0 .
???? PERFORM. save_uom_data.
????ENDIF.
????IF tax = 'X' .
???? result = 0 .
???? PERFORM. save_tax_data.
????ENDIF.
????IF m_valu = 'X' .
???? result = 0 .
???? PERFORM. save_valuation_data.
????ENDIF.
????IF classifi = 'X' .
???? result = 0 .
???? IF modify = c .
???? PERFORM. change_classification_data.
???? ELSE.
???? PERFORM. create_classification_data.
???? ENDIF.
????ENDIF.
????
????
????
????IF all = c .
????
???? f_file = space .
???? PERFORM. save_basic_data.
????
???? IF result = 0 .
???? f_file = space .
???? PERFORM. save_plant_data.
???? ENDIF.
???? IF result = 0 .
???? f_file = space .
???? PERFORM. save_sales_data.
???? ENDIF.
???? IF result = 0 .
???? f_file = space .
???? PERFORM. save_storage_data.
???? ENDIF.
???? IF result = 0 .
???? f_file = space .
???? PERFORM. save_tax_data.
???? ENDIF.
???? IF result = 0 .
???? f_file = space .
???? PERFORM. save_valuation_data.
???? ENDIF.
???? IF result = 0 .
???? IF create = c .
???? f_file = space .
???? PERFORM. create_classification_data.
???? ELSE.
???? PERFORM. change_classification_data.
???? ENDIF.
???? ENDIF.
???? IF result = 0 .
???? f_file = space .
???? PERFORM. save_uom_data.
???? ENDIF.
????ENDIF.
????
????*&--------------------------------------------------------------------*
????*& Form. SAVE_BASIC_DATA
????*&--------------------------------------------------------------------*
????* text
????*---------------------------------------------------------------------*
????FORM. save_basic_data.
???? result = 0 .
???? PERFORM. upload_basic_file .
???? IF result = 0 .
???? PERFORM. update_basic_data .
???? ENDIF.
????ENDFORM. "SAVE_BASIC_DATA
????*&--------------------------------------------------------------------*
????*& Form. SAVE_PLANT_DATA
????*&--------------------------------------------------------------------*
????* text
????*---------------------------------------------------------------------*
????FORM. save_plant_data.
???? result = 0 .
???? PERFORM. upload_plant_file .
???? IF result = 0 .
???? PERFORM. update_plant_data .
???? ENDIF.
????ENDFORM. "SAVE_PLANT_DATA
????*&--------------------------------------------------------------------*
????*& Form. SAVE_Sales_DATA
????*&--------------------------------------------------------------------*
????* text
????*---------------------------------------------------------------------*
????FORM. save_sales_data.
???? result = 0 .
???? PERFORM. upload_sales_file .
???? IF result = 0 .
???? PERFORM. update_sales_data .
???? ENDIF.
????ENDFORM. "SAVE_Sales_DATA
????*&--------------------------------------------------------------------*
????*& Form. SAVE_Storage_DATA
????*&--------------------------------------------------------------------*
????* text
????*---------------------------------------------------------------------*
????FORM. save_storage_data.
???? result = 0 .
???? PERFORM. upload_storage_file .
???? IF result = 0 .
???? PERFORM. update_storage_data .
???? ENDIF.
????ENDFORM. "SAVE_Storage_DATA
????*&--------------------------------------------------------------------*
????*& Form. SAVE_UOM_DATA
????*&--------------------------------------------------------------------*
????* text
????*---------------------------------------------------------------------*
????FORM. save_uom_data.
???? result = 0 .
???? PERFORM. upload_uom_file .
???? IF result = 0 .
???? PERFORM. update_uom_data .
???? ENDIF.
????ENDFORM. "SAVE_UOM_DATA
????
????*&--------------------------------------------------------------------*
????*& Form. SAVE_TAX_DATA
????*&--------------------------------------------------------------------*
????* text
????*---------------------------------------------------------------------*
????FORM. save_tax_data.
???? result = 0 .
???? PERFORM. upload_tax_file .
???? IF result = 0 .
???? PERFORM. update_tax_data .
???? ENDIF.
????ENDFORM. "SAVE_TAX_DATA
????*&--------------------------------------------------------------------*
????*& Form. SAVE_VALUATION_DATA
????*&--------------------------------------------------------------------*
????* text
????*---------------------------------------------------------------------*
????FORM. save_valuation_data.
???? result = 0 .
???? PERFORM. upload_valuation_file .
???? IF result = 0 .
???? PERFORM. update_valuation_data .
???? ENDIF.
????ENDFORM. "SAVE_VALUATION_DATA
????
????*&--------------------------------------------------------------------*
????*& Form. UPDATE_VALUATION_DATA
????*&--------------------------------------------------------------------*
????* text
????*---------------------------------------------------------------------*
????FORM. update_valuation_data .
????
???? DATA : price TYPE p DECIMALS 2 .
???? LOOP AT int_mat_valuation .
???? IF int_mat_valuation-materialnumber = space .
???? DELETE int_mat_valuation INDEX sy-tabix.
???? ENDIF.
???? ENDLOOP.
???? LOOP AT int_mat_valuation.
????* header
???? bapi_head-material = int_mat_valuation-materialnumber.
???? bapi_head-account_view = 'X'.
???? bapi_head-cost_view = 'X'.
????*Accounting view
????* Accounting 2
???? bapi_mbew1-commprice1 = int_mat_valuation-commercialprice1.
???? bapi_mbew1-taxprice_1 = int_mat_valuation-taxprice1.
????
???? IF bapi_mbew1-commprice1 <> space.
???? bapi_mbewx1-commprice1 = 'X'.
???? ENDIF.
???? IF bapi_mbew1-taxprice_1 <> space.
???? bapi_mbewx1-taxprice_1 = 'X'.
???? ENDIF.
????* Cost Estimate 1
???? bapi_mbew1-qty_struct = int_mat_valuation-matlcostqtystruc.
???? bapi_mbew1-orig_group = int_mat_valuation-origingroup.
???? bapi_mbew1-orig_mat = int_mat_valuation-materialorigin.
???? bapi_mbew1-overhead_grp = int_mat_valuation-costingoverheadgroup.
????
???? IF bapi_mbew1-qty_struct <> space.
???? bapi_mbewx1-qty_struct = 'X'.
???? ENDIF.
???? IF bapi_mbew1-orig_group <> space.
???? bapi_mbewx1-orig_group = 'X'.
???? ENDIF.
???? IF bapi_mbew1-orig_mat <> space.
???? bapi_mbewx1-orig_mat = 'X'.
???? ENDIF.
???? IF bapi_mbew1-overhead_grp <> space.
???? bapi_mbewx1-overhead_grp = 'X'.
???? ENDIF.
????
???? bapi_marc1-plant = int_mat_valuation-plant.
???? bapi_marc1-variance_key = int_mat_valuation-variancekey.
???? bapi_marc1-lot_size = int_mat_valuation-lotsizeforproductcosting
???? .
???? bapi_marcx1-plant = int_mat_valuation-plant.
????
???? IF bapi_marc1-variance_key <> space.
???? bapi_marcx1-variance_key = 'X' .
???? ENDIF.
???? IF bapi_marc1-lot_size <> space.
???? bapi_marcx1-lot_size = 'X' .
???? ENDIF.
????
????
????
????* Accounting view -1default -2PRIME -3GRADE B -4Zero value.
????*---------------------------------------------------------------------
????* note : if first create the valuation type of space was fail,system *
????* print error message : "first create the valuation-type- *
????* independent data" *
????*----------------------------------------------------------------------
????
????* Accounting 1 - default
????
???? bapi_mbew1-val_area = int_mat_valuation-plant.
???? bapi_mbew1-val_cat = int_mat_valuation-valuationcategory1.
???? bapi_mbew1-val_class = int_mat_valuation-valuationclass1.
???? bapi_mbew1-price_ctrl = int_mat_valuation-pricecontrol1.
???? bapi_mbew1-price_unit = int_mat_valuation-priceunit.
???? price = int_mat_valuation-standardprice1.
???? bapi_mbew1-std_price = price.
???? price = int_mat_valuation-movingaverageprice1.
???? bapi_mbew1-moving_pr = price.
???? bapi_mbew1-val_type = space .
???? bapi_mbewx1-val_type = space .
????
???? bapi_mbewx1-val_area = int_mat_valuation-plant.
???? IF bapi_mbew1-val_cat <> space.
???? bapi_mbewx1-val_cat = 'X'.
???? ENDIF.
???? IF bapi_mbew1-val_class <> space.
???? bapi_mbewx1-val_class = 'X'.
???? ENDIF.
???? IF bapi_mbew1-price_ctrl <> space.
???? bapi_mbewx1-price_ctrl = 'X'.
???? ENDIF.
???? IF bapi_mbew1-price_unit <> space.
???? bapi_mbewx1-price_unit = 'X'.
???? ENDIF.
???? IF bapi_mbew1-std_price <> space.
???? bapi_mbewx1-std_price = 'X'.
???? ENDIF.
???? IF bapi_mbew1-moving_pr <> space.
???? bapi_mbewx1-moving_pr = 'X'.
???? ENDIF.
???? PERFORM. whether_exist_valuation USING int_mat_valuation-materialnumber
???? int_mat_valuation-plant
???? space.
???? IF sy-subrc = 4 AND create = 'X'.
???? PERFORM. save_accounting.
???? ELSEIF sy-subrc = 1 AND modify = 'X'.
???? PERFORM. save_accounting.
???? ELSEIF sy-subrc = 0 AND modify = 'X'.
???? PERFORM. save_accounting.
???? ELSEIF sy-subrc = 1 AND create = 'X'.
???? bapi_return-type = 'S'.
???? ENDIF.
???? IF bapi_return-type = 'S'.
???? CLEAR bapi_return-type.
????* Accounting 1 - prime
???? bapi_mbew1-val_cat = int_mat_valuation-valuationcategory2.
???? bapi_mbew1-val_class = int_mat_valuation-valuationclass2.
???? bapi_mbew1-price_ctrl = int_mat_valuation-pricecontrol2.
???? price = int_mat_valuation-standardprice2.
???? bapi_mbew1-std_price = price.
???? price = int_mat_valuation-movingaverageprice2.
???? bapi_mbew1-moving_pr = price.
???? bapi_mbew1-val_type = 'PRIME' .
???? bapi_mbewx1-val_type = 'PRIME' .
????
???? bapi_mbewx1-val_area = int_mat_valuation-plant.
???? IF bapi_mbew1-val_cat <> space.
???? bapi_mbewx1-val_cat = 'X'.
???? ENDIF.
???? IF bapi_mbew1-val_class <> space.
???? bapi_mbewx1-val_class = 'X'.
???? ENDIF.
???? IF bapi_mbew1-price_ctrl <> space.
???? bapi_mbewx1-price_ctrl = 'X'.
???? ENDIF.
???? IF bapi_mbew1-std_price <> space.
???? bapi_mbewx1-std_price = 'X'.
???? ENDIF.
???? IF bapi_mbew1-moving_pr <> space.
???? bapi_mbewx1-moving_pr = 'X'.
???? ENDIF.
???? IF bapi_mbew1-price_ctrl <> space .
???? PERFORM. whether_exist_valuation USING int_mat_valuation-materialnumber
???? int_mat_valuation-plant
???? 'PRIME'.
???? IF sy-subrc = 4 AND create = 'X'.
???? PERFORM. save_accounting.
???? ELSEIF sy-subrc = 1 AND modify = 'X'.
???? PERFORM. save_accounting.
???? ELSEIF sy-subrc = 0 AND modify = 'X'.
???? PERFORM. save_accounting.
???? ELSEIF sy-subrc = 1 AND create = 'X'.
???? bapi_return-type = 'S'.
???? ENDIF.
???? ENDIF.
???? IF bapi_return-type = 'S'.
???? CLEAR bapi_return-type.
????* Accounting 1 -grade b
???? bapi_mbew1-val_cat = int_mat_valuation-valuationcategory3.
???? bapi_mbew1-val_class = int_mat_valuation-valuationclass3.
???? bapi_mbew1-price_ctrl = int_mat_valuation-pricecontrol3.
???? price = int_mat_valuation-standardprice3.
???? bapi_mbew1-std_price = price.
???? price = int_mat_valuation-movingaverageprice3.
???? bapi_mbew1-moving_pr = price.
???? bapi_mbew1-val_type = 'GRADE B' .
???? bapi_mbewx1-val_type = 'GRADE B' .
????
???? bapi_mbewx1-val_area = int_mat_valuation-plant.
???? IF bapi_mbew1-val_cat <> space.
???? bapi_mbewx1-val_cat = 'X'.
???? ENDIF.
???? IF bapi_mbew1-val_class <> space.
???? bapi_mbewx1-val_class = 'X'.
???? ENDIF.
???? IF bapi_mbew1-price_ctrl <> space.
???? bapi_mbewx1-price_ctrl = 'X'.
???? ENDIF.
???? IF bapi_mbew1-std_price <> space.
???? bapi_mbewx1-std_price = 'X'.
???? ENDIF.
???? IF bapi_mbew1-moving_pr <> space.
???? bapi_mbewx1-moving_pr = 'X'.
???? ENDIF.
????
???? IF bapi_mbew1-price_ctrl <> space .
???? PERFORM. whether_exist_valuation USING int_mat_valuation-materialnumber
???? int_mat_valuation-plant
???? 'GRADE B'.
???? IF sy-subrc = 4 AND create = 'X'.
???? PERFORM. save_accounting.
???? ELSEIF sy-subrc = 1 AND modify = 'X'.
???? PERFORM. save_accounting.
???? ELSEIF sy-subrc = 0 AND modify = 'X'.
???? PERFORM. save_accounting.
???? ELSEIF sy-subrc = 1 AND create = 'X'.
???? bapi_return-type = 'S'.
???? ENDIF.
???? ENDIF.
???? IF bapi_return-type = 'S'.
???? CLEAR bapi_return-type.
????* Accounting 1 - zero value.
???? bapi_mbew1-val_cat = int_mat_valuation-valuationcategory4.
???? bapi_mbew1-val_class = int_mat_valuation-valuationclass4.
???? bapi_mbew1-price_ctrl = int_mat_valuation-pricecontrol4.
???? price = int_mat_valuation-standardprice4.
???? bapi_mbew1-std_price = price.
???? price = int_mat_valuation-movingaverageprice4.
???? bapi_mbew1-moving_pr = price.
???? bapi_mbew1-val_type = 'ZERO VALUE' .
???? bapi_mbewx1-val_type = 'ZERO VALUE' .
????
???? bapi_mbewx1-val_area = int_mat_valuation-plant.
???? IF bapi_mbew1-val_cat <> space.
???? bapi_mbewx1-val_cat = 'X'.
???? ENDIF.
???? IF bapi_mbew1-val_class <> space.
???? bapi_mbewx1-val_class = 'X'.
???? ENDIF.
???? IF bapi_mbew1-price_ctrl <> space.
???? bapi_mbewx1-price_ctrl = 'X'.
???? ENDIF.
???? IF bapi_mbew1-std_price <> space.
???? bapi_mbewx1-std_price = 'X'.
???? ENDIF.
???? IF bapi_mbew1-moving_pr <> space.
???? bapi_mbewx1-moving_pr = 'X'.
???? ENDIF.
???? IF bapi_mbew1-price_ctrl <> space .
???? PERFORM. whether_exist_valuation USING int_mat_valuation-materialnumber
???? int_mat_valuation-plant
???? 'ZERO VALUE'.
???? IF sy-subrc = 4 AND create = 'X'.
???? PERFORM. save_accounting.
???? ELSEIF sy-subrc = 1 AND modify = 'X'.
???? PERFORM. save_accounting.
???? ELSEIF sy-subrc = 0 AND modify = 'X'.
???? PERFORM. save_accounting.
???? ENDIF.
????
???? ENDIF.
????
???? ENDIF . "GRADE B SUCCESS
???? ENDIF . "PRIME SUCCESS
???? ENDIF . " DEFAULT SUCCESS.
????
????
???? ENDLOOP.
???? WRITE : / 'upload valuation view complete'.
????
????ENDFORM. . "UPDATE_VALUATION_DATA
????
????*&--------------------------------------------------------------------*
????*& Form. UPDATE_TAX_DATA
????*&--------------------------------------------------------------------*
????* text
????*---------------------------------------------------------------------*
????FORM. update_tax_data.
???? LOOP AT int_mat_tax .
???? IF int_mat_tax-materialnumber = space .
???? DELETE int_mat_tax INDEX sy-tabix.
???? ENDIF.
???? ENDLOOP.
???? LOOP AT int_mat_tax.
????* header
???? bapi_head-material = int_mat_tax-materialnumber.
????
???? bapi_mvke1-sales_org = int_mat_tax-salesorg.
???? bapi_mvke1-distr_chan = int_mat_tax-distrchannel.
???? bapi_mvkex1-sales_org = int_mat_tax-salesorg.
???? bapi_mvkex1-distr_chan = int_mat_tax-distrchannel.
????
????* Tax Classification
???? REFRESH int_mlan.
???? int_mlan-depcountry = int_mat_tax-country.
???? int_mlan-tax_type_1 = int_mat_tax-category.
???? int_mlan-taxclass_1 = int_mat_tax-tax1classification.
???? APPEND int_mlan.
???? CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
???? EXPORTING
???? headdata = bapi_head
????* CLIENTDATA = BAPI_MARA1
????* CLIENTDATAX = BAPI_MARAX
????* PLANTDATA = BAPI_MARC1
????* PLANTDATAX = BAPI_MARCX1
????* PLANNINGDATA = BAPI_MPGD1
????* PLANNINGDATAX = BAPI_MPGDX1
????* VALUATIONDATA = BAPI_MBEW1
????* VALUATIONDATAX = BAPI_MBEWX1
???? salesdata = bapi_mvke1
???? salesdatax = bapi_mvkex1
????* STORAGELOCATIONDATA = BAPI_MARD1
????* STORAGELOCATIONDATAX = BAPI_MARDX1
???? IMPORTING
???? return = bapi_return
???? TABLES
????* MATERIALDESCRIPTION = INT_MAKT.
????* UNITSOFMEASURE = INT_MARM
????* UNITSOFMEASUREX = INT_MARMX.
????* MATERIALLONGTEXT = INT_MLTX .
???? taxclassifications = int_mlan.
????
???? IF bapi_return-type = 'E'.
???? FORMAT COLOR COL_GROUP.
???? WRITE : / bapi_return-message,
???? / int_mat_tax-materialnumber,' upload unsucessfully!'.
???? ENDIF.
????
???? IF bapi_return-type = 'S'.
???? FORMAT COLOR COL_KEY .
???? WRITE : / int_mat_tax-materialnumber,' upload sucessfully'.
???? ENDIF.
???? ENDLOOP.
???? WRITE : / 'upload tax view complete'.
????ENDFORM. "UPDATE_TAX_DATA
????
????*&--------------------------------------------------------------------*
????*& Form. UPDATE_UOM_DATA
????*&--------------------------------------------------------------------*
????* text
????*---------------------------------------------------------------------*
????FORM. update_uom_data .
???? LOOP AT int_mat_uom .
???? IF int_mat_uom-materialnumber = space .
???? DELETE int_mat_uom INDEX sy-tabix.
???? ENDIF.
???? ENDLOOP.
???? LOOP AT int_mat_uom.
???? perform. whether_exist_uom using int_mat_uom-materialnumber.
???? if sy-subrc = 1 .
???? continue .
???? endif.
????* header
???? bapi_head-material = int_mat_uom-materialnumber.
????* Inner carton unit of measure
???? int_marm-alt_unit = int_mat_uom-innercartonunit .
???? int_marm-numerator = int_mat_uom-innerconversiontosku .
???? int_marm-gross_wt = int_mat_uom-innergrossweight .
???? int_marm-unit_of_wt = int_mat_uom-innerweightunit .
???? int_marm-volume = int_mat_uom-innervolume .
???? int_marm-volumeunit = int_mat_uom-innervolumeofunit .
???? int_marm-ean_upc = int_mat_uom-innercartoneanupc .
???? int_marm-ean_cat = int_mat_uom-innercartoneancategory .
???? int_marm-length = int_mat_uom-innercartonlength .
???? int_marm-width = int_mat_uom-innercartonwidth .
???? int_marm-height = int_mat_uom-innercartonheight .
???? int_marm-unit_dim = int_mat_uom-innerunitofdimension .
???? APPEND int_marm.
???? int_marmx-alt_unit = int_mat_uom-innercartonunit .
???? IF int_marm-numerator <> space .
???? int_marmx-numerator = 'X' .
???? ENDIF.
???? IF int_marm-gross_wt <> space .
???? int_marmx-gross_wt = 'X' .
???? ENDIF.
???? IF int_marm-unit_of_wt <> space .
???? int_marmx-unit_of_wt = 'X' .
???? ENDIF.
???? IF int_marm-volume <> space .
???? int_marmx-volume = 'X' .
???? ENDIF.
???? IF int_marm-volumeunit <> space .
???? int_marmx-volumeunit = 'X' .
???? ENDIF.
???? IF int_marm-ean_upc <> space .
???? int_marmx-ean_upc = 'X' .
???? ENDIF.
???? IF int_marm-ean_cat <> space .
???? int_marmx-ean_cat = 'X' .
???? ENDIF.
???? IF int_marm-length <> space .
???? int_marmx-length = 'X' .
???? ENDIF.
???? IF int_marm-width <> space .
???? int_marmx-width = 'X' .
???? ENDIF.
???? IF int_marm-height <> space .
???? int_marmx-height = 'X' .
???? ENDIF.
???? IF int_marm-unit_dim <> space .
???? int_marmx-unit_dim = 'X' .
???? ENDIF.
???? APPEND int_marmx.
????* Outer carton unit of measure
???? int_marm-alt_unit = int_mat_uom-outercartonunit .
???? int_marm-numerator = int_mat_uom-outerconversiontosku .
???? int_marm-gross_wt = int_mat_uom-outergrossweight .
???? int_marm-unit_of_wt = int_mat_uom-outerweightunit .
???? int_marm-volume = int_mat_uom-outervolume .
???? int_marm-volumeunit = int_mat_uom-outervolumeofunit .
???? int_marm-ean_upc = int_mat_uom-outercartoneanupc .
???? int_marm-ean_cat = int_mat_uom-outercartoneancategory .
???? int_marm-length = int_mat_uom-outercartonlength .
???? int_marm-width = int_mat_uom-outercartonwidth .
???? int_marm-height = int_mat_uom-outercartonheight .
???? int_marm-unit_dim = int_mat_uom-outerunitofdimension .
???? APPEND int_marm.
???? int_marmx-alt_unit = int_mat_uom-outercartonunit .
????
???? IF int_marm-numerator <> space .
???? int_marmx-numerator = 'X' .
???? ENDIF.
???? IF int_marm-gross_wt <> space .
???? int_marmx-gross_wt = 'X' .
???? ENDIF.
???? IF int_marm-unit_of_wt <> space .
???? int_marmx-unit_of_wt = 'X' .
???? ENDIF.
???? IF int_marm-volume <> space .
???? int_marmx-volume = 'X' .
???? ENDIF.
???? IF int_marm-volumeunit <> space .
???? int_marmx-volumeunit = 'X' .
???? ENDIF.
???? IF int_marm-ean_upc <> space .
???? int_marmx-ean_upc = 'X' .
???? ENDIF.
???? IF int_marm-ean_cat <> space .
???? int_marmx-ean_cat = 'X' .
???? ENDIF.
???? IF int_marm-length <> space .
???? int_marmx-length = 'X' .
???? ENDIF.
???? IF int_marm-width <> space .
???? int_marmx-width = 'X' .
???? ENDIF.
???? IF int_marm-height <> space .
???? int_marmx-height = 'X' .
???? ENDIF.
???? IF int_marm-unit_dim <> space .
???? int_marmx-unit_dim = 'X' .
???? ENDIF.
????
???? APPEND int_marmx.
????
???? CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
???? EXPORTING
???? headdata = bapi_head
???? IMPORTING
???? return = bapi_return
???? TABLES
???? unitsofmeasure = int_marm
???? unitsofmeasurex = int_marmx.
????
???? IF bapi_return-type = 'E'.
???? FORMAT COLOR COL_GROUP.
???? WRITE : / bapi_return-message,
???? / int_mat_uom-materialnumber,' upload unsucessfully!'.
???? ENDIF.
????
???? IF bapi_return-type = 'S'.
???? FORMAT COLOR COL_KEY .
???? WRITE : / int_mat_uom-materialnumber,' upload sucessfully'.
???? ENDIF.
???? ENDLOOP.
???? WRITE : / 'upload UOM view complete '.
????ENDFORM. . "UPDATE_UOM_DATA
????*&--------------------------------------------------------------------*
????*& Form. UPDATE_Storage_DATA
????*&--------------------------------------------------------------------*
????* text
????*---------------------------------------------------------------------*
????FORM. update_storage_data .
???? LOOP AT int_mat_storage .
???? IF int_mat_storage-materialnumber = space .
???? DELETE int_mat_storage INDEX sy-tabix.
???? ENDIF.
???? ENDLOOP.
???? LOOP AT int_mat_storage .
???? TRANSLATE int_mat_storage-materialnumber TO UPPER CASE.
???? PERFORM. whether_exist_storage USING int_mat_storage-materialnumber
???? int_mat_storage-plant
???? int_mat_storage-plantstoragelocation.
???? IF sy-subrc = 1 .
???? CONTINUE.
???? ENDIF.
????* header
???? bapi_head-material = int_mat_storage-materialnumber.
???? bapi_head-storage_view = 'X'.
????
????* General Plant Data / Storage 1
????
???? bapi_mard1-plant = int_mat_storage-plant.
???? bapi_mard1-stge_loc = int_mat_storage-plantstoragelocation.
???? bapi_mard1-stge_bin = int_mat_storage-storagebin.
????
???? bapi_mardx1-plant = int_mat_storage-plant.
???? bapi_mardx1-stge_loc = int_mat_storage-plantstoragelocation.
???? IF bapi_mard1-stge_bin <> space.
???? bapi_mardx1-stge_bin = 'X'.
???? ENDIF.
????
????* General Plant Data / Storage 2
???? bapi_marc1-plant = int_mat_storage-plant.
???? bapi_marc1-issue_unit = int_mat_storage-unitofissue.
???? bapi_marcx1-plant = int_mat_storage-plant.
???? IF bapi_marc1-issue_unit <> space.
???? bapi_marcx1-issue_unit = 'X'.
???? ENDIF.
????* the relationship between base unit and unit of issue.
???? REFRESH int_marm.
???? REFRESH int_marmx.
???? int_marm-alt_unit = int_mat_storage-unitofissue.
???? int_marm-numerator = '1'.
???? APPEND int_marm.
???? int_marmx-alt_unit = int_mat_storage-unitofissue.
???? int_marmx-numerator = 'X'.
???? APPEND int_marmx.
????
????
????
???? CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
???? EXPORTING
???? headdata = bapi_head
???? plantdata = bapi_marc1
???? plantdatax = bapi_marcx1
???? storagelocationdata = bapi_mard1
???? storagelocationdatax = bapi_mardx1
???? IMPORTING
???? return = bapi_return
???? TABLES
????* MATERIALDESCRIPTION = INT_MAKT.
???? unitsofmeasure = int_marm
???? unitsofmeasurex = int_marmx.
????* MATERIALLONGTEXT = INT_MLTX .
????* TAXCLASSIFICATIONS = INT_MLAN.
????
???? IF bapi_return-type = 'E'.
???? FORMAT COLOR COL_GROUP.
???? WRITE : / bapi_return-message,
???? / int_mat_storage-materialnumber,' upload unsucessfully!'.
???? ENDIF.
????
???? IF bapi_return-type = 'S'.
???? FORMAT COLOR COL_KEY .
???? WRITE : / int_mat_storage-materialnumber,' upload sucessfully'.
???? ENDIF.
????
???? ENDLOOP.
???? WRITE : / 'upload storage view complete'.
????ENDFORM. "UPDATE_Storage_DATA
????*&--------------------------------------------------------------------*
????*& Form. UPDATE_Sales_DATA
????*&--------------------------------------------------------------------*
????* text
????*---------------------------------------------------------------------*
????FORM. update_sales_data .
???? LOOP AT int_mat_sales .
???? IF int_mat_sales-materialnumber = space .
???? DELETE int_mat_sales INDEX sy-tabix.
???? ENDIF.
???? ENDLOOP.
???? LOOP AT int_mat_sales.
???? TRANSLATE int_mat_sales-materialnumber TO UPPER CASE.
???? PERFORM. whether_exist_sales USING int_mat_sales-materialnumber
???? int_mat_sales-salesorg
???? int_mat_sales-distrchannel.
???? IF sy-subrc = 1 .
???? CONTINUE.
???? ENDIF.
????* Header
???? bapi_head-material = int_mat_sales-materialnumber.
???? bapi_head-sales_view = 'X'.
????* Sales view
????* Sales Org.1
???? bapi_mvke1-sales_org = int_mat_sales-salesorg.
???? bapi_mvke1-distr_chan = int_mat_sales-distrchannel.
???? bapi_mvke1-min_order = int_mat_sales-minorderqty.
???? bapi_mvke1-min_dely = int_mat_sales-mindelyqty.
???? bapi_mvke1-dely_unit = int_mat_sales-deliveryunit.
???? bapi_mvke1-sales_unit = int_mat_sales-salesunit .
???? bapi_mvke1-cash_disc = int_mat_sales-cashdiscountindicator.
???? bapi_mvke1-valid_from = int_mat_sales-salevalidfrom2.
???? bapi_mvke1-sal_status = int_mat_sales-dchainspecificstatus.
????
???? bapi_mara1-sal_status = int_mat_sales-xdistributionchainstatus.
???? bapi_mara1-svalidfrom = int_mat_sales-salevalidfrom1.
????
???? IF bapi_mara1-sal_status <> space.
???? bapi_marax-sal_status = 'X'.
???? ENDIF .
???? IF bapi_mara1-svalidfrom <> space.
???? bapi_marax-svalidfrom = 'X'.
???? ENDIF.
????* the relationship between base unit and sales unit
???? IF int_mat_sales-salesunit NE space .
???? REFRESH int_marm.
???? REFRESH int_marmx.
???? int_marm-alt_unit = int_mat_sales-salesunit.
???? int_marm-numerator = '1'.
???? APPEND int_marm.
???? int_marmx-alt_unit = int_mat_sales-salesunit.
???? int_marmx-numerator = 'X'.
???? APPEND int_marmx.
???? ENDIF.
????* Sales Org.2
???? bapi_mvke1-matl_stats = int_mat_sales-matstatgroup .
???? bapi_mvke1-rebate_grp = int_mat_sales-rebategroup.
???? bapi_mvke1-acct_assgt = int_mat_sales-acctassigngroup.
???? bapi_mara1-item_cat = int_mat_sales-genitemcateggroup.
???? bapi_mvke1-item_cat = int_mat_sales-itemcatgroup.
???? bapi_mvke1-matl_grp_1 = int_mat_sales-materialgroup1.
???? bapi_mvke1-matl_grp_2 = int_mat_sales-materialgroup2.
???? bapi_mvke1-matl_grp_3 = int_mat_sales-materialgroup3.
???? bapi_mvke1-matl_grp_4 = int_mat_sales-materialgroup4.
???? bapi_mvke1-matl_grp_5 = int_mat_sales-materialgroup5.
????
???? bapi_mvkex1-sales_org = int_mat_sales-salesorg.
???? bapi_mvkex1-distr_chan = int_mat_sales-distrchannel.
????
???? IF bapi_mvke1-sal_status <> space.
???? bapi_mvkex1-sal_status = 'X' .
???? ENDIF.
???? IF bapi_mvke1-min_order <> space.
???? bapi_mvkex1-min_order = 'X' .
???? ENDIF.
???? IF bapi_mvke1-min_dely <> space.
???? bapi_mvkex1-min_dely = 'X' .
???? ENDIF.
???? IF bapi_mvke1-dely_unit <> space.
???? bapi_mvkex1-dely_unit = 'X' .
???? ENDIF.
???? IF bapi_mvke1-valid_from <> space.
???? bapi_mvkex1-valid_from = 'X' .
???? ENDIF.
???? IF bapi_mvke1-sales_unit <> space.
???? bapi_mvkex1-sales_unit = 'X' .
???? ENDIF.
???? IF bapi_mvke1-cash_disc <> space.
???? bapi_mvkex1-cash_disc = 'X' .
???? ENDIF.
???? IF bapi_mvke1-valid_from <> space.
???? bapi_mvkex1-valid_from = 'X' .
???? ENDIF.
???? IF bapi_mvke1-sal_status <> space.
???? bapi_mvkex1-sal_status = 'X' .
???? ENDIF.
???? IF bapi_mvke1-matl_stats <> space.
???? bapi_mvkex1-matl_stats = 'X' .
???? ENDIF.
???? IF bapi_mvke1-rebate_grp <> space.
???? bapi_mvkex1-rebate_grp = 'X' .
???? ENDIF.
???? IF bapi_mvke1-acct_assgt <> space.
???? bapi_mvkex1-acct_assgt = 'X' .
???? ENDIF.
???? IF bapi_mara1-item_cat <> space.
???? bapi_marax-item_cat = 'X' .
???? ENDIF.
???? IF bapi_mvke1-item_cat <> space.
???? bapi_mvkex1-item_cat = 'X' .
???? ENDIF.
???? IF bapi_mvke1-matl_grp_1 <> space.
???? bapi_mvkex1-matl_grp_1 = 'X' .
???? ENDIF.
???? IF bapi_mvke1-matl_grp_2 <> space.
???? bapi_mvkex1-matl_grp_2 = 'X' .
???? ENDIF.
???? IF bapi_mvke1-matl_grp_3 <> space.
???? bapi_mvkex1-matl_grp_3 = 'X' .
???? ENDIF.
???? IF bapi_mvke1-matl_grp_4 <> space.
???? bapi_mvkex1-matl_grp_4 = 'X' .
???? ENDIF.
???? IF bapi_mvke1-matl_grp_5 <> space.
???? bapi_mvkex1-matl_grp_5 = 'X' .
???? ENDIF.
????
???? CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
???? EXPORTING
???? headdata = bapi_head
???? clientdata = bapi_mara1
???? clientdatax = bapi_marax
???? salesdata = bapi_mvke1
???? salesdatax = bapi_mvkex1
???? IMPORTING
???? return = bapi_return
???? TABLES
???? unitsofmeasure = int_marm
???? unitsofmeasurex = int_marmx.
????
???? IF bapi_return-type = 'E'.
???? FORMAT COLOR COL_GROUP.
???? WRITE : / bapi_return-message,
???? / int_mat_sales-materialnumber,' upload unsucessfully!'.
???? ENDIF.
????
???? IF bapi_return-type = 'S'.
???? FORMAT COLOR COL_KEY .
???? WRITE : / int_mat_sales-materialnumber,' upload sucessfully'.
???? ENDIF.
????
???? ENDLOOP.
???? WRITE : / 'upload sales view complete'.
????ENDFORM. . "UPDATE_Sales_DATA
????*&--------------------------------------------------------------------*
????*& Form. UPDATE_BASIC_DATA
????*&--------------------------------------------------------------------*
????* text
????*---------------------------------------------------------------------*
????FORM. update_basic_data .
???? view_n = 'basic'.
???? LOOP AT int_mat_base .
???? IF int_mat_base-materialnumber = space .
???? DELETE int_mat_base INDEX sy-tabix.
???? ENDIF.
???? ENDLOOP.
????* SET THE VALUE FROM INTERAL TABEL TO BAPI
???? LOOP AT int_mat_base.
???? TRANSLATE int_mat_base-materialnumber TO UPPER CASE.
???? PERFORM. whether_exist_basic USING int_mat_base-materialnumber .
???? IF sy-subrc = 1 .
???? CONTINUE.
???? ENDIF.
????* Header
???? bapi_head-material = int_mat_base-materialnumber.
???? bapi_head-ind_sector = int_mat_base-industrysector.
???? bapi_head-matl_type = int_mat_base-materialtype.
???? bapi_head-basic_view = 'X'.
????
????* Material Description
???? REFRESH int_makt.
???? int_makt-langu = sy-langu. " SET THE DEFAULT LAN.
???? int_makt-matl_desc = int_mat_base-description.
???? APPEND int_makt.
????
????* Long text
???? REFRESH int_mltx.
???? int_mltx-applobject = 'MATERIAL'.
???? int_mltx-text_name = int_mat_base-materialnumber.
???? int_mltx-text_id = 'GRUN'.
???? int_mltx-langu = sy-langu.
???? int_mltx-text_line = int_mat_base-longtext1.
???? APPEND int_mltx.
???? int_mltx-applobject = 'MATERIAL'.
???? int_mltx-text_name = int_mat_base-materialnumber.
???? int_mltx-text_id = 'GRUN'.
???? int_mltx-langu = sy-langu.
???? int_mltx-text_line = int_mat_base-longtext2.
???? APPEND int_mltx.
????* Client Data - Basic
???? bapi_mara1-matl_group = int_mat_base-materialgroup.
???? bapi_mara1-base_uom = int_mat_base-baseunitofmeasure.
???? bapi_mara1-unit_of_wt = int_mat_base-weightunit.
???? bapi_mara1-division = int_mat_base-division.
???? bapi_mara1-net_weight = int_mat_base-netweight.
???? bapi_mara1-size_dim = int_mat_base-sizedimensions.
???? bapi_mara1-mat_grp_sm = int_mat_base-packingmaterial.
???? bapi_mara1-extmatlgrp = int_mat_base-externalmaterialgroup.
???? bapi_mara1-prod_hier = int_mat_base-producthierarchy.
???? bapi_mara1-old_mat_no = int_mat_base-oldmaterialnumber.
???? bapi_mara1-item_cat = int_mat_base-itemcategorygroup.
???? bapi_mara1-pur_status = int_mat_base-xplantmatlstatus.
???? bapi_mara1-pvalidfrom = int_mat_base-basicvalidfrom .
???? IF bapi_mara1-matl_group <> space .
???? bapi_marax-matl_group = 'X'.
???? ENDIF.
???? IF bapi_mara1-base_uom <> space .
???? bapi_marax-base_uom = 'X'.
???? ENDIF.
???? IF bapi_mara1-unit_of_wt <> space .
???? bapi_marax-unit_of_wt = 'X'.
???? ENDIF.
???? IF bapi_mara1-division <> space .
???? bapi_marax-division = 'X'.
???? ENDIF.
???? IF bapi_mara1-net_weight <> space .
???? bapi_marax-net_weight = 'X'.
???? ENDIF.
???? IF bapi_mara1-size_dim <> space .
???? bapi_marax-size_dim = 'X'.
???? ENDIF.
???? IF bapi_mara1-mat_grp_sm <> space .
???? bapi_marax-mat_grp_sm = 'X'.
???? ENDIF.
???? IF bapi_mara1-extmatlgrp <> space .
???? bapi_marax-extmatlgrp = 'X'.
???? ENDIF.
???? IF bapi_mara1-prod_hier <> space .
???? bapi_marax-prod_hier = 'X'.
???? ENDIF.
???? IF bapi_mara1-old_mat_no <> space .
???? bapi_marax-old_mat_no = 'X'.
???? ENDIF.
???? IF bapi_mara1-item_cat <> space .
???? bapi_marax-item_cat = 'X'.
???? ENDIF.
???? IF bapi_mara1-pur_status <> space .
???? bapi_marax-pur_status = 'X'.
???? ENDIF.
???? IF bapi_mara1-pvalidfrom <> space .
???? bapi_marax-pvalidfrom = 'X'.
???? ENDIF.
????
???? REFRESH int_marm .
???? REFRESH int_marmx.
???? int_marm-alt_unit = int_mat_base-baseunitofmeasure.
???? int_marm-volume = int_mat_base-volume.
???? int_marm-volumeunit = int_mat_base-volumeunit.
???? int_marm-gross_wt = int_mat_base-grossweight.
???? int_marm-ean_upc = int_mat_base-skueanupc.
???? int_marm-ean_cat = int_mat_base-eancategory.
???? int_marm-length = int_mat_base-skueanupclength.
???? int_marm-width = int_mat_base-skueanupcwidth.
???? int_marm-height = int_mat_base-skueanupcheight.
???? int_marm-unit_dim = int_mat_base-unitofdimension.
???? int_marm-unit_of_wt = int_mat_base-weightunit.
???? APPEND int_marm.
????
???? int_marmx-alt_unit = int_mat_base-baseunitofmeasure.
????
???? IF int_marm-volume <> space .
???? int_marmx-volume = 'X'.
???? ENDIF.
???? IF int_marm-volumeunit <> space .
???? int_marmx-volumeunit = 'X'.
???? ENDIF.
???? IF int_marm-gross_wt <> space .
???? int_marmx-gross_wt = 'X' .
???? ENDIF.
???? IF int_marm-ean_upc <> space .
???? int_marmx-ean_upc = 'X' .
???? ENDIF.
???? IF int_marm-ean_cat <> space .
???? int_marmx-ean_cat = 'X' .
???? ENDIF.
???? IF int_marm-length <> space .
???? int_marmx-length = 'X' .
???? ENDIF.
???? IF int_marm-width <> space .
???? int_marmx-width = 'X' .
???? ENDIF.
???? IF int_marm-height <> space .
???? int_marmx-height = 'X' .
???? ENDIF.
???? IF int_marm-unit_dim <> space .
???? int_marmx-unit_dim = 'X' .
???? ENDIF.
???? IF int_marm-unit_of_wt <> space .
???? int_marmx-unit_of_wt = 'X'.
???? ENDIF.
???? APPEND int_marmx.
????
???? CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
???? EXPORTING
???? headdata = bapi_head
???? clientdata = bapi_mara1
???? clientdatax = bapi_marax
????* PLANTDATA = BAPI_MARC1
????* PLANTDATAX = BAPI_MARCX1
????* PLANNINGDATA = BAPI_MPGD1
????* PLANNINGDATAX = BAPI_MPGDX1
????* VALUATIONDATA = BAPI_MBEW1
????* VALUATIONDATAX = BAPI_MBEWX1
????* SALESDATA = BAPI_MVKE1
????* SALESDATAX = BAPI_MVKEX1
????* STORAGELOCATIONDATA = BAPI_MARD1
????* STORAGELOCATIONDATAX = BAPI_MARDX1
???? IMPORTING
???? return = bapi_return
???? TABLES
???? materialdescription = int_makt
???? unitsofmeasure = int_marm
???? unitsofmeasurex = int_marmx
???? materiallongtext = int_mltx .
????
???? IF bapi_return-type = 'E'.
???? FORMAT COLOR COL_GROUP.
???? WRITE : / bapi_return-message+0(90),
???? / bapi_return-message+90(90),
???? / int_mat_base-materialnumber,' upload unsucessfully!'.
???? ENDIF.
????
???? IF bapi_return-type = 'S'.
???? FORMAT COLOR COL_KEY .
???? WRITE : / int_mat_base-materialnumber,' upload sucessfully'.
???? ENDIF.
???? ENDLOOP.
???? WRITE : / 'upload basic view complete'.
????ENDFORM. "UPDATE_BASIC_DATA
????
????*&--------------------------------------------------------------------*
????*& Form. UPDATE_PLANT_DATA
????*&--------------------------------------------------------------------*
????* text
????*---------------------------------------------------------------------*
????FORM. update_plant_data .
???? view_n = 'plant'.
???? LOOP AT int_mat_plant .
???? IF int_mat_plant-materialnumber = space .
???? DELETE int_mat_plant INDEX sy-tabix.
???? ENDIF.
???? ENDLOOP.
???? LOOP AT int_mat_plant.
???? TRANSLATE int_mat_plant-materialnumber TO UPPER CASE.
???? PERFORM. whether_exist_plant USING int_mat_plant-materialnumber int_mat_plant-plant.
???? IF sy-subrc = 1 .
???? CONTINUE.
???? ENDIF.
????* Header
???? bapi_head-material = int_mat_plant-materialnumber .
???? bapi_head-purchase_view = 'X'.
???? bapi_head-mrp_view = 'X'.
???? bapi_head-work_sched_view = 'X'.
????* Plant - Purchasing
???? bapi_marc1-plant = int_mat_plant-plant.
???? bapi_marc1-pur_group = int_mat_plant-purchasinggroup.
???? bapi_marc1-auto_p_ord = int_mat_plant-automaticpurchaseorderallowed.
???? bapi_marc1-pur_status = int_mat_plant-plantspecificmaterialstatus.
???? bapi_marc1-gr_pr_time = int_mat_plant-purgrprocessingtime.
???? bapi_mara1-pur_valkey = int_mat_plant-purchasingvaluekey.
????
???? bapi_marcx1-plant = int_mat_plant-plant.
???? IF bapi_marc1-pur_group <> space .
???? bapi_marcx1-pur_group = 'X' .
???? ENDIF.
???? IF bapi_marc1-auto_p_ord <> space .
???? bapi_marcx1-auto_p_ord = 'X' .
???? ENDIF.
???? IF bapi_marc1-pur_status <> space .
???? bapi_marcx1-pur_status = 'X' .
???? ENDIF.
???? IF bapi_marc1-gr_pr_time <> space .
???? bapi_marcx1-gr_pr_time = 'X' .
???? ENDIF.
???? IF bapi_mara1-pur_valkey <> space .
???? bapi_marax-pur_valkey = 'X' .
???? ENDIF.
????* MRP view
????* MRP 1
???? bapi_marc1-mrp_type = int_mat_plant-mrptype.
???? bapi_marc1-mrp_ctrler = int_mat_plant-mrpcontroller.
???? bapi_marc1-mrp_group = int_mat_plant-mrpgroup.
???? bapi_marc1-lotsizekey = int_mat_plant-lotsize.
???? bapi_marc1-reorder_pt = int_mat_plant-reorderpoint.
???? bapi_marc1-minlotsize = int_mat_plant-minimumlotsize.
???? bapi_marc1-maxlotsize = int_mat_plant-maximumlotsize.
???? bapi_marc1-fixed_lot = int_mat_plant-fixedlotsize.
???? bapi_marc1-assy_scrap = int_mat_plant-assemblyscrapinpercent.
???? bapi_marc1-round_prof = int_mat_plant-roundingprofile.
???? bapi_marc1-round_val = int_mat_plant-roundingvalue.
????
???? IF bapi_marc1-mrp_type <> space .
???? bapi_marcx1-mrp_type = 'X' .
???? ENDIF.
???? IF bapi_marc1-mrp_ctrler <> space.
???? bapi_marcx1-mrp_ctrler = 'X' .
???? ENDIF.
???? IF bapi_marc1-lotsizekey <> space.
???? bapi_marcx1-lotsizekey = 'X' .
???? ENDIF.
???? IF bapi_marc1-reorder_pt <> space.
???? bapi_marcx1-reorder_pt = 'X' .
???? ENDIF.
???? IF bapi_marc1-minlotsize <> space.
???? bapi_marcx1-minlotsize = 'X' .
???? ENDIF.
???? IF bapi_marc1-maxlotsize <> space.
???? bapi_marcx1-maxlotsize = 'X' .
???? ENDIF.
???? IF bapi_marc1-fixed_lot <> space.
???? bapi_marcx1-fixed_lot = 'X' .
???? ENDIF.
???? IF bapi_marc1-assy_scrap <> space.
???? bapi_marcx1-assy_scrap = 'X' .
???? ENDIF.
???? IF bapi_marc1-round_prof <> space.
???? bapi_marcx1-round_prof = 'X' .
???? ENDIF.
???? IF bapi_marc1-round_val <> space.
???? bapi_marcx1-round_val = 'X' .
???? ENDIF.
????* MRP view
????* MRP 2
???? bapi_marc1-proc_type = int_mat_plant-procurementtype.
???? bapi_marc1-spproctype = int_mat_plant-specialprocurementkey.
???? bapi_marc1-plnd_delry = int_mat_plant-planneddeliverytime.
???? bapi_marc1-inhseprodt = int_mat_plant-inhouseproduction.
???? bapi_marc1-gr_pr_time = int_mat_plant-purgrprocessingtime.
???? bapi_marc1-iss_st_loc = int_mat_plant-issuestoragelocation.
???? bapi_marc1-supply_area = int_mat_plant-proposedsupplyarea .
???? bapi_marc1-backflush = int_mat_plant-backflush.
???? bapi_marc1-safety_stk = int_mat_plant-safetystock.
???? bapi_marc1-min_safety_stk = int_mat_plant-minimumsafetystock.
???? bapi_marc1-sm_key = int_mat_plant-schedulemarginkey.
????
???? IF bapi_marc1-proc_type <> space.
???? bapi_marcx1-proc_type = 'X' .
???? ENDIF.
???? IF bapi_marc1-spproctype <> space.
???? bapi_marcx1-spproctype = 'X' .
???? ENDIF.
???? IF bapi_marc1-plnd_delry <> space.
???? bapi_marcx1-plnd_delry = 'X' .
???? ENDIF.
???? IF bapi_marc1-inhseprodt <> space.
???? bapi_marcx1-inhseprodt = 'X' .
???? ENDIF.
???? IF bapi_marc1-gr_pr_time <> space.
???? bapi_marcx1-gr_pr_time = 'X' .
???? ENDIF.
???? IF bapi_marc1-iss_st_loc <> space.
???? bapi_marcx1-iss_st_loc = 'X' .
???? ENDIF.
???? IF bapi_marc1-supply_area <> space.
???? bapi_marcx1-supply_area = 'X' .
???? ENDIF.
???? IF bapi_marc1-backflush <> space.
???? bapi_marcx1-backflush = 'X' .
???? ENDIF.
???? IF bapi_marc1-safety_stk <> space.
???? bapi_marcx1-safety_stk = 'X' .
???? ENDIF.
???? IF bapi_marc1-min_safety_stk <> space.
???? bapi_marcx1-min_safety_stk = 'X' .
???? ENDIF.
???? IF bapi_marc1-sm_key <> space.
???? bapi_marcx1-sm_key = 'X' .
???? ENDIF.
????* MRP view
????* MRP 3
???? bapi_marc1-availcheck = int_mat_plant-mrpavailabilitycheck.
???? bapi_marc1-period_ind = int_mat_plant-periodindicator.
???? bapi_marc1-plan_strgp = int_mat_plant-strategygroup.
???? bapi_marc1-consummode = int_mat_plant-consumptionmode.
???? bapi_marc1-fwd_cons = int_mat_plant-fwdconsumptionper.
???? bapi_marc1-bwd_cons = int_mat_plant-bwdconsumptionper.
???? bapi_marc1-replentime = int_mat_plant-totreplleadtime.
????
???? IF bapi_marc1-availcheck <> space.
???? bapi_marcx1-availcheck = 'X' .
???? ENDIF.
???? IF bapi_marc1-period_ind <> space.
???? bapi_marcx1-period_ind = 'X' .
???? ENDIF.
???? IF bapi_marc1-plan_strgp <> space.
???? bapi_marcx1-plan_strgp = 'X' .
???? ENDIF.
???? IF bapi_marc1-consummode <> space.
???? bapi_marcx1-consummode = 'X' .
???? ENDIF.
???? IF bapi_marc1-fwd_cons <> space.
???? bapi_marcx1-fwd_cons = 'X' .
???? ENDIF.
???? IF bapi_marc1-bwd_cons <> space.
???? bapi_marcx1-bwd_cons = 'X' .
???? ENDIF.
???? IF bapi_marc1-replentime <> space.
???? bapi_marcx1-replentime = 'X' .
???? ENDIF.
????
???? bapi_mpgd1-plant = int_mat_plant-plant.
???? bapi_mpgd1-plng_matl = int_mat_plant-planningmaterial.
???? bapi_mpgd1-plng_plant = int_mat_plant-planningplant.
???? bapi_mpgd1-convfactor = int_mat_plant-convfactorfplngmaterial.
????
???? bapi_mpgdx1-plant = int_mat_plant-plant.
???? IF bapi_mpgd1-plng_matl <> space.
???? bapi_mpgdx1-plng_matl = 'X'.
???? ENDIF.
???? IF bapi_mpgd1-plng_plant <> space.
???? bapi_mpgdx1-plng_plant = 'X'.
???? ENDIF.
???? IF bapi_mpgd1-convfactor <> space.
???? bapi_mpgdx1-convfactor = 'X'.
???? ENDIF.
????* MRP view
????* MRP 4
???? bapi_marc1-dep_req_id = int_mat_plant-individualandcollreqmts.
???? bapi_marc1-comp_scrap = int_mat_plant-componentscrapinpercent.
???? bapi_marc1-discontinu = int_mat_plant-discontinuationindicator.
???? bapi_marc1-eff_o_day = int_mat_plant-effectiveoutdate.
???? bapi_marc1-follow_up = int_mat_plant-followupmaterial.
???? bapi_marc1-rep_manuf = int_mat_plant-repetitivemfgallowed.
???? bapi_marc1-repmanprof = int_mat_plant-repetitivemanufacturingprofile.
????
???? IF bapi_marc1-dep_req_id <> space.
???? bapi_marcx1-dep_req_id = 'X' .
???? ENDIF.
???? IF bapi_marc1-comp_scrap <> space.
???? bapi_marcx1-comp_scrap = 'X' .
???? ENDIF.
???? IF bapi_marc1-discontinu <> space.
???? bapi_marcx1-discontinu = 'X' .
???? ENDIF.
???? IF bapi_marc1-eff_o_day <> space.
???? bapi_marcx1-eff_o_day = 'X' .
???? ENDIF.
???? IF bapi_marc1-follow_up <> space.
???? bapi_marcx1-follow_up = 'X' .
???? ENDIF.
???? IF bapi_marc1-rep_manuf <> space.
???? bapi_marcx1-rep_manuf = 'X' .
???? ENDIF.
???? IF bapi_marc1-repmanprof <> space.
???? bapi_marcx1-repmanprof = 'X' .
???? ENDIF.
????* Work scheduling view
???? bapi_marc1-production_scheduler = int_mat_plant-productionscheduler.
???? bapi_marc1-setuptime = int_mat_plant-setupandteardowntime.
???? bapi_marc1-interop = int_mat_plant-interoperationtime.
???? bapi_marc1-proc_time = int_mat_plant-processingtime.
???? bapi_marc1-base_qty = int_mat_plant-basequantity.
???? bapi_marc1-prodprof = int_mat_plant-productionschedulerprofile.
????
???? IF bapi_marc1-production_scheduler <> space.
???? bapi_marcx1-production_scheduler = 'X' .
???? ENDIF.
???? IF bapi_marc1-setuptime <> space.
???? bapi_marcx1-setuptime = 'X' .
???? ENDIF.
???? IF bapi_marc1-interop <> space.
???? bapi_marcx1-interop = 'X' .
???? ENDIF.
???? IF bapi_marc1-proc_time <> space.
???? bapi_marcx1-proc_time = 'X' .
???? ENDIF.
???? IF bapi_marc1-base_qty <> space

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/166523/viewspace-343066/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/166523/viewspace-343066/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值