‎2007 Jun 13 6:16 AM
hi all,
how do we fetch the last record in the infotype IT0014 using a FM. i want the last record so that i can delimit the end date from 12/31/9999 to a new date.
points wud be awarded.
‎2007 Jun 13 6:20 AM
Hi Mouli,
you can always get the last record after fetching the data. You just need to SORT the same. No need to look for a special FM for the same.
Regards,
Atish
‎2007 Jun 13 6:21 AM
hi mouli,
try to select all records from the infotype to itab,
then use describe key word to know total records of that internal table,
then read statement on that itab to know the last record.
reward points if helpful.
regards,
seshu.
‎2007 Jun 13 6:24 AM
hi,
1. if ur using PNP LDB, then u can use -> rp_provide_from_last.
INFOTYPES: 0014,
0000. "Organizational Assignment
START-OF-SELECTION.
GET pernr.
rp_provide_from_frst p0000 space pn-begda pn-endda.
if pnp-sw-found EQ '1'.
READ TABLE p0001 WITH KEY pernr = p0000-pernr.
if sy-subrc = 0.
write : p0001-plans. " earliest.
endif.
endif.
rp_provide_from_last p0014 space pn-begda pn-endda.
if pnp-sw-found EQ '1'.
READ TABLE p0014 WITH KEY pernr = p0000-pernr.
if sy-subrc = 0.
write : p0014-LGART. .
endif.
endif.rgds
Anver
‎2007 Jun 13 6:38 AM
if u r sure tht u want to read a data with end date 31.12.9999 then u can simply write a select query to read tht record with pernr, endda and subtype in where clause.
use FM HR_INFOTYPE_OPERATION to delimit the current record.
data: itab like pa0014.
parameters: p_pernr like pa0014-pernr default '00062703'.
select single * from pa0014 into itab
where pernr = p_pernr
and subty = '8970'
and endda = '99991231'.
write: itab-pernr.
‎2007 Jun 13 6:41 AM
thanks for the replies.
i already fetched the last record after reading the internal table of PA0014 corresponding to a wage type with end date as 12/31/9999. this would fetch the last record ofcourse but my lead wants a FM which directly fetches the last record for the infotype IT0014 corresponding to a wage type. does anyone know if HR_ECM_READ_INFOTYPE Function Module works?
i am not working in PNP LDB. i actually dont know what PNP is?
‎2007 Jun 13 7:01 AM
refer this code then -
parameters: p_pernr like pa0014-pernr default '00062703'.
DATA: p0014_tab TYPE TABLE OF p0014 INITIAL SIZE 1 with header line.
data: begin of itab occurs 0.
include structure p0014.
data end of itab.
DATA: message_handler type ref to IF_HRPA_MESSAGE_HANDLER.
CALL FUNCTION 'HR_ECM_READ_INFOTYPE'
EXPORTING
pernr = p_pernr
infty = '0014'
SUBTY = '8970'
OBJPS = '*'
SPRPS = ' '
BEGDA = '18000101'
ENDDA = '99991231'
NO_AUTH_CHECK = ' '
message_handler = message_handler
IMPORTING
INFOTYPE_TAB = itab[].
loop at itab.
write: itab-pernr.
endloop.
‎2007 Jun 13 7:20 AM
Hi,
Please refer to the below program
Look at the marco used in the report
rp_provide_from_last p0001 space pn-begda pn-endda.
*******************
REPORT Z_HR_DEMO_2 LINE-SIZE 200
LINE-COUNT 65
MESSAGE-ID SY.
*-- Declaration
TABLES: pernr,
T001P. "plant section
INFOTYPES: 0001, "Organ. Assignment
0006. "Recurr. Earn. & Deduc.
DATA: FILLED_LINES LIKE SY-INDEX,
WA_RC LIKE SY-SUBRC.
*-- Processing
GET pernr.
DESCRIBE TABLE P0006 LINES FILLED_LINES.
IF filled_lines GT 0.
rp_provide_from_last p0001 space pn-begda pn-endda.
rp-read-t001p p0001-werks p0001-btrtl space.
SKIP 2.
WRITE: / pernr-pernr,
(20) p0001-ename,
p0001-werks,
t001p-btext.
CALL FUNCTION 'HR_READ_INFOTYPE'
EXPORTING
PERNR = PERNR-PERNR
INFTY = '0006'
BEGDA = PN-BEGDA
ENDDA = PN-ENDDA
IMPORTING
SUBRC = WA_RC
TABLES
INFTY_TAB = P0006
EXCEPTIONS
INFTY_NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC = 0.
WRITE : P0006-STRAS,
P0006-ORT01,
P0006-LAND1,
P0006-PSTLZ,
P0006-TELNR,
P0006-STATE.
ENDIF.
ENDIF.
END-OF-SELECTION.
********************
Regards,
IFF
Note: Reward Suitable points.