cancel
Showing results for 
Search instead for 
Did you mean: 

FM 'HR_READ_INFOTYPE'

Former Member
0 Kudos

Hi,

I'm creating a FM, where FM 'HR_READ_INFOTYPE' is called, to validate requests. I have a run time error after entering input. sample code is given below:

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

TYPES : BEGIN of ty_0001,

pernr TYPE pa0001-pernr,

PERSG TYPE pa0001-PERSG,

PERSK TYPE pa0001-PERSK,

massn TYPE pa0000-MASSN,

END OF ty_0001.

DATA : it0001 TYPE TABLE OF ty_0001 with header line.

*tables:

*it0001.

infotypes:

0001, 0000.

msg = 'Business Assignment Action has not been Initiated ...Please Contact HR'.

DATA: p_pernr TYPE ty_0001-pernr,

P_PERSG TYPE TY_0001-PERSG, P_PERSK TYPE ty_0001-PERSK, wa_0001 TYPE ty_0001.

>>>>>call FUNCTION 'HR_READ_INFOTYPE'

EXPORTING

pernr = p_pernr

infty = '0001'

tables

infty_tab = p0001

exceptions

infty_not_found = 1

others = 2.

append wa_0001 to it0001.

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

The error occurs when the FM is called.

Here is the complete algorith for the FM I'm creating.

Screen processing:

If Traveler / Travel Planner selects trip Activity Type u2018Contractors Travelu2019

Read IT 0000 for PENR

If Employee Group (PERSG) =3 &

PERSK = K1 / K2 /V1/ V2/ W1 / W2 read Action Type (MASSN) from IT 0000 SJ / SK. If Action type is found as of date and has end date later than the system date, Allow to Create a Travel Request

If no action found, give an error message u201CBusiness Assignment Action has not been Initiated ...Please Contact HRu2019

points would be rewarded for useful answers.

thanks&regards;

Edited by: abbas ali on Sep 16, 2008 9:17 AM

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi guys,

here is the complete code I wrote.

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

FUNCTION ZVALIDATE.

*"----


""Local Interface:

*" IMPORTING

*" REFERENCE(PERSONNEL_NUMBBER) TYPE PERNR

*" REFERENCE(CONTRACT_TYPE) TYPE KZTKT

*"----


TYPES : BEGIN of ty_0001,

pernr TYPE pa0001-pernr,

  • begda TYPE pa0001-begda,

  • endda TYPE PA0001-endda,

PERSG TYPE pa0001-PERSG,

PERSK TYPE pa0001-PERSK,

massn TYPE pa0000-MASSN,

END OF ty_0001.

DATA : it0001 TYPE TABLE OF ty_0001 with header line, msg type string, p_pernr1 type prelp-pernr.

DATA : it_p0001 type table of p0001, it_p0000 type table of p0000, pernr2 TYPE pa0000-pernr.

*tables:

*it0001.

*infotypes:

  • 0001, 0000.

DATA: p_pernr TYPE ty_0001-pernr,P_PERSG TYPE TY_0001-PERSG,

P_PERSK TYPE ty_0001-PERSK, wa_0001 TYPE ty_0001.

msg = 'Business Assignment Action has not been Initiated ...Please Contact HR'.

SELECT pernr

INTO CORRESPONDING FIELDS OF TABLE it0001

FROM pa0001 "as p1 left outer join pa0000 as p0 ON p1pernr = p0pernr

WHERE pernr EQ PERSONNEL_NUMBBER. "entered pernr

call FUNCTION 'HR_READ_INFOTYPE'

EXPORTING

pernr = p_pernr1

infty = '0001'

begda = sy-datum

endda = sy-datum

  • WA_0001-PERSG = P_PERSG

  • wa_0001-PERSK = P_PERSK

tables

infty_tab = it_p0001

exceptions

infty_not_found = 1

others = 2.

*append wa_0001 to it0001.

SELECT massn

INTO it0001

FROM pa0000

WHERE pernr2 EQ PERSONNEL_NUMBBER. "entered pernr

ENDSELECT.

loop at it0001.

if ( WA_0001-PERSG = '3' ) AND ( wa_0001-PERSK = 'K1' OR wa_0001-PERSK = 'K2' OR wa_0001-PERSK = 'V1' OR wa_0001-PERSK = 'V2' OR wa_0001-PERSK = 'W1' OR wa_0001-PERSK = 'W2' ).

call FUNCTION 'HR_READ_INFOTYPE'

EXPORTING

pernr = p_pernr

infty = '0000'

tables

infty_tab = it_p0000

exceptions

infty_not_found = 1

others = 2.

if ( wa_0001-massn = 'SJ' OR wa_0001-massn = 'SK' ). " Action Type is found

exit.

ENDIF.

ELSE.

write: msg. " Action Type Not found

ENDIF.

ENDLOOP.

ENDFUNCTION.

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

Now, the error message is:

Field "PERNR2" unknown.

" I started 2 hate SAP!!!"

former_member181995
Active Contributor
0 Kudos
SELECT massn
INTO it0001
FROM pa0000
WHERE pernr EQ PERSONNEL_NUMBBER. "<<<--check here
ENDSELECT.
Former Member
0 Kudos

Hi Ámit,

U see, I defined pernr2 to use it in the 2nd select statement, but i don't know how to solve this problem.

I'm using two tables here: pa0000 and pa0001 with similar fields.

please have a look at the provided algorithm for this FM:

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

If Traveler / Travel Planner selects trip Activity Type u2018Contractors Travelu2019

Read IT 0000 for PENR

If Employee Group (PERSG) =3 &

PERSK = K1 / K2 /V1/ V2/ W1 / W2 read Action Type (MASSN) from IT 0000 SJ / SK. If Action type is found as of date and has end date later than the system date, Allow to Create a Travel Request

If no action found, give an error message u201CBusiness Assignment Action has not been Initiated ...Please Contact HRu2019

For all other employee Subgroups under Employee Group 3 this validation will not apply.

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

My logic might be wrong, I'm not sure.

Regards,

shafiq_rehman3
Active Contributor
0 Kudos

You will definately need to do what Ranjith said above.

On top of that, make sure the type of p_pernr, I cannot see in the code that you have published. It should not be character type, if it is then move it to a pernr type.

Begda and Endda are defaulted, but are you sure you do not want to use any BEGDA or ENDDA for reading the infotype?

Otherwise can you share the text from the dump?

Former Member
0 Kudos

Hi Abbas

First check the employee number you are passing has a valid record in PA0001.

declare p_pernr type prelp-pernr,

p0001 type table of p0001.

second thing check begda & endda that you are passing (or pass sy-datum)

and if you can post the error message or dump message (if you are getting runtime error) then we can help you out.

you are using FM to read IT-0001 & logic of custom FM is based on IT-0000 ?

Former Member
0 Kudos

Hi Ranjith,

actually, nothing has changed even after modification.

Thanks & regards.

Former Member
0 Kudos

comment following

infotypes : 0000,0001.

and add following.

data : it_p0001 type table of p0001.

and pass this table to FM instead of p0001.

Try it out. Best of luck.

Please award necessary points, if this helps you.

Regards,

Ranjith