• Like
Alv grid
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

Published

alv grid

alv grid

Published in Technology , Business
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
296
On SlideShare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
40
Comments
0
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. *&-------------------------------------------------------------------- -* *& Report ZJOMS_LAB01 *& *&-------------------------------------------------------------------- -* *& *& *&-------------------------------------------------------------------- -* REPORT ZJOMS_LAB01. TABLES: ZJONMU_EMP,ZJONMU_CAR,ZJONMU_UNG. *--------------------------------------------------------------------* CONSTANTS: C_TAB TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB, C_NEW_LINE TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>NEWLINE. *--------------------------------------------------------------------* CONSTANTS : RBSELECTED TYPE C LENGTH 1 VALUE 'X'. DATA: P_TXT TYPE C LENGTH 100. DATA: P_SELECCION TYPE C LENGTH 50. TYPES: BEGIN OF TY_ZJONMU_EMP, CODEMP TYPE ZJONMU_EMP-CODEMP, NOMEMP TYPE ZJONMU_EMP-NOMEMP, FECING TYPE ZJONMU_EMP-FECING, CODUNG TYPE ZJONMU_EMP-CODUNG, CODCAR TYPE ZJONMU_EMP-CODCAR, STSEMP TYPE ZJONMU_EMP-STSEMP, END OF TY_ZJONMU_EMP. DATA: T_ZJONMU_EMP TYPE STANDARD TABLE OF TY_ZJONMU_EMP, GS_LAYOUT TYPE LVC_S_LAYO, GT_FIELDCAT TYPE LVC_T_FCAT, GT_SORT TYPE LVC_T_SORT, GS_VARIANT TYPE DISVARIANT. *======================================================= * Declaracion de Variables DATA: MYCONTAINER TYPE SCRFNAME VALUE 'ALV_PERSONALIZADO', CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER, GRIDI TYPE REF TO CL_GUI_ALV_GRID, X_SAVE. DATA: LINEA1(50) TYPE C, LINEA2(20) TYPE C, LINEA3(20) TYPE C, FECHA(20) TYPE C, HORA(20) TYPE C, PAGINA(20) TYPE C,
  • 2. LISTAEMP(20) TYPE C, TIPOORDEN(50) TYPE C, STATUS(1) TYPE C. SELECTION-SCREEN BEGIN OF BLOCK BLOQUE0 WITH FRAME TITLE TEXT-000. ********************************************************************** SELECTION-SCREEN BEGIN OF BLOCK BLOQUE1 WITH FRAME TITLE TEXT-001. SELECT-OPTIONS: D_CODEMP FOR ZJONMU_EMP-CODEMP, D_FECING FOR ZJONMU_EMP-FECING, D_CODUNG FOR ZJONMU_UNG-CODUNG. SELECTION-SCREEN END OF BLOCK BLOQUE1. SELECTION-SCREEN BEGIN OF BLOCK BLOQUE2 WITH FRAME TITLE TEXT- 002. "status PARAMETERS: C_ACT RADIOBUTTON GROUP RAD1 DEFAULT 'X' USER-COMMAND ENT, C_INAC RADIOBUTTON GROUP RAD1. SELECTION-SCREEN END OF BLOCK BLOQUE2. SELECTION-SCREEN BEGIN OF BLOCK BLOQUE3 WITH FRAME TITLE TEXT-003. PARAMETERS: C_CODEMP RADIOBUTTON GROUP RAD2 DEFAULT 'X' USER- COMMAND ENT, C_NOMEMP RADIOBUTTON GROUP RAD2, C_CAREMP RADIOBUTTON GROUP RAD2, C_UNEEMP RADIOBUTTON GROUP RAD2. SELECTION-SCREEN END OF BLOCK BLOQUE3. SELECTION-SCREEN END OF BLOCK BLOQUE0. START-OF-SELECTION. PERFORM CABECERA. PERFORM CARGAR_DATOS. PERFORM FILL_LAYOUT. PERFORM FILL_CATALOG. PERFORM LLAMAR_ALV. CALL SCREEN 100. FORM CABECERA . LISTAEMP = 'Lista de empleados'. TIPOORDEN = 'Tipo de Ordenamiento: '. CONCATENATE 'SAP R/3 [' SY-SAPRL '] [' SY-SYSID ']/[' SY- MANDT ']' INTO LINEA1. CONCATENATE SY-REPID '' INTO LINEA2. CONCATENATE SY-UNAME '' INTO LINEA3. CONCATENATE 'Fecha: ' SY-DATUM+6(2) '/' SY-DATUM+4(2) '/' SY- DATUM(4) INTO FECHA SEPARATED BY ' '. CONCATENATE 'Hora: ' SY-UZEIT INTO HORA SEPARATED BY ' '. * CONCATENATE 'Pag ' SY-PAGNO INTO pagina. IF C_CODEMP = 'X'.
  • 3. CONCATENATE TIPOORDEN 'Codigo de empleado' INTO TIPOORDEN SEPARATE D BY ' '. ELSE. IF C_NOMEMP = 'X'. CONCATENATE TIPOORDEN 'Nombre de Empleado' INTO TIPOORDEN SEPARA TED BY ' '. ELSE. IF C_CAREMP = 'X'. CONCATENATE TIPOORDEN 'Cargo' INTO TIPOORDEN SEPARATED BY ' '. ELSE. IF C_UNEEMP = 'X'. CONCATENATE TIPOORDEN 'Codigo Unidad de Negocio' INTO TIPOOR DEN SEPARATED BY ' '. ENDIF. ENDIF. ENDIF. ENDIF. IF C_ACT = 'X'. STATUS = 'A'. ELSE. IF C_INAC = 'X'. STATUS = 'I'. ENDIF. ENDIF. ENDFORM. " CABECERA *&-------------------------------------------------------------------- -* *& Form CARGAR_DATOS *&-------------------------------------------------------------------- -* * text *--------------------------------------------------------------------- -* FORM CARGAR_DATOS . SELECT CODEMP NOMEMP FECING CODUNG CODCAR STSEMP INTO TABLE T_ZJONMU _EMP FROM ZJONMU_EMP WHERE CODEMP IN D_CODEMP AND STSEMP = STATUS AND FECING IN D_FECING AND CODUNG IN D_CODUNG. ENDFORM. " CARGAR_DATOS *&-------------------------------------------------------------------- -* *& Form FILL_LAYOUT *&-------------------------------------------------------------------- -* * text *--------------------------------------------------------------------- -* FORM FILL_LAYOUT .
  • 4. GS_LAYOUT-SEL_MODE = 'A'. ENDFORM. " FILL_LAYOUT *&-------------------------------------------------------------------- -* *& Form FILL_CATALOG *&-------------------------------------------------------------------- -* * text *--------------------------------------------------------------------- -* FORM FILL_CATALOG . DATA: GS_FIELDCAT TYPE LVC_S_FCAT. CLEAR GS_FIELDCAT. GS_FIELDCAT-TABNAME = 'T_ZJONMU_EMP'. GS_FIELDCAT-FIELDNAME = 'CODEMP'. GS_FIELDCAT-REPTEXT = 'Cod.Empleado'. IF C_CODEMP = 'X'. GS_FIELDCAT-COL_POS = 1. PERFORM FILL_SORT CHANGING GT_SORT GS_FIELDCAT-FIELDNAME. ELSEIF C_NOMEMP = 'X'. GS_FIELDCAT-COL_POS = 2. ELSEIF C_CAREMP = 'X'. GS_FIELDCAT-COL_POS = 2. ELSEIF C_UNEEMP = 'X'. GS_FIELDCAT-COL_POS = 2. ENDIF. GS_FIELDCAT-OUTPUTLEN = 15. APPEND GS_FIELDCAT TO GT_FIELDCAT. CLEAR GS_FIELDCAT. GS_FIELDCAT-TABNAME = 'T_ZJONMU_EMP'. GS_FIELDCAT-FIELDNAME = 'NOMEMP'. GS_FIELDCAT-REPTEXT = 'Nombre Empleado'. IF C_CODEMP = 'X'. GS_FIELDCAT-COL_POS = 2. ELSEIF C_NOMEMP = 'X'. GS_FIELDCAT-COL_POS = 1. PERFORM FILL_SORT CHANGING GT_SORT GS_FIELDCAT-FIELDNAME. ELSEIF C_CAREMP = 'X'. GS_FIELDCAT-COL_POS = 2. ELSEIF C_UNEEMP = 'X'. GS_FIELDCAT-COL_POS = 2. ENDIF. GS_FIELDCAT-OUTPUTLEN = 15. APPEND GS_FIELDCAT TO GT_FIELDCAT. CLEAR GS_FIELDCAT. GS_FIELDCAT-TABNAME = 'T_ZJONMU_EMP'. GS_FIELDCAT-FIELDNAME = 'FECING'. GS_FIELDCAT-REPTEXT = 'Fecha Ingreso'. IF C_CODEMP = 'X'. GS_FIELDCAT-COL_POS = 3.
  • 5. ELSE. IF C_NOMEMP = 'X'. GS_FIELDCAT-COL_POS = 3. ELSE. IF C_CAREMP = 'X'. GS_FIELDCAT-COL_POS = 4. ELSE. IF C_UNEEMP = 'X'. GS_FIELDCAT-COL_POS = 4. ENDIF. ENDIF. ENDIF. ENDIF. GS_FIELDCAT-OUTPUTLEN = 15. APPEND GS_FIELDCAT TO GT_FIELDCAT. CLEAR GS_FIELDCAT. GS_FIELDCAT-TABNAME = 'T_ZJONMU_EMP'. GS_FIELDCAT-FIELDNAME = 'CODUNG'. GS_FIELDCAT-REPTEXT = 'Cod.Und.Negocio'. IF C_CODEMP = 'X'. GS_FIELDCAT-COL_POS = 2. ELSE. IF C_NOMEMP = 'X'. GS_FIELDCAT-COL_POS = 2. ELSE. IF C_CAREMP = 'X'. GS_FIELDCAT-COL_POS = 2. ELSE. IF C_UNEEMP = 'X'. GS_FIELDCAT-COL_POS = 1. PERFORM FILL_SORT CHANGING GT_SORT GS_FIELDCAT-FIELDNAME. ENDIF. ENDIF. ENDIF. ENDIF. GS_FIELDCAT-OUTPUTLEN = 15. APPEND GS_FIELDCAT TO GT_FIELDCAT. CLEAR GS_FIELDCAT. GS_FIELDCAT-TABNAME = 'T_ZJONMU_EMP'. GS_FIELDCAT-FIELDNAME = 'CODCAR'. GS_FIELDCAT-REPTEXT = 'Cod.Cargo'. IF C_CODEMP = 'X'. GS_FIELDCAT-COL_POS = 2. ELSE. IF C_NOMEMP = 'X'. GS_FIELDCAT-COL_POS = 2. ELSE. IF C_CAREMP = 'X'. GS_FIELDCAT-COL_POS = 1. PERFORM FILL_SORT CHANGING GT_SORT GS_FIELDCAT-FIELDNAME. ELSE. IF C_UNEEMP = 'X'. GS_FIELDCAT-COL_POS = 4.
  • 6. ENDIF. ENDIF. ENDIF. ENDIF. GS_FIELDCAT-OUTPUTLEN = 15. APPEND GS_FIELDCAT TO GT_FIELDCAT. CLEAR GS_FIELDCAT. GS_FIELDCAT-TABNAME = 'T_ZJONMU_EMP'. GS_FIELDCAT-FIELDNAME = 'STSEMP'. GS_FIELDCAT-REPTEXT = 'Status Empleado'. IF C_CODEMP = 'X'. GS_FIELDCAT-COL_POS = 6. ELSE. IF C_NOMEMP = 'X'. GS_FIELDCAT-COL_POS = 6. ELSE. IF C_CAREMP = 'X'. GS_FIELDCAT-COL_POS = 6. ELSE. IF C_UNEEMP = 'X'. GS_FIELDCAT-COL_POS = 6. ENDIF. ENDIF. ENDIF. ENDIF. GS_FIELDCAT-OUTPUTLEN = 15. APPEND GS_FIELDCAT TO GT_FIELDCAT. ENDFORM. " FILL_CATALOG1 FORM LLAMAR_ALV . IF CUSTOM_CONTAINER IS INITIAL. CREATE OBJECT CUSTOM_CONTAINER EXPORTING CONTAINER_NAME = MYCONTAINER EXCEPTIONS CNTL_ERROR = 1 CNTL_SYSTEM_ERROR = 2 CREATE_ERROR = 3 LIFETIME_ERROR = 4 LIFETIME_DYNPRO_DYNPRO_LINK = 5. ENDIF. CREATE OBJECT GRIDI EXPORTING I_PARENT = CUSTOM_CONTAINER. CALL METHOD GRIDI->SET_TABLE_FOR_FIRST_DISPLAY EXPORTING IS_VARIANT = GS_VARIANT I_SAVE = X_SAVE I_DEFAULT = 'X' IS_LAYOUT = GS_LAYOUT CHANGING IT_FIELDCATALOG = GT_FIELDCAT IT_SORT = GT_SORT[]
  • 7. IT_OUTTAB = T_ZJONMU_EMP[]. CALL METHOD GRIDI->SET_READY_FOR_INPUT EXPORTING I_READY_FOR_INPUT = 0. ENDFORM. " LLAMAR_ALV MODULE STATUS_0100 OUTPUT. SET PF-STATUS '100'. SET TITLEBAR '100'. ENDMODULE. "USER_COMMAND *--------------------------------------------------------------------- -* MODULE USER_COMMAND_0100 INPUT. DATA: OK_CODE TYPE SY-UCOMM. OK_CODE = SY-UCOMM. CASE OK_CODE. WHEN 'BACK' OR 'CANCEL' OR 'EXIT'. SET SCREEN 0. LEAVE SCREEN. CLEAR SY-UCOMM. ENDCASE. ENDMODULE. "USER_COMMAND_0100 INPUT *&-------------------------------------------------------------------- -* *& Form FILL_SORT *&-------------------------------------------------------------------- -* * text *--------------------------------------------------------------------- -* * <--P_GT_SORT text * <--P_GS_CAT_FIELDNAME text *--------------------------------------------------------------------- -* FORM FILL_SORT CHANGING GT_SORT TYPE LVC_T_SORT COLUMNA TYPE C. DATA GS_SORT TYPE LVC_S_SORT. GS_SORT-SPOS = '1'. GS_SORT-FIELDNAME = COLUMNA. GS_SORT-UP = 'X'. APPEND GS_SORT TO GT_SORT. CLEAR GS_SORT. ENDFORM. " FILL_SORT Screen 100 PROCESS BEFORE OUTPUT. MODULE STATUS_0100. *
  • 8. PROCESS AFTER INPUT. MODULE USER_COMMAND_0100. Status