Need to create the sales order by using FM; crm_order_maintain

Dear Expert's.
can any body help me on creation of sales order by using FM; crm_order_maintain.
Regards,
Tanveer.Ahmed

data: et_status type crmt_status_comt,
      es_status type crmt_status_com,
      ct_orderadm_h type  crmt_orderadm_h_comt,
      cs_orderadm_h type  crmt_orderadm_h_com,
      ct_orderadm_i type  crmt_orderadm_i_comt,
      cs_orderadm_i type  crmt_orderadm_i_com,
      ct_input_fields type crmt_input_field_tab,
      cs_input_fields type crmt_input_field,
      it_exception type  crmt_exception_t.
data: gt_crmd_orderadm_h like crmd_orderadm_h occurs 0,
      gs_crmd_orderadm_h type crmd_orderadm_h.
data: et_objects_to_save type crmt_object_guid_tab,
      es_objects_to_save type crmt_object_guid.
data: it_saved_objects type crmt_return_objects.
data: gt_field_names type crmt_input_field_names_tab,
      gs_field_names type crmt_input_field_names.
data: cv_log_handle type  balloghndl.
select single * from crmd_orderadm_h into gs_crmd_orderadm_h
where object_id = '0005000400'.
es_objects_to_save  = gs_crmd_orderadm_h-guid.
append es_objects_to_save  to et_objects_to_save .
es_status-ref_guid       = gs_crmd_orderadm_h-guid.
es_status-ref_kind       = 'A'.
es_status-status         = 'E0010'.
es_status-user_stat_proc = 'ZPR01'.
es_status-activate       = 'X'.
append es_status to et_status.
cs_input_fields-ref_guid    = gs_crmd_orderadm_h-guid.
cs_input_fields-ref_kind    = 'A'.
cs_input_fields-objectname  = 'STATUS'.
cs_input_fields-logical_key = 'E0010ZPRO1'.
gs_field_names-fieldname = 'ACTIVATE'.
append gs_field_names to gt_field_names.
cs_input_fields-field_names = gt_field_names[].
append cs_input_fields to ct_input_fields.
call function 'CRM_ORDER_MAINTAIN'
  exporting
    it_status         = et_status
  importing
    et_exception      = it_exception
  changing
    ct_orderadm_h     = ct_orderadm_h
    ct_orderadm_i     = ct_orderadm_i
    ct_input_fields   = ct_input_fields
  exceptions
    error_occurred    = 1
    document_locked   = 2
    no_change_allowed = 3
    no_authority      = 4
    others            = 5.
if sy-subrc = 0.
      call function 'CRM_ORDER_SAVE'
        exporting
          it_objects_to_save        = et_objects_to_save
       importing
         et_saved_objects           = it_saved_objects
       changing
         cv_log_handle              = cv_log_handle
       exceptions
         document_not_saved         = 1
         others                     = 2.
         commit work.
endif.

