Skip to Content
0
Former Member
Jun 10, 2008 at 05:53 AM

Report

21 Views

Hi,

plz. check my code ...in that 1st select statement for LTA taken employees records are coming correct..

But in 2nd statement, all employees records come..here i want, only Not Taken LTA employees...

Code.....

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

REPORT ZHR_LTA NO STANDARD PAGE HEADING LINE-SIZE 100 .

TABLES : PA0015, "HR Master Record: Infotype 0008 (Basic Pay)

PA0001 , "HR Master Record: Infotype 0001 (Org. Assignment)

PA0002 , "HR Master Record: Infotype 0002 (Personal Data)

T001P . "Personnel Area/Subarea

TYPE-POOLS : SLIS .

DATA : BEGIN OF ITAB OCCURS 0 ,

PERNR LIKE PA0001-PERNR , "Personel no.

ENAME LIKE PA0001-ENAME , "Employee name

Z_DESIGNATION LIKE PA0001-Z_DESIGNATION , "Designation

BEGDA LIKE PA0015-BEGDA , "LTA VALID DATE

ENDDA LIKE PA0015-ENDDA , " LTA VALID DATE

BETRG LIKE PA0015-BETRG , " LTA Amount

END OF ITAB .

DATA : BEGIN OF ITAB1 OCCURS 0 ,

PERNR LIKE PA0001-PERNR , "Personel no.

ENAME LIKE PA0001-ENAME , "Employee name

Z_DESIGNATION LIKE PA0001-Z_DESIGNATION , "Designation

END OF ITAB1 .

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

DATA : W_CONTAINER TYPE SCRFNAME VALUE 'CL_GRID',

W_CPROG TYPE LVC_S_LAYO,

G_REPID LIKE SY-REPID,

W_SAVE TYPE C,

W_EXIT TYPE C,

CL_GRID TYPE REF TO CL_GUI_ALV_GRID,

CL_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,

IT_FLD_CATALOG TYPE SLIS_T_FIELDCAT_ALV,

WA_FLD_CATALOG TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE ,

LAYOUT TYPE SLIS_LAYOUT_ALV,

COL_POS LIKE SY-CUCOL ,

ALVFC TYPE SLIS_T_FIELDCAT_ALV.

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

SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001 .

SELECT-OPTIONS : PERNR FOR PA0001-PERNR .

SELECT-OPTIONS : ENDDA FOR PA0015-ENDDA . "OBLIGATORY.

SELECTION-SCREEN : END OF BLOCK B1 .

PARAMETER : TKN RADIOBUTTON GROUP A,

NTKN RADIOBUTTON GROUP A.

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

IF TKN = 'X'.

PERFORM FILL_CATALOG1 USING:

'PERNR' 'ITAB' 'Personal No.',

'ENAME' 'ITAB' 'Emp Name',

'Z_DESIGNATION' 'ITAB' 'Designation',

'BEGDA' 'ITAB' 'Valid from',

'ENDDA' 'ITAB' 'End Date',

'BETRG' 'ITAB' 'Amount'.

ELSE.

PERFORM FILL_CATALOG1 USING:

'PERNR' 'ITAB1' 'Personal No.',

'ENAME' 'ITAB1' 'Emp Name',

'Z_DESIGNATION' 'ITAB1' 'Designation'.

ENDIF.

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

IF TKN = 'X'.

SELECT M1PERNR M1ENDDA M1BEGDA M1BETRG M2ENAME M2Z_DESIGNATION INTO CORRESPONDING FIELDS OF TABLE ITAB

FROM PA0015 AS M1 INNER JOIN PA0001 AS M2 ON M1PERNR = M2PERNR

WHERE M1PERNR IN PERNR AND M1SUBTY EQ '4004' AND M2~ENDDA EQ '99991231'

AND M1BEGDA GE ENDDA-LOW AND M1ENDDA LE ENDDA-HIGH .

IF SY-SUBRC <> 0 .

MESSAGE 'DATA NOT FOUND.' TYPE 'I' .

ELSE.

SORT ITAB BY PERNR ASCENDING.

DELETE ADJACENT DUPLICATES FROM ITAB COMPARING PERNR.

ENDIF.

ELSEIF NTKN = 'X'.

SELECT M1PERNR M2ENAME M2~Z_DESIGNATION INTO CORRESPONDING FIELDS OF TABLE ITAB1

FROM PA0015 AS M1 INNER JOIN PA0001 AS M2 ON M1PERNR = M2PERNR

WHERE M1PERNR IN PERNR AND M1SUBTY NE '4004' AND M2~ENDDA EQ '99991231'

AND M1BEGDA GE ENDDA-LOW AND M1ENDDA LE ENDDA-HIGH .

SORT ITAB BY PERNR ASCENDING.

DELETE ADJACENT DUPLICATES FROM ITAB1 COMPARING PERNR.

LOOP AT ITAB.

  • SELECT DISTINCT PERNR ENAME Z_DESIGNATION INTO CORRESPONDING FIELDS OF ITAB1

  • FROM PA0001

  • WHERE PERNR IN PERNR AND ENDDA EQ '99991231' AND PERSG = '1' .

IF ITAB1-PERNR = ITAB-PERNR.

DELETE ITAB WHERE PERNR = ITAB-PERNR.

CLEAR ITAB1.

ELSE.

APPEND ITAB1.

CLEAR ITAB.

ENDIF .

  • ENDSELECT.

ENDLOOP.

ENDIF.

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

IF TKN = 'X'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = 'ZHR_LTA'

IS_LAYOUT = LAYOUT

IT_FIELDCAT = IT_FLD_CATALOG

I_DEFAULT = 'X'

I_SAVE = 'A'

TABLES

T_OUTTAB = ITAB

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

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

ELSE.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = 'ZHR_LTA'

IS_LAYOUT = LAYOUT

IT_FIELDCAT = IT_FLD_CATALOG

I_DEFAULT = 'X'

I_SAVE = 'A'

TABLES

T_OUTTAB = ITAB1

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDIF.

*ENDFORM.

FORM FILL_CATALOG1 USING P_FIELDNAME TYPE ANY

P_REF_TABLE TYPE ANY

P_SCRTEXT TYPE ANY.

CLEAR : WA_FLD_CATALOG.

WA_FLD_CATALOG-FIELDNAME = P_FIELDNAME.

WA_FLD_CATALOG-TABNAME = P_REF_TABLE.

WA_FLD_CATALOG-SELTEXT_S = P_SCRTEXT.

WA_FLD_CATALOG-SELTEXT_M = P_SCRTEXT.

WA_FLD_CATALOG-SELTEXT_L = P_SCRTEXT.

APPEND WA_FLD_CATALOG TO IT_FLD_CATALOG.

ENDFORM. " fill_catalog1

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

Plz. check it and tell me, where the statement goes wrong...

Plz. it's very URGENT.

Thanks...