BAPIS_MUDANÇAS DE LOCALIZ BRASIL

68
SAP ® HORIZON Internal & Confidential Design Release: 3.0 SP9 Author: Jan- Klaas Heinsohn EBP 3.0 Localization Brazil History Version Status Date 1.0 Draft 3.0 SP9 Storage location of this design document: N:\My Documents\EBP\EBP_Brazil_Design_30.doc Storage location of the corresponding specification document: N:\My Documents\EBP\EBP-Localization Brazil Specs for SAP Brazil.doc © 2002 SAP AG Neurottstr. 16 D-69190 Walldorf Title: EBP 3.0 Localization Brazil Version: 3.0 SP9 Date: 3.0 SP9 Page 1 of 68

Transcript of BAPIS_MUDANÇAS DE LOCALIZ BRASIL

Page 1: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® HORIZONInternal & Confidential Design

Release: 3.0 SP9

Author: Jan-Klaas Heinsohn

EBP 3.0 Localization Brazil

History

Version Status Date

1.0 Draft 3.0 SP9

Storage location of this design document:N:\My Documents\EBP\EBP_Brazil_Design_30.doc

Storage location of the corresponding specification document:N:\My Documents\EBP\EBP-Localization Brazil Specs for SAP Brazil.-doc

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 1 of 54

GQM, 01/03/-1,
Page: 1 Maintain name of author (responsible developer) in "File" menu -> "Properties", click OK, update using <F9>
GQM, 01/03/-1,
Page: 1 Maintain in "File" menu -> "Properties", click OK, update using <F9>
Page 2: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

Content

1 Organization...........................................................................................51.1 Project Team / Development Team...................................................................5

1.2 Project Plan........................................................................................................5

1.3 Further References............................................................................................5

2 Glossary................................................................................................5

3 Aspects of Brazilian Localization........................................................63.1 Brazil-Specific Fields in EBP Product Master....................................................6

3.2 Brazil-Specific Fields in Procurement Documents.............................................7

3.3 Catalog Integration............................................................................................8

3.4 Creation of Backend Documents.......................................................................8

3.5 Tax Calculation..................................................................................................8

3.5.1 Note on Recalculation of Taxes.........................................................................8

4 Detailed Design...................................................................................104.1 Brazilian Data Structures.................................................................................10

4.1.1 BBP_CUF_ATTR_BR......................................................................................10

4.1.2 BBP_CUF_TAX_BR........................................................................................10

4.1.3 BBP_CUF_ITEM_BR.......................................................................................11

4.1.4 BBP_CUF_ITEM_SC_BR................................................................................11

4.1.5 BBP_CUF_ITEM_PO_BR...............................................................................11

4.1.6 CI_BBP_ITEM..................................................................................................11

4.2 BAdI BBP_CUF_BADI_ICC.............................................................................12

4.2.1 Method PUT_DATA.........................................................................................12

4.2.2 Method GET_DATA.........................................................................................12

4.3 BadI BBP_CUF_ICC_BADI.............................................................................13

4.3.1 Method MODIFY_SCREEN.............................................................................13

4.3.2 Method MODIFY_INPUT.................................................................................14

4.3.3 Method MODIFY_OUTPUT.............................................................................15

4.4 BAdI BBP_DOC_CHECK_ICC........................................................................17

4.5 BAdI BBB_TAX_ICC........................................................................................17

4.5.1 Attributes of Class CL_IM_BBP_TAX_ICC_BR...............................................17

4.5.2 Method CALCULATE_TAX..............................................................................17

4.5.3 Method DETERMINE_CALC_FLAG................................................................23

4.6 BAdI BBP_ICC_PO_MAP................................................................................25

4.6.1 Method MAP_STRUCTURES.........................................................................25

4.6.2 Call to Method MAP_STRUCTURES..............................................................34

4.7 Function module BBP_ICC_PUT_DATA.........................................................36

4.8 Screens and Internet Services.........................................................................38

4.8.1 Screen 200 in Function Group BBP_ICC........................................................39

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 2 of 54

Page 3: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

4.8.2 Internet Service BBP_ICC_TAX_BR...............................................................40

4.8.2.1 HTML Template SAPLBBP_ICC 200..............................................................40

4.8.2.2 HTML Template SAPLBBP_PDH_CUF 100....................................................41

4.9 Tax Calculation in R/3 Plugin...........................................................................42

4.9.1 Function Module BBP_CALCULATE_TAX_ITEM40B.....................................42

4.9.2 Form Routine GET_COUNTRY.......................................................................45

4.9.3 Form Routine FILL_TAXCOM_COUNTRY_SPECIFIC...................................45

4.9.4 Form Routine FILL_TAXCOM_BRAZIL...........................................................46

4.9.5 Form Routine MAP_TAX_REGION.................................................................47

4.9.6 Form Routine FILL_TAX_COND_COUNTRY_SPECIFIC...............................47

4.10 Sequence of Execution of Brazil-Specific Coding............................................48

4.10.1 Chronological Sequence of Execution of BAdI Methods During Posting of a Shopping Cart..................................................................................................48

4.10.1.1 IF_EX_BBP_TAX_ICC~DETERMINE_CALC_FLAG......................................48

4.10.1.2 IF_EX_BBP_CUF_BADI_ICC~PUT_DATA.....................................................49

4.10.1.3 IF_EX_BBP_CUF_ICC_BADI~MODIFY_SCREEN........................................49

4.10.1.4 IF_EX_BBP_CUF_ICC_BADI~MODIFY_OUTPUT.........................................50

4.10.1.5 IF_EX_BBP_CUF_ICC_BADI~MODIFY_INPUT.............................................50

4.10.1.6 IF_EX_BBP_CUF_BADI_ICC~GET_DATA.....................................................50

4.10.1.7 IF_EX_BBP_TAX_ICC~DETERMINE_CALC_FLAG......................................51

4.10.1.8 IF_EX_BBP_TAX_ICC~CALCULATE_TAX....................................................51

4.10.1.9 RFC Call to Backend System: Function Module BBP_CALCULATE_TAX_ITEM40B................................................................52

4.10.1.10 Continuation of IF_EX_BBP_TAX_ICC~CALCULATE_TAX After Call to Backend FI System..........................................................................................52

4.10.1.11 IF_EX_BBP_CUF_BADI_ICC~PUT_DATA................................................53

4.10.1.12 IF_EX_BBP_CUF_ICC_BADI~MODIFY_SCREEN...................................53

4.10.1.13 IF_EX_BBP_CUF_ICC_BADI~MODIFY_OUTPUT....................................53

4.10.2 Chronological Sequence When Adding an Item to the SC..............................53

4.10.2.1 IF_EX_BBP_CUF_ICC_BADI~MODIFY_INPUT.............................................53

4.10.2.2 IF_EX_BBP_CUF_BADI_ICC~GET_DATA.....................................................53

4.10.2.3 IF_EX_BBP_TAX_ICC~DETERMINE_CALC_FLAG......................................53

4.10.2.4 IF_EX_BBP_TAX_ICC~CALCULATE_TAX....................................................54

4.10.2.5 RFC Call to Backend System: Function Module BBP_CALCULATE_TAX_ITEM40B................................................................54

4.10.2.6 IF_EX_BBP_CUF_ICC_BADI~MODIFY_INPUT.............................................54

4.10.2.7 IF_EX_BBP_CUF_BADI_ICC~GET_DATA.....................................................54

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 3 of 54

Page 4: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

4.10.2.8 IF_EX_BBP_TAX_ICC~DETERMINE_CALC_FLAG......................................54

4.10.2.9 IF_EX_BBP_TAX_ICC~CALCULATE_TAX....................................................54

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 4 of 54

Page 5: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

1 Organization

1.1 Project Team / Development Team

Name Company Project Role(s) / Comments

Jan-Klaas Heinsohn Software Developer

Bernd Kaulfuss Software Developer

Hermann Resch Software Developer

2 Glossary

Term, definition

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 5 of 54

Page 6: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

3 Aspects of Brazilian Localization

3.1 Brazil-Specific Fields in EBP Product Master

The additional fields needed in Brazil are described in the specification document. These are the NCM code (also known as tax tariff code), the material usage, the material origin, the pro-duced-in-house indicator, and the CFOP category.

The fields are transferred from the material master of the R/3 backend systems to the product master of the EBP system during the initial download of backend materials. When these fields are changed in the backend systems, the changes are replicated in the EBP system as well (delta download).

In the EBP product master, the Brazilian fields are stored in the following fields:

NCM code: tax tariff code

Material usage: tax type MTUS, tax groups 1 - 3

Material origin: tax type MTOR, tax groups 0 - 2

Produced in-house: tax type MTOR, tax group 3

Mat. CFOP category: tax type CFOP, tax groups customized by user

The following screenshot shows an example of the screen in the EBP product master (transac-tion COMMPR01) where the fields can be found.

Note 522417 describes the details of the product master mapping.

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 6 of 54

Page 7: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

3.2 Brazil-Specific Fields in Procurement Documents

The shopping cart (SC) and local purchase order (PO) use the same data structures; therefore both are referred to here as procurement documents. The item structure is extended by the ad-ditional fields needed in Brazil.

The following screenshot shows the item details of a shopping cart that is just being created. All Brazil-specific modifications on the user interface are contained in this screen.

When a shopping cart is being created, the 5 Brazilian extra fields can be found on the Basic data tabstrip below the standard fields as shown in the screenshot. All field entries are checked against CRM tax types / tax groups and the tax tariff code, respectively.

When you order products that are in the EBP product master data (replicated from R/3 backends or local ones), only the field Tax tariff code (NCM code) is editable. This is the same logic like in R/3.

When you order goods by entering a description (which will lead to the creation of a purchase requisition), then all fields are open for entries.

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 7 of 54

Page 8: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

3.3 Catalog Integration

Brazil-specific data can be stored in the five customer fields NEW_ITEM-CUST_FIELD1 to NEW_ITEM-CUST_FIELD5 specified in the Open Catalog Interface (OCI). By implementing a customer BAdI in the EBP system, these fields can be transferred to the item fields of the pro-curement document according to idividual requirements. Especially, the additional Brazil-spe-cific fields can be provided with catalog data in this BAdI.

3.4 Creation of Backend Documents

When a shopping cart is ordered, there are three kinds of backend documents which can be generated out of it, depending on the Customizing:

reservations

purchase order requisitions

purchase orders

In reservations, Brazil-specific fields do not play a role anyway. The R/3 purchase order requisi-tions do not contain these fields either, so no extra localization in EBP is present.

The backend PO’s created by EBP will contain the additional fields.

3.5 Tax Calculation

Brazilian taxes are calculated in the shopping cart. The additional fields are considered in the tax calculation. The tax calculation is performed in the FI backend system you assigned in the organizational model in EBP.

The tax details are displayed in an additional table on the item detail screens as shown in the screenshot above. For each tax group (corresponding to a condition type) of an item, a separate line is displayed. The values are taken from the pricing-procedure results table that is returned by the backend tax calculation.

The tax regions of the sender (ship-from) and receiver (ship-to) are determined as follows:

Ship-from

If you specify a vendor on the tabstrip Sources of supply of the item details, the tax region of this vendor is taken. This vendor can be deducted from a purchase info record if there is one present in the backend system or it can also be taken from the catalog, according to the stand-ard EBP procedure.

If you do not specify a vendor, the ship-from value is initial. For ICMS tax, e.g., this means that the default rates will be taken.

Ship-to

If you specify a ship-to address on the tabstrip Ship-To Address in the item details, the tax re-gion is taken from that information.

Otherwise, the ship-to tax region is determined from the address of the recipient. This is the ad-dress of the organizational unit the user is assigned to in the organizational model.

3.5.1 Note on Recalculation of Taxes

Since the conventional PBO/PAI logic of R/3 is not present on the EBP screens that are dis-played in a web browser by HTML, the recalculation of taxes is not being triggered everytime

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 8 of 54

Page 9: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

tax-relevant data are changed on the screens. For example, if you change the NCM code, the redetermination of the tax rates is not triggered after pressing the Enter key. To achieve this, you have to switch to a different screen, i.e. to another tabstrip or to the shopping cart overview.

However, the changes will be considered already when returning to the item overview screen and of course when ordering the shopping cart.

4 Detailed Design

4.1 Brazilian Data Structures

4.1.1 BBP_CUF_ATTR_BR

Contains the five Brazil-specific item fields that are derived from the product master data and/or entered manually.

Component Component Type DType Length Dec. Pl. Description

STEUC CRMT_TAX_TARIFF_CODE CHAR 16 0 Tax Tariff Code

J_1BMATUSE J_1BMATUSE CHAR 1 0 Usage of the material

J_1BMATORG J_1BMATORG CHAR 1 0 Origin of the material

J_1BOWNPRO J_1BOWNPRO CHAR 1 0 Produced in-house

J_1BINDUST J_1BINDUS3 CHAR 2 0 Material CFOP category

4.1.2 BBP_CUF_TAX_BR

Contains tax data of up to five tax lines for an item. The corresponding fields of the pricing-procedure results table returned by the function module CALCULATE_TAX_ITEM are stored in these fields.

Component Component Type DType Length Dec. Pl. Description

KSCHL1 KSCHL CHAR 4 0 Condition typeTAXTYP1 CHAR4 CHAR 4 0 Not More Closely Defined Area,

Possibly Used for PatchlevelsKAWRT1 KAWRT CURR 15 2 Condition base valueKBETR1 KBETR CURR 11 2 Rate (condition amount or percent-

age)WAERS1 WAERS CUKY 5 0 Currency KeyKPEIN1 KPEIN DEC 5 0KMEIN1 KMEIN UNIT 3 0 Condition UnitKVSL11 KVSL1 CHAR 3 0STAZF1 CHAR1 CHAR 1 0 Single-character flagKWERT1 KWERT CURR 13 2 Condition valueKSCHL2 KSCHL CHAR 4 0 Condition typeTAXTYP2 CHAR4 CHAR 4 0 Not More Closely Defined Area,

Possibly Used for PatchlevelsKAWRT2 KAWRT CURR 15 2 Condition base valueKBETR2 KBETR CURR 11 2 Rate (condition amount or percent-

age)WAERS2 WAERS CUKY 5 0 Currency KeyKPEIN2 KPEIN DEC 5 0KMEIN2 KMEIN UNIT 3 0 Condition UnitKVSL12 KVSL1 CHAR 3 0STAZF2 CHAR1 CHAR 1 0 Single-character flagKWERT2 KWERT CURR 13 2 Condition valueKSCHL3 KSCHL CHAR 4 0 Condition typeTAXTYP3 CHAR4 CHAR 4 0 Not More Closely Defined Area,

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 9 of 54