Similar Messages

  • How to create the sales order using BAPI's ....?

    Hi Guru's,
    could you please provide how to create the sales order using BAPI's .....i need step by step process and please provide the details from scratch....basically  i don't have basic knowledge on this....please provide required inputs ....:)
    thanks in advance
    Srinivas......

    Hi Guru's thanks for your inouts and your valuble time...
    please find the program logic below...
    *& 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.

  • Error while creating the sales order using Proxy

    Hi Folks,
    I am trying to create a Sales Order using Proxy via BAPI "BAPI_SALESORDER_CREATEFROMDAT2" :
    and i got this type of standard error message
    <Message>FB call: insufficient parameters</Message>
    few days back only i used the same bapi for creating the Sales Order and did it successfully...using the same parameters
    I don't have any clue about this type error .
    Kindly guide .
    Regards,

    Hi Nikhil,
    How refreshing the cache and restart the server will help ?
    basically i am testing the scenario at R/3 end only by generating XML template in SPROXY.
    My ECC 6.0 is on sp 12....I am not sure is it configuration related error or a bug ? as i have used the same code in ECC 6.0 with sp 09.
    regards,

  • How to create the sales order using excell sheet thru BAPI's?

    Hi Guru's,
    In my excell sheet i had 11 sales order details ..now i wanted to create the sales order's sing BAPI's...?
    could please guide me step by step.....that would be greatly helpfull to me...
    Thanks in advance
    Srinivas....

    Hi,
    follow below steps.
    1. Get the excel data into internal table,  Build a internal table whcih fields are in bapi same order
    2. call the Bapi and pass the table data to the bapi
    3. after calling the  bapi,  call the commit bapi.
        then only it will careates.
    Regards
    Ganesh

  • Problem in when creating the sales order

    Hi to All,
    I am using the function module 'BAPI_SALESORDER_CREATEFROMDAT2' to create a sales order with quotation reference. When
    I executing the program the return table shows following issues
    1.Document 20000292 doesn't have document category but
    2.Sales document was not changed
    But , when i used to create the sales order manually( TC : VA01) with reference of '0020000292' it gives the sales order number.
    so,kindly suggest me.
    Thank you

    Hi,
       While using BAPI, you need to give some mandatory fields . So I think document catogary is missing in header structure.
    Thanks,
    Srikanth.A

  • Address number of the person who created the sales order.

    Hello Experts,
       I am currently making a report in which it has to send the output of the script as a email attachment to the person who created the sales order. For this i am using a standard include RVADOPFO but here we need to pass the address number and person number gor getting the rest of the details. So where i can find the address of the person who created the sales order. (I am able to get the name throuhg VBDKA-ERNAM, but i need address number of that person)
    Thanks & Regards,
    Uday S.

    Hi  Uday,
    check
    ADRC-NAME1 = VBAP-ERNAM
    in ADRC you will get the address of the SO created person in the field ADDRNUMBER  that you have to pass in the ADR6-ADDRNUMBER   you will get the mail address in the field ADR6-SMTP_ADDR
    hope it helps you
    Thanks!
    Edited by: Prasanth on Mar 12, 2009 3:15 PM

  • ERROR WHILE CREATING THE SALES ORDER

    Hi,
    When creating the sales order i am entering "mode of transport"in TSW details and while trying to save it im getting a message saying "Express document "update was terminated"" recieved from the author "Rahul". If i dont enter the TSW detail while creating i am able to save the order and later in change mode i can enter the mode of transport.
    When i check the inbox, it says "definately cannot transfer message to node SMTP due to connection error".
    This is hapenning for only one user.
    What could be the problem?
    Regards,
    Rahul.

    Hi Rahul,
    I think you need to enter the mode of transport in external details where it will take for further processing. TSW is different process.
    Thanks
    Pravin

  • Material Listing Error while creating the sales order

    Hi Guru's
    I have mantained a material in the lisitng for A002 combiantion for SO/DC/Pric. ref. material
    While creating the sales order is throwing an error as material is not listed so the transaction is not possible.
    I have done the basic invetingation on the folowing aspects
    1)checking the material in the listing
    2)Validity periods
    3)Material not blcoked
    4)Mateial is extened for the respective sales org
    Kindly help ASAP.
    Thanks & Regards
    Tarakaram

    Dear SAP SD 007
    I can confidently tell that an enhancement or an user exit has been applied in your scenario
    You have to check that
    Normally when creating a sales order with respect or referring billing documents the qty will be in editable mode and it is standard problem
    Your people has solved the standard problem by enhancement
    Usually OR--LF-PGI----F2 (SAY THE QTY IS 25 UNITS)
    Now you are creating returns order with reference to F2 in the return order type Re there is a standard issue that user can edit the qty to 30 from the original 25
    To solve this only your people have used userexit
    Line items and qty greyed out means definately there is some enhancement or user exit applied
    You have to check that
    Regards
    Raja

  • Error while creating the sales order with billing reference

    hi alll
    i am getting error while creating the sales order with billing reference.The line items are coming in grey.I am not able to change the items as well as the quantity field.Can u guide me
    cheers
    shalsa007........

    Dear SAP SD 007
    I can confidently tell that an enhancement or an user exit has been applied in your scenario
    You have to check that
    Normally when creating a sales order with respect or referring billing documents the qty will be in editable mode and it is standard problem
    Your people has solved the standard problem by enhancement
    Usually OR--LF-PGI----F2 (SAY THE QTY IS 25 UNITS)
    Now you are creating returns order with reference to F2 in the return order type Re there is a standard issue that user can edit the qty to 30 from the original 25
    To solve this only your people have used userexit
    Line items and qty greyed out means definately there is some enhancement or user exit applied
    You have to check that
    Regards
    Raja

  • How to put the value in Header test while creating the sales order

    Hi ,
    I am creating the Sales order using the Idoc Orders05 .
    I have to pass the value in the header text 1. the value is a transaction id which is a string value.
    If anyone has an idea how to do this using the the Orders Idoc. it would be a great help
    Thanks
    Nikhil

    If you have access to idoc before calling the processing Function module, Adding header text segments E1EDKT1 and E1EDKT2 to the idoc will create the header text.
    Regards
    Sridhar

  • How to know the sales order closed using right click menu -Close ???

    I have an sales order with ten item, I have copied the same to delivery and before adding the Delivery I have deleted some items. After adding the Delivery, I manually closed the sales order by using the "right click menu close".
    The Open Quantity of those lines are already closed while i Close it manually.
    Now i need  a report regarding the sales orders which i  have closed manually. Any Options??

    Check the below result
    DocNum     DocDate     CardCode     CardName     Row#     ItemCode     Dscription     Price     Quantity     LineTotal
    2     2012-02-04 00:00:00.000     ED-C-102     AI HUDHA BOOK STALL     2     1010          150.000000     10.000000     1500.000000
    3     2012-02-04 00:00:00.000     ED-C-103     AL AMEEN ENGLISH SCHOOL-MANKADA     2     1011     ZINC ROD HIGH GRADE PURE ZINC 140 X 9 MM     59.790000     10.000000     597.900000
    this is the result i get while i execute your query
    but look at the db result
    DocEntry     LineNum     TargetType     TrgetEntry     LineStatus     ItemCode     Quantity     OpenQty
    1     0     15     2     C     1010     10.000000     0.000000
    2     0     15     3     C     1010     10.000000     0.000000
    2     1     -1     NULL     C     1010     10.000000     0.000000
    3     0     15     4     C     1010     1.000000     0.000000
    3     1     -1     NULL     C     1011     10.000000     0.000000
    3     2     15     4     C     1012     15.000000     0.000000
    3     3     15     4     C     1013     20.000000     0.000000
    4     0     15     5     O     1010     10.000000     5.000000
    See the last line data...it have open quantity of 5 and it also have the target type 15, If I close the sales order with docentry 4 manually using right click, the open quantity will be Zero..
    I need that last line result also as my output..
    Hope you understand my problem.
    Thank You

  • Unable to create the sales team record using api AS_ACCESS_PUB.create sales

    Hi all,
    Please help with any sample code to create the sales team using AS_ACCESS_PUB.create sales team.
    When i am initialising,i am getting AS_SALES_MEMBER_PVT USing Fn error
    If i am not initialising,i am getting cannot read the value for profile option user_id;
    Regards,
    Raj

    Hi Ankitha,
    Your scenario is very vague.
    You have got the PO in the client 130 system and you wanted to created a SO in the same client 130 system.
    Usually we don't create a SO using the PO from the same system. Instead of using an IDOC concept, Call the BAPI BAPI_SALESORDER_CREATEFROMDAT1 or BAPI_SALESORDER_CREATEFROMDAT2.
    You can use any of the 2 BAPI's to create the sales order.
    Write a custom program to call the BAPI and assign that custom program as a driver program to your output type which is being triggered in the PO document, then as soon as that output type is triggered it creates the sales order for you.
    My sincere suggestion just counter check your requirement with the concerned persons as we don't generally create a sales order by referencing the po in the same system, but we create a po by referencing a so in the same system for Third party sales orders.
    Thanks,
    Mahesh.

  • Error in bappi creating the sales order

    Hi Xi team,
       i am creating a sales order via xi using the soap as sender adapter and rfc as receiving adpater. i am testing the scenatio using the altova xml spy. its writing the error as "Sales document type OR is not define".  But i could create the sale order by executing the bappi directly with the same set of records successfully. and the records are created. Please tell me wat might be the reason for the error.
    Thanks and Regards
    Karthikeyan

    Hello Karthik,
    What is BAPI you are using for creating Sales Order ?
    Try BAPI - 'BAPI_SALESORDER_CREATEFROMDAT2' to create a sales order .
    If you run into trouble using this BAPI with certain document types you can use the underlying RFC-enabled function module SD_SALESDOCUMENT_CREATE.
    Regards
    Gangaprasad

  • Error creating the sales order

    Hi,
    i am getting error saying ship to party 134 not defined for sales area when i am trying to create sales order
    help needed plzz
    thanks
    s

    Hi,
    Sales area consists of 1 sales organisation, 1 distribution channel and 1 division. If out of these 3 any one unit changes then, the sales area also changes. When you create a customer you specify the sales area for that customer. Customer has basically 4 basic partner functions-SP, SH, BP & PY.
    You are getting an error stating that the ship to party 134 not defined for sales area. First check whether your sold to party and ship to party are the same or not. If they are not same then, please check the sales area of the sold to party customer and the sales area of the ship to party customer. The sales area of both these customers should match with the sales area whcih you specify while creating the sales order.
    Also check the distribution channel of the material, the sold to party customer and the ship to party customer. The distribution channel should be the same.
    You have to assign the ship to party to the sold to party in XD02. Go to XD02, select your sold to party customer and select the sales area data. In sales area data go to 'partner functions' tab and assign the ship to party there. Enter the ship to party number.
    Reward points if solution helps.
    Regards,
    Allabaqsh G. Patil

  • To create the Sales Order based on PO IDOC.

    Hi Experts,
    The requirement is based on the generated PO IDoc, I have to create the Sales Order.
    Say Ex: Consider the Client 130. Here I have changed the PO 4500017195 by giving the Medium as EDI in the messages and saved the PO.
    As a result of that IDoc got generated at the port. Now using this IDoc I have to create the Sales Order in the same 130 client.
    Thanks in Advance.

    now read the same IDOC..configure it for inbound process code in WE20...or you can create  a report...call the created idoc using process code of SO...
    regards,
    madan

Maybe you are looking for

  • Container values not appearing in alerts - SAP CRM 7.0

    Hi Experts, I have 2 issues: 1. I am calling an alert on lead creation by calling an action with processing type as TRIGGER ALERT. The alert appears on the home page but the container values defined in the long text are not appearing. The containers

  • What are the SAP inbox tables.

    Hi Team i want to know what are the SAP inbox tables. if i have click on SAP inbox for perticular user, retrived 37000 entries and give short dump "Time Out" . i want to know from which table retrived the records and display into the SAP inbox(SBWP).

  • Procedure after Automatic Payment it run.

    Dear all, Please suggest what is the procedure after automatic payment is run. what is mostly done. Thanks Nishan

  • BAPI to do save as completed  a journal

    Hi We need a BAPI to park or save as completed a Journal.Inspecific we want to have save as completed of a Journal through BAPI.

  • Tree component. ::: Movable nodes.

    Hi guys, Can i able to move or change the node structure( folder structure ) by drag and dropping a node with in tree component (af:tree) ? or is there any other components supporting this kind of functionality ?