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

Function module for classifications/characteristics

Former Member
0 Likes
13,016

Can anyone suggest a function module or bapi I can use to get values for characteristics.

We are using characteristics to store additional information about fleet vehicles that are not included as standard SAP fields.

At the moment, I am using a couple of database calls, using tables 'CABN' and 'AUSP' to find values of these characteristics for a particular vehicle.

There must be an easier way, using a function module or bapi. Could anyone shed some light?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
5,387

Hi Stuart,

You can use 'BAPI_OBJCL_GETCLASSES' and 'BAPI_OBJCL_GETDETAIL' to get the value of the characteristics.

See the Example.

(I am assuming that you are mentioning about the characteristics of an Equipment)

ws_equipment = ‘1012122’.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = ws_equipment

IMPORTING

output = ws_equipment.

i_object-object = ws_equipment.

i_object-objecttable = EQUI.

i_object-classtype = 002.

APPEND i_object.

CALL FUNCTION 'BAPI_OBJCL_GETCLASSES'

EXPORTING

objectkey_imp = i_object-object

objecttable_imp = i_object-objecttable

classtype_imp = i_object-classtype

read_valuations = 'X'

TABLES

alloclist = i_alloclist

allocvalueschar = i_allocvaluescharnew

allocvaluesnum = i_allocvaluesnumnew

allocvaluescurr = i_allocvaluescurrnew

return = i_return.

LOOP AT i_alloclist.

CASE i_alloclist-classnum.

WHEN "classname".

CALL FUNCTION 'BAPI_OBJCL_GETDETAIL'

EXPORTING

objectkey = i_object-object

objecttable = i_object-objecttable

classnum = i_alloclist-classnum

classtype = i_object-classtype

unvaluated_chars = 'X'

TABLES

allocvaluesnum = i_allocvaluesnumnew

allocvalueschar = i_allocvaluescharnew

allocvaluescurr = i_allocvaluescurrnew

return = i_return.

LOOP AT i_allocvaluescharnew.

CASE i_allocvaluescharnew-charact.

WHEN ‘characteristic name’

Fetch the current value of the characteristic from i_allocvaluescharnew-value_char

ENDCASE.

ENDLOOP.

Tip: If the characteristic is NUM, then get the corresponding value from i_allocvaluesnumnew

Regards,

Bittu

12 REPLIES 12
Read only

Former Member
0 Likes
5,387

Use CLAF_CLASSIFICATION_OF_OBJECTS.

Read only

Former Member
0 Likes
5,387

You can use the bapi: BAPI_CLASS_GET_CHARACTERISTIC

Regards,

ravi

Read only

RichHeilman
Developer Advocate
Developer Advocate
5,387

Have you tried...... CUOBJ is the internal object number. This works good for us when getting characteristics for a sales doc item(VBAP-CUOBJ).



* Internal Table for Characteristic Data
  data: begin of i_char occurs 0.
          include structure comw.
  data: end of i_char.
  clear i_char.  refresh i_char.

* Retrieve Characteristics.
  call function 'CUD0_GET_VAL_FROM_INSTANCE'
       exporting
            instance           = cuobj
       tables
            attributes         = i_char
       exceptions
            instance_not_found = 1.


Is this what you are looking for?

Regards,

Rich Heilman

Read only

0 Likes
5,387

Hai Rich Heilman ,

It works fine.

Thanks.

J.Chandaran

Read only

Former Member
0 Likes
5,387

Hi,

you can try this BAPI <b>BAPI_CLASS_GET_CLASSIFICATIONS</b>

Regards

vijay

Read only

0 Likes
5,387

Thanks for the replies guys.

I have had a look at

CLAF_CLASSIFICATION_OF_OBJECTS

BAPI_CLASS_GET_CHARACTERISTIC

BAPI_CLASS_GET_CLASSIFICATIONS

but either they don't do what I want, or my knowledge is insufficient :oP

As for CUOBJ - I am using equipment that have classifications, however the CUOBJ field in table EQUI is not filled.

Read only

0 Likes
5,387

Hi,

For a given object, the following functions should give the details of the classification / characteristic values.

BAPI_OBJCL_GETDETAIL

This will give the details of the classes to which the Equipement belongs

BAPI_OBJCL_GETCLASSES

Pass the Equipment number as the object number to the function modules.

Regards,

Ravi

Read only

Former Member
5,387

Just check Function Modules <b>CLSE_SELECT_CABN and CLSE_SELECT_CAWN</b> for Reading characteristic attributes and Reading characteristic values respectively.

Also have a look at <b>BAPI_OBJCL_GETDETAIL</b> for which object table as 'MARA'.

rgds,

TM.

Please mark point if helpful.

Read only

Former Member
0 Likes
5,388

Hi Stuart,

You can use 'BAPI_OBJCL_GETCLASSES' and 'BAPI_OBJCL_GETDETAIL' to get the value of the characteristics.

See the Example.

(I am assuming that you are mentioning about the characteristics of an Equipment)

ws_equipment = ‘1012122’.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = ws_equipment

IMPORTING

output = ws_equipment.

i_object-object = ws_equipment.

i_object-objecttable = EQUI.

i_object-classtype = 002.

APPEND i_object.

CALL FUNCTION 'BAPI_OBJCL_GETCLASSES'

EXPORTING

objectkey_imp = i_object-object

objecttable_imp = i_object-objecttable

classtype_imp = i_object-classtype

read_valuations = 'X'

TABLES

alloclist = i_alloclist

allocvalueschar = i_allocvaluescharnew

allocvaluesnum = i_allocvaluesnumnew

allocvaluescurr = i_allocvaluescurrnew

return = i_return.

LOOP AT i_alloclist.

CASE i_alloclist-classnum.

WHEN "classname".

CALL FUNCTION 'BAPI_OBJCL_GETDETAIL'

EXPORTING

objectkey = i_object-object

objecttable = i_object-objecttable

classnum = i_alloclist-classnum

classtype = i_object-classtype

unvaluated_chars = 'X'

TABLES

allocvaluesnum = i_allocvaluesnumnew

allocvalueschar = i_allocvaluescharnew

allocvaluescurr = i_allocvaluescurrnew

return = i_return.

LOOP AT i_allocvaluescharnew.

CASE i_allocvaluescharnew-charact.

WHEN ‘characteristic name’

Fetch the current value of the characteristic from i_allocvaluescharnew-value_char

ENDCASE.

ENDLOOP.

Tip: If the characteristic is NUM, then get the corresponding value from i_allocvaluesnumnew

Regards,

Bittu

Read only

0 Likes
5,387

Here's what I currently use

SELECT SINGLE atinn FROM cabn INTO char_no
                      WHERE atnam = 'WARRANTY_SUPPLIER1'.
  SELECT SINGLE atwrt FROM ausp INTO wa_vehicle-warr_supp1
                      WHERE objek = wa_vehicle-equnr
                      AND   atinn = char_no.

Are there any reasons why I shouldn't do it this way?

It seems quicker than calling two BAPIs

Read only

0 Likes
5,387

There is no issue using your won select statement. Infact, if you drill down BAPI also will be fetching values from the same tables.

However, the BAPI will give you far more details. So, if you need more details you can use the BAPI without worrying about from which table they are coming.

In fact your SELECT statements might be more efficient in this case as the data you are selecting is limited.

Regards,

Ravi

Note : Please mark the helpful answers and close the thread if the issue is resolved.

Read only

0 Likes
5,387

You can do this way also...

The table which you are using are correct tables. classifications/characteristics values present in those tables.

Regards

vijay