Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Classification uploading

Former Member
0 Likes
465

Hi !

I need to upload massive characteristic and their values.

Is in abap Bapi/Function for this task ?

Please give me a code examples how to use the Bapi/Function.

Thanks

Moshe

2 REPLIES 2
Read only

Former Member
0 Likes
396

Hi ,

You can upload the Characteristics using the bapi 'BAPI_OBJCL_CHANGE'.

Go thru the following example code..hope it may help you ...

&----


*& Form F_CREATE_CLSF

&----


  • Create classification

----


form f_create_clsf.

  • Populate with new records to be created

perform f_fill_bapi_tables.

  • Call BAPI

perform f_bapi_objcl_change tables i_av_num

i_av_char

i_av_curr

i_return.

  • Check for errors and set the commit flag.

loop at i_return where type = 'S'.

g_commit = 'X'.

endloop.

endform. " F_CREATE_CLSF

&----


*& Form F_FILL_BAPI_TABLES

&----


  • text

----


form f_fill_bapi_tables.

data : begin of i_yrel_cawnt occurs 0,

atwtb like yrel_cawnt-atwtb,

atwrt like yrel_cawnt-atwrt,

end of i_yrel_cawnt.

data : begin of i_yrel_t163i occurs 0,

knttp like yrel_t163i-knttp,

knttx like yrel_t163i-knttx,

end of i_yrel_t163i.

  • Populate data

refresh :

i_av_num, i_av_char, i_av_curr, i_return.

select atwtb atwrt

into table i_yrel_cawnt

from yrel_cawnt

where spras = sy-langu.

select knttp knttx

into table i_yrel_t163i

from yrel_t163i

where spras = sy-langu.

loop at i_yrel_class.

  • Purchasing document category

if not i_yrel_class-pocat is initial.

clear i_av_char.

i_av_char-value_char = i_yrel_class-pocat.

read table i_yrel_cawnt with key atwtb = i_yrel_class-pocat.

if sy-subrc = 0.

i_av_char-value_neutral = i_yrel_cawnt-atwrt.

clear i_yrel_cawnt.

endif.

i_av_char-charact = 'MM_PUR_DOC_DOCUMENT_CATEGORY'.

i_av_char-charact_descr = 'Purchasing document category'.

append i_av_char.

endif.

  • Purchasing organization

if not i_yrel_class-ekorg is initial.

clear i_av_char.

i_av_char-charact = 'MM_PUR_ORG_PURCHASING_DOC'.

i_av_char-value_char = i_yrel_class-ekorg.

i_av_char-charact_descr = 'Purchasing organization'.

append i_av_char.

endif.

  • Plant

if not i_yrel_class-werks is initial.

clear i_av_char.

i_av_char-charact = 'MM_PLANT_PURCHASING_DOC'.

i_av_char-value_char = i_yrel_class-werks.

i_av_char-charact_descr = 'Plant'.

append i_av_char.

endif.

  • Account Assignment Category

if not i_yrel_class-knttx is initial.

clear i_av_char.

i_av_char-value_char = i_yrel_class-knttx.

read table i_yrel_t163i with key knttx = i_yrel_class-knttx.

if sy-subrc = 0.

i_av_char-value_neutral = i_yrel_t163i-knttp.

clear i_yrel_t163i.

endif.

i_av_char-charact = 'MM_PO_ACCOUNT_ASSIGNMENT_CAT'.

i_av_char-charact_descr = 'Account Assignment Category'.

append i_av_char.

endif.

  • Cost Center/Approval Route

clear i_av_char.

i_av_char-charact = 'MM_PO_APPROVAL'.

i_av_char-charact_descr = 'Cost Center/Approval Route'.

if i_yrel_class-kostl is initial.

if i_yrel_class-apprt is initial.

if not i_yrel_class-code is initial.

i_av_char-value_char = i_yrel_class-code.

append i_av_char.

endif.

else.

i_av_char-value_char = i_yrel_class-apprt.

append i_av_char.

endif.

else.

i_av_char-value_char = i_yrel_class-kostl.

append i_av_char.

endif.

clear i_av_char.

  • Total net order value

if not i_yrel_class-netval is initial.

perform translate_value using i_yrel_class-netval

val_low

val_high

val_opercd

val_unit

rcode.

clear i_av_curr.

i_av_curr-charact = 'MM_PUR_DOC_OVERALL_TOTAL_VAL'.

i_av_curr-value_from = val_low.

i_av_curr-value_to = val_high.

i_av_curr-charact_descr = 'Total net order value'.

append i_av_curr.

clear : val_low, val_high, val_opercd, val_unit.

endif.

endloop.

endform. " F_FILL_BAPI_TABLES

&----


*& Form F_BAPI_OBJCL_CHANGE

&----


  • This BAPI changes an existing classification, or creates the

  • classification if it does not yet exist.

----


form f_bapi_objcl_change tables p_i_av_num

p_i_av_char

p_i_av_curr

p_i_return.

  • Export parameters

data : l_objectkey type bapi1003_key-object,

l_objecttable type bapi1003_key-objecttable,

l_classnum type bapi1003_key-classnum,

l_classtype type bapi1003_key-classtype.

  • Populate data

concatenate g_frggr g_frgsx into l_objectkey.

l_objecttable = c_objecttable. " 'T16FS'.

l_classnum = c_classnum. " 'MM_PO_RELEASE'

l_classtype = c_classtype. " '032'

call function 'BAPI_OBJCL_CHANGE' destination g_destination

exporting

objectkey = l_objectkey

objecttable = l_objecttable

classnum = l_classnum

classtype = l_classtype

status = '1'

  • STANDARDCLASS =

  • CHANGENUMBER =

  • KEYDATE = SY-DATUM

  • NO_DEFAULT_VALUES = ' '

importing

classif_status = g_clsf_status

tables

allocvaluesnumnew = p_i_av_num

allocvaluescharnew = p_i_av_char

allocvaluescurrnew = p_i_av_curr

return = p_i_return

.

endform. " F_BAPI_OBJCL_CHANGE

Regards,

Jayaram...

Read only

Former Member
0 Likes
396

Hi,

U can use the BAPI "BAPI_CHARACT_CREATE" also .

Go thru the documantationf of the BAPI.

Reward Points if it is Useful.

THanks,

Manjunath MS