‎2007 Sep 28 8:42 AM
Hi All
Could you please tell me, which BAPI/FM is executed when 'CREATE WITH REFERENCE' tab is pressed in VA01?
I need to call that BAPI/FM in my RFC and use this functionality to create sales order with reference to another sales order. Also please specify which parameters will be required to pass to this BAPI/FM.
Thanks in advance,
Mihir Shah.
‎2007 Sep 28 9:00 AM
Hi,
please check this BAPI BAPI_SALESDOCUMENT_COPY.
It is possible using BAPI_SALESORDER_CREATEFROMDAT12
you need to pass ref order number to
ORDER_HEADER_IN-REF_DOC (BAPISDHD1-REF_DOC)
Here is list of all bapi for sales order.
BAPISDORDER_GETDETAILEDLIST Sales Order: List of All Order Data
BAPI_ORDER_CHANGE_STATUS_GET Change status for order
BAPI_SALESDOCU_CREATEFROMDATA Creating a Sales Document
BAPI_SALESORDER_CHANGE Sales Order: Change Sales Order
BAPI_SALESORDER_CREATEFROMDAT1 Sales Order: Create Sales Order
BAPI_SALESORDER_CREATEFROMDAT2 Sales Order: Create Sales Order
BAPI_SALESORDER_CREATEFROMDATA Create sales order, no more maintenance
BAPI_SALESORDER_GETLIST Sales order: List of all orders for customer
BAPI_SALESORDER_GETSTATUS Sales order: Display status
BAPI_SALESORDER_SIMULATE Sales Order: Simulate Sales Order
BAPI_XSI_GET_VTRK_G Tracking info
i am giving u some FM SD_SALESDOCUMENT_CREATE ... in the header parameter there is parameter called REFDOCTYPE where you can specify the other sales document.
Thanks and Regards,
dharani kumar.g
‎2007 Sep 28 9:00 AM
Hi,
please check this BAPI BAPI_SALESDOCUMENT_COPY.
It is possible using BAPI_SALESORDER_CREATEFROMDAT12
you need to pass ref order number to
ORDER_HEADER_IN-REF_DOC (BAPISDHD1-REF_DOC)
Here is list of all bapi for sales order.
BAPISDORDER_GETDETAILEDLIST Sales Order: List of All Order Data
BAPI_ORDER_CHANGE_STATUS_GET Change status for order
BAPI_SALESDOCU_CREATEFROMDATA Creating a Sales Document
BAPI_SALESORDER_CHANGE Sales Order: Change Sales Order
BAPI_SALESORDER_CREATEFROMDAT1 Sales Order: Create Sales Order
BAPI_SALESORDER_CREATEFROMDAT2 Sales Order: Create Sales Order
BAPI_SALESORDER_CREATEFROMDATA Create sales order, no more maintenance
BAPI_SALESORDER_GETLIST Sales order: List of all orders for customer
BAPI_SALESORDER_GETSTATUS Sales order: Display status
BAPI_SALESORDER_SIMULATE Sales Order: Simulate Sales Order
BAPI_XSI_GET_VTRK_G Tracking info
i am giving u some FM SD_SALESDOCUMENT_CREATE ... in the header parameter there is parameter called REFDOCTYPE where you can specify the other sales document.
Thanks and Regards,
dharani kumar.g
‎2007 Sep 28 9:33 AM
see the code sample below..........................
report z_bapi_salesorder.
******************************************
vbak: Sales Document: Header Data
******************************************
data : v_vbeln type bapivbeln-vbeln.
data: it_header type table of zbapisdhd1 with header line,
it_item type table of zbapisditm with header line,
it_partner type table of zbapiparnr with header line,
it_return type table of bapiret2 with header line.
types: begin of ty_header,
doc_type type auart, "Sales Document Type
sales_org type vkorg, "Sales Organization
distr_chan type vtweg, "Distribution Channel
in_division type spart, "Division
bstzd type bstzd, "Customer purchase order number
end of ty_header,
tt_header type standard table of ty_header.
types: begin of ty_partner,
partn_numb type kunnr, "Sold-to party
end of ty_partner,
tt_partner type standard table of ty_partner.
types: begin of ty_item,
material type matnr, "material number
target_qty type dzmeng, "Target quantity in sales units
end of ty_item,
tt_item type standard table of ty_item.
types: begin of ty_table,
doc_type type auart, "Sales Document Type
sales_org type vkorg, "Sales Organization
distr_chan type vtweg, "Distribution Channel
in_division type spart, "Division
bstzd type bstzd, "Customer purchase order number
partn_numb type kunnr, "Sold-to party
partn_role type parvw, "Partner function
material type matnr, "material number
target_qty type dzmeng, "Target quantity in sales units
end of ty_table,
tt_table type standard table of ty_table.
data: wa_header type ty_header,
it_header type tt_header,
wa_item type ty_item,
it_item type tt_item,
wa_partner type ty_partner,
it_partner type tt_partner,
wa_table type ty_table,
it_table type tt_table.
data: filename type string, "Default File Name
filetable type filetable, "Table Holding Selected Files
v_rc type i, "Return Code, Number of Files or -1 If Error Occurred
v_file type string. "
filename = 'C:\Documents and Settings\ramyav\Desktop\raam.txt'..
call method cl_gui_frontend_services=>file_open_dialog
exporting
WINDOW_TITLE =
DEFAULT_EXTENSION =
default_filename = filename
FILE_FILTER =
WITH_ENCODING =
INITIAL_DIRECTORY =
MULTISELECTION =
changing
file_table = filetable
rc = v_rc
USER_ACTION =
FILE_ENCODING =
exceptions
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 4
others = 5
.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
if sy-subrc = 0.
read table filetable index 1 into v_file.
endif.
if v_rc = 1.
call function 'GUI_UPLOAD'
exporting
filename = v_file
filetype = 'ASC'
has_field_separator = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
VIRUS_SCAN_PROFILE = VIRUS_SCAN_PROFILE
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH = FILELENGTH
HEADER = HEADER
tables
data_tab = it_table
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.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
endif.
loop at it_table into wa_table.
at first.
read table it_table index sy-tabix into wa_table.
*Populate Header Data
perform populate_header.
*Populate Partner Details
perform populate_partner.
endat.
at new material.
read table it_table index sy-tabix into wa_table.
if not sy-tabix = 1.
*Call BAPI
perform call_bapi.
*Populate Header Data
perform populate_header.
*Populate Partner Details
perform populate_partner.
endif.
endat.
*Populate Item Data
perform populate_items.
at last.
read table it_table index sy-tabix into wa_table.
*Call BAPI
perform call_bapi.
endat.
endloop.
&----
*& Form populate_header
&----
form populate_header .
it_header-doc_type = wa_table-doc_type.
it_header-sales_org = wa_table-sales_org.
it_header-distr_chan = wa_table-distr_chan.
it_header-division = wa_table-in_division.
it_header-po_supplem = wa_table-bstzd .
append it_header.
endform. " populate_header
&----
*& Form populate_partner
&----
form populate_partner .
it_partner-partn_numb = wa_table-partn_numb .
it_partner-partn_role = wa_table-partn_role.
append it_partner.
endform. " populate_partner
&----
*& Form populate_items
&----
form populate_items .
it_item-material = wa_table-material.
it_item-target_qty = wa_table-target_qty.
append it_item.
endform. " populate_items
&----
*& Form call_bapi
&----
form call_bapi .
call function 'ZBAPI_SALES_ORDERCREATE'
exporting
header = it_header
IMPORTING
VBELN = VBELN
tables
item = it_item
partner = it_partner
return = it_return
.
clear: it_headER, it_headER,
it_ITEM, it_Item,
it_PARTNER, it_PARTNER.
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = '1'
importing
return = it_return.
*WRITE: IT_RETURN.
endform. " call_bapi
*********************************************************************************************************************
flat file ******************************************************************
reward points if helpful................
‎2007 Sep 28 9:57 AM
‎2007 Sep 28 11:34 AM
Hi
Thanks to all for your replies. I am now able to create Sales order with reference to another SO, However, Additional data B is not getting populated in the new sales order. Can you tell me how to pupulate that using this BAPI?
Thanks for your time and help
Regards
Mihir Shah.