on 07-10-2007 8:19 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
Hello Preeti,
In sort criteria ,pass begda descending.so ur latest record will come first then delete the adjascent duplicate entries comparing both pernr and VC.So latest one only will come in internal table.
Reward points if its useful!!
Regards,
Manoj.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
8 | |
7 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.