Questations on BAPI

HI all,
I have some questations on BAPI function modue creation,
1.  After creating bapi function module we have to release the
     function module.  why should we release the Function
     module ?
2. Creating BAPI object,
    What is API Method ?
    Why should we create the API Method ?
    What is the use of API ?
3. Here also we are doing like
   Object Type Component -> To Implemented.
   Object Type Component -> To Released.
   Object Type -> To Implemented.
   Object Type -> To Released.
   What is the use of this ?
Thanks,
Nagaraju.

Hi,
1.RFC is Remote Function Call - a function module, which can be called remotely from outside
BAPI is also a Remote enabled function module but the difference between BAPI and RFC is in BAPI there is a bussiness object attached to it which calls SAP application internally.
can you explain RFC and BAPI???
The difference between RFc and BAPI are business objects. You create business objects and those are then registered in your BOR (Business Object Repository) which can be accessed outside the SAP system by using some other applications (Non-SAP) such as VB or JAVA. in this case u only specify the business object and its method from external system in BAPI there is no direct system call. while RFC are direct system call Some BAPIs provide basic functions and can be used for most SAP business object types. These BAPIs should be implemented the same for all business object types. Standardized BAPIs are easier to use and prevent users having to deal with a number of different BAPIs. Whenever possible, a standardized BAPI must be used in preference to an individual BAPI.
RFC is the protocol used to call functions in an R/3 system by a caller external to R/3 or to call programs external to R/3 from an R/3 system. Functions can only be called via RFC, if they are tagged as RFC functions in the SAP development workbench. They are then called RFC function modules. BAPIs are complete sets of (BAPI) function modules that model a business application.
RFC is the protocol used by SAP for remote communication, that is, for communications between remote independent systems.RFC is used for communications between two independent SAP systems, or for communications between an SAP system and a non-SAP system, such as an external application. It can also be used for communications between modules on the same system.Using the RFC interfaces you can extend the functionality of R/3 applications from an external program.
An R/3 system also contains Business Application Programming Interfaces (also called Business APIs, or BAPIs), which provide a programming interface to business objects. BAPIs are a set of methods for working with and manipulating SAP business objects.Internally, BAPIs are implemented as function modules stored in the R/3 Function Builder. Each BAPI has an equivalent internally-named function module. However, you should use the BAPI and not the function module behind it, because the BAPI provides a stable, object-oriented view of R/3 applications and data. The internal function modules or even the fact that the BAPIs are implemented as function modules are not guaranteed to remain the same in future releases of R/3.
BAPI stands for Business Application Programming Interface.
It is a library of functions that are released to the public
as an interface into an existing SAP system from an external
system.
RFC is the protocol used to call functions in an R/3 system
by a caller external to R/3 or to call programs external to
R/3 from an R/3 system.
Functions can only be called via RFC, if they are tagged as
RFC functions in the SAP development workbench. They are
then called RFC function modules. BAPIs are complete sets of
(BAPI) function modules that model a business application.
When you are familiar with web developments: RFC can be
compared to HTTP and BAPIs are CGI applications.
In other words: A BAPI function is a function module that
can be called remotely using the RFC technology.
RFC and BAPIs are remote enabled function modules. They are practicly the same. A BAPI is one step further as it usually is a self contained business function, such as "Create Purchase Order", or "Change Sales Document". BAPIs interface is very well defined and documented. BAPIs can be found in the BAPI browser via transaction BAPI. RFCs are just remote enabled function modules.
BAPI stands for Business Application Programming Interface. It is a library of functions that are released to the public as an interface into an existing SAP system from an external system.
RFC is the protocol used to call functions in an R/3 system by a caller external to R/3 or to call programs external to R/3 from an R/3 system. Functions can only be called via RFC, if they are tagged as RFC functions in the SAP development workbench.
BAPIs are RFCs, the only difference is that BAPIs usually encapulate some complete business object. For example, creating a sales order, the BAPI would do all of the steps required to create a sales order.
2.Create the API Method Using the BAPI WIZARD
The BAPI wizard is used toTo expose the remote function module as a BAPI. The wizard will generate some additional code, so the function module is a valid method of the BOR. This allows the BAPi to be called as a workflow method in addition to be called by an outside program.
Note: Each function module corresponds to a method in the BOR
Go to the Business Object Builder SWO1.
You can either create the new Object type as a subtype of an existing business object or create a new business object from scratch. In this example it would be obvious to create the Object type as a subtype of BUS2005 Production order. However, to illustrate how to create a new Object type from scratch, we will do this.
In the Object/Interface type field write the name of the new Business Object: ZORDERSTAT. Press enter and fill in the additional fields necessary to create the object type.
Supertype: Not relevant because we are creating our object from scratch
Program. This is the name of the program where the wizard generates code for the Object type, NOT the function module we created earlier. The program name must not be the name of an existing program.
Create the API Method Using the BAPI WIZARD
The BAPI wizard is used toTo expose the remote function module as a BAPI. The wizard will generate some additional code, so the function module is a valid method of the BOR. This allows the BAPi to be called as a workflow method in addition to be called by an outside program.
Note: Each function module corresponds to a method in the BOR
Go to the Business Object Builder SWO1.
You can either create the new Object type as a subtype of an existing business object or create a new business object from scratch. In this example it would be obvious to create the Object type as a subtype of BUS2005 Production order. However, to illustrate how to create a new Object type from scratch, we will do this.
In the Object/Interface type field write the name of the new Business Object: ZORDERSTAT. Press enter and fill in the additional fields necessary to create the object type.
Supertype: Not relevant because we are creating our object from scratch
Program. This is the name of the program where the wizard generates code for the Object type, NOT the function module we created earlier. The program name must not be the name of an existing program.
Create the API Method Using the BAPI WIZARD
The BAPI wizard is used toTo expose the remote function module as a BAPI. The wizard will generate some additional code, so the function module is a valid method of the BOR. This allows the BAPi to be called as a workflow method in addition to be called by an outside program.
Note: Each function module corresponds to a method in the BOR
Go to the Business Object Builder SWO1.
You can either create the new Object type as a subtype of an existing business object or create a new business object from scratch. In this example it would be obvious to create the Object type as a subtype of BUS2005 Production order. However, to illustrate how to create a new Object type from scratch, we will do this.
In the Object/Interface type field write the name of the new Business Object: ZORDERSTAT. Press enter and fill in the additional fields necessary to create the object type.
Supertype: Not relevant because we are creating our object from scratch
Program. This is the name of the program where the wizard generates code for the Object type, NOT the function module we created earlier. The program name must not be the name of an existing program.
After you have finished the wizard, you will notice that the ZGetOrderStatus has been added to the business object:
You can double-click on the method to see its properties. To use the business object you must change the Object type status to Implemented. Use menu Edit->Change releases status->Object type->To implemented. No you can test the object (Press F8).
Note that the BAPI wizard has added a wrapper class for the function module so it can be sued as method in the business object. Choose menu Goto->Program to display the program:
Implementation of object type ZORDERSTAT *****
INCLUDE <OBJECT>.
BEGIN_DATA OBJECT. " Do not change.. DATA is generated
only private members may be inserted into structure private
DATA:
" begin of private,
" to declare private attributes remove comments and
" insert private attributes here ...
" end of private,
KEY LIKE SWOTOBJID-OBJKEY.
END_DATA OBJECT. " Do not change.. DATA is generated
BEGIN_METHOD ZGETORDERSTATUS CHANGING CONTAINER.
DATA:
BAPIORDERSTATUSIMPORT LIKE ZBAPI_ORDER_STATUS_IMPORT,
RETURN LIKE BAPIRETURN,
TBAPISTAT LIKE ZBAPISTAT OCCURS 0.
SWC_GET_ELEMENT CONTAINER 'BapiOrderStatusImport'
BAPIORDERSTATUSIMPORT.
SWC_GET_TABLE CONTAINER 'TBapistat' TBAPISTAT.
CALL FUNCTION 'Z_BAPI_GET_ORDER_STATUS'
EXPORTING
BAPI_ORDER_STATUS_IMPORT = BAPIORDERSTATUSIMPORT
IMPORTING
RETURN = RETURN
TABLES
T_BAPISTAT = TBAPISTAT
EXCEPTIONS
OTHERS = 01.
CASE SY-SUBRC.
WHEN 0. " OK
WHEN OTHERS. " to be implemented
ENDCASE.
SWC_SET_ELEMENT CONTAINER 'Return' RETURN.
SWC_SET_TABLE CONTAINER 'TBapistat' TBAPISTAT.
END_METHOD.
Please check this link.
http://help.sap.com/saphelp_utilities472/helpdata/en/c6/4dce68eafc11d18a030000e829fbbd/frameset.htm
Use this its perfect for you
EMIGALL
Regards,
Shiva.

