04-28-2006 6:19 AM
Hi,
I am facing a problem with data retrieval in a BADI with dynamic where clause.
I have a variable defined as:
data: lv_where_condn TYPE string.
I concatenate the data in the string based on the user's input and perform the following select:
SELECT *
FROM zd_apo_prodvar1
INTO TABLE lt_data
WHERE (lv_where_condn).
The sy-subrc returns a value 4 although there is data in the system for the users data input.
Earlier it used to give a short dump which I have now take care of with the catch statement.
SAP has suggested the following:
This problem happens if an attempt was made to bind or define a variable character string with a buffer length less than the two-byte minimum requirement. Please check the variable definition in your custom code and increase the buffer size or use a different type.
Any inputs will b appreciated in declaring the dats type for lv_where_condn.
cheers
Aveek
04-28-2006 6:27 AM
04-28-2006 6:33 AM
Hi ,
Declare your LV_WHERE_CONDITION as below
DATA:BEGIN OF LV_WHERE_CONDITION OCCURS 0.
INCLUDE STRUCTURE RSDWHERE.
DATA: END OF LV_WHERE_CONDITION.
RSDWHERE is a line for dynamic where conditions
APPEND your where condition to this table and use it it should work.
Regards,
Raghavendra
04-28-2006 6:42 AM
Hi,
There is no structure by the name RSDWHERE in APO or R/3. Is there any alternative structure I can use.
cheers
Aveek
04-28-2006 6:43 AM
how is lt_data defined? if it's not exactly as zd_apo_prodvar1 you could have problems.
04-28-2006 6:54 AM
Hi,
lt_data is defined as:
TYPES:
lt_data TYPE STANDARD TABLE OF zd_apo_prodvar1.
cheers
Aveek
04-28-2006 7:06 AM
hi,
check this sample ..
REPORT ZDYNAMIC_SELECT .
TABLES: VBAK.
DATA: CONDITION TYPE STRING.
DATA: BEGIN OF ITAB OCCURS 0,
VBELN LIKE VBAK-VBELN,
POSNR LIKE VBAP-POSNR,
END OF ITAB.
SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN.
CONCATENATE 'VBELN' 'IN' 'S_VBELN.'
INTO CONDITION SEPARATED BY SPACE.
SELECT VBELN POSNR FROM VBAP INTO TABLE ITAB
WHERE (CONDITION).
LOOP AT ITAB.
WRITE 'hello'.
ENDLOOP.
Regards
vijay
04-28-2006 7:13 AM
surely lt_data must be defined after 'data' not 'types'... it would get a syntax error otherwise.
04-28-2006 7:03 AM
Hi !
It must be defined as follows:
DATA: where_clause TYPE STRING
As you did so it would be helpful to post what the string contains in runtime !
Regards
Rainer
Some points would be fine if that helped you....
04-28-2006 7:08 AM
Hi,
I have defined the lv_where_condn as type string.
DATA : lv_where_condn TYPE string.
But I still get the exception raised when I concatenate and use it in my select statement.
Any inputs will be appreciated.
The exception that is raised is:
catch CX_SY_OPEN_SQL_DB.
cheers
Aveek
04-28-2006 7:25 AM
Hi aveek,
i too faced the same problem , but this exceptions is in Older versions , it will give that exception in 4.6C or below, if you run it in 4.7 above it will work. first check your version. and if it is 4.6c then you have go with other solution that you can find in this thread by Rich using Subroutine pool generation.
Regards
vijay
04-28-2006 7:13 AM
Hi !
Is the where condition very long ?
There will be an error if the condition containes many values and the generated SQL-Statemend becomes to lage...
04-28-2006 7:22 AM
as Rainer said before, what are the contents of the string when it dumps?
04-28-2006 7:27 AM
Hi Aveek,
Sorry the structure is RSDSWHERE.
You can have a look at standard program RFKORDJ4.
search for BSI_WHERE is a dynamic where condition.
Regards,
Raghavendra
04-28-2006 7:35 AM
previous versions of r/3 expected the dynamic sql to be declared like this:
DATA:
BEGIN OF it_sql OCCURS 0,
text(72),
END OF it_sql,
maybe you have to use that approach.
04-28-2006 8:03 AM
Hi,
The code returns sy-subrc = 4 for the wher condition:
( BRFAM = 'L&M' ) AND ( ITPCK = '25' ) AND ( MKLEN = 'KS' ) AND ( MKTGR = 'SE04' ) AND PARPR IN LR_MATNR
If I take out the BRFAM field from the string the program works fine.
Looking forward to your inputs.
cheers
Aveek
04-28-2006 8:30 AM
Hi !
Can you post the SE11 definition of the table on wigh the data ist beeing selected ?
AND... maybe you can a a SE16 extract of the table...
04-28-2006 10:08 AM
The data is in the table and it is a view.
The contents are in the view and just one field BRFAM seems to create an issue.
The table is quite long in order to dump the definition in SDN.
cheers
Aveek
04-28-2006 8:33 AM
hi,
When.
SY-SUBRC = 4:
The result table is empty.
check the content in your table where there is any record for that condition.
Regards,
Tanveer.
Mark helpful answers
Message was edited by: Tanveer Shaikh
04-28-2006 12:59 PM
What is the BRFAM field content in the table? is it L&M or something else? can u try with LIKE (BRFAM like %L&%) and check??
04-28-2006 2:48 PM
Hi,
The value is L&M and i tried your option but it does not work. Loking forward to your inputs.
cheers
Aveek
04-29-2006 4:38 AM
it seems like it's a bug with sql....
maybe it's getting confused because of the embedded '&'- you could try defining a constant or variable with that value(L&M)and pass that to the sql.
..and have you tried putting the L&M at the end of the sql??
05-02-2006 3:50 PM
Hi,
Using the where clause for example:
( BRFAM LIKE '%L&%' ) AND PARPR IN LR_MATNR
does not retrieve any value in ABAP Objects but returns a value in the custom program created in se38.
Any inputs will be appreciated.
cheers
Aveek
05-04-2006 8:28 AM
Hi,
I have been able to take care of this problem now.
However I am facing another issue:
The BADI Implementation has a method loc_prod_value_list.
Here there is a changing parameter ct_value_list defined as type standard table.
In the BADI there is a statement:
create data lv_line like line of ct_value_list.
lv_line is defined as type ref to data.
I need to figure out where in the class implementation the changing parameter is populated.
cheers
Aveek
05-04-2006 10:42 AM
Hi Aveek,
could you put something in the thread to explain how you solved it, it may help someone else with a similar problem, and issue any points if appropriate.
Put your latest question in a new thread. Sorry I can't help you with that one.
05-04-2006 3:29 PM