SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Create Invoice with reference to salesorder



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> SD
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Sat Nov 10, 2007 6:51 pm    Post subject: Create Invoice with reference to salesorder Reply with quote

Code:
DATA: s_vbap TYPE vbap.
*
TABLES: vbak,vbap,likp, lips.

DATA: t_billing TYPE STANDARD TABLE OF bapivbrk WITH HEADER LINE.
DATA: t_conditions TYPE STANDARD TABLE OF bapikomv WITH HEADER LINE.
DATA: t_return TYPE STANDARD TABLE OF bapireturn1 WITH HEADER LINE.
DATA: t_ccard TYPE STANDARD TABLE OF bapiccard_vf WITH HEADER LINE.
DATA: t_errors TYPE STANDARD TABLE OF bapivbrkerrors WITH HEADER LINE.
DATA: t_success TYPE STANDARD TABLE OF bapivbrksuccess WITH HEADER LINE
.


PARAMETERS: p_vbeln TYPE vbeln.

select single * from likp
where vbeln = p_vbeln.

SELECT SINGLE * from lips where
vbeln = likp-vbeln.

t_billing-salesorg = likp-vkorg.
t_billing-ref_doc = likp-vbeln.
t_billing-ref_item = lips-posnr.
t_billing-doc_number = p_vbeln.
t_billing-itm_number = lips-posnr.
t_billing-ordbilltyp = 'Billing document type'.
t_billing-price_date = sy-datum.
t_billing-ref_doc_ca = likp-vbtyp.
t_billing-material = lips-matnr.
t_billing-plant = lips-werks.

APPEND t_billing.


CALL FUNCTION 'BAPI_BILLINGDOC_CREATEMULTIPLE'
TABLES
billingdatain = t_billing
return = t_return
success = t_success
.

commit work.


Code:
*// Заполняем структуру фактуры.
* Структура гибридная, можно использовать как для передачи
* только заголовочных данных и ссылки на сбытовой документ,
* так и для передачи позиций фактуры (в случае создания
* фактуры без документа образца)
* Если поле ref_doc_ca незаполнено - считается что фактура
* создается по-позиционно. В противном случае в это поле
* указывается тип документа-образца.
* Если номер позиции ref_item (в случае заказа) не указан,
* то фактурируется все позиции документа. Иначе - только
* указанная позиция.
*//
REFRESH: t_billingdatain.
CLEAR: t_billingdatain.
t_billingdatain-doc_type = 'YYY'.
t_billingdatain-ordbilltyp = 'Z2'.
t_billingdatain-ref_doc = v_salesdocument.
t_billingdatain-ref_doc_ca = 'C'.
APPEND t_billingdatain.
*//

*// Создание фактуры
CALL FUNCTION 'BAPI_BILLINGDOC_CREATEMULTIPLE'
TABLES
billingdatain = t_billingdatain
return = t_return
success = t_success.
COMMIT WORK AND WAIT.


Code:
REPORT ZTEST_INVOICE .

data : i_BAPIVBRK like BAPIVBRK occurs 0 with header line.

data i_BAPIRET1 like BAPIRET1 occurs 0 with header line.

data : i_BAPIVBRKSUCCESS like BAPIVBRKSUCCESS occurs 0 with header line.

parameters : p_vbeln like vbak-vbeln obligatory.

start-of-selection.

i_bapivbrk-DOC_NUMBER = p_vbeln.
i_bapivbrk-REF_DOC_CA = 'C'.
append i_bapivbrk.

CALL FUNCTION 'BAPI_BILLINGDOC_CREATEMULTIPLE'
* EXPORTING
* CREATORDATAIN =
* TESTRUN =
* POSTING =
TABLES
BILLINGDATAIN = i_bapivbrk
* CONDITIONDATAIN =
* CCARDDATAIN =
RETURN = i_BAPIRET1
SUCCESS = i_BAPIVBRKSUCCESS
.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
* IMPORTING
* RETURN =
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> SD All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.