Create work order using BAPI_ALM_ORDER_MAINTAIN

Does anybody know how to use BAPI_ALM_ORDER_MAINTAIN to create a maintenance order?  I did a where used and it isn't used by SAP.  The documentation makes it look like I can use it for create but I am not sure how to do that.
Regards,
Davis

Hi,
I have one sample code piece. try to fit your requirement.
TYPES: t_alm_method       type bapi_alm_order_method occurs 1.
TYPES: t_alm_component    type bapi_alm_order_component occurs 1.
TYPES: t_alm_component_up type bapi_alm_order_component_up occurs 1.
TYPES: BEGIN of tp_sv_update,
         aufnr            type aufnr,             
         method           type t_alm_method,
         component        type t_alm_component,
         component_up     type t_alm_component_up,
       END of tp_sv_update.
  DATA:    ls_method       type bapi_alm_order_method.
  DATA:    ls_component    type bapi_alm_order_component.
  DATA:    ls_component_up type bapi_alm_order_component_up.
  DATA:    ls_sv_update    type tp_sv_update.
  DATA:    lv_tabix        like sy-tabix.
  STATICS: sv_refno        type i.
    clear: lv_tabix, sv_refno.
    ls_sv_update-aufnr     =  gt_alv1_data-aufnr.
  endif.
  sv_refno  = sv_refno + 1.
  ls_method-refnumber      =  sv_refno.
  ls_method-objecttype     =  'COMPONENT'.
  ls_method-method         =  'CHANGE'.
  ls_method-objectkey      =  gt_alv1_data-aufnr.
  APPEND ls_method to ls_sv_update-method.
  if sv_refno eq 1.
    ls_method-refnumber      =  sv_refno.
    ls_method-objecttype     =  space.
    ls_method-method         =  'SAVE'.
    ls_method-objectkey      =  gt_alv1_data-aufnr.
    APPEND ls_method to ls_sv_update-method.
  endif.
  ls_component-reserv_no   =  gt_alv1_data-rsnum.
  ls_component-res_item    =  gt_alv1_data-rspos.
  ls_component-activity    =  gt_alv1_data-vornr.
  ls_component-material    =  gt_alv1_data-matnr.
  if gt_alv1_data-menge_up is not initial.
    ls_component-requirement_quantity =  gt_alv1_data-menge_up.
  endif.
  if gt_alv1_data-netpr_up is not initial.
    ls_component-price       =  gt_alv1_data-netpr_up.
    ls_component-currency    =  gt_alv1_data-waers.
*   It appears the Price is not updated unless the quantity is
    if gt_alv1_data-menge_up is initial.
      ls_component-requirement_quantity =  gt_alv1_data-bdmng.
    endif.
  endif.
  APPEND ls_component to ls_sv_update-component.
  if gt_alv1_data-menge_up is not initial.
    ls_component_up-requirement_quantity =  'X'.
  endif.
  if gt_alv1_data-netpr_up is not initial.
    ls_component_up-price    =  'X'.
    ls_component_up-currency =  'X'.
*   It appears the Price is not updated unless the quantity is
    ls_component_up-requirement_quantity =  'X'.
  endif.
  APPEND ls_component_up to ls_sv_update-component_up.
  if lv_tabix is not initial.
    SORT    ls_sv_update-method by method.
    MODIFY  gt_sv_update  from ls_sv_update
      index lv_tabix transporting method component component_up.
  else.
    APPEND  ls_sv_update    to gt_sv_update.
  endif.
  if gt_alv1_data-menge_up is not initial.
    move 'UPDATED'  to gt_alv1_data-input_menge.
  endif.
  if gt_alv1_data-netpr_up is not initial.
    move 'UPDATED'  to gt_alv1_data-input_netpr.
  endif.
  modify gt_alv1_data transporting input_menge input_netpr.
  LOOP at gt_sv_update.
    CLEAR: lt_return[].
    CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
      TABLES
        it_methods      = gt_sv_update-method
        it_component    = gt_sv_update-component
        it_component_up = gt_sv_update-component_up
        return          = lt_return.
ENDLOOP.

