BAPI Sales order create - Ship to party Error
Dear All,
I have an issue with BAPI_SALESDOCU_CREATEFROMDATA1.
I need different ship to party's on the items , irresspective of the header ship to party. Currently the order is getting created with the same ship to party for all the items , same as the header ship to party. Please refer the code below and help.
Sales document type
IF zdemmast-doc_type = 'X'.
header-doc_type = 'ZDMM'.
ELSEIF zdemmast-doc_type = 'ZDME'.
headerx-doc_type = 'X'.
ENDIF.
Sales organization
header-sales_org = '1000'.
headerx-sales_org = 'X'.
Distribution channel
header-distr_chan = '10'.
headerx-distr_chan = 'X'.
Division
header-division = '10'.
headerx-division = 'X'.
headerx-updateflag = 'I'.
Sold to
partner-partn_role = 'AG'.
partner-partn_numb = zdemmast-kunnr.
APPEND partner.
Ship to
partner-partn_role = 'WE'.
partner-partn_numb = zdemmast-kunnr.
APPEND partner.
LOOP AT it_zdem_item INTO wa_zdem_item.
itemx-updateflag = 'I'.
item-itm_number = wrk_item_number.
itemx-itm_number = 'X'.
item-material = '000000000000000016'. "wa_zdem_item-matnr.
itemx-material = 'X'.
item-plant = '1000'.
itemx-plant = 'X'.
item-target_qty = wa_zdem_item-cret.
itemx-target_qty = 'X'.
lt_schedules_in-itm_number = wrk_item_number.
lt_schedules_in-sched_line = '0001'.
lt_schedules_in-req_qty = wa_zdem_item-cret.
lt_schedules_inx-itm_number = wrk_item_number.
lt_schedules_inx-sched_line = '0001'.
lt_schedules_inx-updateflag = 'X'.
lt_schedules_inx-req_qty = 'X'.
partner-partn_role = 'WE'.
partner-partn_numb = wa_zdem_item-kunnr.
partner-itm_number = wrk_item_number.
APPEND item.
APPEND itemx.
APPEND lt_schedules_in.
APPEND lt_schedules_inx.
APPEND partner.
wrk_item_number = wrk_item_number + 10.
ENDLOOP.
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.
Please suggest.
Thanks in advance
Hi,
try the following:
Fill tables parameter SALES_PARTNERS (BAPIPARTNR).
For header don't fill field ITM_NUMBER.
For position fill field ITM_NUMBER.
For example (BAPIPARTNR):
SP | 0000010000 | 000000 | ...
SP | 0000009034 | 000001 | ...
At header the ship to will be "10000" and at item 1 it will be "9034".
Regards
Similar Messages
-
List of Sales Orders wrt SHIP TO PARTY through T Code VA05.
Hi Experts,
Please let me know how can we extract list of Sales Orders wrt SHIP TO PARTY through T Code VA05. We can select Ship to Party option through Partner function tab in selection screen, but while executing transaction, we get list for SOLD TO PARTY.
Please advise.
Thanks,
Abhishek AgrawalHi,
In the VA05 report selection screen, you have the option of selecting the relevant partner function that needs to be considered. Click on the "Partner Function" button and change it to "SH"
Then given the ship to party number you want to analyze and execute the report.
In the report output screen, you will see the Ship-to Party in the header.
In the detail level, you see the sold to party numbers. Since the report can be executed for one ship to or sold to at once, there is no requirement to see the ship to party in the line level.
If you double click on the line, you can go to the sales order and verify your sold to and ship to details.
Best regards,
Anupa -
BAPI Sales order create with reference
Hi
I need to use BAPI to create sales order with reference to Quantity Contract. The line item material quantity would be less than or equal to quantity contract quantity.
Sales order needs to be created with new quantity.
Quantity contract quantity change needs to be maintained.
Document flow needs to be maintained.
Is any one aware if this is possible using BAPI_SALESORDER_CREATEFROMDAT2. If yes, how?
Any insights would be highly appreciated.Hi Maninder,
The BAPI does not allow the Pricing Conditions to be sourced from the Contract. I debugged the BAPI and it uses a piece of code (don't recall which subroutine though) from SAPMV45A which is relevant for dialog processing where it reads from the VBAP and *VBAP structures. Well this structure is only populated when you are using the Front End transaction (VA41, VA42, etc). Because this structure is empty, pricing conditions do not flow across.
Here is a little prototype program I whipped up to test my method of creating a Sales order and then changing the Sales Order:
REPORT ypat_salesorder_create LINE-SIZE 256.
* This program will create a ZOC Sales Order with Reference to Contract
* 20000720 / 10. This will be done via BAPI. There are 2 BAPi calls,
* BAPI_SALESORDER_CREATEFROMDAT2 and BAPI_SALESORDER_CHANGE. We need to
* perform 2 BAPI calls as the BAPI to create the Sales Order does not
* bring across the Pricing Conditions properly. To get around this we
* create the Order with reference to the Contract, then we get the
* related Pricing Conditions from the COntract and then update the newly
* created Order.
* Constants
CONSTANTS: c_contract LIKE vbak-vbeln VALUE '0020000720',
c_item LIKE vbap-posnr VALUE '000010'.
* Structures
* Structure to hold BAPI Header
DATA: st_bapisdhd1 LIKE bapisdhd1.
* Internal Tables
* Sales Order Create BAPI Return Messages
DATA: tbl_return TYPE STANDARD TABLE OF bapiret2
WITH HEADER LINE.
* Sales Order BAPI Line Item
DATA: tbl_bapisditm TYPE STANDARD TABLE OF bapisditm
WITH HEADER LINE.
* Sales Order BAPI Line Item
DATA: tbl_bapisditmx TYPE STANDARD TABLE OF bapisditmx
WITH HEADER LINE.
* Sales Order BAPI Pricing Conditions
DATA: tbl_bapicond TYPE STANDARD TABLE OF bapicond
WITH HEADER LINE.
* Sales Order BAPI Partner Functions
DATA: tbl_bapiparnr TYPE STANDARD TABLE OF bapiparnr
WITH HEADER LINE.
* Sales Order BAPI Schedule Lines
DATA: tbl_bapischdl TYPE STANDARD TABLE OF bapischdl
WITH HEADER LINE.
* Sales Order BAPI Schedule Lines
DATA: tbl_bapischdlx TYPE STANDARD TABLE OF bapischdlx
WITH HEADER LINE.
* Sales Order BAPI Pricing Conditions
DATA: tbl_bapicondx TYPE STANDARD TABLE OF bapicondx
WITH HEADER LINE.
* Customer Enhancement for VBAK, VBAP, VBEP
DATA: tbl_bapiparex TYPE STANDARD TABLE OF bapiparex
WITH HEADER LINE.
* Table to hold BAPI Detail Conditions
DATA: tbl_bapisdcond TYPE STANDARD TABLE OF bapisdcond
WITH HEADER LINE.
* Table to hold Return Messages from Sales Order Change BAPI
DATA: tbl_return_chg TYPE STANDARD TABLE OF bapiret2
WITH HEADER LINE.
* Variables
DATA: g_vbeln_created LIKE vbak-vbeln,
g_valid_contract TYPE c,
g_cont_price_date TYPE d.
* Start of Selection
START-OF-SELECTION.
PERFORM validate_contract.
PERFORM create_sales_ord.
PERFORM update_sales_ord.
* End of Selection
END-OF-SELECTION.
PERFORM write_output_report.
* Subroutines
*& Form create_sales_ord
* Create the Sales Order
FORM create_sales_ord .
PERFORM populate_bapi_tables.
PERFORM call_create_sales_ord_bapi.
ENDFORM. " create_sales_ord
*& Form populate_bapi_tables
* Fill up the BAPI Tables
FORM populate_bapi_tables .
PERFORM populate_bapi_header.
PERFORM build_bapi_partners.
PERFORM build_bapi_items.
PERFORM build_bapi_sched_lines.
ENDFORM. " populate_bapi_tables
*& Form populate_bapi_header
* Build BAPI Header Details
FORM populate_bapi_header .
CLEAR st_bapisdhd1.
st_bapisdhd1-doc_type = 'ZOC'. "Order type
st_bapisdhd1-sales_org = '026'. "Sales Org
st_bapisdhd1-distr_chan = '00'. "Dist Channel
st_bapisdhd1-division = '00'. "Division
st_bapisdhd1-purch_no_c = 'Cust Po No'. "Cust PO No
st_bapisdhd1-name = 'Orderer'. "Name of Orderer
st_bapisdhd1-ord_reason = ''. "Order Reason
st_bapisdhd1-sales_off = '3001'. "Sales Office
st_bapisdhd1-sales_grp = '301'. "Market Area
IF g_valid_contract = 'X'.
st_bapisdhd1-price_date = g_cont_price_date.
ENDIF.
ENDFORM. " populate_bapi_header
*& Form build_bapi_partners
* Build BAPI Partner Functions
FORM build_bapi_partners .
CLEAR tbl_bapiparnr.
tbl_bapiparnr-partn_role = 'AG'.
tbl_bapiparnr-partn_numb = '0000100750'.
APPEND tbl_bapiparnr.
CLEAR tbl_bapiparnr.
tbl_bapiparnr-partn_role = 'WE'.
tbl_bapiparnr-partn_numb = '0000504472'.
APPEND tbl_bapiparnr.
ENDFORM. " build_bapi_partners
*& Form build_bapi_items
* Build The BAPI Line Items
FORM build_bapi_items .
DATA: l_matnr LIKE mara-matnr.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = '10000072'
IMPORTING
output = l_matnr.
CLEAR tbl_bapisditm.
tbl_bapisditm-itm_number = c_item.
IF g_valid_contract = 'X'.
tbl_bapisditm-ref_doc = c_contract.
tbl_bapisditm-ref_doc_it = c_item.
tbl_bapisditm-ref_doc_ca = 'G'. "Contract
ENDIF.
tbl_bapisditm-material = l_matnr.
tbl_bapisditm-plant = '3012'.
tbl_bapisditm-target_qty = '5.000'.
tbl_bapisditm-target_qu = 'M3'.
tbl_bapisditm-item_categ = 'ZZOC'.
tbl_bapisditm-sales_dist = '301'.
tbl_bapisditm-dlv_prio = '02'.
tbl_bapisditm-prc_group5 = '080'.
tbl_bapisditm-cust_mat35 = 'kdmat'.
tbl_bapisditm-route = 'TESYS'.
tbl_bapisditm-usage_ind = 'CIV'.
APPEND tbl_bapisditm.
CLEAR tbl_bapisditmx.
tbl_bapisditmx-itm_number = c_item.
tbl_bapisditmx-ref_doc = 'X'.
tbl_bapisditmx-ref_doc_it = 'X'.
tbl_bapisditmx-ref_doc_ca = 'X'.
tbl_bapisditmx-material = 'X'.
tbl_bapisditmx-updateflag = 'I'.
tbl_bapisditmx-plant = 'X'.
tbl_bapisditmx-target_qty = 'X'.
tbl_bapisditmx-target_qu = 'X'.
tbl_bapisditmx-item_categ = 'X'.
tbl_bapisditmx-sales_dist = 'X'.
tbl_bapisditmx-dlv_prio = 'X'.
tbl_bapisditmx-prc_group5 = 'X'.
tbl_bapisditmx-cust_mat35 = 'X'.
tbl_bapisditmx-usage_ind = 'X'.
tbl_bapisditmx-route = 'X'.
APPEND tbl_bapisditmx.
ENDFORM. " build_bapi_items
*& Form build_bapi_sched_lines
* Build the BAPI Schedule Lines
FORM build_bapi_sched_lines .
CLEAR tbl_bapischdl.
tbl_bapischdl-itm_number = c_item.
tbl_bapischdl-req_qty = '1'.
tbl_bapischdl-req_date = sy-datum.
APPEND tbl_bapischdl.
ENDFORM. " build_bapi_sched_lines
*& Form build_bapi_conditions
* Pull the BAPI Pricing Conditions from the Contract
FORM build_bapi_conditions .
LOOP AT tbl_bapisdcond.
CLEAR tbl_bapicond.
MOVE-CORRESPONDING tbl_bapisdcond TO tbl_bapicond.
APPEND tbl_bapicond.
CLEAR tbl_bapicondx.
tbl_bapicondx-itm_number = tbl_bapicond-itm_number.
tbl_bapicondx-cond_st_no = tbl_bapicond-cond_st_no.
tbl_bapicondx-cond_count = tbl_bapicond-cond_count.
tbl_bapicondx-cond_type = tbl_bapicond-cond_type.
tbl_bapicondx-updateflag = 'I'.
tbl_bapicondx-cond_value = 'X'.
tbl_bapicondx-currency = 'X'.
tbl_bapicondx-cond_unit = 'X'.
tbl_bapicondx-cond_p_unt = 'X'.
tbl_bapicondx-varcond = tbl_bapicond-varcond.
APPEND tbl_bapicondx.
ENDLOOP.
ENDFORM. " build_bapi_conditions
*& Form call_create_sales_ord_bapi
* Call the Sales Order Create BAPI
FORM call_create_sales_ord_bapi .
CLEAR g_vbeln_created.
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
order_header_in = st_bapisdhd1
IMPORTING
salesdocument = g_vbeln_created
TABLES
return = tbl_return
order_items_in = tbl_bapisditm
order_items_inx = tbl_bapisditmx
order_partners = tbl_bapiparnr
order_schedules_in = tbl_bapischdl.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDFORM. " call_create_sales_ord_bapi
*& Form update_sales_ord
* Update the newly created Sales Order with the Pricing Conditions
* from the Contract
FORM update_sales_ord .
CHECK g_valid_contract EQ 'X'.
PERFORM get_contract_details.
PERFORM build_bapi_conditions.
PERFORM call_change_sales_ord_bapi.
ENDFORM. " update_sales_ord
*& Form get_contract_details
* Get Contract Details
FORM get_contract_details .
* Need to manually get the relevant Pricing Conditions as the BAPI
* BAPISDORDER_GETDETAILEDLIST causes problems when we call the BAPI
* BAPI_SALESORDER_CREATEFROMDAT2 and BAPI_SALESORDER_CHANGE (I think
* this is due to the fact that these BAPIs belong to the same Function
* Group and there must be some common structures that are not cleared
* causing us all sorts of grief when we try and call the next BAPI)
DATA: tbl_konv TYPE STANDARD TABLE OF konv WITH HEADER LINE.
DATA: tbl_komv TYPE STANDARD TABLE OF komv WITH HEADER LINE.
DATA: tbl_vbak TYPE STANDARD TABLE OF vbak WITH HEADER LINE.
* Pricing Condition Master
DATA: BEGIN OF tbl_t685a OCCURS 0,
kschl LIKE t685a-kschl,
kaend_wrt LIKE t685a-kaend_wrt,
END OF tbl_t685a.
SELECT *
INTO TABLE tbl_vbak
FROM vbak
WHERE vbeln = c_contract.
READ TABLE tbl_vbak INDEX 1.
SELECT *
INTO TABLE tbl_konv
FROM konv
WHERE knumv = tbl_vbak-knumv AND
kposn = c_item.
CHECK sy-subrc EQ 0.
* We now need to make sure we only bring across the Condition Types that
* are EDITABLE. If we bring across non editable conditions (such as
* 'ZPR1') the Change Sales Order BAPI will fail
SELECT kschl kaend_wrt
INTO TABLE tbl_t685a
FROM t685a
FOR ALL ENTRIES IN tbl_konv
WHERE kappl EQ 'V' AND "Sales
kschl EQ tbl_konv-kschl AND
kaend_wrt EQ 'X' AND "Value is Editable
kmanu NE 'D'. "Process manually
* Prepare for Binary Search
SORT tbl_t685a BY kschl.
LOOP AT tbl_konv.
READ TABLE tbl_t685a WITH KEY kschl = tbl_konv-kschl BINARY SEARCH.
IF sy-subrc EQ 0.
MOVE-CORRESPONDING tbl_konv TO tbl_komv.
APPEND tbl_komv.
ENDIF.
ENDLOOP.
CHECK NOT tbl_komv[] IS INITIAL.
* Map KOMV into the more BAPI friendly BAPISDCOND structure
CALL FUNCTION 'MAP_INT_TO_EXT_STRUCTURE'
TABLES
fxvbak = tbl_vbak
fxkomv = tbl_komv
fxbapikomv = tbl_bapisdcond
EXCEPTIONS
entry_missing = 1
OTHERS = 2.
ENDFORM. " get_contract_details
*& Form call_change_sales_ord_bapi
* Call the Change Sales Order BAPI
FORM call_change_sales_ord_bapi .
DATA: st_head_chg LIKE bapisdh1x,
st_logic_switch TYPE bapisdls.
CHECK NOT g_vbeln_created IS INITIAL.
CHECK g_valid_contract EQ 'X'.
st_head_chg-updateflag = 'U'.
st_logic_switch-cond_handl = 'X'.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = g_vbeln_created
order_header_inx = st_head_chg
logic_switch = st_logic_switch
TABLES
return = tbl_return_chg
conditions_in = tbl_bapicond
conditions_inx = tbl_bapicondx.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDFORM. " call_change_sales_ord_bapi
*& Form write_output_report
* Produce Output Report
FORM write_output_report .
IF NOT g_vbeln_created IS INITIAL.
WRITE:/ 'Success! Sales Order', g_vbeln_created, 'was created!'.
ELSE.
WRITE:/ 'Failure! Sales Order was not created!'.
ENDIF.
SKIP.
WRITE:/ 'Sales Order Create Log'.
LOOP AT tbl_return.
WRITE:/ tbl_return-type, tbl_return-id, tbl_return-number,
tbl_return-message.
ENDLOOP.
SKIP.
WRITE:/ 'Sales Order Change Log'.
LOOP AT tbl_return_chg.
WRITE:/ tbl_return_chg-type, tbl_return_chg-id,
tbl_return_chg-number, tbl_return_chg-message.
ENDLOOP.
ENDFORM. " write_output_report
*& Form validate_contract
* Make sure that the Contract is Valid
FORM validate_contract .
DATA: l_gueen LIKE vbak-gueen,
l_prsdt LIKE vbkd-prsdt.
SELECT SINGLE vbak~gueen vbkd~prsdt
INTO (l_gueen, l_prsdt)
FROM vbak
INNER JOIN vbkd
ON vbak~vbeln = vbkd~vbeln
WHERE vbak~vbeln = c_contract AND
vbkd~posnr = '000000'.
IF sy-datum LE l_gueen.
* Contract is valid! Set Order Price Date
g_valid_contract = 'X'.
g_cont_price_date = l_prsdt.
ENDIF.
ENDFORM. " validate_contract
Hope this helps.
Cheers,
Pat. -
List of sales orders by ship-to party
Hi Lakshmipathi,
I tried this option and could see SH in VA05 selection screen.
However when i select this and execute the report i do not get any sales orders whereas if i select SP with the same customer i can see the order list.
I tried this with several ship to parties but could not get the order list and it says:
"Please check the entries. No work list selected
Message no. VR420
Diagnosis
No entries were found for the specified selection criteria.
Possible reasons for this:
Indexes for materials and business partners have not been updated
The organizational data or selection criteria are incorrect."
I checked the org data and it is correct as it gives me the results with SP by keeping the org data same.
Please advise.
Thanks.
-Dinesh
Re: Extracting the list of sales orders based on the ship to party
Posted: Nov 12, 2009 3:12 PM in response to: Dinesh Jagasia Reply
No entries were found for the specified selection criteria.
I would request not to continue any new question in the existing one which has been posted by some member.
Coming to your issue, in VA05, select "Further selection criteria" and check whether any defaulted sales area is flowing in which those ship to party has not been created.
thanks
G. Lakshmipathi
Hi G. Lakshmipathi,
I checked this but there is no defaulted sales area flowing.
-Dinesh
Edited by: Dinesh Jagasia on Nov 12, 2009 9:32 PMMessage no. VR420
Check note 623803
thanks
G. Lakshmipathi -
Sales order display - ship-to-party
hi
when VA03 transaction is run after providing the order value it displays header and item details. but in ship-to-party filed from which table the data is coming exactly how to find. and tell me the table name.
I know the process. pressing F1, in the technical information it is displaying the structure name. after that we need to double click on data element and we have to use the where used list and there select table fields. it is displaying so many. but i couldn't able to find the exact table. is there any way to do this.Hi
Ship-to-party is a partner function so you will find it in table VBPA. The Key for this table is VBELN-POSNR-PARVW where PARVW is the partner function. For ship-to-party (on our system anyway) the value you require is 'SH'.
Hope this helps
Andy
There is also VAKPA which kind of does the reverse of VBPA in that it it is an index of sales orders for a given partner function. The one you need will depend on your specific requireements.
Message was edited by: Andrew Wright -
BAPI Sales Order create with reference Invoice document
Hi
I am using BAPI ''SD_SALESDOCUMENT_CREATE'' to create debit memo request with reference Invoice document.
First time its successfully created with reference Invoice.When i am going to create 2nd time debit memo request with same reference Invoice and item
no its giving following error.
Reference quantity:
10 EA (total referenced:
40 EA)
Error in SALES_ITEM_IN 000010
Condition ZSLS is not allowed as header condition
Sales document was not changed
Please help any one to resolved this issue.
Regards
ShyamSD_SALESDOCUMENT_CREATE is not a BAPI. Is there any specific reason you're using this FM when the actual BAPI exists?
ZSLS is a custom condition. There might as well be some user exit that attempts to add it [possibly incorrectly], how would we know this on SCN? There is enough information in the error message to troubleshoot on your own, it seems. What kind of analysis have you done before posting on SCN? -
Hello,
I am using BAPI_SALESORDER_CREATEFROMDAT2 to create sales order. The system is configured to automatically generate the item numbers. I can create an order alright for simple materials.
For this I am populating both Line items and Schedule Line item structures - ORDER_ITEMS_IN and ORDER_SCHEDULES_IN respectively, without passing the line item number(ITM_NUMBER field).
The problem is when I create an order which has a KIT as a line item.
So SAP explodes the Kit correctly, but the quantity information goes all wrong for the subsequent lines after the kit. Hence order does not get correctly created.
Any hints on how to solev this? I want to create the order with Kit and simple materials and without provising the line item numbers.hello,
Please check the following code in case its a bill of material
FORM CHECK_SALES_BOM TABLES ORDER_ITEMS_IN STRUCTURE BAPIITEMIN
ORDER_PARTNERS STRUCTURE ZBAPISHIP1.
CLEAR FLAG_CANCEL_CREATE.
CLEAR V_LINES1.
LOOP AT ORDER_ITEMS_IN.
V_ITM_NUMBER = ORDER_ITEMS_IN-ITM_NUMBER.
ORDER_ITEMS_IN-PO_ITM_NO = ORDER_ITEMS_IN-ITM_NUMBER. " DEVK942749
ORDER_ITEMS_IN-ITM_NUMBER = 10 * SY-TABIX + 10 * V_LINES1.
MODIFY ORDER_ITEMS_IN.
LOOP AT ORDER_PARTNERS WHERE ITEM_NUMB = V_ITM_NUMBER.
ORDER_PARTNERS-ITEM_NUMB = ORDER_ITEMS_IN-ITM_NUMBER.
MODIFY ORDER_PARTNERS.
ENDLOOP.
SELECT SINGLE KNUMH FROM KOTD001 INTO KOTD001-KNUMH
WHERE KAPPL = 'V'
AND KSCHL = 'A001'
AND MATWA = ORDER_ITEMS_IN-MATERIAL
AND DATBI GE SY-DATUM
AND DATAB LE SY-DATUM.
IF SY-SUBRC = 0.
SELECT SINGLE SMATN FROM KONDD INTO KONDD-SMATN
WHERE KNUMH = KOTD001-KNUMH.
ORDER_ITEMS_IN-MATERIAL = KONDD-SMATN.
ELSE.
ORDER_ITEMS_IN-MATERIAL = ORDER_ITEMS_IN-MATERIAL.
ENDIF.
CLEAR V_WERKS.
SELECT SINGLE DWERK MTPOS INTO (V_WERKS, MVKE-MTPOS) FROM MVKE
WHERE MATNR = ORDER_ITEMS_IN-MATERIAL
AND VKORG = WWW_ORDER_HEADER_EXP-VKORG
AND VTWEG = WWW_ORDER_HEADER_EXP-VTWEG.
IF MVKE-MTPOS EQ 'LUMF' OR MVKE-MTPOS EQ 'ZLUM'.
READ TABLE ORDER_PARTNERS WITH KEY ITEM_NUMB = V_ITM_NUMBER
PARTN_ROLE = 'WE'.
REFRESH : DA_MASTB,
DA_STKOB,
DA_STZUB.
CALL FUNCTION 'CS_ALT_SELECT_MAT'
EXPORTING
ALL = ' '
CAPID = 'SD01'
DATUV = SY-DATUM
DIALF = ' '
LOSGR = 0
MATNR = ORDER_ITEMS_IN-MATERIAL
NOTAB = 'X'
NRFDC = ' '
STLAL = ' '
STLAN = ' '
VPRIO = ' '
WERKS = V_WERKS
TABLES
MASTB_WA = DA_MASTB
STKOB_WA = DA_STKOB
STZUB_WA = DA_STZUB
EXCEPTIONS
ALT_NOT_FOUND = 1
BOM_NOT_ACTIVE = 2
BOM_NOT_FOUND = 3
CALL_INVALID = 4
NO_ALT_FOUND = 5
NO_BOM_FOUND = 6
OTHERS = 7.
READ TABLE DA_MASTB INDEX 1.
IF SY-SUBRC = 0.
CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
EXPORTING
CAPID = 'SD01'
DATUV = SY-DATUM
EMENG = 1
MEHRS = 'X'
MTNRV = ORDER_ITEMS_IN-MATERIAL
RNDKZ = '2'
STLAL = '01'
WERKS = V_WERKS
IMPORTING
TOPMAT = CSTMAT
TABLES
STB = TSTB
MATCAT =
EXCEPTIONS
ALT_NOT_FOUND = 1
CALL_INVALID = 2
MATERIAL_NOT_FOUND = 3
MISSING_AUTHORIZATION = 4
NO_BOM_FOUND = 5
NO_PLANT_DATA = 6
NO_SUITABLE_BOM_FOUND = 7
OTHERS = 8.
DESCRIBE TABLE TSTB LINES V_LINES.
ENDIF.
V_LINES1 = V_LINES + V_LINES1 .
CLEAR V_LINES.
ENDIF.
ENDLOOP.
hope this will help you.
Reward points if it helps
regards,
krishna -
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 -
Getting Error while creating multiple Orders using Sales order Create BAPI
Hi,
I am trying to create 2 orders thru the Sales order create BAPI before I commit and save the orders. The Orders are getting created and the BAPI is coming back with success, but it is not setting the system status on the line items of the 1st order. So when I try to cancel the line items on the first order I get the error 'No status object is available for SDI 4924/10' . I would really appreciate if anyone has encountered such error before and could help me out with the reason for this error and the possible solution.
Thanks in advance,
David.Hi,
Check the following link:
http://www.sap-img.com/bapi.htm
Regards,
Bhaskar -
How to create ship to party and sold to party for DC10 during sales order ?
Hello all:
When creating sales order for a material in VA01 with sales Org 1000,
distribution channel 10, division 00
The system does not give me any Ship to Party and Sold to Party with the above combination
How to create ship to party and sold to party with the above combination (Plant 1000,
sales org 1000, distribution channel 10, during creation of a sales order
Ironically, when creating material master for a material with a material type KMAT, plant 1000
sales org 1000, the only distribution channel is populating in the input help (F4) is 10
For which no ship to party neither sold to party is maintained in sales order creation
Thanks in Advance!!Dear Eshwer
It is bcoz, the said account groups (Sold To Party and Ship To Party) are not created in the sales area 1000 / 10 / 00.
To create a customer master, you have to go to XD01, select the Account Group, Company Code and the respective Sales Area and execute. In the Customer Master, you have three tabs, viz.General Data where you have give address details of the customer, then in Control Data, you have to assign the respective Recon Account and in Sales Area Data, you have to maintain the customer's sales related details. Once you give all these datas and save the data, a customer code will be displayed at the bottom.
Now go to VA01, input the sale order type and the sales area and execute.
thanks
G. Lakshmipathi -
Change of Sold to Party in Sales order created with Reference to Contract
Dear Gurus
I want to change the sold to party in Sales Order created with reference to contract.
When I create a Sales order with reference to contract the system copies all the partner functions- Sold to, Ship to, Bill to and Payer alongwith other data.
However Sold to is marked as "Grey" and not changable, rest of the partners can be changed.
There is no subsiquent document created with reference to this Sales Order.
Please advice.
Thanks a lot.
Regards
RaghuHi ,
Please follow the below mentioned step.
1) Create a partner function letts say Authorized SP .
2) Assign all the possible authorised SP (customer) in the contract.
3) When you create sales order with reff to Contract. Put the customer for whom you wish to create a sales order in release partner tab.
Hop this will resolve our problem
Regards,
Krishna O -
Error when trying to search a sales order created by other user
Hi. I'm running SAP HANA One PL 04. I have a problem when I log on with User1 and try to search for sales orders created by another user. I got an error message. I think the user has enough permissions.. Is there anything else I should consider??
Hope anyone can give an idea why this happens
Thanks -
Error : Sales order 'create with Reference' to the contract
We have made a value contract. Now we are trying to make a Sales order 'create with Reference' to the contract.
when we do that, we am getting error 'copying material in any value contract item is not permitted'
Any help or directions would be greatly appreciated . We are on Ecc 6.0
RohitAs of now my value contract has just one material. so i dont need assortment module settings. right?
in VTAA settings are as follows
Target type: OR
Source type: ZK1
there is only on item category
Target item category: TAN
Source item category: WKN
Copying requirement : 301
update doc flow : 2
pricing type : C
cont item copy mode : A
DataT am using 151,102,002
There are no schedule line.
Rohit
Edited by: rohit kumar on May 15, 2008 7:36 PM -
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 -
Error in JCo while connecting BAPI SALES ORDER.
package com.sap;
import com.sap.mw.jco.JCO;
import com.sap.mw.jco.JCO.Exception;
import com.sapportals.portal.prt.component.AbstractPortalComponent;
import com.sapportals.portal.prt.component.IPortalComponentRequest;
import com.sapportals.portal.prt.component.IPortalComponentResponse;
public class DirectBAPI extends AbstractPortalComponent
public void doContent(IPortalComponentRequest request,
IPortalComponentResponse response)
JCO.Client mConnection;
JCO.Repository mRep;
response.write("Connecting..........");
try
// Change the logon information to your own system/user
mConnection = JCO.createClient("<client number>", "<user Id>", "password",
null, // language
"application server number", "<system no..>");
response.write("Reached");
mConnection.connect(); // connecting JCo...
mRep = new JCO.Repository("SAPJCo", mConnection); //use JCo Repository....
response.write("Connected Succesfully");
//response.write( mConnection.getAttributes() );
// mConnection.disconnect();
catch (Exception ex)
ex.printStackTrace();
response.write(ex.getMessage());
JCO.Function function = null;
JCO.FunctionTemplate ftp = null;
JCO.Table codes = null;
try
ftp = mRep.getFunctionTemplate();
function = ftp.getFunction();
function = this.createFunction("BAPI_SALESORDER_GETSTATUS");
// Accessing SALES_ORDER_GETSTATUS.
if (function == null)
response.write("BAPI_COMPANYCODE_GETLIST" + " not found in SAP.");
catch (Exception exx)
response.write(exx.getmessage() );
In the above code while while connecting to the BAPI SALES ORDER GET_STATUS an error is coming for JCO connection for the JCo Repository.
The method createFunction() is undefined for the type of Project.
plz guide how to rectify this so as to connect BAPI SALES ORDER thru JCo connection.
Thanx in advance.
Regards:
HanifHi,
The below Code is helpful for Calling BAPI's Using JCO .
public class TestJCO {
JCO.Client mConnection;
JCO.Repository mRepository;
public TestJCO() {
try {
// Change the logon information to your own system/user
// mConnection =
// JCO.createClient("800", // SAP client
// "USERID", // userid
// "password", // password
// null, // language
// "appserver hostname", // application server host name
// "00"); // system number
mConnection =
JCO.createClient("002", // SAP client
"userid", // userid
"password", // password
null, // language
"app server host name", // application server host name
"00"); // system number
mConnection.connect();
mRepository = new JCO.Repository("companyname", mConnection);
catch (Exception ex) {
ex.printStackTrace();
System.exit(1);
JCO.Function function = null;
JCO.Table codes = null;
try {
function = this.createFunction("BAPI_COMPANYCODE_GETLIST");
if (function == null) {
System.out.println("BAPI_COMPANYCODE_GETLIST" +
" not found in SAP.");
System.exit(1);
mConnection.execute(function);
JCO.Structure returnStructure =
function.getExportParameterList().getStructure("RETURN");
if (! (returnStructure.getString("TYPE").equals("") ||
returnStructure.getString("TYPE").equals("S")) ) {
System.out.println(returnStructure.getString("MESSAGE"));
System.exit(1);
codes =
function.getTableParameterList().getTable("COMPANYCODE_LIST");
for (int i = 0; i < codes.getNumRows(); i++) {
codes.setRow(i);
System.out.println(codes.getString("COMP_CODE") + '\t' +
codes.getString("COMP_NAME"));
catch (Exception ex) {
ex.printStackTrace();
System.exit(1);
try {
codes.firstRow();
for (int i = 0; i < codes.getNumRows(); i++, codes.nextRow()) {
function = this.createFunction("BAPI_COMPANYCODE_GETDETAIL");
if (function == null) {
System.out.println("BAPI_COMPANYCODE_GETDETAIL" +
" not found in SAP.");
System.exit(1);
function.getImportParameterList().
setValue(codes.getString("COMP_CODE"), "COMPANYCODEID");
function.getExportParameterList().setActive(false, "COMPANYCODE_ADDRESS");
mConnection.execute(function);
JCO.Structure returnStructure =
function.getExportParameterList().getStructure("RETURN");
if (! (returnStructure.getString("TYPE").equals("") ||
returnStructure.getString("TYPE").equals("S") ||
returnStructure.getString("TYPE").equals("W")) ) {
System.out.println(returnStructure.getString("MESSAGE"));
JCO.Structure detail =
function.getExportParameterList().
getStructure("COMPANYCODE_DETAIL");
System.out.println(detail.getString("COMP_CODE") + '\t' +
detail.getString("COUNTRY") + '\t' +
detail.getString("CITY"));
catch (Exception ex) {
ex.printStackTrace();
System.exit(1);
mConnection.disconnect();
public JCO.Function createFunction(String name) throws Exception {
try {
IFunctionTemplate ft = mRepository.getFunctionTemplate(name.toUpperCase());
if (ft == null)
return null;
return ft.getFunction();
catch (Exception ex) {
throw new Exception("Problem retrieving JCO.Function object.");
public static void main(String[] args) {
TestJCO app = new TestJCO();
Please Check your code with above code.
Thanks,
SubbaRao Chinta
Maybe you are looking for
-
Boa tarde, Comprei o MacBook Pro de 13 hm Polegadas nenhum dia 13/05/2011, e não dia 18/05, Que notem 5 dias DEPOIS de te-lo Tirado da Caixa e also epidêmico Vários Contatos com oo Suporte da Apple, atraves do numero de Caso 221807482 (chamam Como o
-
My home sharing between windows 7 and macbook pro not working
My macbook pro is not pulling up my windows 7 home sharing? The itunes 10.5.1 is my version
-
Outlook 2007 won't start with 10.1.3 installed
Hi, I'm trying to a do a fresh install of 10.1.3 on a windows XP machine that is running outlook 2007. The install goes ok but when I start Outlook I get the following error "Cannot start Microsoft Office Outlook. Cannot open the Outlook window. The
-
Hello ChaRM-experts! I have the following questions regarding ChaRM-Setup: 1) Do I always need to define a Maintenance Project or can I use tcode u201CSCMAu201D to use transport management/ChaRM for satellite systems in SOLMAN 2) Is it possible to us
-
Error message when creating new video
Cannnot create a new video i get a error message i have imovie 10.3 says : Operation cannot be completed , No other information is available about the problem.