2016 Jun 02 3:19 PM
Hi All,
I am writing an AMDP method with multiple selects into it. The execution gives a dump with SQL Database error code 339.
Below is the code for the calling Program :
TABLES: mseg.
SELECT-OPTIONS: s_matnr FOR mseg-matnr,
s_pspnr FOR mseg-mat_pspnr,
s_werks FOR mseg-werks.
START-OF-SELECTION.
DATA : lo_amdp TYPE REF TO zamdp.
DATA : gt_416 TYPE zamdp=>gtt_quan,
gt_415 TYPE zamdp=>gtt_quan,
gt_qbew TYPE zamdp=>gtt_quan,
gt_28x TYPE zamdp=>gtt_quan,
gt_usnam TYPE zamdp=>gtt_usnam.
CREATE OBJECT lo_amdp.
DATA : lt_seltab TYPE if_shdb_def=>tt_named_dref,
lv_where TYPE string,
lst_seltab TYPE if_shdb_def=>ts_named_dref.
lst_seltab-name = 'MATNR'.
GET REFERENCE OF s_matnr[] INTO lst_seltab-dref.
APPEND lst_seltab TO lt_seltab.
CLEAR lst_seltab.
lst_seltab-name = 'MAT_PSPNR'.
GET REFERENCE OF s_pspnr[] INTO lst_seltab-dref.
APPEND lst_seltab TO lt_seltab.
cl_shdb_seltab=>combine_seltabs( EXPORTING it_named_seltabs = lt_seltab
RECEIVING rv_where = lv_where ).
CALL METHOD Zamdp=>meth_mseg_quan(
EXPORTING
im_where = lv_where
IMPORTING
ex_416 = gt_416
gt_415 = gt_415
gt_qbew = gt_qbew
gt_28x = gt_28x ).
cl_demo_output=>display_data( EXPORTING value = gt_416 ).
The AMDP Code is as attached.
I am not getting what exactly needs to be done to resolve the issue.
Thanks & Regards
Srinivas Rao
2016 Jun 03 2:37 PM
Hello,
1. Always define Raising clause in AMDP defination.
Ex.
CLASS-METHODS : update_data
IMPORTING
VALUE(ip_tmstart) TYPE char16
RAISING cx_amdp_error.
2.Catch exceptions during calling AMDP method so you can understand what is exact error occurring.
Ex.
TRY.
CALL METHOD zcl_test=>update_data
EXPORTING
ip_tmstart = lv_tmstart.
CATCH cx_amdp_error INTO DATA(lx_amdp_error).
--here you can get long text
ENDTRY.
Now you will get exact error message in exception lx_amdp_error.
Still you are unable to understand the error , you can go with AMDP debugging.....
-Amol S
2016 Jun 03 2:37 PM
Hello,
1. Always define Raising clause in AMDP defination.
Ex.
CLASS-METHODS : update_data
IMPORTING
VALUE(ip_tmstart) TYPE char16
RAISING cx_amdp_error.
2.Catch exceptions during calling AMDP method so you can understand what is exact error occurring.
Ex.
TRY.
CALL METHOD zcl_test=>update_data
EXPORTING
ip_tmstart = lv_tmstart.
CATCH cx_amdp_error INTO DATA(lx_amdp_error).
--here you can get long text
ENDTRY.
Now you will get exact error message in exception lx_amdp_error.
Still you are unable to understand the error , you can go with AMDP debugging.....
-Amol S
2016 Jun 04 11:48 AM
Hi Amol
Thanks for the inputs. The exception gives the same information as that of the dump details.
Anyway, I was able to resolve myself. If you check in my AMDP, there is a table called GT_USNAM where I am using SUBSTR function in the ON condition for joining 2 tables. There I had compared the SUBSTR with INT value instead it should be character and hence the right side operand should be in quotes.
I am marking your reply as helpful . Thanks ! Cheers !
2016 Jun 06 7:30 AM
Hi Srinivas,
Have you tried below exception, you can get exact SQL error text message. It might be helpful....
CATCH cx_amdp_dbproc_create_failed INTO DATA(lt_amdp_error).
lw_text = lt_amdp_error->sql_message.
ENDTRY.
-Amol S