Download as pdf or txt
Download as pdf or txt
You are on page 1of 31

Extensibility for Billing Document Printout

S/4 HANA Cloud


Table of Contents

1 Provide Purchase Order Date in Billing Document Output 4


1.1 Aim 4
1.2 Steps to do 4
1.2.1 Creation of an extension field at Billing Document 4
1.2.2 Extend the Form Template with the Extension Field 4
1.2.3 Creation of an extension logic 5
2 Provide Exchange Rate in Billing Document Output 7
2.1 Aim 7
2.2 Steps to do 7
2.2.1 Creation of an extension field at Billing Document 7
2.2.2 Extend the Form Template with the Extension Field 8
2.2.3 Creation of an extension logic 8
3 Provide Net Amount in Billing Document Output 10
3.1 Aim 10
3.2 Steps to do 10
3.2.1 Creation of an extension field at Billing Document 10
3.2.2 Extend the Form Template with the Extension Field 10
3.2.3 Creation of an extension logic 11
4 Provide Created On Date in Billing Document Output 13
4.1 Aim 13
4.2 Steps to do 13
4.2.1 Creation of an extension field at Billing Document 13
4.2.2 Extend the Form Template with the Extension Field 13
4.2.3 Creation of an extension logic 14
5 Provide Customer Material in Billing Document Output 16
5.1 Aim 16
5.2 Steps to do 16
5.2.1 Creation of an extension field at Billing Document Item 16
5.2.2 Extend the Form Template with the Extension Field 16
5.2.3 Creation of an extension logic 17
6 Provide Country Of Origin in Billing Document Output 19
6.1 Aim 19
6.2 Steps to do 19
6.2.1 Creation of an extension field at Billing Document Item 19
6.2.2 Extend the Form Template with the Extension Field 19
6.2.3 Creation of an extension logic 20
7 Provide Commodity Code in Billing Document Output 23
7.1 Aim 23
7.2 Steps to do 23
7.2.1 Creation of an extension field at Billing Document Item 23
7.2.2 Extend the Form Template with the Extension Field 23
7.2.3 Creation of an extension logic 24
8 Provide Tax Code in Billing Document Output 26
8.1 Aim 26
8.2 Steps to do 26
8.2.1 Creation of an extension field at Billing Document Item 26
8.2.2 Extend the Form Template with the Extension Field 26
8.2.3 Creation of an extension logic 27
9 Provide ATF License in Billing Document Output 29
9.1 Aim 29
9.2 Steps to do 29
9.2.1 Creation of an extension field at Billing Document Item 29
9.2.2 Extend the Form Template with the Extension Field 29
9.2.3 Creation of an extension logic 30

3
1 Provide Purchase Order Date in Billing Document Output

1.1 Aim

Show Purchase order date on Form Template Item of Billing Document.

1.2 Steps to do

1.2.1 Creation of an extension field at Billing Document


Use app Custom Fields and Logic, tab Custom Fields, in the Extensibility business catalog. Create a new
extension field in Business Context Billing Document with an appropriate Type.

This extension field is intended to store the Purchase Order Date with the Billing Document.

Remark: The extension field will only be filled when triggering the output request.

1.2.2 Extend the Form Template with the Extension Field


Within the same App Custom Fields and Logic and tab Custom Field enable the Form Templates for the
Billing Document with the extension field.

4
Save and publish the extension field.

1.2.3 Creation of an extension logic


Use app Custom Fields and Logic, tab Custom Logic, in the Extensibility business catalog. Create a new
Enhancement Implementation in Business Context Sales: Billing Document with Definition
Description Billing Standard Output Header Adaption and an appropriate Implementation
Description. In case the Enhancement Implementation already exist, this step can be skipped.

5
Add the following example code to the Draft:

* This method can be used to set values for output to billing document header
extension fields.

billingdoc_extension_out = billingdoc_extension_in.
billingdocdescr_extension_out = billingdocdescr_extension_in.

*get SO number
select single salesdocument
from i_billingdocumentitem
into @data(lv_salesdocument)
where billingdocument = @billingdoc-billingdocument.

*get PO date
select single customerpurchaseorderdate
from i_salesdocument
into @billingdoc_extension_out-yy1_purchaseorderdate_bdh
where salesdocument = @lv_salesdocument.

Save and publish the extension Logic.

Remark: To see the new created extension field in the Billing Document Printout, it is necessary to create a new Form
Template.

6
2 Provide Exchange Rate in Billing Document Output

2.1 Aim

Show Exchange Rate on Form Template Item of Billing Document.

2.2 Steps to do
Note: The fields Absolut Accounting Exchange Rate and Accounting Exchange Rate Is Indirect Quotation
already exist in the Standard Form Data Provider in the Billing Document Node. Please verify if the data is
sufficient.

