Application Development 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: 

dynamic string

Former Member
0 Kudos

Hallow I wont to do a string dynamic that when I wont to ask for relation 027 and 034 the string bring me both of relation my problem is that didn’t work what wrong.

DATA ceck_str TYPE string.

IF switch_history = 'X' .

ceck_str = 'relat EQ ''027'''.

ELSE.

<b>ceck_str = 'relat EQ ''027'' OR relat EQ ''034'''.</b> ENDIF.

3----select the employee who register to course--


SELECT objid sobid priox istat endda begda

FROM hrp1001

INTO CORRESPONDING FIELDS OF TABLE d_itab

  • FOR ALL ENTRIES IN z_course_table

WHERE otype = 'D'

AND objid = z_course_table-objid

AND sclas = 'P'

<b>AND (ceck_str).</b>

regards

1 ACCEPTED SOLUTION

Former Member
0 Kudos

I am not sure why are you using a string but the best option is to use ranges.

Ranges : r_relat like hrp1001-relat.

If switch_history = 'X'.

r_relat-low = '027'.

r_relat-sign = 'EQ'.

r_relat-option = 'I'.

append r_relat.

else.

r_relat-low = '027'.

r_relat-sign = 'EQ'.

r_relat-option = 'I'.

append r_relat.

r_relat-low = '034'.

r_relat-sign = 'EQ'.

r_relat-option = 'I'.

append r_relat.

endif.

SELECT objid sobid priox istat endda begda

FROM hrp1001

INTO CORRESPONDING FIELDS OF TABLE d_itab

  • FOR ALL ENTRIES IN z_course_table

WHERE otype = 'D'

AND objid = z_course_table-objid

AND sclas = 'P'

AND relat in r_relat.

9 REPLIES 9

Former Member
0 Kudos

i think u have to right code as -

DATA ceck_str TYPE string.

IF switch_history = 'X' .

SELECT objid sobid priox istat endda begda

FROM hrp1001

INTO CORRESPONDING FIELDS OF TABLE d_itab

  • FOR ALL ENTRIES IN z_course_table

WHERE otype = 'D'

AND objid = z_course_table-objid

AND sclas = 'P'

AND subty cp '*027'.

ELSE.

SELECT objid sobid priox istat endda begda

FROM hrp1001

INTO CORRESPONDING FIELDS OF TABLE d_itab

  • FOR ALL ENTRIES IN z_course_table

WHERE otype = 'D'

AND objid = z_course_table-objid

AND sclas = 'P'

AND ( subty cp '27' or subty cp '34' ).

endif.

0 Kudos

hi amit what is AND subty cp '027'.or AND subty cp '027'. i dont understand

0 Kudos

Hi!

I found it in the ABAP HELP of the keyword WHERE:


PARAMETERS: airline(2) TYPE C, 
            date       TYPE D. 
DATA: where_clause TYPE STRING, 
      connid       TYPE sflight-connid. 

CONCATENATE     'carrid = ''' airline ''''                     "<-only apostrofes
            ' AND fldate = ''' date '''' INTO where_clause. 

SELECT connid FROM sflight INTO connid 
  WHERE (where_clause). 
  WRITE: / date, airline, connid. 
ENDSELECT. 

You can mix static (variants 1 and 2) and dynamic conditions (variant 3) any way you like in WHERE clauses.

Regards

Tamá

Former Member
0 Kudos

I am not sure why are you using a string but the best option is to use ranges.

Ranges : r_relat like hrp1001-relat.

If switch_history = 'X'.

r_relat-low = '027'.

r_relat-sign = 'EQ'.

r_relat-option = 'I'.

append r_relat.

else.

r_relat-low = '027'.

r_relat-sign = 'EQ'.

r_relat-option = 'I'.

append r_relat.

r_relat-low = '034'.

r_relat-sign = 'EQ'.

r_relat-option = 'I'.

append r_relat.

endif.

SELECT objid sobid priox istat endda begda

FROM hrp1001

INTO CORRESPONDING FIELDS OF TABLE d_itab

  • FOR ALL ENTRIES IN z_course_table

WHERE otype = 'D'

AND objid = z_course_table-objid

AND sclas = 'P'

AND relat in r_relat.

0 Kudos

hi anurag i try your soltion but it bring me a 2 errors like that u have any soltion

thankes men.

The current ABAP/4 program attempted to execute an ABAP/4 Open SQL

statement in which the WHERE condition contains an IN itab operator.

The IN itab operator is used with internal tables which

have the following structure:

SIGN(1) OPTION(2) LOW LIKE db_field HIGH LIKE db_field

The OPTION column should contain only one of the following values:

"EQ LE GE CP BT NE LT GT NP NB"

The value "I " is not allowed here.

AND WHEN I *ASTRICK r_relat-option = 'I'. THIS IS MY ERROR

The IN itab operator is used with internal tables which

have the following structure:

SIGN(1) OPTION(2) LOW LIKE db_field HIGH LIKE db_field

The OPTION column should contain only one of the following values:

"EQ LE GE CP BT NE LT GT NP NB"

The value " " is not allowed here

REGARDS

0 Kudos

Sorry my mistake ...please check the change in bold.

If switch_history = 'X'.

r_relat-low = '027'.

<b>r_relat-sign = 'I'.

r_relat-option = 'EQ'.</b>

append r_relat.

else.

r_relat-low = '027'.

<b>r_relat-sign = 'I'.

r_relat-option = 'EQ'.</b>append r_relat.

r_relat-low = '034'.

r_relat-sign = 'EQ'.

r_relat-option = 'I'.

append r_relat.

endif.

Former Member
0 Kudos

hi

good

go through this link which ll give you detail idea about the dynamic screen

http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/dbab1c35c111d1829f0000e829fbfe/content.htm

thanks

mrutyun^

Former Member
0 Kudos

Hi Tal

Duplicate thread...

Please close one of the thread and continue with the other...

Request you not to open duplicate threads on same topic...

Regards

Eswar

Former Member
0 Kudos

hi try this

IF switch_history = 'X' .

ceck_str = 'relat EQ ''027'''.

ELSE.

ceck_str = 'relat in ( ''027'' , ''034'' )'. ENDIF.

or

IF switch_history = 'X' .

ceck_str = 'relat EQ ''027'''.

ELSE.

ceck_str = ' ( relat EQ ''027'' OR relat EQ ''034'' )'. ENDIF.

regards

shiba dutta

regards