Bdc for MM01 with classification view
Hi all,
I need to create materials using mm01 with classification view. since there is no bapi supporting this view, i am ding by bdc.
The problem is in classification view once i give the class type and name a screen pops with caption
characteristic value assignment, but theere are no charateristics displayed - wat values do i have to enter here >
once i leave this screen the characteristics show up one after the other and i can load the details. but then while tryin to save error comes staing incnsisitent value assigned. wat do i ener in the intermediate screen t avoid this error.
thanks
hi when you are creating a classification view with characteristics.. you need to do all at once... you cannot modify..
all you can do is delete the whole view and create with all the changed again.. I dont memorize the BAPI .. but you have BAPIdelete.. BAPIadd..
Similar Messages
-
Batch Determination in SD - Need for Material Master Classification View
Hi!
Is it mandatory to have the classification view of the material maintained to enable expiry date based batch determination at delivery creation?
I have configured BD for the delivery. When testing with a material for which the classification view is maintained, the batch is determined. When testing with a material for which the classification view is <b>not</b> maintained, the batch is not determined.
Appreciate that this may seem like a strange question given what the testing shows but I am working with a colleague who is adamant that the classification view on the material master is not required.
Any casting votes would be much appreciated and rewarded accordingly. Thanks, DuncanClassification of batches is mandatory if you want to use the batch determination feature.
source: http://help.sap.com/saphelp_erp2005/helpdata/en/4d/2b8bd043ad11d189410000e829fbbd/frameset.htm -
Transfer of material master data with Classification view
Dear Experts
I want to transfer material master data between R/3 using ALE. We are able to send master data using BD10 without classification view.
Please let me know in detail the configuration, steps invloved in sending materail master along with classification view.
Regards
SamalHAI FRIENDS,
CHANGING CLASSIFICATION VIEW FOR MATERIAL USING BAPI
->CREATE CHARACTERISTIC USING TCODE CT04
->CREATE CLASS USING TCODE CL01 .
-> RUN THIS PROGRAM TO CHANGE THE CLASSIFICATION VIEW
PARAMETERS: P_MATNR TYPE MARA-MATNR. "MATERIAL
DATA: OBJECTKEY TYPE BAPI1003_KEY-OBJECT,
OBJECTTABLE TYPE BAPI1003_KEY-OBJECTTABLE,
CLASSNUM TYPE BAPI1003_KEY-CLASSNUM,
CLASSTYPE TYPE BAPI1003_KEY-CLASSTYPE,
ALLOCVALUESNUMNEW TYPE TABLE OF BAPI1003_ALLOC_VALUES_NUM WITH HEADER LINE,
ALLOCVALUESCHARNEW TYPE TABLE OF BAPI1003_ALLOC_VALUES_CHAR WITH HEADER LINE,
ALLOCVALUESCURRNEW TYPE TABLE OF BAPI1003_ALLOC_VALUES_CURR WITH HEADER LINE,
RETURN TYPE TABLE OF BAPIRET2 WITH HEADER LINE.
OBJECTKEY = P_MATNR.
OBJECTTABLE = 'MARA'.
CLASSNUM = 'MTS_CABLE_BIN1'. "CLASS(CREATED USING CL01)
CLASSTYPE = '023'. "CLASS TYPE (023 FOR BATCH)
CALL FUNCTION 'BAPI_OBJCL_CHANGE'
EXPORTING
OBJECTKEY = OBJECTKEY
OBJECTTABLE = OBJECTTABLE
CLASSNUM = CLASSNUM
CLASSTYPE = CLASSTYPE
STATUS = '1'
STANDARDCLASS =
CHANGENUMBER =
KEYDATE = SY-DATUM
NO_DEFAULT_VALUES = ' '
IMPORTING
CLASSIF_STATUS =
TABLES
ALLOCVALUESNUMNEW = ALLOCVALUESNUMNEW
ALLOCVALUESCHARNEW = ALLOCVALUESCHARNEW
ALLOCVALUESCURRNEW = ALLOCVALUESCURRNEW
RETURN = RETURN
LOOP AT RETURN.
WRITE: / RETURN-TYPE ,RETURN-MESSAGE.
ENDLOOP.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT =
IMPORTING
RETURN =
BY VENKATESWARAREDDY D
MYTEC SOFT LTD -
BDC for IW52 with giving Priority
Hi All,
I'll we very thankful if any one please help me in doing BDC for IW52 with giving Priority value .
Actually I don't able to find Priority option in IW52.
It'll be highly applicable if any one help me for this.
ThanksHi,
I think you can make use of the FM "ALM_ME_NOTIFICATION_CHANGE" instead of IW52 BDC.
Regards,
Smart Varghese -
Hi all.
I need BDC code for MM01,i need to populate values depending upon "Material type",Because view changing depending upon material type.
please give me code for that.
To be reward all helpfull answers.
Regards.
jayHi,
This is a BDC for MM for T-code MM01.I hope this will help u.
Below is the coding.
Reward if helpful.
Regards,
Seevangi
REPORT ZMMBDC_MATERIAL_MASTER_UPD
LINE-SIZE 255 NO STANDARD PAGE HEADING LINE-COUNT 65.
Tables
Structure declaration
Work Variables and internal tables
Constants
Parameters
Events: Start-Of-Selection
data : begin of i_mara occurs 0,
matnr like mara-matnr,
end of i_mara.
data : begin of ty_matdata,
matnr like mara-matnr, "material number
mbrsh like rmmg1-mbrsh, "Industry sector
mtart like rmmg1-mtart, "Material Type
werks like rmmg1-werks, "Plant
lgort like rmmg1-lgort, "Storage Location
vkorg like rmmg1-vkorg, "Sales Organization
vtweg like rmmg1-vtweg, "Distribution Channel
maktx like makt-maktx, "Material Description (Short Text)
meins like mara-meins, "Base Unit of Measure
matkl like mara-matkl, "Material Group
bismt like mara-bismt, "Old material number
spart like mara-spart, "Division
brgew(15) ," like mara-brgew, "Gross Weight
ntgew(15), " like mara-ntgew, "Net Weight
ekgrp like marc-ekgrp, "Purchasing Group
gewei like mara-gewei, "Weight Unit
klart like rmclf-klart, "Class Type
taxkm like MG03STEUER-TAXKM, "Tax classification material
ladgr like marc-ladgr, "Loading Group
tragr like mara-tragr, "Transportation Group
dismm like marc-dismm, "MRP Type
dispo like marc-dispo, "MRP Controller (Materials Planner)
fhori like marc-fhori, "Scheduling margin key
disls like marc-disls, " lot size
prmod like mpop-prmod, "Forecast model
peran(3)," like mpop-peran, "Number of historical periods
anzpr(3)," like mpop-anzpr, "Number of forecast periods
kzini like mpop-kzini, "Initialization indicator
siggr(9)," like mpop-siggr, "Tracking limit
autru like marc-autru, "Reset Forecast Model Automatically
modav like mpop-modav, "Model selection procedure
perkz like marc-perkz, "Period Indicator
verpr(13), " like mbew-verpr, "Moving Average Price/Periodic Unit Price
prctr like marc-prctr, "Profit Center
mtvfp like marc-mtvfp, "Checking Group for Availability Check
bklas like mbew-bklas, "Valuation Class
vprsv like mbew-vprsv, "Price control indicator
stprs(13) ," like mbew-stprs, "Standard price
peinh(5) ,"like mbew-peinh, "Price Unit
end of ty_matdata,
begin of ty_matdata1,
matnr like mara-matnr, "material number
mbrsh like rmmg1-mbrsh, "Industry sector
mtart like rmmg1-mtart, "Material Type
werks like rmmg1-werks, "Plant
lgort like rmmg1-lgort, "Storage Location
vkorg like rmmg1-vkorg, "Sales Organization
vtweg like rmmg1-vtweg, "Distribution Channel
maktx like makt-maktx, "Material Description (Short Text)
meins like mara-meins, "Base Unit of Measure
matkl like mara-matkl, "Material Group
bismt like mara-bismt, "Old material number
spart like mara-spart, "Division
brgew(15) ," like mara-brgew, "Gross Weight
ntgew(15), " like mara-ntgew, "Net Weight
ekgrp like marc-ekgrp, "Purchasing Group
gewei like mara-gewei, "Weight Unit
klart like rmclf-klart, "Class Type
taxkm like MG03STEUER-TAXKM, "Tax classification material
ladgr like marc-ladgr, "Loading Group
tragr like mara-tragr, "Transportation Group
dismm like marc-dismm, "MRP Type
dispo like marc-dispo, "MRP Controller (Materials Planner)
fhori like marc-fhori, "Scheduling margin key
prmod like mpop-prmod, "Forecast model
peran(3)," like mpop-peran, "Number of historical periods
anzpr(3)," like mpop-anzpr, "Number of forecast periods
kzini like mpop-kzini, "Initialization indicator
siggr(9)," like mpop-siggr, "Tracking limit
autru like marc-autru, "Reset Forecast Model Automatically
modav like mpop-modav, "Model selection procedure
perkz like marc-perkz, "Period Indicator
verpr(13), " like mbew-verpr, "Moving Average Price/Periodic Unit Price
prctr like marc-prctr, "Profit Center
mtvfp like marc-mtvfp, "Checking Group for Availability Check
bklas like mbew-bklas, "Valuation Class
vprsv like mbew-vprsv, "Price control indicator
stprs(13) ," like mbew-stprs, "Standard price
peinh(5) ,"like mbew-peinh, "Price Unit
message like bapiret2-message, "Error Message.
end of ty_matdata1,
begin of ty_error,
matnr like mara-matnr,
mbrsh like rmmg1-mbrsh, "Industry sector
mtart like rmmg1-mtart, "Material Type
werks like rmmg1-werks, "Plant
message like bapiret2-message,
end of ty_error.
Data Begin with W_ *
data : i_matdata like standard table of ty_matdata with header line.
BAPIMATHEAD - Header Segment with Control Information
data : i_headdata like bapimathead occurs 0 with header line.
bapi_makt - Material Descriptions.
data : i_bapi_makt like bapi_makt occurs 0 with header line.
*bapi_mlan - Tax data
data : i_bapi_mlan like bapi_mlan occurs 0 with header line.
bapi_mara - Material Data at Client Level.
data : i_clientdata like bapi_mara occurs 0 with header line.
bapi_marax - Checkbox Structure for BAPI_MARA.
data : i_clientdatax like bapi_marax occurs 0 with header line.
bapi_marc - Material Data at Plant Level.
data : i_plantdata like bapi_marc occurs 0 with header line.
bapi_marcx - Checkbox Structure for BAPI_MARA.
data : i_plantdatax like bapi_marcx occurs 0 with header line.
BAPI_MARD - Material Data at Storage Location Level.
data : i_storagelocationdata like bapi_mard occurs 0 with header line.
bapi_mardx - Checkbox Structure for BAPI_MARD
data : i_storagelocationdatax like bapi_mardx occurs 0 with header line.
*bapi_mpop - Forecast Parameters
data : i_forcastingparameter like BAPI_MPOP occurs 0 with header line.
*bapi_mpopx - Checkbox Structure for BAPI_MPOP
data : i_forcastingparameterx like BAPI_MPOPX occurs 0 with header line.
*bapi_mbew - Valuation Data
data : i_valuationdata like BAPI_MBEW occurs 0 with header line.
*bapi_mbewx - Checkbox Structure for BAPI_MBEW
data : i_valuationdatax like BAPI_MBEWX occurs 0 with header line.
*bapi_mvke - Sales Data
data : i_salesdata like BAPI_MVKE occurs 0 with header line.
*bapi_mvkex - Checkbox Structure for BAPI_MVKE
data : i_salesdatax like BAPI_MVKEX occurs 0 with header line.
bapiret2 - Return parameter
data : i_return like bapiret2 occurs 0 with header line.
Errors displayed on screen.
data : i_error like standard table of ty_error with header line.
*Error data to be loaded after correction.
data : i_matdata1 like standard table of ty_matdata1 with header line.
*bapi_marm - Unit of measure
data : i_bapi_marm like bapi_marm occurs 0 with header line.
*bapi_marmx - unit of measurex
data : i_bapi_marmx like bapi_marmx occurs 0 with header line.
To determine error.
data : w_flg(1).
S E L E C T I O N S C R E E N / P A R A M E T E R S
selection-screen: begin of block b1 with frame.
parameters: p_file like rlgrap-filename obligatory.
selection-screen: end of block b1.
selection-screen skip 1.
selection-screen: begin of block b2 with frame.
parameters: p_file1 like rlgrap-filename .
selection-screen: end of block b2.
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.
WS_FILENAME_GET - Determination of a file name on the presentation
server using a file selection dialog.
call function 'WS_FILENAME_GET'
exporting
def_filename = '*.TXT'
def_path = 'C:\'
mask = ',.TXT,.*.'
mode = 'O'
TITLE = ' '
importing
filename = p_file
RC =
exceptions
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
others = 5
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
T O P O F P A G E *
top-of-page.
skip.
write : /01 'Material Number', 30 'Error Message'.
S T A R T O F S E L E C T I O N
start-of-selection.
perform read_data.
perform create_material.
perform display_error.
*& Form read_data
text
--> p1 text
<-- p2 text
form read_data.
Uploads a file from the presentation server into an internal table.
call function 'WS_UPLOAD'
exporting
codepage = 'IBM'
filename = p_file
filetype = 'DAT'
tables
data_tab = i_matdata
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_filetransfer = 8
customer_error = 9
others = 10.
if sy-subrc <> 0.
write:/ 'File Not Uploaded'.
endif.
endform. " read_data
*& Form create_material
text
--> p1 text
<-- p2 text
form create_material.
loop at i_matdata.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = i_matdata-matnr
IMPORTING
OUTPUT = i_matdata-matnr.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = i_matdata-prctr
IMPORTING
OUTPUT = i_matdata-prctr
*select matnr from mara into table i_mara .
*sort i_mara by matnr descending.
*read table i_mara index 1.
*i_mara-matnr = i_mara-matnr + 1.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
INPUT = i_mara-matnr
IMPORTING
OUTPUT = i_mara-matnr
EXCEPTIONS
LENGTH_ERROR = 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.
*CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
INPUT = i_matdata-matnr
IMPORTING
OUTPUT = i_matdata-matnr
EXCEPTIONS
LENGTH_ERROR = 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.
i_headdata-material = i_matdata-matnr.
i_headdata-material = i_mara-matnr.
i_headdata-ind_sector = i_matdata-mbrsh.
i_headdata-matl_type = i_matdata-mtart.
i_headdata-basic_view = 'X'.
i_headdata-mrp_view = 'X'.
i_headdata-storage_view = 'X'.
i_headdata-SALES_VIEW = 'X'.
i_headdata-PURCHASE_VIEW = 'X'.
i_headdata-FORECAST_VIEW = 'X'.
i_headdata-ACCOUNT_VIEW = 'X'.
i_headdata-COST_VIEW = 'X'.
i_headdata-prt_view = 'X'.
i_headdata-work_sched_view = 'X'.
i_headdata-quality_view = 'X'.
append i_headdata.
clear i_headdata.
i_bapi_makt-langu = sy-langu.
i_bapi_makt-matl_desc = i_matdata-maktx.
append i_bapi_makt.
clear i_bapi_makt.
i_clientdata-matl_group = i_matdata-matkl.
i_clientdata-old_mat_no = i_matdata-bismt.
i_clientdata-base_uom = i_matdata-meins.
i_clientdata-division = i_matdata-spart.
i_clientdata-UNIT_OF_WT = i_matdata-gewei.
i_clientdata-TRANS_GRP = i_matdata-tragr.
i_clientdata-NET_WEIGHT = i_matdata-ntgew.
append i_clientdata.
clear i_clientdata.
i_clientdatax-matl_group = 'X'.
i_clientdatax-old_mat_no = 'X'.
i_clientdatax-base_uom = 'X'.
i_clientdatax-division = 'X'.
i_clientdatax-UNIT_OF_WT = 'X'.
i_clientdatax-TRANS_GRP = 'X'.
i_clientdatax-NET_WEIGHT = 'X'.
append i_clientdatax.
clear i_clientdatax.
i_plantdata-plant = i_matdata-werks.
i_plantdata-mrp_type = i_matdata-dismm.
i_plantdata-mrp_ctrler = i_matdata-dispo.
i_plantdata-availcheck = i_matdata-mtvfp.
i_plantdata-profit_ctr = i_matdata-prctr.
i_plantdata-LOADINGGRP = i_matdata-ladgr.
i_plantdata-PUR_GROUP = i_matdata-ekgrp.
i_plantdata-AUTO_RESET = i_matdata-autru.
i_plantdata-PERIOD_IND = i_matdata-perkz.
i_plantdata-MRP_CTRLER = i_matdata-dispo.
i_plantdata-SM_KEY = i_matdata-fhori.
i_plantdata-LOTSIZEKEY = i_matdata-disls.
append i_plantdata.
clear i_plantdata.
i_plantdatax-plant = i_plantdata-plant.
i_plantdatax-mrp_type = 'X'.
i_plantdatax-mrp_ctrler = 'X'.
i_plantdatax-availcheck = 'X' .
i_plantdatax-profit_ctr = 'X' .
i_plantdatax-LOADINGGRP = 'X' .
i_plantdatax-PUR_GROUP = 'X' .
i_plantdatax-AUTO_RESET = 'X'.
i_plantdatax-PERIOD_IND = 'X'.
i_plantdatax-MRP_CTRLER = 'X'.
i_plantdatax-SM_KEY = 'X'.
i_plantdatax-LOTSIZEKEY = 'X'.
append i_plantdatax.
clear i_plantdatax.
clear i_forcastingparameter.
i_forcastingparameter-PLANT = i_matdata-werks.
i_forcastingparameter-HIST_VALS = i_matdata-peran.
i_forcastingparameter-FORE_PDS = i_matdata-anzpr.
i_forcastingparameter-INITIALIZE = i_matdata-kzini.
i_forcastingparameter-TRACKLIMIT = i_matdata-siggr.
i_forcastingparameter-MODEL_SP = i_matdata-modav.
i_forcastingparameter-FORE_MODEL = i_matdata-prmod.
append i_forcastingparameter.
clear i_forcastingparameterx.
i_forcastingparameterx-PLANT = i_matdata-werks.
i_forcastingparameterx-HIST_VALS = 'X'.
i_forcastingparameterx-FORE_PDS = 'X'.
i_forcastingparameterx-INITIALIZE = 'X'.
i_forcastingparameterx-TRACKLIMIT = 'X'.
i_forcastingparameterx-MODEL_SP = 'X'.
i_forcastingparameterx-FORE_MODEL = 'X'.
append i_forcastingparameterx.
i_valuationdata-MOVING_PR = i_matdata-verpr.
i_valuationdata-STD_PRICE = i_matdata-stprs.
i_valuationdata-PRICE_CTRL = i_matdata-VPRSV.
i_valuationdata-VAL_CLASS = i_matdata-bklas.
i_valuationdata-PRICE_UNIT = i_matdata-peinh.
i_valuationdata-VAL_AREA = i_matdata-werks.
append i_valuationdata.
i_valuationdatax-VAL_AREA = i_matdata-werks.
i_valuationdatax-MOVING_PR = 'X'.
i_valuationdatax-STD_PRICE = 'X'.
i_valuationdatax-PRICE_CTRL = 'X'.
i_valuationdatax-VAL_CLASS = 'X'.
i_valuationdatax-PRICE_UNIT = 'X'.
append i_valuationdatax.
i_salesdata-SALES_ORG = i_matdata-vkorg.
i_salesdata-DISTR_CHAN = i_matdata-vtweg.
i_salesdata-DELY_UOM = i_matdata-meins.
append i_salesdata.
i_salesdatax-SALES_ORG = i_matdata-vkorg.
i_salesdatax-DISTR_CHAN = i_matdata-vtweg.
i_salesdata-DELY_UOM = 'X'.
append i_salesdatax.
i_bapi_marm-ALT_UNIT = i_matdata-meins.
i_bapi_marm-GROSS_WT = i_matdata-brgew.
append i_bapi_marm.
i_storagelocationdata-plant = i_plantdatax-plant.
i_storagelocationdata-stge_loc = i_matdata-lgort.
append i_storagelocationdata.
clear i_storagelocationdata.
i_storagelocationdatax-plant = i_plantdatax-plant.
i_storagelocationdatax-stge_loc = i_storagelocationdata-stge_loc.
append i_storagelocationdatax.
clear i_storagelocationdatax.
i_bapi_mlan-TAXCLASS_1 = i_matdata-TAXKM.
append i_bapi_mlan.
BAPI - BAPI_MATERIAL_SAVEDATA is used to Create and Change Material
Master Data.
call function 'BAPI_MATERIAL_SAVEDATA'
exporting
headdata = i_headdata
clientdata = i_clientdata
clientdatax = i_clientdatax
plantdata = i_plantdata
plantdatax = i_plantdatax
FORECASTPARAMETERS = i_forcastingparameter
FORECASTPARAMETERSX = i_forcastingparameterx
PLANNINGDATA =
PLANNINGDATAX =
storagelocationdata = i_storagelocationdata
storagelocationdatax = i_storagelocationdatax
VALUATIONDATA = i_valuationdata
VALUATIONDATAX = i_valuationdatax
WAREHOUSENUMBERDATA =
WAREHOUSENUMBERDATAX =
SALESDATA = i_salesdata
SALESDATAX = i_salesdatax
STORAGETYPEDATA =
STORAGETYPEDATAX =
FLAG_ONLINE = ' '
FLAG_CAD_CALL = ' '
importing
return = i_return
tables
materialdescription = i_bapi_makt
UNITSOFMEASURE = i_bapi_marm
UNITSOFMEASUREX = i_bapi_marmx
INTERNATIONALARTNOS =
MATERIALLONGTEXT =
TAXCLASSIFICATIONS = i_bapi_mlan
RETURNMESSAGES =
PRTDATA =
PRTDATAX =
EXTENSIONIN =
EXTENSIONINX =
if i_return-type = 'E'.
i_error-matnr = i_mara-matnr.
i_error-mbrsh = i_matdata-mbrsh.
i_error-mtart = i_matdata-mtart.
i_error-werks = i_matdata-werks.
i_error-message = i_return-message.
append i_error.
clear i_error.
w_flg = 'X'.
*else.
Execute external Commit when using BAPIs
When you call BAPIs in your program that change data in the R/3
System afterwards you must call this method to write the changes to *
the database.
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'
importing
return = i_return
endif.
refresh : i_headdata , i_bapi_makt, i_clientdata, i_clientdatax ,
i_plantdata, i_plantdatax,
i_storagelocationdata,i_storagelocationdatax,
i_salesdata , i_salesdatax ,
i_valuationdata , i_valuationdatax,
i_bapi_marm,i_bapi_marmx,
i_bapi_mlan.
clear : i_headdata , i_bapi_makt, i_clientdata, i_clientdatax ,
i_plantdata, i_plantdatax, i_storagelocationdata,
i_storagelocationdatax,
i_valuationdata , i_valuationdatax,
i_bapi_marm,i_bapi_marmx,
i_bapi_mlan.
endloop.
endform. " create_material
*& Form display_error
text
--> p1 text
<-- p2 text
form display_error.
loop at i_error.
read table i_matdata with key matnr = i_error-matnr.
if sy-subrc = 0.
i_matdata1-matnr = i_mara-matnr.
i_matdata1-mbrsh = i_matdata-mbrsh.
i_matdata1-mtart = i_matdata-mtart.
i_matdata1-maktx = i_matdata-maktx.
i_matdata1-meins = i_matdata-meins.
i_matdata1-matkl = i_matdata-matkl.
i_matdata1-bismt = i_matdata-bismt.
i_matdata1-zeinr = i_matdata-zeinr.
i_matdata1-spart = i_matdata-spart.
i_matdata1-werks = i_matdata-werks.
i_matdata1-dismm = i_matdata-dismm.
i_matdata1-dispo = i_matdata-dispo.
i_matdata1-beskz = i_matdata-beskz.
i_matdata1-sobsl = i_matdata-sobsl.
i_matdata1-lgpro = i_matdata-lgpro.
i_matdata1-lgfsb = i_matdata-lgfsb.
i_matdata1-eprio = i_matdata-eprio.
i_matdata1-mtvfp = i_matdata-mtvfp.
i_matdata1-lgort = i_matdata-lgort.
i_matdata1-lgpbe = i_matdata-lgpbe.
i_matdata1-prctr = i_matdata-prctr.
i_matdata1-message = i_error-message.
append i_matdata1.
clear i_matdata1.
endif.
endloop.
loop at i_error.
write :/01 i_error-matnr , 30 i_error-message.
endloop.
if i_error is initial.
write :/01 text-001.
endif.
if w_flg = 'X'.
call function 'WS_DOWNLOAD'
exporting
BIN_FILESIZE = ' '
codepage = 'IBM'
filename = p_file1
filetype = 'DAT'
MODE = ' '
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
COL_SELECT = ' '
COL_SELECTMASK = ' '
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
tables
data_tab = i_error
FIELDNAMES =
exceptions
file_open_error = 1
file_write_error = 2
invalid_filesize = 3
invalid_type = 4
no_batch = 5
unknown_error = 6
invalid_table_width = 7
gui_refuse_filetransfer = 8
customer_error = 9
others = 10
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
endif.
endform. " display_error7 -
Problem in BDC for selecting the QM View in MM02
Hi,
I am facing a problem that when the material is entered select view screen opens and the positioning of QM view is 11 or 13 sometimes. i want the processing should of QM should be irespective of position.
report ZBDC_MM02_QM_VIEW
no standard page heading line-size 255.
include bdcrecx1.
data: begin of record OCCURS 0,
MATNR_001(018),
WERKS_002(004),
ART_003(008),
APA_004(001),
AKTIV_005(001),
end of record.
PARAMETERS : P_FILNAM LIKE RLGRAP-FILENAME.
initialization.
CTUMODE = 'A'.
CUPDATE = 'A'.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILNAM.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
MASK = ',.'
MODE = 'O'
IMPORTING
FILENAME = P_FILNAM
EXCEPTIONS
INV_WINSYS = 1
NO_BATCH = 2
SELECTION_CANCEL = 3
SELECTION_ERROR = 4
OTHERS = 5.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
start-of-selection.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
FILENAME = P_FILNAM
FILETYPE = 'DAT'
TABLES
DATA_TAB = RECORD
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_FILETRANSFER = 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.
LOOP AT RECORD.
ON CHANGE OF RECORD-MATNR_001.
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MATNR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RMMG1-MATNR'
record-MATNR_001.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(11)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(11)'
'X'.
perform bdc_dynpro using 'SAPLMGMM' '0080'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-WERKS'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'RMMG1-WERKS'
record-WERKS_002.
perform bdc_dynpro using 'SAPLMGMM' '4000'.
perform bdc_field using 'BDC_OKCODE'
'=PB01'.
perform bdc_dynpro using 'SAPLQPLS' '0100'.
perform bdc_field using 'BDC_CURSOR'
'RMQAM-ARGUMENT'.
perform bdc_field using 'BDC_OKCODE'
'=NEU'.
perform bdc_field using 'RMQAM-INSMK'
'X'.
perform bdc_field using 'RMQAM-QKZVERF'
'06'.
perform bdc_field using 'RMQAM-PPL'
'X'.
perform bdc_field using 'RMQAM-APP'
'X'.
perform bdc_field using 'RMQAM-DYN'
'X'.
perform bdc_field using 'RMQAM-MER'
'X'.
perform bdc_field using 'RMQAM-AVE'
'X'.
perform bdc_dynpro using 'SAPLQPLS' '0100'.
perform bdc_field using 'BDC_CURSOR'
'RMQAM-AKTIV(01)'.
perform bdc_field using 'BDC_OKCODE'
'=WEIT'.
perform bdc_field using 'RMQAM-ART(01)'
record-ART_003.
perform bdc_field using 'RMQAM-AKTIV(01)'
'X'.
perform bdc_transaction using 'MM02'.
ENDON.
ENDLOOP.Hi,
Use following code
CALL FUNCTION 'MATERIAL_BTCI_SELECTION_NEW'
EXPORTING
MATERIAL = IT_UPLOAD-MATNR " Material number
MATERIALART = GI_MARA-MTART " Material Type
SELECTION = 'Q' " PSTAT(maintenance status) value for Quality Managemant.
TCODE = 'MM01' " Tcode where view's are called.
TABLES
BTCI_D0070 = IT_BDCDATA_VIEW
EXCEPTIONS
MATERIAL_NOT_FOUND = 1
MATERIAL_NUMBER_MISSING = 2
MATERIAL_TYPE_MISSING = 3
MATERIAL_TYPE_NOT_FOUND = 4
NO_ACTIVE_DYNPRO_SELECTED = 5
NO_AUTHORITY = 6
OTHERS = 7.
READ TABLE IT_BDCDATA_VIEW WITH KEY FVAL = 'X'.
IF SY-SUBRC = 0.
V_SELECTION = IT_BDCDATA_VIEW-FNAM.
VAR = IT_BDCDATA_VIEW-FNAM+17(2).
IF VAR > '17'.
VAR = VAR - 17.
IF VAR NE '2'.
CONCATENATE '0' VAR INTO VAR.
ENDIF.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=P+'.
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '0070'.
CONCATENATE 'MSICHTAUSW-DYTXT(' VAR ')' INTO VAR1.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
VAR1.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTR'.
CLEAR VAR1.
CONCATENATE 'MSICHTAUSW-KZSEL(' VAR ')' INTO VAR1.
PERFORM BDC_FIELD USING VAR1
'X'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTR'.
ENDIF.
IF VAR < '17'.
CONCATENATE 'MSICHTAUSW-DYTXT(' VAR ')' INTO VAR1.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
VAR1.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTR'.
CLEAR VAR1.
CONCATENATE 'MSICHTAUSW-KZSEL(' VAR ')' INTO VAR1.
PERFORM BDC_FIELD USING VAR1
'X'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTR'.
ENDIF.
Regards,
Pritish -
BDC for MM01(Material creation)
Hello Please anybody send me code for creating materials with reference to reference material and plant in sselection screen in version ECC 6.0?
My selection screen will be::
Reference material: Plant:Plz User <b>BAPI_MATERIAL_SAVEDATA</b>
Why So :
you will never get it to work correctly in all cases every time for all material types, it is just much easier to work with an API that is not screen dependent. Then you don't have to worry about all of the exceptions when dealing with certain material types, and such. For example, say you have a material which you want to update the po text, and you did your recording for another material, which didn't have a specific view, so now when doing BDC for this material, the screen where you select the view you want to process, may be in a different place in the table control, see what I'm getting at? Its just very much easier to work with BAPIs and is suggest to use BAPI over BDC whenever possible.
Also still u want to go for it, check this code :
REPORT Y730_BDC5 .
*HANDLING TABLE CONTROL IN BDC
DATA : BEGIN OF IT_DUMMY OCCURS 0,
DUMMY(100) TYPE C,
END OF IT_DUMMY.
DATA : BEGIN OF IT_XK01 OCCURS 0,
LIFNR(10) TYPE C,
BUKRS(4) TYPE C,
EKORG(4) TYPE C,
KTOKK(4) TYPE C,
NAME1(30) TYPE C,
SORTL(10) TYPE C,
LAND1(3) TYPE C,
SPRAS(2) TYPE C,
AKONT(6) TYPE C,
FDGRV(2) TYPE C,
WAERS(3) TYPE C,
END OF IT_XK01,
BEGIN OF IT_BANK OCCURS 0,
BANKS(3) TYPE C,
BANKL(10) TYPE C,
BANKN(10) TYPE C,
KOINH(30) TYPE C,
LIFNR(10) TYPE C,
END OF IT_BANK.
DATA : IT_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE,
IT_BDCMSGCOLL LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
FILENAME = 'C:\VENDOR.TXT'
FILETYPE = 'ASC'
TABLES
DATA_TAB = IT_DUMMY.
LOOP AT IT_DUMMY.
IF IT_DUMMY-DUMMY+0(2) = '11'.
IT_XK01-LIFNR = IT_DUMMY-DUMMY+2(10).
IT_XK01-BUKRS = IT_DUMMY-DUMMY+12(4).
IT_XK01-EKORG = IT_DUMMY-DUMMY+16(4).
IT_XK01-KTOKK = IT_DUMMY-DUMMY+20(4).
IT_XK01-NAME1 = IT_DUMMY-DUMMY+24(30).
IT_XK01-SORTL = IT_DUMMY-DUMMY+54(10).
IT_XK01-LAND1 = IT_DUMMY-DUMMY+64(3).
IT_XK01-SPRAS = IT_DUMMY-DUMMY+67(2).
IT_XK01-AKONT = IT_DUMMY-DUMMY+69(6).
IT_XK01-FDGRV = IT_DUMMY-DUMMY+75(2).
IT_XK01-WAERS = IT_DUMMY-DUMMY+77(3).
APPEND IT_XK01.
ELSE.
IT_BANK-BANKS = IT_DUMMY-DUMMY+2(3).
IT_BANK-BANKL = IT_DUMMY-DUMMY+5(10).
IT_BANK-BANKN = IT_DUMMY-DUMMY+15(10).
IT_BANK-KOINH = IT_DUMMY-DUMMY+25(30).
IT_BANK-LIFNR = IT_DUMMY-DUMMY+55(10).
APPEND IT_BANK.
ENDIF.
ENDLOOP.
LOOP AT IT_XK01.
REFRESH IT_BDCDATA.
perform bdc_dynpro using 'SAPMF02K' '0100'.
perform bdc_field using 'BDC_CURSOR'
'RF02K-REF_LIFNR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RF02K-LIFNR'
IT_XK01-LIFNR.
perform bdc_field using 'RF02K-BUKRS'
IT_XK01-BUKRS.
perform bdc_field using 'RF02K-EKORG'
IT_XK01-EKORG.
perform bdc_field using 'RF02K-KTOKK'
IT_XK01-KTOKK.
perform bdc_dynpro using 'SAPMF02K' '0110'.
perform bdc_field using 'BDC_CURSOR'
'LFA1-TELX1'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'LFA1-NAME1'
IT_XK01-NAME1.
perform bdc_field using 'LFA1-SORTL'
IT_XK01-SORTL.
perform bdc_field using 'LFA1-LAND1'
IT_XK01-LAND1.
perform bdc_field using 'LFA1-SPRAS'
IT_XK01-SPRAS.
perform bdc_dynpro using 'SAPMF02K' '0120'.
perform bdc_field using 'BDC_CURSOR'
'LFA1-KUNNR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPMF02K' '0130'.
perform bdc_field using 'BDC_CURSOR'
'LFBK-KOINH(02)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
DATA : FNAM(20) TYPE C,
IDX TYPE C.
MOVE 1 TO IDX.
LOOP AT IT_BANK WHERE LIFNR = IT_XK01-LIFNR.
CONCATENATE 'LFBK-BANKS(' IDX ')' INTO FNAM.
perform bdc_field using FNAM
IT_BANK-BANKS.
CONCATENATE 'LFBK-BANKL(' IDX ')' INTO FNAM.
perform bdc_field using FNAM
IT_BANK-BANKL.
CONCATENATE 'LFBK-BANKN(' IDX ')' INTO FNAM.
perform bdc_field using FNAM
IT_BANK-BANKN.
CONCATENATE 'LFBK-KOINH(' IDX ')' INTO FNAM.
perform bdc_field using FNAM
IT_BANK-KOINH.
IDX = IDX + 1.
ENDLOOP.
perform bdc_dynpro using 'SAPMF02K' '0130'.
perform bdc_field using 'BDC_CURSOR'
'LFBK-BANKS(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_dynpro using 'SAPMF02K' '0210'.
perform bdc_field using 'BDC_CURSOR'
'LFB1-FDGRV'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'LFB1-AKONT'
IT_XK01-AKONT.
perform bdc_field using 'LFB1-FDGRV'
IT_XK01-FDGRV.
perform bdc_dynpro using 'SAPMF02K' '0215'.
perform bdc_field using 'BDC_CURSOR'
'LFB1-ZTERM'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPMF02K' '0220'.
perform bdc_field using 'BDC_CURSOR'
'LFB5-MAHNA'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPMF02K' '0310'.
perform bdc_field using 'BDC_CURSOR'
'LFM1-WAERS'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'LFM1-WAERS'
IT_XK01-WAERS.
perform bdc_dynpro using 'SAPMF02K' '0320'.
perform bdc_field using 'BDC_CURSOR'
'WYT3-PARVW(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
CALL TRANSACTION 'XK01' USING IT_BDCDATA
MODE 'A'
UPDATE 'S'
MESSAGES INTO IT_BDCMSGCOLL.
ENDLOOP.
FORM BDC_DYNPRO USING PROG SCR.
CLEAR IT_BDCDATA.
IT_BDCDATA-PROGRAM = PROG.
IT_BDCDATA-DYNPRO = SCR.
IT_BDCDATA-DYNBEGIN = 'X'.
APPEND IT_BDCDATA.
ENDFORM.
FORM BDC_FIELD USING FNAM FVAL.
CLEAR IT_BDCDATA.
IT_BDCDATA-FNAM = FNAM.
IT_BDCDATA-FVAL = FVAL.
APPEND IT_BDCDATA.
ENDFORM.
All things r available in SDN, please search.
Reward points if useful.
Thanks
vinsee -
HI I HAVE PROBLEM WHEN IAM WRITING BDC FOR MM01
HI,
WHEN IAM WRITING BDC PROGRAM FOR MM01 USING SHDB RECORDING. WHEN I RECORDED SOME VIEWS I MEAN I SCROLLED DOWN AND SELECT THOSE VIEWS.
BUT IT WILL NOT TAKE THOSE VIEWS WHEN I UPLOAD THE DATA THOSE VIEWS ARE NOT SELECTED. PLZ TELL ME HOW COULD I DO THIS.
URGENT PLZ.
THANKS,
MURALI.Hi Murali,
Rather of scrolling down while recording press page down button. as scroll will not get recorded during recording.
The page down function code is P+.
Press page down button on key board while recording.
I had checked it through recording it had worked.
I got BDC_OKCODE = P+ in recording.
This will solve your problem.
Regards
Narin Nandivada -
How to get the list data in MM01/MM02 Classification view
Hi,
Anyone know the FM that we use for getting the list in Clasification View of MM01/MM02?
Thanks,
Alfredhii,
U can use the below fm to get the classification view in MM02..
CLFM_OBJECT_CLASSIFICATION
CLFM_OBJECTS_CLASSIFICATION
BAPI_OBJCL_CREATE_KEY
CLFM_CLASS_CLASSIFICATION
or if u want data from classificaton view then use this function module.
CLAF_CLASSIFICATION_OF_OBJECTS
Regards,
Anil N. -
BDC for MM with different material types.
Hi, Can anyone explain me how the MM01 tcode can be handled in BDC, when material with different material types are present in the flat file. Different material types have different views and hence different recordings....How to handle this scenario?
Based on different types of material, you can able to find out which all views are required to call through BDC. Try to find out views by using tables MARA, MAKT, MARD, MARC etc. Once it is confirmed you can call views using screen numbers.
Here I don't think so more than one recording is required. Record MM01 transaction using Basic Data1, once you go inside the transaction select all the views required to complete the MM01 transaction. It will record all the views (hence screen numbers), then you can switch/call views based on screen numbers.
Hope this helps you to resolve your query. -
HI all ,
i am new to bapi . i have created so many bdcs to upload data in sap but havent done any bapi .
i want to upload data through bapi for mm01 .
how can i achieve this and which bapi is responsible for this job . plz send any sample code for this .
Thanks ,
Amit Ranjan .Hi Amit,
Refer to the code in the following link:
Re: Reg Transfer of MM01 data using BAPI method
Hope this will solve your query... -
Unable to CIF Materials with Classification View
Hi,
We sent materials from R/3 (4.6C) to SCM 4.1.The materials without classifcation view went through successfully. But the materials with classifiation views failed. I have selected the materials,plant,class.characteristics. The organizational indicator is same for material in R/3 and APO. I have seelcted the class type. When I create the integration model an entry in the class is visible.
But the material is not transferred. Did I miss anything ?
If you have any tips or input ,please letme know.
Thanks a lotIn the old way of things - what did change?
Look at the WebAccess on the HTTP view - how long does it say that it
has been up?
rpm -qa novell-group What version
What does the POA report?
If this has all got squirrely rcgrpwise stop, rcapache2 stop and
rctomcat5 stop (then restart them again in reverse order)
T
On Fri, 02 Sep 2011 19:26:02 GMT, taphillips
<[email protected]> wrote:
>
>We have webaccess agent 8.0.2 running on OES SLES 10 sp3.
>In the past few days webaccess users cannot send email when compose
>view is set to html. They will be redirected back to the address bar to
>input an address even though there is already and address listed. Some
>will get the message "you must specify a recipient to send to" It will
>send ok when set to plain text.
>It happens across all operating ystems and different browsers and
>versions I have tried so far.
>I did find and old reference to this problem, but it had to do with an
>older agent working against a newer post office.
>This seemed to happen quite suddenly. We have had several power outages
>in the last week or so but the server has not gone down.
>Any ideas?
>Thanks,
>Tom -
Hi all,
I am performing BDC on MM02 to change MRP2 data.
I have used SELECTION_VIEWS_FIND to get the correct view. It works fine on my screen as i have access to all the views in MM02.
But when the user runs, it errors out as the user is restricted to only MRP view.
How do i get my BDC working based on user view?
Points will rewarded for helpful ansHi Ramesh babu, user has mrp view and my program also uses mrp view.
But the problem is my program when uses the FM SELECTION_VIEWS_FIND, it considers almost all view and the MRP 2 view is at 12 position say, but since user has only mrp view MRP 2 is at position 2 and hence mismatch. Now how do i get the current position of view in my program based on the user view? -
BDC for MM01 - Views not getting selected
Hi,
I have recorded the MM01 transaction and have developed the BDC code. While recording I selected the following views - Basic Data 1, Basic Data 2, Purchasing, Accounting 1 and Accounting 2.
I run the BDC program by call transaction method. I selected the processing mode as 'A'. Now when I execute the program I get the Select view screen. In that Basic data1, basic data2 and purchasing views are getting selected automatically but Accounting 1 and accounting 2 views are not getting selected. When I click ok, the Plant in organization level is not picked up from excel file.
While selecting views when I scroll the views screen then Accounting 1 and accounting 2 views are getting selected and the plant detail is picked from the excel.
Please help.
Regards,
SriramHi,
Use this BDC okcode to get the Accounting tab selected.
T MM01
SAPLMGMM 0060 X
BDC_CURSOR RMMG1-MTART
BDC_OKCODE /00
RMMG1-MTART FERT
SAPLMGMM 0070 X
BDC_CURSOR MSICHTAUSW-DYTXT(02)
BDC_OKCODE =P+
MSICHTAUSW-KZSEL(01) X
MSICHTAUSW-KZSEL(02) X
SAPLMGMM 0070 X
BDC_CURSOR MSICHTAUSW-DYTXT(08)
BDC_OKCODE =ENTR
MSICHTAUSW-KZSEL(07) X
MSICHTAUSW-KZSEL(08) X
Hope this may be useful
Thanks,
Archana -
Hi friends,
I have to upload data using mm01 transaction.
My program has to select respective views according to material type.
Can anybody help me.
Thanks and regards,
Pavani.Hi,
You will save lot of time & energy if you opt to use BAPI_MATERIAL_SAVEDATA. Have a look @the sample code. Please note Do not allocate any points as this code doesn't belong to me, however I have tested it & it works fine.
TABLES bapi_MVKEx.
* FLAGS
DATA: F_STOP. " Flag used to stop processing
* DATA DECLARATIONS
DATA : V_EMPTY TYPE I, " No. of empty records
V_TOTAL TYPE I. " Total no. of records.
* STRUCTURES & INTERNAL TABLES
*--- BAPI structures
DATA: BAPI_HEAD LIKE BAPIMATHEAD, " Header Segment with Control
"Information
BAPI_MAKT LIKE BAPI_MAKT, " Material Description
BAPI_MARA1 LIKE BAPI_MARA, " Client Data
BAPI_MARAX LIKE BAPI_MARAX, " Checkbox Structure for BAPI_MARA
BAPI_MARC1 LIKE BAPI_MARC, " Plant View
BAPI_MARCX LIKE BAPI_MARCX, " Checkbox Structure for BAPI_MARC
BAPI_MBEW1 LIKE BAPI_MBEW, " Accounting View
BAPI_MBEWX LIKE BAPI_MBEWX, " Checkbox Structure for BAPI_MBEW
BAPI_MVKE1 LIKE BAPI_MVKE, "Sales Data
BAPI_RETURN LIKE BAPIRET2. " Return Parameter
DATA: return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
*--- Internal table to hold excel file data
DATA: IT_INTERN TYPE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.
*--- Internal table to hold Matetrial descriptions
DATA: BEGIN OF IT_MAKT OCCURS 100.
INCLUDE STRUCTURE BAPI_MAKT.
DATA: END OF IT_MAKT.
*--- Internal to hold the records in the text file
DATA : BEGIN OF IT_DATA OCCURS 100,
WERKS(4), " Plant
MTART(4), " Material type
MATNR(18), " Material number
MATKL(9) , " Material group
MBRSH(1), " Industry sector
MEINS(3), " Base unit of measure
GEWEI(3), " Weight Unit
SPART(2), " Division
EKGRP(3), " Purchasing group
VPRSV(1), " Price control indicator
STPRS(12), " Standard price
PEINH(3), " Price unit
SPRAS(2), " Language key
MAKTX(40), " Material description
MTPOS_MARA(4), "Item Category Group
vkorg(4), "Sales Org
vtweg(2), "Dist channel
Prdha(18), "Prod Hierarchy
ladgr(4), " Loading Group
prctr(10), "Profit Centr
xchpf(1), "Batch Mgmt
kondm(2), "Material Pricing Grp
ktgrm(2), "Account Assignment Grp
mvgr1(4),
mvgr2(4),
mvgr3(4),
versg(1), "Material Statistics Grp
* Added fields not part of the layout
sapmatnr(18),
END OF IT_DATA.
* SELECTION SCREEN. *
SELECTION-SCREEN BEGIN OF BLOCK SCR1 WITH FRAME TITLE TEXT-111.
PARAMETER : P_FILE TYPE RLGRAP-FILENAME OBLIGATORY DEFAULT " Input File
'H:\DATA\Nova\rbc\zrbc129.xls'.
PARAMETER : P_MAX(4) OBLIGATORY DEFAULT '100'. " no.of recs in a session
PARAMETERS: P_HEADER TYPE I DEFAULT 0. " Header Lines
PARAMETERS: P_BEGCOL TYPE I DEFAULT 1 NO-DISPLAY,
P_BEGROW TYPE I DEFAULT 1 NO-DISPLAY,
P_ENDCOL TYPE I DEFAULT 100 NO-DISPLAY,
P_ENDROW TYPE I DEFAULT 32000 NO-DISPLAY.
SELECTION-SCREEN END OF BLOCK SCR1.
* AT SELECTION-SCREEN
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
*--- Validating file
PERFORM VALIDATE_FILE USING P_FILE.
* START-OF-SELECTION
START-OF-SELECTION.
*--- Perform to convert the Excel data into an internal table
PERFORM CONVERT_XLS_ITAB.
IF NOT IT_DATA[] IS INITIAL.
*--- Perform to delete Header lines
PERFORM DELETE_HEADER_EMPTY_RECS.
ENDIF.
* END OF SELECTION.
END-OF-SELECTION.
*--- Perform to upload Material Master data
PERFORM UPLOAD_MATMAS.
* Form : validate_input_file
* Description : To provide F4 help for file if read from PC
FORM VALIDATE_FILE USING F_FILE TYPE RLGRAP-FILENAME.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
exporting
STATIC = 'X'
CHANGING
FILE_NAME = F_FILE
EXCEPTIONS
MASK_TOO_LONG = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
*MESSAGE S010" 'Error in getting filename'.
ENDIF.
ENDFORM. " validate_input_file
*& Form CONVER_XLS_ITAB
* To convert XLS to internal table
FORM CONVERT_XLS_ITAB.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = P_FILE
I_BEGIN_COL = P_BEGCOL
I_BEGIN_ROW = P_BEGROW
I_END_COL = P_ENDCOL
I_END_ROW = P_ENDROW
TABLES
INTERN = IT_INTERN.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*--- Perform to move the data into an internal data
PERFORM MOVE_DATA.
ENDFORM. " CONVERT_XLS_ITAB
*& Form MOVE_DATA
* text
FORM MOVE_DATA.
DATA : LV_INDEX TYPE I.
FIELD-SYMBOLS: <fs> type any.
*--- Sorting the internal table
SORT IT_INTERN BY ROW COL.
CLEAR IT_INTERN.
LOOP AT IT_INTERN.
MOVE IT_INTERN-COL TO LV_INDEX.
*--- Assigning the each record to an internal table row
ASSIGN COMPONENT LV_INDEX OF STRUCTURE IT_DATA TO <fs>.
*--- Asigning the field value to a field symbol
<fs> = it_intern-value.
*MOVE IT_INTERN-VALUE TO <fs>.
AT END OF ROW.
APPEND IT_DATA.
CLEAR IT_DATA.
ENDAT.
ENDLOOP.
ENDFORM. " MOVE_DATA
*& Form DELETE_HEADER_EMPTY_RECS
* To delete the Header and empty records
FORM DELETE_HEADER_EMPTY_RECS.
DATA: LV_TABIX LIKE SY-TABIX.
IF NOT P_HEADER IS INITIAL.
LOOP AT IT_DATA.
IF P_HEADER > 0 AND NOT IT_DATA IS INITIAL.
DELETE IT_DATA FROM 1 TO P_HEADER.
* P_HEADER = 0.
EXIT.
ENDIF.
ENDLOOP.
ENDIF.
CLEAR IT_DATA.
*--- To delete the empty lines from internal table
LOOP AT IT_DATA.
LV_TABIX = SY-TABIX.
IF IT_DATA IS INITIAL.
V_EMPTY = V_EMPTY + 1.
DELETE IT_DATA INDEX LV_TABIX..
ENDIF.
ENDLOOP.
CLEAR IT_DATA.
*--- Total no of recs in file
DESCRIBE TABLE IT_DATA LINES V_TOTAL.
IF V_TOTAL = 0.
*MESSAGE I013" No records in the file
F_STOP = 'X'.
STOP.
ENDIF.
ENDFORM. " DELETE_HEADER_EMPTY_RECS
*& Form UPLOAD_MATMAS
* to upload Material Master data
FORM UPLOAD_MATMAS .
LOOP AT IT_DATA.
* Header
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = it_data-matnr
IMPORTING
OUTPUT = it_data-sapmatnr
EXCEPTIONS
LENGTH_ERROR = 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.
BAPI_HEAD-MATERIAL = IT_DATA-sapMATNR.
BAPI_HEAD-IND_SECTOR = IT_DATA-MBRSH.
BAPI_HEAD-MATL_TYPE = IT_DATA-MTART.
BAPI_HEAD-BASIC_VIEW = 'X'.
BAPI_HEAD-PURCHASE_VIEW = 'X'.
BAPI_HEAD-ACCOUNT_VIEW = 'X'.
BAPI_HEAD-SALES_VIEW = 'X'.
BAPI_HEAD-QUALITY_VIEW = 'X'.
* Material Description
REFRESH IT_MAKT.
IT_MAKT-LANGU = IT_DATA-SPRAS.
IT_MAKT-MATL_DESC = IT_DATA-MAKTX.
APPEND IT_MAKT.
* Client Data - Basic
BAPI_MARA1-MATL_GROUP = IT_DATA-MATKL.
BAPI_MARA1-BASE_UOM = IT_DATA-MEINS.
BAPI_MARA1-UNIT_OF_WT = IT_DATA-GEWEI.
BAPI_MARA1-DIVISION = IT_DATA-SPART.
BAPI_MARA1-item_cat = it_data-mtpos_mara.
BAPI_MARA1-PROD_HIER = it_data-prdha.
bapi_marax-item_cat = 'X'.
bapi_marax-prod_hier = 'X'.
BAPI_MARAX-MATL_GROUP = 'X'.
BAPI_MARAX-BASE_UOM = 'X'.
BAPI_MARAX-UNIT_OF_WT = 'X'.
BAPI_MARAX-DIVISION = 'X'.
* Plant - Purchasing
BAPI_MARC1-PLANT = IT_DATA-WERKS.
BAPI_MARC1-PUR_GROUP = IT_DATA-EKGRP.
BAPI_MARC1-LOADINGGRP = IT_DATA-LADGR.
BAPI_MARC1-PROFIT_CTR = IT_DATA-prctr.
BAPI_MARC1-BATCH_MGMT = IT_DATA-xchpf.
bapi_marc1-qm_authgrp = 'X'.
bapi_marcx-qm_authgrp = 'X'.
BAPI_MARCX-PLANT = IT_DATA-WERKS.
BAPI_MARCX-PUR_GROUP = 'X'.
BAPI_MARCX-LOADINGGRP = 'X'.
BAPI_MARCX-PROFIT_CTR = 'X'.
BAPI_MARCX-BATCH_MGMT = 'X'.
* Accounting
BAPI_MBEW1-VAL_AREA = IT_DATA-WERKS.
BAPI_MBEW1-PRICE_CTRL = IT_DATA-VPRSV.
BAPI_MBEW1-STD_PRICE = IT_DATA-STPRS.
BAPI_MBEW1-PRICE_UNIT = IT_DATA-PEINH.
BAPI_MBEWX-VAL_AREA = IT_DATA-WERKS.
BAPI_MBEWX-PRICE_CTRL = 'X'.
BAPI_MBEWX-STD_PRICE = 'X'.
BAPI_MBEWX-PRICE_UNIT = 'X'.
* Sales Data
BAPI_MVKE1-ITEM_CAT = IT_DATA-MTPOS_MARA.
BAPI_MVKEX-ITEM_CAT = 'X'.
BAPI_MVKE1-SALES_ORG = IT_DATA-vkorg.
BAPI_MVKEX-SALES_ORG = IT_DATA-vkorg.
BAPI_MVKE1-DISTR_CHAN = IT_DATA-vtweg.
BAPI_MVKEX-DISTR_CHAN = IT_DATA-vtweg.
BAPI_MVKE1-MAT_PR_GRP = IT_DATA-kondm.
BAPI_MVKEX-MAT_PR_GRP = 'X'.
BAPI_MVKE1-ACCT_ASSGT = IT_DATA-ktgrm.
BAPI_MVKEX-ACCT_ASSGT = 'X'.
BAPI_MVKE1-MATL_GRP_1 = IT_DATA-mvgr1.
BAPI_MVKEX-MATL_GRP_1 = 'X'.
BAPI_MVKE1-MATL_GRP_2 = IT_DATA-mvgr2.
BAPI_MVKEX-MATL_GRP_2 = 'X'.
BAPI_MVKE1-MATL_GRP_3 = IT_DATA-mvgr3.
BAPI_MVKEX-MATL_GRP_3 = 'X'.
BAPI_MVKE1-matl_stats = IT_DATA-versg.
BAPI_MVKEX-matl_stats = 'X'.
*--- BAPI to create material
call function 'BAPI_MATERIAL_SAVEDATA'
exporting
HEADDATA = BAPI_HEAD
CLIENTDATA = BAPI_MARA1
CLIENTDATAX = BAPI_MARAX
PLANTDATA = BAPI_MARC1
PLANTDATAX = BAPI_MARCX
SALESDATA = BAPI_MVKE1
SALESDATAX = BAPI_MVKEX
IMPORTING
RETURN = BAPI_RETURN
TABLES
MATERIALDESCRIPTION = IT_MAKT
IF BAPI_RETURN-TYPE = 'E'.
WRITE:/ 'Error:' ,BAPI_RETURN-MESSAGE ,'for material:' ,it_data-matnr.
ELSEIF BAPI_RETURN-TYPE = 'S'.
WRITE: 'Successfully created/Changed material' ,it_data-matnr.
CLEAR return.
REFRESH return.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
IMPORTING
return = return.
ENDIF.
ENDLOOP.
ENDFORM. " UPLOAD_MATMAS
Regards
Raju Chitale
Maybe you are looking for
-
Error installing 10g on Windows Server 2003
I am trying to install Oracle 10g on a Windows Server 2003 box. I'm following the instructions listed here: http://www.oracle.com/technology/obe/10gr2_db_single/install/wininst/wininst_otn.htm Everything seems to go fine up until step 8. My Oracle Ne
-
Why won't my Frame display?
I know this is simple. If I change these components to awt (not swing) they display. As written, no labels display. Why? JFrame display = new JFrame("Printing Batched Reports"); JLabel label = new JLabel("Gathering Agencies To Report",JLabe
-
Exist recovery partition but won't access to reset laptop to factory seting
Dear all, I am using Toshiba satellite L855-S5186, and bad luck, I erased disk by toshiba tool. I inserted windows 8 DVD to check partition, and result is : windows 8 partition lost but Recovery partition still exist and full data, OMG, lucky. And th
-
Collective document created in Depreciation Posting: SAP ECC 6.0
Hi experts, We just migrated from version R/3 4.6C to SAP ECC 6.0. In version 4.6C, when executing Depreciation Run the system created several accounting documents (one per every cost center). In new version SAP ECC 6.0, the system creates just one
-
HT1212 My screen is not working
I can not enter my passcode nor turn my phone off to back up my phone. I am getting a new iPhone and i need to back my current one right now, but iTunes is not letting me due to my passcode. Since my screen is not working, how can I back up my accoun