2.2.1 Creation of an extension field at Billing Document


Use app Custom Fields and Logic, tab Custom Fields, in the Extensibility business catalog. Create a new
extension field in Business Context Sales: Billing Document with an appropriate Type.

This extension field is intended to store the Exchange Rate with the Billing Document.

Remark: The extension field will only be filled when triggering the output request.

7
2.2.2 Extend the Form Template with the Extension Field
Within the same App Custom Fields and Logic and tab Custom Field extend the Form Templates for the
Billing Document with the extension field.

Save and publish the extension field.

2.2.3 Creation of an extension logic


Use app Custom Fields and Logic, tab Custom Logic, in the Extensibility business catalog. Create a new
Enhancement Implementation in Business Context Sales Billing Document with Definition Description
Billing Standard Output Header Adaption and an appropriate Implementation Description. In
case the Enhancement Implementation already exist, this step can be skipped.

8
Add the following example code to the Draft:

if billingdoc-transactioncurrency ne 'SGD'.
*get Exchange Rate
select single accountingexchangerate
from i_billingdocumentbasic
into @data(lv_exchangerate)
where billingdocument = @billingdoc-billingdocument.

if sy-subrc is initial.
billingdoc_extension_out-yy1_exchangerate_bdh = 1 / lv_exchangerate.
endif.
endif.

Save and publish the extension Logic.

Remark: To see the new created extension field in the Billing Document Printout, it is necessary to create a new Form
Template.

9
3 Provide Net Amount in Billing Document Output

3.1 Aim

Show Net Amount on Form Template Item of Billing Document.

3.2 Steps to do

3.2.1 Creation of an extension field at Billing Document


Use app Custom Fields and Logic, tab Custom Fields, in the Extensibility business catalog. Create a new
extension field in Business Context Sales: Billing Document with an appropriate Type.

This extension field is intended to store the Net Amount with the Billing Document.

Remark: The extension field will only be filled when triggering the output request.

3.2.2 Extend the Form Template with the Extension Field


Within the same App Custom Fields and Logic and tab Custom Field extend the Form Templates for the
billing document with the extension field.

10
Save and publish the extension field.

3.2.3 Creation of an extension logic


Use app Custom Fields and Logic, tab Custom Logic, in the Extensibility business catalog. Create a new
Enhancement Implementation in Business Context Sales: Billing Document with Definition
Description Billing Standard Output Header Adaption and an appropriate Implementation
Description. In case the Enhancement Implementation already exist, this step can be skipped.

11
Add the following example code to the Draft:

*set Net Amount


billingdoc_extension_out-yy1_netamount_bdh = billingdoc-totalnetamount.

Save and publish the extension Logic.

Remark: To see the new created extension field in the Billing Document Printout, it is necessary to create a new Form
Template.

12
4 Provide Created On Date in Billing Document Output

4.1 Aim

Show Created On Date on Form Template Item of Billing Document.

4.2 Steps to do

4.2.1 Creation of an extension field at Billing Document


Use app Custom Fields and Logic, tab Custom Fields, in the Extensibility business catalog. Create a new
extension field in Business Context Sales: Billing Document with an appropriate Type.

This extension field is intended to store the Created On Date with the billing document.

Remark: The extension field will only be filled when triggering the output request.

4.2.2 Extend the Form Template with the Extension Field


Within the same App Custom Fields and Logic and tab Custom Field extend the Form Templates for the
billing document with the extension field.

13
Save and publish the extension field.

4.2.3 Creation of an extension logic


Use app Custom Fields and Logic, tab Custom Logic, in the Extensibility business catalog. Create a new
Enhancement Implementation in Business Context Sales: Billing Document with Definition
Description Billing Standard Output Header Adaption and an appropriate Implementation
Description. In case the Enhancement Implementation already exist, this step can be skipped.

14
Add the following example code to the Draft.

* First of all assign existing extension field values to output parameter:


billingdoc_extension_out = billingdoc_extension_in.

billingdoc_extension_out-yy1_created_on_date_bdh = billingdoc-creationdate.

Save and publish the extension Logic.

Remark: To see the new created extension field in the Billing Document Printout, it is necessary to create a new Form
Template.

15
5 Provide Customer Material in Billing Document Output

5.1 Aim

Show Customer Material on Form Template Item of Billing Document Item.

5.2 Steps to do

5.2.1 Creation of an extension field at Billing Document Item


Use app Custom Fields and Logic, tab Custom Fields, in the Extensibility business catalog. Create a new
extension field in Business Context Sales: Billing Document Item with an appropriate Type.

