Upload for MM01
Hi
I am trying to create Recording for MM01 through SHDB Tcode but after selecting views , i m fail to select Plant through search help on next screen. system get stuck and i need to restart the SAP.
Regards
Ammad
thanks for your reply i have to upload material master data ...
i have 59 fields in MS Excel file, i ill get into an internal table through Function module now tell me how can i pass that data to the BAPI
Data is like that E.g
Field Name Data
Industry Sector B
Mat type Fert
Plant 1000
sales Org PBLS
Dist Channel 02
Regards
Ammad
Similar Messages
-
hi all,
this is an extract of materail master upload for mm01 when i execute this recording purchase order text view doesnot get populated with text. anybody can tell me whts wrong with this?????
perform bdc_field using 'MAKT-MAKTX'
'carr'.
perform bdc_dynpro using 'SAPLSTXX' '1100'.
perform bdc_field using 'BDC_CURSOR'
'RSTXT-TXLINE(05)'.
perform bdc_field using 'BDC_OKCODE'
'=TXVB'.
perform bdc_field using 'RSTXT-TXLINE(02)'
'qqqqqqqqqqqqqq ssssssssssssssssssssss'
& 'sssss.00000000000000jjjjjjjjjjjjoo'.
perform bdc_field using 'RSTXT-TXLINE(03)'
'wwwwwwwwwwwwwwwwwwwwwwwwwwwwwww jjjjjj'
& 'jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj'.
perform bdc_field using 'RSTXT-TXLINE(04)'
'kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk'
& 'kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk'.
perform bdc_field using 'RSTXT-TXLINE(05)'
'66666666666666666666666666666666666666'
& '6666666666666666666666666666666666'.
perform bdc_dynpro using 'SAPLSTXX' '1100'.
perform bdc_field using 'BDC_CURSOR'
'RSTXT-TXLINE(06)'.
perform bdc_field using 'BDC_OKCODE'
'=TXBA'.
perform bdc_dynpro using 'SAPLMGMM' '4040'.
perform bdc_field using 'BDC_OKCODE'
'=SP12'.
perform bdc_field using 'MAKT-MAKTX'
'carr'.
perform bdc_dynpro using 'SAPLMGMM' '4000'.Hi
You have to upload the Texts using the CREATE_TEXT fun module
see the sample program
REPORT zmm_longtext
NO STANDARD PAGE HEADING
LINE-SIZE 255.
Internal Table for Upload of Long Texts Data
DATA: BEGIN OF itab1 OCCURS 0,
matnr LIKE mara-matnr, " Material
text LIKE tline-tdline, " Long Text
END OF itab1.
Internal Table for Upload of Long Texts Data
DATA: BEGIN OF itab OCCURS 0,
matnr LIKE mara-matnr, " Material
text LIKE tline-tdline, " Long Text
END OF itab.
To create Long Text lines for CREATE_TEXT function module
DATA:BEGIN OF dt_lines OCCURS 0.
INCLUDE STRUCTURE tline. " Long Text
DATA:END OF dt_lines.
Variable declarations for CREATE_TEXT function module
DATA : dl_name TYPE thead-tdname, " Object Name
dl_lan TYPE thead-tdspras, " Language
gv_matnr TYPE matnr.
Constants
CONSTANTS:
Object ID for Long Text of Material Basic Data 1
c_best TYPE thead-tdid VALUE 'GRUN',
c_material TYPE thead-tdobject VALUE 'MATERIAL'. " Object
Parameters
PARAMETERS p_file LIKE rlgrap-filename.
At selection-screen on Value Request for file Name
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
Get the F4 Values for the File
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
IMPORTING
file_name = p_file.
Start Of Selection
START-OF-SELECTION.
*To Upload Flat file
CALL FUNCTION 'UPLOAD'
EXPORTING
filename = p_file
filetype = 'DAT'
TABLES
data_tab = itab1
EXCEPTIONS
conversion_error = 1
invalid_table_width = 2
invalid_type = 3
no_batch = 4
unknown_error = 5
gui_refuse_filetransfer = 6
OTHERS = 7.
SORT itab1 BY matnr.
LOOP AT itab1.
CLEAR gv_matnr.
SELECT SINGLE matnr INTO gv_matnr
FROM mara WHERE bismt = itab1-matnr.
IF itab1-text NE ' '.
itab-matnr = gv_matnr.
itab-text = itab1-text.
APPEND itab.
ENDIF.
CLEAR itab.
ENDLOOP.
DELETE itab WHERE matnr EQ ' '.
Upload the Texts
SORT itab BY matnr.
LOOP AT itab.
dt_lines-tdformat = 'ST'.
dt_lines-tdline = itab-text.
APPEND dt_lines.
dl_lan = sy-langu.
dl_name = itab-matnr.
Call the Function Module to Create Text
CALL FUNCTION 'CREATE_TEXT'
EXPORTING
fid = c_best
flanguage = dl_lan
fname = dl_name
fobject = c_material
save_direct = 'X'
fformat = '*'
TABLES
flines = dt_lines
EXCEPTIONS
no_init = 1
no_save = 2
OTHERS = 3.
IF sy-subrc <> 0.
WRITE:/ 'Long Text Creation failed for Material'(001),
itab-matnr.
ELSE.
WRITE:/ 'Long Text Created Successfully for Material'(002),
itab-matnr.
ENDIF.
AT END OF matnr.
REFRESH dt_lines.
ENDAT.
ENDLOOP.
Regards
Anji -
Profit Center not getting uploaded through BAPI for MM01. Pls help
Hello all,
I am getting an errror while uploading a file through BAPI for MM01 , The error says
Error:
Profit center 1000/sslcommon does not exist
for material: AC2
*& Report ZBAPI_DUMMY
REPORT ZBAPI_MM01.
*& Report ZBAPI2
TABLES
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
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_RETURN LIKE BAPIRET2, " Return Parameter
BAPI_MARDL LIKE BAPI_MARD,
BAPI_MARDX LIKE BAPI_MARDX.
*--- 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
SPART(2), " Division
EKGRP(3), " Purchasing group
PRCTR(10), " Profit Center
VPRSV(1), " Price control indicator
BKLAS(4), "Valuation Class
*stprs(12), " Standard price
PEINH(3), " Price unit
SPRAS(2), " Language key
MAKTX(40), " Material description
LGORT(4) , " storage location
DISMM(2) , "MRP TYPE
VERPR(23), " Moving Average Price
MTVFP(2) , " Availability Check
DISLS(2) , "Lot Size
DISPO(3) , "MRP Controller
BESKZ(1) , "Procurment Type
FHORI(3) , "SCHEDMARGIN KEY
PERKZ(1) , "Period Indicator
END OF IT_DATA.
SELECTION SCREEN. *
SELECTION-SCREEN BEGIN OF BLOCK SCR1 WITH FRAME TITLE TEXT-111.
PARAMETER : P_FILE TYPE RLGRAP-FILENAME OBLIGATORY " Input File
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 2 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'
CHANGING
FILE_NAME = F_FILE
EXCEPTIONS
MASK_TOO_LONG = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE S010(ZLKPL_MSGCLASS). " 'Error in getting filename'.
ENDIF.
ENDFORM. " validate_input_file
*& Form CONVER_XLS_ITAB
text
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> .
*--- 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
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(ZLKPL_MSGCLASS). " 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
BAPI_HEAD-MATERIAL = IT_DATA-MATNR.
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-storage_view ='X'.
bapi_head-mrp_view = 'X'.
bapi_head-COST_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_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-PROFIT_CTR = IT_DATA-PRCTR.
BAPI_MARC1-MRP_TYPE = IT_DATA-DISMM.
BAPI_MARC1-AVAILCHECK = IT_DATA-MTVFP.
BAPI_MARC1-LOTSIZEKEY = IT_DATA-DISLS.
BAPI_MARC1-MRP_CTRLER = IT_DATA-DISPO.
BAPI_MARC1-PROC_TYPE = IT_DATA-BESKZ.
BAPI_MARC1-SM_KEY = IT_DATA-FHORI.
BAPI_MARC1-PERIOD_IND = IT_DATA-PERKZ.
BAPI_MARCX-PLANT = IT_DATA-WERKS.
BAPI_MARCX-PUR_GROUP = 'X'.
BAPI_MARCX-AVAILCHECK = 'X'.
BAPI_MARCX-PROFIT_CTR = 'X'.
BAPI_MARCX-MRP_TYPE = 'X'.
BAPI_MARCX-MRP_CTRLER = 'X'.
BAPI_MARCX-SM_KEY = 'X'.
BAPI_MARCX-LOTSIZEKEY = 'X'.
Storage Location.
BAPI_MARDL-PLANT = IT_DATA-WERKS.
BAPI_MARDL-STGE_LOC = IT_DATA-LGORT.
BAPI_MARDX-PLANT = IT_DATA-WERKS.
BAPI_MARDX-STGE_LOC = IT_DATA-LGORT.
Accounting
BAPI_MBEW1-VAL_AREA = IT_DATA-WERKS.
BAPI_MBEW1-PRICE_CTRL = IT_DATA-VPRSV.
BAPI_MBEW1-VAL_CLASS = IT_DATA-BKLAS.
BAPI_MBEW1-MOVING_PR = IT_DATA-VERPR.
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'.
BAPI_MBEWX-MOVING_PR = '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
FORECASTPARAMETERS =
FORECASTPARAMETERSX =
PLANNINGDATA =
PLANNINGDATAX =
STORAGELOCATIONDATA = BAPI_MARDL
STORAGELOCATIONDATAX = BAPI_MARDX
VALUATIONDATA = BAPI_MBEW1
VALUATIONDATAX = BAPI_MBEWX
WAREHOUSENUMBERDATA =
WAREHOUSENUMBERDATAX =
SALESDATA = BAPI_MVKE1
SALESDATAX = BAPI_MVKEX
STORAGETYPEDATA =
STORAGETYPEDATAX =
IMPORTING
RETURN = BAPI_RETURN
TABLES
MATERIALDESCRIPTION = IT_MAKT
UNITSOFMEASURE =
UNITSOFMEASUREX =
INTERNATIONALARTNOS =
MATERIALLONGTEXT =
TAXCLASSIFICATIONS =
RETURNMESSAGES =
PRTDATA =
PRTDATAX =
EXTENSIONIN =
EXTENSIONINX =
IF BAPI_RETURN-TYPE = 'E'.
WRITE:/ 'Error:' ,BAPI_RETURN-MESSAGE ,'for material:' ,
IT_DATA-MATNR.
ELSEIF BAPI_RETURN-TYPE = 'S'.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT =
IMPORTING
RETURN = BAPI_RETURN
WRITE: 'Successfully created material' ,IT_DATA-MATNR.
ENDIF.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT =
IMPORTING
RETURN = BAPI_RETURN
ENDLOOP.
ENDFORM. " UPLOAD_MATMASthe Profit center 1000/sslcommon not created. first create the profit center and then upload your data.check tcode KE52 for created profit centers...
-
Using Direct input method(LSMW)Can I upload only 3 fields for MM01
Using Direct input method(LSMW)Can I upload only Matnr,mbrsh,mtart fields for MM01.Otherwise I have to give all the mandatory fields.?
Hello TJK,
LSMW will work in the same way as you create normal material master with the transactions, here you are giving the value through flat file and creating material master with program.
You can create only one view with LSMW but you need to give all mandatory field on that particular view, so if you have only these three field as mandatory then yes it is possible, if you have any more field mandatory addition to these fields then it will not work out, during the last step it will throw error saying "maintain the value for field XXX"
Hope this helps.
Regards
Arif Mansuri -
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... -
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 -
hi gurus,
i want notes for creating materials and to create purchase order using bdc and to upload some datas using that recording from datas in note pad or any external file with screen shots. if any body sent to it ll be very useful to me...
thanks in advance
arunHi,
check the codes for mm01 and me21n.
mm01
report ZBHMAT no standard page heading line-size 255.
DATA:BEGIN OF ITAB OCCURS 0,
MATNR LIKE RMMG1-MATNR,
MBRSH LIKE RMMG1-MBRSH,
MTART LIKE RMMG1-MTART,
KZSEL LIKE MSICHTAUSW-KZSEL,
WERKS LIKE RMMG1-WERKS,
VKORG LIKE RMMG1-VKORG,
VTWEG LIKE RMMG1-VTWEG,
MAKTX LIKE MAKT-MAKTX,
MEINS LIKE MARA-MEINS,
SKTOF LIKE MVKE-SKTOF,
TAXKM LIKE MG03STEUER-TAXKM,
GEWEI LIKE MARA-GEWEI,
MTVFP LIKE MARC-MTVFP,
TRAGR LIKE MARA-TRAGR,
LADGR LIKE MARC-LADGR,
END OF ITAB.
DATA BDCTAB LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = 'C:/BHARAT/MAT.TXT'
FILETYPE = 'ASC'
TABLES
DATA_TAB = ITAB.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = 'MATERIAL'
KEEP = 'X'
USER = SY-UNAME
PROG = SY-CPROG.
LOOP AT ITAB.
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MATNR'.
perform bdc_field using 'RMMG1-MATNR'
ITAB-MATNR.
perform bdc_field using 'RMMG1-MBRSH'
ITAB-MBRSH.
perform bdc_field using 'RMMG1-MTART'
ITAB-MTART.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-KZSEL(04)'.
perform bdc_field using 'MSICHTAUSW-KZSEL(04)'
ITAB-KZSEL.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_dynpro using 'SAPLMGMM' '0080'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-WERKS'.
perform bdc_field using 'RMMG1-WERKS'
ITAB-WERKS.
perform bdc_field using 'RMMG1-VKORG'
ITAB-VKORG.
perform bdc_field using 'RMMG1-VTWEG'
ITAB-VTWEG.
perform bdc_field using 'BDC_OKCODE'
'ENTR'.
perform bdc_dynpro using 'SAPLMGMM' '4000'.
perform bdc_field using 'BDC_CURSOR'
'MAKT-MAKTX'.
perform bdc_field using 'MAKT-MAKTX'
ITAB-MAKTX.
perform bdc_field using 'MARA-MEINS'
ITAB-MEINS.
perform bdc_field using 'MVKE-SKTOF'
ITAB-SKTOF.
perform bdc_field using 'MG03STEUER-TAXKM(01)'
ITAB-TAXKM.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPLMGMM' '4200'.
perform bdc_field using 'BDC_CURSOR'
'MAKT-MAKTX'.
perform bdc_field using 'MAKT-MAKTX'
ITAB-MAKTX.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPLMGMM' '4000'.
perform bdc_field using 'BDC_CURSOR'
'MAKT-MAKTX'.
perform bdc_field using 'MAKT-MAKTX'
ITAB-MAKTX.
perform bdc_field using 'MARA-MEINS'
ITAB-MEINS.
perform bdc_field using 'MVKE-SKTOF'
ITAB-SKTOF.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
perform bdc_dynpro using 'SAPLMGMM' '4000'.
perform bdc_field using 'BDC_CURSOR'
'MAKT-MAKTX'.
perform bdc_field using 'MAKT-MAKTX'
ITAB-MAKTX.
perform bdc_field using 'MARA-MEINS'
ITAB-MEINS.
perform bdc_field using 'MARA-GEWEI'
ITAB-GEWEI.
perform bdc_field using 'MARC-MTVFP'
ITAB-MTVFP.
perform bdc_field using 'MARA-TRAGR'
ITAB-TRAGR.
perform bdc_field using 'MARC-LADGR'
ITAB-LADGR.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'MM01'
TABLES
DYNPROTAB = BDCTAB.
REFRESH BDCTAB.
ENDLOOP.
CALL FUNCTION 'BDC_CLOSE_GROUP'.
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR BDCTAB.
BDCTAB-PROGRAM = PROGRAM.
BDCTAB-DYNPRO = DYNPRO.
BDCTAB-DYNBEGIN = 'X'.
APPEND BDCTAB.
ENDFORM.
FORM BDC_FIELD USING FNAM FVAL.
CLEAR BDCTAB.
BDCTAB-FNAM = FNAM.
BDCTAB-FVAL = FVAL.
APPEND BDCTAB.
ENDFORM.
me21n
report ZBH_PURORDER no standard page heading line-size 255.
PARAMETERS:P_FILE LIKE IBIPPARMS-PATH.
DATA FILENAME TYPE STRING.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = sy-cprog
dynpro_number = sy-dynnr
IMPORTING
file_name = P_FILE.
START-OF-SELECTION.
FILENAME = P_FILE.
DATA:BEGIN OF XTAB OCCURS 0,
TYP,
DES(255) TYPE C,
END OF XTAB.
DATA:BEGIN OF ITAB OCCURS 0,
SUPERFIELD LIKE MEPO_TOPLINE-SUPERFIELD,
EKORG LIKE MEPO1222-EKORG,
EKGRP LIKE MEPO1222-EKGRP,
BUKRS LIKE MEPO1222-BUKRS,
END OF ITAB.
DATA:BEGIN OF JTAB OCCURS 0,
N(4) TYPE C,
EMATN LIKE MEPO1211-EMATN,
MENGE(13) TYPE C,
NETPR(13) TYPE C,
NAME1 LIKE MEPO1211-NAME1,
END OF JTAB.
DATA:BDCTAB LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
DATA:DELIMITER VALUE '*'.
DATA A TYPE I.
DATA M(4) TYPE N.
DATA L_FNAM(30) TYPE C.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = FILENAME
FILETYPE = 'ASC'
TABLES
DATA_TAB = XTAB.
LOOP AT XTAB.
IF XTAB-TYP = 'H'.
SPLIT XTAB-DES AT DELIMITER INTO ITAB-SUPERFIELD ITAB-EKORG ITAB-EKGRP
ITAB-BUKRS.
JTAB-N = JTAB-N + 1.
APPEND ITAB.
ELSEIF XTAB-TYP = 'I'.
SPLIT XTAB-DES AT DELIMITER INTO JTAB-EMATN JTAB-MENGE JTAB-NETPR
JTAB-NAME1.
APPEND JTAB.
ENDIF.
ENDLOOP.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = 'PORDER'
KEEP = 'X'
USER = SY-UNAME.
LOOP AT ITAB.
A = SY-TABIX.
REFRESH BDCTAB.
perform bdc_dynpro using 'SAPLMEGUI' '0014'.
perform bdc_field using 'BDC_CURSOR'
'MEPO_TOPLINE-SUPERFIELD'.
perform bdc_field using 'MEPO_TOPLINE-BSART'
'NB'.
perform bdc_field using 'MEPO_TOPLINE-SUPERFIELD'
ITAB-SUPERFIELD.
perform bdc_field using 'MEPO_TOPLINE-BEDAT'
'09.02.2007'.
perform bdc_field using 'DYN_6000-LIST'
' 1'.
perform bdc_field using 'BDC_OKCODE'
'=MEV4000BUTTON'.
perform bdc_dynpro using 'SAPLMEGUI' '0014'.
perform bdc_field using 'MEPO_TOPLINE-BSART'
'NB'.
perform bdc_field using 'MEPO_TOPLINE-SUPERFIELD'
ITAB-SUPERFIELD.
perform bdc_field using 'MEPO_TOPLINE-BEDAT'
'09.02.2007'.
perform bdc_field using 'BDC_CURSOR'
'MEPO1222-EKORG'.
perform bdc_field using 'MEPO1222-EKORG'
ITAB-EKORG.
perform bdc_field using 'MEPO1222-EKGRP'
ITAB-EKGRP.
perform bdc_field using 'MEPO1222-BUKRS'
ITAB-BUKRS.
perform bdc_field using 'DYN_6000-LIST'
' 1'.
perform bdc_field using 'BDC_OKCODE'
'=MEV4001BUTTON'.
perform bdc_dynpro using 'SAPLMEGUI' '0014'.
perform bdc_field using 'MEPO_TOPLINE-BSART'
'NB'.
perform bdc_field using 'MEPO_TOPLINE-SUPERFIELD'
ITAB-SUPERFIELD.
perform bdc_field using 'MEPO_TOPLINE-BEDAT'
'09.02.2007'.
perform bdc_field using 'MEPO1222-EKORG'
ITAB-EKORG.
perform bdc_field using 'MEPO1222-EKGRP'
ITAB-EKGRP.
perform bdc_field using 'MEPO1222-BUKRS'
ITAB-BUKRS.
M = 1.
LOOP AT JTAB.
IF JTAB-N = A.
WRITE:/ JTAB.
CONCATENATE 'MEPO1211-EMATN(' M ')' INTO L_FNAM.
perform bdc_field using 'BDC_CURSOR'
L_FNAM.
perform bdc_field using L_FNAM
JTAB-EMATN.
CONCATENATE 'MEPO1211-MENGE(' M ')' INTO L_FNAM.
perform bdc_field using L_FNAM
JTAB-MENGE.
CONCATENATE 'MEPO1211-NETPR(' M ')' INTO L_FNAM.
perform bdc_field using L_FNAM
JTAB-NETPR.
CONCATENATE 'MEPO1211-NAME1(' M ')' INTO L_FNAM.
perform bdc_field using L_FNAM
JTAB-NAME1.
M = M + 1.
ENDIF.
ENDLOOP.
perform bdc_field using 'DYN_6000-LIST'
' 1'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPLMEGUI' '0014'.
perform bdc_field using 'MEPO_TOPLINE-BSART'
'NB'.
perform bdc_field using 'MEPO_TOPLINE-SUPERFIELD'
ITAB-SUPERFIELD.
perform bdc_field using 'MEPO_TOPLINE-BEDAT'
'09.02.2007'.
perform bdc_field using 'MEPO1222-EKORG'
ITAB-EKORG.
perform bdc_field using 'MEPO1222-EKGRP'
ITAB-EKGRP.
perform bdc_field using 'MEPO1222-BUKRS'
ITAB-BUKRS.
perform bdc_field using 'DYN_6000-LIST'
' 1'.
perform bdc_field using 'BDC_CURSOR'
'MEPO1319-MATKL'.
perform bdc_field using 'MEPO1319-SPINF'
'X'.
perform bdc_field using 'BDC_OKCODE'
'=MESAVE'.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'ME21N'
TABLES
DYNPROTAB = BDCTAB.
ENDLOOP.
CALL FUNCTION 'BDC_CLOSE_GROUP'.
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR BDCTAB.
BDCTAB-PROGRAM = PROGRAM.
BDCTAB-DYNPRO = DYNPRO.
BDCTAB-DYNBEGIN = 'X'.
APPEND BDCTAB.
ENDFORM.
FORM BDC_FIELD USING FNAM FVAL.
CLEAR BDCTAB.
BDCTAB-FNAM = FNAM.
BDCTAB-FVAL = FVAL.
APPEND BDCTAB.
ENDFORM.
FLAT FILE:
H1171611000001*1000
ICPU116000*1000
ILEY BOARD1010000*1000
IMOUSE66000*1000
H1171711000001*1000
ICPU580000*1000
H1171701000001*1000
IMOUSE33000*1000
ILEY BOARD1010000*1000
rgds,
bharat. -
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 -
Hello All,
I am trying to develop a bapi for MM01.For which i have used a code as suggested by one of you.But the problem is when i am trying to upload my Excel sheet it is giving me a dump. I have designed my Excel sheet according to the sequence in my code. Is it necessary to maintain the sequence as in BDC?. Hers the code to have a clear idea.Please help me out as i am new to BAPI.
*& Report ZBAPI2
REPORT ZBAPI2.
TABLES
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
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_return LIKE bapiret2. " Return Parameter
*--- 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
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
'C:\Material_master.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'
CHANGING
file_name = f_file
EXCEPTIONS
mask_too_long = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE s010(zlkpl_msgclass). " 'Error in getting filename'.
ENDIF.
ENDFORM. " validate_input_file
*& Form CONVER_XLS_ITAB
text
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> .
*--- 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
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(zlkpl_msgclass). " 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
bapi_head-material = it_data-matnr.
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'.
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_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_marcx-plant = it_data-werks.
bapi_marcx-pur_group = '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'.
*--- 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
FORECASTPARAMETERS =
FORECASTPARAMETERSX =
PLANNINGDATA =
PLANNINGDATAX =
STORAGELOCATIONDATA =
STORAGELOCATIONDATAX =
VALUATIONDATA = BAPI_MBEW1
VALUATIONDATAX = BAPI_MBEWX
WAREHOUSENUMBERDATA =
WAREHOUSENUMBERDATAX =
SALESDATA = BAPI_MVKE1
SALESDATAX = BAPI_MVKEX
STORAGETYPEDATA =
STORAGETYPEDATAX =
IMPORTING
return = bapi_return
TABLES
materialdescription = it_makt
UNITSOFMEASURE =
UNITSOFMEASUREX =
INTERNATIONALARTNOS =
MATERIALLONGTEXT =
TAXCLASSIFICATIONS =
RETURNMESSAGES =
PRTDATA =
PRTDATAX =
EXTENSIONIN =
EXTENSIONINX =
IF bapi_return-type = 'E'.
WRITE:/ 'Error:' ,bapi_return-message ,'for material:' ,
it_data-matnr.
ELSEIF bapi_return-type = 'S'.
WRITE: 'Successfully created material' ,it_data-matnr.
ENDIF.
ENDLOOP.
ENDFORM. " UPLOAD_MATMASHi bnupur14,
Please do place a debugger @ FM ALSM_EXCEL_TO_INTERNAL_TABLE and check p_file, make p_endcol is 12, p_endrow 65000, then check whether its going for dump or not.
I have executed your code there is no dump @ FM ALSM_EXCEL_TO_INTERNAL_TABLE or converting data into internal table.
But where You are getting Dump actually.
Regards,
Suneel G
Edited by: Suneel Kumar Gopisetty on Aug 19, 2009 11:02 AM -
What is the process for mm01 datatransfer by selecting different views
what will be the basic thing to be done for selecting different views?
hi ..if want to upload master data for different views then first create material using MM01 and then update material for different views one by one in MM02..for mass data transfer u can use BDCs for MM01 and MM02
regards -
Hello experts,
We are extending the material to another plant and storage location etc.
so i want to do in lsmw. but it is not working fine .please help me.
First in the lsmw i selected recording and done the recording for mm01.
in the first screen i entered
material abc,industry sector mech engi, material type wfinis and copy from material abc,then i pressed the
enter and i selected the views Sales: Sales Org. Data 1,Sales: Sales Org. Data 2,
Purchasing and Accounting 1.
then i pressed enter and got the screen to enter plant, valuation type , sales org, cist channel. so i enterd
plant ,sale org and dist channel in the organization levels and copy from fields.
then i pressed enter and in the next screen i entered some required data and pressed enter and in another
screen o entered and etc and finally saved . The recording is
successful .then i completed all the lsmw steps when i run the session it is showing the error
at the screen where we enter the orginational levels like plant, sales org etc.
our flat file is a text file and it is in the same order as in
the lsmw.
I approched one senior consultant and he said we cant do lsmw bcuse
the org level screen will be moving every time.
so please kindly help me what to do to analyse this error.
=>Can we debug the lsmw , if so how.
=>In one moment previously 2 days back when i am doing lsmw i got a
error with return code 13, please tell what actually means and where to see this one.
Thank you so much for the replies.Shiva,
First of all its not advisable to use the recording method in lsmw for uploading the material master data. It involves lot of views so if something goes wrong very much difficult to identify the error point, at the same time I will advise you to go with bapi or idoc method to do the same.
When comes to you question regarding the debugging of lsmw you can debug it.
From the usermenu tab take the generate conversion program step into u r list of steps
then execute it and go into the program and put a break point then execute the convert data step directly you will get into the debugging mode you do debug the code. -
Legacy asset data upload for multiple line items
Hello
Legacy asset data upload for multiple line items- for example Building is an asset which is having different line items for purchasing of land,constructaion or renovation etc.........now to upload the legacy data what should be consider...only one line item for Building or numbers of line item.........
which one is the proper way to do this exercise?
regardsHi,
It completely depends on clients requirement. but following are few approaches:
1. Define Building as Asset Class.
2. Create a Building at specific location at asset code and
3. create asset sub numbers for other components.
other approach would be:
1. Define Building as Asset Class.
2. Create a Building at specific location at asset code and
3. create further asset codes for other components where field description will be used for relating each other.
Regards,
Sayujya -
Hi All,
I am looking for a User Exit for MM01
I need to catpure the Document data in MM01>Additional data>Document data tab
I checked with the following enchancements but no use
MGA00001
MGA00002
MGA00003
BADI_Material_Check.
Can any one help me in finding the suitable enhancemet?
Thanks
BhaskerHi Bhasker
Go to Se18 Tcode
and give the definition name is "DOCUMENT_MAIN01"
check the definition in display mode because it is Sap Standard Definition.
there you will find a "TYPE" Tab
under this you have two check boxes
<b>1) Multiple Use</b>
2) Filter-Depend
if you want multiple implementations check this Check box
after this you need to create a request and the system asks Access Key for Changes
for that you will catch that Key from your Basis Team.
Regards
Sreeni -
Any tools are there in data upload for other than BDC.
Any tools are there in data upload for other than BDC.
Hi Hassan,
<b>LSMW</b>
<a href="http://sapabap.iespana.es/sapabap/manuales/pdf/lsmw.pdf">http://sapabap.iespana.es/sapabap/manuales/pdf/lsmw.pdf</a>
<b>Direct Input</b>
<a href="http://help.sap.com/saphelp_di471/helpdata/EN/fa/097174543b11d1898e0000e8322d00/content.htm">Direct Input</a>
<b>BAPI</b>'s
Example :
<b>BAPI_QUOTATION_CREATEFROMDATA2</b> - Customer Quotation: Create Customer Quotation
<b>BAPI_PO_CREATE1 </b> - Create Purchase Order
<b>Close your previous threads if you have got the answers.</b>
Regards,
AS -
A small logical problem in LSMW for MM01...
I need to create a LSMW for MM01 transaction, wherein I have to check the initial four
digits of the material as 'ORCL'. If initial four digits of the
incoming material are 'ORCL', then create this material as it is.
Else replace these four digits with 'SAPM' (for sap material) while
creating this material.
This will differentiate between materials coming from Oracle and non
oracle system.
I know that I need to create a new rule in the step 5 of LSMW: "Maintain Field Mapping and Conversion Rules", under the ABAP heading.
But, how should the rule proceed??
Pls help me out!!!awesome! thnks a lot naimesh.... you are tooo goood!
Can you please help me again...??
Now, I need to replace the records which are not 'ORCLXXX' with SAPXXX format. For example, say a record has the material number as ORCL007. This will pass on and created as ORCL007. If a record has the material number as MMMM007, this should be converted to SAPM007.
Should I use fieldsymbols for this, or just replace the strings??
This will be the last, I promise....
Maybe you are looking for
-
SSRS subreport with a sub-report as header on all pages
Hello, I need some guidance on how to get a sub-report with a sub-report header and an expanding table. Please see below. This is the structure of things that I have: Main Report 1 is being invoked by ONLY Parameter 1 (User Text Box Entry). It Contai
-
What's wrong in my customer component
Hi all, I'm newer to JSF, and I am writing a component which extends UICommand, The component is same to commandButton exclude that it preventing from duplicately submit . When I complete it, I found that it doesn't fire the action. I found that the
-
Multiple speakers not working after recent update?
Can anyone help me with getting my multiple speakers working with Itunes and ATV2. It wont work since last update a few days ago.
-
Dear All, Can anyone tell how to get data from the table or from Std., T.code regarding the reservation created with status open also who has created. Please help me out in htis. Regards, Nagaraj S
-
Can we output a 'fixed-layout' (Apple's variety), Enhanced EPUB?
This is (of course), not a true 'EPUB', but instead Apple's bastardization of the format to allow 'enhanced' illustrated books to be sold in their bookstore. But InDesign can produce some terrific interactive output for regular 'flowing' EPUBS for iB