on 07-10-2007 8:22 AM
Hi All,
I have to pick the value of massg from infotype 0302 where massn = 'VC' for multiple perners to print in my smartform . In table pa0302, theer exist more than 1 record for each employee where massn = 'VC'. I want the latest recored of VC for each perner. Please see my code and result after debugging:-
Please advice how can i pick the latest recored for each employee for massn = VC
DATA: BEGIN OF ITAB_EMP_DEATILS6 OCCURS 0,
MASSG LIKE PA0302-MASSG,
MASSN LIKE PA0302-MASSN,
BEGDA LIKE PA0000-BEGDA,
PERNR LIKE PA0001-PERNR,
MGTXT LIKE T530T-MGTXT,
END OF ITAB_EMP_DEATILS6.
SELECT APERNR AMASSN AMASSG ABEGDA B~MGTXT INTO CORRESPONDING FIELDS OF TABLE ITAB_EMP_DEATILS6 FROM PA0302 AS A INNER JOIN T530T AS B
ON AMASSG = BMASSG WHERE APERNR IN P_PERNR AND BMASSN = 'VC' AND BSPRSL = SY-LANGU. "AND AENDDA = '99991231' .
SORT ITAB_EMP_DEATILS6 BY PERNR.
DELETE ADJACENT DUPLICATES FROM ITAB_EMP_DEATILS6.
LOOP AT ITAB_EMP_DEATILS.
READ TABLE ITAB_EMP_DEATILS6 WITH KEY PERNR = ITAB_EMP_DEATILS-PERNR. " ....Purpose of seeking vigilance clearance
IF SY-SUBRC = '0'.
ITAB_EMP_DEATILS-PURPOSE = ITAB_EMP_DEATILS6-MGTXT.
ENDIF.
MODIFY ITAB_EMP_DEATILS TRANSPORTING PURPOSE.
ENDLOOP.
Result after debugging :-
Sno. massg massn begda perners mgtxt
1 PR VC 20070617 01002360 Promotion
2 PR VC 20070630 01002360 Promotion
3 NC VC 20070712 01002503 NoC for Passport
4 PR VC 20070719 01002503 Promotion
Thanks & Regrads,
Preeti
To fetch the lates record in HR use -
1. The one existing in todays date is the latest records for an employee.
sselect * from pa0302 where pernr = v_pernr
and begda <= sy-datum
and endda >= sy-dayum
and massn = 'VC'.
2. But if this acion does not exist in todays date, then also you are looking to fetch this record, then -
select * from PA0302 into table t_pa0302 where massn = 'VC.
if sy-subrc = 0.
sort t_pa0302 DESCENDING by begda.
Read table t_pa0302 with index 1.
endif.
Regards,
Amit
reward all helpful replies.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI ,
first of all pick all the records matches where massn = 'VC' . Latest u mean to say on the basis of date . So sort the internal table on the basis of date in ascending order and use read table itag index 1 . u will the latest record .
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
if it has date and time field use them. try to sort internal table with date and time to use READ( INDEX 1) pick the latest record.
Regards,
SaiRam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.