‎2010 Aug 17 1:11 AM
Hi. Good Night.
I have the following screen of selection for a user. I need create a Select Dynamic for the table ANLA, Having in count the values selected by the user in each option of the screen.
SELECTION-SCREEN BEGIN OF BLOCK SEL WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS:
BUKRS FOR ANLA-BUKRS,
ANLKL FOR ANLA-ANLKL,
KOSTL FOR ANLZ-KOSTL,
GDLGRP FOR ANLA-GDLGRP,
INVNR FOR ANLA-INVNR.
SELECTION-SCREEN END OF BLOCK SEL.
How can do this?
Thank in advance for your help.
Regards.
‎2010 Aug 17 4:16 PM
Why can you not just use a standard SELECT statement joining ANLA and ANLZ with IN operators for each select option? I might not be understanding "Having in count the values" correctly though, please clarify.
Good night
Thomas
‎2010 Aug 17 3:40 AM
Hi,
Please have a refer of this:
DATA: l_lines(72) TYPE c.
* itab for fields selection
DATA: lt_condition LIKE TABLE OF l_lines(72),
lt_fields LIKE TABLE OF l_lines(72).
DEFINE m_add_fields.
l_lines = &1.
append l_lines to lt_fields.
END-OF-DEFINITION.
*
m_add_fields 'BUKRS'.
m_add_fields 'ANLK'.
m_add_fields 'GDLGRP'.
m_add_fields 'INVNR'.
*bukrs
l_lines = 'BUKRS in BUKRS'.
APPEND l_lines TO lt_condition.
* ANLK
l_lines = 'AND ANLK in ANLK'.
APPEND l_lines TO lt_condition.
*
l_lines = 'AND GDLGRP in GDLGRP'.
APPEND l_lines TO lt_condition.
*
l_lines = 'AND INVNR in INVNR'.
APPEND l_lines TO lt_condition.
* Select statement
SELECT (lt_fields)
INTO TABLE <table>
FROM <from>
WHERE (lt_condition).
‎2010 Aug 17 2:52 PM
The system send a dump.
The system display a message of error.
Regards
‎2010 Aug 17 3:24 PM
So, what's in the dump? What did it tell you it found wrong?!
‎2010 Aug 17 4:04 PM
You need to add SPACE before and after for all the strings...
' XXXX in XXXX ' -> SPACEs before and after..KR
Veeranji Reddy P.
‎2010 Aug 17 4:12 PM
This is the error:
Err.tmpo.ejec. SAPSQL_WHERE_ILLEGAL_VALUE
Excep. CX_SY_DYNAMIC_OSQL_SEMANTICS
Fecha y hora 17.08.2010 10:05:08
This is my source code.
SELECTION-SCREEN BEGIN OF BLOCK SEL WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: SOCIEDAD FOR ANLA-BUKRS, "
CLASEAF FOR ANLA-ANLKL, "
CENCOST FOR ANLZ-KOSTL,"
CARRESP FOR ANLA-GDLGRP,
NUMINV FOR ANLA-INVNR.
SELECTION-SCREEN END OF BLOCK SEL.
DATA: l_lines(72) TYPE c.
*
itab for fields selection
DATA: lt_condition LIKE TABLE OF l_lines(72),
lt_fields LIKE TABLE OF l_lines(72).
*
DEFINE m_add_fields.
l_lines = &1.
append l_lines to lt_fields.
END-OF-DEFINITION.
*
**
m_add_fields 'BUKRS'.
m_add_fields 'ANLK'.
m_add_fields 'GDLGRP'.
m_add_fields 'INVNR'.
*bukrs
l_lines = 'BUKRS in SOCIEDAD'.
APPEND l_lines TO lt_condition.
*
ANLK
l_lines = 'AND ANLK in CLASEAF'.
APPEND l_lines TO lt_condition.
*
*
Select statement
SELECT INVNR ANLKL SERNR ANLN1 TXT50 AKTIV ZUGDT
BSTDT LIFNR LIEFE ORD41 ORD42 ORD43 AIBN1
AIBN2 VMGLI FLURN
INTO TABLE it_tabla
FROM ANLA
WHERE (lt_condition).
Thank in advance for your help.
Regards
‎2010 Aug 17 4:16 PM
Why can you not just use a standard SELECT statement joining ANLA and ANLZ with IN operators for each select option? I might not be understanding "Having in count the values" correctly though, please clarify.
Good night
Thomas
‎2010 Aug 17 4:20 PM
>
> Why can you not just use a standard SELECT statement joining ANLA and ANLZ with IN operators for each select option?
+1
‎2010 Aug 17 4:23 PM
Hi want create a Select Dynamic only with the parameters that the user add in the Screen Selection in the WHERE ....
Regards
‎2010 Aug 17 4:37 PM
Empty select options will be ignored by the select query. This is very basic, please read here and close this thread afterwards:
http://help.sap.com/abapdocu%5F70/en/ABENLOGEXP_SELECT_OPTION.htm
Thomas
‎2010 Aug 17 4:54 PM