2013 Jan 18 1:18 PM
Hi At all,
Is the first time that I used the statement Select using dynamic where clause.
The piece of code I created is this:
DATA: la_where_tab(100) OCCURS 0 WITH HEADER LINE,
la_where_clause(70) TYPE c.
IF i_zvka1 IS NOT INITIAL.
APPEND 'knvp~pernr IN wa_vknum_def ' TO la_where_tab.
APPEND 'AND knvp~parvw EQ "VK" ' TO la_where_tab.
APPEND 'AND knvv~vkorg EQ w_vkorg ' TO la_where_tab.
APPEND 'AND knvv~loevm EQ " " ' TO la_where_tab.
APPEND 'AND knvv~zzakl20 NE "P" ' TO la_where_tab.
IF p_call = 'X'.
APPEND 'AND knvv~/wrp/ssf_vcust EQ "X" ' TO la_where_tab.
ELSEIF p_visit = 'X'.
APPEND 'AND knvv~/wrp/ssf_vcust EQ "X" ' TO la_where_tab.
ENDIF.
APPEND 'AND kna1~loevm EQ " " ' TO la_where_tab.
SELECT kna1~kunnr
knvp~pernr
knvv~vkorg
knvv~/wrp/ssf_vday
knvv~/wrp/ssf_vfreq
knvv~/wrp/ssf_nvisit
knvv~/wrp/ssf_lvisit
knvv~/wrp/ssf_lcall
knvv~/wrp/ssf_ccust
knvv~/wrp/ssf_vcust
FROM kna1 JOIN knvv ON kna1~mandt = knvv~mandt
AND kna1~kunnr = knvv~kunnr
JOIN knvp ON knvv~mandt = knvp~mandt
AND knvv~kunnr = knvp~kunnr
AND knvv~vkorg = knvp~vkorg
AND knvv~vtweg = knvp~vtweg
AND knvv~spart = knvp~spart
INTO CORRESPONDING FIELDS OF TABLE i_customer
WHERE (la_where_tab).
Someone of you can you help me to understand how write the correct clause to insert in the Where statement??
Thank you
2013 Jan 18 3:06 PM
Hi Tony,
The problem is with the quotes you're using when building the conditions table la_where_tab.
Instead of using double-quotes to specify the condition value:
APPEND 'AND knvp~parvw EQ "VK"' TO la_where_tab.
APPEND 'AND knvv~loevm EQ " "' TO la_where_tab.
Use single-quotes:
APPEND 'AND knvp~parvw EQ ''VK''' TO la_where_tab.
APPEND 'AND knvv~loevm EQ '' ''' TO la_where_tab.
Cheers,
Amy
2013 Jan 18 3:06 PM
Hi Tony,
The problem is with the quotes you're using when building the conditions table la_where_tab.
Instead of using double-quotes to specify the condition value:
APPEND 'AND knvp~parvw EQ "VK"' TO la_where_tab.
APPEND 'AND knvv~loevm EQ " "' TO la_where_tab.
Use single-quotes:
APPEND 'AND knvp~parvw EQ ''VK''' TO la_where_tab.
APPEND 'AND knvv~loevm EQ '' ''' TO la_where_tab.
Cheers,
Amy
2013 Jan 18 4:29 PM
2013 Jan 18 4:32 PM
2013 Jan 19 10:49 AM
Another question,
If in on my screen I have the following input:
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-002 .
PARAMETERS: p_bukrs TYPE bukrs OBLIGATORY DEFAULT 3143,
p_c_num TYPE kna1-kunnr.
SELECT-OPTIONS s_pernr FOR zvka1-vknum. "OBLIGATORY.
PARAMETERS: p_call RADIOBUTTON GROUP gad1.
PARAMETERS: p_visit RADIOBUTTON GROUP gad1.
PARAMETERS: p_m_data AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
Where p_c_num is the number of customer which the user can select.
This field isn´t obligatory and then the user can insert nothing in this field. In this case I would that
my query take all customer.
The query is the same that i show you above.
I try to do this istruction but doesn´t work because doesn´t take all customer
.... query above...
AND kna1~kunnr EQ p_c_num
Can you help me??
Thank you...
2013 Jan 22 1:29 PM
Hi Tony,
Instead of making p_c_num a parameter, make it a select-option, then regardless of whether the user enters a value, you can use the statement
AND kna1~kunnr IN p_c_num
Take a look at the keyword documentation for options you can apply to a select-option such as no-extension and no intervals.
Cheers,
Amy