Application Development 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: 

FM: HR_READ_INFOTYPE Problem

Former Member
0 Kudos

Hi all you ABAP experts!

I'm working in a program (report mode) that has to read the data from an Infotype (in this case is IT0584) just after the IT has been created (by the same program, using CALL TRANSACTION). I am using the HR_READ_INFOTYPE FM as follows:

-


CLEAR: p0584, p0584[].

CALL FUNCTION 'HR_READ_INFOTYPE'

EXPORTING

pernr = l_test_pernr

infty = l_infty

"BYPASS_BUFFER = 'X'

TABLES

infty_tab = p0584

EXCEPTIONS

infty_not_found = 1

OTHERS = 2.

" p0584 was declared using: INFOTYPES: 0584.

-


As you can notice the BYPASS_BUFFER parameter is commented. The "problem" is that I can see the record just created in SE16 but I can't get anything into p0584.

Now, if I uncomment the BYPASS_BUFFER I get the record(s) into p0584. Could anybody please explain me why this happens? How exactly does the BYPAS_BUFFER parameter is affecting p0584?

This really confuses me because I'm using the same FM without the BYPASS_BUFFER at the begining of the program for the same Infotype and successfully getting the existing records by that moment.

I will really appreciate if any can provide me the answer. Many thanks in advance!

1 ACCEPTED SOLUTION

Former Member
0 Kudos

HI

Hope this will help you.

try to make use of FM

'HR_INFOTYPE_OPERATION'

and see the sample code:-

https://www.sdn.sap.com/irj/sdn/wiki?path=/pages/viewpage.action&pageid=13160

REPORT YBDC_NEW_586

no standard page heading line-size 255.

data: begin of i_upload occurs 0,

pernr like pa0586-pernr,

bedda(10) type c,

ebdda(10) type c,

pin01 like pa0586-pin01,

pin02 like pa0586-pin01,

pin03 like pa0586-pin01,

pin04 like pa0586-pin01,

pin05 like pa0586-pin01,

pin06 like pa0586-pin01,

pin07 like pa0586-pin01,

pin08 like pa0586-pin01,

pin09 like pa0586-pin01,

pin11 like pa0586-pin01,

pin12 like pa0586-pin01,

pin13 like pa0586-pin01,

pin14 like pa0586-pin01,

pin16 like pa0586-pin01,

pin17 like pa0586-pin01,

pin18 like pa0586-pin01,

pin19 like pa0586-pin01,

pin20 like pa0586-pin01,

pin21 like pa0586-pin01,

pin22 like pa0586-pin01,

pin23 like pa0586-pin01,

pin24 like pa0586-pin01,

pin25 like pa0586-pin01,

ain01 like pa0586-ain01,

ain02 like pa0586-ain01,

ain03 like pa0586-ain01,

ain04 like pa0586-ain01,

ain05 like pa0586-ain01,

ain06 like pa0586-ain01,

ain07 like pa0586-ain01,

ain08 like pa0586-ain01,

ain09 like pa0586-ain01,

ain11 like pa0586-ain01,

ain12 like pa0586-ain01,

ain13 like pa0586-ain01,

ain14 like pa0586-ain01,

ain16 like pa0586-ain01,

ain17 like pa0586-ain01,

ain18 like pa0586-ain01,

ain19 like pa0586-ain01,

ain20 like pa0586-ain01,

ain21 like pa0586-ain01,

ain22 like pa0586-ain01,

ain23 like pa0586-ain01,

ain24 like pa0586-ain01,

ain25 like pa0586-ain01,

end of i_upload.

data: begin of p586 occurs 0,

icode like pa0586-itc01,

pinvt like pa0586-pin01,

ainvt like pa0586-ain01,

end of p586.

data: p0586 like p0586 ,

ia586 like pa0586 occurs 0 with header line,

return like bapireturn1,

pin_ainvt type pin_ainvt.

************************************************************************

  • S E L E C T I O N - S C R E E N D E F I N I T I O N *

************************************************************************

selection-screen begin of block b1 with frame title text-001.

parameters: p_file like rlgrap-filename obligatory,

p_begda like pa0586-begda obligatory,

p_endda like pa0586-endda obligatory.

selection-screen end of block b1.

************************************************************************

  • E V E N T H A N D L I N G - B E G I N *

************************************************************************

at selection-screen on value-request for p_file.

perform get_file using p_file.

************************************************************************

  • START OF SELECTION - B E G I N *

************************************************************************

start-of-selection.

data: lines like sy-index.

*Getting the file data.

perform upload using p_file.

loop at i_upload.

ia586-pernr = i_upload-pernr.

ia586-endda = p_endda.

