BAPI for sales order create

My query is
In BAPI_SALESORDER_CREATEFROMDAT2, when pricing condition types have been passed in ORDER_CONDITIONS_IN  tables, after creation of sales order, double conditions types occurred in sales order.
How to remove that duplicacy ?
Suggestion is that
1st set of condition types occurring based on config
2nd set of conditions types coming from FM.
How to ignore 1st of data?

hi
Hi,
Go through this one
*& Report ZSD_j_SALESORDER
report zsd_j_salesorder1 line-size 132 message-id zmmbapi .
*& Created By : janani
*& Created on : 13.10.2007
*& Requested By : vardhman
*& Description of program :
Internal table definition *
data: gt_order_header_in like bapisdhead occurs 0 with header line,
gt_return like bapireturn1 occurs 0 with header line, " Return Messages
gt_order_items_in like bapiitemin occurs 0 with header line, " Item Data
gt_salesdocument like bapivbeln-vbeln , "Number of Generated Document
gt_order_partners like bapiparnr occurs 0 with header line, "Document Partner
gt_return1 like bapiret2 occurs 0 with header line.
Data definition *
types: begin of ty_gt_ft_sales ,
partn_numb(10) type n ,"Customer Number 1
partn_role(2) ,"Partner function
sales_org(4) , "Sales Organization
distr_chan(2) , "Distribution Channel
division(002), "DIVISION
doc_type(4) , "Sales Document Type
purch_no(020), "Purchase order
material(18), "MATERIAL
targetquantity(020),"Target quantity
reqqty(020), "Req quantity
reqdate(010), "req date
*REQ_DATE_H(010),
ref_1(012), "Ref
unload_pt(025),
*PARTN_ROLE(2) ,"Partner function
*PARTN_NUMB(10) ,"Customer Number 1
end of ty_gt_ft_sales,
begin of ty_header ,
partn_numb(10) ,"Customer Number 1
partn_role(2) ,"Partner function
sales_org(4) , "Sales Organization
distr_chan(2) , "Distribution Channel
division(002), "DIVISION
doc_type(4) , "Sales Document Type
purch_no(020), "Purchase order
unload_pt(025),
req_date_h(010),
end of ty_header,
begin of ty_item,
material(18), "MATERIAL
targetquantity(020),"Target quantity
reqqty(020), "Req quantity
reqdate(010), "req date
ref_1(012), "Ref
*UNLOAD(025),
end of ty_item.
data : msg(240) type c, " Return Message
e_rec(8) type c, " Error Records Counter
rec_no(8) type c, " Records Number Indicator
s_rec(8) type c, " Successful Records Counter
t_rec(8) type c, " Total Records Counter
v_matnr like mara-matnr,
v_parvw type parvw.
data : gt_ft_sales type standard table of ty_gt_ft_sales with header line.
data : wa_gt_ft_sales type ty_gt_ft_sales,
wa_order_items_in like gt_order_items_in,
wa_gt_ft_sales1 type ty_gt_ft_sales,
wa_header type ty_header,
salesdocument like bapivbeln-vbeln.
selection block for EXCEL UPLOAD FILE
selection-screen begin of block b1 with frame title text-000.
parameters file type ibipparms-path obligatory.
selection-screen end of block b1.
*<<<<AT SELECTION-SCREEN ON VALUE-REQUEST FOR FILE .
at selection-screen on value-request for file .
perform getname.
form getname.
call function 'F4_FILENAME'
exporting
program_name = syst-cprog
dynpro_number = syst-dynnr
importing
file_name = file.
endform.
*TOP-OF-PAGE.
top-of-page.
skip 3.
format color col_heading inverse on.
write 40 text-001.
format color col_heading inverse off.
skip 1.
format color col_negative inverse on.
write :/ text-002, 13 sy-mandt , 104 text-003, 121 sy-uname,
/ text-004, 13 sy-datum , 104 text-005, 121 sy-uzeit.
format color col_negative inverse off.
skip 3.
*START-OF-SELECTION.
start-of-selection.
perform get_data.
perform bapi.
*end-of-page.
perform result.
form result.
t_rec = e_rec + s_rec.
skip 3.
format color col_total inverse on.
write: /38 text-007, t_rec.
format color col_total inverse off.
format color col_negative inverse on.
write: /38 text-008, e_rec.
format color col_negative inverse off.
format color col_total inverse on.
write: /38 text-009, s_rec.
format color col_total inverse off.
endform.
*& Form get_data
text
--> p1 text
<-- p2 text
form get_data .
call function 'WS_UPLOAD' "#EC *
exporting
filename = file
filetype = 'DAT'
tables
data_tab = gt_ft_sales
exceptions
conversion_error = 1
file_open_error = 2
file_read_error = 3
invalid_type = 4
no_batch = 5
unknown_error = 6
invalid_table_width = 7
gui_refuse_filetransfer = 8
customer_error = 9
no_authority = 10
others = 11.
if sy-subrc 0 .
message e000.
endif.
endform. " get_data
*& Form BAPI
form bapi .
loop at gt_ft_sales into wa_gt_ft_sales.
wa_gt_ft_sales1 = wa_gt_ft_sales.
at new partn_numb.
wa_header-doc_type = wa_gt_ft_sales1-doc_type..
wa_header-sales_org = wa_gt_ft_sales1-sales_org . "'0001'
wa_header-distr_chan = wa_gt_ft_sales1-distr_chan. "'01'
wa_header-division = wa_gt_ft_sales1-division. " '01'
wa_header-purch_no = wa_gt_ft_sales1-purch_no.
wa_header-req_date_h = wa_gt_ft_sales1-reqdate.
call function 'CONVERSION_EXIT_PARVW_INPUT'
exporting
input = wa_gt_ft_sales1-partn_role
importing
output = v_parvw.
wa_header-partn_role = v_parvw.
wa_header-partn_numb = wa_gt_ft_sales1-partn_numb.
wa_header-unload_pt = wa_gt_ft_sales1-unload_pt.
move-corresponding wa_header to gt_order_partners.
move-corresponding wa_header to gt_order_header_in.
append gt_order_header_in.
append gt_order_partners.
endat.
call function 'CONVERSION_EXIT_CCMAT_INPUT'
exporting
input = wa_gt_ft_sales1-material
importing
output = v_matnr.
gt_order_items_in-material = v_matnr .
gt_order_items_in-target_qty = wa_gt_ft_sales1-targetquantity . "'1000'
gt_order_items_in-req_qty = wa_gt_ft_sales1-reqqty.
gt_order_items_in-req_date = wa_gt_ft_sales1-reqdate.
*GT_ORDER_ITEMS_IN-BILL_DATE = wa_GT_FT_SALES1-REQDATE.
gt_order_items_in-ref_1 = wa_gt_ft_sales1-ref_1.
append gt_order_items_in.
clear : wa_gt_ft_sales1,wa_header.
at end of partn_numb.
call function 'BAPI_SALESORDER_CREATEFROMDAT1'
exporting
order_header_in = gt_order_header_in
WITHOUT_COMMIT = ' '
CONVERT_PARVW_AUART = 'X'
importing
salesdocument = salesdocument
SOLD_TO_PARTY =
SHIP_TO_PARTY =
BILLING_PARTY =
return = gt_return
tables
order_items_in = gt_order_items_in
order_partners = gt_order_partners.
ORDER_ITEMS_OUT =
ORDER_CFGS_REF =
ORDER_CFGS_INST =
ORDER_CFGS_PART_OF =
ORDER_CFGS_VALUE =
ORDER_CCARD =
ORDER_CFGS_BLOB =
ORDER_SCHEDULE_EX =
if gt_return-type eq 'E' .
e_rec = e_rec + 1.
read table gt_return with key id = 'V1'.
format color col_negative inverse on.
rec_no = e_rec + s_rec.
concatenate text-006 rec_no ':'
gt_return-message into msg separated by space .
condense msg.
write: / msg.
format color col_negative inverse off.
elseif gt_return-number = '000'.
s_rec = s_rec + 1.
format color col_positive inverse on.
msg = 'SUCCESS'.
condense msg.
write: / msg .
format color col_positive inverse off.
write :/ salesdocument, 'Has been created'.
perform commit_mm.
endif.
clear: gt_return[], msg.
endat.
endloop.
endform. " SLALE_UPLOAD_DATA
*& Form COMMIT_MM
text
--> p1 text
<-- p2 text
form commit_mm .
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'
importing
return = gt_return1.
clear: gt_order_items_inhttp://].\"GT_ORDER_CONDITIONS_IN[.
endform. " COMMIT_MM
inthis pass re_doc field in header...

