Application Development 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: 

Function module for classifications/characteristics

Former Member
0 Kudos
9,218

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

Former Member
0 Kudos
1,589

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

Former Member
0 Kudos
1,589

Use CLAF_CLASSIFICATION_OF_OBJECTS.

former_member181962
Active Contributor
0 Kudos
1,589

You can use the bapi: BAPI_CLASS_GET_CHARACTERISTIC

Regards,

ravi

RichHeilman
Developer Advocate
Developer Advocate
1,589

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

0 Kudos
1,589

Hai Rich Heilman ,

It works fine.

Thanks.

J.Chandaran

former_member188685
Active Contributor
0 Kudos
1,589

Hi,

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

Regards

vijay

0 Kudos
1,589

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.

0 Kudos
1,589

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

Former Member
1,589

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.

Former Member
0 Kudos
1,590

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

0 Kudos
1,589

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

0 Kudos
1,589

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.

0 Kudos
1,589

You can do this way also...

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

Regards

vijay