Creating Material Using BAPI
Hi Friends,
I want to create a material using BAPI, can anyone give me some sample program or can any one give me links which earlier posted this problem.
Points for sure for sample program.
thanks and regards
Vijaya
hi
good
go through this REPORT z_bapi_salesorder_create.
Parameters
Sales document type
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text FOR FIELD p_auart.
PARAMETERS: p_auart TYPE auart OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Sales organization
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text1 FOR FIELD p_vkorg.
PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Distribution channel
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text2 FOR FIELD p_vtweg.
PARAMETERS: p_vtweg TYPE vtweg OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Division.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text3 FOR FIELD p_spart.
PARAMETERS: p_spart TYPE spart OBLIGATORY.
SELECTION-SCREEN END OF LINE.
SKIP 1.
Sold-to
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text4 FOR FIELD p_sold.
PARAMETERS: p_sold TYPE kunnr OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Ship-to
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text5 FOR FIELD p_ship.
PARAMETERS: p_ship TYPE kunnr OBLIGATORY.
SELECTION-SCREEN END OF LINE.
SKIP 1.
Material
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text6 FOR FIELD p_matnr.
PARAMETERS: p_matnr TYPE matnr OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Quantity.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text7 FOR FIELD p_menge.
PARAMETERS: p_menge TYPE kwmeng OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Plant
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text9 FOR FIELD p_plant.
PARAMETERS: p_plant TYPE werks_d OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Data declarations.
DATA: v_vbeln LIKE vbak-vbeln.
DATA: header LIKE bapisdhead1.
DATA: headerx LIKE bapisdhead1x.
DATA: item LIKE bapisditem OCCURS 0 WITH HEADER LINE.
DATA: itemx LIKE bapisditemx OCCURS 0 WITH HEADER LINE.
DATA: partner LIKE bapipartnr OCCURS 0 WITH HEADER LINE.
DATA: return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
DATA: lt_schedules_inx TYPE STANDARD TABLE OF bapischdlx
WITH HEADER LINE.
DATA: lt_schedules_in TYPE STANDARD TABLE OF bapischdl
WITH HEADER LINE.
Initialization.
INITIALIZATION.
v_text = 'Order type'.
v_text1 = 'Sales Org'.
v_text2 = 'Distribution channel'.
v_text3 = 'Division'.
v_text4 = 'Sold-to'.
v_text5 = 'Ship-to'.
v_text6 = 'Material'.
v_text7 = 'Quantity'.
v_text9 = 'Plant'.
Start-of-selection.
START-OF-SELECTION.
Header data
Sales document type
header-doc_type = p_auart.
headerx-doc_type = 'X'.
Sales organization
header-sales_org = p_vkorg.
headerx-sales_org = 'X'.
Distribution channel
header-distr_chan = p_vtweg.
headerx-distr_chan = 'X'.
Division
header-division = p_spart.
headerx-division = 'X'.
headerx-updateflag = 'I'.
Partner data
Sold to
partner-partn_role = 'AG'.
partner-partn_numb = p_sold.
APPEND partner.
Ship to
partner-partn_role = 'WE'.
partner-partn_numb = p_ship.
APPEND partner.
ITEM DATA
itemx-updateflag = 'I'.
Line item number.
item-itm_number = '000010'.
itemx-itm_number = 'X'.
Material
item-material = p_matnr.
itemx-material = 'X'.
Plant
item-plant = p_plant.
itemx-plant = 'X'.
Quantity
item-target_qty = p_menge.
itemx-target_qty = 'X'.
APPEND item.
APPEND itemx.
Fill schedule lines
lt_schedules_in-itm_number = '000010'.
lt_schedules_in-sched_line = '0001'.
lt_schedules_in-req_qty = p_menge.
APPEND lt_schedules_in.
Fill schedule line flags
lt_schedules_inx-itm_number = '000010'.
lt_schedules_inx-sched_line = '0001'.
lt_schedules_inx-updateflag = 'X'.
lt_schedules_inx-req_qty = 'X'.
APPEND lt_schedules_inx.
Call the BAPI to create the sales order.
CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA1'
EXPORTING
sales_header_in = header
sales_header_inx = headerx
IMPORTING
salesdocument_ex = v_vbeln
TABLES
return = return
sales_items_in = item
sales_items_inx = itemx
sales_schedules_in = lt_schedules_in
sales_schedules_inx = lt_schedules_inx
sales_partners = partner.
Check the return table.
LOOP AT return WHERE type = 'E' OR type = 'A'.
EXIT.
ENDLOOP.
IF sy-subrc = 0.
WRITE: / 'Error in creating document'.
ELSE.
Commit the work.
COMMIT WORK AND WAIT.
WRITE: / 'Document ', v_vbeln, ' created'.
ENDIF.
thanks
mrutyun^
Similar Messages
-
Create material using bapi ' bapi_material_savedata'
Hi Experts,
i was tring to create material using bapi ' bapi_material_savedata' but the material is not updating in the table.
please find the code and suggest me if any modification
data: la_headdata type BAPIMATHEAD,
la_clientdata type BAPI_MARA,
la_CLIENTDATAX type BAPI_MARAX,
la_return type BAPIRET2.
data: i_materialdescription type table of BAPI_MAKT,
wa_materialdescription like line of i_materialdescription.
*la_headdata-MATERIAL = int_matnum-MATERIAL.
*LOOP AT int_matnum.
la_headdata-MATERIAL = int_matnum-MATERIAL.
write : int_matnum-material.
*ENDLOOP.
la_headdata-MATERIAL = '100000518'."int_matnum-MATERIAL.
la_headdata-IND_SECTOR = p_indsr.
la_headdata-MATL_TYPE = p_matype.
la_clientdata-BASE_UOM = 'FT3'.
la_clientdata-pur_valkey = ' '.
la_CLIENTDATAX-BASE_UOM = 'X'.
la_clientdata-MATL_GROUP = '01'.
la_CLIENTDATAX-MATL_GROUP = 'X'.
wa_materialdescription = 'TEST'.
append wa_materialdescription to i_materialdescription.
clear: wa_materialdescription.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = la_headdata
CLIENTDATA = la_clientdata
CLIENTDATAX = la_CLIENTDATAX
PLANTDATA =
PLANTDATAX =
FORECASTPARAMETERS =
FORECASTPARAMETERSX =
PLANNINGDATA =
PLANNINGDATAX =
STORAGELOCATIONDATA =
STORAGELOCATIONDATAX =
VALUATIONDATA =
VALUATIONDATAX =
WAREHOUSENUMBERDATA =
WAREHOUSENUMBERDATAX =
SALESDATA =
SALESDATAX =
STORAGETYPEDATA =
STORAGETYPEDATAX =
FLAG_ONLINE = ' '
FLAG_CAD_CALL = ' '
IMPORTING
RETURN = la_return
TABLES
MATERIALDESCRIPTION = i_materialdescription
UNITSOFMEASURE =
UNITSOFMEASUREX =
INTERNATIONALARTNOS =
MATERIALLONGTEXT =
TAXCLASSIFICATIONS =
RETURNMESSAGES =
PRTDATA =
PRTDATAX =
EXTENSIONIN =
EXTENSIONINX =
Please Help me
Regards,
NareshHi all,
Now it is asking me for the other fields,
E ,
The field MARA-XCHPF/BAPI_MARA-BATCH_MGMT is defined as a required field; it does not contain an entry
i have passed this val as
la_clientdata-batch_mgmt = 'X'.
even though i am getting the same error.
can you help me to solve the issue.
Tthanks
Naresh
Edited by: naresh.k.dasari on Jan 4, 2011 10:36 AM -
How to create material using BAPI Methods?
hi,
how to create material master dat using BAPI?
could u guide me
i will be waiting for reply.
REGARDS
ESWAR.Hi eswar,
Try this code to create gods mmovement...
DATA: GOODSMVT_HEADER LIKE BAPI2017_GM_HEAD_01,
" Material Document Header Data
GOODSMVT_CODE LIKE BAPI2017_GM_CODE,
" Assign code to transaction for BAPI goods movement
MATERIALDOCUMENT LIKE BAPI2017_GM_HEAD_RET-MAT_DOC,
" Number of Material Document
GOODSMVT_ITEM LIKE BAPI2017_GM_ITEM_CREATE OCCURS 0 WITH HEADER
LINE,
" Create Material Document Item
RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE
" Return table for messages
*Fill values in header
GOODSMVT_HEADER-PSTNG_DATE = '20030825'.
GOODSMVT_HEADER-DOC_DATE = '20030802'.
*Fill GOODSMVT_CODE
GOODSMVT_CODE-GM_CODE = '05' .
*Fill Item Table
GOODSMVT_ITEM-MATERIAL = '100-100'.
GOODSMVT_ITEM-PLANT = '1000'.
GOODSMVT_ITEM-STGE_LOC = '0001'.
GOODSMVT_ITEM-MOVE_TYPE = '501'.
GOODSMVT_ITEM-ENTRY_QNT = '50'.
GOODSMVT_ITEM-ITEM_TEXT = 'Test Sanket'.
*GOODSMVT_ITEM-COSTCENTER = '1000'.
APPEND GOODSMVT_ITEM.
*Create Good's movement
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
GOODSMVT_HEADER = GOODSMVT_HEADER
GOODSMVT_CODE = GOODSMVT_CODE
IMPORTING
MATERIALDOCUMENT = MATERIALDOCUMENT
TABLES
GOODSMVT_ITEM = GOODSMVT_ITEM
RETURN = RETURN.
*Commit BAPI
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
*Display Goods movement number
FORMAT COLOR 6 INVERSE ON.
READ TABLE RETURN WITH KEY TYPE = 'E'.
IF SY-SUBRC = 0.
WRITE: /,'ERROR! Goods movement not created'.
ELSE.
WRITE: /,'Goods movent number',MATERIALDOCUMENT COLOR 5,
'posted for material',GOODSMVT_ITEM-MATERIAL.
ENDIF.
FORMAT COLOR OFF INVERSE OFF.
try this on report program and create a goods movement.
Sanket. -
How to create invoice using bapi base on delivery number with example
hi,
Pl give me one example to create invoice using bapi base on delivery number (PGI).Use this code
* Pass the delivery no to the FM to create the invoice
wa_vbsk-smart = u2018Fu2019.
wa_komfk-vbeln = nast-objky. u201CuF0DF-----delivery number
APPEND wa_komfk TO it_komfk.
CLEAR wa_komfk.
* To fill the message structure
* l_wa_error-vbeln_vl = nast-objky. " Delivery No.
* l_wa_error-fkart = wa_ztab-bil_doc_type." Billing Doc type
CALL FUNCTION 'RV_INVOICE_CREATE'
EXPORTING
* delivery_date = 0
invoice_date = v_date u201C<- date
* invoice_type = ' '
* pricing_date = 0
vbsk_i = wa_vbsk
with_posting = u2018Du2019
* select_date = 0
i_no_vblog = ' '
i_analyze_mode = ' '
id_utasy = ' '
id_utswl = ' '
id_utsnl = ' '
id_no_enqueue = ' '
id_new_cancellation = ' '
** IMPORTING
* VBSK_E =
* OD_BAD_DATA =
* DET_REBATE =
TABLES
xkomfk = it_komfk
xkomv = it_komv
xthead = it_thead
xvbfs = it_vbfs
xvbpa = it_vbpa
xvbrk = it_xvbrk
xvbrp = it_vbrp
xvbss = it_vbss
* XKOMFKGN =
* XKOMFKKO = -
Need code for sales order create report using bapi's
need code for sales order create report using bapi's
Hi,
Go through below link
http://www.saptechies.com/bapi_salesorder_createfromdat2/
<b>Reward points if it helps,</b>
Satish -
I can create material using inbound Idoc of type MATMAS01, but not MATMAS05
I can create material using inbound Idoc of type MATMAS01 in WE19, but MATMAS05 failed. In fact I used same data ( different material number), and same inbound function, but got different result.
What is different between MATMAS01 and MATMAS05? Is there some configuation need for MATMAS05?
My system is ECC5.0. Thanks.Hi, nagaraj
this is inbound IDoc, not outbound IDoc, so we can't assign Basic type in WE20, only can assign Message type.
In WE82, there are 5 records about Messagetype MATMAS:
Message type Basic type Release
MATMAS MATMAS01 30A
MATMAS MATMAS02 30D
MATMAS MATMAS03 40A
MATMAS MATMAS04 46C
MATMAS MATMAS05 470
I think it should be ok.
In WE57, there 2 records are exist:
FM_name BasicType MessageType
IDOC_INPUT_MATMAS01 MATMAS01 MATMAS
IDOC_INPUT_MATMAS01 MATMAS05 MATMAS
so I think all configurations should be ok.
Message was edited by:
liu bin -
ERROR IN CREATING PO USING BAPI
Hi friends,
My requirement is to create po using BAPI but i am getting error message .i have entered all the fields but still i am getting This errors.
E BAPI 001 No instance of object type Purchase Order has been created. External reference:
E MEPO 000 Purchase order still contains faulty items
E ME 645 Subcontracting as stock transfer within a company code not possible
I ME 123 Supplying and receiving plants identical (Please check)
please help.
thanks in advance.
Moderator message: please read message long texts, speak to a functional expert (these are not ABAP related errors), do more research before asking, do not use all capitals in the title.
Edited by: Thomas Zloch on Nov 30, 2011 1:06 PMHi
It seems you're creating a transfer order and an item is set for subcontracting, that's not possible, so check the item type
Max -
Hi,
I am trying to create PDF using BAPI. I got one BAPI(Z_MM_EPSP_BAPI_GET_PO_PDF). That bapi returns bytecodes. How can I generate PDF file using this BAPI output in BLS. Give some example
Thanks & Regards
ArtArt,
Are you familiar with xMII at all? I would like to answer your question but it seems more like a tutoring lesson rather than a technical problem.
Please post a problem and not how somone can help you do your work. Unless of course you are willing to paypal some money over. :-D -
Account assignment while creating reservation using bapi
Hi , I am creating reservation using BAPI (BAPI_RESERVATION_CREATE1), but when I seeing the open reservation account assignment field is blank, could any on ehelp me on this, i.e what parameter I am missing in BAPI for account assignment.
best regards
pankajHi,
there is not field to assign the account assignment in Bapi..
you need to assignt he account manaually.
Assign account assignment category.
SELECT * FROM eban INTO TABLE lt_eban WHERE banfn = w_banfn .
IF sy-subrc = 0.
LOOP AT lt_eban .
lt_eban-knttp = 'J'. "assign your own account categeory
MODIFY eban FROM lt_eban.
COMMIT WORK AND WAIT.
ENDLOOP.
endif.
Regards,
Prabhudas -
Problem while creating assets using BAPI
Use table enhancement BAPI_TE_ANLU
Diagnosis :The BAPIs for creating and changing assets currently support only those customer enhancements that relate to the user fields created using SAP enhancement AIST0002.
Can anybody give the appropriate solution why this error is coming while creating assets using BAPI.Looks like you are trying to transfer custom fields into the asset master data that were not added following the steps in enhancement AIST0002.
Using EXTENSIONIN parameter, you can transfer user fields from the asset master record. However, it is not possible to transfer fields that are updated in user-defined tables. Only user fields that were defined using SAP enhancement AIST0002 and are automatically updated in table ANLU can be udpated in this way. This means you have to use table extension BAPI_TE_ANLU.
Enhancement AIST0002 contains function module EXIT_SAPL1022_001 as a component in which user fields can be implemented.
The documentation ( BAPIPAREX) of the structure that forms the basis for this parameter contains additional information about using this parameter.
Please check how table ANLU has been enhanced and also go through the documentation of enhancement AIST0002.
Regards,
Shyam -
To create a Material using BAPI with out passing the material number
Hello Experts,
I am using BAPI_MATERIAL_SAVEDATA to create a material of some Ztype. I am successfully creating a material if I am passing Material Number as input. I want the material number to generated internally.
When I am doing material creation with same input data with out material number using BDC, it is working fine. It is generating the material number.
But, not with the BAPI.
Do, I need to specify this some where in the BAPI to generate the Material number internally? Please let me know.
Please help me in this regard.
Thanks & Regards,
Naresh.Hi,
Read the BAPI documentation regarding Internal Number range for materials.
When you create material master data, the following fields must always
contain a value in the structure:
o MATERIAL
Only external number assignment is supported for the material number
(MATERIAL). If you want the material number to be assigned
internally, the method BAPI_MATERIAL_GETINTNUMBER must first be
called. This method determines an internal number for the material
to be created. You must enter this internal number in field
HEADDATA-MATERIAL.
Regards
Vinod -
Error while creating GR using BAPI
*I am creating material document using BAPI_GOODSMVT_CREATE .
When I create the Material document using this BAPI I am able to create is successfully when there is no Account assignment category used means it blank at scheduling agreement level.
But if the Account assignment category is given at the scheduling agreement level then BAPI fails and shows the error message u201CNo goods receipt possible for purchase order.
I am using SAP version 4.6C
SPLIT w_file-dln AT '.' INTO w_dd w_mm w_yyyy.
CONCATENATE w_yyyy w_mm w_dd INTO w_dt.
w_gm_hdr-pstng_date = w_dt. " Posting Date
w_gm_hdr-doc_date = sy-datum." Doc Date
w_gm_hdr-pr_uname = sy-uname." User Name
w_gm_cd-gm_code = '01'. "01 Goods Receipts for Purchase Order
w_gm_itm-move_type = '101'.
w_gm_itm-mvt_ind = 'B'.
BAPI Call.
Edited by: Nandkumar Ghodke on May 21, 2010 4:15 PM
Edited by: Nandkumar Ghodke on May 21, 2010 4:16 PMAs per i know..
that the account assignment information applies to the item level and not to the schedule line level. This means that the quantities, values, and percentage rates indicate how the account assignment information of an item is assigned. This also applies to service items and purchase orders with invoicing plan
Thanks
Naresh -
Fasing some problem in Material using BAPI..?
Hi... Guru's..
thanks in advance and will give full points...
I am creating material master using the BAPI and the data is in presentation server....
this is is the error message i am getting while control ebterinng into CALL BAPI(FM)....
Key fields for use data PLANTDATA and checkbox structure PLANTDATAX are different
please look into the program and and let me know if any chenges required...
i am able get the data from presentation layer and i am able to move field values from internal table to BAPI fields and values are populating properly....
while entering control into BAPI ..i am getting the above error..(error message ....i found in debugging mode...)
TYPE : E
ID : MM
NUMBER : 360
MESSAG :Key fields for use data PLANTDATA and checkbox structure PLANTDATAX are different
LOG_NO
LOG_MSG_NO : 000000
MESSAGE_V1 : PLANTDATA
MESSAGE_V2 : PLANTDATAX
MESSAGE_V3
MESSAGE_V4
PARAMETER
ROW 0
FIELD
SYSTEM
Program logic:
DATA:gs_bapimathead TYPE bapimathead,
gs_clientdata TYPE bapi_mara,
gs_clientdatax TYPE bapi_marax,
gs_plantdata TYPE bapi_marc,
gs_plantdatax TYPE bapi_marcx,
gs_forecastparameters TYPE bapi_mpop,
gs_forecastparametersx TYPE bapi_mpopx,
gs_valuationdata TYPE bapi_mbew,
gs_valuationdatax TYPE bapi_mbewx,
gs_salesdata TYPE bapi_mvke,
gs_salesdatax TYPE bapi_mvkex,
gs_storagelocationdata TYPE bapi_mard,
gs_storagelocationdatax TYPE bapi_mardx,
gt_materialdescription TYPE STANDARD TABLE OF bapi_makt,
gwa_materialdescription TYPE bapi_makt,
gt_taxclassifications TYPE STANDARD TABLE OF bapi_mlan,
gwa_taxclassifications TYPE bapi_mlan,
gt_prtdata TYPE STANDARD TABLE OF bapi_mfhm,
gwa_prtdata TYPE bapi_mfhm,
gt_prtdatax TYPE STANDARD TABLE OF bapi_mfhmx,
gwa_prtdatax TYPE bapi_mfhmx,
gt_unitsofmeasure TYPE STANDARD TABLE OF bapi_marm,
gwa_unitsofmeasure TYPE bapi_marm,
gt_unitsofmeasurex TYPE STANDARD TABLE OF bapi_marmx,
gwa_unitsofmeasurex TYPE bapi_marmx,
gs_return TYPE bapiret2.
TYPES:BEGIN OF gty_itab1,
matnr(18),
mbrsh(1),
mtart(4),
werks(4),
lgort(4),
vkorg(4),
vtweg(2),
maktx(40),
meins(3),
matkl(9),
spart(2),
brgew(13),
ntgew(13),
gewei(3),
dwerk(4),
taxkm(1),
kondm(2),
ktgrm(2),
mtpos(4),
tragr(4),
ladgr(4),
disgr(4),
dismm(2),
dispo(3),
beskz(1),
mtvfp(2),
prmod(1),
planv(3),
bklas(4),
vprsv(1),
peinh(5),
stprs(11),
END OF gty_itab1.
DATA:gt_itab1 TYPE STANDARD TABLE OF gty_itab1,
gwa_itab1 TYPE gty_itab1.
TYPES:BEGIN OF gty_itab2,
abc(1000),
END OF gty_itab2.
DATA:gt_itab2 TYPE STANDARD TABLE OF gty_itab2,
gwa_itab2 TYPE gty_itab2.
PARAMETERS:p_files TYPE string.
START-OF-SELECTION.
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = p_files
filetype = 'ASC'
CHANGING
data_tab = gt_itab2
EXCEPTIONS
OTHERS = 8.
LOOP AT gt_itab2 INTO gwa_itab2.
gwa_itab1 = gwa_itab2-abc(1000).
APPEND gwa_itab1 TO gt_itab1.
ENDLOOP.
LOOP AT gt_itab1 INTO gwa_itab1.
gs_bapimathead-material = gwa_itab1-matnr.
gs_bapimathead-ind_sector = gwa_itab1-mbrsh.
gs_bapimathead-matl_type = gwa_itab1-mtart.
gs_plantdata-plant = gwa_itab1-werks.
gs_plantdatax-plant = 'X'.
gs_salesdata-sales_org = gwa_itab1-vkorg.
gs_salesdatax-sales_org = 'X'.
gs_salesdata-distr_chan = gwa_itab1-vtweg.
gs_salesdatax-distr_chan = 'X'.
gs_salesdata-mat_pr_grp = gwa_itab1-kondm.
gs_salesdatax-mat_pr_grp = 'X'.
gs_salesdata-acct_assgt = gwa_itab1-ktgrm.
gs_salesdatax-acct_assgt = 'X'.
gs_salesdata-delyg_plnt = gwa_itab1-dwerk.
gs_salesdatax-delyg_plnt = 'X'.
gs_clientdata-base_uom = gwa_itab1-meins.
gs_clientdatax-base_uom = 'X'.
gs_clientdata-trans_grp = gwa_itab1-tragr.
gs_clientdatax-trans_grp = 'X'.
gs_clientdata-matl_group = gwa_itab1-matkl.
gs_clientdatax-matl_group = 'X'.
gs_clientdata-division = gwa_itab1-spart.
gs_clientdatax-division = 'X'.
gs_clientdata-net_weight = gwa_itab1-ntgew.
gs_clientdatax-net_weight = 'X'.
gs_clientdata-unit_of_wt = gwa_itab1-gewei.
gs_clientdatax-unit_of_wt = 'X'.
gs_plantdata-loadinggrp = gwa_itab1-ladgr.
gs_plantdatax-loadinggrp = 'X'.
gs_plantdata-mrp_type = gwa_itab1-dismm.
gs_plantdatax-mrp_type = 'X'.
gs_plantdata-availcheck = gwa_itab1-mtvfp.
gs_plantdatax-availcheck = 'X'.
gs_plantdata-mrp_group = gwa_itab1-disgr.
gs_plantdatax-mrp_group = 'X'.
gs_plantdata-mrp_ctrler = gwa_itab1-dispo.
gs_plantdatax-mrp_ctrler = 'X'.
gs_plantdata-proc_type = gwa_itab1-beskz.
gs_plantdatax-proc_type = 'X'.
gs_forecastparameters-fore_model = gwa_itab1-prmod.
gs_forecastparametersx-fore_model = 'X'.
gs_valuationdata-val_class = gwa_itab1-bklas.
gs_valuationdatax-val_class = 'X'.
gs_valuationdata-std_price = gwa_itab1-stprs.
gs_valuationdatax-std_price = 'X'.
gs_valuationdata-price_ctrl = gwa_itab1-vprsv.
gs_valuationdatax-price_ctrl = 'X'.
gs_valuationdata-price_unit = gwa_itab1-peinh.
gs_valuationdatax-price_unit = 'X'.
gs_storagelocationdata-stge_loc = gwa_itab1-lgort.
gs_storagelocationdatax-stge_loc = 'X'.
gwa_materialdescription-langu = 'E'.
gwa_materialdescription-matl_desc = gwa_itab1-maktx.
gwa_taxclassifications-taxclass_1 = gwa_itab1-taxkm.
gwa_prtdata-prt_usage = gwa_itab1-planv.
gwa_prtdatax-prt_usage = 'X'.
gwa_unitsofmeasure-gross_wt = gwa_itab1-brgew.
gwa_unitsofmeasurex-gross_wt = 'X'.
APPEND gwa_materialdescription TO gt_materialdescription.
APPEND gwa_taxclassifications TO gt_taxclassifications.
APPEND gwa_prtdata TO gt_prtdata.
APPEND gwa_prtdatax TO gt_prtdatax.
APPEND gwa_unitsofmeasure TO gt_unitsofmeasure.
APPEND gwa_unitsofmeasurex TO gt_unitsofmeasurex.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = gs_bapimathead
clientdata = gs_clientdata
clientdatax = gs_clientdatax
plantdata = gs_plantdata
plantdatax = gs_plantdatax
forecastparameters = gs_forecastparameters
forecastparametersx = gs_forecastparametersx
valuationdata = gs_valuationdata
valuationdatax = gs_valuationdatax
salesdata = gs_salesdata
salesdatax = gs_salesdatax
IMPORTING
return = gs_return
TABLES
materialdescription = gt_materialdescription
unitsofmeasure = gt_unitsofmeasure
unitsofmeasurex = gt_unitsofmeasurex
taxclassifications = gt_taxclassifications
prtdata = gt_prtdata
prtdatax = gt_prtdatax.
Check the return table.
IF sy-subrc NE 0.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
WRITE: / 'Error occured while creating material'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
WRITE: / 'material',gwa_itab1-matnr,'created'.
ENDIF.
ENDLOOP.Hello,
Unfortunately SAP does not support any BAPI's to change customer/vendor master data.
The BAPI's were developed from different applications and were designed for their special needs.
You can see the existing BAPIs via tranx BAPI.
Please have a look at the SAP notes 390045 and 384462 which should
explain the proceeding. If you want to use Batch Input, please also have a look at SAP note 306275.
Another possibility is to use Trx XD99, object KNA1, Trx XK99, object LFA1.
Regards,
David -
Creation of material using BAPI in LSMW without using material no.
Hi SAP Gurus,
I have a requirement of creating materials using the BAPI in LSMW.
I tried to create a material using the BAPI (Business Object - BUS1001006 , and method - SAVEDATA) which should be created internally, but it is asking the material number to be given externally and my configuration is setup to create the material number internally.
Even I looked into the material type which is associated with the number range and everything looks good.
Is there any solution to create the material by using BAPI in LSMW without passing the material no. externally ?
Appreciate your help.
Kalikonda.Hi,
it looks like it's not possible to call this BAPI wihtout material number. Here is a quote from BAPI documentation.
When creating material master data, you must transfer the material
number, the material type, and the industry sector to the method. You
must also enter a material description and its language.
Cheers -
Hi Folks,
I want to create a PO using BAPI. Which BAPI we are suppose to use and what are the mandatory fields for the same?
Sample code will be helpful.
Thanks
SiddarthHi,
*& Report ZBAPI_CREATE_PO *
*& Program demonstrates the BAPI call to create Purchase Order *
*& Minimum required parameters are used are as per the current *
*& system configuration *
REPORT ZBAPI_CREATE_PO .
*DATA DECLARATION
CONSTANTS : C_X VALUE 'X'.
*Structures to hold PO header data
DATA : HEADER LIKE BAPIMEPOHEADER ,
HEADERX LIKE BAPIMEPOHEADERX .
*Internal Tables to hold PO ITEM DATA
DATA : ITEM LIKE BAPIMEPOITEM OCCURS 0 WITH HEADER LINE,
ITEMX LIKE BAPIMEPOITEMX OCCURS 0 WITH HEADER LINE,
*Internal table to hold messages from BAPI call
RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE.
data : w_header(40) value 'PO Header'.
data : ws_langu like sy-langu.
*text-001 = 'PO Header' - define as text element
selection-screen begin of block b1 with frame title text-001.
parameters : company like header-comp_code default '2700' ,
doctyp like HEADER-DOC_TYPE default 'NB' ,
cdate like HEADER-CREAT_DATE default sy-datum ,
vendor like HEADER-VENDOR default '0010000023',
pur_org like HEADER-PURCH_ORG default '2700' ,
pur_grp like HEADER-PUR_GROUP default '001' .
selection-screen end of block b1.
selection-screen begin of block b2 with frame title text-002.
parameters : item_num like ITEM-PO_ITEM default '00001',
material like ITEM-MATERIAL default 'CRANE' ,
plant like ITEM-PLANT default '2700' ,
quantity like ITEM-QUANTITY default 100.
selection-screen end of block b2.
START-OF-SELECTION.
*DATA POPULATION
ws_langu = sy-langu. "Language variable
*POPULATE HEADER DATA FOR PO
HEADER-COMP_CODE = company .
HEADER-DOC_TYPE = doctyp .
HEADER-CREAT_DATE = cdate .
HEADER-VENDOR = vendor .
HEADER-LANGU = ws_langu .
HEADER-PURCH_ORG = pur_org .
HEADER-PUR_GROUP = pur_grp .
*POPULATE HEADER FLAG.
HEADERX-comp_code = c_x.
HEADERX-doc_type = c_x.
HEADERX-creat_date = c_x.
HEADERX-vendor = c_x.
HEADERX-langu = c_x.
HEADERX-purch_org = c_x.
HEADERX-pur_group = c_x.
HEADERX-doc_date = c_x.
*POPULATE ITEM DATA.
ITEM-PO_ITEM = item_num.
ITEM-MATERIAL = material.
ITEM-PLANT = plant.
ITEM-QUANTITY = quantity.
APPEND ITEM.
*POPULATE ITEM FLAG TABLE
ITEMX-PO_ITEM = item_num.
ITEMX-MATERIAL = C_X.
ITEMX-PLANT = C_X .
ITEMX-STGE_LOC = C_X .
ITEMX-QUANTITY = C_X .
ITEMX-TAX_CODE = C_X .
ITEMX-ITEM_CAT = C_X .
ITEMX-ACCTASSCAT = C_X .
APPEND ITEMX.
*BAPI CALL
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
POHEADER = HEADER
POHEADERX = HEADERX
POADDRVENDOR =
TESTRUN =
IMPORTING
EXPPURCHASEORDER =
EXPHEADER =
EXPPOEXPIMPHEADER =
TABLES
RETURN = RETURN
POITEM = ITEM
POITEMX = ITEMX.
*Confirm the document creation by calling database COMMIT
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN =
end-of-selection.
*Output the messages returned from BAPI call
LOOP AT RETURN.
WRITE / RETURN-MESSAGE.
ENDLOOP.
Create a purchase order with configuration using the BAPI
This took some time to figure out how to setup. It may be useful.
call function 'BAPI_CFG_CREATE'
exporting
object_id = 'MYMATCODE'
root_type = 'MARA'
root_name = 'MYMATCODE'
plant = 'MYPLANT'
importing
cfg_handle = l_handle
root_instance = l_instance
exceptions
error = 1
others = 2.
l_characts_vals-atnam = 'WIDTH'.
l_characts_vals-atwtb = '500'.
append l_characts_vals to it_characts_vals.
call function 'BAPI_CFGINST_CHARCS_VALS_SET'
exporting
object_id = 'MYMATCODE'
instance = l_instance
tables
characts_vals = it_characts_vals
characts_vals_err = it_characts_vals_err.
call function 'CE_C_SET_CBASE'.
l_poitem-int_obj_no = l_handle.
call function 'BAPI_PO_CREATE1'
exporting
poheader = l_poheader
poheaderx = l_poheaderx
importing
expheader = l_expheader
exppurchaseorder = l_exppurchaseorder
tables
poitem = lt_poitem
poitemx = lt_poitemx
poschedule = lt_poschedule
poschedulex = lt_poschedulex
return = lt_return.
call function 'BAPI_TRANSACTION_COMMIT'.
Regards
Sudheer
Maybe you are looking for
-
Exception in thread "main" java.lang.NoSuchMethodError: main
I know you answered this questions a thousand times, but from all the threads i've read, i understand that it is also a program specific problem. I'm an absolute beginner in Java coding, learning it right now at university... I also undertood from ot
-
Issue Putting Data from ArrayCollection into List
I'm having trouble getting data that has been pulled from a textArea and put into an ArrayCollection to be displayed in a List. The data is being saved and then read as a file from local storage. When I run the application, nothing appears in the c
-
Can i filter a report based on a value of a navigational attribute?
Hi all, i need to filter a report and the characteristic i need it's a navigational attribute that is already present in the infocube, can i use it as a filter or i need to add a new characteristic to the ic? thank you
-
Ipod nano keeps turning on and off
My ipod nano keeps turning off and on automatically and when I push a button once its on then it freezes, and when I reset it then it starts turning on and off again....what do I do someone please help me
-
IWORK 09-NUMBERS -HOW TO COPY AND PASTE A VARIABLE TO CELLS IN OTHER SHEETS
IN EXCEL I USED COPY IN THE CEL WITH THE VARIABLE AND THEN" PASTE SPECIAL" IN THE OTHER CELLS.WHEN CHANGING THE VARIABLE ALL THE OTHER CELLS TOOK OVER THIS VALUE AND USED IT IN FORMULAS. IS THERE ANY METHOD IN NUMBERS TO DO THE SAME ?