Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BAPI for DB/CR note request with reference to invoice

Former Member
0 Likes
544

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.

1 REPLY 1
Read only

brunobex
Active Participant
0 Likes
436

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.