Skip to Content
0
Feb 12, 2006 at 08:27 PM

Transfer Inforecord Conditions Scales to SRM Product Master

127 Views

Hi

<b>REQUIREMENT</b>

We have a requirement to transfr Material Vendor info record conditions data to SRM Product master since standard Product transfer object MATERIAL in R3AS can't transfer

<b>WHAT WE DID</b>

we implemented BADI PRODUCT_CUSTOMER2 method map_r3_to_crm_material to make RFC call to R/3 and grab inforecord conditions and populate in BADI structure cs_product_bdoc-conditions. This conditions structure has various nested structures some for scales some for conditions.

Populated following structures for scales

data:w_amt type /1cn/lbpscb__lin_s,

w_qty type /1cn/lbpscc__lin_s,

w_def type /1cn/lbpscaledef_s,

w_dim type /1cn/lbpscaledim_s,

w_evl type /1cn/lbpscaleevl_s,

w_ev1 type /1CN/LBPSCALEV01_S,

w_ev2 type /1CN/LBPSCALEV02_S.

<b>

ISSUE</b>

Conditions are transferred fine but scales are not transferred after filling the structures. In SMWO1 the log shows Everything successful so i can't even debug this process to troubleshoot .

<b>HELP WE NEED</b>

How to Debug R3AS Process ???? to see what's wrong with BADI maybe i am not populating the structures appropriately

Anyone who did this before can you look at the code and let me know please what is missing.

i have attached code of BADI what we did

method if_ex_product_customer2~map_r3_to_crm_material.

----


  • WORK AREAS *

----


data: w_matnr type bbps_bapieina-material,

w_transid type zxref-ztransid,

w_in type zxref-zin,

w_out type zxref-zout,

w_dest type rfcdest,

w_infor_gen type bbps_bapieina,

w_infor_purorg type bbps_bapieine,

w_conditions type /1cn/working_set_i_d_bbp,

w_bdoc_dtyp type comt_prod_service_bdoc,

  • Product: Vendor Material Number Relationship

w_prdvnd_rel type comt_il_prdvnd_maintain,

  • Product: Manufacturer Number Relationship

w_prdmpn_rel type comt_il_prdmpn_maintain,

w_but000 type but000,

w_action.

----


  • INTERNAL TABLES *

----


data: t_infor_gen type table of bbps_bapieina,

t_infor_purorg type table of bbps_bapieine,

t_return type table of bapireturn.

