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: 

HR Macros

Former Member
0 Kudos
690

When ever i use the follwing macros get more than one record.. what can be the possible cause ?

<b>rp_provide_from_last</b>

<b>rp-provide-from-frst</b>

In principle it should return me one record per infotype but i am getting more than one.. sometime it gives mw whole of the table for that employee record which i am processing..

I am using the PNP LDB.

I don't know whats going wrong.. Any help would be appriciated...

Here is the Code

  • start of selection

START-OF-SELECTION.

GET pernr.

  • Selecting the infotype record

rp_provide_from_last p0000 space sy-datum sy-datum.

  • Active

  • check if they are active today

IF p0000-stat2 = '3'.

  • if yes

lv_begin = '18000101'.

lv_process = 'X'.

  • append to table

ELSE.

CALL FUNCTION 'RP_HIRE_FIRE'

EXPORTING

beg = '18000101'

end = '99991231'

IMPORTING

fire_date = lv_termdate

hire_date = lv_hiredate

TABLES

pp0000 = p0000.

IF lv_termdate => '20050701'.

lv_begin = '20050701'.

lv_process = 'X'.

ENDIF.

ENDIF.

CHECK lv_process = 'X'.

rp-provide-from-frst p0000 space lv_begin '99991231'.

rp-provide-from-frst p0001 space lv_begin '99991231'.

rp-provide-from-frst p0002 space lv_begin '99991231'.

MOVE-CORRESPONDING p0000 TO wa_0000.

MOVE-CORRESPONDING p0001 TO wa_0001.

MOVE-CORRESPONDING p0002 TO wa_0002.

APPEND wa_0000 TO it_employee.

END-OF-SELECTION.

<b></b>

14 REPLIES 14

former_member181966
Active Contributor
0 Kudos
277

<b>rp_provide_from_last

rp-provide-from-frst</b>

This macro will give you all records , but you have to pass paramter in order that which recored you wna read ...

like this

rp_provide_from_last p0002 space pn-begda pn-endda.

hope this `ll help .

Thanks

Message was edited by: Saquib Khan

suresh_datti
Active Contributor
0 Kudos
277

Hi,

It could be clearing issue. put

clear: wa_0000,p0000, p0001,p0002.

after the append statement.

Also the after get pernr all the infotype records get loaded into the itabs p0000,p0001& p0002. When you use the last/first macro the corresponding record gets moved to the header of the infotype's internal table. ie p0001,1,2 as the case may be. I am pretty sure there is nothing wrong with the macros.

Regards,

Suresh Datti

Former Member
0 Kudos
277

use PNP-SW-FOUND check after each RP-provide staement and if it is equal to 1 only move the correspoding data then the program may give single result

thanks

Aditya

Former Member
0 Kudos
277

get pernr and end-of selection acts like loop endloop.

and as ur passing this lv_begin = '18000101'.

The infotypes on which rp-provide gets the data it will display all the data from those infotypes.

so if u give "IF PNP-SW-FOUND = 1." after the statement

<b>rp_provide_from_last p0000 space sy-datum sy-datum.</b>

and

"endif." before the statement

<b>END-OF-SELECTION</b>

you will only get one record for one employee if the employee if present in table PA0001

thanks

Aditya

0 Kudos
277

Hi Aditya,

I have done as you told me. i placed

<b>IF PNP-SW-FOUND = 1.</b> right after the

<b> rp_provide_from_last p0000 space sy-datum sy-datum.</b> stetement and <b>ENDIF</b> before the <b>END-OF-SELECTION</b>. I am still getting stragne results.

parameter value of <b>pn-begda</b> and <b>pn-endda</b> is <b>20060209</b> which is sy-datum basically which i am intending to pass.

<i><b>Here are results</b></i>

I have Six Records when i <b>GET PERNR</b>.

PERNR INFTY SUBTY OBJPS SPRPS ENDDA BEGDA

1 00000350|0000 | | | |19980630|19970818|

2 00000350|0000 | | | |20010630|19980701|

3 00000350|0000 | | | |20030630|20010701|

4 00000350|0000 | | | |20031031|20030701|

5 00000350|0000 | | | |20041231|20031101|

6 00000350|0000 | | | |99991231|20050101|

When i step on to the <b>rp_provide statement</b> with the folowwing code

<b>rp_provide_from_last p0000 space sy-datum sy-datum</b> i still get 6 records.

The data set which i am getting is not what i am looking for. Even if i enclose the statement with the <b>IF PNP-SW-FOUND = 1</b> statement. it doesn't help me at all. don't know whats going on.

0 Kudos
277

Hi,

rp-provide-from last fetch you all the records, but the header record will have the correct records as per the dates you mentioned in the rp-provide-statement.

Venu

0 Kudos
277

Hi Amnadeep.

The RP_PROVIDE_FROM_LAST P0000 space sy-datum sy-datum macro will only move the last record in P0000 internal table to its header.

Can you pl post the complete code? the part between GET PERNR & END-OF-SELECTION events.

Regards,

Suresh Datti

0 Kudos
277

Hi Suresh,

The Code is alredy there on the Top.

heres its once again.

<b>START-OF-SELECTION.

GET pernr.

rp_provide_from_last p0000 space sy-datum sy-datum.

  • check if they are active today

IF p0000-stat2 = '3'.

  • if yes

lv_begin = '18000101'.

lv_process = 'X'.

ELSE.

CALL FUNCTION 'RP_HIRE_FIRE'

EXPORTING

beg = '18000101'

end = '99991231'

IMPORTING

fire_date = lv_termdate

hire_date = lv_hiredate

TABLES

pp0000 = p0000

pphifi = phifi

pp0001 = p0001.

  • check the termination date

IF lv_termdate => '20050701'.

lv_begin = '20050701'.

lv_process = 'X'.

ENDIF.

ENDIF.

CHECK lv_process = 'X'.

rp-provide-from-frst p0000 space lv_begin '99991231'.

rp-provide-from-frst p0001 space lv_begin '99991231'.

rp-provide-from-frst p0002 space lv_begin '99991231'.

CLEAR lv_process.

END-OF-SELECTION.</b>

Thanks a lot.

A.

0 Kudos
277

Hi,

rp-provide-from-frst p0000 space lv_begin '99991231'

will move the first valid record in 0000 between the above date range to the header of p0000. The itab p0000 will still have all the valid records.

I don't know if I am missing your point.

Regards,

Suresh Datti

0 Kudos
277

OK Suresh,

I agree with your point now.. What about provide from first ??

rp-provide-from-frst p0000 space lv_begin '99991231'.

when i execute the HR_READ_INFOTYPE FM i get results too. How different would be using a macro and a FM. Is it just the performance or would be the Data as well. I appriciate your reply.

I am getting confused , whether to use the macro or to call the FM.. any Advise ??

A

0 Kudos
277

Hi Aman,

As I mentioned in my previous reply, when you do rp-provide-from-last space begda endda , You will fetch all the recrods, but the latest record will be in the header record.

Loop at the following example:

TABLES: pernr.

NODES : person, peras.

INFOTYPES: 0006.

DATA: BEGIN OF gt_0006 OCCURS 0,

pernr LIKE pernr-pernr,

stras LIKE p0006-stras,

ort01 LIKE p0006-ort01,

ort02 LIKE p0006-ort02,

pstlz LIKE p0006-pstlz,

END OF gt_0006.

START-OF-SELECTION.

GET person.

GET peras.

rp_provide_from_last p0006 space pn-begda pn-endda.

gt_0006-pernr = p0006-pernr.

gt_0006-stras = p0006-stras.

gt_0006-ort01 = p0006-ort01.

gt_0006-ort02 = p0006-ort02.

gt_0006-pstlz = p0006-pstlz.

APPEND gt_0006.

CLEAR gt_0006.

END-OF-SELECTION.

LOOP AT gt_0006.

WRITE:/ gt_0006-pernr,

gt_0006-stras,

gt_0006-ort01,

gt_0006-ort02,

gt_0006-pstlz.

ENDLOOP.

Good luck.

Venu

0 Kudos
277

I think, both will do the same thing, but, why would you want to go for a function module when you are getting the same using one single statement.

Also, we can use the function module if you are not using the logical database and still want to read the information.

Venu

0 Kudos
277

Hi,

If your report is tied to PNP use the macro else use the function call HR_READ_INFOTYPE.

Regards,

Suresh Datti

Former Member
0 Kudos
277

hi,

as i said in my previous mail that get pernr and end-of-selection acts like loop endloop.

This loop will process all the records which satisfies the selections on the selection screen with respect to the infotypes u declared in program. i think this loop is processed many times, as u mentioned rp-provide on p0000 and that statement is fetching a record.

and when it comes to the other rp-provide statements they are also fetching a record and that is why many records are comming.

so check in the infotypes u declared in the program with the selections made . u will get the count as the number of records u got on the output.

so the reason is rp-provide statement is fetching only one record but the get pernr event is triggered multiple times depending on the selections.

if you are clear with the explanation good otherwise reply to it, i will clarify the doubts again.

Thanks

Aditya