Rp_provide_from_last p9003
Hi
I am working on a HR report using the custom infotype, I am using following code
rp_provide_from_last p9003 space pn-begda pn-endda.
IF pnp-sw-found = 1 .
MOVE-CORRESPONDING p9003 TO i_pa9003.
APPEND i_pa9003.
ENDIF.
pernr endda begda
01 31.12.2009 19.05.1990
01 31.12.9999 01.01.2010
after executing I am not getting the second record, only getting the first record.
Please let me know what is problem, in my uderstanding rp_provide_from_last will give the last record.
Regards
Sebastian John
Edited by: Sebastian John on Mar 21, 2010 1:04 PM
Edited by: Sebastian John on Mar 21, 2010 1:06 PM
Hi John,
<li> You are correct. When you use rp_provide_from_last, it gives you the last record in the given period pn-begda and pn-endda.
<li>Instead of that macro, you can use PROVIDE-ENDPROVIDE. Its like LOOP-ENDDLOOP. for more info.. Use F1 help on PROVIDE.
PROVIDE * FROM p9003 BETWEEN pn-begda AND pn-endda.
MOVE-CORRESPONDING p9003 TO i_pa9003.
APPEND i_pa9003.
ENDPROVIDE
Thanks
Venkat.O
Similar Messages
-
Smartform of a particular employee with dynamic actions
Hi All,
I am making an HR smartform - pulling data from infotypes - so I am using logical database pnp. Now Everytime I enter the personal number in the PNP screen, it gives me form with correct data of respective employee.
I want to club this smart form's driver program to a dynamic action, so the personal number would ne chosen dynamically. For that I believe we have to choose HR report category from program attributes of driver program as '0000003'.
If I do that and hardcode the employee number it do not takes it but it starts printing smartforms of all the employees - even if I keep the report category as 0000001, it asks for a personal number at runtime,n do not takes hardcoded value - The getpernr statment is not fetching up the data for that particular employee but it pulls data for all employees.
Please suggest how could I use the hard coded value of pernr to get the resp3ective data in the smartform. Do I have to create another report category - a new one? if so how?
If u have any sample code? Please share it.
Thanks
RibhuHi Suresh, I was just testing it by hardcoding, wheather it takes the pernr from places other than input box of the report category. Right.
Below is the code. If you want to know anything else, Please let me know.
Thanks
Ribhu
Here is the code:
REPORT ZHRtest.
tables : q0008, pa0001, pa0000, pa0002, pa0014, pa0021, pa0022, pa0008, pa0006, pernr, t500p,t530, t512t, t510, t526, t529t, t528t,
M_PLOMC, T7INA3, T7INB5, T7INB7, T518B.
infotypes : 0000, 0001, 0002, 0014, 0021, 0022, 0008, 0006, 0105, 9003.
data : E_DATE TYPE SY-DATUM, " Date
E_ORGUNIT TYPE ORGEH, " Organizational Unit
E_PERSNO TYPE P_PERNR, " Personnel Number
DATA : WS_UCOMM LIKE SY-UCOMM.
data: begin of pers_tab occurs 0,
E_SLAB1MIN TYPE PIN_MINBS,
E_SLAB1MAX TYPE PIN_MAXBS,
E_SLAB1INCR TYPE PIN_AMINC,
E_SLAB2MIN TYPE PIN_MINBS,
E_SLAB2MAX TYPE PIN_MAXBS,
E_SLAB2INCR TYPE PIN_AMINC,
end of pers_tab.
DATA: BEGIN OF WAGETYPES,
E_LGA LIKE P0008-LGA01,
E_BET LIKE P0008-BET01,
E_pernr like pernr-pernr,
END OF WAGETYPES.
data : E_lga like pa0008-lga01,
E_bet like pa0008-bet01.
data: count type i.
data : v_year(4) type c,
v_mon(2) type c,
v_date like sy-datum,
v_date1 like sy-datum.
data : v_formname type tdsfname ,
v_fmname type rs38l_fnam.
data: i_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
i_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE.
DATA : WAGETYPES1 LIKE BAPIP0008P OCCURS 0 WITH HEADER LINE.
data: begin of temp_tab occurs 0 ,
t_minbs type PIN_MINBS,
t_maxbs type PIN_MAXBS,
t_aminc type PIN_AMINC,
end of temp_tab.
data: hr_pernr like p0000-pernr, " persno of hr emp
plans_hr like p0001-plans . " position text.
constants : c_x type c value 'X', " Sign
c_pernr(8) type n value '00000000', " Pernr
c_val1(2) type c value '31', " Date Type
c_val2(2) type c value '12', " Date Type
c_val like p0041-dar01 value '01', " Date Type
c_1 like pernr-persg value '1', " Emp Group
c_type like hrp1001-otype value ' ', " Object Type
c_date1 like sy-datum value '18000101', " Date
c_date2 like sy-datum value '99991231', " Date
r_all value 'X'.
selection-screen begin of block b2 with frame title text-001.
selection-screen begin of line.
parameter pdf radiobutton group smf.
selection-screen comment 5(20) text-002.
parameter prn radiobutton group smf.
selection-screen comment 40(20) text-003.
selection-screen end of line.
selection-screen skip 3.
selection-screen begin of line.
selection-screen comment 3(30) text-007.
selection-screen end of line.
selection-screen begin of line.
selection-screen comment 5(30) text-004.
parameter p1 radiobutton group pg.
selection-screen end of line.
selection-screen begin of line.
selection-screen comment 5(30) text-005.
parameter p2 radiobutton group pg.
selection-screen end of line.
selection-screen begin of line.
selection-screen comment 5(30) text-006.
parameter p3 radiobutton group pg.
selection-screen end of line.
Selection-screen end of block b2.
ws_ucomm = sy-ucomm.
*CLEAR PERNR.
*CLEAR PNPPERNR.
At selection-screen.
perform validate_screen.
start-of-selection.
perform get_period.
PERNR-PERNR = 27.<b> <<<<< ----- this is where i tried to hard code</b>
PNPPERNR-LOW = 27.
get pernr .
LOOP AT PERNR.
*IF PNPPERNR-LOW NE PERNR-PERNR.
*CLEAR PERNR.
*ELSE. EXIT.
*ENDIF.
*ENDLOOP.
**PNPPERNR-HIGH = ''.
E_PERSNO = PNPPERNR-LOW.
rp_provide_from_last p0000 space pnpbegda pnpendda.
rp_provide_from_last p0002 space pnpbegda pnpendda .
rp_provide_from_last p0021 space pnpbegda pnpendda.
rp_provide_from_last p0022 space pnpbegda pnpendda.
rp_provide_from_last p9003 space pnpbegda pnpendda.
describe table p0008 lines count.
describe table p0001 lines count.
PERFORM FORM_SELECTION changing P1 P2 P3."<----
To get the fathers name.
select FAVOR FANAM from pa0021 into corresponding fields of p0021 where pernr = E_PERSNO and FAMSA = '11'.
if sy-subrc = 0.
E_FIRSTNAME = P0021-FAVOR.
E_LASTNAME = P0021-FANAM.
endif.
endselect.
FORM validate_screen .
CLEAR PERNR. <b><<<<< ----- this is where i tried to hard code</b>
PERNR-PERNR = '00000027'.
PNPPERNR = '00000027'.
**PNPPERNR-HIGH = ''.
E_PERSNO = pnppernr-low.
p9003-pernr = 27.
*E_PERSNO = p9003-pernr.
pnppernr-low = E_PERSNO.
clear sy-index.
loop at pnppernr.
endloop.
if sy-index GT 1.
message 'Enter only one personal number' type 'E'.
endif.
if pnppernr-low is initial.
PNPPERNR-LOW = '27'.
message 'enter a personal number' type 'E'.
endif.
ENDFORM. " validate_screen -
Rp_provide_from_last dynamic table
Hi,
I have a report which uses logical database PNPCE to fetch employee data and macros like rp_provide_from_last to read infotypes.
INFOTYPES: 0001 name gtab1,
002 name gtab2.
rp_provide_from_last gtab1 space pn-begda pn-endda
rp_provide_from_last gtab2 space pn-begda pn-endda.
I want to use a dynamic fieldname instead of gtab1 / gtab2. Basically i want to use this above macro statement to check if the infotype exists for a employee. So if there are 50 infotypes to be checked, i donot want to write this macro 50 times with 50 tables, is there a way to use a dynamic table name in the macro statement ?
Thanks
SubhaYour requirement can be met by modelling the program based on the below source code. This program will list all infotypes that have been maintained for a PERNR. This proram excludes certain infotypes like PD infotypes. The source code can be changed to include all desired infotypes.
*& Report ZTEST_CHECK_INFY
REPORT ZTEST_CHECK_INFY.
tables: t777d.
DATA SUBRC LIKE SY-SUBRC.
DATA PAR1 LIKE SY-MSGV1.
DATA: BEGIN OF SELTAB OCCURS 5.
INCLUDE STRUCTURE PRELP AS prelp. "UC
DATA: OPERA(1).
DATA: END OF SELTAB.
data: it_777d like t777d occurs 0.
data: wa_777d type t777d.
data: ls_index(4) type n.
select-options: so_infty for t777d-infty.
select-options: so_inft1 for t777d-infty no intervals.
Initialization.
so_infty-sign = 'I'.
so_infty-option = 'BT'.
so_infty-low = '0000'.
so_infty-high = '9999'.
append so_infty.
select * from t777d into corresponding fields of table it_777d where infty in so_infty.
loop at it_777d into wa_777d.
so_inft1-sign = 'I'.
so_inft1-option = 'EQ'.
so_inft1-low = wa_777d-infty.
append so_inft1.
endloop.
start-of-selection.
CALL FUNCTION 'HR_INITIALIZE_BUFFER'
EXPORTING
TCLAS = 'A'
PERNR = '40101017'
EXCEPTIONS
OTHERS = 1.
Loop at so_inft1 where not low between '1000' and '8999'.
REFRESH SELTAB.
CLEAR SELTAB.
CALL FUNCTION 'HR_READ_INFOTYPE'
EXPORTING
TCLAS = 'A'
PERNR = '40101017'
INFTY = so_INFT1-low
BEGDA = '19000101'
ENDDA = '99991231'
IMPORTING
SUBRC = SUBRC
TABLES
INFTY_TAB = SELTAB
EXCEPTIONS
INFTY_NOT_FOUND = 1
OTHERS = 2.
if subrc eq 0.
write:/ so_inft1-low, 'has been maintained for employee: ', '40101017'.
endif.
endloop. -
What is rp_provide_from_last
Hi all,
Can any one please explain me what his line would do?
rp_provide_from_last p0001 space pn-begda pn-endda.
I know p0001[] is itab and p0001 its wa but I cantunderstand what it does.?
Thanks in advance.in your example:
rp_provide_from_last p0001 space pn-begda pn-endda.
rp_provide_from_last is a macro which will get you latest record from internal table p0001, it will place the fetched record in the header of P0001.
space is placeholder for subtype, there is no subtype in infotype 0001 so thats why we put 'space' here.
pn-begda and pn-endda are the date ranges in which the latest record will be fetched.
P0001 will be populated with all records of current pernr. so basically we are looking for latest record in the dates that user provides on the selection screen.
Hope it helps.
Thanks. -
Proper use of rp_provide_from_last
Hello Experts,
I've used the macro rp_provide_from_last p0000 space pn-begda pn-endda
pn-begda = 05.07.2010
pn-endda = 05.07.2010
I can't retrieve the last record with
p0000-begda = 07.07.2010
p0000-endda = 31.12.9999
Instead I keep retrieving the second to the last record with
p0000-begda = 01.09.2009
p0000-endda = 06.07.2010
What is the reason why I keep retrieving the second to the last record? Hope you can answer my query.
Thanks in advancegive
pn-begda = 01.01.1800
pn-endda = 31.12.9999
With this specification you will always retrieve the latest record.
In short the macro will give you the last record in the given dates i.e. last record between pn-begda and pn-endda.
cheers
AJ
Edited by: Ajay Hosur on Jul 16, 2010 7:02 AM -
Use of RP_PROVIDE_FROM_LAST
Hi experts ,
I need to fatch the record base on PERNR in RFC . as well i need fatch data from othere info type . but my requirement is i need last record .
there is some thread to use RP_PROVIDE_FROM_LAST , but i am not confident to how can use this .
Please if any body have sample program please send me . so i can refeer the same .
Regards
Ajay PandeyGET PERNR.
RP_PROVIDE_FROM_LAST P0002 SPACE PN-BEGDA PN-ENDDA.
LOOP AT P0002.
MOVE: P0002-VORNA TO GW_0002-VORNA,
P0002-NACHN TO GW_0002-NACHN.
MODIFY GT_0002 FROM GW_0002
TRANSPORTING BEGDA WHERE PERNR = P0002-PERNR.
ENDLOOP.
I used this code but i not know how i will make this with my import parameters . and i am getting two records -
Difference between RP_PROVIDE_FROM_LAST and RP-PROVIDE-FROM-LAST
Can anyone tell me the difference between RP_PROVIDE_FROM_LAST and RP-PROVIDE-FROM-LAST? Both the macros are same difference is with underscore(_) and hiphen(-). Both are working fine for the functionality without any difference. Then why there are two macros for a single functionality?
Just providing the links are considered as link farming ( which are against the rules of the forums ), the links would be removed for the following reasons:
1) If a link is provided( not many ) , then you must point out the explanation in it
2) If the links were easily searchable by the OP
3) If the links just direct you to sap documentation
4) If the reply consists only bunch of link references.
I think the 3rd & 4th point made your post to be deleted.
There are no links which states the differences between these two Macro's. Mod's are doing their right job, please join them and make this forum clean
Kesav -
Regarding rp_provide_from_last
hi experts,
PERNR INFTY SUBTY OBJPS SPRPS ENDDA BEGDA SEQNR PUNCHTIME EMPLOYEECARDNO
00000001|9777 |P20 | | |20080804|20080804|000 |130000 |12345678
00000001|9777 |P20 | | |20080804|20080804|001 |190000 |12345678
here the data in my internal table is in this format i need to pick the last row
for this i use " rp_provide_from_frst P9777 'P20' s_date s_date."but this
macro is picking the first row not the last row which i want..
plz help me to sort out this problem,i want to pick up the last punch out i.e punchtime-190000
i.e P20 for the employees not punchtime-1300000.Have a look at this link. This will describe almost every macro in HR with examples.
http://help.sap.com/saphelp_45b/helpdata/en/60/d8bc0a576311d189270000e8322f96/frameset.htm
The one which is of interest to you is
[RP_PROVIDE_FROM_FRST|http://help.sap.com/saphelp_45b/helpdata/en/60/d8bc0a576311d189270000e8322f96/content.htm]
[RP_PROVIDE_FROM_LAST|http://help.sap.com/saphelp_45b/helpdata/en/60/d8bc17576311d189270000e8322f96/content.htm]
Amandeep -
Macro rp_provide_from_last is not working for ...
Hi all,
MAcro rp_provide_from_last in include DBPNPMAC is no working for the records
PERNR ENDDA BEGDA BSSAL
00033987 12/30/2004 01/01/2004 60,000
00033987 12/31/2004 01/01/2004 61,000
00033987 12/31/2005 01/01/2005 64,000
00033987 12/31/2005 01/01/2005 67,000
Am using .
rp_provide_from_last p9380 space pn-begda pn-endda .
PN-BEGDA 01/01/2004 PN-ENDDA 12/16/2004
I have to get bssal as 61,000 but am getting 60,000
DEFINE rp_provide_from_last.
$PNNNN$ = &1.
$SUBTY$ = &2.
$BEGDA$ = &3.
$ENDDA$ = &4.
pnp-sw-found = '0'.
clear pnp-sy-tabix.
loop at &1.
if &2 <> space.
check &1-subty = &2.
endif.
if &1-begda <= &4 and &1-endda >= &4.
pnp-sw-found = '1'.
exit.
endif.
if &1-begda <= &4 and &1-endda >= &3.
pnp-sy-tabix = sy-tabix.
endif.
endloop.
if pnp-sw-found = '0'.
if pnp-sy-tabix <> 0.
pnp-sw-found = '1'.
read table &1 index pnp-sy-tabix.
else.
clear &1.
endif.
endif.
END-OF-DEFINITION.
cheers
senthil
Message was edited by: senthil balaYou need to sort P9380 descending on ENDDA before doing RP-PROVIDE-FROM-LAST.
SORT P9380 by ENDDA DESCENDING. -
RP_PROVIDE_FROM_FRST & RP_PROVIDE_FROM_LAST
Dear friends
Coul any1 of u tel me th exact diff bet th macros RP_PROVIDE_FROM_FRST & RP_PROVIDE_FROM_LAST which r used for HR application.
regards
sakthiHi Sakthi vel,
Check the program.
REPORT ztest1.
TABLES: pernr.
INFOTYPES: 0001.
GET pernr.
rp_provide_from_frst p0001 space pn-begda pn-endda.
IF pnp-sw-found EQ '1'.
WRITE: / pernr-pernr, p0001-stell, pn-begda, pn-endda.
ELSE.
REJECT.
ENDIF.
"After GET PERNR event p0001 internal table is filled up with
"data for one employee. If you have multiple records in the
"internal table, If use rp_provide_from_frst macro along with
"parameters dates , It gets the first record from the body of
"the internal table and puts on the header of the internal table
"in the given period pn-begda and pn-endda. It does not get
"from database table.
REPORT ztest1.
TABLES: pernr.
INFOTYPES: 0001.
GET pernr.
rp_provide_from_last p0001 space pn-begda pn-endda.
IF pnp-sw-found EQ '1'.
WRITE: / pernr-pernr, p0001-stell, pn-begda, pn-endda.
ELSE.
REJECT.
ENDIF.
"After GET PERNR event p0001 internal table is filled up with
"data for one employee. If you have multiple records in the
"internal table, If use rp_provide_from_last macro along with
"parameters dates , It gets the last record from the body of
"the internal table and puts on the header of the internal table
"in the given period pn-begda and pn-endda. It does not get
"from database table.
I hope that it helps u .
Regards,
Venkat.O -
Rp_provide_from_last
hi friends,
What is the proper use of RP_PROIVDE_FROM_LAST.
thanks,
SKHi
The RP_PROVIDE_FROM_LAST macro retrieves the last valid data record in the data selection period.
The parameters for RP_PROVIDE_FROM_LAST are: infotype, subtype, start date, and end date. If you do not want to specify a particular subtype, enter SPACE.
You can process not only the last valid data record in the data selection period, but also the first valid data record using the RP_PROVIDE_FROM_FRST macro.
Regards Lokesh -
Rp_provide_from_last p2001 space pn-begda pn-endda
Hi Guru's,
I am using PNP as LDB and after ,
My requirement is to fetch the records from p2001 for a specific time period mentioned in the selection screen.
Code :
Get Perner.
rp_provide_from_last p2001 space pn-begda pn-endda.
the output of the above is giving all the data from P2001 irrespective of the dates (Pn-begda & pn-endda.)
But i want the data with in the dates (Pn-begda & pn-endda.).
Plz suggest.
Thanks.Hi,
PROVIDE * FROM P2001
BETWEEN Pnpbegda AND Pnpendda.
write: p2001-pernr,p2001-begda.
ENDPROVIDE.
use this code..........
Regards,
vamshidhar .
Edited by: vamshi naini on Apr 23, 2008 2:06 PM -
Rp_provide_from_last infotype subtype pn-begda pn-endda.
Hi All,
Is there a way to find out if a subtype exists before using this macro. If a subtype does not exist then it crashes.
rp_provide_from_last infotype subtype pn-begda pn-endda.
Thanks,
~MarkMark,
Check the View V_T591A - Subtype Characteristics.
It will have all Subtypes maintained in your sytem for infotype.
Additionally if you want to Use the Macro for an Infotype without Subtype, Pass SPACE instead of Subtype.
RP_PROVIDE_FROM_LAST P0001 SPACE PN-BEGDA PN-ENDDA.
Hope this helps.
Vinodh Balakrishnan
Edited by: Vinodh Balakrishnan on Jan 15, 2008 3:19 PM -
RP_provide_from_last selecting wrong value ???
Hi experts..
In my report i had used statement ..
RP_provide_from_last P0027 SPACE PN-BEGDA PN-ENDA...
Now on selction secreen i am giving any random pernr no. 5656 along with
begda-->01011800
enda--->31129999
Although there no such data peresent for perner 5656 in the TABLE PA0027 but the rp_provide stmt is selecting the record.
i tried with clear and refresh stmt but nothing is working.
how stmt can select records if specified pernr is not peresent .
Please help.
I will reward points.
Thanks.Hi,
Refer to my code as follows:
at selection-screen.
SELECT SINGLE * FROM MSEG WHERE
MBLNR = IMBLNR.
IF SY-SUBRC <> 0.
MESSAGE S000(ZMM) WITH 'Please select a valid Material Number'.
ENDIF.
Modify it according to your requirement.
Hope this helps.
Reward if helpful.
Regards,
Sipra -
RP_PROVIDE_FROM_LAST AND PROVIDE AND ENDPROVIDE
hi all,
When to use RP_PROVIDE_FROM_LAST and Provide and EndProvide?
which scenario we go for RP_PROVIDE_FROM_LAST and Provide?
both will do the same purpose?
RP_PROVIDE_FROM_LAST will read recent records.
Provide will read sequentially data.
other than this...difference
can anyone clear my doubt?Hi,
For PROVIDE-ENDPROVIDE :
1) You can fetch individual fields of the infotypes.
2) You can also use the JOIN and PROJECTION of infotypes. Based on the criteria, datas can be fetched from two or more infotypes.
3) It is similar to the SELECT STATEMENT of normal ABAP.
4) You can do processing within the Block of PROVIDE - ENDPROVIDE
For RP_PROVIDE_FROM_LAST:
1) You fetch only the recent record of the Infotype.
2) This is a MACRO delivered by SAP and not a statement. You can also create something similar to this.
Regards,
Anirban
Maybe you are looking for
-
BPS Retraction to R/3. (using BI 7)
Hi Gurus, We have a requirement to build retractors from BPS to R/3. Its related to PS retractors and we would like to use the fields like version, fiscal year, period, Business Process Number, WBS, Amount. I was able to get some nice blogs and docum
-
How to pass a internal table used in one method to another method in a view
hi all, Is it possible to pass a internal table from one method to another method in a view?? If so , kindly help me.
-
Problems with e-mail - cann't read the whole text of the letter, cann't answer.
-
ORA-27038: created file already exists
BANNER Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production PL/SQL Release 11.2.0.1.0 - Production CORE 11.2.0.1.0 Production TNS for IBM/AIX RISC System/6000: Version 11.2.0.1.0 - Production NLSRTL Version 11.2.0.1.0 - Produc
-
Version advantages 5.1.1
Hi I have Iphone 4 Factory Unlocked, So what is release note for version 5.1.1 tell me sipple advantages thinks on version 5.1.1