******************/start-types/************

types: begin of ty_ekomd,

ebelp type numc5,

kschl type /sapcnd/cond_type,

knumh type char10,

kopos type numc2,

klfn1 type numc4,

datab type dats,

datbi type dats,

kbetr type wert11v,

koein type bapibp_curr,

kpein type prct_cond_pricing_unit,

kmein type prct_prod_uom,

vtext type char30,

kstbm type crmquant15,

kstbw type prct_cond_rate,

konws type prct_cond_scale_curr,

konwa type prct_cond_curr,

stfkz type /sapcnd/scale_type,

kzbzg type char1,

konms type prct_cond_scale_uom,

werks type werks_d,

bstme type prct_base_uom,

kont_pack type numc10,

kont_zeile type numc10,

end of ty_ekomd.

data:t_ekomd type standard table of ty_ekomd,

w_ekomd like line of t_ekomd,

wekomd like line of t_ekomd,

w_plant type ewerk value ' ',

w_samount type /1cn/lbpscalev02_s,

w_sqnt type /1cn/lbpscc__lin_s.

data:w_amt type /1cn/lbpscb__lin_s,

w_qty type /1cn/lbpscc__lin_s,

w_def type /1cn/lbpscaledef_s,

w_dim type /1cn/lbpscaledim_s,

w_evl type /1cn/lbpscaleevl_s,

w_ev1 type /1CN/LBPSCALEV01_S,

w_ev2 type /1CN/LBPSCALEV02_S.

data:w_scaleid type /1cn/lbpscb__lin_s-scale_id,

w_num(2) type n,

w_first.

******************/end-types/**************

clear: w_bdoc_dtyp,w_matnr,t_return,t_infor_purorg,t_infor_gen,

w_infor_gen, w_action.

refresh:t_return,t_infor_purorg,t_infor_gen.

move-corresponding cs_product_bdoc to w_bdoc_dtyp.

w_matnr = is_mara-material.

*GET RFC DESTINATION

w_transid = 'ZRFCDEST'.

w_in = sy-sysid.

clear: w_out,w_dest.

call function 'Z_GET_XREF_VALUE'

exporting

i_xrefid = w_transid

i_input = w_in

importing

e_output = w_out

exceptions

nodatafound = 1

others = 2.

w_dest = w_out.

check not w_dest is initial.

  • Function Module for Material Number Conversion (INPUT)

call function 'CONVERSION_EXIT_MATN1_INPUT'

exporting

input = w_matnr

importing

output = w_matnr

exceptions

length_error = 1

others = 2.

check not w_matnr is initial.

case is_mara-operation.

when '003'.

w_action = 'D'.

when '004' or '005'.

w_action = 'U'.

when '009'.

w_action = 'I'.

when others.

clear w_action.

endcase.

  • Get Vendor info records and conditions using material

call function 'BBP_INFORECORD_GETLIST'

destination w_dest

exporting

material = w_matnr

purchorg_data = 'X'

general_data = 'X'

tables

inforecord_general = t_infor_gen

inforecord_purchorg = t_infor_purorg

return = t_return.

loop at t_infor_gen into w_infor_gen

where not vendor is initial and delete_ind is initial.

clear:w_but000.

  • Get Partner/Vendor GUID with vendor

call function 'BUP_BUT000_SELECT_SINGLE'

exporting

i_partner = w_infor_gen-vendor

i_valdt = sy-datum

importing

e_but000 = w_but000

exceptions

not_found = 1

internal_error = 2

others = 3.

check not w_but000-partner_guid is initial.

*append material vendor relationship

w_bdoc_dtyp-interlink-product_guid = is_mara-matguid.

w_prdvnd_rel-data-client = sy-mandt.

w_prdvnd_rel-data-sourceguid = is_mara-matguid.

w_prdvnd_rel-data-destinguid = w_but000-partner_guid..

w_prdvnd_rel-data-reltype = 'PRDVND'.

w_prdvnd_rel-data-prid_vendor = w_infor_gen-vend_mat.

*check if not populated use sy-datum

w_prdvnd_rel-data-valid_from = w_infor_gen-suppl_from.

w_prdvnd_rel-data-logsys = w_out.

w_prdvnd_rel-update_type = w_action.

append w_prdvnd_rel to w_bdoc_dtyp-interlink-comm_il_prdvnd.

clear w_prdvnd_rel.

************************************************************

call function 'Z_GET_INFORECORD_CONDITIONS'

destination w_dest

exporting

i_ekorg = w_infor_purorg-purch_org

i_esokz = w_infor_purorg-info_type

i_infnr = w_infor_gen-info_rec

i_lifnr = w_infor_gen-vendor

i_matkl = w_infor_gen-mat_grp

i_matnr = w_matnr "w_infor_gen-MATERIAL

i_werks = w_plant "w_infor_purorg-PLANT

  • I_VABME = w_infor_gen-VAR_ORD_UN

tables

t_ekomd = t_ekomd

exceptions

invalidinput = 1

nodatafound = 2

others = 3.

*append scales

sort t_ekomd by klfn1.

clear:wekomd.

read table t_ekomd into wekomd with key klfn1 = '0000'.

clear: w_ekomd, w_first.

loop at t_ekomd into w_ekomd where klfn1 ne '0000'.

*Scale ID

clear w_scaleid.

call function 'GUID_CREATE'

importing

ev_guid_16 = w_scaleid.

*Amount

w_amt-scale_id = w_scaleid.

w_amt-scale_amount = w_ekomd-kbetr.

w_amt-dbaction = w_action.

append w_amt to w_conditions-/sapcnd/sbpb__lin.

clear w_amt.

*Quantity

w_qty-scale_id = w_scaleid.

w_qty-scale_amount = w_ekomd-kstbm.

w_qty-dbaction = w_action.

append w_qty to w_conditions-/sapcnd/sbpc__lin.

clear w_qty.

*Dimension

w_dim-varnumh = w_ekomd-knumh.

w_dim-scale_id = w_scaleid.

w_dim-dim_id = w_num.

w_dim-dbaction = w_action.

append w_dim to w_conditions-/sapcnd/sbpdim.

clear w_dim.

*evaluation

w_evl-varnumh = w_ekomd-knumh.

w_evl-eval_type = 'C'.

w_evl-kpein = w_ekomd-kpein.

w_evl-kmein = w_ekomd-kmein.

w_evl-konwa = w_ekomd-konwa.

w_evl-dbaction = w_action.

append w_evl to w_conditions-/sapcnd/sbpevl.

*definition

clear w_def.

if w_first is initial.

w_def-scale_id = w_scaleid.

w_def-scale_base_type = wekomd-kzbzg.

w_def-scale_type = wekomd-stfkz.

w_def-scale_unit = wekomd-konms.

w_def-dbaction = w_action.

w_def-scale_currency = wekomd-konwa.

append w_def to w_conditions-/sapcnd/sbpdef.

else.

w_def-scale_id = w_scaleid.

w_def-scale_base_type = w_ekomd-kzbzg.

w_def-scale_type = w_ekomd-stfkz.

w_def-scale_unit = w_ekomd-konms.

w_def-dbaction = w_action.

w_def-scale_currency = w_ekomd-konwa.

append w_def to w_conditions-/sapcnd/sbpdef.

endif.

w_first = 'N'.

*ev1

clear w_ev1.

w_ev1-varnumh = w_ekomd-knumh.

w_ev1-eval_type = 'C'.

w_ev1-kbetr = w_ekomd-kbetr.

w_ev1-dbaction = w_action.

append w_ev1 to w_conditions-/SAPCND/SBPV01.

*ev2

clear w_ev2.

w_ev2-varnumh = w_ekomd-knumh.

w_ev2-eval_type = 'C'.

w_ev2-kbetr = w_ekomd-kbetr.

w_ev2-dbaction = w_action.

append w_ev2 to w_conditions-/SAPCND/SBPV02.

endloop.

************************************************************

*append conditions for the vendor

clear w_infor_purorg.

read table t_infor_purorg into w_infor_purorg

with key info_rec = w_infor_gen-info_rec.

check not w_infor_purorg is initial.

w_conditions-client = sy-mandt.

w_conditions-kschl = '0100'. "condition type

w_conditions-kvewe = 'PR'. "Usage for Condition Technique

w_conditions-kotabnr = 'SAP001'."Condition Table

w_conditions-kappl = 'BBP'. "Application as Condition Technique

w_conditions-krech = 'C'. "Calculation Type for Condition

w_conditions-konwa = w_infor_purorg-currency. "Condition Currency

w_conditions-kbetr = w_infor_purorg-net_price. "Condition Rate

w_conditions-vendor = w_but000-partner_guid. "Vendor GUID

  • Internal Unique ID of Product

w_conditions-product = w_infor_gen-material.

  • Unit of Measure for Product-Specific Quantity

w_conditions-kmein = w_infor_purorg-orderpr_un.

  • Condition Pricing Unit

w_conditions-kpein = w_infor_purorg-price_unit.

w_conditions-varnumh = w_ekomd-knumh.

w_conditions-scale_dim = w_num.

append w_conditions to w_bdoc_dtyp-conditions-cnd_bbp_working_set.

clear w_conditions.

endloop.

delete adjacent duplicates from

w_bdoc_dtyp-conditions-cnd_bbp_working_set.

delete adjacent duplicates from

w_bdoc_dtyp-interlink-comm_il_prdmpn.

w_bdoc_dtyp-conditions-pr_number =

w_bdoc_dtyp-header-pr_number.

move-corresponding w_bdoc_dtyp to cs_product_bdoc.

endmethod.