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

How to assign characteristics to class using BAPI

Former Member
0 Likes
7,280

Dear All,

I created class using BAPI_CLASS_CREATE, then Created 2 Characteristics using BAPI_CHARACT_CREATE.

Which means I class created as "CLS_001" and characteristics created as "CHAR_001_01" and "CHAR_001_02" respectively.

Now my question is, how can I assign "CHAR_001_01" and "CHAR_001_02" to that class "CLS_001"? Which BAPI i can use for this?

Thanks in advance.

-JANARAJA

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
5,399

Thank you all. Finally I found the Solution. The solution is First we should create charact then class then Assign charact to that class. let me explain bit easier.

loop.

Check Charact n = exist

If true

{

Check Class = Exist

If true

{

Assign Charact to Class with specific Class type.

If False

{

Create Class.

}

If false Create Charact

{

Then Assign Charact(s) to Class

}

Endloop.

-Thanks.

-Regards

Janaraja

Dear All,

I created class using BAPI_CLASS_CREATE, then Created 2 Characteristics using BAPI_CHARACT_CREATE.

Which means I class created as "CLS_001" and characteristics created as "CHAR_001_01" and "CHAR_001_02" respectively.

Now my question is, how can I assign "CHAR_001_01" and "CHAR_001_02" to that class "CLS_001"? Which BAPI i can use for this?

Thanks in advance.

-JANARAJA

14 REPLIES 14
Read only

former_member188827
Active Contributor
0 Likes
5,399

use BAPI_CLASS_CREATE. Please check the link:

http://scn.sap.com/thread/179610

Regards

Read only

Former Member
0 Likes
5,399

Hi Janaraja,

You have two options to assign characteristics to class.

Option1 ) In BAPI BAPI_CLASS_CREATE -> While creating you the Class you can assign.

OPtion 2) In BAPI BAPI_CLASS_CHANGE -> You can assign a created characteristic to the already created class.

After these call BAPI_TRANSACTION_COMMIT and should work.

Revert in case further questions,

BR,

Ankit.

Read only

0 Likes
5,399

Dear Ankit,

I tried to assign characteristics to my particular class using BAPI_CLASS_CREATE.

But Still I can not assign the characteristics. I am using the following code.

*&---------------------------------------------------------------------*
*& Report  ZRBAPI_CLASS_CREATE
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  zrbapi_class_create.

PARAMETERS: pclass TYPE klasse_d,
pcls_typ TYPE klassenart ,
pcls_des TYPE klschl ,
cls_car1 TYPE atnam ,
cls_car2 TYPE atnam ,
cls_car3 TYPE atnam .

DATA: cls_bas_dat LIKE bapi1003_basic,
       it_cls_desc  LIKE bapi1003_catch OCCURS 0 WITH HEADER LINE,
       it_cls_car LIKE bapi1003_charact OCCURS 0 WITH HEADER LINE,
       it_ret  LIKE bapiret2 OCCURS 0 WITH HEADER LINE.

it_cls_desc-langu = 'EN'.
it_cls_desc-langu_iso = 'EN'.
it_cls_desc-catchword = pcls_des.
APPEND it_cls_desc.

it_cls_car-name_char = cls_car1.
APPEND it_cls_car.

it_cls_car-name_char = cls_car2.
APPEND it_cls_car.

it_cls_car-name_char = cls_car3.
APPEND it_cls_car.

CALL FUNCTION 'BAPI_CLASS_CREATE'
EXPORTING
classnumnew                 = pclass
classtypenew                = pcls_typ
*   CHANGENUMBER                =
classbasicdata              = cls_bas_dat
*   CLASSDOCUMENT               =
*   CLASSADDITIONAL             =
*   CLASSSTANDARD               =
TABLES
return                      = it_ret
classdescriptions           = it_cls_desc
*   CLASSLONGTEXTS              =
classcharacteristics        = it_cls_car
*   CHARACTOVERWRITE            =
*   CHARACTVALUEOVERWRITE       =
*   CHARACTVALUETEXTOVR         =
.

LOOP AT it_ret.
   WRITE: / it_ret-type, /, it_ret-id, /, it_ret-number, /, it_ret-message.
   WRITE: /, '_______________________________________________'.
ENDLOOP.


CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
   EXPORTING
     wait   = 'X'
   IMPORTING
     return = it_ret.

But Characteristics not getting assign. Where I am doing mistake.?

Thanks.


Read only

0 Likes
5,399

hey, i checked your code its working perfectly, i don't see any reason you should continue this thread.

its perfectly fine..

the only thing is you should have characteristics ready to assign them to the class.

everything else is fine.

Thumbs UP. 

if you still have doubts. give me what is the message you are getting back... but your code is good.

Read only

0 Likes
5,399

Hi Janaraja,

The characteristic which you intend to pass from selection screen to it_cls_car should exist and be visible in CT04 transaction. Then your code works fine.

See your code modified by me and attached screenshots for your reference.

REPORT  YTEST.

PARAMETERS: pclass TYPE klasse_d,

pcls_typ TYPE klassenart ,

pcls_des TYPE klschl ,

cls_car1 TYPE atnam .

