‎2008 Feb 26 5:27 PM
Hi Guys!
I´m making a badi in BW, but i have a problem with a select statement that gets me a dump, can you help me to fix it.? the code is:
TYPES: BEGIN OF tp_mat_sales,
salesorg TYPE /bi0/pmat_sales-salesorg,
distr_chan TYPE /bi0/pmat_sales-distr_chan,
mat_sales TYPE /bi0/pmat_sales-mat_sales,
fcushpdt TYPE /bi0/pmat_sales-/bic/fcushpdt,
commmgmt TYPE /bi0/pmat_sales-/bic/commmgmt,
END OF tp_mat_sales.
DATA: t_mat_sales TYPE HASHED TABLE OF tp_mat_sales WITH UNIQUE KEY mat_sales salesorg distr_chan,
i_mat_sales TYPE tp_mat_sales.
SELECT salesorg distr_chan mat_sales /bic/commmgmt
INTO TABLE t_mat_sales
FROM /bi0/pmat_sales
FOR ALL ENTRIES IN t_data_in
WHERE mat_sales = t_data_in-mat_sales
AND salesorg = t_data_in-salesorg
AND distr_chan = t_data_in-distr_chan
AND objvers = 'A'.
Regards!!
‎2008 Feb 26 6:14 PM
‎2008 Feb 26 5:34 PM
What's the message of the Dump???
I don't see any problem in the code...
Greetings,
Blag.
‎2008 Feb 26 5:58 PM
Hi!, the dump says:
Runtime Errors DBIF_RSQL_INVALID_RSQL
Exceptn CX_SY_OPEN_SQL_DB
ShrtText
Error in RSQL module of database interface.
What happened?
Error in ABAP application program.
The current ABAP program "ZCL_IM_AMGENMATS==============CP" had to be
terminated because one of the
statements could not be executed.
This is probably due to an error in the ABAP program.
Following a SELECT statement, the data read could not be placed in AN
the output area.
A conversion may have been intended that is not supported by the
system, or the output area may be too small.
Error analysis
An exception occurred. This exception is dealt with in more detail below
. The exception, which is assigned to the class 'CX_SY_OPEN_SQL_DB', was
neither
caught nor passed along using a RAISING clause, in the procedure
"IF_EX_OPENHUB_TRANSFORM~TRANSFORM" "(METHOD)"
.
Since the caller of the procedure could not have expected this exception
to occur, the running program was terminated.
The reason for the exception is:
The data read during a SELECT access could not be inserted into the
target field.
Either conversion is not supported for the target field's type or the
target field is too short to accept the value or the data are not in a
form that the target field can accept
‎2008 Feb 26 6:04 PM
Check these two things:
1) Double check if the field types specified for internal table are identical to the data elements in the database table you are selecting from.
2) Make sure that the SELECT statement is really returning unique values. Since you have defined the internal table as hash table with unique key, that could be causing the problem.
‎2008 Feb 26 6:07 PM
I think the itab definition should have LIKE instead of TYPE.
TYPES: BEGIN OF tp_mat_sales,
salesorg like /bi0/pmat_sales-salesorg,
distr_chan like /bi0/pmat_sales-distr_chan,
mat_sales like /bi0/pmat_sales-mat_sales,
fcushpdt like /bi0/pmat_sales-/bic/fcushpdt,
commmgmt like /bi0/pmat_sales-/bic/commmgmt,
END OF tp_mat_sales.
‎2008 Feb 26 7:06 PM
Alexander is (partially) right. You have 5 fields in ITAB declaration, but only selecting 4 fields in SQL thereby sending the wrong data into wrong field.
‎2008 Feb 26 7:10 PM
...and that's why you use INTO CORRESPONDING...
You don't have to worry (as much) when the fields being selected change.
Rob
‎2008 Feb 26 6:14 PM
‎2008 Feb 26 6:35 PM
Pls avoid the statement INTO CORRESPONDING becasue te performance reason. Check the selection feild, the field /bic/commmgmt is missing in decalration.
‎2008 Feb 26 6:55 PM
There is a performance hit when using INTO CORRESPONDING FIELDS OF TABLE..., but it's small. See
[ Performance - what will kill you and what will leave you with only a flesh wound|/people/rob.burbank/blog/2006/11/16/performance--what-will-kill-you-and-what-will-leave-you-with-only-a-flesh-wound]
Rob