Similar Messages

  • Open Purchase Order UPload Using the BAPI 's

    i need to upload the open Purchase Order using the BAPI function BAPI_PO_CREATE1., below is the given fileds blod are for Header, header will Repeat for the line items,can any one help me out  using the BAIP's for upload the PO, i need sample code for this ........
    Thanks & Regards
    Raghu
    <u>Field Name     Field Description                              Type     Length</u>
    <b>EBELN             Purchasing Document Number                         CHAR     010          X
    BUKRS             Company Code                                                     CHAR    004     MN10     C
    EKORG             Purchasing Organization                              CHAR     004     MN00     C
    EKGRP             Purchasing group                              CHAR     003          X
    BSART             Order type (Purchasing)                              CHAR     004          X
    LIFNR             Account Number of Vendor or Creditor                    CHAR     010          X
    BEDAT             Purchase Order Date                              DATS     010          X
    ZTERM             Terms of payment key                              CHAR     004          X
    WAERS             Currency Key                                   CUKY     005          X
    INCO1             Incoterms (part 1)                              CHAR     003          X
    INCO2             Incoterms (part 2)                              CHAR     028          X</b>
    EBELP             Item Number of Purchasing Document                    NUMC     005          X
    EMATN             Material number                                   CHAR     018          X
    WERKS             Plant                                        CHAR     004          X
    LGORT             Storage location                              CHAR     004          X
    EPSTP             Item category in purchasing document                    CHAR     001          X
    KNTTP             Account assignment category                         CHAR     001          X
    EINDT             Item delivery date                              DATS     010          X
    MENGE            "Purchase order quantity (direct input, transfer of POs)"     CHAR     013          X
    MEINS            Order unit                                   UNIT     003          X
    NETPR            "Net price: Document currency (direct input, transfer of"     CHAR     011          X
    PEINH            "Price unit (direct input, transfer of POs)"               CHAR     005          X
    BPRME            Order Price Unit (Purchasing)                         UNIT     003          X
    BPUMZ            Numerator: Conversion OPUn into OUn (direct input of POs          CHAR     005          X
    BPUMN            Denominator: Conversion OPUn into OUn (direct input of P          CHAR     005          X
    SAKTO            Cost element                                   CHAR     010          X
    KOSTL              Cost Center                                   CHAR     010          X
    VBELN          Sales and Distribution Document Number                    CHAR     010          X
    VBELP          Sales document item                              NUMC     006          X
    WEMPF          Goods recipient                                   CHAR     012          X
    WEBTH          "Amount in local currency (direct input, transfer of POs)"     CHAR     013          X
    WEBTF          "Amount in document currency (direct input, transfer of P"     CHAR     013          X
    WEREF          Flag for treatment of GR/IR (direct input of POs)          CHAR     001          X
    SPINF          Indicator: Update info record                         CHAR     001          X
    WEPOS          Goods Receipt Indicator                              CHAR     001          X
    REPOS          Invoice receipt indicator                         CHAR     001          X

    i need to upload the open Purchase Order using the BAPI function BAPI_PO_CREATE1., below is the given fileds blod are for Header, header will Repeat for the line items,can any one help me out  using the BAIP's for upload the PO, i need sample code for this ........
    Thanks & Regards
    Raghu
    <u>Field Name     Field Description                              Type     Length</u>
    <b>EBELN             Purchasing Document Number                         CHAR     010          X
    BUKRS             Company Code                                                     CHAR    004     MN10     C
    EKORG             Purchasing Organization                              CHAR     004     MN00     C
    EKGRP             Purchasing group                              CHAR     003          X
    BSART             Order type (Purchasing)                              CHAR     004          X
    LIFNR             Account Number of Vendor or Creditor                    CHAR     010          X
    BEDAT             Purchase Order Date                              DATS     010          X
    ZTERM             Terms of payment key                              CHAR     004          X
    WAERS             Currency Key                                   CUKY     005          X
    INCO1             Incoterms (part 1)                              CHAR     003          X
    INCO2             Incoterms (part 2)                              CHAR     028          X</b>
    EBELP             Item Number of Purchasing Document                    NUMC     005          X
    EMATN             Material number                                   CHAR     018          X
    WERKS             Plant                                        CHAR     004          X
    LGORT             Storage location                              CHAR     004          X
    EPSTP             Item category in purchasing document                    CHAR     001          X
    KNTTP             Account assignment category                         CHAR     001          X
    EINDT             Item delivery date                              DATS     010          X
    MENGE            "Purchase order quantity (direct input, transfer of POs)"     CHAR     013          X
    MEINS            Order unit                                   UNIT     003          X
    NETPR            "Net price: Document currency (direct input, transfer of"     CHAR     011          X
    PEINH            "Price unit (direct input, transfer of POs)"               CHAR     005          X
    BPRME            Order Price Unit (Purchasing)                         UNIT     003          X
    BPUMZ            Numerator: Conversion OPUn into OUn (direct input of POs          CHAR     005          X
    BPUMN            Denominator: Conversion OPUn into OUn (direct input of P          CHAR     005          X
    SAKTO            Cost element                                   CHAR     010          X
    KOSTL              Cost Center                                   CHAR     010          X
    VBELN          Sales and Distribution Document Number                    CHAR     010          X
    VBELP          Sales document item                              NUMC     006          X
    WEMPF          Goods recipient                                   CHAR     012          X
    WEBTH          "Amount in local currency (direct input, transfer of POs)"     CHAR     013          X
    WEBTF          "Amount in document currency (direct input, transfer of P"     CHAR     013          X
    WEREF          Flag for treatment of GR/IR (direct input of POs)          CHAR     001          X
    SPINF          Indicator: Update info record                         CHAR     001          X
    WEPOS          Goods Receipt Indicator                              CHAR     001          X
    REPOS          Invoice receipt indicator                         CHAR     001          X

  • URGENT: Function modules or BAPIs

    Hi Experts,
    I need function modules or BAPI to get the open items and cleared items G/L Account wise.
    Useful replies will be surely awarded.

    Hi Chakradhar,
    Check tcode : BAPI
    u will get all bapis there.
    Regards,
    Hemant

  • Questions on BPS BAPI calls and PDF forms

    I will need to create a button on a BPS form and that button is supposed to call a BAPI.  One of the buttons will create a PDF of the form (using the contents of the form) and print said form to a 'default' printer.  The issue is that not all cFolder users will have an ECC logon name.  What am I to do in this instance?  Will I need to pass some type of credentials to the ECC backend in order to run this BAPI?
    Also, how can I get the contents of the form(s) to the BAPI?  I assume that I will need to create the PDF in the code of the BAPI.  Please be patient with me as this is my first time to work with cFolders and/or BPS.
    Regards,
    Davis

    Hi Davis,
    Well, if you are able to log on the BPS application (thus, a Web Interface if I'm not mistaken) then it means that some user is logged on the ABAP-side. It is either a "personal" user or a technical (common) user, that is used for anonymous access.
    You will certainly be able to track down this user with the SM04 transaction.
    You should be able to add a button to the BPS page. One idea would be to call an URL with an ICF service behind that will be able to process the parameters contained in this URL.
    It will be this very ICF service that will call the BAPI.
    Try these links
    http://help.sap.com/saphelp_nw04s/helpdata/en/55/33a83e370cc414e10000000a114084/frameset.htm
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/ea8db790-0201-0010-af98-de15b6c1ee1a
    Hope this helps.
    Best regards,
    Guillaume

  • Deletion of Scheduling Agreement and Delivery Schedule using BAPI

    Hi SAP MM Gurus,
    Please assist in inquiry below:
    My scenario is that I am trying to delete delivery schedules and scheduling lines using BAPIs. I have no issues when there is no GR made yet for the delivery schedules. The error arises when there are already existing Goods Receipts and Invoices for the schedule line that I wish to delete
    When using the BAPIs (either BAPI_SAG_CHANGE or BAPI_SCHEDULE_MAINTAIN), I set the deletion indicator to "L" and set to X all change relevant fields (i.e. DELETION_INDX). However, whenever I execute it, I get the error message 06088. The funny thing is both the Quantities and the delivered quantities that are normally populated are left blank.
    For example:
    Normal error for 06088:
    Quantity 100.0 smaller than quantity delivered 179.0
    Error using BAPI with deletion indicator:
    Quantity  smaller than quantity delivered
    Is this a bug of the BAPI? or am I just missing some settings?
    Your immediate response is appreciated
    Regards,
    DeLo

    Hi,
    Please find the below link check the setting are correct or not
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/a02cb00a-bfb4-2c10-98aa-e33e7f64ba28?quicklink=index&overridelayout=true
    Reagrds,
    Pramod

  • BAPI for training and event management

    Hi all,
    I need a bapi that returns the list of the attendees of a training course.
    I've seen that a FM exists: RH_GET_PARTICIPANTS and i know how it works.
    I would like a standard BAPI to be called by an external system.
    If it doesn't exit I will create a remote FM that calls the RH_GET_PARTICIPANTS.
    thanks
    enzo

    Hi Enzo,
    I don't think there is a BAPI.. but you can create one using the Method 'Display Attendance' for the 'Attendance' Business Object (PDRELA_025) in Tcode BAPI. But I think creating an RFC that in turn calls RH_GET_PARTICIPANTS is the easy way out.
    Regards,
    Suresh Datti

  • Scheduling BAPi

    Hi guys,
    While scheduling a BAPI(ZBAPI_WS_REPORT ),am gettin an error msg says Program ZBAPI_WS_REPORT is invalid or does not exist,even though it exists in the target client.What could be the problem?Please help me out in this regard asap.Its very urgent.
    Surely points vl b rewarded.
    Warm Regards,
    Mohandoss P.

    You need to call that BAPI into your report and then you have schedule that report.
    I hope it helps.
    Let me know if any doubts.
    Thanks,
    Vibha
    Please mark all the useful answers

  • BAPI Error: No account assignment exists for service line 0000000000

    I am using BAPI : BAPI_PO_CREATE1 to create a PO.
    I am getting this error while creating PO  "No account assignment exists for service line 0000000000"
    Please help.

    Yes...
    for each item i am creating one parent service record and one child service record with REQUISITION_SERVICES.
    the Package no for parent is the subpackage no for child.
    also for each item, I fill REQUISITION_ACCOUNT_ASSIGNMENT and REQUISITION_SRV_ACCASS_VALUES
    Still I get the Error.
    Thanks to help me resolve.

  • Need BAPI for MIGO to create a Goods Receipt against PO &Outbound Delivery

    Hi Friends,
    GRN’s (Good receipt notifications) created in DHL (Non SAP system) will need to be communicated to SAP.
    I need to post goods receipt using input data in MIGO. Is there any BAPI that i can use.The requirement is like below:
    PO number field in output file is checked against entries in EKKO-EBELN, if a match is found the GR is posted against a Purchase Order otherwise LIKP-VBELN is checked and if a match is found GR is posted against an Outbound Delivery.
              If PO Number = EKKO-EBELN    GR against Purchase Order
                            = LIKP-VBELN      GR against Outbound Delivery
    Based on the above condition I need to create a Goods Receipt. 
    Could you please tell me the GM code, movement types and the required fields to be passed for the BAPI?
    The fields available are with us are...
    Header text. - Bill of Lading- Posting Date-Quantity- UOM--- Vendor Batch / Batch / Serial No --- PO Number or Delivery Number… SLED
    Are these fields sufficient for doing MIGO with the BAPI or do we require more fields???
    Please provide sample code if possible.
    Waiting for replies,
    Thanks and Regards,
    Sudha

    Hi Friends,
    GRN’s (Good receipt notifications) created in DHL (Non SAP system) will need to be communicated to SAP.
    I need to post goods receipt using input data in MIGO. Is there any BAPI that i can use.The requirement is like below:
    PO number field in output file is checked against entries in EKKO-EBELN, if a match is found the GR is posted against a Purchase Order otherwise LIKP-VBELN is checked and if a match is found GR is posted against an Outbound Delivery.
              If PO Number = EKKO-EBELN    GR against Purchase Order
                            = LIKP-VBELN      GR against Outbound Delivery
    Based on the above condition I need to create a Goods Receipt. 
    Could you please tell me the GM code, movement types and the required fields to be passed for the BAPI?
    The fields available are with us are...
    Header text. - Bill of Lading- Posting Date-Quantity- UOM--- Vendor Batch / Batch / Serial No --- PO Number or Delivery Number… SLED
    Are these fields sufficient for doing MIGO with the BAPI or do we require more fields???
    Please provide sample code if possible.
    Waiting for replies,
    Thanks and Regards,
    Sudha

  • How to change pricing Conditions in Sales order in change sales order bapi

    Hi Experts,
    How to change pricing Conditions in Sales order in change sales order bapi.
    I have used the 2 function modules bapi-changesalesorder and sd salesdocument change, But it is creating the new record , instead of changing the existing one, Could please assist regarding the same
    Thanks in Advance .
    NLN

    HI NLN
      I have just tried on my system and managed to overwrite the existing price by passing the following parameters.
      <b>Import Paramters:</b>
         SALESDOCUMENT - Sales Document Number
         ORDER_HEADER_INX - UPDATEFLAG as <b>'U'</b>.
         LOGIC_SWITCH - Import Structure - Pass 'X' to LOGIC_SWITCH-COND_HANDL.
      <b>Tables:</b>
         CONDITIONS_IN - ITM_NUMBER,
                         COND_COUNT, -> Condition counter same as KONV-ZAEHK generally it is <b>'01'</b>
                         COND_TYPE,
                         COND_VALUE,
                         CURRENCY.
         CONDITIONS_INX - ITM_NUMBER,
                          COND_COUNT,
                          COND_TYPE,
                          UPDATEFLAG as <b>'U'</b>,
                          CURRENCY.
       Hope i have clarified your query.
    Kind Regards
    Eswar

  • Error in BAPI

    Hello ,
    While using the BAPI 'BAPI_MATERIAL_SAVEDATA', to extend material from one plant to another my code is throwing an error 'Currency initial v,current amount 6,000.0000 in MOVING_PR was transferred without a currency'
    Enter a material number'
    I have incorporated mbew-peinh, even then its throwing the same error.
    I snd copy of my code.
    report  zmm_r018 .
    *& Prog to copy n create the existing material using bapi .
    tables: t001l, "Storage Locations
            mara,  "General Material Data
            makt,  "Material Descriptions
            mbew,  "Material Valuation
            marc,  "Plant Data for Material
            mltx.  "Purchase Order Descriptions
    **parameters : new_mat like mara-matnr,
                desc like makt-maktx,
    *data:         ref_mat like mara-matnr.
    *data: xmara type mara.
    **data: wamatnr like mara-matnr.
    data: potext type string."Purchase Order Desc
    data : ihead_data type bapimathead,
           iclient_data type bapi_mara,                    "Client Data
           iclient_datax type bapi_marax,
          imakt like bapi_makt,                           "Mat Description
           iplant_data    like bapi_marc,                  "Plant View
           iplant_datax   like bapi_marcx,
           iltxt type table of bapi_mltx with header line, "Pur Order Text
           istoragelocationdata type bapi_mard,            "Storage Location
           istoragelocationdatax type bapi_mardx,
           iaccounting_data  like bapi_mbew,               "Accounting View
           iaccounting_datax  like bapi_mbewx,
           bapiret like bapiret2,
           returnm type table of bapi_matreturn2 with header line.
    **Internal Table to hold the records in the text file
    types:begin of it,
    matnr(18),  " Material number
    mbrsh(1),   " Industry sector
    mtart(4),   " Material type
    werks(4),   " Plant
    lgort_d(4),  "Storage Location
    maktx(40),  " Material description
    meins(3),   " Base unit of measure
    matkl(9) ,  " Material group
    bismt(18),  " Old Material number
    spart(2),   " Division
    gewei(3),   " Weight Unit
    text1(30),  " Purchasr Order Text
    text2(30),
    text3(30),
    text4(30),
    text5(30),
    text6(30),
    dzeinr(22), " Document
    ekgrp(3),   " Purchasing group
    ekwsl(4),   " Purchase Value Key
    webaz(3),   " Goods receipt processing time in days
    dismm(2),   " MRP Type
    minbe(13),  "Reorder point
    dispo(3),   " MRP Controller
    disls(2),   "Lot size (materials planning)
    mabst(13),  "Maximum stock level
    plifz(3),   " Planned delivery time in days
    webaz1(3),  " Goods receipt processing time in days
    fhori(3),   "Scheduling Margin Key for Floats
    eisbe(13),  "Safety stock
    mtvfp(2),   "Checking Group for Availability Check
    lgpbe(10),  "Storage Bin
    qmatauth(6),"Material Authorization Group for Activities in QM
    qmpur(1),   " QM in Procurement is Active
    qsspur(8),  "Control Key for Quality Management in Procurement
    bklas(4),   " Valuation Class
    bwtty_d(1), "Valuation Category
    vprsv(1),   " Price control indicator
    verpr_bapi(23), "Moving average price/periodic unit price
    peinh(5),     "Price Unit
    end of it.
    data: it_data type table of it,
          wa_data like line  of it_data.
    *Decalraing flag
    data: v_flag value ''.
    *DECLARING WORK AREAs  TO BE PASSED TO THE FUNCTION MODULE.
    data: bapi_head like bapimathead,
          bapi_clientdata like bapi_mara,
          bapi_clientdatax like bapi_marax,
          bapi_plantdata like bapi_marc,
          bapi_plantdatax like  bapi_marcx,
          bapi_storagelocationdata like bapi_mard,
          bapi_storagelocationdatax like bapi_mardx,
          bapi_salesdata like bapi_mvke,
          bapi_salesdatax like bapi_mvkex,
          bapi_makt like bapi_makt,
          bapi_return like bapiret2.
    *INTERNAL TABLE TO HOLD THE MATERIAL DESCRIPTION
    data: begin of it_makt occurs 0.
    include structure bapi_makt.
    data end of it_makt.
    data:begin of it_ret occurs 0.
    include structure bapiret2.
    data end of it_ret.
    *INTERNAL TABLE TO HOLD HEADER DATA
    data: it_excel type alsmex_tabline occurs 0 with header line.
    *SELECTION-SCREEN ELEMENTS
    selection-screen begin of block b1 with frame title text-001.
    parameter: fname type rlgrap-filename  default 'c:\supplies.xls'.
    parameters: p_begcol type i default '1' no-display,
                p_begrow type i default '2' no-display,
                p_endcol type i default '200' no-display,
                p_endrow type i default '2500' no-display.
    *perform f_get_data.
    selection-screen end of block b1.
    *DECLARATION OF EXCELAL TABLE
    at selection-screen on value-request for fname.
    perform f_get_file using fname.
    start-of-selection.
    perform f_xls_itab using fname
                       changing it_excel.
    perform f_move_data.
    perform f_get_data.
    perform f_call_bapi.
    *&      Form  F_GET_FILE
          text
         -->P_FNAME  text
         <--P_SY_SUBRC  text
    form f_get_file  using    p_fname like fname.
    call function 'KD_GET_FILENAME_ON_F4'
    exporting
       program_name        = syst-repid
       dynpro_number       = syst-dynnr
      FIELD_NAME          = ' '
      STATIC              = ' '
      MASK                = ' '
      changing
        file_name           = p_fname
    EXCEPTIONS
      MASK_TOO_LONG       = 1
      OTHERS              = 2
    if sy-subrc <>  0.
    message e006(zhnc).
    endif.
    endform.                    " F_GET_FILE
    *&      Form  F_XLS_ITAB
          text
         -->P_FNAME  text
         <--P_IT_EXCEL  text
    form f_xls_itab  using    p_fname
                     changing p_it_excel.
    call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      exporting
        filename                      = 'c:\supplies.xls'
        i_begin_col                   = p_begcol
        i_begin_row                   = p_begrow
        i_end_col                     = p_endcol
        i_end_row                     = p_endrow
      tables
        intern                        = it_excel
    exceptions
       inconsistent_parameters       = 1
       upload_ole                    = 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.
    endform.                    " F_XLS_ITAB
    *&      Form  F_MOVE_DATA
          text
    -->  p1        text
    <--  p2        text
    form f_move_data .
    data : lv_index type i.
    field-symbols <fs>.
    *--- Sorting the internal table
    sort it_excel by row col.
    clear it_excel.
    loop at it_excel.
    move it_excel-col to lv_index.
    *--- Assigning the each record to an internal table row
    assign component lv_index of structure wa_data to <fs>.
    *--- Asigning the field value to a field symbol
    move it_excel-value to <fs>.
    at end of row.
    append wa_data to it_data.
    clear wa_data.
    endat.
    endloop.
    endform.                    " F_MOVE_DATA
    form f_get_data .
    loop at it_data into wa_data.
    move-corresponding wa_data to ihead_data.
    Header
        ihead_data-material       = wa_data-matnr.
        ihead_data-ind_sector     = wa_data-mbrsh.
        ihead_data-matl_type      = wa_data-mtart.
        ihead_data-basic_view     = 'X'.
        ihead_data-purchase_view  = 'X'.
        ihead_data-mrp_view       = 'X'.
        ihead_data-storage_view   = 'X'.
        ihead_data-quality_view   = 'X'.
        ihead_data-account_view   = 'X'.
        move-corresponding wa_data to iclient_data.
    Material Description
        refresh it_makt.
        it_makt-langu              = 'EN'.
        it_makt-matl_desc          =  wa_data-maktx.
        append it_makt.
    Purchase Order Description
    clear:iltxt,iltxt[].
    concatenate wa_data-text1 wa_data-text2 wa_data-text3 wa_data-text4
    wa_data-text5 wa_data-text6 into potext
    separated by space.
    iltxt-applobject = 'MATERIAL'.
    iltxt-text_name  =  wa_data-matnr.
    iltxt-text_id    = 'BEST'.
    iltxt-langu      = sy-langu.
    iltxt-langu_iso  = 'EN'.
    iltxt-format_col = space.
    iltxt-text_line  = potext.
    append iltxt.
    Client Data - Basic
        iclient_data-matl_group     = wa_data-matkl.
        iclient_data-old_mat_no     = wa_data-bismt.
        iclient_data-base_uom       = wa_data-meins.
        iclient_data-document       = wa_data-dzeinr.
        iclient_data-unit_of_wt     = wa_data-gewei.
        iclient_data-division       = wa_data-spart.
        iclient_data-qm_procmnt     = wa_data-qmpur.
        iclient_data-pur_valkey     = wa_data-ekwsl.
        iclient_datax-matl_group    = 'X'.
        iclient_datax-old_mat_no    = 'X'.
        iclient_datax-base_uom      = 'X'.
        iclient_datax-po_unit       = 'X'.
        iclient_datax-document      = 'X'.
        iclient_datax-unit_of_wt    = 'X'.
        iclient_datax-division      = 'X'.
        iclient_datax-var_ord_un    = 'X'.
        iclient_data-pur_valkey    = 'X'.
    move-corresponding wa_data to iplant_data.
    Plant - Purchasing
        iplant_data-plant          = wa_data-werks.
        iplant_data-pur_group      = wa_data-ekgrp.
        iplant_data-gr_pr_time     = wa_data-webaz.
        iplant_datax-plant         = wa_data-werks.
        iplant_data-pur_group      = 'X'.
        iplant_datax-gr_pr_time     = 'X'.
    *MRP1 View
        iplant_data-mrp_type       = wa_data-dismm.
        iplant_data-reorder_pt     = wa_data-minbe.
        iplant_data-mrp_ctrler     = wa_data-dispo.
        iplant_data-lotsizekey     = wa_data-disls.
        iplant_data-max_stock      = wa_data-mabst .
        iplant_datax-mrp_type       = 'X'.
        iplant_datax-reorder_pt     = 'X'.
        iplant_datax-mrp_ctrler     = 'X'.
        iplant_datax-lotsizekey     = 'X'.
        iplant_datax-max_stock      = 'X'.
    *MRP2 View
        iplant_data-plnd_delry     = wa_data-plifz.
        iplant_data-sm_key         = wa_data-fhori.
        iplant_data-ctrl_key       = wa_data-qsspur.
        iplant_data-availcheck     = wa_data-mtvfp.
        iplant_datax-plnd_delry     = 'X'.
        iplant_datax-sm_key         = 'X'.
        iplant_data-ctrl_key        = 'X'.
        iplant_datax-availcheck     = 'X'.
    *MRP3 View
       iplant_data-safety_stk     = wa_data-eisbe.
       iplant_data-qm_authgrp     = wa_data-qmatauth.
       iplant_datax-safety_stk     = 'X'.
       iplant_data-qm_authgrp      = 'X'.
    move-corresponding wa_data to istoragelocationdata.
    Storage View
        istoragelocationdata-plant        = wa_data-werks.
        istoragelocationdata-stge_loc     = wa_data-lgort_d.
        istoragelocationdata-stge_bin     = wa_data-lgpbe.
        istoragelocationdatax-plant        = wa_data-werks.
        istoragelocationdatax-stge_loc     = wa_data-lgort_d.
        istoragelocationdatax-stge_bin     = 'X'.
    Accounting
        iaccounting_data-val_area   = wa_data-werks.
        iaccounting_data-price_ctrl = wa_data-vprsv.
        iaccounting_data-moving_pr  = wa_data-verpr_bapi.
        iaccounting_data-price_unit = wa_data-peinh.
        iaccounting_data-val_class  = wa_data-bklas.
        iaccounting_data-val_cat    = wa_data-bwtty_d.
        iaccounting_datax-val_area   = wa_data-werks.
        iaccounting_datax-price_ctrl = 'X'.
        iaccounting_datax-moving_pr  = 'X'.
        iaccounting_datax-price_unit = 'X'.
        iaccounting_datax-val_class  = 'X'.
        iaccounting_datax-val_cat    = 'X'.
    clear it_ret.
    refresh it_ret.
    perform f_call_bapi.
    read table it_ret with key type = 'S'.
    if sy-subrc eq 0.
    perform f_bapi_commit.
    write:/ 'MATERIAL CREATED OR UPDATED SUCESSFULLY WITH MATERIAL NO',
    wa_data-matnr.
    else.
    *message e000(zhnc) with 'ERROR IN CREATING THE MATERIAL'.
    *WRITE: / 'ERROR IN CREATIN MATERIAL',IT_RET-MESSAGE.
    *PERFORM F_DOWNLOAD.
    endif.
    *ENDIF.
    endloop.
    endform.                    " F_GET_DATA
    *&      Form  F_CALL_BAPI
          text
    -->  p1        text
    <--  p2        text
    form f_call_bapi .
    call function 'BAPI_MATERIAL_SAVEDATA'
       exporting
         headdata                   = ihead_data
         clientdata                 = iclient_data
         clientdatax                = iclient_datax
         plantdata                  = iplant_data
         plantdatax                 = iplant_datax
       FORECASTPARAMETERS         =
       FORECASTPARAMETERSX        =
       PLANNINGDATA               =
       PLANNINGDATAX              =
        storagelocationdata        = istoragelocationdata
        storagelocationdatax       = istoragelocationdatax
         valuationdata              = iaccounting_data
         valuationdatax             = iaccounting_datax
       WAREHOUSENUMBERDATA        =
       WAREHOUSENUMBERDATAX       =
       SALESDATA                  =
       SALESDATAX                 =
       STORAGETYPEDATA             = istoragelocationdata
       STORAGETYPEDATAX            = istoragelocationdatax
       FLAG_ONLINE                = ' '
       FLAG_CAD_CALL              = ' '
       NO_DEQUEUE                 = ' '
       NO_ROLLBACK_WORK           = ' '
      importing
        return                     = it_ret
      tables
        materialdescription        = it_makt
       UNITSOFMEASURE             = it_uom
       UNITSOFMEASUREX            = it_uomx
      INTERNATIONALARTNOS        =
         materiallongtext          = iltxt
       TAXCLASSIFICATIONS        =
        returnmessages             = returnm.
       PRTDATA                   =
       PRTDATAX                  =
       EXTENSIONIN               =
       EXTENSIONINX              =
    append it_ret.
    write: it_ret-message .
    endform.                    " F_CALL_BAPI
    *&      Form  F_BAPI_COMMIT
          text
    -->  p1        text
    <--  p2        text
    form f_bapi_commit .
    call function 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
      WAIT         =
    IMPORTING
      RETURN        =
    endform.                    " F_BAPI_COMMIT
    Plz suggest some solution.
    Best Regards,
    Ravi

    Hi,
    Insert Material number in the MAKT(Material Description table).
    Also, check if the material number is missing somewhere else...
    Regards,
    Kunjal

  • Issue in material master update from presentation server  using BAPI....

    Hi Guru's...
    i am trying to change the material master from presentation server (desktop flat file)
    using BAPI(BAPI_MATERIAL_SAVEDATA) ....
    while executing my program i am getting the message like material had changed...
    but while in mm02 i am un able to fine the updates...
    please find below program logic and correct me if any mistakes....
    thanks in advance...
    *& Report  ZAREPAS36
    REPORT  zarepas36.
    DATA : gs_bapimathead             TYPE  bapimathead,
           gs_clientdata              TYPE  bapi_mara,
           gs_clientdatax             TYPE  bapi_marax.
    TYPES : BEGIN OF gty_itab1,
            matnr(18),
            matkl(9),
            spart(2),
            ntgew(13),
            gewei(3),
            meins(3),
            END OF gty_itab1.
    DATA : gt_itab1 TYPE STANDARD TABLE OF gty_itab1,
           gwa_itab1 TYPE gty_itab1.
    TYPES: BEGIN OF gty_itab2,
           abc(132),
           END OF gty_itab2.
    DATA: gt_itab2 TYPE STANDARD TABLE OF gty_itab2,
          gwa_itab2 TYPE gty_itab2.
    flat file at selection screen
    PARAMETERS: p_files TYPE string.
    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.
      IF gwa_itab2-abc(1) = 'S'.
        gwa_itab1 = gwa_itab2-abc(132).
        APPEND gwa_itab1 TO gt_itab1.
      ENDIF.
    ENDLOOP.
    loop at gt_itab1 into gwa_itab1.
    *Material
    gs_bapimathead-material    = gwa_itab1-matnr.
    *Material details at client data
    *material group.
    gs_clientdata-matl_group = gwa_itab1-matkl.
    gs_clientdatax-matl_group = 'X'.
    *Division
    gs_clientdata-division = gwa_itab1-spart.
    gs_clientdatax-division = 'X'.
    *Net Weight
    gs_clientdata-net_weight = gwa_itab1-ntgew.
    gs_clientdatax-net_weight = 'X'.
    *Unit of Weight
    gs_clientdata-unit_of_wt = gwa_itab1-gewei.
    gs_clientdatax-unit_of_wt = 'X'.
    *Base Unit of Measure
    gs_clientdata-base_uom = gwa_itab1-meins.
    gs_clientdatax-base_uom = 'X'.
    endloop.
    *calling BAPI for making changes in material and saving thru BAPI.
    CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
      EXPORTING
        headdata    = gs_bapimathead
        clientdata  = gs_clientdata
        clientdatax = gs_clientdatax.
    IF sy-subrc NE 0.
      CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
      WRITE: / 'Error occured while changing material'.
    ELSE.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
      WRITE: / 'material',gs_bapimathead-material,'changed'.
    ENDIF.

    hi hello Guru's
    i resolved the issuee..
    pleaso go thru the below proram logic for your reference..........
    *& Report  ZAREPAS36
    REPORT  zarepas36.
    DATA : gs_bapimathead             TYPE  bapimathead,
           gs_clientdata              TYPE  bapi_mara,
           gs_clientdatax             TYPE  bapi_marax.
    TYPES : BEGIN OF gty_itab1,
            matnr(18),
            matkl(9),
            spart(2),
            ntgew(13),
            gewei(3),
            meins(3),
            END OF gty_itab1.
    DATA : gt_itab1 TYPE STANDARD TABLE OF gty_itab1,
           gwa_itab1 TYPE gty_itab1.
    TYPES: BEGIN OF gty_itab2,
           abc(132),
           END OF gty_itab2.
    DATA: gt_itab2 TYPE STANDARD TABLE OF gty_itab2,
          gwa_itab2 TYPE gty_itab2.
    DATA:ls_return         TYPE bapiret2,
         lt_bapiret2       TYPE standard table of bapiret2.
    flat file at selection screen
    PARAMETERS: p_files TYPE string.
    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.
      IF gwa_itab2-abc(1) = 'S'.
        gwa_itab1 = gwa_itab2-abc(132).
        APPEND gwa_itab1 TO gt_itab1.
      ENDIF.
    ENDLOOP.
    LOOP AT gt_itab1 INTO gwa_itab1.
    *Material
      gs_bapimathead-material    = gwa_itab1-matnr.
    *Material details at client data
    *material group.
      gs_clientdata-matl_group = gwa_itab1-matkl.
      gs_clientdatax-matl_group = 'X'.
    *Division
      gs_clientdata-division = gwa_itab1-spart.
      gs_clientdatax-division = 'X'.
    *Net Weight
      gs_clientdata-net_weight = gwa_itab1-ntgew.
      gs_clientdatax-net_weight = 'X'.
    *Unit of Weight
      gs_clientdata-unit_of_wt = gwa_itab1-gewei.
      gs_clientdatax-unit_of_wt = 'X'.
    *Base Unit of Measure
      gs_clientdata-base_uom = gwa_itab1-meins.
      gs_clientdatax-base_uom = 'X'.
    ENDLOOP.
    *calling BAPI for making changes in material and saving thru BAPI.
    CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
      EXPORTING
        headdata    = gs_bapimathead
        clientdata  = gs_clientdata
        clientdatax = gs_clientdatax
      IMPORTING
        return      = ls_return.
    LOOP AT lt_bapiret2 INTO ls_return.
      EXIT.
    ENDLOOP.
    IF sy-subrc = 0.
      CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
      WRITE: / 'Error occured while changing material'.
    ELSE.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
      WRITE: / 'material',gs_bapimathead-material,'changed'.
    ENDIF.

  • Problem in creation of sales order using BAPI

    Hi Guru's,
                  I am currently working on Minimum Order Value problem. If the ordered item is less than 5$, the requirement is to add a new material MOV to the existing order by filling the difference amount and making it to 5 pounds. I am using the bapi BAPI_SALESORDER_CHANGE to amend the existing order with the MOV material. The material is getting created successfully and the order is getting amended. When i tried to process the order for billing It shows incompletion log exist. On checking the incompletion log it shows "missing configuration". But when i go to the configuration of the material it shows green sign. <b>The most important thing is the material MOV has 2 configuration profile, I believe there is a confusion in selecting the configuration profile for creation of MOV </b>. I came to know about that problem because when i go to change mode (VA02) and try to check the configuration, It askes me to choose the configuration profile and when i choose the configuration profile incompletion log is cleared. When i save the order and send it to billing the billing happens successfully. Could any one help me on this issue.......
    Parameters passed to BAPI for configuration.
       st_order_cfgs_ref-posex = '900010'.            "PM14/06/07
      st_order_cfgs_ref-config_id = '000010'.       "PM14/06/07
      st_order_cfgs_ref-root_id = '10000010'.         "PM14/06/07
      append st_order_cfgs_ref to t_order_cfgs_ref.   "PM14/06/07
    st_order_cfgs_inst-config_id = '000010'.       "PM14/06/07
      st_order_cfgs_inst-inst_id = '10000010'.         "PM14/06/07
      append st_order_cfgs_inst to t_order_cfgs_inst.   "PM14/06/07
      st_order_cfgs_refinst-posex = '900010'.       "PM14/06/07
    st_order_cfgs_refinst-config_id = '000010'.       "PM14/06/07
      st_order_cfgs_refinst-inst_id = '10000010'.         "PM14/06/07
      append st_order_cfgs_refinst to t_order_cfgs_refinst.   "PM14/06/07
    Thanks in advance...
    Shiv

    Hi,
    Did u have a look at the standard programs which make use of BAPI_SALESORDER_CREATEFROMDAT1
    Heres a list...
    LWSSOU08                     
    MV45WF0S                     
    MWWMJF21_BAPI_SALESORDER_CREAT
    RBUS2032                    
    Regards,
    Tanveer.
    <b>Please mark helpful answers</b>

  • Problem in Creation of BAPI

    Hello friends,
    I'am facing problem in creating BAPI.
    I've created and released BAPI function module successfully.
    I've also created Business Object type, included the function module in business object type, and released Method of this business object type. I've generated and implemented Business Object type too.
    However I am not able to view my business object in BAPI explorer.
    Please help.
    Regards,
    Navin

    Hi
    In BAPI explorer, Customer BAPI, cannot be viewed directly.
    To display all BAPIs, change the settings by choosing Goto -> Set release filter.
    <b>Use transaction BAPI</b>, and then <b>Click F5 Key</b> and Select <b>All</b> Radio button.
    Hope this will help.
    Please reward suitable points.
    Regards
    - Atul

  • Issue in creating sales order using BAPI's...?

    Hi Guru's,
    i had generated the sales order using the BAPI..but could please guide me how to declare the data declaratin same fields as globally and how to move internal table and how to append ....
    thanks in advance...
    REPORT z_bapi_salesorder_create.
    Sales document type
    PARAMETERS: p_auart TYPE auart OBLIGATORY.
    Sales organization
    PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY.
    Distribution channel
    PARAMETERS: p_vtweg TYPE vtweg OBLIGATORY.
    Division.
    PARAMETERS: p_spart TYPE spart OBLIGATORY.
    Sold-to
    PARAMETERS: p_sold  TYPE kunnr OBLIGATORY.
    Ship-to
    PARAMETERS: p_ship  TYPE kunnr OBLIGATORY.
    Material
    PARAMETERS: p_matnr TYPE matnr   OBLIGATORY.
    Quantity.
    PARAMETERS: p_menge TYPE kwmeng  OBLIGATORY.
    Plant
    PARAMETERS: p_plant TYPE werks_d OBLIGATORY.
    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.
    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.
         call FUNCTION 'BAPI_TRANSACTION_COMMIT'.
        WRITE: / 'Document ', v_vbeln, ' created'.
      ENDIF.

    *& Report  ZAREPAS30
    REPORT  zarepas30.
    DATA : gs_vbeln                   TYPE  vbak-vbeln,
           gs_order_header_in         TYPE  bapisdhd1,
           gs_order_header_inx        TYPE  bapisdhd1x,
           gt_order_items_in          TYPE  STANDARD TABLE OF bapisditm,
           gwa_itab1                  TYPE  bapisditm,
           gt_order_items_inx         TYPE  STANDARD TABLE OF bapisditmx,
           gwa_itab2                  TYPE  bapisditmx,
           gt_order_partners          TYPE  STANDARD TABLE OF bapiparnr,
           gwa_itab3                  TYPE  bapiparnr,
           gt_return                  TYPE  STANDARD TABLE OF bapiret2,
           gwa_itab4                  TYPE  bapiret2.
    Sales document type
      PARAMETERS: p_auart TYPE auart OBLIGATORY.
    Sales organization
      PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY.
    Distribution channel
      PARAMETERS: p_vtweg TYPE vtweg OBLIGATORY.
    Division.
      PARAMETERS: p_spart TYPE spart OBLIGATORY.
    Requested Delivery Date
      PARAMETERS: p_edatu  TYPE edatu OBLIGATORY.
    Sold-to
      PARAMETERS: p_sold  TYPE kunnr OBLIGATORY.
    Ship-to
      PARAMETERS: p_ship  TYPE kunnr OBLIGATORY.
    Material
      PARAMETERS: p_matnr TYPE matnr   OBLIGATORY.
    Quantity.
      PARAMETERS: p_menge TYPE kwmeng  OBLIGATORY.
    Plant
      PARAMETERS: p_plant TYPE werks_d OBLIGATORY.
    Start-of-selection.
      START-OF-SELECTION.
    Header data
    Sales document type
      gs_order_header_in-doc_type = p_auart.
      gs_order_header_inx-doc_type = 'X'.
    Sales organization
      gs_order_header_in-sales_org = p_vkorg.
      gs_order_header_inx-sales_org = 'X'.
    Distribution channel
      gs_order_header_in-distr_chan  = p_vtweg.
      gs_order_header_inx-distr_chan = 'X'.
    Division
      gs_order_header_in-division = p_spart.
      gs_order_header_inx-division = 'X'.
    Reguested Delivery Date
      gs_order_header_in-req_date_h = p_edatu.
      gs_order_header_inx-req_date_h = 'X'.
      gs_order_header_inx-updateflag = 'I'.
    Partner data
    Sold to
      gwa_itab3-partn_role = 'AG'.
      gwa_itab3-partn_numb = p_sold.
      APPEND gwa_itab3 TO  gt_order_partners .
    ship to
      gwa_itab3-partn_role = 'WE'.
      gwa_itab3-partn_numb = p_ship.
      APPEND gwa_itab3 TO  gt_order_partners .
    ITEM DATA
      gwa_itab2-updateflag = 'I'.
    Line item number.
      gwa_itab1-itm_number = '000010'.
      gwa_itab2-itm_number = 'X'.
    Material
      gwa_itab1-material = p_matnr.
      gwa_itab2-material = 'X'.
    Plant
      gwa_itab1-plant    = p_plant.
      gwa_itab2-plant   = 'X'.
    Quantity
      gwa_itab1-target_qty = p_menge.
      gwa_itab2-target_qty = 'X'.
      APPEND gwa_itab1 TO gt_order_items_in.
      APPEND gwa_itab2 TO gt_order_items_inx.
    Line item number.
      gwa_itab1-itm_number = '000020'.
      gwa_itab2-itm_number = 'X'.
    Material
      gwa_itab1-material = p_matnr.
      gwa_itab2-material = 'X'.
    Plant
      gwa_itab1-plant    = p_plant.
      gwa_itab2-plant   = 'X'.
    Quantity
      gwa_itab1-target_qty = p_menge.
      gwa_itab2-target_qty = 'X'.
      APPEND gwa_itab1 TO gt_order_items_in.
      APPEND gwa_itab2 TO gt_order_items_inx.
    CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
      EXPORTING
        order_header_in               = gs_order_header_in
        ORDER_HEADER_INX              = gs_order_header_inx
      IMPORTING
        SALESDOCUMENT                 = gs_vbeln
      tables
        RETURN                        = gt_return
        ORDER_ITEMS_IN                = gt_order_items_in
        ORDER_ITEMS_INX               = gt_order_items_inx
        order_partners                = gt_order_partners.
    Check the return table.
      LOOP AT gt_return into gwa_itab4 WHERE type = 'E' OR type = 'A'.
        EXIT.
      ENDLOOP.
      IF sy-subrc = 0.
        WRITE: / 'Error occured while creating sales order '.
      ELSE.
    Commit the work.
      CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
        WRITE: / 'Document ', gs_vbeln, ' created'.
      ENDIF.

Maybe you are looking for

  • Macbook Air Mid-2012 UI freeze

    Hi there, I have a Mid-2012 13" Macbook Air (i7 and 8GB of RAM) with Mountain Lion and all software updates (as of 15th of November) and for the last few weeks I have been experiencing some random and very strange UI freezes. It seems to happen while

  • Why are enums with constant-specifics  methods no enums?

    I'm working on an application which uses reflection to determine how a certain object should be represented in the GUI. If an object is an enum it will be represented as a drop-down box. Yesterday however our code broke on a newly added enum which us

  • How to INSTALL SAMPLES on 10.4.6 HD when system is 10.4.8 RED " ! "

    I get a red explamation point ! ! ! ! only in RED when I go to choose a HD to install. Read here it happens when a HD may have an old OS on it. Is there a way to fix this? I want to install SOFTWARE SAMPLES (Drums) onto a different drive but the syst

  • Reader Software Sync Issue

    Sony has received reports from a number of PRST1 owners that the Reader software has been causing bookmarks and notes to be duplicated with some of their books. Sony engineering is aware of the issue and is currently working on a solution which will

  • Delete post in wrong topic?

    Hi there, I posted in the wrong place last night, can someone remove this post for me? Thanks. http://discussions.apple.com/thread.jspa?threadID=2401902&tstart=0