This extension field is intended to store the Customer Material with the Billing Document.

Remark: The extension field will only be filled when triggering the output request.

5.2.2 Extend the Form Template with the Extension Field


Within the same App Custom Fields and Logic and tab Custom Field extend the Form Templates for the
billing document with the extension field.

16
Save and publish the extension field.

5.2.3 Creation of an extension logic


Use app Custom Fields and Logic, tab Custom Logic, in the Extensibility business catalog. Create a new
Enhancement Implementation in Business Context Sales: Billing Document Item with Definition
Description Billing Standard Output Item Adaption and an appropriate Implementation
Description. In case the Enhancement Implementation already exist, this step can be skipped.

17
Add the following example code to the Draft:

* This method can be used to set values for output to billing document item
extension fields.

billingdocitem_ext_out = billingdocitem_ext_in.
billingdocitemdescr_ext_out = billingdocitemdescr_ext_in.

*get Salesorganization and Distributionchannel


select single salesorganization, distributionchannel
from i_billingdocumentbasic
into (@data(lv_salesorganization), @data(lv_distributionchannel))
where billingdocument = @billingdocitem-billingdocument.

*get ‘Sold-To’ Customer


select single customer
from i_billingdocumentpartner
into @data(lv_customer)
where billingdocument = @billingdocitem-billingdocument and
partnerfunction = 'AG'.

*get Customer Material


select single materialbycustomer
from i_customermaterial
into @billingdocitem_ext_out-yy1_customermaterial_bdi
where salesorganization = @lv_salesorganization and
distributionchannel = @lv_distributionchannel and
customer = @lv_customer and
material = @billingdocitem-material.

Save and publish the extension Logic.

Remark: To see the new created extension field in the Billing Document Printout, it is necessary to create a new Form
Template.

18
6 Provide Country Of Origin in Billing Document Output

6.1 Aim

Show Country Of Origin on Form Template Item of Billing Document Item.

6.2 Steps to do

6.2.1 Creation of an extension field at Billing Document Item


Use app Custom Fields and Logic, tab Custom Fields, in the Extensibility business catalog. Create a new
extension field in Business Context Sales: Billing Document Item with an appropriate Type.

This extension field is intended to store the Country Of Origin with the Billing Document Item.

Remark: The extension field will only be filled when triggering the output request.

6.2.2 Extend the Form Template with the Extension Field


Within the same App Custom Fields and Logic and tab Custom Field extend the Form Templates for the
billing document with the extension field.

19
Save and publish the extension field.

6.2.3 Creation of an extension logic


Use app Custom Fields and Logic, tab Custom Logic, in the Extensibility business catalog. Create a new
Enhancement Implementation in Business Context Sales: Billing Document Item with Definition
Description Billing Standard Output Item Adaption and an appropriate Implementation
Description. In case the Enhancement Implementation already exist, this step can be skipped.

Add the following example code to the Draft:

20
6.2.3.1 Select Country of Origin from table MARC:

* First of all assign existing extension field values to output parameter:


billingdocitem_ext_out = billingdocitem_ext_in.
billingdocitemdescr_ext_out = billingdocitemdescr_ext_in.

select single CountryOfOrigin from I_Productplant


WHERE product = @billingdocitem-Material and
plant = @billingdocitem-plant
into @billingdocitem_ext_out-YY1_country_of_origin_bdi.

Save and publish the extension Logic.

6.2.3.2 Select Country of Origin from table MARA:

* First of all assign existing extension field values to output parameter:


billingdocitem_ext_out = billingdocitem_ext_in.
billingdocitemdescr_ext_out = billingdocitemdescr_ext_in.

select single CountryOfOrigin from I_Product


WHERE product = @billingdocitem-material
into @billingdocitem_ext_out-YY1_country_of_origin_bdi.

Save and publish the extension Logic.

21
Remark: To see the new created extension field in the Billing Document Printout, it is necessary to create a new Form
Template.

22
7 Provide Commodity Code in Billing Document Output

7.1 Aim

Show Commodity Code on Form Template Item of Billing Document Item.

7.2 Steps to do

7.2.1 Creation of an extension field at Billing Document Item


Use app Custom Fields and Logic, tab Custom Fields, in the Extensibility business catalog. Create a new
extension field in Business Context Sales: Billing Document Item with an appropriate Type.

This extension field is intended to store the Commodity Code with the Billing Document Item.

Remark: The extension field will only be filled when triggering the output request.

7.2.2 Extend the Form Template with the Extension Field


Within the same App Custom Fields and Logic and tab Custom Field extend the Form Templates for the
billing document with the extension field.

23
Save and publish the extension field.

7.2.3 Creation of an extension logic