Page 10: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

Component Component Type DType Length Dec. Pl. Description

KSCHL1 KSCHL CHAR 4 0 Condition typePossibly Used for Patchlevels

KAWRT3 KAWRT CURR 15 2 Condition base valueKBETR3 KBETR CURR 11 2 Rate (condition amount or percent-

age)WAERS3 WAERS CUKY 5 0 Currency KeyKPEIN3 KPEIN DEC 5 0KMEIN3 KMEIN UNIT 3 0 Condition UnitKVSL13 KVSL1 CHAR 3 0STAZF3 CHAR1 CHAR 1 0 Single-character flagKWERT3 KWERT CURR 13 2 Condition valueKSCHL4 KSCHL CHAR 4 0 Condition typeTAXTYP4 CHAR4 CHAR 4 0 Not More Closely Defined Area,

Possibly Used for PatchlevelsKAWRT4 KAWRT CURR 15 2 Condition base valueKBETR4 KBETR CURR 11 2 Rate (condition amount or percent-

age)WAERS4 WAERS CUKY 5 0 Currency KeyKPEIN4 KPEIN DEC 5 0KMEIN4 KMEIN UNIT 3 0 Condition UnitKVSL14 KVSL1 CHAR 3 0STAZF4 CHAR1 CHAR 1 0 Single-character flagKWERT4 KWERT CURR 13 2 Condition valueKSCHL5 KSCHL CHAR 4 0 Condition typeTAXTYP5 CHAR4 CHAR 4 0 Not More Closely Defined Area,

Possibly Used for PatchlevelsKAWRT5 KAWRT CURR 15 2 Condition base valueKBETR5 KBETR CURR 11 2 Rate (condition amount or percent-

age)WAERS5 WAERS CUKY 5 0 Currency KeyKPEIN5 KPEIN DEC 5 0

KMEIN5KMEIN

UNIT 3 0 Condi-tion Unit

KVSL15 KVSL1 CHAR 3 0STAZF5 CHAR1 CHAR 1 0 Single-character flagKWERT5 KWERT CURR 13 2 Condition value

4.1.3 BBP_CUF_ITEM_BR

Includes the above two data structures.

Component Component Type Description

.INCLUDE BBP_CUF_ATTR_BR Brasilian Fields in SC/PO-Item

.INCLUDE BBP_CUF_TAX_BR Detail Data - Brazilian Tax

4.1.4 BBP_CUF_ITEM_SC_BR

This include contains the same fields as BBP_CUF_ITEM_BR (section 4.1.3). It is used in the data structures of the shopping cart items.

4.1.5 BBP_CUF_ITEM_PO_BR

This include contains the same fields as BBP_CUF_ITEM_BR (section 4.1.3). It is used in the data structures of the items of a local purchase order.

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 10 of 54

Page 11: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

4.1.6 CI_BBP_ITEM

This is the customer include to which customers can append their own additional item fields. It is also used to include SAP standard country-specific fields. If the customer wants to use country-specific item fields, the respective include structure has to be inserted into this include.

This include is present in the data types BBPS_CUF_ITEM, BBP_BE_IV_IT, and BBP_PDS_IGP.

4.2 BAdI BBP_CUF_BADI_ICC

This BAdI controls the data transfer to/from the country-specific screen on which the additional country-specific fields are displayed.

Interface: IF_EX_BBP_CUF_BADI_ICC

Brazil-specific implementation: BBP_CUF_BADI_ICC_BR

Name of implementing class: CL_IM_BBP_CUF_BADI_ICC_BR

4.2.1 Method PUT_DATA

Parameter Type V O Typing Reference Type Default Value

IS_HEADER Imp. X X Type BBP_PDS_HEADER

IS_ITEM Imp. X X Type BBP_PDS_ITEM

IS_ACC Imp. X X Type BBP_PDS_ACC

IV_DOC_TYPE Imp. X Type CRMD_ORDERADM_H-OBJECT_TYPE

IV_INCLUDE_NAME Imp. X Type DD03P-TABNAME

IV_MODE Imp. X Type C

IT_DD03P Imp. X Type DD03TTYP

EV_REPID Exp. Type SY-REPID

EV_DYNNR Exp. Type SY-DYNNR

FLT_VAL Imp. X Type INTCA

METHOD if_ex_bbp_cuf_badi_icc~put_data .

* Map the tax details that are stored in "customer" fields of the item* to the table with tax details that is displayed on screen 0200.* Tell the application that not the standard screen 0100 of SAPLBBP_CUF* shall be displayed in the customer-fields subscreen of the item* details, but instead the screen 0200 of SAPLBBP_ICC.

IF is_item IS INITIAL. CLEAR: ev_repid, ev_dynnr. RETURN. ELSE. ev_repid = 'SAPLBBP_ICC'. ev_dynnr = '0200'. ENDIF.

CALL FUNCTION 'BBP_ICC_PUT_DATA' EXPORTING is_item = is_item.

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 11 of 54

Page 12: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

ENDMETHOD. "IF_EX_BBP_CUF_BADI_ICC~PUT_DATA

4.2.2 Method GET_DATA

Parameter Type V O Typing Reference Type Default Value

EV_OKCODE Exp. Type SY-UCOMM

ES_HEADER Cha. Type BBP_PDS_HEADER

ES_ITEM Cha. Type BBP_PDS_ITEM

ES_ACC Cha. Type BBP_PDS_ACC

FLT_VAL Imp. X Type INTCA

METHOD if_ex_bbp_cuf_badi_icc~get_data .

* This method can be used to bring modifications on screens different* from the standard screen 0100 in SAPLBBP_CUF back to the item. The* different screen is set in the method put_data.* Since the alternative screen 0200 in SAPLBBP_ICC that we use* includes the standard screen 0100 and only adds a table control* that displays the tax details, no further changes can be made.* Therefore, nothing is to be done here.

ENDMETHOD. "IF_EX_BBP_CUF_BADI_ICC~GET_DATA

4.3 BadI BBP_CUF_ICC_BADI

This BAdI is used to modify the screen control of the additional country-specific fields and to fill these fields with values controlled by the program.

Interface: IF_EX_BBP_CUF_ICC_BADI

Brazil-specific implementation: BBP_CUF_ICC_BADI_BR

Name of implementing class: CL_IM_BBP_CUF_ICC_BADI_BR

4.3.1 Method MODIFY_SCREEN

Parameter Type V O Typing Reference Type Default Value

FLT_VAL Imp. X Type INTCA

IV_STRUCTURE_TYPE Imp Type DD03P-TABNAME

IV_INCLUDE_NAME Imp. Type DD03P-TABNAME

IV_DOC_TYPE Imp. Type CRMD_ORDERADM_H-OBJECT_TYPE

IV_USER Imp. Type SY-UNAME

IV_DOC_GUID Imp. Type CRMT_OBJECT_GUID

IS_HEADER Imp. Type BBP_PDS_HEADER

IS_ITEM Imp. Type BBP_PDS_ITEM

IS_ACC Imp. Type BBP_PDS_ACC

ET_FIELDS Cha. Type BBPT_CUF_DISPLAY

METHOD if_ex_bbp_cuf_icc_badi~modify_screen .

* Modify the field properties of the table control that displays the* country-specific "customer" fields.* STEUC is always editable, the other 4 Brazilian extra fields of the

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 12 of 54

Page 13: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

* material master are only editable if no product is informed.* The tax detail fields that store the values of the various taxes* are not to be displayed in this table control.

FIELD-SYMBOLS: <line> LIKE LINE OF et_fields. DATA: lt_ddic TYPE TABLE OF bdt_ddstruct, wa_ddic TYPE bdt_ddstruct, ls_br_fields TYPE bbp_cuf_item_sc_br.

MOVE-CORRESPONDING is_item TO ls_br_fields.

CALL FUNCTION 'BUS_DDSTRUC_GET' EXPORTING i_tabname = 'BBP_CUF_ITEM_SC_BR' TABLES et_ddstruct = lt_ddic EXCEPTIONS not_found = 1 OTHERS = 2.

IF sy-subrc NE 0. RETURN. ENDIF.

LOOP AT lt_ddic INTO wa_ddic. READ TABLE et_fields WITH KEY fieldname = wa_ddic-fieldname ASSIGNING <line>. IF sy-subrc NE 0. CONTINUE. ENDIF. CASE <line>-fieldname. WHEN 'STEUC'.* NCM code can always be edited. WHEN 'J_1BMATUSE' OR 'J_1BMATORG' OR 'J_1BOWNPRO' OR 'J_1BINDUST'.* These fields can be edited if no product informed IF is_item-product IS INITIAL. <line>-xinput = 'X'. ELSE. CLEAR <line>-xinput. ENDIF. WHEN OTHERS.* Tax detail fields are displayed in separate table control CLEAR <line>-xdisplay. ENDCASE. ENDLOOP.

ENDMETHOD. "IF_EX_BBP_CUF_ICC_BADI~MODIFY_SCREEN

4.3.2 Method MODIFY_INPUT

Parameter Type V O Typing Reference Type Default Value

FLT_VAL Imp. X Type INTCA

IV_FIELDNAME Imp. Type DD03P-FIELDNAME

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 13 of 54

Page 14: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

Parameter Type V O Typing Reference Type Default Value

IV_INCLUDE_NAME Imp. Type DD03P-TABNAME

IV_DOC_TYPE Imp. Type CRMD_ORDERADM_H-OBJECT_TYPE

IV_STRUCTURE_TYPE Imp Type DD03P-TABNAME

IV_MODE Imp. Type C

IV_DOC_GUID Imp. Type CRMT_OBJECT_GUID

IV_VALUE Imp. Type CUF_VALUE

IS_HEADER Imp. Type BBP_PDS_HEADER

IS_ITEM Imp. Type BBP_PDS_ITEM

IS_ACC Imp. Type BBP_PDS_ACC

EV_VALUE Exp. Type CUF_VALUE

METHOD if_ex_bbp_cuf_icc_badi~modify_input .

* This method can be used to modify the appearance of the customer* fields in the table control of screen 100 in SAPLBBP_PDH_CUF.* The transfer of changed data back to the item is handled automatically* by the standard coding.* Since we needn't format any customer field differently, nothing is to* be done here for us.

* The value is not modified. ev_value = iv_value.

ENDMETHOD. "IF_EX_BBP_CUF_ICC_BADI~MODIFY_INPUT

4.3.3 Method MODIFY_OUTPUT

Parameter Type V O Typing Reference Type Default Value

FLT_VAL Imp. X Type INTCA

IV_FIELDNAME Imp. Type DD03P-FIELDNAME

IV_INCLUDE_NAME Imp. Type DD03P-TABNAME

IV_DOC_TYPE Imp. Type CRMD_ORDERADM_H-OBJECT_TYPE

IV_STRUCTURE_TYPE Imp Type DD03P-TABNAME

IV_MODE Imp. Type C

IV_DOC_GUID Imp. Type CRMT_OBJECT_GUID

IV_VALUE Imp. Type CUF_VALUE

IS_HEADER Imp. Type BBP_PDS_HEADER

IS_ITEM Imp. Type BBP_PDS_ITEM

IS_ACC Imp. Type BBP_PDS_ACC

EV_VALUE Exp. Type CUF_VALUE

METHOD if_ex_bbp_cuf_icc_badi~modify_output .

* Read data from product master in case the value of the* Brazil-specific "customer" field is initial.* The export variable ev_value gets the value of the Brazilian field* that corresponds to the "customer" field which name is in* iv_fieldname.

DATA: lt_set TYPE crmt_pr_tax_tab,

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 14 of 54

Page 15: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

wa_set TYPE crmt_pr_tax.

IF is_item-product IS INITIAL OR " No product informed NOT iv_value IS INITIAL OR " Value already determined iv_mode <> 'C'. " Not in "create" mode* Don't read product master in these cases ev_value = iv_value. RETURN. ENDIF.

* The Brazilian extra fields are stored in the tax type/tax group* of the product master. The NCM code is stored in the tax tariff code.* Read the tax types of the product: CALL FUNCTION 'CRM_CRMM_PR_TAX_READ_WITH_PROD' EXPORTING iv_product_guid = is_item-product IMPORTING et_set = lt_set.

CASE iv_fieldname. WHEN 'STEUC'. READ TABLE lt_set INTO wa_set WITH KEY tax_cty = 'BR' tax_type = 'CFOP'. IF sy-subrc NE 0. RETURN. ENDIF. MOVE wa_set-tax_tariff_code TO ev_value.

WHEN 'J_1BINDUST'. READ TABLE lt_set INTO wa_set WITH KEY tax_cty = 'BR' tax_type = 'CFOP'. IF sy-subrc NE 0. RETURN. ENDIF. MOVE wa_set-tax_group(2) TO ev_value.

WHEN 'J_1BMATUSE'. READ TABLE lt_set INTO wa_set WITH KEY tax_cty = 'BR' tax_type = 'MTUS'. IF sy-subrc NE 0. RETURN. ENDIF. MOVE wa_set-tax_group(1) TO ev_value.

WHEN 'J_1BMATORG'. READ TABLE lt_set INTO wa_set WITH KEY tax_cty = 'BR' tax_type = 'MTOR'. IF sy-subrc NE 0. RETURN. ENDIF. CASE wa_set-tax_group(1). WHEN '0'.* national ev_value = '0'. WHEN '1'.* imported directly

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 15 of 54

Page 16: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

ev_value = '1'. WHEN '2'.* imported, purchased locally ev_value = '2'. WHEN '3'.* national, produced in-house (CRM coding of matorg and ownpro) ev_value = '0'. ENDCASE.

WHEN 'J_1BOWNPRO'. READ TABLE lt_set INTO wa_set WITH KEY tax_cty = 'BR' tax_type = 'MTOR'. IF sy-subrc NE 0. RETURN. ENDIF.* CRM coding of matorg and ownpro: Ownpro is stored as value '3'* in matorg: IF wa_set-tax_group(1) = '3'. ev_value = 'X'. ELSE. CLEAR ev_value. ENDIF.

ENDCASE.