ia586-begda = p_begda.

perform col_row.

perform do.

append ia586.

clear : ia586,p586.

refresh : p586.

endloop.

loop at ia586.

move-corresponding ia586 to p0586.

CALL FUNCTION 'HR_EMPLOYEE_ENQUEUE'

EXPORTING

NUMBER = p0586-pernr.

CALL FUNCTION 'HR_INFOTYPE_OPERATION'

EXPORTING

INFTY = '0586'

NUMBER = p0586-pernr

LOCKINDICATOR = ''

VALIDITYEND = p0586-endda

VALIDITYBEGIN = p0586-begda

RECORD = p0586

OPERATION = 'INS' or MOD or DEL

NOCOMMIT = ''

tclas = 'A'

IMPORTING

RETURN = RETURN

EXCEPTIONS

OTHERS = 0.

CALL FUNCTION 'HR_EMPLOYEE_ENQUEUE'

EXPORTING

NUMBER = p0586-pernr.

clear : p0586.

endloop.

&----


*& Form GET_FILE

&----


  • Show "Open File" dialog box on F4

----


  • -->P_W_FILE Name of the file selected by the user

----


form get_file using p_w_file.

call function 'KD_GET_FILENAME_ON_F4'

CHANGING

file_name = p_w_file

EXCEPTIONS

mask_too_long = 1

others = 2.

if sy-subrc ne 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

endform. "GET_FILE

&----


*& Form UPLOAD

&----


  • Upload the file into the internal table for processing

----


  • -->P_LOADFILE Name of file to upload

----


form upload using p_loadfile.

  • Read the file into the Internal Table

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

filename = p_loadfile

filetype = 'DAT'

TABLES

data_tab = i_upload.

if sy-subrc ne 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

endform. "UPLOAD

FORM col_row .

if i_upload-ain01 is not initial or i_upload-pin01 is not initial.

p586-icode = '01'.

p586-pinvt = i_upload-pin01.

p586-ainvt = i_upload-ain01.

append p586.

clear p586.

endif.

if i_upload-ain02 is not initial or i_upload-pin02 is not initial.

p586-icode = '02'.

p586-pinvt = i_upload-pin02.

p586-ainvt = i_upload-ain02.

append p586.

clear p586.

endif.

if i_upload-ain03 is not initial or i_upload-pin03 is not initial.

p586-icode = '03'.

p586-pinvt = i_upload-pin03.

reward if help.

5 REPLIES 5

Former Member
0 Kudos

hi,

Actually this hr_read infotype fm processes the data in such a way that it keeps the personal number locked until the entire loop within which it is declared gets completed.So if we r using this to read large data u have to call a Fm to initialize the buffer first.

in ur case it is keeping the data in buffer so ur able to fetch the data.

reward points if helpful,

Regards,

Sumanjeet.

0 Kudos

Hi Sumanjeet!

Thank you for your answer.

Is it possible to unlock the personal number? I have tried with the BAPI_EMPLOYEE_ENQUEUE/DEQUEUE but it didn't make any difference.

What FM should I use to initialize the buffer?

Many thanks in advance.

0 Kudos

Hi rix,

After call transaction try committing the work explicitly by using command 'COMMIT WORK'.

I guess your program updates the database only after committing the work/ end of the program.

IF you commit work explicitly you should able to read through HR_READ_INFOTYPE in both modes.

Hope this helps,

Shrinivas

Former Member
0 Kudos

HI

Hope this will help you.

try to make use of FM

'HR_INFOTYPE_OPERATION'

and see the sample code:-

https://www.sdn.sap.com/irj/sdn/wiki?path=/pages/viewpage.action&pageid=13160

REPORT YBDC_NEW_586

no standard page heading line-size 255.

data: begin of i_upload occurs 0,

pernr like pa0586-pernr,

bedda(10) type c,

ebdda(10) type c,

pin01 like pa0586-pin01,

pin02 like pa0586-pin01,

pin03 like pa0586-pin01,

pin04 like pa0586-pin01,

pin05 like pa0586-pin01,

pin06 like pa0586-pin01,

pin07 like pa0586-pin01,

pin08 like pa0586-pin01,

pin09 like pa0586-pin01,

pin11 like pa0586-pin01,

pin12 like pa0586-pin01,

pin13 like pa0586-pin01,

pin14 like pa0586-pin01,

pin16 like pa0586-pin01,

pin17 like pa0586-pin01,

pin18 like pa0586-pin01,

pin19 like pa0586-pin01,

pin20 like pa0586-pin01,

pin21 like pa0586-pin01,

pin22 like pa0586-pin01,

pin23 like pa0586-pin01,

