Requirement: Enhanced BP Sales area view to add a Tax Classification custom drop-down field and on BP save, Tax classification value should update on XD02 transaction in ECC from CRM.

1.GIF

2.GIF

3.GIF

4.GIF

5.GIF

6.GIF

7.GIF

8.GIF

METHOD eh_onsave.
DATA:   lv_wa_smof_erpsh    TYPE smof_erpsh,
lv_rfcdest         
TYPE rfcdest,
lr_builheader      
TYPE REF TO cl_crm_bol_entity,
lr_builsale        
TYPE REF TO cl_crm_bol_entity,
lr_pricing         
TYPE REF TO cl_crm_bol_entity,
lv_ztaxclass       
TYPE char1 ,
lr_ztaxclass       
TYPE REF TO cl_bsp_wd_value_node,
lr_coco            
TYPE REF TO zl_bp_head_bspwdcomponent_impl,
lv_bp              
TYPE bu_partner,
ls_sales_area      
TYPE crmt_bupa_il_sales_area .

CALL METHOD super->eh_onsave
EXPORTING
htmlb_event   
= htmlb_event
htmlb_event_ex
= htmlb_event_ex
IMPORTING
ev_success    
= ev_success.
lr_coco ?= me
->comp_controller.
IF ev_success EQ abap_true.
lr_builheader ?= me
->typed_context->builheader->collection_wrapper->get_current( ).
IF lr_builheader IS BOUND.
*TRY.
CALL METHOD lr_builheader->if_bol_bo_property_access~get_property_as_value
EXPORTING
iv_attr_name
= ‘BP_NUMBER’
IMPORTING
ev_result   
= lv_bp.

CALL METHOD lr_builheader->get_related_entity
EXPORTING
iv_relation_name
= ‘BuilSalesArrangementRel’
*         IV_MODE          = NORMAL
RECEIVING
rv_result       
= lr_builsale.
IF lr_builsale IS BOUND.

CALL METHOD lr_builsale->if_bol_bo_property_access~get_properties
IMPORTING
es_attributes
= ls_sales_area.

ENDIF.
ENDIF.
lr_ztaxclass ?= lr_coco
->ztyped_context->ztaxclass->collection_wrapper->get_current( ).

IF lr_ztaxclass IS BOUND.
CALL METHOD lr_ztaxclass->if_bol_bo_property_access~get_property_as_value
EXPORTING
iv_attr_name
= ‘ZTAXCLASS’
IMPORTING
ev_result   
= lv_ztaxclass.
ENDIF.
ENDIF.

** Get the ERP RFC Destination.
CALL FUNCTION ‘CRM_GET_ERP_SYSTEM’
IMPORTING
es_smof_erpsh
= lv_wa_smof_erpsh.

IF sysubrc EQ 0.
lv_rfcdest
= lv_wa_smof_erpshrfcdest.
ENDIF.

IF lv_bp IS NOT INITIAL AND ls_sales_areasales_org_r3 IS NOT INITIAL
AND ls_sales_areachannel IS NOT INITIAL AND ls_sales_areadivision IS NOT INITIAL
AND ls_sales_areadivision IS NOT INITIAL AND lv_rfcdest IS NOT INITIAL.

CALL FUNCTION ‘ZFM_TAX_CLASSIFICATION’ DESTINATION lv_rfcdest
EXPORTING
im_kunnr
= lv_bp
im_vkorg
= ls_sales_areasales_org_r3
im_vtweg
= ls_sales_areachannel
im_spart
= ls_sales_areadivision
im_taxkd
= lv_ztaxclass.
ENDIF.
 
ENDMETHOD.

Development Part-2 in ECC


1. Now Developed a BDC program to update XD02 in ECC


report Z_TXCLSFCN
no standard page heading line-size 255.

PARAMETERS:P_KUNNR TYPE  KUNNR NODISPLAY,
P_VKORG
TYPE  VKORG NODISPLAY,
P_VTWEG
TYPE  VTWEG NODISPLAY,
P_SPART
TYPE  SPART NODISPLAY,
P_TAXKD
TYPE  TAKLD NODISPLAY.

DATA: IT_BDCDATA TYPE STANDARD TABLE OF BDCDATA,
WA_BDCDATA
TYPE BDCDATA.

perform bdc_dynpro      using ‘SAPMF02D’ ‘0101’.
perform bdc_field       using ‘BDC_CURSOR’
‘RF02D-D0320’.
perform bdc_field       using ‘BDC_OKCODE’
‘/00’.
perform bdc_field       using ‘RF02D-KUNNR’
P_KUNNR
.                 “‘11000797’.
perform bdc_field       using ‘RF02D-VKORG’
P_VKORG
.                “‘LW00’.
perform bdc_field       using ‘RF02D-VTWEG’
P_VTWEG
.                  “‘LW’.
perform bdc_field       using ‘RF02D-SPART’
P_SPART
.                 “’99’.
perform bdc_field       using ‘RF02D-D0320’
‘X’.
perform bdc_dynpro      using ‘SAPMF02D’ ‘0320’.
perform bdc_field       using ‘BDC_CURSOR’
‘KNVV-PERFK’.
perform bdc_field       using ‘BDC_OKCODE’
‘=VW’.
perform bdc_field       using ‘KNVV-INCO1’
‘FOB’.
perform bdc_field       using ‘KNVV-INCO2’
‘FOB’.
perform bdc_field       using ‘KNVV-ZTERM’
‘LW01’.
perform bdc_dynpro      using ‘SAPMF02D’ ‘1350’.
perform bdc_field       using ‘BDC_CURSOR’
‘KNVI-TAXKD(01)’.
perform bdc_field       using ‘BDC_OKCODE’
‘=UPDA’.
perform bdc_field       using ‘KNVI-TAXKD(01)’
P_TAXKD
.               “‘0’.

CALL TRANSACTION ‘XD02’
USING IT_BDCDATA
MODE ‘N’
UPDATE ‘A’.

form bdc_dynpro using program dynpro.
clear WA_bdcdata.
WA_bdcdata
program  = program.
WA_bdcdata
dynpro   = dynpro.
WA_bdcdata
dynbegin = ‘X’.
append WA_bdcdata TO IT_BDCDATA.
CLEAR WA_BDCDATA.
endform.

*———————————————————————-*
*        Insert field                                                  *
*———————————————————————-*
form bdc_field using fnam fval.

clear WA_bdcdata.
WA_bdcdata
fnam = fnam.
WA_bdcdata
fval = fval.
append WA_bdcdata TO IT_BDCDATA.
CLEAR WA_BDCDATA.
endform.

9.GIF

Now when save button press the value of Tax Classification will update in ECC- XD02.

10.GIF

Thanks

NVV

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply