cancel
Showing results for 
Search instead for 
Did you mean: 

HR Abap - Using select query

hassimkhan
Explorer
0 Kudos

Hello expert,

I've tried provide statement and macro both work fine. Now i want to do a select statement using bedga and endda entered on screen.

"getting all employee personal number & normal hours employee only

   SELECT pernr

     FROM pa0007

     INTO TABLE gt_007

     WHERE begda <= p_begda AND endda > p_endda.


Is this the right way? Because here we are dealing with with period interval not just comparing date, please let me know if this is correct

Accepted Solutions (1)

Accepted Solutions (1)

aarif_baig
Active Participant
0 Kudos

Hi hassim,

                 Your code is correct if your are not using LDB, Just a little change for endda

SELECT pernr

     FROM pa0007

     INTO TABLE gt_007

     WHERE begda <= p_begda AND endda >= p_endda.


cheers

hassimkhan
Explorer
0 Kudos

Thanks for your replied, just one question.

Assume p_begda is 01.01.2000 and p_endda is 31.12.2020

Using your select query, What will happen to the record in between for e.g:

01.02.2001 ending at 01.01.2021.

It is a valid records isnt?

aarif_baig
Active Participant
0 Kudos

yes it will pick that data

hassimkhan
Explorer
0 Kudos

Can you please explain me how...

begda <= p_begda  >>> it will take all date less or equal to.


endda >= p_endda. >>> it will take all date greater of equal to.


How will it take the middle values 

aarif_baig
Active Participant
0 Kudos

Sorry hassim, I misread your question mate it will not pick that data

former_member201275
Active Contributor
0 Kudos

You could then try:

WHERE begda <= p_begda OR endda >= p_endda.

0 Kudos

Hi

If you want to cover all values then why don't you try

where begda <= p_endda and endda >= p_begda.

thanks

Answers (2)

Answers (2)

former_member201275
Active Contributor
0 Kudos

Hi Hassim,

Did you manage to resolve the issue? If so please post the code here so that others can also learn. Thank u.

benamor_bentebba
Participant
0 Kudos

Hi,

try with:


DATA: GT_007 LIKE PA0007 OCCURS 0 WITH HEADER LINE.


SELECT * FROM PA0007 INTO TABLE GT_007

     WHERE ( PERNR = PERNR-PERNR AND BEGDA <=  PN-BEGDA

                    AND   ENDDA >=  PN-ENDDA.

benamor_bentebba
Participant
0 Kudos

@Hassim,

select PNP in Logical database on attributes of screen,

and put:

DATA: GT_007 LIKE PA0007 OCCURS 0 WITH HEADER LINE.

SELECT PERNR

      FROM PA0007

      INTO TABLE GT_007

      WHERE BEGDA <= PN-BEGDA AND ENDDA >= PN-ENDDA.


A+