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.
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 sy-subrc EQ 0.
lv_rfcdest = lv_wa_smof_erpsh-rfcdest.
ENDIF.
IF lv_bp IS NOT INITIAL AND ls_sales_area-sales_org_r3 IS NOT INITIAL
AND ls_sales_area-channel IS NOT INITIAL AND ls_sales_area-division IS NOT INITIAL
AND ls_sales_area-division 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_area-sales_org_r3
im_vtweg = ls_sales_area-channel
im_spart = ls_sales_area-division
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 NO-DISPLAY,
P_VKORG TYPE VKORG NO-DISPLAY,
P_VTWEG TYPE VTWEG NO-DISPLAY,
P_SPART TYPE SPART NO-DISPLAY,
P_TAXKD TYPE TAKLD NO-DISPLAY.
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.
Now when save button press the value of Tax Classification will update in ECC- XD02.
Thanks
NVV
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
5 | |
5 | |
4 | |
4 | |
4 | |
4 | |
3 | |
3 | |
3 |