Similar Messages

  • Need code for sales order create report using bapi's

    need code for sales order create report using bapi's

    Hi,
    Go through below link
    http://www.saptechies.com/bapi_salesorder_createfromdat2/
    <b>Reward points if it helps,</b>
    Satish

  • Function module which uses both BAPI's for sales order create and change

    Please name the function module which uses both BAPI's for sales order create and change.
    BAPI_SALESORDER_CREATEFORMDAT2
    BAPI_SALESORDERCHANGE

    Yup.
    you must write a piece of code for this.
    with if else condition.first check if SO is exsist than use second FM to change it else create new SO from first FM.
    logic somethig like this.
    Amit.

  • RFC/BAPI For Sales Order Credit Block Release like vkm3 (very urgent )!!

    hi experts,
    I need the RFC/BAPI For Sales Order Credit Block Release like vkm3 function ,please help
    thanks
    Godspeed

    hi
    can get the list of all the bapis..
    http://www.planetsap.com/LIST_ALL_BAPIs.htm
    Reward if USeful
    Thanx & regards.
    Naren..

  • Is there a Business Object for Sales Order Create and Change VA01 and VA02

    Hi experts -
    I am looking for a business object for Sales order create and change VA01 and VA02 respectively?
    Thanks,
    Mark

    Hi Mark,
    I think this question is best answered in [SAP Solutions|/community [original link is broken]; Forums.
    - Subhodeep
    Edited by: Subhodeep on Aug 29, 2009 11:14 AM

  • Regarding bapis for sales order creation and modification

    Hi,
    I am trying to create a syncbo for sales order creation, modification and display. The bapis that I am using are
    1.BAPI_SALESORDER_GETLIST
    2.BAPISDORDER_GETDETAILEDLIST
    3.BAPI_SALESORDER_CREATEFROMDATA1
    4. BAPI_SALESORDER_CHANGE
    Am I using the correct bapis. When I tried to create a syncbo it gave the following errors
    BAPISDORDER_GETDETAILEDLIST does not have RETURN parameter in export or tables parameter
    RETURN parameter in Create BAPI Wrapper should refer to structure BAPIRET2
    RETURN parameter in GetList BAPI Wrapper should refer to structure BAPIRET2
    GetDetail BAPI Wrapper does not have RETURN parameter in export or tables parameter
    No Export parameter referring to header structure exists in GetDetail BAPI Wrapper
    No Import parameter referring to header structure exists in Create BAPI Wrapper
    No Import parameter referring to header structure exists in Modify BAPI Wrapper
    No Import parameter referring to a field of header structure exists in GetDetail BAPI Wrapper
    No Export parameter referring to a field of header structure exists in Create BAPI Wrapper
    No Tables parameter referring to item structure exists in Create BAPI Wrapper
    No Tables parameter referring to item structure exists in Modify BAPI Wrapper
    I am informed that the above bapis are standard bapis.
    I am not sure as to why I am getting the errors.
    Does the syncbo require the  bapi's to be in a specific format.
    What would be the header and item structures for sales order bapis
    Regards
    Raja Sekhar

    Hi Raja,
      ya , for creating Sync BOs ,our BAPI wrappers must satisfy certain conditions..
    just go through this link.
    u can use the standard BAPIs of SALES Order in ur Custom BAPI Wrapper
      http://media.sdn.sap.com/public/html/submitted_docs/MI/MDK_2.5/content/appdev/smartsync/what_is_a_bapi_wrapper.html
    the RETURN must be of type BAPIRET2..
                    Regards
                    Kishor Gopinathan

  • Throw Information message for sale order created with value less that 5$

    Hi all,
            I am basically an abaper, I have got a requirement in SD. The requirement is any sales order created with value less that 5$, should be prompted with an error message saying the minimum order value should be more than 5$. Could any one help me on this.
    Thanks in advance,
    shiv

    userexit_save_document_prepare,main program - sapmv45a, issue an error message if your document value is less than 5$ (VBAK-NETWR) but check if your order has any non-rejected item, I would not issue this message if all items are rejected:
    loop at xvbap where updkz ne 'D' and abgru = ' '.
      exit.
    endloop.
    if sy-subrc = 0.  "-you have at least one non-rejected, non-deleted item.
    NOTE: sapmv45a works NOT only for orders, so please check document types in your logic which are relevant to your messge only (VBAK-VBTYP and/or VBAK-AUART).

  • BAPI for Sales Orders items

    I'm looking for BAPI, which returns all items for sales order.
    Returned items must have included all information, which we can see in transaction va02 on card Item Overview
    I'll reward with points for good BAPI.
    BR Tomek

    In the i_bapi_view structure, populate which tables you would like to have returned by using a value of X.
    Use the sales documents table to pass which documents you want information on.
    So if you wanted item details:
    i_bapi_view-item       = 'X'.
    sales_documents-vbeln = '0000012345'.
    append sales_documents.
          call function 'BAPISDORDER_GETDETAILEDLIST'
               exporting
                    i_bapi_view         = i_bapi_view
               tables
                    sales_documents     = sales_documents
                    order_items_out     = order_items_out.

  • BAPI for Sales Order Creation from Third-party Application

    Hi,
    I need to create a Sales order in a SAP system from a third-party applications. Please provide the list of BAPIs/Interfaces that are involved in creation of Sales Order.

    Hi,
    Check this link, explains step by step.
    http://abaplovers.blogspot.com/2008/02/bap-sales-order-create.html
    Thanks,
    Krishna

  • BAPI for Sales Order & Production Order

    Hi Experts,
    1)i need to Identify standard  BAPI's for Sales Order & Production Order.ie for one BAPI need both sales order and production order.
    2)i need to Identify standard BAPI to return delivery number and shipment number for a particular Sale Order. If any one give me answer thanks for advance. it's really helpful for my project.
    thanks and regards,
    bala.

    Hi Bala
    Kindly do not open duplicate threads for the same topic. Help to close one thread and continue with the other to avoid confusion.
    Kind Regards
    Eswar

  • Applying Price list for sales order created from Internal Requisition

    I am using 12.0.5. I have created a price list and applicable discount. I am creating Internal Requisitions and Importing them into Order Management as Sales Order using "Create Internal Order" and "Import Request". But when the sales orders are created, the pricing flag is "Freeze Price" and to apply the price list, I have to change the pricing flag of each line and re-price order/ line. Is this a way around this such that Sales orders created from Internal Requisitions pick up the correct discounted selling pricing automatically after import?

    Hi Ravichandran,
    When the Internal Sales Orders are created via Order Import program, the pricing flag will be "Freeze Price" because the value of CALCULATE_PRICE_FLAG will be set to 'N' in the OE interface line table by the Create Internal Orders program. This is the standard functionality of the Oracle.
    However, if your requirement is to re-price the line (automatic application of discounts at the time of booking) after the SO is created then to avoid the manual repricing steps, you can write a custom program to update the CALCULATE_PRICE_FLAG to 'Y' for the OE Line records present in the interface tables itself. You need to make sure that this update happens before the Order Import program. You can create a Request Set to acheive this, for example...
    XXX Create Internal Orders (Custom Request Set)
    - Create Internal Order (Standard Oracle Program)
    - XXX Update PriceFlag for ISO (Custom Program to update the price flag)
    First run the above request set & then run standard Order Import program. So when SO is being booked, CALCULATE_PRICE_FLAG will be 'Y' i.e., Calculate Price, the required discounts will be pulled & the line will be re-priced automatically.
    I hope this is what you wanted to achieve. Let me know if you have any questions.
    Regards,
    Hemanth

  • How to maintain serial no for sales order created by BAPI

    Hi all,
    We are using BAPI for creating sales order "BAP_SALESORDERDAT2" but we are not able to assign Serial number while using this BAPI. Is there any function modul, BAPI, or workarround available to solve this problem. Or how to maintain Serial number.
    Regards
    Shambhu Sarkar

    Hi
    It is not possible to to maintain serial numbers with the normal SD
    BAPIS. This functionality is not scope of the BAPIS.
    regards,
    Ramana

  • BAPI FOR SALES ORDER PROBELM IN PRICING VALUE

    Respected Members
    i have a problem in creating sales order through BAPI
    i will explain you.
    My flat file structure is
    doc_type sales_org dis_Ch division part_num pono itm_num material short_text qty plant price
    OR 1000 20 10 1000 123 10 100-100 abc 50 1000 500
    OR 1000 20 10 1000 254 10 100-200 XYZ 70 1000 800
    Now when i am executing my program with this flat file data , everything is coming but problem is that in second sales order which is getting create is also having the quantity and price value of the first sales order ie 50 and 500 and it is not taking quantity as 70 and price as 800.
    Rest everything is getting changed .
    For eg Material is getting changed and description is getting changed for second po.
    for second sales order it is taking material 100-200 and description XYZ only.
    Then why it is taking values for quantity and price same as first sales order.
    i m using the bapi function module in the loop only and thats why two sales order are getting generated.
    also at the debugging when the values are passed to BAPI function module it is passing the correct values ie 70 and 800 but finally when i am going to tcode VA02 and seeing the sales order then it is showing the values of the previous order.
    Please give me the solution as soon as possible.
    Thanks

    Hello Manish,
    If you are calling the BAPI within a loop, try to put the BAPI_TRANSACTION_COMMIT within the loop as well so every order is commited properly before the next one is created.
    Hope that solves your problem.
    Michael

  • BAPI for sales order creation with Reference

    Hello Experts,
    I have a order, with its reference I have to create a new sales order.
    Am looking for BAPi, with which I can create a sales order with a Reference order (which is in my hand), so I checked SE37 with wild cards, but I did not find any!!
    1) Pls. let me know a BAPI
    2) And just like that I do not want to create a new order with the reference(existing) order, I have to change the PO number & order Reason(2 fileds) in newley creationg order, pls. let me know How to do it
    Thank you

    Hi,
    First try to pass these two parameters to BAPI_SALESORDER_CREATEFROMDAT2
    ORDER_HEADER_IN-REFDOCTYPE = Your Sch. Agreement No. (Please Check) and
    ORDER_HEADER_IN-SD_DOC_CAT = 'E'.
    If the above doesnt work ,than try using BAPI "BAPI_SALESDOCUMENT_COPY"
    I hope you are working in SAP R/3 4.6C and above version because i am not sure whether this BAPI is available in lower version.
    Let us know if this helps you..
    Rgds,
    Mayank

  • Bapi for sales order

    hi all ,
    could any one give me the step by step procedure how to creat a sales order using bapi.  i found BAPI_SALESORDER_CREATEFROMDAT2 this the bapi ... but iam not sure about the passing the parameters. please it would be help ful.
    the fields which i have to upload are
    order type - or
    organisational data -1000 ,10  ,00.
    sold to party - 1000
    purchase oder number- 10
    purchase order date - 31 03 2005
    required dlivery date- 5 4 07
    material - p-103
    quantity 10
    regards
    reena

    Hi,
    Please check the code below:
    DATA ok_code LIKE sy-ucomm.
      DATA:
    Order partners
    li_order_partners TYPE STANDARD TABLE OF bapiparnr,
    l_order_partners LIKE bapiparnr,
    Structures for order header
      l_order_header_in LIKE bapisdhd1,
      l_order_header_inx LIKE bapisdhd1x,
    Tables for order items
      li_order_items_in TYPE STANDARD TABLE OF bapisditm,
      l_order_items_in LIKE bapisditm,
      li_order_items_inx TYPE STANDARD TABLE OF bapisditmx,
      l_order_items_inx LIKE bapisditmx,
    Return table from bapi call
      li_return TYPE STANDARD TABLE OF bapiret2,
      l_return TYPE bapiret2,
    Sales document number
    l_vbeln LIKE bapivbeln-vbeln,
    Error flag
      l_errflag(1) TYPE c.
      DATA: BEGIN OF lt_itab OCCURS 0,
                           vbeln(10),
                           augru(3),
                           bstkd(10),
                           ean11(18),
           END OF lt_itab.
    START-OF-SELECTION.
      CALL SCREEN 100.
    Build partner information
      CLEAR l_order_partners.
      l_order_partners-partn_role = 'AG'. "Remember German codes !
      l_order_partners-partn_numb = itab-st.
      APPEND l_order_partners TO li_order_partners.
    Build order header
    Update flag
      l_order_header_inx-updateflag = 'I'.
    Sales document type
      l_order_header_in-doc_type = 'YR30'.
      l_order_header_inx-doc_type = 'X'.
    customer reference
      l_order_header_in-ord_reason = lt_itab-augru.
      l_order_header_inx-ord_reason = 'X'.
    Distribution channel
      l_order_header_in-refdoctype = lt_itab-vbeln.
      l_order_header_inx-doc_type = 'X'.
    Purchase order
      l_order_header_in-purch_no_c = lt_itab-bstkd.
      l_order_header_inx-purch_no_c = 'X'.
    Build order item(s) - Only 1 is used in this example
      l_order_items_in-ean_upc = lt_itab-ean11.
      l_order_items_inx-ean_upc = lt_itab-ean11.
      l_order_items_in-material = itab-matnr.
      l_order_items_inx-material = 'X'.
      l_order_items_in-comp_quant = itab-qty.
      l_order_items_inx-comp_quant = 'X'.
      APPEND l_order_items_in TO li_order_items_in.
      l_order_items_inx-updateflag = 'I'.
      APPEND l_order_items_inx TO li_order_items_inx.
    CALL Bapi
    MODULE user_command_0100 INPUT.
      CASE sy-ucomm.
        WHEN 'CREATE'.
      CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
        EXPORTING
          order_header_in  = l_order_header_in
          order_header_inx = l_order_header_inx
          testrun          = 'X'
            IMPORTING
              salesdocument    = l_vbeln
        TABLES
          return           = li_return
          order_items_in   = li_order_items_in
          order_items_inx  = li_order_items_inx.
              order_partners   = li_order_partners.
      PERFORM error.
       WHEN 'EXIT'.
         LEAVE PROGRAM.
    ENDCASE.
    *ENDMODULE. " USER_COMMAND_0100 INPUT
    ENDFORM.                    " call_bapi
    Check and write Return table
    FORM error.
      DATA: l_errflag(1) TYPE c,
    Return table from bapi call
      li_return TYPE STANDARD TABLE OF bapiret2,
      l_return TYPE bapiret2.
      LEAVE TO LIST-PROCESSING.
      CLEAR l_errflag.
    WRITE: / 'Sales dcoument: ', l_vbeln.
      LOOP AT li_return INTO l_return.
        WRITE: / l_return-type, l_return-message(50).
        IF l_return-type = 'E'.
          l_errflag = 'X'.
        ENDIF.
      ENDLOOP.
      PERFORM commit.
    ENDFORM. " ERROR INPUT
    No errors - Commit
    FORM commit.
      DATA: l_errflag(1) TYPE c.
      IF l_errflag IS INITIAL.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
      ENDIF.
    ENDFORM. " COMMIT INPUT
    Regards
    Kannaiah

Maybe you are looking for

  • Which one is the best way to collect config and performance details in azure

    Hi , I want to collect the information of both configuration and performance of cloud, virtual machine and web role .I am going to collect all these details using java.  so Please suggest which one is the best way.  1) REST API 2) Azure SDK for java

  • Cannot connect itunes store

    New iphone 5, but I cannot get any apps.  Error message comes up "Cannot connect to itunes store"  I tried switching the date as mentioned in previous post. Does anyone have a suggestion?  Thanks...

  • Illustrator CS6 mac fail at save large file

    hi there~ I'm using macbook pro 9,2 and with os 10.8. I've just got my illustrator cs6. I have a piece of work about 11mb and everytime I save the work the app is no response and I have to force quit it. I tried for appro. 20 times and everytime is t

  • WL 10.3 Commons LogFactory NoClassDefFoundError, Hibernate

    I keep getting this error when I try to deploy on weblogic 10.3. I'm trying to initialize hibernate through spring. We are using split-directory structure for development. Code: java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory at

  • Take action before destory

    Hello, I am so confused with my current problem. Actually, I need to tackle some attributes in session just before destory. However, using HttpSessionListener is not OK, as its destory action is called after destory. Choosing HttpSessionAttributeList