pin24 like pa0586-pin01,

pin25 like pa0586-pin01,

ain01 like pa0586-ain01,

ain02 like pa0586-ain01,

ain03 like pa0586-ain01,

ain04 like pa0586-ain01,

ain05 like pa0586-ain01,

ain06 like pa0586-ain01,

ain07 like pa0586-ain01,

ain08 like pa0586-ain01,

ain09 like pa0586-ain01,

ain11 like pa0586-ain01,

ain12 like pa0586-ain01,

ain13 like pa0586-ain01,

ain14 like pa0586-ain01,

ain16 like pa0586-ain01,

ain17 like pa0586-ain01,

ain18 like pa0586-ain01,

ain19 like pa0586-ain01,

ain20 like pa0586-ain01,

ain21 like pa0586-ain01,

ain22 like pa0586-ain01,

ain23 like pa0586-ain01,

ain24 like pa0586-ain01,

ain25 like pa0586-ain01,

end of i_upload.

data: begin of p586 occurs 0,

icode like pa0586-itc01,

pinvt like pa0586-pin01,

ainvt like pa0586-ain01,

end of p586.

data: p0586 like p0586 ,

ia586 like pa0586 occurs 0 with header line,

return like bapireturn1,

pin_ainvt type pin_ainvt.

************************************************************************

  • S E L E C T I O N - S C R E E N D E F I N I T I O N *

************************************************************************

selection-screen begin of block b1 with frame title text-001.

parameters: p_file like rlgrap-filename obligatory,

p_begda like pa0586-begda obligatory,

p_endda like pa0586-endda obligatory.

selection-screen end of block b1.

************************************************************************

  • E V E N T H A N D L I N G - B E G I N *

************************************************************************

at selection-screen on value-request for p_file.

perform get_file using p_file.

************************************************************************

  • START OF SELECTION - B E G I N *

************************************************************************

start-of-selection.

data: lines like sy-index.

*Getting the file data.

perform upload using p_file.

loop at i_upload.

ia586-pernr = i_upload-pernr.

ia586-endda = p_endda.

ia586-begda = p_begda.

perform col_row.

perform do.

append ia586.

clear : ia586,p586.

refresh : p586.

endloop.

loop at ia586.

move-corresponding ia586 to p0586.

CALL FUNCTION 'HR_EMPLOYEE_ENQUEUE'

EXPORTING

NUMBER = p0586-pernr.

CALL FUNCTION 'HR_INFOTYPE_OPERATION'

EXPORTING

INFTY = '0586'

NUMBER = p0586-pernr

LOCKINDICATOR = ''

VALIDITYEND = p0586-endda

VALIDITYBEGIN = p0586-begda

RECORD = p0586

OPERATION = 'INS' or MOD or DEL

NOCOMMIT = ''

tclas = 'A'

IMPORTING

RETURN = RETURN

EXCEPTIONS

OTHERS = 0.

CALL FUNCTION 'HR_EMPLOYEE_ENQUEUE'

EXPORTING

NUMBER = p0586-pernr.

clear : p0586.

endloop.

&----


*& Form GET_FILE

&----


  • Show "Open File" dialog box on F4

----


  • -->P_W_FILE Name of the file selected by the user

----


form get_file using p_w_file.

call function 'KD_GET_FILENAME_ON_F4'

CHANGING

file_name = p_w_file

EXCEPTIONS

mask_too_long = 1

others = 2.

if sy-subrc ne 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

endform. "GET_FILE

&----


*& Form UPLOAD

&----


  • Upload the file into the internal table for processing

----


  • -->P_LOADFILE Name of file to upload

----


form upload using p_loadfile.

  • Read the file into the Internal Table

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

filename = p_loadfile

filetype = 'DAT'

TABLES

data_tab = i_upload.

if sy-subrc ne 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

endform. "UPLOAD

FORM col_row .

if i_upload-ain01 is not initial or i_upload-pin01 is not initial.

p586-icode = '01'.

p586-pinvt = i_upload-pin01.

p586-ainvt = i_upload-ain01.

append p586.

clear p586.

endif.

if i_upload-ain02 is not initial or i_upload-pin02 is not initial.

p586-icode = '02'.

p586-pinvt = i_upload-pin02.

p586-ainvt = i_upload-ain02.

append p586.

clear p586.

endif.

if i_upload-ain03 is not initial or i_upload-pin03 is not initial.

p586-icode = '03'.

p586-pinvt = i_upload-pin03.

reward if help.

Former Member
0 Kudos

Thank you all guys for your help. I will create a new question to find if someone can explain me what does the BYPASS_BUFFER parameter do.