BAPI executing examlpe
Hi Friends,
i am trying to develop a java application and i need to fetch data from backend.
I understand, we can use JCo, JAVA RESOURCE ADAPTER, ENTERPRISE CONNECTOR, J2EE CONNECTOR.
Can you please let me know which is better suited for a stand-alone java application to get data and display in JSP file?
I need to validate DoB from R3 server, and the required BAPI is created.
I Understand i need to connect using one of the connector and fetch the required output from BAPI, but not sure how.
Some examples would be really of great help....
regards,
Sushil Jain
hi
check this
this is standalone application to access the R3 database
http://www.vogella.de/articles/SAPJCo/article.html
let me know u need any further info
bvr
Similar Messages
-
Execute Infopackage Through BAPI Using Excel Macro (BAPI_IPAK_START)
Hi everyone,
I have a problem when execute infopackage through BAPI using excel macro. I have create a button in macro. When this button is clicked, BAPI for trigger InfoPackage will executed (BAPI_IPAK_START) and this button will disabled.
After this process completely done (traffic indicator for the request is green in update rules), the button will enabled again.
Here the subroutine or pseudocode that i will write :
Private Sub ClickButton()
Begin
1. ThisButton.Activated = False --> Disabled Button
2. Call BAPI/custom Function Module to execute InfoPackage (BAPI_IPAK_START)
4. ThisButton.Activated = True --> Enabled Button
End
The problem is i need some statement like this between statement no 2 and statement no 4
Statement That I Want :
3. Wait Until BAPI Execute Completely
So user can click this button again only after the process is finished completely. I don't know how to do this in macro (in ABAP i know i can use "WAIT ... SECOND"), others said this can be done using event in schedule option at infopackage. Anyone,please help me.
Thank you.
Regards,
Satria BEnter that req number in RSRQ and monitor the load
or right click on the DS - manage - you will req in yellow status which is in progress and you can click on the ...takes you monitor screen
Edited by: Srinivas on Jul 6, 2010 7:51 AM -
How to execute bapi through ep?
hi!
I want to display PO on EP, for which i created one model for BAPI_PO_GETDETAIL. Then I bind import elements of BAPI with inputfield.
Please let me know what has to be done after this to display the content on ep on click of button(any code has to be written for this or bapi executes automatically).
ThanksHi Vijay,
Please go through this tutorial which demonstrates the use of BAPI with WebDynpro and accessing it via EP.
here is hte link of the tutorial:
http://help.sap.com/saphelp_nw04/helpdata/en/c3/76b45d9688e04abe1a1070410ddc1e/content.htm
Regards,
Tejas -
BAPI Table Input not passing to R/3 Backend
Hello Experts,
I am having trouble populating a Table input in my Web Dynpro Java application. I have tried researching this issue on SDN and have attemped many of the solutions with no luck. Here is my code:
Bapi_Order_Input NewOrder = new Bapi_Order_Input();
wdContext.nodeBapi_Order_Input().bind(NewOrder);
Bapisdhd1 OrderHead = new Bapisdhd1(); - <i>(This is part of the Input Paramter, values are successfully passed)</i>
OrderHead.setDoc_Type("ZOR");
OrderHead.setSales_Org("2000");
OrderHead.setDistr_Chan("40");
NewOrder.setOrder_Header_In(OrderHead);
Bapiparnr Partner = new Bapiparnr(); - <i>(This is a table parameter, values are not being passed to the backend)</i>
Partner.setPartn_Role("SP");
Partner.setPartn_Numb("20010");
Partner.setItm_Number("000000");
NewOrder.addOrder_Partners(Partner);
wdContext.currentBapi_Salesorder_Createfromdat2_InputElement().modelObject().execute();
I cannot use "NewOrder.setOrder_Partners(Partner)" because Order_Partners is an AbstactList. I have attempted to create this abstract list below but it will not syntactically check:
AbstractList PartnerList = new Bapiparnr.Bapiparnr_List();
If I test these same input values above in R/3, the BAPI executes fine. When I test the BAPI from WD, I get the return message " Please enter a Sold-To or ShipTo Party". I can replicate this same message in R/3 if I do not populate the Partner table.
I am also able to see the Partner values I enter when I create a Table is display them in Web Dynpro.
This is frusterating me a great deal and I would greatly appreciate, and rewards, any suggestions or recomendations.
Thank you for your help,
MattHi Everyone,
Well, I was finally able to resolve my issue. After debugging the Web Dynpro Application from the ECC BAPI side, I was able to see that the Partner values were failing to be passed to the back-end SAP system. After I restarted the J2EE engine, I was able to create the sales order.
I noticed a couple of interesting things as well:
-You need to fill in the leading zeros for Customer Number (KUNNR) before passing of this value
-The ECC BAPI automatically (atleast in my case) changed the input value of Partner-PartnerRole from "SP" to "AG". This change occurs before the first step in the Debugger is performed. This change, however, does not occur when the BAPI is called from Web Dynpro. Once I edited the Web Dynpro Partner Role input to "AG", I was able to create the sales order.
I have list my code below, thank you all for your help.
Regards,
Matt
Bapi_Salesorder_Createfromdat2_Input SO = new Bapi_Salesorder_Createfromdat2_Input();
Bapi_Transaction_Commit_Input Commit = new Bapi_Transaction_Commit_Input();
Bapisdhd1 OrderHeader = new Bapisdhd1();
OrderHeader.setSales_Off("0000");
OrderHeader.setDoc_Type("ZOR");
OrderHeader.setPo_Meth_S("CU01");
SO.setOrder_Header_In(OrderHeader);
Bapiparnr Partner = new Bapiparnr();
Bapiparnr.Bapiparnr_List PartnerList = new Bapiparnr.Bapiparnr_List();
Partner.setPartn_Numb(PartnerNumber);
Partner.setPartn_Role("AG");
PartnerList.addBapiparnr(Partner);
SO.setOrder_Partners(PartnerList);
int size = wdContext.nodeShoppingCart().size();
BigDecimal Qty;
Bapisditm.Bapisditm_List ItemsList = new Bapisditm.Bapisditm_List();
Bapisditm Items;
IPublicUserAccount.IShoppingCartElement CartItem = wdContext.currentShoppingCartElement();
for (int i=0; i < size; i++){
Items = new Bapisditm();
Qty = new BigDecimal(BigInteger.ZERO);
CartItem = wdContext.nodeShoppingCart().getShoppingCartElementAt(i);
Qty = Qty.add(BigDecimal.valueOf(CartItem.getQuantity()));
Items.setTarget_Qty(Qty);
Items.setTarget_Qu("EA");
Items.setMaterial(CartItem.getMaterial_number());
ItemsList.add(Items);
SO.setOrder_Items_In(ItemsList);
wdContext.nodeBapi_Salesorder_Createfromdat2_Input().bind(SO);
wdContext.nodeBapi_Transaction_Commit_Input().bind(Commit);
catch(Exception ex) {
IWDMessageManager msgMgr = wdComponentAPI.getMessageManager();
msgMgr.reportException(ex.getLocalizedMessage()+ " Create SO Failed!", true);
try {
wdContext.currentBapi_Salesorder_Createfromdat2_InputElement().modelObject().execute();
wdContext.currentBapi_Transaction_Commit_InputElement().modelObject().execute();
catch (Exception ex){
IWDMessageManager msgMgr = wdComponentAPI.getMessageManager();
msgMgr.reportException(ex.getLocalizedMessage()+ " Retrieve Cart Failed!", true); -
Rollback BAPI in BADI ME_PROCESS_PO_CUST
hi guys,
I used BADI ME_PROCESS_PO_CUST to implement a code before saving the purchase order (Method POST).
This code contains a BAPI to create a delivery BAPI_OUTB_DELIVERY_CREATENOREF. If this BAPI fails (this is when Return parameter contains 'E' message), I execute function BAPI_TRANSACTION_ROLLBACK.
Guess what is happening?
There is no purchase order created even when screen shows message "Standard PO created under the number 45#######".
What do I want to do?
- Rollback the bapi executed and let the system continue saving the purchase order.
- If possible show a message to the user that there is an error, but command MESSAGE doesn't seem to work in this BADI
Could you share your insights with this wannabe-abapper?
PD: it says in documentation that it is required ABAP OO to implement this BADI and I think I used it correctly for gathering all data I needed. But I just don't understand why MESSAGE statement and FM POPUP_TO_CONFIRM don't work.Hello
You may try an approach like this:
IF ( 1 = 1 ).
MESSAGE 'Creation of outbound delivery failed' type 'I'.
data: ld_dummy type string,
ls_msg type SMESG,
lt_msg type tsmesg.
message id '00' type 'E' number '398' with 'Creation of outbound delivery failed'
space space space into gl_dummy.
move-CORRESPONDING syst to ls_msg.
APPEND ls_msg to lt_msg.
CALL FUNCTION 'FB_MESSAGES_DISPLAY_POPUP'
EXPORTING
IT_SMESG = lt_msg
* ID_SMESG_ZEILE =
* IT_RETURN =
* ID_SEND_IF_ONE =
EXCEPTIONS
NO_MESSAGES = 1
POPUP_CANCELLED = 2
OTHERS = 3.
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.
Regards
Uwe -
How to set the tables parameter to a BAPI using adaptive RFC model
Hi,
I have a BAPI ZBAPI that has a tables parameter ZPernr of type ZTable with two elements pernr and name.
I used adaptive RFC model and created model classes for the BAPI.
My question how do i set list of pernr and name to the tables parameter in the webdynpro for java.
I have the following methods available
ZBAPI input = new ZBAPI();
1.ZTable table = new ZTable();
table.setPernr(pernr);
table.setname(name);
input.addZPernr(table);
how do i set the table parameter for multiple pernr and name
2.
add all the pernr and name to list and set that list to input in the following way
input.setZPernr(list) and list of typecom.sap.aii.proxy.framework.core. AbstractList
out of two methods mentioned which one is correct.
Please let me know the solution
Thanks
Bala DuvvuriHi Bala,
In your code:
List pernrList = new ArrayList();
pernrList should be declared as the type of class HROBJECT ( The structure name in the model e.g. the node PERFWARN type is Zhrecmfm_002_Perfrat_Warning_Input )
Try this:
HROBJECT pernrList = new HROBJECT();
pernrList.setPernr(pernr);
input.setPernr_List(pernrList);
// call BAPI execute method
If you want to pass list of pernrs, you can pass in alternate way
IPrivate<viewname>.I<nodeame>Node prNode = wdContext.node<node>();
IPrivate<viewname>.I<nodeame>Element prEle;
for (int i = 0; i < table.size(); i++) {
HROBJECT pernrList = new HROBJECT();
pernrList.setPernr(pernr); // Set the pernr from current record
prEle = prNode.create<nodeame>Element(pernrList);
prNode.addElement(prEle);
// call BAPI execute method
Once I execute the BAPI how do i iterate thru second table parameter PERNR_PERFRAT to get pernr and performance rating text
Say your node name is PERNR_PERFRAT
for (int i = 0; i < wdContext.nodePERNR_PERFRAT().size(); i++) {
wdContext.nodePERNR_PERFRAT().getPERNR_PERFRATElementAt(i).getPernr();
wdContext.nodePERNR_PERFRAT().getPERNR_PERFRATElementAt(i).getPerfrat();
Regards,
Siva -
External system point of view - BAPI and RFC difference
Hi all,
I have already searched forums and have seen many posts. But none of them are giving exact difference between BAPI and RFC.
Please don't copy paste any previous posts which give differences in definitions and please explain me in simple terms the difference between RFC and BAPI from external system point of view.
Can RFC be used to link SAP to Non-SAP system? If so, why BAPI?
Difference between RFC and RFC Call?
How exception handling is different?
I know that BAPI is based on OOPS concept but if that is the only difference then from external system point of view they should the same.
Regards
VasuHello Vasu
BAPIs implement the so-called "methods" of business objects (like sales order, customer, etc.). However, this OO-concept is just of semantic nature.
I like to make the following equation: BAPI = Dialog (transaction) without dialog
What does this mean? A BAPI executes the very same validations like in the corresponding dialog transaction.
In order to understand the difference between a BAPI and another RFC enabled function module the following hierarchy may be useful:
BAPI = RFC enabled => executes all validations like in dialog transaction
--> RFC module => may execute similar function like BAPI but does NOT execute all validations
--> calls local function modules => execute specific function
but not as comprehensive as a BAPI function
--> may call internal function modules => modules that are intended to be used by SAP only
Regards
Uwe -
How to create SO by refer a QT with BOM items by BAPI
I want to create Sales order according to exist Quotations and I used the BAPI "BAPI_SALESORDER_CREATEFROMDAT2".
I tested for those normal case, no problem, but if in Quotation have some BOM material,
such as
in a QT 600000000
item high item materil quantity
000010 000000 M1 2 <--BOM header material
000020 000010 M2 2 <--BOM son material
000030 000010 M3 2 <--BOM son material
if a set the parameters of BAPI item and schedule line table like normal case
BAPI-ITEM table
item high item materil quantity refer QT refer item refer category
000010 000000 M1 2 600000000 000010 B
000020 000010 M2 2 600000000 000020 B
000030 000010 M3 2 600000000 000030 B
if a set the parameters of BAPI item and schedule table like normal case
BAPI-schedule line table
item schedule line quantity
000010 0001 2
000020 0001 2
000030 0001 2
after BAPI executed
Sales order will be
item schedule line materil quantity
000010 0001 M1 2
000020 0001 M2 2
000020 0002 M2 2
000030 0001 M3 2
000030 0002 M3 2
i checked the logic in BAPI
for the first item (BOM header item), system will automatically add its all son item to schedule line table due to BOM master
and for those automatically added items, they have no reference doc(Quotation), so the second and third Quotation items' status is still open, just the first item's status is completed in SD flow.
anyone know how to solve it?Hi Ram,
Do you need to make changes in already existing rows or you need to create a new row for every line item?
I think when the first time your view is getting displayed the node which is bound to table uie is empty and hence the table is grayed. If you want input enabled rows then you need to bind few empty rows using the supply_function of the node.
data lt_tables type wd_this->elements_table.
data ls_table like line of lt_table.
append ls_table to lt_table.
append ls_table to lt_table.
node->bind_table( lt_table ).
Here table is the node which is bound to the table uie.
Now when the first time view is displayed you will have 2 rows ready for input.
To add more input enabled rows create a button and add empty lines in the action method assigned to button.
Thanks,
Abhishek -
When to call a BAPI inputexecute method from webdynpro-java?
Hello... I'm a little concerned about a situation I'm having. The thing is that I'm trying to use the Bapi_Qualiprof_Change bapi with some test and hard coded data for a future application. It works fine if I fill the input profile_add table in the init() method of my view and then directly call the onActionModifyQualification method (inside the same init() where i filled the parameters).
On the contrary, if I change the code that intializes the data to the onActionModifyQualification or create an special method to initialize it wich is called later with an action button, then it doesn't work.
After many test I noticed that i have to call the bapi execute method right in the init... is there something I can do to fix it? or is it that i must do it in order to make it work?
I have my controller's context mapped to the bapi's model and the view context mapped to the controller's one.... is it good or do i have to build a similar structure to capture the parameters before and then copy the values into the controller's context??
Thanks a lot!!Thanks for your answer, but it doesn't let me do that because wdModifyView is static. Therefore if 2 people are trying to use it, it's goning to be all mixed up, isn't it?
Anyway, what I really want is executing the bapi when I press the button (that's when it should call the action that calls the bapi). But it only works if I call the action in the init method. -
File to RFC(BAPI) asynchoronous strange error.
Hi,
Iam doing a File to RFC scenario. It is a sale order creation. We are using the BAPI BAPI_SALESORDER_CREATEFROMDAT2. I tried to execute the BAPI in R/3 manually with the mandatory fields like DocType, Material, Quantity, Parnertype & Partner number. It is executed successfully manually. But when implemented the same in XI with the same data. It is throwing some stange errors like
Order type not defined.,
TYPE='E', Message (ID:VP, NUMBER:112): "Please enter sold-to party or ship-to party", LOG_NO:, LOG_MSG_NO:000000 (PARAMETER:SALES_HEADER_IN, ROW:0, FIELD:, SYSTEM:ERDCLNT220)
TYPE='E', Message (ID:V4, NUMBER:219): "Sales document was not changed", LOG_NO:, LOG_MSG_NO:000000 (PARAMETER:, ROW:0, FIELD:, SYSTEM:ERDCLNT220).
Finally BAPI Executed with the errors. Manually it is working in R/3. But when I call it Xi it is erroneous. Please help me in resolving this.
Thank You.
Radhika.>>Finally BAPI Executed with the errors.Manually it is working in R/3. But when I call it Xi it is erroneous.
It should be because of the DATA you are passing to the BAPI.
Try to execute the scenario by passing similar data to bapi that was executed manually and check what happens.
Also check if you have missed to map/pass some fields value to BAPI which is causing the BAPI to error out. Check you mapping again...
Thanks
SaNv... -
Error while calling BAPI in BLS(Logic Editor)
Hi all,
I am using a RFC(BAPI_OBJCL_CHANGE) in XMLL logic editor. I have configured in SAP JCO interface. While executing that transaction, it shows error like ACTION FAILED: End Action SAPJCOInterface_0 : (SAP JCO Interface). But, when I try with other BAPI's its working fine. At the same time when I execute the RFC(BAPI_OBJCL_CHANGE) in SAP logon its working fine. What could be the problem?
Help in this regard, it's urgent.
Thanks & Regards,
HemalathaDid you try to execute the BAPI from SAP in BAPI Explorer? If you are not familiar with the behavior of a particular BAPI, that is a good place to do testing. By using BAPI Explorer, you have bypassed any impact xMII may have on the execution of the BAPI.
Once you have the parameters set correctly there and the BAPI executes without error, then try it in xMII. A couple of other things to keep in mind. SAP often adds leading zeroes to various ID's (material, production order, batch, etc.). BAPI's often do not. So make sure you know the configuration of the object and check to make sure you have leading zeroes where appropriate.
Hope this helps,
Mike
Also make sure you check the Automatically Commit Transaction since you are performing an action upon SAP rather than simply retrieving information.
Edited by: Michael Appleby on Feb 11, 2008 4:17 PM -
I developed an enhancement to substitute one of the subscreens used in the Material Maintenance (Retail) to release some of the standard validations in the Forecast Planning subscreen.
It was done by creating a copy of the Standard subcreen, and modifying the function module in charge of the validations. Additionally it was changed the customizing of the screens sequence.
When the transaction MM42 is executed and the new subscreen is called, the desired validations are working correctly.
In a related process it is called a BAPI (BAPI_MATERIAL_MAINTAINDATA_RT) that can maintain the data in the Forecast subcreen. When the BAPI is used, it uses the standard subscreen, then the validations executed are the standard ones. So, the BAPI is not considering the new customizing of the subscreens secuence.
Any idea of why is this happening? Should the BAPI execute the validations in the standard subscreen or the ones available for the custom subscreen? Can the BAPI consider the custom subscreen?
Thanks. Diana.Hi Diana,
Check BADI artmas_bapi_extend
Regards,
Eduardo -
Hi gurus,,
I'm using the Bapi "BAPI_BUPR_RELATIONSHIP_CREATE" to create realtioship on Sales Area for Customer and after execute the Bapi, execute the "BAPI_TRANSACTION COMMIT", but it not save in the table BUT050 and do not show on the screen. What happening ?? there are some more steps ??
Regards.
Carlos Lima.Yes, Check for RETURN parameter under table - See if there are any Error/warning/Abend messages in the return table.
if you dont see any of the above message, then you should the result atleast. If you see the the success message then issue commit. -
Remotely Debuging BAPI.
Hi,
I am executing ZBAPI from java caps Jcaps in XML format .
Java, Jcaps is mediator which send XML file to SAP BAPI and in back ground BAPI execute SAP stander tcode like VL10F.. etc.
This is totaly automatic process. but when error occurs then it will send errore msg to correspoinding email Id.
i want to debug this bapi remotely . Is it possible then how ?
i know other process JDBG and SM37. but it will not work for my senario.I am Using ECC 5 .
I heard about SAP GUI some 0 and 1 setting but not know more about it.
If anybody know How to debug remotely RFC or BAPI plz share our idia ? -
Report problem with BAPI_MATERIAL_SAVEDATA (help required)
hi all,
i am using this source code to create material using
BAPI_MATERIAL_SAVEDATA.
when i am executing the program,
i am getting message the material no 512 transferred without leading 0.
but when i am checking the mara table i am not getting the material 512 created.
my program is as follows plz check where i am wrong ? why i am not able to create the material using this program.what changes i have to make in this program so that i will be successful in creating material.?
*& Report ZCREATE_MATERIAL
*& Developer
*& Date: &DATE
STRUCTURE DECLARATIONS *
Report:zcreate_material.
TABLES: BAPIMATHEAD, "Headerdata
BAPI_MARA, "Clientdata
BAPI_MARAX, "Clientdatax
BAPI_MARC, "Plantdata
BAPI_MARCX, "Plantdatax
BAPI_MAKT, "Material description
BAPIRET2. "Return messages
DATA:V_FILE TYPE STRING.
DATA:
BEGIN OF LSMW_MATERIAL_MASTER,
MATNR(018) TYPE C, "Material number
MTART(004) TYPE C, "Material type
MBRSH(001) TYPE C, "Industry sector
WERKS(004) TYPE C, "Plant
MAKTX(040) TYPE C, "Material description
DISMM(002) TYPE C, "Extra Field Added In the Program as
*itsrequired
MEINS(003) TYPE C, "Base unit of measure
MATKL(009) TYPE C, "Material group
SPART(002) TYPE C, "Division
LABOR(003) TYPE C, "Lab/office
PRDHA(018) TYPE C, "Product hierarchy
MSTAE(002) TYPE C, "X-plant matl status
MTPOS_MARA(004) TYPE C, "Gen item cat group
BRGEW(017) TYPE C, "Gross weight
GEWEI(003) TYPE C, "Weight unit
NTGEW(017) TYPE C, "Net weight
GROES(032) TYPE C, "Size/Dimensions
MAGRV(004) TYPE C, "Matl grp pack matls
BISMT(018) TYPE C, "Old material number
WRKST(048) TYPE C, "Basic material
PROFL(003) TYPE C, "DG indicator profile
KZUMW(001) TYPE C, "Environmentally rlvt
BSTME(003) TYPE C, "Order unit
VABME(001) TYPE C,
EKGRP(003) TYPE C, "Purchasing group
XCHPF(001) TYPE C, "Batch management
EKWSL(004) TYPE C, "Purchasing key value
WEBAZ(003) TYPE C, "GR processing time
MFRPN(040) TYPE C, "Manufacturer part number
MFRNR(010) TYPE C, "Manufacturer number
VPRSV(001) TYPE C, "Price control indicator
STPRS(015) TYPE C, "Standard price
BWPRH(014) TYPE C, "Commercial price1
BKLAS(004) TYPE C, "Valuation class
END OF LSMW_MATERIAL_MASTER.
INTERNAL TABLE DECLARATIONS *
*to store the input data
DATA:
BEGIN OF it_matmaster OCCURS 0.
INCLUDE STRUCTURE LSMW_MATERIAL_MASTER.
DATA:END OF it_matmaster.
*for material description
DATA:BEGIN OF IT_MATERIALDESC OCCURS 0.
INCLUDE STRUCTURE BAPI_MAKT .
DATA:END OF IT_MATERIALDESC.
*to return messages
DATA:BEGIN OF IT_RETURN OCCURS 0.
INCLUDE STRUCTURE BAPIRET2.
DATA:END OF IT_RETURN.
SELECTION SCREEN
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-002.
PARAMETERS:P_FILE LIKE RLGRAP-FILENAME OBLIGATORY.
SELECTION-SCREEN END OF BLOCK B1 .
AT SELECTION SCREEN
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'P_FILE'
IMPORTING
FILE_NAME = P_FILE.
TO UPLOAD THE DATA *
START-OF-SELECTION.
V_FILE = P_FILE.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = V_FILE
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
IMPORTING
FILELENGTH =
HEADER =
tables
data_tab = IT_MATMASTER
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
DATA POPULATIONS *
LOOP AT IT_MATMASTER.
BAPIMATHEAD-MATERIAL = IT_MATMASTER-MATNR.
BAPIMATHEAD-IND_SECTOR = IT_MATMASTER-Mbrsh.
BAPIMATHEAD-MATL_TYPE = IT_MATMASTER-Mtart.
BAPIMATHEAD-BASIC_VIEW = 'X'.
BAPIMATHEAD-PURCHASE_VIEW = 'X'.
BAPIMATHEAD-ACCOUNT_VIEW = 'X'.
BAPI_MARA-MATL_GROUP = IT_MATMASTER-MATKL.
BAPI_MARA-OLD_MAT_NO = IT_MATMASTER-BISMT.
BAPI_MARA-BASE_UOM = IT_MATMASTER-MEINS.
BAPI_MARA-BASIC_MATL = IT_MATMASTER-WRKST.
BAPI_MARA-MFR_NO = IT_MATMASTER-MFRNR.
BAPI_MARAX-MATL_GROUP = 'X'.
BAPI_MARAX-OLD_MAT_NO = 'X'.
BAPI_MARAX-BASE_UOM = 'X'.
BAPI_MARAX-BASIC_MATL = 'X'.
BAPI_MARAX-MFR_NO = 'X'.
BAPI_MARC-PLANT = IT_MATMASTER-WERKS.
BAPI_MARC-PUR_GROUP = IT_MATMASTER-EKGRP.
BAPI_MARCX-PLANT = IT_MATMASTER-WERKS.
BAPI_MARCX-PUR_GROUP = 'X'.
IT_MATERIALDESC-LANGU = 'EN'.
IT_MATERIALDESC-MATL_DESC = IT_MATMASTER-MAKTX.
append IT_materialdesc.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = BAPIMATHEAD
CLIENTDATA = BAPI_MARA
CLIENTDATAX = BAPI_MARAx
PLANTDATA = BAPI_MARc
PLANTDATAX = BAPI_MARcx
FORECASTPARAMETERS =
FORECASTPARAMETERSX =
PLANNINGDATA =
PLANNINGDATAX =
STORAGELOCATIONDATA =
STORAGELOCATIONDATAX =
VALUATIONDATA =
VALUATIONDATAX =
WAREHOUSENUMBERDATA =
WAREHOUSENUMBERDATAX =
SALESDATA =
SALESDATAX =
STORAGETYPEDATA =
STORAGETYPEDATAX =
FLAG_ONLINE = ' '
FLAG_CAD_CALL = ' '
IMPORTING
RETURN = IT_RETURN
TABLES
MATERIALDESCRIPTION = IT_MATERIALDESC
UNITSOFMEASURE =
UNITSOFMEASUREX =
INTERNATIONALARTNOS =
MATERIALLONGTEXT =
TAXCLASSIFICATIONS =
RETURNMESSAGES =
PRTDATA =
PRTDATAX =
EXTENSIONIN =
EXTENSIONINX =
Bapi to commit the changes
IF sy-subrc <> 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDIF.
WRITE:/ IT_RETURN-TYPE,
2 IT_RETURN-ID,
22 IT_RETURN-NUMBER,
25 IT_RETURN-MESSAGE.
IT_RETURN-LOG_NO,
IT_RETURN-LOG_MSG_NO,
IT_RETURN-MESSAGE_V1,
IT_RETURN-MESSAGE_V2,
IT_RETURN-MESSAGE_V3,
IT_RETURN-MESSAGE_V4,
IT_RETURN-PARAMETER,
IT_RETURN-ROW,
IT_RETURN-FIELD,
IT_RETURN-SYSTEM.
ENDLOOP.
thanks
sanjeevActually your COMMIT call not at all executed.
IF sy-subrc <> 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDIF.
The sy-subrc = 0 after the BAPI executed, the right way is after BAPI call check the bapi RETURN table has any error, if not commit the BAPI otherwise rollback.
Maybe you are looking for
-
Safari doesn't show Youtube and Yahoo websites.
I just bought a Macbook Pro a few days ago, and I have a problem since day one. Safari doesn't work with Yahoo Mail or Youtube. I always get a blank page. When I open other sites like www.real.com the pages show text but no images. Can anyone help me
-
To Create employee master data.
Hi, How to create employee master data from scratch in SAP-HCM through BAPI's. Then we need to insert data in infotype 0000, 0001 and 0002 for that employee. Thanks in advance. Regards, Rajesh Kumat
-
How to find out the Idoc number triggered for any material transfer frm SAP
Hi Folks, Can any body let me know How to find out the Idoc number triggered for any material transfer frm SAP? Do we have any navigation for that in MM03? Thanks, SPMD.
-
Thanks for taking the time to read my question. I have a pattern swatch that I created in an .ai file. How can I move it so that I can use it in a new file? Thanks, Brad
-
I need some help on analyzing the transports. The situation here is that we have say about 500 transports that were imported into test system and took about 24 hrs. Now we want to import those transports into another system but to improve import dura