10-23-2007 5:26 AM
Hi everyone,
I tried to call the BAPI_CLASS_SELECT_OBJECTS, but i can't retrieve any result. Anything wrong??
*&---------------------------------------------------------------------*
*& Report ZFETCH_BATCH
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zfetch_batch.
DATA: c_classnum TYPE bapi_class_key-classnum VALUE '023_094', "Class Number
c_classtype TYPE bapi_class_key-classtype VALUE '022' , "Class Type
it_selectioncriterions LIKE bapi_selection_criterions OCCURS 1, " criteria
it_selectedobjects LIKE bapi_selected_objects OCCURS 0. " result
DATA: l_selectioncriterions LIKE LINE OF it_selectioncriterions,
l_selectedobjects LIKE LINE OF it_selectedobjects.
l_selectioncriterions-name_char = 'PURITY002'.
l_selectioncriterions-char_value = '*'.
APPEND l_selectioncriterions TO it_selectioncriterions.
CALL FUNCTION 'BAPI_CLASS_SELECT_OBJECTS'
EXPORTING
classtype = c_classtype
classnum = c_classnum
* LANGUISO =
* LANGUINT =
* KEYDATE = SY-DATUM
* MAXHITS = 100
* I_STATUS_LOCKED =
* I_STATUS_INCOMPLETE =
* IMPORTING
* RETURN =
TABLES
selectioncriterions = it_selectioncriterions
selectedobjects = it_selectedobjects
* OBJECTCLASSIFICATION =
.
LOOP AT it_selectedobjects INTO l_selectedobjects.
WRITE: / l_selectedobjects-object.
WRITE: / l_selectedobjects-objecttext.
ENDLOOP.
Regards,
Kit
10-23-2007 5:36 AM
Hi,
In Import parameters you are not populating RETURN. Can you add that and see after execution what messages are populating in RETURN table? That will give you an idea about the error.
Also check BAPI documentation, it also contains sample code -
Example
DATA: so LIKE bapi_selected_objects OCCURS 0 WITH HEADER LINE,
sc LIKE bapi_selection_criterions OCCURS 0 WITH HEADER LINE,
oc LIKE bapi_object_values OCCURS 0 WITH HEADER LINE,
return like bapireturn1.
*- Set up selection criteria
*- Characteristic name
sc-name_char = 'NUM_CHAR'.
*- Numeric value from
sc-num_val_fm = 0.
*- Numeric value to
sc-num_val_to = 1000.
*- Set indicator that describes interval
sc-val_relatn = '2'.
APPEND sc.
*- Characteristics whose assigned values you want to read
oc-name_char = 'CHARX'.
APPEND oc.
CALL FUNCTION 'BAPI_CLASS_SELECT_OBJECTS'
EXPORTING
classtype = '001'
classnum = 'CF10'
langu_iso = 'EN'
key_date = sy-date
max_hits = 10
IMPORTING
return = return
TABLES
selection_criterions = sc
selected_objects = so
object_classifications = oc
EXCEPTIONS
others = 0.
ashish
10-23-2007 5:36 AM
Hi,
In Import parameters you are not populating RETURN. Can you add that and see after execution what messages are populating in RETURN table? That will give you an idea about the error.
Also check BAPI documentation, it also contains sample code -
Example
DATA: so LIKE bapi_selected_objects OCCURS 0 WITH HEADER LINE,
sc LIKE bapi_selection_criterions OCCURS 0 WITH HEADER LINE,
oc LIKE bapi_object_values OCCURS 0 WITH HEADER LINE,
return like bapireturn1.
*- Set up selection criteria
*- Characteristic name
sc-name_char = 'NUM_CHAR'.
*- Numeric value from
sc-num_val_fm = 0.
*- Numeric value to
sc-num_val_to = 1000.
*- Set indicator that describes interval
sc-val_relatn = '2'.
APPEND sc.
*- Characteristics whose assigned values you want to read
oc-name_char = 'CHARX'.
APPEND oc.
CALL FUNCTION 'BAPI_CLASS_SELECT_OBJECTS'
EXPORTING
classtype = '001'
classnum = 'CF10'
langu_iso = 'EN'
key_date = sy-date
max_hits = 10
IMPORTING
return = return
TABLES
selection_criterions = sc
selected_objects = so
object_classifications = oc
EXCEPTIONS
others = 0.
ashish
10-23-2007 5:42 AM
Dear Ashish,
Thx for your code. What parameter should i pass for the wild card search??
Regards,
Kit
10-23-2007 5:49 AM
I think for character PURITY002, you want to fetch all values.
Enter Value from and Value to to the selection structure, similar to the example.
*- Numeric value from
sc-num_val_fm = 0.
*- Numeric value to
sc-num_val_to = 1000.
And should solve your problem.
ashish
10-23-2007 8:10 AM
Dear Ashish,
I tried the following condition:
l_selectioncriterions-name_char = 'PURITY002'.
l_selectioncriterions-char_value = 'ABC'.
APPEND l_selectioncriterions TO it_selectioncriterions.
but i encounter a short dump.
Runtime Errors:SAPSQL_IN_ITAB_ILLEGAL_OPTION
Short Text:Invalid value in OPTION field of value table for IN itab operator
Any idea??
Message was edited by:
Kit