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

String comparision

Former Member
0 Likes
543

Hi Gurus,

I have one variable 'Date' which is having value '10'. And I want to match this variable in where condition like this.

LOOP AT ITAB.

SELECT SINGLE KALTG FROM PA2001

INTO ITAB-KALTG

WHERE PERNR = ITAB-PERNR

AND BEGDA = DATE. "my variable havin value 10

MODIFY ITAB.

ENDLOOP.

NOW in this condition BEGDA is having some date like '01.10.2007' . Now I want to match that 'Date' variable to PA2001-BEGDA's only month. That means if BEGDA have 10th month then get record only like this.

Means my variale value '10' should match with only BEGDA 's 10 which is month and in midle of that BEGDA Date.

Thanks and Regards .

Pradip Pawar.

ABAP Consultant

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
522
DATA: l_begda_month TYPE string.

l_begda_month = '____10__'. "<---YYYYMMDD use of underscore instead of %

SELECT SINGLE KALTG FROM PA2001
INTO ITAB-KALTG
WHERE PERNR = ITAB-PERNR
AND <b>BEGDA LIKE l_begda_month</b>. 
4 REPLIES 4
Read only

Former Member
0 Likes
522

Hi,

Do like below :

LOOP AT ITAB. 
SELECT SINGLE KALTG FROM PA2001
INTO ITAB-KALTG
WHERE PERNR = ITAB-PERNR
AND BEGDA+4(2) = DATE. "Do this Change in your program
MODIFY ITAB.
ENDLOOP.

Thanks,

Sri.

Read only

Former Member
0 Likes
522

then you need to take a DATE type range and populate with that month's 1st date and last date in that range with BT option. Then use that range in select as below

SELECT SINGLE KALTG FROM PA2001

INTO ITAB-KALTG

WHERE PERNR = ITAB-PERNR

AND BEGDA in DATE_range.

Read only

Former Member
0 Likes
523
DATA: l_begda_month TYPE string.

l_begda_month = '____10__'. "<---YYYYMMDD use of underscore instead of %

SELECT SINGLE KALTG FROM PA2001
INTO ITAB-KALTG
WHERE PERNR = ITAB-PERNR
AND <b>BEGDA LIKE l_begda_month</b>. 
Read only

0 Likes
522

DATA: l_begda_month TYPE string.
 
l_begda_month = '____10__'. "<---YYYYMMDD use of underscore instead of %
 
SELECT SINGLE KALTG 
   FROM PA2001
   INTO ITAB-KALTG
   WHERE PERNR = ITAB-PERNR AND 
         BEGDA LIKE l_begda_month.