ENDMETHOD. "IF_EX_BBP_CUF_ICC_BADI~MODIFY_OUTPUT

4.4 BAdI BBP_DOC_CHECK_ICC

This BAdI serves to check the contents of country-specific additional fields before the posting of a document. Here, plausibility checks, consistency checks, calls to backend systems, etc. can be performed.

No Brazil-specific implementation has been created so far because all Brazilian fields have check tables assigned to them which prevents the user to enter values that are not allowed.

4.5 BAdI BBB_TAX_ICC

This BAdI performs country-specific tax calculation.

Interface: IF_EX_BBP_TAX_ICC

Brazil-specific implementation: BBP_TAX_ICC_BR

Name of implementing class: CL_IM_BBP_TAX_ICC_BR

4.5.1 Attributes of Class CL_IM_BBP_TAX_ICC_BR

Attribute Level Visibility Typing Reference Type

MT_OLD_ITEM Instance Attribute Private Type BBPT_PD_ITEM

MT_OLD_PARTNER Instance Attribute Private Type BBPT_PD_PARTNER

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 16 of 54

Page 17: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

4.5.2 Method CALCULATE_TAX

Parameter Type V O Typing Reference Type Default Value

FLT_VAL Imp. X Type INTCA

IV_DEST Imp. X Type RFCDEST

IT_ITEM Imp. X Type BBPT_PD_ITEM

IT_PARTNER Imp. X Type BBPT_PD_PARTNER

IS_HEADER Imp. X Type BBP_PDS_HEADER

IV_LOGSYS Imp. X Type LOGSYS

EV_CALCULATED Exp. Type XFELD

ET_TAX_COND Exp. Type BBPT_TAX_COMM_OUT

CT_BAPIRET Cha. Type BBPT_RETURN

IT_TAX Cha. Type BBPT_PD_TAX

METHOD if_ex_bbp_tax_icc~calculate_tax .

CONSTANTS: cs_zero_tax_fields TYPE bbp_cuf_tax_br VALUE IS INITIAL.

DATA: lt_item_be TYPE TABLE OF bbp_tax_comm, lt_tax_map TYPE TABLE OF bbp_tax_item_r3, lt_partner_sf TYPE TABLE OF bbp_pds_partner, lt_partner_vendor TYPE TABLE OF bbp_pds_partner, lt_partner_st TYPE TABLE OF bbp_pds_partner, lt_partner_recipient TYPE TABLE OF bbp_pds_partner, wa_return TYPE bapiret2, wa_item_bbp LIKE LINE OF it_item, wa_item_be LIKE LINE OF lt_item_be, wa_tax_map LIKE LINE OF lt_tax_map, wa_partner TYPE bbp_pds_partner, wa_tax LIKE LINE OF it_tax, wa_tax_cond LIKE LINE OF et_tax_cond, ls_header TYPE bbp_pds_header, ls_brazil_fields TYPE bbp_cuf_item_sc_br, lv_product_id TYPE comt_product_id, lv_vendor TYPE bu_partner, lv_partner_guid TYPE bbp_pds_partner-p_guid, ls_partner_to TYPE bbp_pds_partner, ls_partner_from TYPE bbp_pds_partner, lv_error TYPE xfeld, lv_partner_func_to TYPE crmt_partner_pft, lv_partner_func_from TYPE crmt_partner_pft, lv_tabix LIKE sy-tabix, lt_update_items TYPE TABLE OF bbp_pds_item, wa_update_items LIKE LINE OF lt_update_items.

DATA: lt_ddic TYPE TABLE OF bdt_ddstruct, wa_ddic TYPE bdt_ddstruct, lv_length TYPE i, lv_offset TYPE i, lv_index(1) TYPE c, lv_save_index TYPE i, lv_name TYPE bdt_ddstruct-fieldname, lv_type(1) TYPE c.

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 17 of 54

Page 18: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

DATA: ls_itmigp TYPE bbp_pdigp, ls_itmpset TYPE bbp_pdpset, ls_itmbei TYPE bbp_pdbei, ls_com TYPE bbp_pds_igp_icom.

FIELD-SYMBOLS: <item_field> TYPE ANY, <tax_field> TYPE ANY, <item> LIKE LINE OF it_item.

ev_calculated = 'X'.

* Read various partners into internal tables

* Ship From CALL FUNCTION 'BBP_PARTNER_TYPE_SELECT' EXPORTING partner_ftyp = '0018' "Ship From TABLES i_partner = it_partner e_partner = lt_partner_sf.

* Vendor CALL FUNCTION 'BBP_PARTNER_TYPE_SELECT' EXPORTING partner_ftyp = '0012' "Vendor TABLES i_partner = it_partner e_partner = lt_partner_vendor.

* Ship To CALL FUNCTION 'BBP_PARTNER_TYPE_SELECT' EXPORTING partner_ftyp = '0017' "Ship To TABLES i_partner = it_partner e_partner = lt_partner_st.

* Recipient CALL FUNCTION 'BBP_PARTNER_TYPE_SELECT' EXPORTING partner_ftyp = '0002' " Recipient TABLES i_partner = it_partner e_partner = lt_partner_recipient.

* Loop at all items LOOP AT it_item INTO wa_item_bbp.

REFRESH lt_tax_map. READ TABLE it_tax INTO wa_tax WITH KEY p_guid = wa_item_bbp-guid. wa_tax_map-mwskz = wa_tax-tax_code. APPEND wa_tax_map TO lt_tax_map. CALL FUNCTION 'BBP_TAX_MAP_TAX_CODE' EXPORTING iv_logsys = iv_logsys TABLES t_tax_r3 = lt_tax_map.

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 18 of 54

Page 19: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

READ TABLE lt_tax_map INDEX 1 INTO wa_tax_map.

CALL FUNCTION 'BBP_PRODUCT_PD_MAP_BE' EXPORTING i_product_guid = wa_item_bbp-product i_target_logsys = iv_logsys IMPORTING e_be_product_id = lv_product_id EXCEPTIONS mapping_error = 1 no_id_determined = 2 OTHERS = 3.

IF sy-subrc <> 0. CLEAR lv_product_id. ENDIF.

* Determine ship-from region* -------------------------- CLEAR wa_partner.* Partner function: ship-from* Try with item GUID READ TABLE lt_partner_sf INTO wa_partner WITH KEY p_guid = wa_item_bbp-guid. IF sy-subrc <> 0.* Try with header GUID READ TABLE lt_partner_sf INTO wa_partner WITH KEY p_guid = is_header-guid. ENDIF. IF wa_partner IS INITIAL.* Partner function: vendor* Try with item GUID READ TABLE lt_partner_vendor INTO wa_partner WITH KEY p_guid = wa_item_bbp-guid. IF sy-subrc <> 0.* Try with header GUID READ TABLE lt_partner_vendor INTO wa_partner WITH KEY p_guid = is_header-guid. ENDIF. ENDIF. wa_item_be-txreg_sf = wa_partner-region. IF wa_item_be-txreg_sf IS INITIAL. IF 1 = 2. MESSAGE i024(bbp_tax). ENDIF. wa_return-type = 'I'. wa_return-id = 'BBP_TAX'. wa_return-number = '024'. APPEND wa_return TO ct_bapiret. ENDIF.

* Determine ship-to region* ------------------------ CLEAR wa_partner.* Partner function: ship-to* Try with item GUID READ TABLE lt_partner_st INTO wa_partner WITH KEY p_guid = wa_item_bbp-guid. IF sy-subrc <> 0.* Try with header GUID READ TABLE lt_partner_st INTO wa_partner WITH KEY p_guid = is_header-guid.

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 19 of 54

Page 20: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

ENDIF. IF wa_partner IS INITIAL.* Partner function: recipient* Try with item GUID READ TABLE lt_partner_recipient INTO wa_partner WITH KEY p_guid = wa_item_bbp-guid. IF sy-subrc <> 0.* Try with header GUID READ TABLE lt_partner_recipient INTO wa_partner WITH KEY p_guid = is_header-guid. ENDIF. ENDIF. wa_item_be-txjcd = wa_partner-region. wa_item_be-txreg_st = wa_partner-region. IF wa_item_be-txjcd IS INITIAL. IF 1 = 2. MESSAGE i025(bbp_tax). ENDIF. wa_return-type = 'I'. wa_return-id = 'BBP_TAX'. wa_return-number = '025'. APPEND wa_return TO ct_bapiret. ENDIF.

* Determine vendor number* -----------------------* Determine the vendor number for this item READ TABLE lt_partner_vendor INTO wa_partner WITH KEY p_guid = wa_item_bbp-guid. IF sy-subrc <> 0.* Determine vendor number for header READ TABLE lt_partner_vendor INTO wa_partner WITH KEY p_guid = is_header-guid. ENDIF. IF sy-subrc <> 0.* No vendor information CLEAR lv_vendor. ELSE.* Get backend vendor number (LIFNR) MOVE wa_partner-partner_no TO lv_partner_guid. CALL FUNCTION 'BUPA_NUMBERS_READ' EXPORTING iv_partner_guid = lv_partner_guid IMPORTING ev_partner = lv_vendor EXCEPTIONS no_partner_specified = 1 no_valid_record_found = 2 inconsistent_parameters = 3 OTHERS = 4. IF sy-subrc <> 0. CLEAR lv_vendor. ENDIF. ENDIF.

MOVE-CORRESPONDING wa_item_bbp TO wa_item_be. wa_item_be-guid = wa_item_bbp-guid. wa_item_be-bukrs = wa_item_bbp-be_co_code. wa_item_be-budat = is_header-posting_date. wa_item_be-waers = wa_item_bbp-currency. wa_item_be-kposn = wa_item_bbp-number_int. wa_item_be-mwskz = wa_tax_map-mwskz.

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 20 of 54

Page 21: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

wa_item_be-shkzg = 'S'. wa_item_be-wrbtr = wa_item_bbp-value. wa_item_be-wmwst = space. wa_item_be-lifnr = lv_vendor. wa_item_be-ekorg = space. wa_item_be-gsber = space. wa_item_be-llief = lv_vendor. wa_item_be-matnr = lv_product_id. wa_item_be-werks = wa_item_bbp-be_plant. wa_item_be-matkl = wa_item_bbp-category_id. wa_item_be-meins = wa_item_bbp-unit. wa_item_be-mglme = wa_item_bbp-quantity.

* Brazilian fields are only present in the item structure if they were* included during the implementation. Therefore this* move-corresponding to avoid syntax errors. MOVE-CORRESPONDING wa_item_bbp TO ls_brazil_fields. wa_item_be-mtorg = ls_brazil_fields-j_1bmatorg. wa_item_be-mtuse = ls_brazil_fields-j_1bmatuse. wa_item_be-ownpr = ls_brazil_fields-j_1bownpro. wa_item_be-mtorg = ls_brazil_fields-j_1bmatorg.

APPEND wa_item_be TO lt_item_be.

ENDLOOP.

CALL FUNCTION 'BBP_CALCULATE_TAX_ITEM40B' DESTINATION iv_dest EXPORTING iv_invoice = space TABLES it_item = lt_item_be et_bapireturn = ct_bapiret et_tax_cond = et_tax_cond.

CALL FUNCTION 'BUS_DDSTRUC_GET' EXPORTING i_tabname = 'BBP_TAX_COMM_OUT' TABLES et_ddstruct = lt_ddic EXCEPTIONS not_found = 1 OTHERS = 2.

IF sy-subrc NE 0. RETURN. ENDIF.

LOOP AT lt_item_be INTO wa_item_be.

READ TABLE it_tax INTO wa_tax WITH KEY p_guid = wa_item_be-guid. wa_tax-tax_amount = wa_item_be-wmwst. MODIFY it_tax INDEX sy-tabix FROM wa_tax.

READ TABLE it_item ASSIGNING <item> WITH KEY guid = wa_item_be-guid.* Delete all tax fields of the item MOVE-CORRESPONDING cs_zero_tax_fields TO <item>.

lv_index = '0'. LOOP AT et_tax_cond INTO wa_tax_cond

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 21 of 54

Page 22: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

WHERE p_guid = wa_item_be-guid AND NOT taxtyp IS initial.

ADD 1 TO lv_index. LOOP AT lt_ddic INTO wa_ddic.

CONCATENATE wa_ddic-fieldname lv_index INTO lv_name. ASSIGN COMPONENT lv_name OF STRUCTURE <item> TO <item_field>. IF NOT sy-subrc IS INITIAL.* Fieldname is P_GUID or COUNTER ==> skip these fields CONTINUE. ENDIF. ASSIGN COMPONENT wa_ddic-fieldname OF STRUCTURE wa_tax_cond TO <tax_field>.

DESCRIBE FIELD <tax_field> TYPE lv_type. IF lv_type = 'P'.* Currency fields contain negative tax values => take abs. value <item_field> = abs( <tax_field> ). ELSE. <item_field> = <tax_field>. ENDIF.

ENDLOOP.

ENDLOOP.

ENDLOOP.

CALL FUNCTION 'BBP_PROCDOC_GETDETAIL' EXPORTING i_guid = is_header-guid i_object_type = is_header-object_type i_with_items = 'X' IMPORTING e_header = ls_header TABLES e_item = lt_update_items.

LOOP AT lt_update_items INTO wa_update_items.

READ TABLE it_item INTO wa_item_bbp WITH KEY guid = wa_update_items-guid.

MOVE-CORRESPONDING wa_item_bbp TO ls_brazil_fields. MOVE-CORRESPONDING ls_brazil_fields TO wa_update_items.

MOVE-CORRESPONDING wa_update_items TO ls_itmigp. MOVE-CORRESPONDING wa_update_items TO ls_itmpset. MOVE-CORRESPONDING wa_update_items TO ls_itmbei. CALL FUNCTION 'BBP_ITMPROC_UPDATE' EXPORTING i_guid = wa_update_items-guid i_obj_type = is_header-object_type i_itmigp = ls_itmigp i_itmpset = ls_itmpset i_itmbei = ls_itmbei i_com = ls_com iv_without_checks = 'X'.

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 22 of 54

Page 23: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

ENDLOOP.

ENDMETHOD. "IF_EX_BBP_TAX_ICC~CALCULATE_TAX

4.5.3 Method DETERMINE_CALC_FLAG

Parameter Type V O Typing Reference Type Default Value

IV_TAX_TOOL Imp. Type BBP_TAX_DEST-TAX_SYS

