‎2010 Nov 11 9:27 PM
When Classifying a material (or any object for that matter) using BAPI_OBJCL_CREATE, If there is a problem with a value being assigned to a characteristic such as an invalid value being passed, the BAPI passes back the problem in tbapiret2 and does not save the allocation. The problem I have with this is that it only passes back the 1st problem it encounters. So after correcting the 1st problem, and callling the bapi again, the next error is then visible. This process has to be repeated until all errors are corrected. I thought I could write a "pre-edit" FM that would run thru all the characteristics and return to the user ALL validation errors at one time, saving large amounts of frustration and time.
What I have found is the function CTMS_CHAR_CHECK_VALUE which seem to do exactly what I want, but whenever it encounters an error it executes the message command causing the message to be sent to the screen and terminating the processing, so that I cannot check the next characteristic.
Does anyone know of a way I can accomplish checking ALL my characteristics in one pass?
Thanks,
Larry
‎2010 Nov 11 11:05 PM
I may be hot on the trail of the solution. There is a switch in the top include of the function group CTMS called X_RAISE that I believe needs to be set to "1". Now all I need to do is figure out how to set it to "1"
‎2010 Nov 11 9:35 PM
When you tested CTMS_CHAR_CHECK_VALUE, did you run it from a program that caught all of the exceptions?
Rob
‎2010 Nov 11 9:48 PM
Rob,
Thanks for trying to help me!
here is the code I used to call the FM
CALL FUNCTION 'CTMS_CHAR_CHECK_VALUE'
EXPORTING
characteristic = p_chara
new_value = p_value
old_value = space
EXCEPTIONS
currency_check = 1
date_check = 2
format_check = 3
illegal_internal_baseunit = 4
interval_check = 5
pattern_check = 6
time_check = 7
unit_check = 8
value_not_found = 9
no_valid_dimension = 10
interval_not_allowed = 11
characteristic_not_found = 12
value_not_possible = 13
characteristic_enqueue = 14
objectcharacteristic = 15
only_one_value_allowed = 16
characteristic_not_selectable = 17
input_to_long = 18
value_contradiction = 19
OTHERS = 20.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Inside the FM all the errors are thrown like this:
MESSAGE E001 WITH iv_string0
RAISING FORMAT_CHECK.
My test program displays the message at the bottom of the screen and terminates.
Edited by: Larry Browning on Nov 11, 2010 3:50 PM
Edited by: Larry Browning on Nov 11, 2010 3:51 PM
‎2010 Nov 11 10:06 PM
Because of the RAISING in the FM, I would exoect that it would not send the message to the terminal, but instead pass a return code to the calling program. So I tested your code and I did get a retrun code and no message was displayed.
Rob
‎2010 Nov 11 10:15 PM
Really! I expected the same thing from my program but it did not do as I expected.
Here is my entire test program:
REPORT yljb005
NO STANDARD PAGE HEADING
LINE-SIZE 80
LINE-COUNT 65(0).
* message-id ...
************************************************************************
* P A R A M E T E R S / S E L E C T - O P T I O N S
************************************************************************
*SELECT-OPTIONS:
PARAMETERS: p_class TYPE klasse_d OBLIGATORY,
p_type TYPE klassenart OBLIGATORY,
p_chara TYPE atinn OBLIGATORY,
p_value TYPE atwrt OBLIGATORY.
************************************************************************
START-OF-SELECTION.
CALL FUNCTION 'CTMS_CLASS_DDB'
EXPORTING
class = p_class
classtype = p_type
MODE = ' '
* LANGUAGE = SY-LANGU
* KEY_DATE = SY-DATUM
* OBJECTID =
* OBJECT =
* I_ADD_ON_CHAR = ' '
* I_TABS_ACTIVE = ' '
* INIT_CONF = ' '
* READONLY = ' '
* I_CALLED_FROM_DDB = ' '
* EXCEPTIONS
* NOT_FOUND = 1
* OTHERS = 2
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'CTMS_CHAR_CHECK_VALUE'
EXPORTING
characteristic = p_chara
new_value = p_value
old_value = space
EXCEPTIONS
currency_check = 1
date_check = 2
format_check = 3
illegal_internal_baseunit = 4
interval_check = 5
pattern_check = 6
time_check = 7
unit_check = 8
value_not_found = 9
no_valid_dimension = 10
interval_not_allowed = 11
characteristic_not_found = 12
value_not_possible = 13
characteristic_enqueue = 14
objectcharacteristic = 15
only_one_value_allowed = 16
characteristic_not_selectable = 17
input_to_long = 18
value_contradiction = 19
OTHERS = 20.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
************************************************************************
* E N D O F S E L E C T I O N
************************************************************************
END-OF-SELECTION.
I had to call CTMS_CLASS_DDB to get CTMS_CHAR_CHECK_VALUE to not throw the Characteristic not found error.
Edited by: Larry Browning on Nov 11, 2010 4:18 PM
‎2010 Nov 11 10:33 PM
‎2010 Nov 11 10:53 PM
Did you use a valid class when you called CTMS_CLASS_DDB and then used a characteristic in that class to validate with?
‎2010 Nov 11 11:05 PM
I may be hot on the trail of the solution. There is a switch in the top include of the function group CTMS called X_RAISE that I believe needs to be set to "1". Now all I need to do is figure out how to set it to "1"
‎2010 Nov 11 11:22 PM
Hi Larry,
have you tried to use exception ERROR_MESSAGE?
If you specify of ERROR_MESSAGE in the EXCEPTION list you can influence the message handling of function modules. Normally, you should only call messages in function modules using the MESSAGE....RAISING statement. With ERROR_MESSAGE you can force the system to treat messages that are called without the RAISING option in a function module as follows:
· Messages of classes S, I, and W are ignored (but written to the log in a background job).
· Messages of classes E and A stop the function module as if the exception ERROR_MESSAGE had occurred (sy-subrc is set to rE).
‎2010 Nov 11 11:49 PM
Alejiandro,
This solved my problem! Thanks,
I like you solution much better than mine (which actually works too, but I was using trickery).
My solution goes this way:
After calling the FM CTMS_CLASS_DDB (which brings the Function group into memory)
I added this code:
w_sharename = '(SAPLCTMS)X_RAISE'.
ASSIGN (w_sharename) TO <fs1>.
IF sy-subrc = '0'.
<fs1> = 1.
ENDIF.
This gave me access to the variables inside the function group CTMS. I then was able to set the X_RAISE flag to 1, so that when I called the value check function it raised the exception instead of displaying the message.
But I am going to use your solution.
Thanks to Rob as well.
Maybe we all learned something today.
Edited by: Larry Browning on Nov 11, 2010 5:53 PM