2006 Jan 26 3:21 PM
ALL:
I am faced with a task of creating credit and debit memo request referencing a sales order. I am trying to use: BAPI_SALESORDER_CREATEFROMDAT2 to accomplish this task but keep getting error message:
Unpermitted combination of business object BUS2032 and sales doc. category L
I inserted the sales order number I 'am referencing in the BAPI HEADER FIELD - REFDOCTYPE. Has any one use this BAPI to create credit and debit memo request referencing a sales order, please help with a sample code on how to load this BAPI for credit and debit memo request creation referencing a sales order.
Thanks,
Frank
2006 Jan 26 3:45 PM
Frank,
This FM does not perform this task. We have cloned the original and modified the clone to pass the Business Object as an inbound parameter.
data: con_cr_memo_bus_obj like BAPIUSW01-OBJTYPE value 'BUS2094'.
CALL FUNCTION 'ZBAPI_CRED_MEMO_CREATEFROMDAT2'
EXPORTING
ORDER_HEADER_IN = bapi_hdr
business_object = con_cr_memo_bus_obj
convert = 'X'
IMPORTING
SALESDOCUMENT = bapi_salesdoc
TABLES
return = bapi_ret_tbl
ORDER_ITEMS_IN = bapi_itm
ORDER_PARTNERS = bapi_prtnr
ORDER_ITEMS_inx = bapi_itm_out
order_schedules_in = bapi_schd_lin
order_text = bapi_text.
AND in the cloned ZBAPI above in SE37/80, add this Importing parameter: BUSINESS_OBJECT LIKE BAPIUSW01-OBJTYPE
Please reward points accordingly.
2006 Jan 26 3:45 PM
Frank,
This FM does not perform this task. We have cloned the original and modified the clone to pass the Business Object as an inbound parameter.
data: con_cr_memo_bus_obj like BAPIUSW01-OBJTYPE value 'BUS2094'.
CALL FUNCTION 'ZBAPI_CRED_MEMO_CREATEFROMDAT2'
EXPORTING
ORDER_HEADER_IN = bapi_hdr
business_object = con_cr_memo_bus_obj
convert = 'X'
IMPORTING
SALESDOCUMENT = bapi_salesdoc
TABLES
return = bapi_ret_tbl
ORDER_ITEMS_IN = bapi_itm
ORDER_PARTNERS = bapi_prtnr
ORDER_ITEMS_inx = bapi_itm_out
order_schedules_in = bapi_schd_lin
order_text = bapi_text.
AND in the cloned ZBAPI above in SE37/80, add this Importing parameter: BUSINESS_OBJECT LIKE BAPIUSW01-OBJTYPE
Please reward points accordingly.
2006 Jan 26 4:10 PM
Thanks John for the quick response, before I test this bapi sample - what fields in the ORDER_HEADER_IN did you populate? Can you send me code portion where you loaded the required BAPI structure fields,
THANKS,
Frank
2006 Jan 26 4:22 PM
ORDER_HEADER_IN loading:
bapi_hdr-doc_type = 'ZMRE'.
select single * from knvv into knvv_rec where
kunnr = tmp_kunnr and loevm ne 'X'.
bapi_hdr-sales_org = knvv_rec-vkorg.
bapi_hdr-distr_chan = knvv_rec-vtweg.
bapi_hdr-division = knvv_rec-spart.
bapi_hdr-purch_date = hdr_rec-rmidate.
bapi_hdr-req_date_h = hdr_rec-rmidate.
bapi_hdr-price_date = sys_date.
bapi_hdr-purch_no_c = hdr_rec-rminum_po.
bapi_hdr-created_by = sy-uname.
ORDER_ITEMS_IN Loading:
loop at det_tbl2 into det_rec2.
clear bapi_itm.
clear bapi_schd_lin.
perform good_material_check.
if good_matnr_flag ne 'Y'.
bapi_itm-material = p_defmat.
bapi_itm-cust_mat35 = det_rec2-matnr.
bapi_itm-short_text = item_err_desc.
else.
bapi_itm-material = det_rec2-matnr.
endif.
tmp_posnr = tmp_posnr + 10.
bapi_itm-itm_number = tmp_posnr.
bapi_itm-target_qty = det_rec2-qty.
bapi_itm-target_qu = det_rec2-uom.
append bapi_itm.
endloop.
2006 Jan 26 4:40 PM
John - can you share the source code of your clone bapi - when I copied the original bapi (BAPI_SALESORDER_CREATEFROMDAT2)to zbapiXXXXXX
I am having a hard time trying to figure out which of source code to omit or include in the my bapi rapper.
You can zip the source code to my email if the file is too large
Thank,
Frank
2006 Jan 26 4:42 PM
Do not omit any code... just add the Business Object parameter in the Import tab. And then fill in that parameter in your CALL FUNCTION "ZBAPIxxxx".
2006 Jan 26 4:45 PM
Sorry...
FUNCTION ZBAPI_CRED_MEMO_CREATEFROMDAT2.
*"----
""Local Interface:
*" IMPORTING
*" VALUE(SALESDOCUMENTIN) LIKE BAPIVBELN-VBELN OPTIONAL
*" VALUE(ORDER_HEADER_IN) LIKE BAPISDHD1 STRUCTURE BAPISDHD1
*" VALUE(ORDER_HEADER_INX) LIKE BAPISDHD1X STRUCTURE BAPISDHD1X
*" OPTIONAL
*" VALUE(SENDER) LIKE BAPI_SENDER STRUCTURE BAPI_SENDER OPTIONAL
*" VALUE(BINARY_RELATIONSHIPTYPE) LIKE BAPIRELTYPE-RELTYPE
*" OPTIONAL
*" VALUE(INT_NUMBER_ASSIGNMENT) LIKE BAPIFLAG-BAPIFLAG OPTIONAL
*" VALUE(BEHAVE_WHEN_ERROR) LIKE BAPIFLAG-BAPIFLAG OPTIONAL
*" VALUE(LOGIC_SWITCH) LIKE BAPISDLS STRUCTURE BAPISDLS OPTIONAL
*" VALUE(TESTRUN) LIKE BAPIFLAG-BAPIFLAG OPTIONAL
*" VALUE(CONVERT) LIKE BAPIFLAG-BAPIFLAG DEFAULT SPACE
*" VALUE(BUSINESS_OBJECT) LIKE BAPIUSW01-OBJTYPE
*" EXPORTING
*" VALUE(SALESDOCUMENT) LIKE BAPIVBELN-VBELN
*" TABLES
*" RETURN STRUCTURE BAPIRET2 OPTIONAL
*" ORDER_ITEMS_IN STRUCTURE BAPISDITM OPTIONAL
*" ORDER_ITEMS_INX STRUCTURE BAPISDITMX OPTIONAL
*" ORDER_PARTNERS STRUCTURE BAPIPARNR
*" ORDER_SCHEDULES_IN STRUCTURE BAPISCHDL OPTIONAL
*" ORDER_SCHEDULES_INX STRUCTURE BAPISCHDLX OPTIONAL
*" ORDER_CONDITIONS_IN STRUCTURE BAPICOND OPTIONAL
*" ORDER_CONDITIONS_INX STRUCTURE BAPICONDX OPTIONAL
*" ORDER_CFGS_REF STRUCTURE BAPICUCFG OPTIONAL
*" ORDER_CFGS_INST STRUCTURE BAPICUINS OPTIONAL
*" ORDER_CFGS_PART_OF STRUCTURE BAPICUPRT OPTIONAL
*" ORDER_CFGS_VALUE STRUCTURE BAPICUVAL OPTIONAL
*" ORDER_CFGS_BLOB STRUCTURE BAPICUBLB OPTIONAL
*" ORDER_CFGS_VK STRUCTURE BAPICUVK OPTIONAL
*" ORDER_CFGS_REFINST STRUCTURE BAPICUREF OPTIONAL
*" ORDER_CCARD STRUCTURE BAPICCARD OPTIONAL
*" ORDER_TEXT STRUCTURE BAPISDTEXT OPTIONAL
*" ORDER_KEYS STRUCTURE BAPISDKEY OPTIONAL
*" EXTENSIONIN STRUCTURE BAPIPAREX OPTIONAL
*" PARTNERADDRESSES STRUCTURE BAPIADDR1 OPTIONAL
*"----
generate data record
fbgenmac 'BAPI_SALESORDER_CREATEFROMDAT2'.
BAPIs run without dialog
CALL FUNCTION 'DIALOG_SET_NO_DIALOG'.
CALL FUNCTION 'SD_SALESDOCUMENT_CREATE'
EXPORTING
SALESDOCUMENT = salesdocumentin
SALES_HEADER_IN = ORDER_HEADER_IN
SALES_HEADER_INX = ORDER_HEADER_INX
SENDER = SENDER
BINARY_RELATIONSHIPTYPE = BINARY_RELATIONSHIPTYPE
INT_NUMBER_ASSIGNMENT = INT_NUMBER_ASSIGNMENT
BEHAVE_WHEN_ERROR = BEHAVE_WHEN_ERROR
LOGIC_SWITCH = LOGIC_SWITCH
BUSINESS_OBJECT = BUSINESS_OBJECT "here !!!!
TESTRUN = TESTRUN
convert_parvw_auart = convert
IMPORTING
SALESDOCUMENT_EX = salesdocument
TABLES
RETURN = RETURN
SALES_ITEMS_IN = ORDER_ITEMS_IN
SALES_ITEMS_INX = ORDER_ITEMS_INX
SALES_PARTNERS = ORDER_PARTNERS
SALES_SCHEDULES_IN = ORDER_SCHEDULES_IN
SALES_SCHEDULES_INX = ORDER_SCHEDULES_INX
SALES_CONDITIONS_IN = ORDER_CONDITIONS_IN
SALES_CONDITIONS_INX = ORDER_CONDITIONS_INX
SALES_CFGS_REF = ORDER_CFGS_REF
SALES_CFGS_INST = ORDER_CFGS_INST
SALES_CFGS_PART_OF = ORDER_CFGS_PART_OF
SALES_CFGS_VALUE = ORDER_CFGS_VALUE
SALES_CFGS_BLOB = ORDER_CFGS_BLOB
sales_cfgs_vk = order_cfgs_vk
sales_cfgs_refinst = order_cfgs_refinst
SALES_CCARD = ORDER_CCARD
SALES_TEXT = ORDER_TEXT
SALES_KEYS = ORDER_KEYS
EXTENSIONIN = EXTENSIONIN
partneraddresses = partneraddresses.
reset the dialogflag
CALL FUNCTION 'DIALOG_SET_WITH_DIALOG'.
ENDFUNCTION.
Note the Business OBject needs to be passed !!!
2006 Jan 27 1:36 AM
Frank,
Have you completed the project? If not, please let me know the issue(s) outstanding. If you have finished, please reward points accordingly
2006 Jan 27 1:31 PM
John,
Thanks for your help, I have awarded you your points. But I still have couples of questions for your proposed solution.
1 Copying a standard SAPI BAPI with its function Group its not the best practice, in the case an OSS Note is released for one of the copied objects - your code may be outdated.
2. It appears that uses the Business Objects parameter you added to BAPI_SALESORDER_CREATEFROMDAT2 was only used standard BAPI :'SD_SALESDOCUMENT_CREATE'
Why not call the BAPI 'SD_SALESDOCUMENT_CREATE' directly from your program and pass 'BUS2094' to the field
3. 'BUS2094' is the business object for Credit memo creation and 'BUS2096' is for Debit Credit memo creation. I had a problem using 'BUS2094' for debit , I finally debug the BAPI and realize the correct object for debit memo creation was 'BUS2096'.
Thanks again for your help.
Frank
2006 Jan 27 1:59 PM
Frank,
1 Copying a standard SAPI BAPI with its function Group its not the best practice, in the case an OSS Note is released for one of the copied objects - your code may be outdated.
This is true. If an OSS note is applied OR the SAP system goes thru an upgrade (and I hope that your company is doing that regularly), there is a risk for additional changes being needed in the ZBAPIxxxx that you made. Just something to "keep your eyes peeled for"...
2. It appears that uses the Business Objects parameter you added to BAPI_SALESORDER_CREATEFROMDAT2 was only used standard BAPI :'SD_SALESDOCUMENT_CREATE'
Why not call the BAPI 'SD_SALESDOCUMENT_CREATE' directly from your program and pass 'BUS2094' to the field
Probably a "safe" operation in this case... but only PROBABLY. BAPIs were built by SAP to allow external applications (Internet apps, Windows apps, etc) to access R/3 business objects. By addding the Business Object to the ZBAPI, we have enabled the opportunity for other developers to create debit/credit memos from external systems.
Hope that helps. Thanks for the points. Keep 'em coming.
2006 Dec 06 1:59 AM
Hi John ,
I have created the Zxxxxx funtion module and I am filling all the appropriate fields but Im getting an error. Its asking me to please enter a Sold to party or ship to party. I have tried padding the sold to with zero's and still no luck. Any clue what could be causing this ?
Thanks and points will be rewarded if you can help me out.
2006 Dec 06 2:16 AM
HI James
Instead of creating a "Z" Function Module, we can use SD_SALESDOCUMENT_CREATE for creating credit memo request.
Kind Regards
Eswar
FYI, Points can be awarded by the thread owners only...:)
2006 Jan 26 3:54 PM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |