Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Select Dynamic for Select Option

Former Member
0 Likes
1,286

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.

1 ACCEPTED SOLUTION
Read only

ThomasZloch
Active Contributor
0 Likes
1,198

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

10 REPLIES 10
Read only

Former Member
0 Likes
1,198

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).

Read only

0 Likes
1,198

The system send a dump.

The system display a message of error.

Regards

Read only

0 Likes
1,198

So, what's in the dump? What did it tell you it found wrong?!

Read only

0 Likes
1,198

You need to add SPACE before and after for all the strings...

'  XXXX in XXXX  ' -> SPACEs before and after..

KR

Veeranji Reddy P.

Read only

0 Likes
1,198

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

Read only

ThomasZloch
Active Contributor
0 Likes
1,199

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

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,198

>

> Why can you not just use a standard SELECT statement joining ANLA and ANLZ with IN operators for each select option?

+1

Read only

0 Likes
1,198

Hi want create a Select Dynamic only with the parameters that the user add in the Screen Selection in the WHERE ....

Regards

Read only

0 Likes
1,198

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

Read only

Former Member
0 Likes
1,198

Thank You.