IS_HEADER Imp. Type BBP_PDS_HEADER

IT_ITEM Imp. Type BBPT_PD_ITEM

IT_TAX Imp. Type BBPT_PD_TAX

IT_PARTNER Imp. Type BBPT_PD_PARTNER

IT_ACC Imp. Type BBPT_PD_ACC

CV_XCALCULATE Cha. Type XFELD

FLT_VAL Imp. X Type INTCA

METHOD if_ex_bbp_tax_icc~determine_calc_flag .* Taxes have to be recalculated in some situations additional to the* standard behaviour of EBP.

DATA: wa_item LIKE LINE OF it_item, wa_old_item LIKE LINE OF it_item, lt_partner TYPE bbpt_pd_partner, wa_old_partner LIKE LINE OF lt_partner, lv_item_brazil TYPE bbp_cuf_item_br, lv_old_item_brazil TYPE bbp_cuf_item_br.

* Check if relevant item data have changed LOOP AT it_item INTO wa_item.

READ TABLE mt_old_item INTO wa_old_item WITH KEY guid = wa_item-guid.

* Has delivery date changed? IF wa_item-deliv_date <> wa_old_item-deliv_date. cv_xcalculate = 'X'. mt_old_item[] = it_item[]. ENDIF.

* This is necessary to avoid syntax errors in systems that don't have* Brazilian structures included: MOVE-CORRESPONDING wa_item TO lv_item_brazil. MOVE-CORRESPONDING wa_old_item TO lv_old_item_brazil.* Has NCM code changed? IF lv_item_brazil-steuc <> lv_old_item_brazil-steuc. cv_xcalculate = 'X'. mt_old_item[] = it_item[]. ENDIF.

ENDLOOP.

Note: Partner function types 18, 12, 17, and 8 have to be checked!Extend partner check as follows: data: lt_partner TYPE bbpt_pd_partner, lt_partner_all type bbpt_pd_partner.

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 23 of 54

Page 24: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

* Check if the ship-from has changed CALL FUNCTION 'BBP_PARTNER_TYPE_SELECT' EXPORTING partner_ftyp = '0018' "Ship from TABLES i_partner = it_partner e_partner = lt_partner. append lines of lt_partner to lt_partner_all.* Check if the vendor has changed CALL FUNCTION 'BBP_PARTNER_TYPE_SELECT' EXPORTING partner_ftyp = '0012' "Vendor TABLES i_partner = it_partner e_partner = lt_partner. append lines of lt_partner to lt_partner_all.* Check if the ship-to has changed CALL FUNCTION 'BBP_PARTNER_TYPE_SELECT' EXPORTING partner_ftyp = '0017' "Ship To TABLES i_partner = it_partner e_partner = lt_partner. append lines of lt_partner to lt_partner_all.* Check if the recipient has changed CALL FUNCTION 'BBP_PARTNER_TYPE_SELECT' EXPORTING partner_ftyp = '0002' "Recipient TABLES i_partner = it_partner e_partner = lt_partner. append lines of lt_partner to lt_partner_all.

IF lt_partner_all[] <> mt_old_partner[]. cv_xcalculate = 'X'. mt_old_partner[] = lt_partner_all[]. ENDIF.

ENDMETHOD. "IF_EX_BBP_TAX_ICC~DETERMINE_CALC_FLAG

4.6 BAdI BBP_ICC_PO_MAP

This BAdI is used to before the call to the BAPI that creates a backend purchase order. For some countries, especially for Brazil, it is necessary to call the function module BAPI_PO_CRE-ATE1 instead of the older one BAPI_PO_CREATE, because only the new one has the Brazil-specific fields in its interface. The BAdI is used to map the parameters for the old BAPI that are filled by EBP to the parameters used by the new BAPI.

Interface: IF_EX_BBP_ICC_PO_MAP

Brazil-specific implementation: BBP_ICC_PO_MAP_BR

Name of implementing class: CL_IM_BBP_ICC_PO_MAP_BR

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 24 of 54

Page 25: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

4.6.1 Method MAP_STRUCTURES

Parameter Type V O Typing Reference Type

IS_HEADER Imp. Type BAPIEKKOC

IS_HEADER_ADD_DATA Imp. Type BAPIEKKOA

IS_PO_ADDRESS Imp. Type BAPIADDRESS

IV_HEADER_ADD_DATA_RELEVANT Imp. Type SELKZ

IV_ITEM_ADD_DATA_RELEVANT Imp. Type SELKZ

IT_PO_ITEMS Imp. Type BBP_PO_ITEM_SPOOL

IT_PO_ITEM_ADD_DATA Imp. Type BBP_PO_ITEM_ADD_SPOOL

IT_PO_ITEM_SCHEDULES Imp. Type BBP_PO_SCHED_SPOOL

IT_PO_ITEM_ACCOUNT_ASSIGNMENT Imp. Type BBP_PO_ACCT_SPOOL

IT_PO_ITEM_TEXT Imp. Type BBP_PO_TEXT_SPOOL

IT_PO_LIMITS Imp. Type BBP_PO_LIMIT_SPOOL

IT_PO_CONTRACT_LIMITS Imp. Type BBP_PO_LIMIT_CONTR_SPOOL

IT_PO_SERVICES Imp. Type BBP_PO_SERV_SPOOL

IT_PO_SRV_ACCASS_VALUES Imp. Type BBP_PO_SERV_ACCT_SPOOL

IT_PO_SERVICES_TEXT Imp. Type BBP_PO_SERV_TEXT_SPOOL

IT_POADDRDELIVERY Imp. Type BBPS_POADDRDELIVERY_46_TAB

FLT_VAL Imp. X Type INTCA

IT_CUF_ITEM Imp. Type BBPT_CUF_ITEM

ES_BAPIMEPOHEADER Exp. Type BBP_BAPIMEPOHEADER

ES_BAPIMEPOHEADERX Exp. Type BBP_BAPIMEPOHEADERX

ES_BAPIMEPOADDRVENDOR Exp. Type BBP_BAPIMEPOADDRVENDOR

ET_POITEM Exp. Type BBPT_BAPIMEPOITEM

ET_POITEMX Exp. Type BBPT_BAPIMEPOITEMX

ET_POADDRDELIVERY Exp. Type BBPT_BAPIMEPOADDRDELIVERY

ET_POSCHEDULE Exp. Type BBPT_BAPIMEPOSCHEDULE

ET_POSCHEDULEX Exp. Type BBPT_BAPIMEPOSCHEDULX

ET_POACCOUNT Exp. Type BBPT_BAPIMEPOACCOUNT

ET_POACCOUNTX Exp. Type BBPT_BAPIMEPOACCOUNTX

ET_POCOND Exp. Type BBPT_BAPIMEPOCOND

ET_POCONDX Exp. Type BBPT_BAPIMEPOCONDX

ET_POLIMITS Exp. Type BBP_PO_LIMIT_SPOOL

ET_POCONTRACTLIMITS Exp. Type BBP_PO_LIMIT_CONTR_SPOOL

ET_POSERVICES Exp. Type BBP_PO_SERV_SPOOL

ET_POSRVACCESSVALUES Exp. Type BBP_PO_SERV_ACCT_SPOOL

ET_POSERVICESTEXT Exp. Type BBP_PO_SERV_TEXT_SPOOL

EV_NEW_PO_CREATE Exp. Type SELKZ

method IF_EX_BBP_ICC_PO_MAP~MAP_STRUCTURES .

data: lt_dd03l type standard table of dd03l, ls_dd03l type dd03l, ls_brfields type bbp_cuf_attr_br, lv_fieldname type string, lv_fieldnamex type string.

field-symbols: <A> type any, <X> type any.

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 25 of 54

Page 26: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

Clear: es_bapimepoheader, es_bapimepoheaderx, es_bapimepoaddrvendor, ev_new_po_create.

Refresh:et_poitem, et_poitemx, et_poaddrdelivery, et_poschedule, et_poschedulex, et_poaccount, et_poaccountx, et_pocond, et_pocondx, et_polimits, et_pocontractlimits, et_poservices, et_posrvaccessvalues, et_poservicestext.

*--- set flag for calling BAPI_PO_CREATE1 ----* ev_new_po_create = 'X'.*------------------------------------------------------------**--- H E A D E R ---**------------------------------------------------------------** Move: is_header-DOC_TYPE to es_bapimepoheader-DOC_TYPE, is_header-DOC_DATE to es_bapimepoheader-DOC_DATE, is_header-CO_CODE to es_bapimepoheader-COMP_CODE, is_header-PURCH_ORG to es_bapimepoheader-PURCH_ORG, is_header-PUR_GROUP to es_bapimepoheader-PUR_GROUP, is_header-VENDOR to es_bapimepoheader-VENDOR, is_header-PO_NUMBER to es_bapimepoheader-PO_NUMBER, is_header-CREATED_BY to es_bapimepoheader-CREATED_BY.**--- fill new header from old header additional data -------* Move: is_header_add_data-PMNTTRMS to es_bapimepoheader-PMNTTRMS, is_header_add_data-DSCNT1_TO to es_bapimepoheader-DSCNT1_TO, is_header_add_data-DSCNT2_TO to es_bapimepoheader-DSCNT2_TO, is_header_add_data-DSCNT3_TO to es_bapimepoheader-DSCNT3_TO, is_header_add_data-CURRENCY to es_bapimepoheader-CURRENCY.

*--- fill change flag structure -------------------------------* refresh lt_dd03l. select * from dd03l into table lt_dd03l where tabname = 'BBP_BAPIMEPOHEADER'.

loop at lt_dd03l into ls_dd03l. concatenate 'ES_BAPIMEPOHEADER' ls_dd03l-fieldname into lv_fieldname separated by '-'. assign (lv_fieldname) to <A>. check sy-subrc is initial. if <A> is initial. else. concatenate 'ES_BAPIMEPOHEADERX' ls_dd03l-fieldname into lv_fieldnamex separated by '-'. assign (lv_fieldnamex) to <X>. if sy-subrc is initial.

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 26 of 54

Page 27: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

<X> = 'X'. endif. endif. endloop.**--- reset interval for items -> if not filled required from MEPO!! clear: es_bapimepoheaderx-ITEM_INTVL.*--- fill order date with system date when not filled from interface if es_bapimepoheader-DOC_DATE is initial. move sy-datum to es_bapimepoheader-DOC_DATE. endif. if es_bapimepoheader-agreement is initial. clear: es_bapimepoheaderx-agreement. endif. if es_bapimepoheader-CURRENCY is initial. move 'BRL' to es_bapimepoheader-CURRENCY. endif.**------------------------------------------------------------**--- V E N D O R A D R E S S ---**------------------------------------------------------------* Move: is_header-PO_NUMBER to es_bapimepoaddrvendor-PO_NUMBER, is_po_address-ADDRNUMBER to es_bapimepoaddrvendor-ADDR_NO, is_po_address-name1 to es_bapimepoaddrvendor-name, is_po_address-name2 to es_bapimepoaddrvendor-name_2, is_po_address-name3 to es_bapimepoaddrvendor-name_3, is_po_address-name4 to es_bapimepoaddrvendor-name_4, is_po_address-name_co to es_bapimepoaddrvendor-c_o_name, is_po_address-city1 to es_bapimepoaddrvendor-city, is_po_address-city2 to es_bapimepoaddrvendor-district, is_po_address-city_code to es_bapimepoaddrvendor-city_no, is_po_address-CITYP_CODE to es_bapimepoaddrvendor-DISTRCT_NO, is_po_address-CHCKSTATUS to es_bapimepoaddrvendor-CHCKSTATUS, is_po_address-POST_CODE1 to es_bapimepoaddrvendor-POSTL_COD1, is_po_address-POST_CODE2 to es_bapimepoaddrvendor-POSTL_COD2, is_po_address-POST_CODE3 to es_bapimepoaddrvendor-POSTL_COD3, is_po_address-po_box to es_bapimepoaddrvendor-po_box, is_po_address-po_box_loc to es_bapimepoaddrvendor-po_box_cit, is_po_address-CITY_CODE2 to es_bapimepoaddrvendor-PBOXCIT_NO, is_po_address-POSTALAREA to es_bapimepoaddrvendor-DELIV_DIS, is_po_address-TRANSPZONE to es_bapimepoaddrvendor-TRANSPZONE, is_po_address-STREET to es_bapimepoaddrvendor-STREET, is_po_address-STREETCODE to es_bapimepoaddrvendor-STREET_NO, is_po_address-STREETABBR to es_bapimepoaddrvendor-STR_ABBR, is_po_address-HOUSE_NUM1 to es_bapimepoaddrvendor-HOUSE_NO, is_po_address-HOUSE_NUM2 to es_bapimepoaddrvendor-HOUSE_NO2, is_po_address-STR_SUPPL1 to es_bapimepoaddrvendor-STR_SUPPL1, is_po_address-STR_SUPPL2 to es_bapimepoaddrvendor-STR_SUPPL2, is_po_address-LOCATION to es_bapimepoaddrvendor-LOCATION, is_po_address-BUILDING to es_bapimepoaddrvendor-BUILDING, is_po_address-FLOOR to es_bapimepoaddrvendor-FLOOR, is_po_address-ROOMNUMBER to es_bapimepoaddrvendor-ROOM_NO, is_po_address-COUNTRY to es_bapimepoaddrvendor-COUNTRY, is_po_address-LANGU to es_bapimepoaddrvendor-LANGU, is_po_address-REGION to es_bapimepoaddrvendor-REGION, is_po_address-SORT1 to es_bapimepoaddrvendor-SORT1, is_po_address-SORT2 to es_bapimepoaddrvendor-SORT2, is_po_address-TIME_ZONE to es_bapimepoaddrvendor-TIME_ZONE, is_po_address-TAXJURCODE to es_bapimepoaddrvendor-TAXJURCODE,

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 27 of 54

Page 28: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

is_po_address-REMARK to es_bapimepoaddrvendor-ADR_NOTES, is_po_address-DEFLT_COMM to es_bapimepoaddrvendor-COMM_TYPE, is_po_address-TEL_NUMBER to es_bapimepoaddrvendor-TEL1_NUMBR, is_po_address-TEL_EXTENS to es_bapimepoaddrvendor-TEL1_EXT, is_po_address-FAX_NUMBER to es_bapimepoaddrvendor-FAX_NUMBER, is_po_address-FAX_EXTENS to es_bapimepoaddrvendor-FAX_EXTENS, is_po_address-BUILD_LONG to es_bapimepoaddrvendor-BUILD_LONG.