*cls_car2 TYPE atnam ,

*cls_car3 TYPE atnam .

DATA: cls_bas_dat LIKE bapi1003_basic,

        it_cls_desc  LIKE bapi1003_catch OCCURS 0 WITH HEADER LINE,

        it_cls_car LIKE bapi1003_charact OCCURS 0 WITH HEADER LINE,

        it_ret  LIKE bapiret2 OCCURS 0 WITH HEADER LINE.

it_cls_desc-langu = 'EN'.

it_cls_desc-langu_iso = 'EN'.

it_cls_desc-catchword = pcls_des.

APPEND it_cls_desc.

it_cls_car-name_char = cls_car1.

APPEND it_cls_car.

*it_cls_car-name_char = cls_car2.

*APPEND it_cls_car.

*

*it_cls_car-name_char = cls_car3.

*APPEND it_cls_car.

CALL FUNCTION 'BAPI_CLASS_CREATE'

EXPORTING

classnumnew                 = pclass

classtypenew                = pcls_typ

*   CHANGENUMBER                =

classbasicdata              = cls_bas_dat

*   CLASSDOCUMENT               =

*   CLASSADDITIONAL             =

*   CLASSSTANDARD               =

TABLES

return                      = it_ret

classdescriptions           = it_cls_desc

*   CLASSLONGTEXTS              =

classcharacteristics        = it_cls_car

*   CHARACTOVERWRITE            =

*   CHARACTVALUEOVERWRITE       =

*   CHARACTVALUETEXTOVR         =

.

LOOP AT it_ret.

    WRITE: / it_ret-type, /, it_ret-id, /, it_ret-number, /, it_ret-message.

    WRITE: /, '_______________________________________________'.

ENDLOOP.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

    EXPORTING

      wait   = 'X'

    IMPORTING

      return = it_ret.

Run Procedure -

Output -

Now see the class (901) and characteristic (Test 3) in CL03.

Please revert in case of further Q's.

BR.

Read only

Former Member
0 Likes
5,399

Hi Janaraja,

Check these Information Notes also Sample Code given by SAP :

Note 1083986 - BAPIs for classification - Overview

Note 1323945 - BAPI_CLASS_CREATE: Instructions for use

Note 1479120 - BAPI_CHARACT_CREATE: Operating instructions

Note 1235844 - BAPI_CLASS_CHANGE: Operating instructions

As per your requirement , if you already create class using "BAPI_CLASS_CREATE" without Characteristics .

then you create two characteristics using "BAPI_CHARACT_CREATE" .

Now you want to assign these characteristics to class , mean you must change your class with assign these characteristics, for Changing the Class use

BAPI_CLASS_CHANGE. if you use this Class change BAPI , use one more BAPI (i.e.  "BAPI_CLASS_GETDETAIL")  before assign any value into "BAPI_CLASS_CHANGE" .

Check the Sample Code in Note 1235844 - BAPI_CLASS_CHANGE: Operating instructions

Regard's

Smruti

Read only

Former Member
0 Likes
5,399

Hi lakshmanan,

use BAPI BAPI_CLASS_CHANGE,

CLASSNUM = class_name

CLASSTYPE = 003 "class type

CLASSDESCRIPTIONS = description ' key word

CLASWSCHARACTERISTICSNEW = character name " which we want to assign to the class.

call BAPI_TRANSACTION_COMMIT.

Regards

Satish Chandra

Read only

Former Member
0 Likes
5,399

Hi Lakshmanan,

If you are using BAPI_CLASS_CREATE, here the Character should already exist.

hence what we are doing here is, we creating a new class and assigning a character which already exists to it.

BAPI_CLASS_CREATE

CLASSNUMNEW = class name

CLASSTYPENEW = class type

CLASSDESCRIPTIONS = description                    " en en description

CLASSCHARACTERISTICS = character_name     " name_char = character name

Regards

Satish Chandra

Read only

venkateswaran_k
Active Contributor
0 Likes
5,399

Hi

Use :    'BAPI_CHARACT_CREATE'

This will work..

Regards,

Venkat

Read only

0 Likes
5,399

Hi Venkateswaran,

i don't see how could the bapi u gave could solve the issue?

Regards

satish Chandra

Read only

former_member821147
Participant
0 Likes
5,399

Hi,

try below Bapis.

BAPI_OBJCL_CREATE and BAPI_OBJCL_CHANGE

Thanks,

Pradeep P

Read only

0 Likes
5,399

Pradeeep,

those BAPIs are for object class assignment.

if you want to assign a classification to a Functional location or Equipment or Material then, we  could use the BAPIs you mentioned.

Read only

Former Member
0 Likes
5,400

Thank you all. Finally I found the Solution. The solution is First we should create charact then class then Assign charact to that class. let me explain bit easier.

loop.

Check Charact n = exist

If true

{

Check Class = Exist

If true

{

Assign Charact to Class with specific Class type.

If False

{

Create Class.

}

If false Create Charact

{

Then Assign Charact(s) to Class

}

Endloop.

-Thanks.

-Regards

Janaraja

Read only

0 Likes
5,399

Welcome Janaraja.. .Happy to hear that.

Please close this thread now.

BR.