Use app Custom Fields and Logic, tab Custom Logic, in the Extensibility business catalog. Create a new
Enhancement Implementation in Business Context Sales: Billing Document Item with Definition
Description Billing Standard Output Item Adaption and an appropriate Implementation
Description. In case the Enhancement Implementation already exist, this step can be skipped.

Add the following example code to the Draft:

24
* First of all assign existing extension field values to output parameter:
billingdocitem_ext_out = billingdocitem_ext_in.
billingdocitemdescr_ext_out = billingdocitemdescr_ext_in.
*
* Read commodity code for specific product:
SELECT SINGLE commoditycode
FROM c_prodcommoditycodeforkeydate( p_keydate = @billingdoc-
billingdocumentdate )
WHERE product = @billingdocitem-material
AND country = @billingdocitem-DepartureCountry
INTO @billingdocitem_ext_out-YY1_CommodityCode_BDI.

Save and publish the extension Logic.

Remark: To see the new created extension field in the Billing Document Printout, it is necessary to create a new Form
Template.

25
8 Provide Tax Code in Billing Document Output

8.1 Aim

Show Tax Code on Form Template Item of Billing Document Item.

8.2 Steps to do

8.2.1 Creation of an extension field at Billing Document Item


Use app Custom Fields and Logic, tab Custom Fields, in the Extensibility business catalog. Create a new
extension field in Business Context Sales: Billing Document Item with an appropriate Type.

This extension field is intended to store the Tax Code with the Billing Document Item.

Remark: The extension field will only be filled when triggering the output request.

8.2.2 Extend the Form Template with the Extension Field


Within the same App Custom Fields and Logic and tab Custom Field extend the Form Templates for the
billing document with the extension field.

26
Save and publish the extension field.

8.2.3 Creation of an extension logic


Use app Custom Fields and Logic, tab Custom Logic, in the Extensibility business catalog. Create a new
Enhancement Implementation in Business Context Sales: Billing Document Item with Definition
Description Billing Standard Output Item Adaption and an appropriate Implementation
Description. In case the Enhancement Implementation already exist, this step can be skipped.

Add the following example code to the Draft:

* First of all assign existing extension field values to output parameter:


billingdocitem_ext_out = billingdocitem_ext_in.
billingdocitemdescr_ext_out = billingdocitemdescr_ext_in.
*
* Read tax code for specific billing document item:
SELECT SINGLE taxcode
FROM i_billingdocitemprcgelmntbasic
WHERE billingdocument = @billingdocitem-billingdocument

27
AND billingdocumentitem = @billingdocitem-billingdocumentitem
AND pricingprocedurestep = '850'
INTO @billingdocitem_ext_out-yy1_taxcode_bdi.

Save and publish the extension Logic.

Remark 1: The pricing procedure step depends on the pricing scheme and in case of customer pricing scheme the value
could differ.

Remark 2: To see the new created extension field in the Billing Document Printout, it is necessary to create a new Form
Template.

28
9 Provide ATF License in Billing Document Output

9.1 Aim

Show ATF License on Form Template Item of Billing Document.

9.2 Steps to do

9.2.1 Creation of an extension field at Billing Document Item


Use app Custom Fields and Logic, tab Custom Fields, in the Extensibility business catalog. Create a new
extension field in Business Context Sales: Billing Document Item with an appropriate Type.

This extension field is intended to store the ATF License with the Billing Document Item.

Remark: The extension field will only be filled when triggering the output request.

9.2.2 Extend the Form Template with the Extension Field


Within the same App Custom Fields and Logic and tab Custom Field enable the Form Templates for the
Billing Document with the extension field.

29
Save and publish the extension field.

9.2.3 Creation of an extension logic


Use app Custom Fields and Logic, tab Custom Logic, in the Extensibility business catalog. Create a new
Enhancement Implementation in Business Context Sales: Billing Document Item with BAdI
Description Billing Standard Output Item Adaption and an appropriate Implementation
Description. This step can be skipped in case the Enhancement Implementation already exist.

Add the following example code to the Draft:

* First of all assign existing extension field values to output parameter:


billingdocitem_ext_out = billingdocitem_ext_in.
billingdocitemdescr_ext_out = billingdocitemdescr_ext_in.

* select the ATF License

30
select single ExtTrdCmplncLicense
from C_TrdCmplncDocItmLicAssgmt
where referencedocument = @billingdocitem-referencesddocument
and referencedocumentitem = @billingdocitem-referencesddocumentitem
into @billingdocitem_ext_out-yy1_atf_license_bdi.

Save and publish the extension Logic.

Remark: To see the new created extension field in the Billing Document Printout, it is necessary to create a new Form
Template.

31

You might also like