2012 May 28 4:11 AM
Hi,
I want to read a record from a table with below condition
READ TABLE pp0001 WITH KEY PERNR = group_all_pernrs_wa-pernr and BEGDA <= PN-DBEDA ENDDA >= PN-ENDDA.
but encounter error, it said can't use <=, only =, how can I get the record with above condition?
2012 May 28 7:03 AM
Hi,
The best way to do it is use a LOOP statement with all conditions in the where clause of the LOOP. This will make sure only that particular record enters inside the LOOP statement. Syntax would be like below,
LOOP AT pp0001 WHERE PERNR = group_all_pernrs_wa-pernr AND BEGDA <= PN-DBEDA AND ENDDA >= PN-ENDDA.
< your logic>
ENDLOOP.
Reagrds,
Praveenkumar T
2012 May 28 7:03 AM
Hi,
The best way to do it is use a LOOP statement with all conditions in the where clause of the LOOP. This will make sure only that particular record enters inside the LOOP statement. Syntax would be like below,
LOOP AT pp0001 WHERE PERNR = group_all_pernrs_wa-pernr AND BEGDA <= PN-DBEDA AND ENDDA >= PN-ENDDA.
< your logic>
ENDLOOP.
Reagrds,
Praveenkumar T
2012 May 28 7:18 AM
Hi,
You could TRY this.
READ TABLE pp0001 WITH KEY PERNR = group_all_pernrs_wa-pernr.
IF sy-subrc EQ 0.
IF BEGDA <= PN-DBEDA AND ENDDA >= PN-ENDDA.
" put your action here
ENDIF.
ENDIF.
Regards,
Jake
2012 May 28 7:23 AM
Hi,
In read statement you cannot use the <= or >= signs.It allows only = sign in the with key condition.
For your requirement you can use loop statement as below:
Loop at pp0001 where PERNR = group_all_pernrs_wa-pernr
and BEGDA <= PN-DBEDA
and ENDDA >= PN-ENDDA.
"Your logic"
Endloop.
If sy-subrc ne 0. "If the above condition is not satisfied that is the loop fails.
"Your logic
Endif.
Hope it serves your problem.
2012 May 28 7:25 AM
You can use this way...
READ TABLE pp0001 WITH KEY PERNR = group_all_pernrs_wa-pernr.
if BEGDA <= PN-DBEDA and ENDDA >= PN-ENDDA.
****** process your code***
endif.
Regards,
Manu
2012 May 28 10:37 AM
Hi
I thought you need to READ TABLE and do not required to Run a LOOP.
Rgds,
ManuB
2012 May 28 10:46 AM
Hi Manu,
yes you could have used READ TABLE , But the problem would be if you had more than one data for PERNR = group_all_pernrs_wa-pernr. Then your read table will return only the first record and hence you will miss out the remaining records. Therefore READ TABLE will not workout for all the cases in this situation.
Hope i am clear.
Regards,
Praveenkumar T.
2012 May 28 7:34 AM
Hi,
The table PP0001 looks like a HR infotype, so you should be using the LDB(Logical Database) statements like PROVIDE to acheive your requirement.
Also see ABAP HR macros like ;
RP_PROVIDE_FROM_LAST
RP_SET_DATA_INTERVAL
RP_READ_INFOTYPE
Read the F1 help for PROVIDE.
Regards,
Karthik D
2012 May 28 7:42 AM
DO NOT USE 'AND' -- between two conditions of Read table command.
ur code:
READ TABLE pp0001 WITH KEY PERNR = group_all_pernrs_wa-pernr and BEGDA <= PN-DBEDA ENDDA >= PN-ENDDA.
instead u should Write:
READ TABLE pp0001 WITH KEY PERNR = group_all_pernrs_wa-pernr
BEGDA <= PN-DBEDA ENDDA >= PN-ENDDA.