*--- This fields are not available in the new structures**is_po_address-ADDRHANDLE to es_bapimepoaddrvendor- ,**is_po_address-NATION to es_bapimepoaddrvendor-,**is_po_address-DATE to es_bapimepoaddrvendor-,**is_header-DATE_FROM to es_bapimepoaddrvendor-,**is_po_address-TITLE to es_bapimepoaddrvendor- ,**is_po_address- NAME_TXT to es_bapimepoaddrvendor-,**is_po_address-HOUSE_NUM3 to es_bapimepoaddrvendor-,**is_po_address-SORT_PHN to es_bapimepoaddrvendor-**is_po_address-ADDRORIGIN to es_bapimepoaddrvendor-**is_po_address-EXTENSION1 to es_bapimepoaddrvendor-**is_po_address-EXTENSION2 to es_bapimepoaddrvendor-**is_po_address-ADDRESS_ID to es_bapimepoaddrvendor-*--- TBV**is_po_address-PO_BOX_REG to es_bapimepoaddrvendor-,**is_po_address-PO_BOX_CTY to es_bapimepoaddrvendor-,**-----------------------------------------------------------**--- I T E M ---**--- A N D ---**--- A D D I T I O N A L D A T A ---**-----------------------------------------------------------** Data: wa_poitem type bbp_bapimepoitem, wa_poitemx type bbp_bapimepoitemx, wa_po_item_add_data type BBP_BAPIEKPOA, wa_po_items type BAPIEKPOC, wa_cuf_item type BBPS_CUF_ITEM.*--- get item structure definition ----------------- refresh lt_dd03l. select * from dd03l into table lt_dd03l where tabname = 'BBP_BAPIMEPOITEM'.* Loop at it_po_items into wa_po_items.*--- get brazilian specific fields from county structures read table it_cuf_item into wa_cuf_item with key item_cuf = wa_po_items-po_item.

Note: Wrong item number!! Table IT_CUF_ITEM has items numbered with 10, 20, … Table IT_PO_ITEMS has items numbered with 1, 2, …

if sy-subrc is initial. move-corresponding wa_cuf_item to ls_brfields. move: ls_brfields-steuc to wa_poitem-bras_nbm, ls_brfields-j_1bmatuse to wa_poitem-matl_usage, ls_brfields-j_1bmatorg to wa_poitem-mat_origin, ls_brfields-j_1bownpro to wa_poitem-in_house, ls_brfields-j_1bindust to wa_poitem-indus3. endif.* Move: wa_po_items-PO_ITEM to wa_poitem-PO_ITEM,

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 28 of 54

Page 29: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

wa_po_items-MATERIAL to wa_poitem-MATERIAL, wa_po_items-PUR_MAT to wa_poitem-EMATERIAL, wa_po_items-INFO_REC to wa_poitem-INFO_REC, wa_po_items-ITEM_CAT to wa_poitem-ITEM_CAT, wa_po_items-ACCTASSCAT to wa_poitem-ACCTASSCAT, wa_po_items-AGREEMENT to wa_poitem-AGREEMENT, wa_po_items-AGMT_ITEM to wa_poitem-AGMT_ITEM, wa_po_items-STORE_LOC to wa_poitem-STGE_LOC, wa_po_items-MAT_GRP to wa_poitem-MATL_GROUP, wa_po_items-SHORT_TEXT to wa_poitem-SHORT_TEXT, wa_po_items-DISTRIB to wa_poitem-DISTRIB, wa_po_items-PART_INV to wa_poitem-PART_INV, wa_po_items-KANBAN_IND to wa_poitem-KANBAN_IND, wa_po_items-PLANT to wa_poitem-PLANT, wa_po_items-UNIT to wa_poitem-PO_UNIT, wa_po_items-NET_PRICE to wa_poitem-NET_PRICE, "Dezimalstellen!! wa_po_items-PRICE_UNIT to wa_poitem-PRICE_UNIT, wa_po_items-CONV_NUM1 to wa_poitem-CONV_NUM1, wa_po_items-CONV_DEN1 to wa_poitem-CONV_DEN1, wa_po_items-ORDERPR_UN to wa_poitem-ORDERPR_UN, wa_po_items-PCKG_NO to wa_poitem-PCKG_NO, wa_po_items-PROMOTION to wa_poitem-R_PROMO, wa_po_items-ACKN_REQD to wa_poitem-ACKN_REQD, wa_po_items-TRACKINGNO to wa_poitem-TRACKINGNO, wa_po_items-PLAN_DEL to wa_poitem-PLAN_DEL, wa_po_items-RET_ITEM to wa_poitem-RET_ITEM, wa_po_items-AT_RELEV to wa_poitem-AT_RELEV, wa_po_items-VEND_MAT to wa_poitem-VEND_MAT, wa_po_items-SHIPPING to wa_poitem-SHIPPING, wa_po_items-PO_UNIT_ISO to wa_poitem-PO_UNIT_ISO, wa_po_items-ORDERPR_UN_ISO to wa_poitem-ORDERPR_UN_ISO, wa_po_items-PREQ_NAME to wa_poitem-PREQ_NAME, wa_po_items-QUAL_INSP to wa_poitem-QUAL_INSP, wa_po_items-NO_MORE_GR to wa_poitem-NO_MORE_GR, wa_po_items-DELETE_IND to wa_poitem-DELETE_IND, wa_po_items-TAX_CODE to wa_poitem-TAX_CODE, wa_po_items-MATERIAL_EXTERNAL to wa_poitem-MATERIAL_EXTERNAL, wa_po_items-MATERIAL_GUID to wa_poitem-MATERIAL_GUID, wa_po_items-MATERIAL_VERSION to wa_poitem-MATERIAL_VERSION, wa_po_items-PUR_MAT_EXTERNAL to wa_poitem-EMATERIAL_EXTERNAL, wa_po_items-PUR_MAT_GUID to wa_poitem-EMATERIAL_GUID, wa_po_items-PUR_MAT_VERSION to wa_poitem-EMATERIAL_VERSION.

*--- This fields are not available in the new structures**wa_po_items-PO_NUMBER to wa_poitem-**wa_po_items-ADDRESS to wa_poitem-**wa_po_items-MANUF_PROF to wa_poitem-**wa_po_items-MANU_MAT to wa_poitem-**wa_po_items-MFR_NO to wa_poitem-**wa_po_items-MFR_NO_EXT to wa_poitem-**wa_po_items-PO_PRICE to wa_poitem-**wa_po_items-ALLOC_TBL to wa_poitem-**wa_po_items-AT_ITEM to wa_poitem-**wa_po_items-ITEM_CAT_EXT to wa_poitem-**wa_po_items-DISP_QUAN to wa_poitem-**wa_po_items-NO_ROUNDING to wa_poitem-**--- ITEM ADDITIONAL DATA*--- In BAPI_PO_CREATE for additinal data a seperate table is

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 29 of 54

Page 30: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

*--- used. In the new BAPI_PO_CREATE1 this fileds are includes*--- in the item structure/table Read table it_po_item_add_data into wa_po_item_add_data with key po_item = wa_poitem-po_item. If sy-subrc is initial. Move: wa_po_item_add_data-INFO_UPD to wa_poitem-INFO_UPD, wa_po_item_add_data-REMINDER1 to wa_poitem-REMINDER1, wa_po_item_add_data-REMINDER2 to wa_poitem-REMINDER2, wa_po_item_add_data-REMINDER3 to wa_poitem-REMINDER3, wa_po_item_add_data-OVERDELTOL to wa_poitem-OVER_DLV_TOL, wa_po_item_add_data-UNLIMITED to wa_poitem-UNLIMITED_DLV, wa_po_item_add_data-UNDER_TOL to wa_poitem-UNDER_DLV_TOL, wa_po_item_add_data-GR_IND to wa_poitem-GR_IND, wa_po_item_add_data-GR_NON_VAL to wa_poitem-GR_NON_VAL, wa_po_item_add_data-IR_IND to wa_poitem-IR_IND, wa_po_item_add_data-FINAL_INV to wa_poitem-FINAL_INV.**--- This fields are not available in the new structures**wa_po_item_add_data-DEL_COMPL to wa_poitem-,**wa_po_item_add_data-BUS_TRANST to wa_poitem-,**wa_po_item_add_data-EXPIMPPROC to wa_poitem-,**wa_po_item_add_data-COMM_CODE to wa_poitem-,**wa_po_item_add_data-REG_ORIGIN to wa_poitem-,**wa_po_item_add_data-COUNT_ORIG to wa_poitem-,**--- fill no_more_gr form addditional data when not filled from item if wa_poitem-NO_MORE_GR is initial. Move: wa_po_item_add_data-DEL_COMPL to wa_poitem-NO_MORE_GR. endif. Endif.* Append wa_poitem to et_poitem.

*--- fill change flag structure -------------------------------* clear wa_poitemx. move wa_poitem-po_item to wa_poitemx-po_item.* loop at lt_dd03l into ls_dd03l.*--> do not assign change for item ---- check ls_dd03l-position > 1. concatenate 'WA_POITEM' ls_dd03l-fieldname into lv_fieldname separated by '-'. assign (lv_fieldname) to <A>. check sy-subrc is initial. if <A> is initial. else. concatenate 'WA_POITEMX' ls_dd03l-fieldname into lv_fieldnamex separated by '-'. assign (lv_fieldnamex) to <X>. if sy-subrc is initial. <X> = 'X'. endif. endif. endloop.

append wa_poitemx to et_poitemx.

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 30 of 54

Page 31: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

Endloop.**------------------------------------------------------------**--- I T E M - S C H E D U L E S ---**------------------------------------------------------------*

Data: wa_schedules type BAPIEKET, wa_bapimeposchedule type bbp_bapimeposchedule, wa_bapimeposchedulx type bbp_bapimeposchedulx.

*--- get item structure definition ----------------- refresh lt_dd03l. select * from dd03l into table lt_dd03l where tabname = 'BBP_BAPIMEPOSCHEDULE'.* Loop at it_po_item_schedules into wa_schedules. Move: wa_schedules-PO_ITEM to wa_bapimeposchedule-PO_ITEM, wa_schedules-SERIAL_NO to wa_bapimeposchedule-SCHED_LINE, wa_schedules-DEL_DATCAT to wa_bapimeposchedule-DEL_DATCAT_EXT, wa_schedules-DELIV_DATE to wa_bapimeposchedule-DELIVERY_DATE, wa_schedules-DELIV_TIME to wa_bapimeposchedule-DELIV_TIME, wa_schedules-QUANTITY to wa_bapimeposchedule-QUANTITY, wa_schedules-PREQ_NO to wa_bapimeposchedule-PREQ_NO, wa_schedules-PREQ_ITEM to wa_bapimeposchedule-PREQ_ITEM, wa_schedules-DEL_DATCAT_EXT to wa_bapimeposchedule-DEL_DATCAT_EXT.**--- This fields are not available in the new structures**wa_schedules-CREATE_IND to wa_bapimeposchedule-,**wa_schedules-QUOTA_NO to wa_bapimeposchedule-,**wa_schedules-QUOTA_ITEM to wa_bapimeposchedule-,**wa_schedules-BOMEXPL_NO to wa_bapimeposchedule-,**wa_schedules-RESERV_NO to wa_bapimeposchedule-,**wa_schedules-BATCH to wa_bapimeposchedule-,**wa_schedules-VEND_BATCH to wa_bapimeposchedule-,**wa_schedules-VERSION to wa_bapimeposchedule-,* Append wa_bapimeposchedule to ET_POSCHEDULE.**--- fill change flag structure -------------------------------* clear wa_bapimeposchedulx.

move: wa_schedules-PO_ITEM to wa_bapimeposchedulx-PO_ITEM, wa_schedules-SERIAL_NO to wa_bapimeposchedulx-SCHED_LINE.

*--- fill change flag structure -------------------------------* loop at lt_dd03l into ls_dd03l.*--> do not assign change for item & schedule line ---- check ls_dd03l-position > 2. concatenate 'WA_BAPIMEPOSCHEDULE' ls_dd03l-fieldname into lv_fieldname separated by '-'. assign (lv_fieldname) to <A>. check sy-subrc is initial. if <A> is initial. else. concatenate 'WA_BAPIMEPOSCHEDULX' ls_dd03l-fieldname into lv_fieldnamex separated by '-'.

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 31 of 54

Page 32: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

assign (lv_fieldnamex) to <X>. if sy-subrc is initial. <X> = 'X'. endif. endif. endloop.* append wa_bapimeposchedulx to et_poschedulex.* Endloop.*------------------------------------------------------------**--- I T E M - A C C O U N T I N G ---**------------------------------------------------------------** Data: WA_ACCOUNT type BAPIEKKN, Wa_poaccount type BBP_BAPIMEPOACCOUNT, Wa_poaccountx type BBP_BAPIMEPOACCOUNTx.**--- get item structure definition ----------------- refresh lt_dd03l. select * from dd03l into table lt_dd03l where tabname = 'BBP_BAPIMEPOACCOUNT'.* Loop at it_po_item_account_assignment into wa_account. Move: wa_account-PO_ITEM to Wa_poaccount-PO_ITEM, wa_account-SERIAL_NO to Wa_poaccount-SERIAL_NO, wa_account-QUANTITY to Wa_poaccount-QUANTITY, wa_account-DISTR_PERC to Wa_poaccount-DISTR_PERC, wa_account-G_L_ACCT to Wa_poaccount-GL_ACCOUNT, wa_account-BUS_AREA to Wa_poaccount-BUS_AREA, wa_account-COST_CTR to Wa_poaccount-COSTCENTER, wa_account-SD_DOC to Wa_poaccount-SD_DOC, wa_account-SDOC_ITEM to Wa_poaccount-ITM_NUMBER, wa_account-SCHED_LINE to Wa_poaccount-SCHED_LINE, wa_account-ASSET_NO to Wa_poaccount-ASSET_NO, wa_account-SUB_NUMBER to Wa_poaccount-SUB_NUMBER, wa_account-ORDER_NO to Wa_poaccount-ORDERID, wa_account-GR_RCPT to Wa_poaccount-GR_RCPT, wa_account-UNLOAD_PT to Wa_poaccount-UNLOAD_PT, wa_account-CO_AREA to Wa_poaccount-CO_AREA, wa_account-COST_OBJ to Wa_poaccount-COSTOBJECT, wa_account-PROF_SEGM to Wa_poaccount-PROFIT_SEGM_NO, wa_account-PROFIT_CTR to Wa_poaccount-PROFIT_CTR, wa_account-WBS_ELEM_E to Wa_poaccount-WBS_ELEMENT, wa_account-NETWORK to Wa_poaccount-NETWORK, wa_account-RL_EST_KEY to Wa_poaccount-RL_EST_KEY, wa_account-PART_ACCT to Wa_poaccount-PART_ACCT, wa_account-CMMT_ITEM to Wa_poaccount-CMMT_ITEM, wa_account-REC_IND to Wa_poaccount-REC_IND, wa_account-FUNDS_CTR to Wa_poaccount-FUNDS_CTR, wa_account-FUND to Wa_poaccount-FUND, wa_account-FUNC_AREA to Wa_poaccount-FUNC_AREA, wa_account-REF_DATE to Wa_poaccount-REF_DATE, wa_account-ACTIVITY to Wa_poaccount-ACTIVITY.

