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

HR

Former Member
0 Likes
1,047

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.

7 REPLIES 7
Read only

Former Member
0 Likes
1,003

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

Read only

Former Member
0 Likes
1,003

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.

Read only

anversha_s
Active Contributor
0 Likes
1,003

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

Read only

Former Member
0 Likes
1,003

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.

Read only

Former Member
0 Likes
1,003

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?

Read only

0 Likes
1,003

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.

Read only

Former Member
0 Likes
1,003

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.