Skip to Content
author's profile photo Former Member
Former Member

hi sap gurus...

hi,

how to create a sales order bapi and how to test it?also pls tell me the appropiate transaction code.reply asap.

regards

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jun 16, 2008 at 03:29 PM

    Hi,

    Example Code

    U need to give the step_nr, item_nr, cond_count and cond_type so the correct conditon will be updated. If no condition exists for the given parameters, a new condition will be created.

    U can find these parameters for a particular condition type in table KONV.

    &----


    *& Form saveTransactionJOCR

    &----


    text

    ________________________________________

    --> p1 text

    <-- p2 text

    ________________________________________

    FORM saveTransactionJOCR .

    data: salesdocument like BAPIVBELN-VBELN,

    order_header_inx like bapisdh1x,

    order_header_in like bapisdh1,

    return type standard table of bapiret2 with header line,

    conditions_in type standard table of bapicond with header line,

    conditions_inx type standard table of bapicondx with header line,

    logic_switch like BAPISDLS,

    step_nr like conditions_in-cond_st_no,

    item_nr like conditions_in-itm_number,

    cond_count like conditions_in-cond_count,

    cond_type like conditions_in-cond_type.

    salesdocument = wa_order_information-VBELN.

    LOGIC_SWITCH-COND_HANDL = 'X'.

    order_header_inx-updateflag = 'U'.

    conditions

    clear conditions_in[].

    clear conditions_inx[].

    clear: step_nr,

    item_nr,

    cond_count,

    cond_type.

    step_nr = '710'.

    item_nr = '000000'.

    cond_count = '01'.

    cond_type = 'ZCP2'.

    CONDITIONS_IN-ITM_NUMBER = item_nr.

    conditions_in-cond_st_no = step_nr.

    CONDITIONS_IN-COND_COUNT = cond_count.

    CONDITIONS_IN-COND_TYPE = cond_type.

    CONDITIONS_IN-COND_VALUE = 666.

    CONDITIONS_IN-CURRENCY = 'EUR'.

    append conditions_in.

    CONDITIONS_INX-ITM_NUMBER = item_nr.

    conditions_inx-cond_st_no = step_nr.

    CONDITIONS_INX-COND_COUNT = cond_count.

    CONDITIONS_INX-COND_TYPE = cond_type.

    CONDITIONS_INX-UPDATEFLAG = 'U'.

    CONDITIONS_INX-COND_VALUE = 'X'.

    CONDITIONS_INX-CURRENCY = 'X'.

    append conditions_inx.

    CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

    EXPORTING

    SALESDOCUMENT = salesdocument

    ORDER_HEADER_IN = order_header_in

    ORDER_HEADER_INX = order_header_inx

    LOGIC_SWITCH = logic_switch

    TABLES

    RETURN = return

    CONDITIONS_IN = conditions_in

    CONDITIONS_INX = conditions_inx

    .

    if return-type ne 'E'.

    commit work and wait.

    endif.

    ENDFORM. " saveTransactionJOCR

    Bdc to Bapi

    The steps to be followed are :

    1. Find out the relevant BAPI (BAPI_SALESORDER_CHANGE for VA02).

    for VA01 use BAPI_SALESORDER_CREATEFROMDAT2

    2. Create a Z program and call the BAPi (same as a Funtion module call).

    2. Now, if you see this BAPi, it has

    -> Importing structures.

    eg: SALESDOCUMENT: this will take the Sales order header data as input.

    -> Tables parameters:

    eg: ORDER_ITEM_IN: this will take the line item data as input.

    Note :

    Only specify fields that should be changed

    Select these fields by entering an X in the checkboxes

    Enter a U in the UPDATEFLAG field

    Always specify key fields when changing the data, including in the checkboxes

    The configuration is an exception here. If this needs to be changed, you need to complete it again fully.

    Maintain quantities and dates in the schedule line data

    Possible UPDATEFLAGS:

    U = change

    D = delete

    I = add

    Example

    1. Delete the whole order

    2. Delete order items

    3. Change the order

    4. Change the configuration

    Notes

    1. Minimum entry:

    You must enter the order number in the SALESDOCUMENT structure.

    You must always enter key fields for changes.

    You must always specify the update indicator in the ORDER_HEADER_INX.

    2. Commit control:

    The BAPI does not run a database Commit, which means that the application must trigger the Commit so that the changes are read to the database. To do this, use the BAPI_TRANSACTION_COMMIT BAPI.

    For further details... refer to the Function Module documentation for the BAPi.

    Thanks

    Sarada

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 16, 2008 at 03:30 PM

    Hi,

    open transaction BAPI and select - sales and distribution

    open Se37 and type: BAPIsalesord*

    do you want to create if so then:

    BAPI_SALESORDER_CREATEFROMDAT1

    reward if useful

    regards

    saipriya

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 16, 2008 at 03:30 PM
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 16, 2008 at 03:31 PM

    Hi,

    Try this:

    &----


    *& Report ZBAPINQTEST *

    *& *

    &----


    *& *

    *& *

    &----


    REPORT ZBAPINQTEST.

    data WA_HEADER like BAPISDHEAD occurs 0 with header line.

    data:wa_item_in like BAPIITEMIN occurs 0 with header line.

    data:ZDATUM like BAPIITEMIN-BILL_DATE.

    data:ZITMDATE like BAPIITEMIN-BILL_DATE.

    data:WA_PARTNERS like BAPIPARTNR occurs 0 with header line.

    data: ZSALESDOCUMENT like BAPIVBELN-VBELN,

    ZSOLD_TO_PARTY like BAPISOLDTO,

    ZSHIP_TO_PARTY like BAPISHIPTO,

    ZBILLING_PARTY like BAPIPAYER.

    data:ZRETURN like BAPIRETURN1.

    data:ZORDER_ITEMS_OUT like BAPIITEMEX occurs 0 with header line.

    data:ORDER_CFGS_REF like BAPICUCFG occurs 0 with header line.

    data:ORDER_CFGS_INST like BAPICUINS occurs 0 with header line.

    data:ORDER_CFGS_PART_OF like BAPICUPRT occurs 0 with header line.

    data:ORDER_CFGS_VALUE like BAPICUVAL occurs 0 with header line.

    DATA:S_MESS TYPE STRING.

    ZDATUM = '20071212'."SY-DATUM.

    ZITMDATE = ZDATUM.

    *-HEADER-

    WA_HEADER-DOC_TYPE = 'ZIR'.

    WA_HEADER-SALES_ORG = '3000'.

    WA_HEADER-DISTR_CHAN = '40'.

    WA_HEADER-DIVISION = '10'.

    WA_HEADER-REQ_DATE_H = ZDATUM.

    WA_HEADER-PURCH_DATE = ZDATUM.

    WA_HEADER-PRICE_DATE = ZDATUM.

    WA_HEADER-CT_VALID_F = '20071212'.

    WA_HEADER-CT_VALID_T = '20071226'.

    *append WA_HEADER.

    *clear WA_HEADER.

    *-ITEMS

    wa_item_in-ITM_NUMBER = 1.

    WA_ITEM_IN-PO_ITM_NO = 1.

    WA_ITEM_IN-MATERIAL = 'APACK_SL_V2'.

    WA_ITEM_IN-BILL_DATE = ZITMDATE.

    WA_ITEM_IN-PLANT = '0010'.

    WA_ITEM_IN-TARGET_QTY = 3.

    WA_ITEM_IN-TARGET_QU = 'EA'.

    WA_ITEM_IN-REQ_QTY = 3000.

    WA_ITEM_IN-SALES_UNIT = 'EA'.

    WA_ITEM_IN-ITEM_CATEG = 'AFC'.

    WA_ITEM_IN-REQ_DATE = ZITMDATE.

    WA_ITEM_IN-COND_TYPE = 'ZE01'.

    WA_ITEM_IN-COND_VALUE = '235.67'.

    WA_ITEM_IN-PURCH_DATE = ZITMDATE.

    WA_ITEM_IN-PURCH_NO_S = 'D1200001'.

    WA_ITEM_IN-SHORT_TEXT = 'this is a test'.

    APPEND WA_ITEM_IN.

    CLEAR WA_ITEM_IN.

    wa_item_in-ITM_NUMBER = 2.

    WA_ITEM_IN-HG_LV_ITEM = 1.

    WA_ITEM_IN-PO_ITM_NO = 2.

    WA_ITEM_IN-MATERIAL = 'SL-CARP-SHOP'.

    WA_ITEM_IN-BILL_DATE = ZITMDATE.

    WA_ITEM_IN-PLANT = '0010'.

    WA_ITEM_IN-TARGET_QTY = 3.

    WA_ITEM_IN-TARGET_QU = 'EA'.

    WA_ITEM_IN-REQ_QTY = 3000.

    WA_ITEM_IN-SALES_UNIT = 'EA'.

    WA_ITEM_IN-ITEM_CATEG = 'ZZFC'.

    WA_ITEM_IN-REQ_DATE = ZITMDATE.

    WA_ITEM_IN-COND_TYPE = 'ZE01'.

    WA_ITEM_IN-COND_VALUE = '500.00'.

    WA_ITEM_IN-PURCH_DATE = ZITMDATE.

    WA_ITEM_IN-PURCH_NO_S = 'D1200001'.

    APPEND WA_ITEM_IN.

    order_cfgs_ref-posex = '000001'.

    order_cfgs_ref-config_id = '000001'.

    order_cfgs_ref-root_id = '000001'.

    APPEND order_cfgs_ref.

    order_cfgs_value-config_id = '000002'.

    order_cfgs_value-inst_id = '000002'.

    order_cfgs_value-charc = 'SL-CARP-SHOP'.

    order_cfgs_value-value = 'A'.

    APPEND order_cfgs_value.

    order_cfgs_value-config_id = '000001'.

    order_cfgs_value-inst_id = '000001'.

    order_cfgs_value-charc = 'M10142_A_SIZE'.

    order_cfgs_value-value = '43-23-135'.

    APPEND order_cfgs_value.

    *Table KNVP

    WA_PARTNERS-PARTN_ROLE = 'WE'.

    WA_PARTNERS-PARTN_NUMB = '0000000007'.

    APPEND WA_PARTNERS.

    *******

    CALL FUNCTION 'CUXC_INIT'.

    CALL FUNCTION 'BAPI_INQUIRY_CREATEFROMDATA'

    EXPORTING

    ORDER_HEADER_IN = WA_HEADER

    IMPORTING

    SALESDOCUMENT = ZSALESDOCUMENT

    SOLD_TO_PARTY = ZSOLD_TO_PARTY

    SHIP_TO_PARTY = ZSHIP_TO_PARTY

    BILLING_PARTY = ZBILLING_PARTY

    RETURN = ZRETURN

    TABLES

    ORDER_ITEMS_IN = WA_ITEM_IN

    ORDER_PARTNERS = WA_PARTNERS

    ORDER_ITEMS_OUT = ZORDER_ITEMS_OUT

    ORDER_CFGS_REF = ORDER_CFGS_REF

    ORDER_CFGS_INST = ORDER_CFGS_INST

    ORDER_CFGS_PART_OF = ORDER_CFGS_PART_OF

    ORDER_CFGS_VALUE = ORDER_CFGS_VALUE

    EXCEPTIONS

    OTHERS = 1.

    CONCATENATE ZSALESDOCUMENT ' CREATED' INTO S_MESS .

    if Zreturn is initial.

    MESSAGE S_MESS TYPE 'S'.

    else.

    message Zreturn-MESSAGE type 'S'.

    endif.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 16, 2008 at 03:35 PM

    Hi Preethi,

    Please check below link.

    http://www.sap-img.com/abap/bapi-conventions.htm

    Regards,

    Anil

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.