*--- This fields are not available in the new structures**wa_account-PROJ_EXT to Wa_poaccount-**wa_account-TO_COSTCTR to Wa_poaccount-**wa_account-TO_ORDER to Wa_poaccount-

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 32 of 54

Page 33: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

**wa_account-TO_PROJECT to Wa_poaccount-**wa_account-ROUTING_NO to Wa_poaccount-**wa_account-COUNTER to Wa_poaccount-

Append Wa_POACCOUNT to et_poaccount.

*--- fill change flag structure -------------------------------* clear Wa_poaccountx.

move: wa_account-PO_ITEM to Wa_poaccountx-PO_ITEM, wa_account-SERIAL_NO to Wa_poaccountx-SERIAL_NO.**--- fill change flag structure -------------------------------* loop at lt_dd03l into ls_dd03l.*--> do not assign change for item & serial nr. ---- check ls_dd03l-position > 2. concatenate 'WA_POACCOUNT' ls_dd03l-fieldname into lv_fieldname separated by '-'. assign (lv_fieldname) to <A>. check sy-subrc is initial. if <A> is initial. else. concatenate 'WA_POACCOUNTX' ls_dd03l-fieldname into lv_fieldnamex separated by '-'. assign (lv_fieldnamex) to <X>. if sy-subrc is initial. <X> = 'X'. endif. endif. endloop.* append Wa_poaccountx to et_poaccountx. Endloop.*endmethod. "IF_EX_BBP_ICC_PO_MAP~MAP_STRUCTURES

4.6.2 Call to Method MAP_STRUCTURES

This method is called in the function module B46C_PO_CREATE. That function module is called in the meta-BAPI logic based on the entry for the business object BUS2012 (purchase or-der) in table BBP_FUNCTION_MAP. The following screenshot shows the call stack in the cre-ation of a backend PO with the function module BBP_REQREQ_TRANSFER:

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 33 of 54

Page 34: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

The following part of the coding shows the place in the function module where the BAdI is called:

FUNCTION b46c_po_create.……* Reference to BAdI interface that fills BAPI structures for* BAPI_PO_CREATE1 STATICS: badi_icc_po_map TYPE REF TO if_ex_bbp_icc_po_map.

* Check if BAdI object was alread instanciated. If not, do so. IF badi_icc_po_map IS INITIAL. CALL METHOD cl_exithandler=>get_instance CHANGING instance = badi_icc_po_map. ENDIF.…… CALL FUNCTION 'BBP_CUF_GET_COMPANY_COUNTRY' EXPORTING iv_user_id = po_items-preq_name iv_doc_type = '' "this parameter should be optional!! IMPORTING ev_countryiso = lv_country.

* For certain countries, the function BAPI_PO_CREATE1 has to be* used to create the backend PO. This BAdI does the necessary* mapping to the BAPI structures: CALL METHOD badi_icc_po_map->map_structures EXPORTING is_header = po_header is_header_add_data = po_header_add_data is_po_address = po_address iv_header_add_data_relevant = header_add_data_relevant iv_item_add_data_relevant = item_add_data_relevant it_po_items = po_items[] it_cuf_item = cuf_item[] it_po_item_add_data = po_item_add_data[] it_po_item_schedules = po_item_schedules[] it_po_item_account_assignment = po_item_account_assignment[] it_po_item_text = po_item_text[] it_po_limits = po_limits[] it_po_contract_limits = po_contract_limits[] it_po_services = po_services[] it_po_srv_accass_values = po_srv_accass_values[] it_po_services_text = po_services_text[] it_poaddrdelivery = poaddrdelivery[] flt_val = lv_country IMPORTING es_bapimepoheader = ls_bapimepoheader es_bapimepoheaderx = ls_bapimepoheaderx es_bapimepoaddrvendor = ls_bapimepoaddrvendor et_poitem = lt_poitem et_poitemx = lt_poitemx et_poaddrdelivery = lt_poaddrdelivery et_poschedule = lt_poschedule et_poschedulex = lt_poschedulex et_poaccount = lt_poaccount et_poaccountx = lt_poaccountx

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 34 of 54

Page 35: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

et_pocond = lt_pocond et_pocondx = lt_pocondx et_polimits = lt_polimits et_pocontractlimits = lt_pocontractlimits et_poservices = lt_poservices et_posrvaccessvalues = lt_posrvaccessvalues et_poservicestext = lt_poservicestext ev_new_po_create = lv_new_po_create.

ENDIF.

* If the flag lv_new_po_create is set, the new BAPI is to be called

IF NOT lv_new_po_create IS INITIAL.* Country-specific processing: Use "new" BAPI CALL FUNCTION 'BAPI_PO_CREATE1' DESTINATION destination EXPORTING poheader = ls_bapimepoheader poheaderx = ls_bapimepoheaderx poaddrvendor = ls_bapimepoaddrvendor IMPORTING exppurchaseorder = purchaseorder TABLES return = return poitem = lt_poitem poitemx = lt_poitemx poaddrdelivery = lt_poaddrdelivery poschedule = lt_poschedule poschedulex = lt_poschedulex poaccount = lt_poaccount poaccountx = lt_poaccountx pocond = lt_pocond pocondx = lt_pocondx polimits = lt_polimits pocontractlimits = lt_pocontractlimits poservices = lt_poservices posrvaccessvalues = lt_posrvaccessvalues poservicestext = lt_poservicestext EXCEPTIONS* Set if an error occurs during the RFC OTHERS = 1. ELSE.* Standard processing: Use "old" BAPI CALL FUNCTION 'BAPI_PO_CREATE' DESTINATION destination EXPORTING po_header = po_header po_header_add_data = po_header_add_data header_add_data_relevant = header_add_data_relevant po_address = po_address skip_items_with_error = skip_items_with_error item_add_data_relevant = item_add_data_relevant IMPORTING purchaseorder = purchaseorder TABLES po_items = po_items po_item_add_data = po_item_add_data po_item_schedules = po_item_schedules po_item_account_assignment = po_item_account_assignment

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 35 of 54

Page 36: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

po_item_text = po_item_text return = return po_limits = po_limits po_contract_limits = po_contract_limits po_services = po_services po_srv_accass_values = po_srv_accass_values po_services_text = po_services_text* poaddrdelivery = poaddrdelivery EXCEPTIONS OTHERS = 1. ENDIF.…

4.7 Function module BBP_ICC_PUT_DATA

This function module is called by the method PUT_DATA of the BAdI implementation BBP_CUF_BADI_ICC_BR. It is used to map the tax details that are stored in additional fields of the item to the table with tax details that is displayed on screen 0200 in the program SAPLBBP_ICC. In the Brazil-specific solution, this screen replaces the standard screen that is used to display customer fields.

The function creates an internal table lt_ddic that stores the fields of the additional fields that contain tax values:

Function Group: BBP_ICC

FUNCTION bbp_icc_put_data.*"----------------------------------------------------------------------*"*"Lokale Schnittstelle:*" IMPORTING*" REFERENCE(IS_ITEM) TYPE BBP_PDS_ITEM

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 36 of 54

Page 37: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

*"----------------------------------------------------------------------

* Map the tax details that are stored in "customer" fields of the item* to the table with tax details that is displayed on screen 0200.

DATA: lt_ddic TYPE TABLE OF bdt_ddstruct, wa_ddic TYPE bdt_ddstruct, lv_length TYPE i, lv_offset TYPE i, lv_index TYPE i, lv_save_index TYPE i, lv_name TYPE bdt_ddstruct-fieldname, wa_tax_data LIKE LINE OF gt_tax_data. FIELD-SYMBOLS: <item_field> TYPE ANY, <tax_field> TYPE ANY.

CALL FUNCTION 'BUS_DDSTRUC_GET' EXPORTING i_tabname = 'BBP_CUF_TAX_BR' TABLES et_ddstruct = lt_ddic EXCEPTIONS not_found = 1 OTHERS = 2.

IF sy-subrc NE 0. RETURN. ENDIF.

lv_save_index = 0. REFRESH gt_tax_data.

LOOP AT lt_ddic INTO wa_ddic.

lv_length = strlen( wa_ddic-fieldname ). lv_offset = lv_length - 1. lv_index = wa_ddic-fieldname+lv_offset(1). lv_name = wa_ddic-fieldname(lv_offset).

IF lv_index <> lv_save_index. IF lv_save_index > 0. APPEND wa_tax_data TO gt_tax_data. ENDIF. CLEAR wa_tax_data. lv_save_index = lv_index. ENDIF.

ASSIGN COMPONENT wa_ddic-fieldname OF STRUCTURE is_item TO <item_field>. ASSIGN COMPONENT lv_name OF STRUCTURE wa_tax_data TO <tax_field>.

IF lv_name = 'KSCHL' AND <item_field> IS INITIAL. EXIT. ENDIF.

IF lv_name = 'KBETR'.

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 37 of 54

Page 38: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

* Tax rates are stored multplied by 10 to get 3 dec.places precision <tax_field> = <item_field> / 10. ELSE. <tax_field> = <item_field>. ENDIF.

ENDLOOP.

ENDFUNCTION.

4.8 Screens and Internet Services

The additional fields on the screens are realized as a separate subscreen CUSTOMER_FIELDS. This subscreen is included on the following standard EBP screens.

Program SAPBBPPU02, Screen 1100: Display status of shopping cart

Function Group BBP_SC, Screen 3001: Create shopping cart

Which screen is included in the subscreen is determined by the method method PUT_DATA of the BAdI BBP_CUF_BADI_ICC_BR (see section 4.2.1).

4.8.1 Screen 200 in Function Group BBP_ICC

Screen 200 in the function group BBP_ICC is set as the screen to display additional fields in the method PUT_DATA of the BAdI BBP_CUF_BADI_ICC_BR. It contains a table control with tax details and a subscreen BRAZIL_FIELDS where the standard screen with additional fields is in-cluded.

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 38 of 54

Page 39: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

PROCESS BEFORE OUTPUT.

* This is only to be able to set breakpoints MODULE dummy.

* Customer fields CALL SUBSCREEN brazil_fields INCLUDING gc_cuf_prog gc_cuf_dynnr.

*&SPWIZARD: PBO FLOW LOGIC FOR TABLECONTROL 'TAX_DETAILS' MODULE tax_details_change_tc_attr.*&SPWIZARD: MODULE TAX_DETAILS_CHANGE_COL_ATTR. LOOP AT gt_tax_data INTO wa_tax_data WITH CONTROL tax_details CURSOR tax_details-current_line.*&SPWIZARD: MODULE TAX_DETAILS_CHANGE_FIELD_ATTR ENDLOOP.

* MODULE STATUS_0200.

PROCESS AFTER INPUT.* Customer fields CALL SUBSCREEN brazil_fields.

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 39 of 54

Page 40: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

*&SPWIZARD: PAI FLOW LOGIC FOR TABLECONTROL 'TAX_DETAILS' LOOP AT gt_tax_data. CHAIN. FIELD wa_tax_data-kschl. FIELD wa_tax_data-taxtyp. FIELD wa_tax_data-kawrt. FIELD wa_tax_data-kbetr. FIELD wa_tax_data-waers. FIELD wa_tax_data-kpein. FIELD wa_tax_data-kmein. FIELD wa_tax_data-kvsl1. FIELD wa_tax_data-stazf. FIELD wa_tax_data-kwert.* MODULE TAX_DETAILS_MODIFY ON CHAIN-REQUEST. ENDCHAIN. ENDLOOP.*&SPWIZARD: MODULE TAX_DETAILS_CHANGE_TC_ATTR.*&SPWIZARD: MODULE TAX_DETAILS_CHANGE_COL_ATTR.

* MODULE USER_COMMAND_0200.

4.8.2 Internet Service BBP_ICC_TAX_BR

This service contains one theme: Theme 99. The theme contains two HTML templates:

SAPLBBP_ICC 200

SAPLBBP_PDH_CUF 100

The first template corresponds to the screen 200 in the function group BBP_ICC that is set as the screen to display additional fields in the method PUT_DATA of the BAdI BBP_CUF_BADI_ICC_BR. The second template just includes the standard table with additional fields.

4.8.2.1 HTML Template SAPLBBP_ICC 200

Note: This still has to be changed and published in PIC! The file was directly modified in the fol-lowing location:

\\pwdf0549\QEC_ITS\templates\bbp_icc_tax_br\99\ saplbbp_icc_200.html

<!-- START: Partner : Template 1000 -->

<!-- --------------INCLUDING FUNCTIONS... ------------------------------- -->`include (~service="bbpglobal", ~name="bbpfunctions.html")` <!-- -------------------------------------------------------------------- -->

<!-- --------------INCLUDING Customer Fields ... ----------------------> `includeFrame (~frameName="BRAZIL_FIELDS")` <! -------------------------------------------------------------------- -->

`endTABLE()`

<br>

`if (WA_TAX_DATA-KSCHL.dim > 0)``TABLE(class="list")` `TR(tableName=#TABLE_NAME_TAX_DETAILS)` `TR(class="heading")`

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 40 of 54

Page 41: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