Similar Messages

  • Create Work Order Using BAPI in LSMW

    Hi All,
    I searched in SCN but i dint get the correct idea to create Work Order USING BAPI,
    Im trying to create Work Order Using BAPI in LSWM
    Can any one Give me Brief Idea to create Work Order(Either Component or Operations) (t code - IW31) using BAPI in LSMW
    Regards
    Smitha

    Hi All,
    I searched in SCN but i dint get the correct idea to create Work Order USING BAPI,
    Im trying to create Work Order Using BAPI in LSWM
    Can any one Give me Brief Idea to create Work Order(Either Component or Operations) (t code - IW31) using BAPI in LSMW
    Regards
    Smitha

  • Creating an order using Bapi_alm_order_maintain

    Hi,
    Can any one help me how to use bapi to create an order (example code ) using BAPI_ALM_ORDER_MAINTAIN.
    reagrds
    Praveen k

    Hi,
    REPORT  ZMK_BAPI_PROGRAM                        .
    DATA : RESB.
    DATA : IT_METHODS LIKE BAPI_ALM_ORDER_METHOD OCCURS 0 ,
           IT_HEADER LIKE BAPI_ALM_ORDER_HEADERS_I OCCURS 0,
           IT_HEADER_UP LIKE BAPI_ALM_ORDER_HEADERS_UP OCCURS 0 ,
           IT_RETURN LIKE  BAPIRET2 OCCURS 0 WITH HEADER LINE.
    DATA : X_METHODS LIKE BAPI_ALM_ORDER_METHOD ,
           X_HEADER LIKE BAPI_ALM_ORDER_HEADERS_I,
           X_HEADER_UP LIKE BAPI_ALM_ORDER_HEADERS_UP .
    DATA T_METH TYPE TABLE OF BAPI_ALM_ORDER_METHOD.
    **Internal table for Operation (BAPI)
    DATA T_OPER TYPE TABLE OF BAPI_ALM_ORDER_OPERATION.
    DATA T_COMP TYPE TABLE OF BAPI_ALM_ORDER_COMPONENT.
    **Internal Table for Opertaions UP (BAPI)
    DATA T_COMP_UP TYPE TABLE OF BAPI_ALM_ORDER_COMPONENT_UP.
    **Internal table for BAPI Return code
    DATA T_RET TYPE TABLE OF BAPIRET2.
    ***WORK AREA DECLARATIONS
    **Work Area for Hedaer
    DATA:WA_HEADER TYPE CAUFVDB,
    WA_METH TYPE BAPI_ALM_ORDER_METHOD,
    WA_OP TYPE AFVGB,
    WA_COMP TYPE RESBB,
    WA_COMP1 TYPE BAPI_ALM_ORDER_COMPONENT,
    WA_COMP_UP TYPE BAPI_ALM_ORDER_COMPONENT_UP,
    WA_OPER TYPE BAPI_ALM_ORDER_OPERATION.
    DATA : IT_RESB TYPE RESB OCCURS 0 WITH HEADER LINE.
    *PARAMETERS:TEST.
    ****Fill Method Internal table
    *WA_METH-REFNUMBER = '000001'.
    *WA_METH-OBJECTTYPE = 'HEADER'.
    *WA_METH-METHOD = 'CHANGE'.
    *WA_METH-OBJECTKEY(12) = '000004000180'.
    **WA_METH-OBJECTKEY+12(4) = '0020'.
    **WA_METH-OBJECTKEY+16(4) = '0020'.
    *APPEND WA_METH TO T_METH.
    DATA : WA_REFNUMBER LIKE WA_METH-REFNUMBER VALUE 1,
           WA_ITEM   LIKE EKPO-EBELP .
    CLEAR WA_METH.
    WA_METH-METHOD = 'SAVE'.
    APPEND WA_METH TO T_METH.
    SELECT * FROM RESB INTO TABLE IT_RESB
                           WHERE AUFNR = '000004000180'.
    IF SY-SUBRC EQ 0.
      LOOP AT IT_RESB.
        WA_REFNUMBER = WA_REFNUMBER + 1.
        WA_METH-REFNUMBER = WA_REFNUMBER.
        WA_METH-OBJECTTYPE = 'COMPONENT'.
        WA_METH-METHOD = 'CHANGE'.
        WA_METH-OBJECTKEY(12) = '000004000180'.
    *WA_METH-OBJECTKEY+12(4) = '0020'.
    *WA_METH-OBJECTKEY+16(4) = '0020'.
        APPEND WA_METH TO T_METH.
        CLEAR WA_ITEM.
        CONCATENATE  IT_RESB-RSPOS+0(4) '0' INTO WA_ITEM.
        WA_COMP1-RESERV_NO = IT_RESB-RSNUM.
        WA_COMP1-RES_ITEM =  IT_RESB-RSPOS.
        WA_COMP1-ACTIVITY = '0010'.
        WA_COMP1-ITEM_NUMBER = WA_ITEM.
    *wa_comp1-special_stock = 'B'.
        WA_COMP1-REQUIREMENT_QUANTITY = '1102'.
    *wa_comp1-stge_loc = '0001'.
    *wa_comp1-backflush = 'X'.
        APPEND WA_COMP1 TO T_COMP.
    ****Component Update Internal table
    ***WA_COMP_UP-SPECIAL_STOCK = 'X'.
    ****wa_comp_up-backflush = 'X'.
        WA_COMP_UP-REQUIREMENT_QUANTITY = 'X'.
    ****wa_comp_up-stge_loc = 'X'.
        APPEND WA_COMP_UP TO T_COMP_UP.
      ENDLOOP.
    ENDIF.
    X_HEADER-ORDERID = '000004000180'.
    APPEND X_HEADER TO IT_HEADER.
    ***WA_METH-REFNUMBER = '000001'.
    ***WA_METH-OBJECTTYPE = 'COMPONENT'.
    ***WA_METH-METHOD = 'CHANGE'.
    ***WA_METH-OBJECTKEY(12) = '000004000180'.
    ****WA_METH-OBJECTKEY+12(4) = '0020'.
    ****WA_METH-OBJECTKEY+16(4) = '0020'.
    ***APPEND WA_METH TO T_METH.
    ***WA_METH-REFNUMBER = '000002'.
    ***WA_METH-OBJECTTYPE = 'COMPONENT'.
    ***WA_METH-METHOD = 'CHANGE'.
    ***WA_METH-OBJECTKEY(12) = '000004000180'.
    ****WA_METH-OBJECTKEY+12(4) = '0020'.
    ****WA_METH-OBJECTKEY+16(4) = '0020'.
    ***APPEND WA_METH TO T_METH.
    ***WA_METH-REFNUMBER = '000003'.
    ***WA_METH-OBJECTTYPE = 'COMPONENT'.
    ***WA_METH-METHOD = 'CHANGE'.
    ***WA_METH-OBJECTKEY(12) = '000004000180'.
    ****WA_METH-OBJECTKEY+12(4) = '0020'.
    ****WA_METH-OBJECTKEY+16(4) = '0020'.
    ***APPEND WA_METH TO T_METH.
    ***WA_METH-REFNUMBER = '000004'.
    ***WA_METH-OBJECTTYPE = 'COMPONENT'.
    ***WA_METH-METHOD = 'CHANGE'.
    ***WA_METH-OBJECTKEY(12) = '000004000180'.
    ****WA_METH-OBJECTKEY+12(4) = '0020'.
    ****WA_METH-OBJECTKEY+16(4) = '0020'.
    ***APPEND WA_METH TO T_METH.
    ***WA_METH-REFNUMBER = '000005'.
    ***WA_METH-OBJECTTYPE = 'COMPONENT'.
    ***WA_METH-METHOD = 'CHANGE'.
    ***WA_METH-OBJECTKEY(12) = '000004000180'.
    ****WA_METH-OBJECTKEY+12(4) = '0020'.
    ****WA_METH-OBJECTKEY+16(4) = '0020'.
    ***APPEND WA_METH TO T_METH.
    ***X_HEADER-ORDERID = '000004000180'.
    ***APPEND X_HEADER TO IT_HEADER.
    *****Component Internal table
    ***WA_COMP1-RESERV_NO = '0000001461'.
    ***WA_COMP1-RES_ITEM = '0002'.
    ***WA_COMP1-ACTIVITY = '0010'.
    ***WA_COMP1-ITEM_NUMBER = '0020'.
    ****wa_comp1-special_stock = 'B'.
    ***WA_COMP1-REQUIREMENT_QUANTITY = '12102'.
    ****wa_comp1-stge_loc = '0001'.
    ****wa_comp1-backflush = 'X'.
    ***APPEND WA_COMP1 TO T_COMP.
    ****Component Update Internal table
    ***WA_COMP_UP-SPECIAL_STOCK = 'X'.
    ****wa_comp_up-backflush = 'X'.
    ***WA_COMP_UP-REQUIREMENT_QUANTITY = 'X'.
    ****wa_comp_up-stge_loc = 'X'.
    ***APPEND WA_COMP_UP TO T_COMP_UP.
    ***WA_COMP1-RESERV_NO = '0000001461'.
    ***WA_COMP1-RES_ITEM = '0003'.
    ***WA_COMP1-ACTIVITY = '0010'.
    ***WA_COMP1-ITEM_NUMBER = '0030'.
    ****wa_comp1-special_stock = 'B'.
    ***WA_COMP1-REQUIREMENT_QUANTITY = '13013'.
    ****wa_comp1-stge_loc = '0001'.
    ****wa_comp1-backflush = 'X'.
    ***APPEND WA_COMP1 TO T_COMP.
    ****Component Update Internal table
    ***WA_COMP_UP-SPECIAL_STOCK = 'X'.
    ****wa_comp_up-backflush = 'X'.
    ***WA_COMP_UP-REQUIREMENT_QUANTITY = 'X'.
    ****wa_comp_up-stge_loc = 'X'.
    ***APPEND WA_COMP_UP TO T_COMP_UP.
    ***WA_COMP1-RESERV_NO = '0000001461'.
    ***WA_COMP1-RES_ITEM = '0004'.
    ***WA_COMP1-ACTIVITY = '0010'.
    ***WA_COMP1-ITEM_NUMBER = '0040'.
    ****wa_comp1-special_stock = 'B'.
    ***WA_COMP1-REQUIREMENT_QUANTITY = '14014'.
    ****wa_comp1-stge_loc = '0001'.
    ****wa_comp1-backflush = 'X'.
    ***APPEND WA_COMP1 TO T_COMP.
    ****Component Update Internal table
    ***WA_COMP_UP-SPECIAL_STOCK = 'X'.
    ****wa_comp_up-backflush = 'X'.
    ***WA_COMP_UP-REQUIREMENT_QUANTITY = 'X'.
    ****wa_comp_up-stge_loc = 'X'.
    ***APPEND WA_COMP_UP TO T_COMP_UP.
    ***WA_COMP1-RESERV_NO = '0000001461'.
    ***WA_COMP1-RES_ITEM = '0005'.
    ***WA_COMP1-ACTIVITY = '0010'.
    ***WA_COMP1-ITEM_NUMBER = '0050'.
    ****wa_comp1-MATERIAL = '803'.
    ***WA_COMP1-REQUIREMENT_QUANTITY = '15013'.
    ****wa_comp1-stge_loc = '0001'.
    ****wa_comp1-backflush = 'X'.
    ***APPEND WA_COMP1 TO T_COMP.
    ****Component Update Internal table
    ****wa_comp_up-MATERIAL = 'X'.
    ****wa_comp_up-backflush = 'X'.
    ***WA_COMP_UP-REQUIREMENT_QUANTITY = 'X'.
    ****wa_comp_up-stge_loc = 'X'.
    ***APPEND WA_COMP_UP TO T_COMP_UP.
    ***WA_COMP1-RESERV_NO = '0000001461'.
    ***WA_COMP1-RES_ITEM = '0006'.
    ***WA_COMP1-ACTIVITY = '0010'.
    ***WA_COMP1-ITEM_NUMBER = '0060'.
    ****wa_comp1-MATERIAL = '803'.
    ***WA_COMP1-REQUIREMENT_QUANTITY = '11563'.
    ****wa_comp1-stge_loc = '0001'.
    ****wa_comp1-backflush = 'X'.
    ***APPEND WA_COMP1 TO T_COMP.
    ****Component Update Internal table
    ****wa_comp_up-MATERIAL = 'X'.
    ****wa_comp_up-backflush = 'X'.
    ***WA_COMP_UP-REQUIREMENT_QUANTITY = 'X'.
    ****wa_comp_up-stge_loc = 'X'.
    ***APPEND WA_COMP_UP TO T_COMP_UP.
    PERFORM CALL_BAPI.
    *&      Form  CALL_BAPI
          text
    -->  p1        text
    <--  p2        text
    FORM CALL_BAPI .
      CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
      TABLES
      IT_METHODS = T_METH
      IT_HEADER = IT_HEADER
    *it_header_up = it_header_up
      IT_COMPONENT = T_COMP
      IT_COMPONENT_UP = T_COMP_UP
      RETURN = T_RET.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
      REFRESH: T_COMP,
               T_COMP_UP,
               T_RET.
    ENDFORM.                    " CALL_BAPI
    Check this code...., and also read the BAPI documentation it is explained very well...
    <b>Reward points</b>
    Regards

  • How to create Work Order in CMRO

    Dear All,
    We are new to using Oracle CMRO and because of unavailability of CMRO resources, we are facing quite a few problems while working on CMRO. Can anyone please help me out how can I create Work Order using CMRO.
    If anyone can provide me with Oracle CMRO White Papers, I will be very thankful.
    Regards,
    Zulfiqar Ali Mughal

    Hi,
    There are 3 ways to create work order in oracle cMRO.
    1) Through Maintenance Requirement and associated to visit and push to production.
    2) Non-routine.
    3) Unassociated Task.
    1.     Create Work Order From Maintenance Requirement:- In order create work order first of all we need to define an MR in Engineering > Fleet Maintenance Program > Overview > Create. After creating the MR Header at least one route should be associated (Route can be created from Engineering > Route >Overview > Create and the status should be "complete"). Then MR effectivity (means which item or unit MR is applicable) need to be defined and in turn the interval threshold also need to define. Once the MR is completed from the Planning window associate the MR to a visit and push to Production. In case of Planned MRs run the Build Unit Effectivities and view the due date from the Planning> Unit Maintenance Plan screen and associate to a Visit in Planning and push the visit to production. In case of Unplanned MRs create visit, associate unplanned MR, push to production.Work Orders would have generated and visible in Execution >Production Planning > Work Orders.
    2.     Create Non-Routine:- Non- Routines can be created from Execution and Planning
    a.Create Non-Routine work order from Execution:- Select the Routine work order and select Create Non-Routine work order from the pull down menu, furnish the details like severity, urgency, summary etc. and click on (B) Apply.
    b.Non-Routine from Planning: Create NR from Planning >Unit Maintenance Plan> Non-Routines (B)Create and then associate to a visit and push to production.
    3.     Unassociated Task:-This is for executing the miscellaneous operations to be done as part of already created visit. Navigate the visit task screen in an already created visit (Navigation: Planning > Visit Work Package > Overview > Search the visit > Click on the visit hyperlink> view visit task in side Menu), From the drop down menu select the “ Create Unassociated Task” and click (B) Go. Furnish the details in the Task header and click on (B) Apply and (B) Cancel, you would be navigate back to the “Visit Task” Screen. Select the unassociated task and push to production. Unassociated work orders would have created. You can create Unassociated task any time during the execution, before closing of visit.

  • Create a work order using the BAPI for IW31

    Hi,
          I want to create a work order using the BAPI for IW31 tr. can any one help me with the program description.
    Full points will be awarded for the useful answers.
    Thanks and regards,
    Sunil

    hi,
      first use fm "bapi_po_create".
      then use fm "BAPI_ACC_GL_POSTING_POST"
    The demo environment was made with real business scenario in mind, but following subjects need to be addressed in a live implementation:
    •     No exceptions and error handling is implemented, except the order rejection (e.g. partly delivery);
    •     In Navision both XML Ports and the XML DOM has been used to integrate with SAP XI, because XML ports has some drawbacks regarding to Namespaces in XML Documents (mandatory in SAP XI);
    •     A minimum of SAP and Navision customization is required to implement this solution. (e.g. user exit in SAP, Navision XML DOM).

  • On Work Order using Object lists for equip u can manually create Notifi

    On a maintenance Work Order using Object lists for equipment you can manually create a notification for each line item.
    We want to automate this process to do this when we save the document.
    Any ideau2019s on how to do this?
    Does a user exit exist for this?

    Hi:
    Check with Tcode: IBIP - Plant maintenace batch input utility tool.
    Hope, it may help!
    Thanks,
    Murali.

  • PM: Create notification from a work order using transaction IW32.

    Hi guys,
    I am trying to create a Notification for a Functional Location thru Work Order Using transaction Code IW32.
    The actual transaction works fine as below -
    1. Open a work order in change mode using T code IW32
    2. Choose tab "Objects" to see the list of functional locations.
    3. Select a line with a functional loc, for which you want to create Notification & click "Create" Button at the bottom of the list.
    4. Enter Notification type on the pop up screen & enter.
    5. Enter the activity code, text & start date on the notif create screen & click Back. You can see the temp Notif Number in the row selected from the object list.
    6. Click save on the order change screen & the Notification is saved & is associated with the order & func Loc..
    However I can not do this in a program.
    I tried using Batch Input method. It works, but the problem is if you have more than 1 page of the Objects (Func locations) in objects tab, you can not goto the next pages.
    I also tried using BAPI_ALM_NOTIF_CREATE. Which doesnot for this purpose. It tries to create Notification but can't associate with the order.
    I appreciate your help.
    Thank you,
    Raj

    Hi:
    Check with Tcode: IBIP - Plant maintenace batch input utility tool.
    Hope, it may help!
    Thanks,
    Murali.

  • Creating work order

    How to create a service order or work order using a BAPI ??

    Hi,
       Welcome To SDN!!
    Have you seen function modules BAPI_ALM_ORDER_CREATE and BAPI_ALM_ORDER_MAINTAIN ?
    Regards
    Kiran Sure

  • While creating Maintenance order using t-code iw31 mainwork center not pick

    Hi,
    while creating Maintenance order using t-code iw31 Maintenance work center not picking from drop down (already have in drop down)but giving manually accepting.
    --Ganesh

    Hi,
    My understanding is that the selected work center is not copied into the input field. This can be corrected with note [1451299|https://service.sap.com/sap/support/notes/1451299]. Check if the note is relevant for your system.
    -Paul

  • How can I make settlement rule mandatory in create work order (IW31)

    How can I make settlement rule mandatory in create workorder and saving without release.
    I kanow we can make settlement rule mandatory upon Release order but here requirement is
    Create work order (IW21) save without releasing that time settlement rule should default.

    Hi,
    1.If you want the settlement rule default then maintain account assignment data in technical object and when MO is created on that it would be copied into the settlement rule...
    2. If you want to make those fields mandatory .... plz check up field selections in config , if you cannot find those then use SHD0 Transaction variant to make those fields mandatory.
    3. Enter SHD0 , Enter IW31 in transaction and ZIW31 for transaction variant ..click create option and this takes you to IW31 initial screen , here enter required values of technical object etc and press enter and this gives you IW31 Initial scree screen variant , click continue and this takes you to inside screen and here enter required field values and on pressing enter gives you screen variant .. so you need to enter field values and check the flow of screen variants and on getting settlement rule screen variant select required option for the fields you need.
    4. Finally you can save that in package created in SE80 for transporting to other client .., you can activate the variant in SHD0 -->Standard variants -->you can find activate option ..
    regrds
    pushpa

  • Can i create production order using process material ?

    Dear All.
    Please help me.
    I want to create production order using process material (material type is PROC).
    For may knowledge, process order is standard for the process material, but my customer want to use the PP module for the process material.
    But I cant convert the planned order of precess material to production order in MD05.
    The system message is "System does not support planned orders for process materials."
    The followings are my test steps.
      1. Master Creation
          - Material Master, BOM, ROUTING
    In standard, process material (Material Type : PROC) need creation of master recipe. But due to my clients need (Using production order
               for the process material), I create the work center and ROUTING
      2. DM Creation
          - In MD61, I create the planned independent requirement (Type : LSF)
      3. Planned order creation for the process material using MRP
          - In MD01, I run the total MRP, the the planned order is created.
            It's order type is "LA"
      4. Converting the planned order to Production Order
          - In this step, the system give the error "System does not support planned orders for process materials."
             and can not do anything.
    I want to know that the above case is possible, and how.
    Please Help meu2026..

    Hi
    First of if yur want to create production order or process order why do you go for material type :PROC.
    you can create the same material as FERT & go ahead.
    I do not understand the logic to select the material type as PROC.
    Pl. go through SAP library where PROC is used.
    Regards
    YMREDDY

  • PS Project description when creating sales order using BAPI

    I am trying to create sales orders using BAPI_SALESORDER_CREATE_FROMDAT2.
    Because of the material configuration in table TCN61 the material will trigger a project creation in the project system.
    Now, in order to create a project, we must provide the project description.
    I would like to ask you if anyone knows how to pass the project description in one of the BAPI parameters.
    Thank you for your help.

    Thank you Sreedhar for the answer.
    I tried the CAMPAIGN field but did not work...
    In fact, I am not able to find a field, in any of the of the tables, that could hold the project description (PROJ-POST1).
    An entry is created in PROJ table when we manually create a sales order for materials specified in table TCN61.
    Thanks.

  • Creating sales order using bapi

    while creating sales order using bapi serial no is added in dat but its not saving.
    plz reply

    Hi
    See tha sample code for sales order creation
    SALES ORDER INPUT CREATION.
    PARAMETERS: p_auart TYPE auart OBLIGATORY.
    PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY.
    PARAMETERS: p_vtweg TYPE vtweg OBLIGATORY.
    PARAMETERS: p_spart TYPE vtweg OBLIGATORY.
    PARAMETERS: p_sold TYPE kunnr OBLIGATORY.
    PARAMETERS: p_ship TYPE kunnr OBLIGATORY.
    *ITEM
    PARAMETERS: p_matnr TYPE matnr OBLIGATORY.
    PARAMETERS: p_menge TYPE kwmeng OBLIGATORY.
    PARAMETERS: p_plant TYPE werks_d OBLIGATORY.
    PARAMETERS: p_itcat TYPE pstyv 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.
    HEADER DATA
    header-doc_type = p_auart.
    headerx-doc_type = 'X'.
    header-sales_org = p_vkorg.
    headerx-sales_org = 'X'.
    header-distr_chan = p_vtweg.
    headerx-distr_chan = 'X'.
    header-division = p_spart.
    headerx-division = 'X'.
    headerx-updateflag = 'I'.
    PARTNER DATA
    partner-partn_role = 'AG'.
    partner-partn_numb = p_sold.
    APPEND partner.
    partner-partn_role = 'WE'.
    partner-partn_numb = p_ship.
    APPEND partner.
    ITEM DATA
    itemx-updateflag = 'I'.
    item-itm_number = '000010'.
    itemx-itm_number = 'X'.
    item-material = p_matnr.
    itemx-material = 'X'.
    item-plant = p_plant.
    itemx-plant = 'X'.
    item-target_qty = p_menge.
    itemx-target_qty = 'X'.
    item-target_qu = 'EA'.
    itemx-target_qu = 'X'.
    item-item_categ = p_itcat.
    itemx-item_categ = '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
    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 WORK AND WAIT.
    WRITE: / 'Document ', v_vbeln, ' created'.
    ENDIF.
    after that check in the table VBAP whether serial number is cretaed or not
    Reward points if useful
    Regards
    Anji

  • HOW TO CREATE PURCHASE ORDER USING BAPI

    HI FRIENDS,
    I HAVE URGENT REQUIREMNT ,TO CREATE PURCHASE ORDER USING BAPI.PLS HELP ON THIS.
    UR'S
    RAVI

    Hi
    See the sample code and do accordingly
    REPORT zpo_bapi_purchord_tej.
    DATA DECLARATIONS *
    TYPE-POOLS slis.
    TYPES: BEGIN OF ty_table,
    v_legacy(8),
    vendor TYPE bapimepoheader-vendor,
    purch_org TYPE bapimepoheader-purch_org,
    pur_group TYPE bapimepoheader-pur_group,
    material TYPE bapimepoitem-material,
    quantity(13),
    delivery_date TYPE bapimeposchedule-delivery_date,
    net_price(23),
    plant TYPE bapimepoitem-plant,
    END OF ty_table.
    TYPES: BEGIN OF ty_alv,
    v_legs(8),
    success(10),
    v_legf(8),
    END OF ty_alv.
    TYPES: BEGIN OF ty_alv1,
    v_legf1(8),
    v_msg(500),
    END OF ty_alv1.
    *-----Work area declarations.
    DATA: x_table TYPE ty_table,
    x_header TYPE bapimepoheader,
    x_headerx TYPE bapimepoheaderx,
    x_item TYPE bapimepoitem,
    x_itemx TYPE bapimepoitemx,
    x_sched TYPE bapimeposchedule,
    x_schedx TYPE bapimeposchedulx,
    x_commatable(255),
    x_alv TYPE ty_alv,
    x_alv1 TYPE ty_alv1,
    x_alv2 TYPE ty_alv1.
    *-----Internal table declarations.
    DATA: it_table TYPE TABLE OF ty_table,
    it_commatable LIKE TABLE OF x_commatable,
    it_item TYPE TABLE OF bapimepoitem,
    it_itemx TYPE TABLE OF bapimepoitemx,
    it_sched TYPE TABLE OF bapimeposchedule,
    it_schedx TYPE TABLE OF bapimeposchedulx,
    it_alv TYPE TABLE OF ty_alv,
    it_alv1 TYPE TABLE OF ty_alv1,
    it_alv2 TYPE TABLE OF ty_alv1.
    DATA: po_number TYPE bapimepoheader-po_number,
    x_return TYPE bapiret2,
    it_return TYPE TABLE OF bapiret2,
    v_file TYPE string,
    v_temp(8),
    v_succsount TYPE i VALUE 0,
    v_failcount TYPE i VALUE 0,
    v_total TYPE i.
    DATA: v_temp1(5) TYPE n VALUE 0.
    DATA: x_event TYPE slis_t_event,
    x_fieldcat TYPE slis_t_fieldcat_alv,
    x_list_header TYPE slis_t_listheader,
    x_event1 LIKE LINE OF x_event,
    x_layout1 TYPE slis_layout_alv,
    x_variant1 TYPE disvariant,
    x_repid2 LIKE sy-repid.
    DATA : it_fieldcat TYPE TABLE OF slis_t_fieldcat_alv.
    SELECTION-SCREEN *
    SELECTION-SCREEN BEGIN OF BLOCK v_b1 WITH FRAME.
    *-----To fetch the flat file.
    PARAMETERS: p_file TYPE rlgrap-filename.
    SELECTION-SCREEN END OF BLOCK v_b1.
    AT SELECTION-SCREEN *
    AT SELECTION-SCREEN.
    IF p_file IS INITIAL.
    MESSAGE text-001 TYPE 'E'.
    ENDIF.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    *-----To use F4 help to find file path.
    CALL FUNCTION 'F4_FILENAME'
    EXPORTING
    program_name = syst-cprog
    dynpro_number = syst-dynnr
    IMPORTING
    file_name = p_file.
    v_file = p_file.
    START-OF-SELECTION *
    START-OF-SELECTION.
    PERFORM gui_upload.
    LOOP AT it_table INTO x_table.
    PERFORM header_details.
    v_temp = x_table-v_legacy.
    LOOP AT it_table INTO x_table WHERE v_legacy = v_temp.
    PERFORM lineitem.
    PERFORM schedule.
    ENDLOOP.
    DELETE it_table WHERE v_legacy = v_temp.
    PERFORM bapicall.
    MOVE po_number TO x_alv-success.
    APPEND x_alv TO it_alv.
    CLEAR x_alv.
    *-----To clear the item details in internal table after the operation for a header.
    REFRESH: it_item,
    it_itemx,
    it_sched,
    it_schedx.
    CLEAR: v_temp1.
    ENDLOOP.
    v_total = v_succsount + v_failcount.
    PERFORM display_alv.
    FORM GUI_UPLOAD *
    FORM gui_upload .
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = v_file
    filetype = 'ASC'
    TABLES
    data_tab = it_commatable
    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.
    *-----To fetch the comma seperated flat file into an internal table.
    LOOP AT it_commatable INTO x_commatable.
    IF x_commatable IS NOT INITIAL.
    SPLIT x_commatable AT ',' INTO
    x_table-v_legacy
    x_table-vendor
    x_table-purch_org
    x_table-pur_group
    x_table-material
    x_table-quantity
    x_table-delivery_date
    x_table-net_price
    x_table-plant.
    APPEND x_table TO it_table.
    ENDIF.
    CLEAR x_table.
    ENDLOOP.
    ENDIF.
    ENDFORM. " gui_upload
    FORM HEADER_DETAILS *
    FORM header_details .
    MOVE 'NB' TO x_header-doc_type.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
    input = x_table-vendor
    IMPORTING
    output = x_table-vendor
    MOVE x_table-vendor TO x_header-vendor.
    MOVE x_table-purch_org TO x_header-purch_org.
    MOVE x_table-pur_group TO x_header-pur_group.
    x_headerx-doc_type = 'X'.
    x_headerx-vendor = 'X'.
    x_headerx-purch_org = 'X'.
    x_headerx-pur_group = 'X'.
    ENDFORM. " header_details
    FORM LINEITEM *
    FORM lineitem .
    v_temp1 = v_temp1 + 10.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
    input = v_temp1
    IMPORTING
    output = v_temp1.
    MOVE v_temp1 TO x_item-po_item.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
    input = x_table-material
    IMPORTING
    output = x_table-material.
    MOVE x_table-material TO x_item-material.
    MOVE x_table-quantity TO x_item-quantity.
    MOVE x_table-net_price TO x_item-net_price.
    MOVE x_table-plant TO x_item-plant.
    x_itemx-po_item = v_temp1.
    x_itemx-material = 'X'.
    x_itemx-quantity = 'X'.
    x_itemx-net_price = 'X'.
    x_itemx-plant = 'X'.
    APPEND x_item TO it_item.
    APPEND x_itemx TO it_itemx.
    CLEAR: x_item, x_itemx.
    ENDFORM. " lineitem1
    FORM SCHEDULE *
    FORM schedule .
    MOVE x_table-delivery_date TO x_sched-delivery_date.
    MOVE v_temp1 TO x_sched-po_item.
    x_schedx-delivery_date = 'X'.
    x_schedx-po_item = v_temp1.
    APPEND x_sched TO it_sched.
    APPEND x_schedx TO it_schedx.
    CLEAR: x_sched, x_schedx.
    ENDFORM. " schedule
    FORM BAPICALL *
    FORM bapicall .
    CALL FUNCTION 'BAPI_PO_CREATE1'
    EXPORTING
    poheader = x_header
    poheaderx = x_headerx
    IMPORTING
    exppurchaseorder = po_number
    TABLES
    return = it_return
    poitem = it_item
    poitemx = it_itemx
    poschedule = it_sched
    poschedulex = it_schedx.
    IF po_number IS NOT INITIAL.
    v_succsount = v_succsount + 1.
    MOVE x_table-v_legacy TO x_alv-v_legs.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
    ELSE.
    v_failcount = v_failcount + 1.
    MOVE x_table-v_legacy TO x_alv-v_legf.
    MOVE x_table-v_legacy TO x_alv1-v_legf1.
    LOOP AT it_return INTO x_return.
    IF x_alv1-v_msg IS INITIAL.
    MOVE x_return-message TO x_alv1-v_msg.
    ELSE.
    CONCATENATE x_alv1-v_msg x_return-message INTO x_alv1-v_msg SEPARATED BY space.
    ENDIF.
    ENDLOOP.
    APPEND x_alv1 TO it_alv1.
    CLEAR x_alv1.
    ENDIF.
    ENDFORM. " bapicall
    FORM DISPLAY_ALV *
    FORM display_alv .
    PERFORM x_list_header.
    PERFORM build_fieldcat CHANGING x_fieldcat.
    x_repid2 = sy-repid.
    x_event1-name = 'TOP_OF_PAGE'.
    x_event1-form = 'TOP_OF_PAGE'.
    APPEND x_event1 TO x_event.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    i_callback_program = x_repid2
    is_layout = x_layout1
    it_fieldcat = x_fieldcat
    i_callback_user_command = 'USER_COMMAND'
    i_callback_top_of_page = 'TOP_OF_PAGE'
    i_save = 'A'
    is_variant = x_variant1
    it_events = x_event
    TABLES
    t_outtab = it_alv
    EXCEPTIONS
    program_error = 1
    OTHERS = 2.
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    ENDFORM. " display_master_data
    FORM USER_COMMAND *
    FORM user_command USING ucomm LIKE sy-ucomm selfield
    TYPE slis_selfield.
    READ TABLE it_alv INTO x_alv INDEX selfield-tabindex.
    CLEAR : x_alv2,it_alv2[].
    LOOP AT it_alv1 INTO x_alv1 WHERE v_legf1 = x_alv-v_legf.
    x_alv2 = x_alv1.
    APPEND x_alv2 TO it_alv2 .
    ENDLOOP.
    DATA : it_fieldcat TYPE slis_t_fieldcat_alv.
    DATA : x3_fieldcat LIKE LINE OF it_fieldcat.
    CLEAR : x3_fieldcat,it_fieldcat[].
    CLEAR x3_fieldcat.
    x3_fieldcat-col_pos = '1'.
    x3_fieldcat-fieldname = 'V_LEGF1'.
    x3_fieldcat-reptext_ddic = text-111.
    x3_fieldcat-ref_tabname = 'IT_ALV2'.
    APPEND x3_fieldcat TO it_fieldcat.
    CLEAR x3_fieldcat.
    CLEAR x3_fieldcat.
    x3_fieldcat-col_pos = '1'.
    x3_fieldcat-fieldname = 'V_MSG'.
    x3_fieldcat-reptext_ddic = text-112.
    x3_fieldcat-ref_tabname = 'IT_ALV2'.
    APPEND x3_fieldcat TO it_fieldcat.
    CLEAR x3_fieldcat.
    x_layout1-colwidth_optimize = 'X'.
    x_layout1-zebra = 'X'.
    IF it_alv2[] IS NOT INITIAL.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    i_callback_program = x_repid2
    is_layout = x_layout1
    it_fieldcat = it_fieldcat
    i_save = 'A'
    i_callback_top_of_page = 'TOP'
    is_variant = x_variant1
    it_events = x_event
    TABLES
    t_outtab = it_alv2
    EXCEPTIONS
    program_error = 1
    OTHERS = 2.
    ENDIF.
    ENDFORM.
    FORM USER_COMMAND *
    FORM top.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    it_list_commentary = 'Commentry'.
    ENDFORM.
    FORM BUILD_FIELDCAT *
    FORM build_fieldcat CHANGING et_fieldcat TYPE slis_t_fieldcat_alv.
    DATA: x1_fieldcat TYPE slis_fieldcat_alv.
    CLEAR x1_fieldcat.
    x1_fieldcat-col_pos = '1'.
    x1_fieldcat-fieldname = 'V_LEGS'.
    x1_fieldcat-reptext_ddic = text-108.
    x1_fieldcat-ref_tabname = 'IT_ALV'.
    APPEND x1_fieldcat TO et_fieldcat.
    CLEAR x1_fieldcat.
    x1_fieldcat-col_pos = '2'.
    x1_fieldcat-fieldname = 'SUCCESS'.
    x1_fieldcat-key = 'X'.
    x1_fieldcat-reptext_ddic = text-109.
    x1_fieldcat-ref_tabname = 'IT_ALV'.
    APPEND x1_fieldcat TO et_fieldcat.
    CLEAR x1_fieldcat.
    x1_fieldcat-col_pos = '3'.
    x1_fieldcat-fieldname = 'V_LEGF'.
    x1_fieldcat-key = 'X'.
    x1_fieldcat-reptext_ddic = text-110.
    x1_fieldcat-ref_tabname = 'IT_ALV'.
    APPEND x1_fieldcat TO et_fieldcat.
    CLEAR x1_fieldcat.
    ENDFORM. " build_fieldcat
    FORM BUILD_LIST_HEADER *
    FORM x_list_header.
    DATA: x_list_header1 TYPE slis_listheader.
    *-----List Header: type H
    CLEAR x_list_header1 .
    x_list_header1-typ = 'H'.
    x_list_header1-info = text-105.
    APPEND x_list_header1 TO x_list_header.
    *-----List Key: type S
    x_list_header1-typ = 'S'.
    x_list_header1-key = text-106.
    x_list_header1-info = v_total.
    APPEND x_list_header1 TO x_list_header.
    *-----List Key: Type S
    CLEAR x_list_header1 .
    x_list_header1-typ = 'S'.
    x_list_header1-key = text-107.
    x_list_header1-info = v_succsount.
    APPEND x_list_header1 TO x_list_header.
    ENDFORM. " build_list_header
    FORM TOP_OF_PAGE *
    FORM top_of_page.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    it_list_commentary = x_list_header.
    ENDFORM. " TOP_OF_PAGE
    Reward points if useful
    Anji

  • How to create sales order using BAPI.

    Hi all,
    I am trying to create sales order using standard BAPI
    "BAPI_SALESORDER_CREATEFROMDAT2". But, even I had entered all mandatory fields, I am unable to create sales order sucessfully.
    I had gone through the documentaion of this BAPI and entered these fields.
    These are the mandatory fields that which I had tried to create,
    ORDER_HEADER_IN :
    DOC_TYPE Sales document type
    SALES_ORG Sales organization
    DISTR_CHAN Distribution channel
    DIVISION Division
    ORDER_PARTNERS..:
    PARTN_ROLE Partner role, SP sold-to party
    PARTN_NUMB Customer number
    ORDER_ITEMS_IN..:
    MATERIAL Material number
    Do we have anymore fields to give as inputs? I am getting this error message as below :
    Msg: Personal number 00007176 does not exit.
    But, I am not giving any personal number manually. This personal number was having connection with partner role field,
    I had reffered this from the VBPA (Sales Document: Partner Table). Now, please suggest me how to solve this?
    Can anyone tell me how to solve this problem and create sales order sucessfully.
    Thanks in advance,
    Surender Batlanki.

    hi surendra ,
    chech with below code.
    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.
    let us know if you have any qauistions.
    ~linganna

Maybe you are looking for

  • Major Nano Problem - Please Help

    I have a 1 GB iPod Nano that worked fine when I got it in May 2006. Now, however I have a major problem. I put my iPod on the computer to charge through USB and when it was finished I could not safely remove. Actually, the iPod was not recognized by

  • LR3 using LR2 history

    To try out LR3,  I exported a half dozen M9 DNG files as originals into a folder from Lr2.   These were not exported as DNG but as originals .   Then I imported the test files into LR3 and to Capture One.  My objective was to see how the raw conversi

  • OCCI setVector() Problem

    Hi      I have written the following OCCI code to call two procedures 1. add1_detail(val in number) which is acceptiing an number as input 2. add_detail2(val in my_type) where my_type is a user defined type (a TABLE of NUMBER type) I am trying to cal

  • ICM 7.5-how to get individual outbound dialer calls talktime and respective ECC values

    Hello, I'm looking for following two items 1. Outbound dialer calls talktime in each call. 2. Each calls respective ECC values. I have tried to get talktime from TCD table it's shows zero value. Please advice how to get above values, it would be much

  • SAP HCM Implementation: Blue Print Phase

    Hi, I have been wondering if there are any template of generic questionnaires to be asked to the client during the TO BE info gathering which is compact and covers all aspects of an organisation. It would also be good to understand what kind of gener