08-22-2022 2:28 PM
Hello,
A table previous built many years ago has a key of 66 characters. Yes, one field, ugh.
The examples I have seen for building dynamic where statements show the line being 72 characters. With the key field name and the condition, this would be longer that 72 characters.
Is there a way to solver this?
Regards, Dean.
08-22-2022 2:48 PM
Could you please share the example , which limits to 72 characters ?
08-22-2022 3:20 PM
This the example that I was reviewing....
https://answers.sap.com/questions/8136030/dynamic-where-condition-in-select-statement.html
08-22-2022 3:22 PM
SAP Help on sql_cond - (cond_syntax) doesn't say anything about 72 chars limit. The examples put dynamic WHERE into a string type variable, which is not limited to 72 chars.
08-22-2022 3:38 PM
Hello Dominik,
So then I can use a string and that would be suffice?
Regards, Dean.
08-22-2022 5:42 PM
Look at the comment (not the answer) in the link you sent.
the code in the comment is:
DATA : l_where TYPE string,
i_marc TYPE STANDARD TABLE OF marc.
CONSTANTS: l_quote TYPE char1 VALUE ''''.
PARAMETERS : p_plant TYPE marc-werks.
CONCATENATE 'WERKS' space '=' space l_quote p_plant l_quote space
'AND' space 'PERKZ' space '=' space l_quote 'M' l_quote
INTO l_where RESPECTING BLANKS.
SELECT * FROM marc INTO TABLE i_marc WHERE (l_where).
As 3a9e4ce873a94034b33dc62b0ce600ee wrote "The example put dynamic WHERE into a string type variable, which is not limited to 72 chars."
08-22-2022 5:57 PM
Hello Dominik,
I was looking at the other one. Sorry that I didn't see that particular section. Then I am good o go forward.
Thank you.
Regards, Dean.
08-23-2022 9:14 AM
which can be written:
DATA(l_where) = |WERKS = '{ p_plant }' AND PERKZ = 'M'|.
be aware of CL_ABAP_DYN_PRG class to avoid SQL Injection Attacks (see ABAP documentation).
08-23-2022 9:11 AM
dean.hinson2
to answer your question "so then I can use a string", as you can see in "SAP Help on sql_cond - (cond_syntax)"character-like data object" means STRING or TYPE C or whatever, as can be found here.