`TD(nowrap="x")``TAX_DETAILS-column[1].title` `TD(nowrap="x")``TAX_DETAILS-column[2].title` `TD(nowrap="x", align="right")``TAX_DETAILS-column[3].title` `TD(nowrap="x", align="right")``TAX_DETAILS-column[4].title` `TD(nowrap="x")``TAX_DETAILS-column[6].title` `TD(nowrap="x", align="right")``TAX_DETAILS-column[8].title` `TD(nowrap="x", align="middle")``TAX_DETAILS-column[9].title` `TD(nowrap="x", align="right")``TAX_DETAILS-column[10].title`

`repeat with j from 1 to WA_TAX_DATA-KSCHL.dim` `TR()` `TD(nowrap="x")``WA_TAX_DATA-KSCHL[j].value` `TD(nowrap="x")``WA_TAX_DATA-TAXTYP[j].value` `TD(nowrap="x", align="right")``WA_TAX_DATA-KAWRT[j].value` `TD(nowrap="x", align="right")``WA_TAX_DATA-KBETR[j].value`&nbsp; `if (WA_TAX_DATA-WAERS[j].value)` `WA_TAX_DATA-WAERS[j].value` `else` % `end` `TD(nowrap="x", align="right")``WA_TAX_DATA-KPEIN[j].value` &nbsp;`WA_TAX_DATA-KMEIN[j].value` `TD(nowrap="x")``WA_TAX_DATA-KVSL1[j].value` `TD(nowrap="x")` `if (WA_TAX_DATA-STAZF[j].value)` <img src="`mimeURL(~service="bbpglobal", ~language="", ~name="images/icon/checkedr.gif")`" border="0"> `else` <img src="`mimeURL(~service="bbpglobal", ~language="", ~name="images/icon/un-checkedr.gif")`" border="0"> `end` `TD(nowrap="x", align="right")``WA_TAX_DATA-KWERT[j].value` `end` <!-- repeat -->`end`

<!-- END: Partner : Template 1000 -->

4.8.2.2 HTML Template SAPLBBP_PDH_CUF 100

This has to be included in the internet service in order to display the subscreen BRAZIL_FIELDS.

`include (~service="bbpcuf", ~theme="99", ~language="", ~name="saplbbp_pdh_cuf_100.html")`

4.9 Tax Calculation in R/3 Plugin

4.9.1 Function Module BBP_CALCULATE_TAX_ITEM40B

This function module is called via RFC to the FI R/3 backend by the method CALCULATE_TAX of the BAdI BBB_TAX_ICC_BR.

Function Group: BBPI4X

FUNCTION BBP_CALCULATE_TAX_ITEM40B.*"----------------------------------------------------------------------*"*"Lokale Schnittstelle:

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 41 of 54

Page 42: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

*" IMPORTING*" VALUE(IV_INVOICE) LIKE BKPF-XUSVR OPTIONAL*" EXPORTING*" VALUE(EV_TAX_ON_HEADER) LIKE BKPF-XUSVR*" TABLES*" IT_ITEM STRUCTURE BBP_TAX_COMM_PI*" ET_BAPIRETURN STRUCTURE BAPIRET2 OPTIONAL*" ET_TAX_COND STRUCTURE BBP_TAX_COND_PI OPTIONAL*" ET_HEADER_TAX STRUCTURE BBP_TAX_HEADER_PI OPTIONAL*"---------------------------------------------------------------------- TABLES : TTXD.

DATA: LV_ITEM_WISE LIKE TTXD-XTXIT, "Line wise tax calculation LT_TAXCOM LIKE TAXCOM OCCURS 0 WITH HEADER LINE, LV_LINES LIKE SY-TABIX, LV_KALSM LIKE T005-KALSM, LV_INDEX LIKE SY-TABIX, LV_NAVFW LIKE BSEG-NAVFW, ET_TAXCOM LIKE TAXCOM OCCURS 0 WITH HEADER LINE, LV_XSTVR LIKE BSEZ-XSTVR, LV_NAV_ANTEIL LIKE BSET-FWSTE, LT_XKOMV LIKE KOMV OCCURS 0 WITH HEADER LINE, LV_KPOSN LIKE KOMV-KPOSN, LV_ITEM_INDEX LIKE SY-TABIX, LV_APPL(2) TYPE C, LV_COUNTRY LIKE T005-LAND1.

LV_KPOSN = 1. READ TABLE IT_ITEM INDEX 1.

CALL FUNCTION 'FIND_TAX_SPREADSHEET' EXPORTING BUCHUNGSKREIS = IT_ITEM-BUKRS IMPORTING SCHEMA = LV_KALSM EXCEPTIONS NOT_FOUND = 1 OTHERS = 2.

IF SY-SUBRC NE 0. PERFORM FILL_RETURN TABLES ET_BAPIRETURN USING SY-MSGTY SY-MSGID SY-MSGNO SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF.

* Determine the country of the company code PERFORM GET_COUNTRY USING IT_ITEM-BUKRS CHANGING LV_COUNTRY.

LV_ITEM_WISE = 'X'.* In case of invoice read customizing. Otherwise item wise calculation IF NOT IV_INVOICE IS INITIAL. SELECT SINGLE * FROM TTXD WHERE KALSM = LV_KALSM. IF SY-SUBRC = 0. LV_ITEM_WISE = TTXD-XTXIT. ELSE. CLEAR LV_ITEM_WISE. ENDIF. ENDIF.

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 42 of 54

Page 43: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

LOOP AT IT_ITEM. LV_INDEX = SY-TABIX. CLEAR LT_TAXCOM. MOVE-CORRESPONDING IT_ITEM TO LT_TAXCOM.* Set flag: calculate taxes LT_TAXCOM-XMWST = 'X'.* Fill country with company code country LT_TAXCOM-LAND1 = LV_COUNTRY.* In EBP: company code currency always document currency LT_TAXCOM-HWAER = LT_TAXCOM-WAERS.* In EBP: no differentiation between doc.date and posting date LT_TAXCOM-BLDAT = LT_TAXCOM-BUDAT.

IF LV_ITEM_WISE IS INITIAL. "Calculation per document LT_TAXCOM-KPOSN = 1. CLEAR LT_TAXCOM-LIFNR. CLEAR LT_TAXCOM-EKORG. CLEAR LT_TAXCOM-GSBER. CLEAR LT_TAXCOM-LLIEF. CLEAR LT_TAXCOM-MATNR. CLEAR LT_TAXCOM-WERKS. CLEAR LT_TAXCOM-MATKL. CLEAR LT_TAXCOM-MEINS. CLEAR LT_TAXCOM-MGLME. COLLECT LT_TAXCOM. ELSE. "Calculation per item IF LT_TAXCOM-KPOSN IS INITIAL. LT_TAXCOM-KPOSN = LV_KPOSN. IT_ITEM-KPOSN = LV_KPOSN. MODIFY IT_ITEM INDEX LV_INDEX. LV_KPOSN = LV_KPOSN + 1. ENDIF. APPEND LT_TAXCOM. ENDIF. ENDLOOP.

LOOP AT LT_TAXCOM. LV_INDEX = SY-TABIX.

* Country-specific extensions that change the taxcom structure* and/or store PO-specific data in function groups used during* the tax calculation PERFORM FILL_TAXCOM_COUNTRY_SPECIFIC TABLES IT_ITEM ET_BAPIRETURN USING LV_COUNTRY IV_INVOICE LV_KALSM CHANGING LT_TAXCOM.

REFRESH LT_XKOMV.

CALL FUNCTION 'CALCULATE_TAX_ITEM' EXPORTING I_TAXCOM = LT_TAXCOM* reset = 'X' IMPORTING E_NAVFW = LV_NAVFW E_TAXCOM = ET_TAXCOM

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 43 of 54

Page 44: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

E_XSTVR = LV_XSTVR NAV_ANTEIL = LV_NAV_ANTEIL TABLES T_XKOMV = LT_XKOMV EXCEPTIONS OTHERS = 6.

IF SY-SUBRC NE 0. PERFORM FILL_RETURN TABLES ET_BAPIRETURN USING SY-MSGTY SY-MSGID SY-MSGNO SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. DESCRIBE TABLE ET_BAPIRETURN LINES LV_LINES. READ TABLE ET_BAPIRETURN INDEX LV_LINES. ET_BAPIRETURN-ROW = LV_INDEX. MODIFY ET_BAPIRETURN INDEX LV_LINES. EXIT. ENDIF.

IF NOT LV_ITEM_WISE IS INITIAL. "Zeilenweise Steuerrechnung READ TABLE IT_ITEM WITH KEY KPOSN = ET_TAXCOM-KPOSN. LV_ITEM_INDEX = SY-TABIX. IF SY-SUBRC NE 0. PERFORM FILL_RETURN TABLES ET_BAPIRETURN USING 'E' 'F5' '898' 'BBP_CALCULATE_TAX_ITEM40B' SPACE SPACE SPACE. EXIT. ENDIF. IT_ITEM-WMWST = ET_TAXCOM-WMWST. MODIFY IT_ITEM INDEX LV_ITEM_INDEX.

* Append all tax lines to table et_tax_cond.* lt_xkomv contains all non-statistical conditions in* tax calculation procedure. LOOP AT LT_XKOMV. MOVE-CORRESPONDING LT_XKOMV TO ET_TAX_COND.* The GUID identifies the item of the EBP document ET_TAX_COND-P_GUID = IT_ITEM-GUID.* The counter identifies one tax line of an item. ET_TAX_COND-COUNTER = SY-TABIX.

* Country-specific modifications/extensions to return structure* that contains the taxes PERFORM FILL_TAX_COND_COUNTRY_SPECIFIC USING LV_COUNTRY LT_XKOMV CHANGING ET_TAX_COND.

APPEND ET_TAX_COND. ENDLOOP. ELSE. EV_TAX_ON_HEADER = 'X'. ET_HEADER_TAX-WMWST = ET_TAXCOM-WMWST. ET_HEADER_TAX-MWSKZ = ET_TAXCOM-MWSKZ. ET_HEADER_TAX-WAERS = ET_TAXCOM-WAERS. COLLECT ET_HEADER_TAX. ENDIF. ENDLOOP.

ENDFUNCTION.

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 44 of 54

Page 45: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

4.9.2 Form Routine GET_COUNTRY

Include: LBBPI4XF04

This routine determines whether the country of the company code is Brazil.

*&---------------------------------------------------------------------**& Form GET_COUNTRY*&---------------------------------------------------------------------** text*----------------------------------------------------------------------*FORM GET_COUNTRY USING IV_BUKRS LIKE T001-BUKRS CHANGING EV_COUNTRY LIKE T005-LAND1.

* Check if country of comp.code is Brazil CALL FUNCTION 'J_1BSA_COMPONENT_ACTIVE' EXPORTING BUKRS = IV_BUKRS COMPONENT = 'BR' IMPORTING ACTIVE_COMPONENT = EV_COUNTRY EXCEPTIONS COMPONENT_NOT_ACTIVE = 1 OTHERS = 2.

ENDFORM. " GET_COUNTRY

4.9.3 Form Routine FILL_TAXCOM_COUNTRY_SPECIFIC

*&---------------------------------------------------------------------**& Form FILL_TAXCOM_COUNTRY_SPECIFIC*&---------------------------------------------------------------------** Country-specific extensions before call to* CALCULATE_TAX_ITEM*----------------------------------------------------------------------*FORM FILL_TAXCOM_COUNTRY_SPECIFIC TABLES IT_ITEM STRUCTURE BBP_TAX_COMM_PI ET_BAPIRETURN STRUCTURE BAPIRET2 USING IV_COUNTRY LIKE T005-LAND1 IV_INVOICE TYPE C IV_KALSM LIKE T005-KALSM CHANGING CS_TAXCOM LIKE TAXCOM.

CASE IV_COUNTRY. WHEN 'BR'.* Brazil PERFORM FILL_TAXCOM_BRAZIL TABLES IT_ITEM ET_BAPIRETURN USING IV_INVOICE IV_KALSM CHANGING CS_TAXCOM. WHEN OTHERS.* No other country specifics yet. ENDCASE.

ENDFORM. " FILL_TAXCOM_COUNTRY_SPECIFIC

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 45 of 54

Page 46: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

4.9.4 Form Routine FILL_TAXCOM_BRAZIL

*&---------------------------------------------------------------------**& Form FILL_TAXCOM_BRAZIL*&---------------------------------------------------------------------** Brazil-specific extensions:* Fill NCM code in PO to use it later in J_1BCALCULATE_TAXES*----------------------------------------------------------------------*FORM FILL_TAXCOM_BRAZIL TABLES IT_ITEM STRUCTURE BBP_TAX_COMM_PI ET_BAPIRETURN STRUCTURE BAPIRET2 USING IV_INVOICE TYPE C IV_KALSM LIKE T005-KALSM CHANGING CS_TAXCOM LIKE TAXCOM.

DATA: IT_KONV LIKE TABLE OF KONV, "just an empty dummy table LS_EKPO LIKE EKPO.

CASE IV_INVOICE. WHEN 'X'.* Localization of invoice not implemented yet. EXIT. WHEN SPACE.* Shopping cart or purchase order READ TABLE IT_ITEM WITH KEY KPOSN = CS_TAXCOM-KPOSN. LS_EKPO-EBELP = CS_TAXCOM-KPOSN. LS_EKPO-J_1BNBM = IT_ITEM-STEUC.

* Transfer the NCM code to function group J1BP, so that* J_1BCALCULATE_TAXES can read it during the tax calculation CALL FUNCTION 'J_1B_NF_PO_DISCOUNTS' EXPORTING I_KALSM = IV_KALSM I_EKPO = LS_EKPO TABLES I_KONV = IT_KONV.

* The ship-from and ship-to regions have to be replaced by the tax* regions. PERFORM MAP_TAX_REGION TABLES ET_BAPIRETURN CHANGING IT_ITEM-TXJCD. PERFORM MAP_TAX_REGION TABLES ET_BAPIRETURN CHANGING CS_TAXCOM-TXJCD. PERFORM MAP_TAX_REGION TABLES ET_BAPIRETURN CHANGING IT_ITEM-TXREG_SF. PERFORM MAP_TAX_REGION TABLES ET_BAPIRETURN CHANGING IT_ITEM-TXREG_ST.

WHEN OTHERS.* Who knows...? ENDCASE.

ENDFORM. " FILL_TAXCOM_BRAZIL

4.9.5 Form Routine MAP_TAX_REGION

