2011 Nov 22 1:22 PM
Hi All,
I have customer number,how can I get class and Characterestic Description and Value of that class for the given customer number?
which all tables I should use to get required values?
Please explain in detail,
Thanks
Ashik
Edited by: ashik03 on Nov 22, 2011 6:53 PM
2011 Nov 22 9:47 PM
HI,
Please use the below code
*--Get the class values from the BAPI
{CALL FUNCTION 'BAPI_OBJCL_GETCLASSES'
EXPORTING
objectkey_imp = lv_kunnr
objecttable_imp = 'KNA1'
classtype_imp = '011'
keydate = sy-datum
language = sy-langu
TABLES
alloclist = lt_alloc
return = t_return.
*--Get the characteristics values from the BAPI
CALL FUNCTION 'BAPI_OBJCL_GETDETAIL'
EXPORTING
objectkey = lw_alloc-object
objecttable = 'KNA1'
classnum = lw_alloc-classnum
classtype = lw_alloc-classtype
keydate = sy-datum
language = sy-langu
TABLES
allocvaluesnum = lt_dummy1
allocvalueschar = lt_values
allocvaluescurr = lt_dummy
return = t_return.}
you can also refer to the below tables:
CABN/CABNT--> Characteristic name description
CAWN/CAWNT--> Characteristic Name
Thanks,
Manish
Edited by: Manish_SDN on Nov 22, 2011 11:07 PM
Hi All,
I have customer number,how can I get class and Characterestic Description and Value of that class for the given customer number?
which all tables I should use to get required values?
Please explain in detail,
Thanks
Ashik
Edited by: ashik03 on Nov 22, 2011 6:53 PM
2011 Nov 22 3:34 PM
Customer No. is stored in table KNA1. So you can get other related fields from that table of a particular customer no.
Edited by: Arthas.Archmage on Nov 22, 2011 4:51 PM
2011 Nov 22 9:47 PM
HI,
Please use the below code
*--Get the class values from the BAPI
{CALL FUNCTION 'BAPI_OBJCL_GETCLASSES'
EXPORTING
objectkey_imp = lv_kunnr
objecttable_imp = 'KNA1'
classtype_imp = '011'
keydate = sy-datum
language = sy-langu
TABLES
alloclist = lt_alloc
return = t_return.
*--Get the characteristics values from the BAPI
CALL FUNCTION 'BAPI_OBJCL_GETDETAIL'
EXPORTING
objectkey = lw_alloc-object
objecttable = 'KNA1'
classnum = lw_alloc-classnum
classtype = lw_alloc-classtype
keydate = sy-datum
language = sy-langu
TABLES
allocvaluesnum = lt_dummy1
allocvalueschar = lt_values
allocvaluescurr = lt_dummy
return = t_return.}
you can also refer to the below tables:
CABN/CABNT--> Characteristic name description
CAWN/CAWNT--> Characteristic Name
Thanks,
Manish
Edited by: Manish_SDN on Nov 22, 2011 11:07 PM
2011 Nov 25 9:17 AM
HI,
'BAPI_OBJCL_GETDETAIL' will give only characteresti Description having values, but I want to get all characterestic Description i.e those having no values.
Please suggest me solution for this.
Thanks
2011 Nov 27 8:56 AM
Hi,
Please use the below code for your requirement:
I have created this example for Material, you can code similarly for customer.
First use 'BAPI_OBJCL_GETCLASSES' to get the class values.
Use the values in the table lt_alloc and the below logic will give you the desired results.
DATA:
lit_allocs LIKE api_kssk OCCURS 0,
lwa_allocs LIKE api_kssk,
lit_chartab LIKE api_char OCCURS 0,
lwa_chartab LIKE api_char,
lit_valtab LIKE api_vali OCCURS 0,
lit_val_api LIKE api_val_r OCCURS 0,
lwa_val_api LIKE api_val_r,
lt_cabn LIKE cabn
OCCURS 0 WITH HEADER LINE,
lt_ghcl LIKE ghcl
OCCURS 0 WITH HEADER LINE,
lt_klah LIKE klah
OCCURS 0 WITH HEADER LINE,
ls_return TYPE bapiret2,
lh_bgrkl(3) TYPE c,
l_tabix LIKE sy-tabix,
lf_error TYPE flag.
SELECT bgrkl
INTO lh_bgrkl
UP TO 1 ROWS
FROM klah
WHERE class = 'Z_MATERIAL_GENERAL'
AND klart = '001'.
ENDSELECT.
*....Read allocations of object .......................................
CALL FUNCTION 'CLAP_DDB_GET_CLASSIFICATION'
EXPORTING
object = '000004000522000400'
obtab = 'MARA'
standard_type_only = space
object_eq_class = space
spras = 'E'
only_varklart = space
change_service_number = space
classtype = '001'
read_only = 'X'
called_from_api = 'X'
TABLES
allocations = lit_allocs
EXCEPTIONS
no_allocation = 1
set_aennr = 2
change_nr_not_exist = 3
date_in_past = 4
error_class = 5
error_date_restriction = 6
error_status = 7
OTHERS = 8.
IF sy-subrc = 0.
READ TABLE lit_allocs WITH KEY class = 'Z_MATERIAL_GENERAL'
klart = '001'
INTO lwa_allocs.
ENDIF.
**....Get validations of allocations.....................................
IF lf_error IS INITIAL.
CALL FUNCTION 'CTMS_CONFIGURATION_INITIALIZER'.
* exclude other allocations
LOOP AT lit_allocs INTO lwa_allocs
WHERE class <> 'Z_MATERIAL_GENERAL'.
REFRESH lt_klah.
CLEAR lt_klah.
lt_klah-class = lwa_allocs-class.
lt_klah-klart = '001'.
APPEND lt_klah.
CALL FUNCTION 'CLSE_SELECT_KLAH'
TABLES
imp_exp_klah = lt_klah
EXCEPTIONS
no_entry_found = 1
OTHERS = 2.
IF sy-subrc = 0.
CLEAR lt_ghcl.
lt_ghcl-clas2 = lwa_allocs-class.
lt_ghcl-clin2 = lt_klah-clint.
lt_ghcl-mklas = 'X'.
APPEND lt_ghcl TO lt_ghcl.
ENDIF.
ENDLOOP.
IF sy-subrc = 0.
CALL FUNCTION 'CLHI_DDB_DEL_MULTIPLE_CLASSES'
TABLES
del_multiple_classes = lt_ghcl
EXCEPTIONS
OTHERS = 1.
ENDIF.
CALL FUNCTION 'CTMS_CLASS_OBJECT_DDB'
EXPORTING
class = 'Z_MATERIAL_GENERAL'
classtype = '001'
language = 'E'
objectid = 'MARA'
object = '4000522000400'
display = 'X'
key_date = '20110818'
set_values_from_db = 'X'
readonly = 'X'
i_no_objects = 'X'
EXCEPTIONS
not_found = 1
no_allocation_to_classes = 2
OTHERS = 3.
IF sy-subrc NE 0.
CLEAR sy-subrc.
lf_error = 'X'.
ENDIF.
ENDIF.
** Get characteristics.
IF lf_error IS INITIAL.
CALL FUNCTION 'CTMS_DDB_HAS_CHARACTERISTICS'
EXPORTING
inherited_excluding = space
allowed = 'X'
TABLES
exp_characteristics = lit_chartab
EXCEPTIONS
not_found = 1
no_characteristic_in_ddb = 2
OTHERS = 3.
IF sy-subrc > 0.
lf_error = 'X'.
ENDIF.
ENDIF.
The table lit_chartab gives you all the values of the characteristics existing for a particular class.
Edited by: Manish_SDN on Nov 27, 2011 9:59 AM
2011 Nov 27 9:11 AM
Hi,
Use BAPI_OBJCL_GETDETAIL in below format.
CALL FUNCTION 'BAPI_OBJCL_GETDETAIL'
EXPORTING
objectkey = lw_alloc-object
objecttable = 'KNA1'
classnum = lw_alloc-classnum
classtype = lw_alloc-classtype
UNVALUATED_CHARS = 'X' <----you need pass this to get all assigned characterstics.
TABLES
allocvaluesnum = lt_dummy1
allocvalueschar = lt_values
allocvaluescurr = lt_dummy
return = t_return.Try this.
BR,
Vijay
2011 Nov 30 1:39 PM
Thanks all for your help,
@vijay that is what I needed Thank you
Edited by: ashik03 on Nov 30, 2011 7:09 PM
2011 Nov 23 5:22 AM
I think so you have to link it through table KNMT-MATNR and material classfications .