‎2005 Dec 06 9:22 AM
How to retrieve a field from an infotype.
Suppose in infotype P0017,the field name is KFZKZ.I want to compare this field with an internal table field.
1.Can I just use If P0017-KFZKZ = INTAB-FIELD or some thing else (because it is an infotype)
2.If i want to retrieve P0017-KFZKZ,how can i do this
Please reply immediately
‎2005 Dec 06 9:31 AM
Hi Jayasree,
Use the following method
Infotypes : 0017.
Start-of-selection.
rp-provide-from-last p0017 space pn-begda pn-endda.
if p0017-kfzkz = intab-field.
*--so some thing
else.
*--do something.
endif.
Reward points if it help you.
Regards,
Sudhakar
‎2005 Dec 06 9:33 AM
Hi Jayasree,
You need to seelct KFZKZ from table PA0017 (HR master record: Infotype 0017 (Travel Privileges) and then do the comparision.
Regards,
Raj
‎2005 Dec 06 9:36 AM
Hi jayasree,
1. How to retrieve a field from an infotype
Before answering, this
how are u retrieing infotype data ?
2. Use the FM
HR_READ_INFOTYPE
(This is recommended by SAP)
as compared to getting data
thru SQLs
3. Yes, after retriving data,
u can compare the field, like any other table field.
(Make sure u compare the right record, bcos
the infotype internal table may contain
more than one record )
Regards,
Amit M.
‎2005 Dec 06 10:20 AM
Hi Jayasree,
The mode of data retrieval really depends on the design of your report. If you have tied it to either PNP or PNPCE Logical Database, you can use the macro ie
RP-PROVIDE-FROM-LAST or LOOP AT P0017.. ENDLOOP. If you are not using the Logical Database, you are better off using the function call 'HR_READ_INFOTYPE' instead instead of direct SELECT on the PA0017 table.
Good Luck,
Suresh DAtti
‎2005 Dec 07 6:10 AM
REPORT ZTEST.
INFOTYPES: 0017.
DATA:PERNR LIKE P0017-PERNR.
CALL FUNCTION 'HR_READ_INFOTYPE'
EXPORTING
TCLAS = 'A'
PERNR = PERNR
INFTY = 'P0017'
BEGDA = '18000101'
ENDDA = '99991231'
BYPASS_BUFFER = ' '
LEGACY_MODE = ' '
IMPORTING
SUBRC =
TABLES
INFTY_TAB = P0017
EXCEPTIONS
INFTY_NOT_FOUND = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
WRITE P0017-PERNR.
WRITE P0017-KFZKZ.
iF i EXECUTE THIS CODE , A SHORT DUMP IS OCCURING . IT IS TELLING INCORRECT FUNCTION MODULE.
PL REPLY IMMM
‎2005 Dec 07 6:46 AM
Hi
In HR Module keep few things in your mind
P0001, P0002....P0017....
All are line type of tables
PA0001, PA0002.....PA0017..
And their infotypes Are
0001, 0002.....0017...
So in your case instead of INFTY = P0017 use infty = 0017.
Hope you get your problem solved now
Regards
Amit
‎2005 Dec 07 6:18 AM
Hi again,
1. While calling the FM
Use
infty = '0017'
instead of infty = 'P0017'
( Don't write P )
2. It will work. I tried here.
3. We have to give the name of the infotype.
(Not the internal table)
4. The above will solve your problem and
u will not get any short dump.
5. However i noticed in the code, that
u have not passed Pernr value.
ie. we have to pass the actual personnel number.
eg. 0001, 0002 ,0100 etc.
Then only u will get some data.
Otherwise no data in P0017.
regards,
amit m.
Message was edited by: Amit Mittal
Message was edited by: Amit Mittal
Message was edited by: Amit Mittal
‎2005 Dec 07 6:19 AM
Hi Jayasree,
Try this one:
REPORT ZTEST.
INFOTYPES: 0017.
DATA:V_PERNR LIKE P0017-PERNR,
IT_0017 LIKE P0017.
V_PERNR = '1234'. "You need to pass Personnel no
CALL FUNCTION 'HR_READ_INFOTYPE'
EXPORTING
TCLAS = 'A'
PERNR = V_PERNR
INFTY = '0017'
BEGDA = '18000101'
ENDDA = '99991231'
BYPASS_BUFFER = ' '
LEGACY_MODE = ' '
IMPORTING
SUBRC =
TABLES
INFTY_TAB = IT_0017
EXCEPTIONS
INFTY_NOT_FOUND = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
WRITE IT_0017-PERNR.
WRITE IT_0017-KFZKZ.
Let me know still you are getting dump.
Award points if it helps you.
Regards,
Sudhakar.
‎2007 Jun 24 1:48 PM
hey,
declare the internal table type table pa0017..
pass the value of the Infotype...
i.e., instead of p0017, give '0017'