*&---------------------------------------------------------------------**& Form MAP_TAX_REGION*&---------------------------------------------------------------------*

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 46 of 54

Page 47: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

* text*----------------------------------------------------------------------** <--P_CS_TAXCOM_TXJCD text **----------------------------------------------------------------------*FORM MAP_TAX_REGION TABLES ET_BAPIRETURN STRUCTURE BAPIRET2 CHANGING CV_REGION TYPE C.

DATA: LS_COMJUR LIKE COM_JUR, IT_COMJUR LIKE TABLE OF COM_JUR.

* Only try to map if region is not initial CHECK NOT CV_REGION IS INITIAL.

LS_COMJUR-COUNTRY = 'BR'. LS_COMJUR-STATE = CV_REGION.

CALL FUNCTION 'J_1BDETERMINE_JURISDICTION' EXPORTING LOCATION_DATA = LS_COMJUR TABLES LOCATION_RESULTS = IT_COMJUR EXCEPTIONS OTHERS = 1.

READ TABLE IT_COMJUR INDEX 1 INTO LS_COMJUR. CV_REGION = LS_COMJUR-TXJCD. DESCRIBE TABLE IT_COMJUR LINES SY-TFILL. CASE SY-TFILL. WHEN 0.* No mapping entry PERFORM FILL_RETURN TABLES ET_BAPIRETURN USING 'W' 'AM' 215 'BR' CV_REGION SPACE SPACE. WHEN 1.* Exactly one entry WHEN OTHERS.* Multiple tax regions for the region PERFORM FILL_RETURN TABLES ET_BAPIRETURN USING 'W' 'AM' 215 CV_REGION 'BR' SPACE SPACE. ENDCASE.

ENDFORM. " MAP_TAX_REGION

4.9.6 Form Routine FILL_TAX_COND_COUNTRY_SPECIFIC

*&---------------------------------------------------------------------**& Form FILL_TAX_COND_COUNTRY_SPECIFIC*&---------------------------------------------------------------------** Fill the tax group (IPI, ICMS, ...) into the return structure* for EBP tax calculation Brazil.*----------------------------------------------------------------------*FORM FILL_TAX_COND_COUNTRY_SPECIFIC USING IV_COUNTRY LIKE T005-LAND1 IS_XKOMV LIKE KOMV CHANGING CS_TAX_COND LIKE BBP_TAX_COND_PI.

DATA: WA_J_1BAJ LIKE J_1BAJ. STATICS: ST_J_1BAJ LIKE TABLE OF J_1BAJ.

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 47 of 54

Page 48: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

CHECK IV_COUNTRY = 'BR'.

DESCRIBE TABLE ST_J_1BAJ LINES SY-TFILL. IF SY-TFILL IS INITIAL. SELECT * FROM J_1BAJ INTO TABLE ST_J_1BAJ. ENDIF.

READ TABLE ST_J_1BAJ INTO WA_J_1BAJ WITH KEY TAXTYP = IS_XKOMV-KSCHL. CS_TAX_COND-TAXGRP = WA_J_1BAJ-TAXGRP.

ENDFORM. " FILL_TAX_COND_COUNTRY_SPECIFIC

4.10Sequence of Execution of Brazil-Specific Coding

4.10.1 Chronological Sequence of Execution of BAdI Methods During Posting of a Shopping Cart

Start transaction BBPPU99. Enter a product, inform a quantity, and press Add to Shopping Cart. This is analog to creating a shopping cart item in the browser and pressing the Add to Shopping Cart button.

After pressing the button, the following BAdI methods are being processed:

4.10.1.1 IF_EX_BBP_TAX_ICC~DETERMINE_CALC_FLAG

Determines whether taxes have to be recalculated. The BAdI method is called in the function module BBP_TAX_UPDATE_TAX_SEG. It changes the flag ev_xcalculate. In that function the handling of, e.g., changes of the tax code is performed, which leads to a recalculation of the taxes by standard.

Since the item is processed the first time, the flag will always be set in this step.

This happens for each item that is added to the shopping cart or deleted from the shopping cart.

The next steps happen after pressing the Detail button for an item.

4.10.1.2 IF_EX_BBP_CUF_BADI_ICC~PUT_DATA

The screen number and program name containing the Brazil-specific screen that displays the additional fields are set. Afterwards, the function module BBP_ICC_PUT_DATA is called.

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 48 of 54

Page 49: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

Since the item does not contain any tax values at this moment, the internal table that contains the tax lines to be displayed is not filled.

4.10.1.3 IF_EX_BBP_CUF_ICC_BADI~MODIFY_SCREEN

In this method, the properties of the additional fields on the screen are modified. The 5 item fields are made editable depending on whether a product was informed (i.e. master data are available). The fields that contain tax values are made invisible since these fields are displayed in a separate table control.

4.10.1.4 IF_EX_BBP_CUF_ICC_BADI~MODIFY_OUTPUT

This method is called in a screen loop for each additional field: STEUC, J_1BMATUSE, J_1BMATORG, J_1BOWNPRO, J_1BINDUST

If a product is informed, the master data record is read and the additional fields are filled with the master data. These fields are stored in the tax type/tax group data.

Note: Here, the product id and the internal table that contains the product master data should be stored in a local static variable in order to avoid multiple accesses to the product master data on the database for each additional field in one item!

After processing of this method, the item detail screen is displayed. (The master screen is 3001 in program SAPLBBP_SC).

Inform a net price per unit and a tax code (in this example I3). After PAI ist triggered, the follow-ing BAdI methods are being executed.

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 49 of 54

Page 50: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

4.10.1.5 IF_EX_BBP_CUF_ICC_BADI~MODIFY_INPUT

In this method, the format or content of the additional fields can be modified after PAI was trig-gered. For each additional field, the method is called. However, the Brazil-specific implementa-tion makes no changes to the data.

4.10.1.6 IF_EX_BBP_CUF_BADI_ICC~GET_DATA

This method can be used to extend the standard transfer mechanism that modifies the addi-tional fields according to changes made on the screen. Since in the Brazil-specific implementa-tion the only extension to the standard solution is an additional screen with tax details, no further coding has to be executed here because the data are only displayed.

4.10.1.7 IF_EX_BBP_TAX_ICC~DETERMINE_CALC_FLAG

The tax calculation for the item that is currently displayed is being performed. However, the form routine UPDATE_DOCUMENT_SINGLE_ITEM which performs this immediately calls the form routine UPDATE_DOCUMENT. This means, for each change in an item, the whole shopping cart is processed.

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 50 of 54

Page 51: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

The data of the currently processed items are compared with the corresponding data of the pre-vious tax calculation. Only if tax-relevant data are changed, the recalculation indicator is set. This is the case for the delivery date, the NCM code, and the vendor. Other checks (like change of tax code) are performed in the standard coding.

Now the item does contain tax-relevant data; therefore the recalculation indicator is set.

4.10.1.8 IF_EX_BBP_TAX_ICC~CALCULATE_TAX

In the following, the tax-calculating function is determined by reading the meta-BAPI table. This leads to the call of the function module B46B_TAX_CALCULATE_NET_AMOUNT. Here, the country of the requisitioner’s company code is determined. Afterwards, the country-specific im-plementation of a tax calculation BAdI is called.

In the beginning, the partners are determined. First, an explicit ship-from partner is searched for in the partner table corresponding to the current item. If no ship-from partners were found, then the vendor is searched.

Note: At present, it is checked if the partner table is initial after the search for ship-to partners. Verify if the partner table contains data of all items. If yes, this check is too simple!

YES! The table does contain data of all items. Loop at all items and access partner table always with the item GUID. Perform item-specific logic.

Note 521651 created that solves this problem.

After the tax region of the origin, the tax region of the destination is determined. First, the part-ner table is accessed with the explicit partner function ship-to, then the recipient is searched for.

Then the tax codes of the items are mapped to backend R/3 tax codes.

Now the backend material number is determined by a call to the function module BBP_PROD-UCT_PD_MAP_BE.

Afterwards, the partner table is searched for the vendor and the backend vendor number is de-termined by a call to the function module BUPA_NUMBERS_READ.

Eventually, the backend structure is filled with all values that are relevant for the tax calculation and an RFC call to the function module BBP_CALCULATE_TAX_ITEM40B in the FI R/3 system is issued.

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 51 of 54

Page 52: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

4.10.1.9 RFC Call to Backend System:Function Module BBP_CALCULATE_TAX_ITEM40B

Determine calculation procedure assigned to country of company code of items to be pro-cessed. All items have to belong to the same company code.

Determine the country of the company code.

Fill the table LT_TAXCOM that stores the tax comnmunication data.

Perform FILL_TAXCOM_COUNTRY_SPECIFIC which does country-specific modifica-tions of the TAXCOM table. For Brazil, call the form routine FILL_TAXCOM_BRAZIL.

Store the NCM code of the current item in the function group J1BP by calling the function module J_1B_NF_PO_DISCOUNTS. The NCM code is read later in J_1BCALCULATE_TAXES.

Map the geographical regions that belong to the ship-from and ship-to data to tax regions by calling the function module J_1BDETERMINE_JURISDICTION.

Call the function module CALCULATE_TAX_ITEM that returns the pricing-procedure re-sults table (of structure KOMV). This table is copied to the table ET_TAX_COND that is returned by the function module, filling some additional fields like the item GUID.

Perform FILL_TAX_COND_COUNTRY_SPECIFIC which reads the tax group (IPI, ICMS) of each condition type in the pricing-procedure results table from the DDIC table J_1BAJ and stores it in the table ET_TAX_COND. This will also be displayed in the tax detail screen of the item details in EBP.

4.10.1.10 Continuation of IF_EX_BBP_TAX_ICC~CALCULATE_TAX After Call to Backend FI System

Store the total tax amount of the item also in the item’s tax segment (from which the tax amount is read in the EBP screens).

Clear all additional fields of the item that contain tax details (the components of the DDIC structure bbp_cuf_tax_br.

Transfer the data of the pricing-procedure results table to the corresponding additional tax fields of the item.

Transfer the changes of the item to the global EBP variables by calling the function mod-ules BBP_PROCDOC_GETDETAIL and BBP_ITMPROC_UPDATE.

In case of errors, which are collected in the internal table lt_bapireturn, transfer them to the EBP error log by calling the form routine fill_msg_log_sy.

4.10.1.11 IF_EX_BBP_CUF_BADI_ICC~PUT_DATA

The screen number and program name containing the Brazil-specific screen that displays the additional fields are set. Afterwards, the function module BBP_ICC_PUT_DATA is called. There, the additional tax detail fields of the item are transferred to the table gt_tax_data that is to be displayed in the tax detail table control.

4.10.1.12 IF_EX_BBP_CUF_ICC_BADI~MODIFY_SCREEN

No changes compared to the first call.

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 52 of 54

Page 53: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

4.10.1.13 IF_EX_BBP_CUF_ICC_BADI~MODIFY_OUTPUT

Since the values were already read from the master data, the additional fields are already filled. Therefore, no changes are made to the fields.

Note: However, if a field is empty because the master data was empty as well, the master data are read again! This is only a lack of performance. Since the field is not editable (switched to read-only in BAdI method MODIFY_SCREEN), manual changes cannot be made.

4.10.2 Chronological Sequence When Adding an Item to the SC

Starting from selecting Back to Shopping Cart on the item detail screen, the following steps are being performed.

4.10.2.1 IF_EX_BBP_CUF_ICC_BADI~MODIFY_INPUT

4.10.2.2 IF_EX_BBP_CUF_BADI_ICC~GET_DATA

4.10.2.3 IF_EX_BBP_TAX_ICC~DETERMINE_CALC_FLAG

Now the table it_item has two entries. In the loop over this table it is checked if tax-relevant item data were changed. The first item is processed, compared with the stored item, and no change is found.

Note: The second item is not present in the table mt_old_item. When this table is read with the item GUID, no entry is found and sy-subrc is set to 4. This has to set the recalculation indicator and modify the table!

Anyway, the tables mt_old_item and mt_old_partner are modified to now contain two items, and the recalculation indicator is set.

4.10.2.4 IF_EX_BBP_TAX_ICC~CALCULATE_TAX

Note: See the red note in section 4.10.1.8. The determination of the partners is wrong. It always accesses the partners of the first item! Solved by Note 521651.

The product and partner backend data are determined, and the two items stored in the table lt_item_be. Then the backend function module BBP_CALCULATE_TAX_ITEM40B is called via RFC, which calculates the taxes for both items.

4.10.2.5 RFC Call to Backend System:Function Module BBP_CALCULATE_TAX_ITEM40B

Loop over all items.

For each item, fill the taxcom structure and perform the mappings and additional actions de-scribed in section 4.10.1.9.

For each item, call the function module CALCULATE_TAX_ITEM.

Note: Tax calculation is wrong! Second call to CALCULATE_TAX_ITEM yields a pricing-proce-dure results table that contains data for both items. Consequently, data for first and second item are ttansferred into the tax details of second item.

Solution: After CALCULATE_TAX_ITEM was called for an item, the TKOMV data have to be ap-pended to et_tax_cond as it is done now. However, before the next item is processed, i.e. at the end of the loop, CALCULATE_TAX_ITEM has to be called again, this time with the reset flag

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 53 of 54

Page 54: BAPIS_MUDANÇAS DE LOCALIZ BRASIL

SAP® DESIGNInternal & Confidential

set. This leads to a deletion of the TKOMV data of this item in the local memory of the function group TAX1.

Note 521687 created that solves this problem.

The next steps happen after pressing the Detail button for the second item (no. 20). First, the steps described above are being executed. Here, we continue after a tax code and a net price per unit were informed and PAI was triggered.

4.10.2.6 IF_EX_BBP_CUF_ICC_BADI~MODIFY_INPUT

4.10.2.7 IF_EX_BBP_CUF_BADI_ICC~GET_DATA

4.10.2.8 IF_EX_BBP_TAX_ICC~DETERMINE_CALC_FLAG

The second item has no Brazil-specific product master data. This means, NCM code etc. are still empty. Therefore, the recalculation indicator is not set. However, since the tax code was changed, the standard coding sets the recalculation indicator.

4.10.2.9 IF_EX_BBP_TAX_ICC~CALCULATE_TAX

© 2002 SAP AG

Neurottstr. 16D-69190 Walldorf

Title: EBP 3.0 Localization BrazilVersion: 3.0 SP9Date: 3.0 SP9

Page 54 of 54