sdn filter badi solution business add

Upload: charming-luteraa

Post on 08-Apr-2018

220 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/7/2019 sdn filter badi solution Business Add

    1/12

    Business Add-ins - Filter BADI - Application for

    displaying customer data based on filter value -

    Country code

    Attachments:16

    Added by Harsh Dave, last edited by Harsh Dave on Jun 08, 2009 (view change)

    Business Add-ins (BADI)Filter BADI

    What is a Filter-BADI?

    Business Add-Ins may be implemented on the basis of a filter value. If an enhancement for country-

    specific versions is provided for in the standard version, it is likely that different partners will want to

    implement this enhancement. The individual countries can create and activate their own

    implementation.

    How to define a Filter-BADI and then implement it?

    We encounter a business requirement where different country clients (customers) may have

    different country specific applications. These applications can be integrated centrally in one

    standard application by means of a 'Filter'.

    Here we consider a scenario for three country specific application (say) for India (IN), USA (US) and

    Germany (DE) respectively.

    Note: Here the scenario will be dealt with a BADI created under customer name space for easy

    understanding.

    To enable a BADI to allow 'Filter' implementations, make the BADI filter dependent. In case of a

    standard BADI it should be inbuilt 'Filter dependent'.

    http://wiki.sdn.sap.com/wiki/display/ABAP/Business+Add-ins+-+Filter+BADI+-+Application+for+displaying+customer+data+based+on+filter+value+-+Country+codehttp://wiki.sdn.sap.com/wiki/display/ABAP/Business+Add-ins+-+Filter+BADI+-+Application+for+displaying+customer+data+based+on+filter+value+-+Country+codehttp://wiki.sdn.sap.com/wiki/display/ABAP/Business+Add-ins+-+Filter+BADI+-+Application+for+displaying+customer+data+based+on+filter+value+-+Country+codehttp://wiki.sdn.sap.com/wiki/pages/viewpageattachments.action?pageId=93388909&metadataLink=truehttp://wiki.sdn.sap.com/wiki/pages/viewpageattachments.action?pageId=93388909&metadataLink=truehttp://wiki.sdn.sap.com/wiki/pages/viewpageattachments.action?pageId=93388909&metadataLink=truehttp://wiki.sdn.sap.com/wiki/display/~zaclr8ihttp://wiki.sdn.sap.com/wiki/display/~zaclr8ihttp://wiki.sdn.sap.com/wiki/pages/diffpages.action?pageId=93388909&originalId=107774453http://wiki.sdn.sap.com/wiki/display/ABAP/Business+Add-ins+-+Filter+BADI+-+Application+for+displaying+customer+data+based+on+filter+value+-+Country+codehttp://wiki.sdn.sap.com/wiki/display/ABAP/Business+Add-ins+-+Filter+BADI+-+Application+for+displaying+customer+data+based+on+filter+value+-+Country+codehttp://wiki.sdn.sap.com/wiki/display/ABAP/Business+Add-ins+-+Filter+BADI+-+Application+for+displaying+customer+data+based+on+filter+value+-+Country+codehttp://wiki.sdn.sap.com/wiki/pages/viewpageattachments.action?pageId=93388909&metadataLink=truehttp://wiki.sdn.sap.com/wiki/display/~zaclr8ihttp://wiki.sdn.sap.com/wiki/display/~zaclr8ihttp://wiki.sdn.sap.com/wiki/pages/diffpages.action?pageId=93388909&originalId=107774453
  • 8/7/2019 sdn filter badi solution Business Add

    2/12

    As usual create an interface method,

    Create interface parameters. Here 'FLT_VAL' indicates the parameter which will act as a filter,

  • 8/7/2019 sdn filter badi solution Business Add

    3/12

    Create an implementation for (say) filter value 'INDIA' that is 'IN'.

  • 8/7/2019 sdn filter badi solution Business Add

    4/12

    Navigate inside the method to write the code,

  • 8/7/2019 sdn filter badi solution Business Add

    5/12

    Observe the code for filter value 'INDIA',

    method zif_ex_dave_badi_filter~zdave_method_country.data:begin of fs_kna1,kunnr type kunnr,land1 type land1,name1 type name1,ort01 type ort01,pstlz type pstlz,regio type regio,stras type stras,end of fs_kna1.

    data:t_kna1 like

    standard tableof fs_kna1.

    select kunnrland1name1ort01pstlzregiostras

    from kna1into table

    t_kna1where kunnr = customer

    and land1 = flt_val.

    if sy-subrc eq 0.

    write:/2 'Customer'(001) color 1,15 'India Ctry Key'(002) color 2,35 'Name'(003) color 3,65 'City'(004) color 4,80 'PO code'(005) color 5,95 'Region'(006) color 6,110 'Street'(007) color 7.

    skip.

    loop at t_kna1 into fs_kna1.

    write:/2 fs_kna1-kunnr color 1 inverse,

  • 8/7/2019 sdn filter badi solution Business Add

    6/12

    15 fs_kna1-land1 color 2 inverse,35 fs_kna1-name1 color 3 inverse,65 fs_kna1-ort01 color 4 inverse,80 fs_kna1-pstlz color 5 inverse,95 fs_kna1-regio color 6 inverse,110 fs_kna1-stras color 7 inverse.

    endloop.

    endif.

    endmethod.

    Now, create a filter implementation for country code 'US' that is USA,

    Navigate inside the filter method to code for the filter condition,

  • 8/7/2019 sdn filter badi solution Business Add

    7/12

    Observe the code for filter implementation 'USA',

    method zif_ex_dave_badi_filter~zdave_method_country.data:begin of fs_kna1,kunnr type kunnr,land1 type land1,name1 type name1,sortl type sortl,telf1 type telf1,telfx type telfx,adrnr type adrnr,end of fs_kna1.

    data:t_kna1 like

    standard tableof fs_kna1.

    select kunnrland1name1sortltelf1telfxadrnr

    from kna1into table

    t_kna1where kunnr = customerand land1 = flt_val.

    write:/2 'Customer'(001) color 1,15 'USA Ctry Key'(002) color 2,35 'Name'(003) color 3,65 'Sort Name'(004) color 4,80 'Tel no'(005) color 5,95 'Fax no'(006) color 6,110 'Addr no'(007) color 7.

    skip.

    loop at t_kna1 into fs_kna1.

    write:/2 fs_kna1-kunnr color 1 inverse,

  • 8/7/2019 sdn filter badi solution Business Add

    8/12

    15 fs_kna1-land1 color 2 inverse,35 fs_kna1-name1 color 3 inverse,65 fs_kna1-sortl color 4 inverse,80 fs_kna1-telf1 color 5 inverse,95 fs_kna1-telfx color 6 inverse,110 fs_kna1-adrnr color 7 inverse.

    endloop.

    endmethod.

    Create an implementation for (say) filter value 'GERMANY' that is 'DE'.

    Navigate inside the method to write the code,

  • 8/7/2019 sdn filter badi solution Business Add

    9/12

    Observe the code for filter implementation 'DE',

    method zif_ex_dave_badi_filter~zdave_method_country.data:begin of fs_kna1,kunnr type kunnr,land1 type land1,name1 type name1,anred type anred,erdat type erdat,ktokd type ktokd,lifnr type lifnr,

    end of fs_kna1.

    data:t_kna1 like

    standard tableof fs_kna1.

    select kunnrland1name1anrederdatktokdlifnr

    from kna1into table

    t_kna1where kunnr = customer

    and land1 = flt_val.

    write:/2 'Customer'(001) color 1,15 'DE Ctry Key'(002) color 2,35 'Name'(003) color 3,65 'Title'(004) color 4,80 'Created on'(005) color 5,95 'Acct grp'(006) color 6,110 'Vendor'(007) color 7.

    skip.

    loop at t_kna1 into fs_kna1.

  • 8/7/2019 sdn filter badi solution Business Add

    10/12

    write:/2 fs_kna1-kunnr color 1 inverse,15 fs_kna1-land1 color 2 inverse,35 fs_kna1-name1 color 3 inverse,65 fs_kna1-anred color 4 inverse,80 fs_kna1-erdat color 5 inverse,95 fs_kna1-ktokd color 6 inverse,110 fs_kna1-lifnr color 7 inverse.

    endloop.

    endmethod.

    Now its time to call the enhancements in the customer application,

    Now, execute the application (here report) and test the customer enhancement,

    Test case I - Country code 'INDIA' (IN),

  • 8/7/2019 sdn filter badi solution Business Add

    11/12

    Execute the test data and observe the functionality,

    Test case II - Country code 'USA' (US),

    Execute the test data and observe the functionality,

    Test case III - Country code 'Germany' (DE)

  • 8/7/2019 sdn filter badi solution Business Add

    12/12

    Execute the test data and observe the functionality,