*Main Program*
REPORT zdr600 NO STANDARD PAGE HEADING LINE-SIZE 200.
INCLUDE zdr600_top.
*----------- -Selection Parameters
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-t01.
PARAMETERS: p_fname LIKE rlgrap-filename.
SELECTION-SCREEN END OF BLOCK b2.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-t02.
PARAMETERS: p_werks LIKE marc-werks OBLIGATORY,
p_lgort LIKE mard-lgort OBLIGATORY,
p_vkorg LIKE vbak-vkorg OBLIGATORY,
"Sales Org
p_vtweg LIKE vbak-vtweg OBLIGATORY,
p_mtart LIKE mara-mtart OBLIGATORY,
p_kokrs LIKE tka01-kokrs OBLIGATORY DEFAULT 'LNMM'
MEMORY ID cac.
"Channel
SELECTION-SCREEN END OF BLOCK b1.
*--------Selection Screen validations
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fname..
*----------- ---Drill Down(F4) Filename
PERFORM 1000_get_filename.
*----------- --Program Logic Begins
START-OF-SELECTION.
*------ main logic : start
PERFORM 1002_read_mm_ all_views_ excel.
PERFORM 1003_process_ uploaded_ data.
PERFORM 1004_prepare_ bapi_data. * Perform open_msg_log.
* PERFORM F_WRITE_LOG_ to_file..
* Perform f_update_process_ ind.
PERFORM 1005_write_log. .* Perform display_common_ mtrl.*--- --- main logic : endEND-OF-SELECTION . INCLUDE zdr600_forms
* top include ***********
*Top Include* &------------ --------- --------- --------- --------- --------- --------- ---*
*& Include ZDR600_TOP *
*&------------ --------- --------- --------- --------- --------- --------- ---* tables : mara, marc.data: begin of i_upload occurs 0, "This is similar 2 MM_ALL_VIEWS. xls mat(18), "Material No |
indsec(1), "Industry Sector |
mattype(4), "Material Type |
matdesc(40), "Material Description | Basic Data1
basuom(3), "Base Unit of Measure |
matgroup(9), "Material Group |
div(2) , "Division |
grosswt(13), "Gross Weight |
netwt(13), "Net Weight |
unitwt(13), "Weight Unit |
mindelvqt(13) , "Min Delivering Quantity |
minordqt(13) , "Min Order Quantity |
taxclass(1), "Tax classification |Sales Org1 matstatgrp(1) , "Mat Statistic Group |Sales Org2 matprgrp(2), "Mat Pricing Group |
accassgrp(2) , "Account assignment Group |
itmcatgrp(4) , "Item Cat Group | availchk(2), "Avail check |Sales General Plant
transgrp(4), "Transportation Group |
loadgrp(4), "Loading Group |
prctr(10), "Profit Center | salestext(132) , "Sales Text /TextID |
plant(4), "Plant | purgrp(3), "Purchasing Group |
batchman(1), "Batch management | potext(132), "Pur Order Text / TextID | sloc(4), "Storage loc | dwerk(4), "Plant |
valclass(4), "Valuation Class |
mavgprc(11), "Moving Price |Accounting User Inp
valcat(1), "Valuation Category |
end of i_upload. data: wa_upload like i_upload.
data: wa_upload1(1000) .data: begin of i_mat occurs 0,
mat(18),
end of i_mat.
data: p_ux(128).*- --------- -- Message log
data : begin of i_msglog occurs 0,
string(150),
end of i_msglog.* Data Declaration for BAPI Mat Master change
data: s_headdata like bapimathead.
data: s_clientdata like bapi_mara.
data: s_clientdatax like bapi_marax.
data: s_plantdata like bapi_marc.
data: s_plantdatax like bapi_marcx.
data: s_sales like bapi_mvke.
data: s_salesx like bapi_mvkex.
data: s_forecast like bapi_mpop.
data: s_forecastx like bapi_mpopx.
data: s_whno like bapi_mlgn.
data: s_whnox like bapi_mlgnx.
data: s_stotyp like bapi_mlgt.
data: s_stotypx like bapi_mlgtx.
data: s_stoloc like bapi_mard.
data: s_stolocx like bapi_mardx.
data: s_valclass like bapi_mbew.
data: s_valclassx like bapi_mbewx.
data: s_return like bapiret2.* DATA: I_RETURN LIKE S_RETURN OCCURS 0 WITH HEADER LINE.
data: begin of i_return occurs 0,
mat(18),
plant(4),
stloc like mard-lgort,
vkorg like vbak-vkorg,
vtweg like vbak-vtweg.
include structure bapiret2.
data: end of i_return.
data : begin of i_common occurs 0,
matnr like mara-matnr,
end of i_common.
data: i_taxclass like bapi_mlan occurs 0 with header line.
data: i_uom like bapi_marm occurs 0 with header line.
data: i_uomx like bapi_marmx occurs 0 with header line.
data: i_matdesc like bapi_makt occurs 0 with header line.
data: i_longtext like bapi_mltx occurs 0 with header line.** Constants
constants: c_module(02) value 'MM',
c_itype value 'I',
c_icode(02) value '01',
c_flag value 'X',
c_delim value 'X'. *Variablesdata: v_fname1 type ibipparms-path. "Filename
************ ********* ********* ********* ********* ********* *******
*Form Include* *&------------ --------- --------- --------- --------- --------- --------- ---*
*& Include ZDR005C_FORM *
*&------------ --------- --------- --------- --------- --------- --------- ---**&------------ --------- --------- --------- --------- --------- --------- ---*
*& Form f_read_mm_all_ views_excel
*&------------ --------- --------- --------- --------- --------- --------- ---*
* text
*----------- --------- --------- --------- --------- --------- --------- -----*
* --> p1 text
* <-- p2 text
*----------- --------- --------- --------- --------- --------- --------- -----*
*include zbdcrex.form 1002_read_mm_ all_views_ excel .
data : v_subrc like sy-tabix.
perform f_upload_from_ pr.
*----- update delivery plant , is user has entered it
loop at i_upload.
* IF p_dwerk IS NOT INITIAL .
i_upload-dwerk = p_werks.
* ENDIF.
*---- for common material, take existing UOM
select single meins into mara-meins
from mara
where matnr eq i_upload-mat. .
if sy-subrc eq 0.
i_upload-basuom = mara-meins.
if mara-meins = 'ST'.
i_upload-basuom = 'PC'.
endif.
* i_upload-matgroup = mara-matkl.
endif. modify i_upload index sy-tabix.
endloop.*--- --- upload common material , if user wants
* LOOP AT i_upload.
* v_subrc = sy-tabix.
* SELECT SINGLE matnr INTO marc-matnr
* FROM marc
* WHERE matnr EQ i_upload-mat AND
* werks EQ 'CAR1'.
* IF sy-subrc NE 0.
* MOVE i_upload-mat TO i_common-matnr.
* APPEND i_common. CLEAR : i_common.
* DELETE i_upload INDEX v_subrc.
* ENDIF.
* ENDLOOP.**-- ---- do not upload common material , if user wants* LOOP AT i_upload.
* v_subrc = sy-tabix.
* SELECT SINGLE matnr INTO marc-matnr
* FROM marc
* WHERE matnr EQ i_upload-mat and
* werks eq 'CAR1'.
* IF sy-subrc EQ 0.
* move i_upload-mat to i_common-matnr.
* append i_common. clear : i_common.
* delete i_upload index v_subrc.
* ENDIF.
* ENDLOOP.
*
*--- if material is already created in PART, do not upload it again* LOOP AT i_upload..
* v_subrc = sy-tabix.
* SELECT SINGLE matnr INTO marc-matnr
* FROM marc
* WHERE matnr EQ i_upload-mat AND
* werks EQ 'PART'.
* IF sy-subrc EQ 0.
* DELETE i_upload INDEX v_subrc.
* ENDIF.
* ENDLOOP.endform. " 1002_read_mm_ all_views_ excel
*&------------ --------- --------- --------- --------- --------- --------- ---*
*& Form f_process_uploaded_ data
*&------------ --------- --------- --------- --------- --------- --------- ---*
* text
*----------- --------- --------- --------- --------- --------- --------- -----*
* --> p1 text
* <-- p2 text
*----------- --------- --------- --------- --------- --------- --------- -----*
form 1003_process_ uploaded_ data .*Delete column heading and unnecessary lines-frist 4 lines
* DELETE i_upload FROM 1 TO 10. delete i_upload where mat is initial.endform. " 1003_process_ uploaded_ data
*&------------ --------- --------- --------- --------- --------- --------- ---*
*& Form f_prepare_bapi_ data
*&------------ --------- --------- --------- --------- --------- --------- ---*
* text
*----------- --------- --------- --------- --------- --------- --------- -----*
* --> p1 text
* <-- p2 text
*----------- --------- --------- --------- --------- --------- --------- -----*
form 1004_prepare_ bapi_data . loop at i_upload . wa_upload = i_upload. perform f_initialise_ bapi_tables. perform f_fill_bapi_ headdata. perform f_fill_bapi_ clientdata. perform f_fill_bapi_ plantdata. perform f_fill_bapi_ salesdata. * PERFORM f_fill_bapi_ forcastdata. perform f_fill_bapi_ stlocdata. perform f_fill_bapi_ valclassdata. perform f_fill_bapi_ taxclassdata. perform f_fill_bapi_ uomdata. perform f_fill_bapi_ matdescdata. perform f_fill_bapi_ longtextdata. perform f_call_bapi. * PERFORM f_update_gross_ wt. endloop.endform. " 1004_prepare_ bapi_data
*&------------ --------- --------- --------- --------- --------- --------- ---*
*& Form f_call_bapi
*&------------ --------- --------- --------- --------- --------- --------- ---*
* text
*----------- --------- --------- --------- --------- --------- --------- -----*
* --> p1 text* <-- p2 text
*----------- --------- --------- --------- --------- --------- --------- -----*
form f_call_bapi . call function 'BAPI_MATERIAL_ SAVEDATA'
exporting
headdata = s_headdata
clientdata = s_clientdata
clientdatax = s_clientdatax
plantdata = s_plantdata
plantdatax = s_plantdatax
forecastparameters = s_forecast
forecastparametersx = s_forecastx
storagelocationdata = s_stoloc
storagelocationdata x = s_stolocx
valuationdata = s_valclass
valuationdatax = s_valclassx
warehousenumberdata = s_whno
warehousenumberdata x = s_whnox
salesdata = s_sales
salesdatax = s_salesx
storagetypedata = s_stotyp
storagetypedatax = s_stotypx
importing
return = s_return
tables
materialdescription = i_matdesc
unitsofmeasure = i_uom
unitsofmeasurex = i_uomx
taxclassifications = i_taxclass
materiallongtext = i_longtext. call function 'BAPI_TRANSACTION_ COMMIT'. perform f_populate_result_ table.
*------- Update process indicator
* Perform f_update_process_ ind.
endform. " f_call_bapi
*&------------ --------- --------- --------- --------- --------- --------- ---*
*& Form F_WRITE_LOG
*&------------ --------- --------- --------- --------- --------- --------- ---*
* text
*----------- --------- --------- --------- --------- --------- --------- -----*
* --> p1 text
* <-- p2 text
*----------- --------- --------- --------- --------- --------- --------- -----*
form 1005_write_log . data: l_message(220) . format color 1 on.
write: / 'Material' ,
19 'Plant',
27 'St. Loc',
35 'Sales Org',
46 'Distr Chnl',
58 'Message'.
format color off. loop at i_return. concatenate i_return-id '/' i_return-type '/' i_return-number
'**' i_return-message into l_message. replace '**' with ' ' into l_message . write: / i_return-mat,
19 i_return-plant,
27 i_return-stloc,
35 i_return-vkorg,
46 i_return-vtweg,
58 l_message.
endloop.
endform. " 1005_WRITE_LOG
*&------------ --------- --------- --------- --------- --------- --------- ---*
*& Form F_WRITE_LOG_ to_file
*&------------ --------- --------- --------- --------- --------- --------- ---*
* text
*----------- --------- --------- --------- --------- --------- --------- -----*
* --> p1 text
* <-- p2 text
*----------- --------- --------- --------- --------- --------- --------- -----*
form f_write_log_ to_file .
refresh : i_msglog. clear : i_msglog.
*------- msg hdr
move
'** Start Processing : Record type 53 - Create material master**'
to i_msglog-string.
append i_msglog.
move '*' to i_msglog-string.
append i_msglog..
*----- collect msg log
loop at i_return.
concatenate i_return-type '-' i_return-message into
i_msglog-string.
append i_msglog.
endloop..
*----- footer
move '*' to i_msglog-string.
append i_msglog.
move
'** End Processing : Record type 53 - Create material master**'
to i_msglog-string.
append i_msglog.
write sy-uline to i_msglog.
append i_msglog.*-- --- now write log to file
loop at i_msglog.
transfer i_msglog-string to p_ux.
endloop.
*------ close msg log
close dataset p_ux.endform. " F_WRITE_LOG_ to_file
*&------------ --------- --------- --------- --------- --------- --------- ---*
*& Form open_msg_log
*&------------ --------- --------- --------- --------- --------- --------- ---*
* text
*----------- --------- --------- --------- --------- --------- --------- -----*
* --> p1 text
* <-- p2 text
*----------- --------- --------- --------- --------- --------- --------- -----*
form open_msg_log .
*------ read path for message log on server
* SELECT SINGLE message_folder FROM zpainterface_ ctl INTO p_ux
* WHERE module_name = c_module AND
* interface_type = c_itype AND
* interface_code = c_icode.
* IF sy-subrc NE 0.
* CLEAR : p_ux.
* ENDIF.
*
concatenate p_ux 'message_log. txt' into p_ux.
open dataset p_ux for appending in text mode encoding default.endform. " open_msg_log
*&------------ --------- --------- --------- --------- --------- --------- ---*
*& Form f_update_process_ ind
*&------------ --------- --------- --------- --------- --------- --------- ---*
* text
*----------- --------- --------- --------- --------- --------- --------- -----*
* --> p1 text
* <-- p2 text
*----------- --------- --------- --------- --------- --------- --------- -----*
*FORM f_update_process_ ind .
* LOOP AT i_return.
* IF i_return-type = 'E'.
* UPDATE zpadata53 SET zprocess_mm = ''
** where ersda = sy-datum
* WHERE zprocess_mm NE 'X'
* AND matnr_sup = i_return-mat.
* ELSE.
* UPDATE zpadata53 SET zprocess_mm = 'X'
** where ersda = sy-datum
* WHERE zprocess_mm NE 'X'
* AND matnr_sup = i_return-mat.
*
* ENDIF.
* ENDLOOP.
*ENDFORM. " f_update_process_ ind
*&------------ --------- --------- --------- --------- --------- --------- ---*
*& Form f_populate_result_ table
*&------------ --------- --------- --------- --------- --------- --------- ---*
* text
*----------- --------- --------- --------- --------- --------- --------- -----*
* --> p1 text
* <-- p2 text
*----------- --------- --------- --------- --------- --------- --------- -----*
form f_populate_result_ table . i_return-mat = i_upload-mat.
i_return-plant = p_werks.
i_return-stloc = p_lgort.
i_return-vkorg = p_vkorg.
i_return-vtweg = p_vtweg.
move-corresponding s_return to i_return.
append i_return. clear: i_return.endform. " f_populate_result_ table
*&------------ --------- --------- --------- --------- --------- --------- ---*
*& Form f_fill_bapi_ headdata
*&------------ --------- --------- --------- --------- --------- --------- ---*
* text
*----------- --------- --------- --------- --------- --------- --------- -----*
* --> p1 text
* <-- p2 text
*----------- --------- --------- --------- --------- --------- --------- -----*
form f_fill_bapi_ headdata . s_headdata-material = wa_upload-mat.
s_headdata-ind_ sector = 'M'.
s_headdata-matl_ type = p_mtart."'CARC' .
s_headdata-basic_ view = 'X'.
s_headdata-sales_ view = 'X'.
s_headdata-purchase _view = 'X'.
* s_headdata-mrp_ view = 'X'.
s_headdata-forecast _view = 'X'.
s_headdata-storage_ view = 'X'.
s_headdata-cost_ view = 'X'.
* IF NOT p_werks = 'MUMB'.
* s_headdata-warehous e_view = 'X'.
* ENDIF.
*
s_headdata-account_ view = 'X'.
endform. " f_fill_bapi_ headdata
*&------------ --------- --------- --------- --------- --------- --------- ---*
*& Form f_fill_bapi_ clientdata
*&------------ --------- --------- --------- --------- --------- --------- ---*
* text
*----------- --------- --------- --------- --------- --------- --------- -----*
* --> p1 text
* <-- p2 text
*----------- --------- --------- --------- --------- --------- --------- -----*
form f_fill_bapi_ clientdata .* PERFORM f_check_uom_ from_mara. perform f_get_uom.
* perform f_get_original_ mtrlgroup. s_clientdatax- base_uom = 'X'.
s_clientdatax- matl_group = 'X'.
s_clientdatax- division = 'X'.
* s_clientdatax- std_descr = 'X'.
* s_clientdatax- hazmatprof = 'X'.
* s_clientdatax- document = 'X'.
s_clientdatax- item_cat = 'X'.
s_clientdatax- trans_grp = 'X'.
s_clientdatax- unit_of_wt = 'X'.
s_clientdatax- net_weight = 'X'.
* s_clientdatax- allowed_wt = 'X'.* s_clientdatax- pur_valkey = 'X'.
* s_clientdatax- minremlife = 'X'.
* s_clientdatax- shelf_life = 'X'.
* s_clientdatax- extmatlgrp = 'X'.
* s_clientdatax- pur_status = 'X'.
s_clientdatax- base_uom_ iso = 'X'.
s_clientdatax- batch_mgmt = 'X'. *------ added by vitthal - start
* s_clientdata- pur_status = wa_upload-xplant.
*----end
s_clientdata- base_uom = wa_upload-basuom.
s_clientdata- base_uom_ iso = wa_upload-basuom.
s_clientdata- matl_group = wa_upload-matgroup.
* s_clientdata- matl_group = mara-matkl. s_clientdata- division = wa_upload-div.
* s_clientdata- std_descr = wa_upload-indstdesc .
* s_clientdata- hazmatprof = wa_upload-dgindprof .
* s_clientdata- document = wa_upload-document.
s_clientdata- item_cat = wa_upload-itmcatgrp .
s_clientdata- trans_grp = wa_upload-transgrp.
s_clientdata- unit_of_wt = wa_upload-unitwt.
s_clientdata- net_weight = wa_upload-netwt.
s_clientdata- allowed_wt = wa_upload-grosswt.
* s_clientdata- pur_valkey = wa_upload-purvalkey .
* s_clientdata- minremlife = wa_upload-minrslife .
* s_clientdata- shelf_life = wa_upload-totslife.
* s_clientdata- extmatlgrp = wa_upload-extmatgp.
s_clientdata- batch_mgmt = wa_upload-batchman.
endform. " f_fill_bapi_ clientdata
*&------------ --------- --------- --------- --------- --------- --------- ---*
*& Form f_fill_bapi_ plantdata
*&------------ --------- --------- --------- --------- --------- --------- ---*
* text
*----------- --------- --------- --------- --------- --------- --------- -----*
* --> p1 text
* <-- p2 text
*----------- --------- --------- --------- --------- --------- --------- -----*
form f_fill_bapi_ plantdata .
CALL FUNCTION 'CONVERSION_ EXIT_ALPHA_ INPUT'
EXPORTING
input = wa_upload-prctr
IMPORTING
OUTPUT = wa_upload-prctr. s_plantdatax- plant = p_werks.
s_plantdatax- availcheck = 'X'.
s_plantdatax- loadinggrp = 'X'.
s_plantdatax- batch_mgmt = 'X'.
s_plantdatax- pur_group = 'X'.
s_plantdatax- profit_ctr = 'X'.
* s_plantdatax- gr_pr_time = 'X'.
* s_plantdatax- ctrl_code = 'X'.
* s_plantdatax- abc_id = 'X'.
* s_plantdatax- mrp_type = 'X'.
* s_plantdatax- reorder_pt = 'X'.
* s_plantdatax- mrp_ctrler = 'X'.
* s_plantdatax- lotsizekey = 'X'.
* s_plantdatax- minlotsize = 'X'.
* s_plantdatax- proc_type = 'X'.
* s_plantdatax- sm_key = 'X'.
* s_plantdatax- plnd_delry = 'X'.
* s_plantdatax- serv_level = 'X'.
* s_plantdatax- period_ind = 'X'.
* s_plantdatax- pur_status = 'X'.
* s_plantdatax- mrp_group = 'X'.
s_plantdata- plant = p_werks ."wa_upload- plant.
* s_plantdata- plant1 = p_werks ."wa_upload- plant1.
s_plantdata- availcheck = wa_upload-availchk.
s_plantdata- loadinggrp = wa_upload-loadgrp.
s_plantdata- batch_mgmt = wa_upload-batchman.
s_plantdata- pur_group = wa_upload-purgrp.
s_plantdata- profit_ctr = wa_upload-prctr.
* s_plantdata- gr_pr_time = wa_upload-grproctim .
* s_plantdata- ctrl_code = wa_upload-ctrlcode.
* s_plantdata- abc_id = wa_upload-abcind.
* s_plantdata- mrp_type = wa_upload-mrptyp.
* s_plantdata- reorder_pt = wa_upload-reordpt.
* s_plantdata- mrp_ctrler = wa_upload-mrpcont.
* s_plantdata- lotsizekey = wa_upload-lotsize.
* s_plantdata- minlotsize = wa_upload-minlotsiz e.
* s_plantdata- proc_type = wa_upload-proctype.
* s_plantdata- sm_key = wa_upload-schmarkey .
* s_plantdata- plnd_delry = wa_upload-pladeltim .
* s_plantdata- serv_level = wa_upload-servlev.
* s_plantdata- period_ind = wa_upload-perind.
* s_plantdata- pur_status = wa_upload-xplant.
* s_plantdata- mrp_group = '0000'.
endform. " f_fill_bapi_ plantdata
*&------------ --------- --------- --------- --------- --------- --------- ---*
*& Form f_fill_bapi_ salesdata
*&------------ --------- --------- --------- --------- --------- --------- ---*
* text
*----------- --------- --------- --------- --------- --------- --------- -----*
* --> p1 text
* <-- p2 text
*----------- --------- --------- --------- --------- --------- --------- -----*
form f_fill_bapi_ salesdata . s_salesx-sales_ org = p_vkorg."wa_ upload-sorg.
s_salesx-distr_ chan = p_vtweg."wa_ upload-dc.
s_salesx-delyg_ plnt = 'X'.
s_salesx-mat_ pr_grp = 'X'.
s_salesx-matl_ stats = 'X'.
s_salesx-acct_ assgt = 'X'.
s_salesx-item_ cat = 'X'.
s_salesx-min_ order = 'X'.
s_salesx-min_ dely = 'X'.
* s_salesx-matl_ grp_1 = 'X'.
* s_salesx-matl_ grp_2 = 'X'.
* s_salesx-matl_ grp_3 = 'X'.
* s_salesx-matl_ grp_4 = 'X'.
* s_salesx-matl_ grp_5 = 'X'.
s_sales-sales_ org = p_vkorg."wa_ upload-sorg.
s_sales-distr_ chan = p_vtweg."wa_ upload-dc
* s_sales-delyg_ plnt = wa_upload-dwerk. .
s_sales-mat_ pr_grp = wa_upload-matprgrp.
s_sales-matl_ stats = wa_upload-matstatgr p.
s_sales-acct_ assgt = wa_upload-accassgrp .
s_sales-item_ cat = wa_upload-itmcatgrp .
s_sales-min_ order = wa_upload-minordqt.
s_sales-min_ dely = wa_upload-mindelvqt .* s_sales-matl_ grp_1 = wa_upload-matgrp1.
* s_sales-matl_ grp_2 = wa_upload-matgrp2.
* s_sales-matl_ grp_3 = wa_upload-matgrp3.
* s_sales-matl_ grp_4 = wa_upload-matgrp4.
* s_sales-matl_ grp_5 = wa_upload-matgrp5.
* s_sales-prod_ att_1 = wa_upload-prodatt1. endform. " f_fill_bapi_ salesdata
*&------------ --------- --------- --------- --------- --------- --------- ---*
*& Form f_fill_bapi_ forcastdata
*&------------ --------- --------- --------- --------- --------- --------- ---*
* text
*----------- --------- --------- --------- --------- --------- --------- -----*
* --> p1 text
* <-- p2 text
*----------- --------- --------- --------- --------- --------- --------- -----*
*FORM f_fill_bapi_ forcastdata .
*
* s_forecastx- plant = p_werks ."wa_upload- plant.
* s_forecastx- fore_model = 'X'.
* s_forecastx- hist_vals = 'X'.
* s_forecastx- init_pds = 'X'.
* s_forecastx- fore_pds = 'X'.
* s_forecastx- initialize = 'X'..
*
*
* s_forecast-plant = p_werks."wa_ upload-plant.
* s_forecast-fore_ model = wa_upload-foremod.
* s_forecast-hist_ vals = wa_upload-histperd.
* s_forecast-init_ pds = wa_upload-initperd.
* s_forecast-fore_ pds = wa_upload-forperd.
* s_forecast-initiali ze = wa_upload-init.
*
*ENDFORM. " f_fill_bapi_ forcastdata
*&------------ --------- --------- --------- --------- --------- --------- ---*
*& Form f_fill_bapi_ whdata
*&------------ --------- --------- --------- --------- --------- --------- ---*
* text
*----------- --------- --------- --------- --------- --------- --------- -----*
* --> p1 text
* <-- p2 text
*----------- --------- --------- --------- --------- --------- --------- -----*
*FORM f_fill_bapi_ whdata .
*
* s_whnox-whse_ no = wa_upload-whno.
* s_whnox-placement = 'X'.
* s_whnox-stgesector = 'X'.
* s_whnox-withdrawal = 'X'.
*
*
*
* s_whno-whse_ no = wa_upload-whno.
* s_whno-placement = wa_upload-stockplac .
* s_whno-stgesector = wa_upload-stosec.
* s_whno-withdrawal = wa_upload-stkremstr a.
*
*ENDFORM.. " f_fill_bapi_ whdata
*&------------ --------- --------- --------- --------- --------- --------- ---*
*& Form f_fill_bapi_ stlocdata
*&------------ --------- --------- --------- --------- --------- --------- ---*
* text
*----------- --------- --------- --------- --------- --------- --------- -----*
* --> p1 text
* <-- p2 text
*----------- --------- --------- --------- --------- --------- --------- -----*
form f_fill_bapi_ stlocdata . s_stolocx-plant = p_werks."wa_ upload-plant.
* s_stolocx-plant1 = p_werks."wa_ upload-plant1.
s_stolocx-stge_ loc = p_lgort."wa_ upload-sloc.
s_stolocx-stge_ bin = 'X'. s_stoloc-plant = p_werks."wa_ upload-plant.
* s_stoloc-plant1 = p_werks."wa_ upload-plant1.
s_stoloc-stge_ loc = p_lgort."wa_ upload-sloc.
* s_stoloc-stge_ bin = wa_upload-stobin_ i.
endform. " f_fill_bapi_ stlocdata
*&------------ --------- --------- --------- --------- --------- --------- ---*
*& Form f_fill_bapi_ sttypdata
*&------------ --------- --------- --------- --------- --------- --------- ---*
* text
*----------- --------- --------- --------- --------- --------- --------- -----*
* --> p1 text
* <-- p2 text
*----------- --------- --------- --------- --------- --------- --------- -----*
*FORM f_fill_bapi_ sttypdata .
*
* s_stotypx-whse_ no = wa_upload-whno.
* s_stotypx-stge_ type = wa_upload-stotype.
* s_stotypx-stge_ bin = 'X'.
*
*
*
* s_stotyp-whse_ no = wa_upload-whno.
* s_stotyp-stge_ type = wa_upload-stotype.
* s_stotyp-stge_ bin = wa_upload-stobin.
*
*
*
*
*ENDFORM. " f_fill_bapi_ sttypdata
*&------------ --------- --------- --------- --------- --------- --------- ---*
*& Form f_fill_bapi_ valclassdata
*&------------ --------- --------- --------- --------- --------- --------- ---*
* text
*----------- --------- --------- --------- --------- --------- --------- -----*
* --> p1 text
* <-- p2 text
*----------- --------- --------- --------- --------- --------- --------- -----*
form f_fill_bapi_ valclassdata . s_valclassx- val_area = p_werks."wa_ upload-plant.
s_valclassx- val_class = 'X'.
s_valclassx- price_ctrl = 'X'.
s_valclassx- moving_pr = 'X'.
s_valclassx- val_cat = 'X'. s_valclass-val_ area = p_werks."wa_ upload-plant.
s_valclass-val_ class = wa_upload-valclass.
s_valclass-price_ ctrl = 'V'.
s_valclass-moving_ pr = wa_upload-mavgprc.
s_valclass-val_ cat = wa_upload-valcat. endform. " f_fill_bapi_ valclassdata
*&------------ --------- --------- --------- --------- --------- --------- ---*
*& Form f_fill_bapi_ taxclassdata
*&------------ --------- --------- --------- --------- --------- --------- ---*
* text
*----------- --------- --------- --------- --------- --------- --------- -----*
* --> p1 text
* <-- p2 text
*----------- --------- --------- --------- --------- --------- --------- -----*
form f_fill_bapi_ taxclassdata . i_taxclass-depcount ry = 'AE'.
i_taxclass-tax_ type_1 = 'MWST'.
i_taxclass-taxclass _1 = wa_upload-taxclass.
append i_taxclass.
clear: i_taxclass.endform. " f_fill_bapi_ taxclassdata
*&------------ --------- --------- --------- --------- --------- --------- ---*
*& Form f_fill_bapi_ uomdata
*&------------ --------- --------- --------- --------- --------- --------- ---*
* text
*----------- --------- --------- --------- --------- --------- --------- -----*
* --> p1 text
* <-- p2 text
*----------- --------- --------- --------- --------- --------- --------- -----*
form f_fill_bapi_ uomdata . i_uomx-alt_unit = wa_upload-basuom.
i_uomx-gross_ wt = 'X'.
i_uomx-unit_ of_wt = 'X'.
* i_uomx-alt_unit_ iso = 'X'.
* i_uomx-numerator = 'X'.
* i_uomx-denominatr = 'X'.
append i_uomx. clear: i_uomx. i_uom-alt_unit = wa_upload-basuom.
i_uom-alt_unit = wa_upload-unitwt. i_uom-gross_ wt = wa_upload-grosswt.
i_uom-unit_of_ wt = wa_upload-unitwt.
* i_uom-alt_unit_ iso = wa_upload-basuom.
* i_uom-numerator = '1'.
* i_uom-denominatr = '1'.
*
append i_uom. clear: i_uom.endform. . " f_fill_bapi_ uomdata
*&------------ --------- --------- --------- --------- --------- --------- ---*
*& Form f_fill_bapi_ matdescdata
*&------------ --------- --------- --------- --------- --------- --------- ---*
* text
*----------- --------- --------- --------- --------- --------- --------- -----*
* --> p1 text
* <-- p2 text
*----------- --------- --------- --------- --------- --------- --------- -----*
form f_fill_bapi_ matdescdata . i_matdesc-langu = sy-langu.
i_matdesc-matl_ desc = wa_upload-matdesc.
append i_matdesc.. clear: i_matdesc.endform. " f_fill_bapi_ matdescdata
*&------------ --------- --------- --------- --------- --------- --------- ---*
*& Form f_get_filename
*&------------ --------- --------- --------- --------- --------- --------- ---*
* text
*----------- --------- --------- --------- --------- --------- --------- -----*
* --> p1 text
* <-- p2 text
*----------- --------- --------- --------- --------- --------- --------- -----*
form 1000_get_filename . call function 'F4_FILENAME'
importing
file_name = v_fname1. p_fname = v_fname1. endform. " 1000_get_filename
*&------------ --------- --------- --------- --------- --------- --------- ---*
*& Form f_initialise_ bapi_tables
*&------------ --------- --------- --------- --------- --------- --------- ---*
* text
*----------- --------- --------- --------- --------- --------- --------- -----*
* --> p1 text
* <-- p2 text
*----------- --------- --------- --------- --------- --------- --------- -----*
form f_initialise_ bapi_tables . clear : s_headdata,
s_clientdatax,
s_clientdata,
s_plantdatax,
s_plantdata,
s_salesx,
s_sales,
* s_forecastx,
* s_forecast,
* s_whnox,
* s_whno,
* s_stolocx,
* s_stoloc,
* s_stotypx,
* s_stotyp,
i_longtext,
s_valclassx,
s_valclass. refresh: i_taxclass,
i_matdesc,
i_longtext,
i_uom,
i_uomx.endform. " f_initialise_ bapi_tables
*&------------ --------- --------- --------- --------- --------- --------- ---*
*& Form f_update_gross_ wt
*&------------ --------- --------- --------- --------- --------- --------- ---*
* text
*----------- --------- --------- --------- --------- --------- --------- -----*
* --> p1 text
* <-- p2 text
*----------- --------- --------- --------- --------- --------- --------- -----*
form f_update_gross_ wt . update mara set brgew = wa_upload-grosswt where matnr = wa_upload-mat
. if sy-subrc eq 0. commit work. endif.endform. " f_update_gross_ wt
*&------------ --------- --------- --------- --------- --------- --------- ---*
*& Form f_check_uom_ from_mara
*&------------ --------- --------- --------- --------- --------- --------- ---*
* text
*----------- --------- --------- --------- --------- --------- --------- -----*
* --> p1 text
* <-- p2 text
*----------- --------- --------- --------- --------- --------- --------- -----*
form f_check_uom_ from_mara . select single meins from mara into mara-meins
where matnr = wa_upload-mat. if sy-subrc eq 0. if mara-meins ne wa_upload-basuom.
wa_upload-basuom = mara-meins.
endif. else.
clear mara-meins.
endif.endform. " f_check_uom_ from_mara
*&------------ --------- --------- --------- --------- --------- --------- ---*
*& Form display_common_ mtrl
*&------------ --------- --------- --------- --------- --------- --------- ---*
* text
*----------- --------- --------- --------- --------- --------- --------- -----*
* --> p1 text
* <-- p2 text
*----------- --------- --------- --------- --------- --------- --------- -----*
form display_common_ mtrl .
write : / '*********** ***** Common material *********'.
loop at i_common.
write : / i_common-matnr.
endloop.
endform. " display_common_ mtrl
*&------------ --------- --------- --------- --------- --------- --------- ---*
*& Form f_get_original_ mtrlgroup
*&------------ --------- --------- --------- --------- --------- --------- ---*
* text
*----------- --------- --------- --------- --------- --------- --------- -----*
* --> p1 text
* <-- p2 text
*----------- --------- --------- --------- --------- --------- --------- -----*
form f_get_original_ mtrlgroup .
select single matkl into mara-matkl
from mara
where matnr eq i_upload-mat.
if sy-subrc ne 0.
* CLEAR : mara-matkl.
*Added by Urvashi on 6/11/03
mara-matkl = wa_upload-matgroup.
*End Addition 6/11/03
endif.
* IF sy-subrc EQ 0.
* i_upload-basuom = mara-meins.
* IF mara-meins = 'ST'.
* i_upload-basuom = 'PC'.
* ENDIF.
* i_upload-matgroup = mara-MATKL.
* ENDIF.
endform. " f_get_original_ mtrlgroup
*&------------ --------- --------- --------- --------- --------- --------- ---*
*& Form f_upload_from_ pr
*&------------ --------- --------- --------- --------- --------- --------- ---*
* text
*----------- --------- --------- --------- --------- --------- --------- -----*
* --> p1 text
* <-- p2 text
*----------- --------- --------- --------- --------- --------- --------- -----*
form f_upload_from_ pr .
call function 'WS_UPLOAD'
exporting
filename = p_fname
filetype = 'DAT'
tables
data_tab = i_upload
exceptions
conversion_error = 1
file_open_error = 2
file_read_error = 3
invalid_type = 4
no_batch = 5
unknown_error = 6
invalid_table_ width = 7
gui_refuse_filetran sfer = 8
customer_error = 9
no_authority = 10
others = 11.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
endform. " f_upload_from_ pr
*&------------ --------- --------- --------- --------- --------- --------- ---*
*& Form f_upload_from_ ap
*&------------ --------- --------- --------- --------- --------- --------- ---*
* text
*----------- --------- --------- --------- --------- --------- --------- -----*
* --> p1 text
* <-- p2 text
*----------- --------- --------- --------- --------- --------- --------- -----*
form f_upload_from_ ap .
*-------DCLK902489
* constants : v_filepath like rlgrap-filename
* value
* '/usr/sap/MBL/ DVEBMGS00/ work/PA_INTERFAC E/initial_ upload/'.
** '/usr/sap/DCL/ DVEBMGS02/ work/PA_INTERFAC E/initial_ upload/'.
*
* data: v_filepath1 like rlgrap-filename.
*
** concatenate v_filepath p_fn_ap into v_filepath1.
*
**Open Dataset for reading file data
* open dataset v_filepath1
* for input in text mode encoding default.
*
* if sy-subrc eq 0.
* do.
* read dataset v_filepath1 into wa_upload1.
* if sy-subrc >< 0.
* exit.
* else.
* perform f_split_data.
* endif.
* enddo.
* endif.
*
**Close dataset.
* close dataset v_filepath1.
*
endform. " f_upload_from_ ap
*&------------ --------- --------- --------- --------- --------- --------- ---*
*& Form f_split_data
*&------------ --------- --------- --------- --------- --------- --------- ---*
* text
*----------- --------- --------- --------- --------- --------- --------- -----*
* --> p1 text
* <-- p2 text
*----------- --------- --------- --------- --------- --------- --------- -----*
form f_split_data . data: v_junk(10). split wa_upload1 at c_delim into
i_upload-plant
i_upload-mat
i_upload-sloc
* i_upload-sorg
* i_upload-dc
* i_upload-whno
* i_upload-stotype
i_upload-matdesc
i_upload-basuom
i_upload-matgroup
i_upload-div
* i_upload-xplant
* i_upload-indstdesc
* i_upload-dgindprof
* i_upload-document* i_upload-taxcat
* i_upload-xdisstat
* i_upload-validfr
i_upload-taxclass i_upload-dwerk
i_upload-matprgrp
i_upload-matstatgrp
i_upload-accassgrp
* i_upload-genitmcatg rp
i_upload-itmcatgrp
i_upload-mindelvqt
i_upload-minordqt
* i_upload-matgrp1
* i_upload-matgrp2
* i_upload-matgrp3
* i_upload-matgrp4
* i_upload-matgrp5
* i_upload-extmatgp
i_upload-availchk
i_upload-transgrp
i_upload-grosswt
i_upload-unitwt
i_upload-netwt
i_upload-loadgrp
i_upload-batchman
i_upload-salestext
i_upload-purgrp
i_upload-prctr
* i_upload-grproctim
* i_upload-purvalkey
* i_upload-ctrlcode
i_upload-potext* i_upload-abcind
* i_upload-mrptyp
* i_upload-reordpt
* i_upload-mrpcont
* i_upload-lotsize
* i_upload-minlotsize
*
* i_upload-proctype
* i_upload-schmarkey
* i_upload-pladeltim
* i_upload-servlev
*
*
* i_upload-foremod
* i_upload-histperd
* i_upload-initperd
* i_upload-forperd
* i_upload-init
* i_upload-perind
* i_upload-stobin_ i
*
*
* i_upload-minrslife
* i_upload-totslife
* i_upload-pindsled
*
* i_upload-stkremstra
* i_upload-stockplac
* i_upload-stosec
* i_upload-stobin
i_upload-valcat
i_upload-valclass
* i_upload-prctrl
i_upload-mavgprc
v_junk. replace all occurrences of c_delim in i_upload-mavgprc with 'E'.
if i_upload-mavgprc( 1) = 'E'.
clear i_upload-mavgprc.
endif.
append i_upload. clear i_upload.endform. " f_split_data
*&------------ --------- --------- --------- --------- --------- --------- ---*& Form f_get_uom
*&------------ --------- --------- --------- --------- --------- --------- ---* text
*----------- --------- --------- --------- --------- --------- --------- -----* --> p1 text
* <-- p2 text
*----------- --------- --------- --------- --------- --------- --------- -----form f_get_uom . call function 'CONVERSION_ EXIT_CUNIT_ INPUT'
exporting
input = wa_upload-basuom
language = sy-langu
importing
output = wa_upload-basuom
exceptions
unit_not_found = 1
others = 2. if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.endform. " f_get_uom
*&------------ --------- --------- --------- --------- --------- --------- ---*
*& Form f_fill_bapi_ longtextdata
*&------------ --------- --------- --------- --------- --------- --------- ---*
* text
*----------- --------- --------- --------- --------- --------- --------- -----*
* --> p1 text
* <-- p2 text
*----------- --------- --------- --------- --------- --------- --------- -----*
form f_fill_bapi_ longtextdata .data: begin of v_obj_key ,
matnr like mara-matnr,
vkorg like RMMG1-VKORG,
vtweg like RMMG1-VTWEG,
end of v_obj_key.v_ obj_key-matnr = wa_upload-mat.
v_obj_key-vkorg = p_vkorg.
v_obj_key-vtweg = p_vtweg.*--- ----- Sales text
i_longtext-TEXT_ NAME = v_obj_key.
i_longtext-APPLOBJE CT = 'MVKE'.i_longtext- TEXT_ID = '0001'.
i_longtext-langu = 'EN'.
i_longtext-TEXT_ LINE = wa_upload-salestext .
append i_longtext. clear i_longtext.
*-------- Purchase text
i_longtext-TEXT_ NAME = wa_upload-mat.
i_longtext-TEXT_ ID = 'BEST'.
i_longtext-APPLOBJE CT = 'MATERIAL'.i_ longtext- langu = 'EN'.
i_longtext-TEXT_ LINE = wa_upload-potext.
append i_longtext. clear i_longtext.endform. " f_fill_bapi_ longtextdata