‎2011 Nov 30 7:16 AM
Friends,
I found BAPI for DB/CR note request with reference to Invoice (BAPI_SALESDOCU_CREATEFROMDATA) , which is working fine. But in reference field is not working. Please help me out. Please find the code details.
data: order_header_in type BAPISDHEAD.
data: SALESDOCUMENT type BAPIVBELN-VBELN.
data: RETURN type BAPIRETURN1.
data: ORDER_ITEMS_IN type standard table of BAPIITEMIN WITH HEADER LINE.
data: ORDER_PARTNERS type standard table of BAPIPARTNR WITH HEADER LINE.
DATA: SOLD_TO_PARTY TYPE BAPISOLDTO,
SHIP_TO_PARTY TYPE BAPISHIPTO.
order_header_in-DOC_TYPE = 'ZCR'. "Credit note request type
order_header_in-SALES_ORG = '1000'.
order_header_in-DISTR_CHAN = '10'.
order_header_in-DIVISION = '05'.
order_header_in-SALES_OFF = '1130'.
order_header_in-REF_DOC = '1116002582'. "Invoice no
order_header_in-REF_DOC_CA = 'M'.
order_header_in-SD_DOC_CAT = 'K'.
order_header_in-PURCH_NO = 'Credit Note'.
order_header_in-PURCH_DATE = SY-DATUM.
order_items_in-ITM_NUMBER = '000010'.
order_items_in-REF_DOC = '1116002582'. "Invoice no
order_items_in-REF_DOC_IT = '000010'.
order_items_in-REF_DOC_CA = 'M'.
order_items_in-COND_TYPE = 'ZP01'. "Pricing cond Type
order_items_in-COND_VALUE = 551. "Amt
APPEND order_items_in.
order_partners-PARTN_ROLE = 'AG'.
order_partners-PARTN_NUMB = '0010000493'.
APPEND order_partners.
CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA'
EXPORTING
order_header_in = order_header_in
business_object = 'BUS2094'
IMPORTING
SALESDOCUMENT = SALESDOCUMENT
RETURN = RETURN
tables
order_items_in = order_items_in
order_partners = order_partners.
IF SY-SUBRC = 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDIF.
But in VBAK table, I did compare with another credit not request (created in GUI TCode VA01), where I found reference no is taking by the BAPI.
‎2012 Jan 31 10:35 PM
Hi Sanjeet Kumar Yadav,
Please see note [Note 370988 - BAPIs in SD: Creation with reference|https://service.sap.com/sap/support/notes/370988], I believe that this note can help you.
Regards
Bruno Xavier.