SAP ABAP- MODULE PULL
REPORT NAME:---SAPMZ_SWRAN.
REPORT NAME:---SAPMZ_SWRAN.
INCLUDE MZ_SWRANTOP . " global Data
INCLUDE MZ_SWRANO01 . " PBO-Modules
INCLUDE MZ_SWRANI01 . " PAI-Modules
INCLUDE MZ_SWRANF01
INCLUDE MZ_SWRANO01 . " PBO-Modules
INCLUDE MZ_SWRANI01 . " PAI-Modules
INCLUDE MZ_SWRANF01
TOP.
TYPE-POOLS:SLIS.
TABLES : MARA .
DATA :MLOW(18),MHIGH(18).
DATA :MLOW1(18),MHIGH1(18).
DATA: BEGIN OF T_MARA OCCURS 1,
MATNR TYPE MARA-MATNR,
ERSDA TYPE MARA-ERSDA,
ERNAM TYPE MARA-ERNAM,
PSTAT TYPE MARA-PSTAT,
MBRSH TYPE MARA-MBRSH,
END OF T_MARA.
DATA : BEGIN OF RANGE OCCURS 0 ,
SIGN(1),
OPTION(2),
LOW(18),
HIGH(18),
END OF RANGE .
DATA : T_FCAT TYPE TABLE OF SLIS_FIELDCAT_ALV ,
W_FCAT TYPE SLIS_FIELDCAT_ALV ,
W_LAYO TYPE SLIS_LAYOUT_ALV .
TABLES : MARA .
DATA :MLOW(18),MHIGH(18).
DATA :MLOW1(18),MHIGH1(18).
DATA: BEGIN OF T_MARA OCCURS 1,
MATNR TYPE MARA-MATNR,
ERSDA TYPE MARA-ERSDA,
ERNAM TYPE MARA-ERNAM,
PSTAT TYPE MARA-PSTAT,
MBRSH TYPE MARA-MBRSH,
END OF T_MARA.
DATA : BEGIN OF RANGE OCCURS 0 ,
SIGN(1),
OPTION(2),
LOW(18),
HIGH(18),
END OF RANGE .
DATA : T_FCAT TYPE TABLE OF SLIS_FIELDCAT_ALV ,
W_FCAT TYPE SLIS_FIELDCAT_ALV ,
W_LAYO TYPE SLIS_LAYOUT_ALV .
PBO MODULE
MODULE STATUS_9001 OUTPUT.
SET PF-STATUS 'ZGUI_STATUS'.
* SET TITLEBAR 'xxx'.
ENDMODULE.
SET PF-STATUS 'ZGUI_STATUS'.
* SET TITLEBAR 'xxx'.
ENDMODULE.
PAI MODULE.
*&---------------------------------------------------------------------*
*& Include MZ_SWRANI01
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9001 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9001 INPUT.
CASE SY-UCOMM.
WHEN 'EXECUTE'."FC-CODE OF ENTER BUTTON
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT' "CONVERSION ROUTINE FOR MLOW
EXPORTING
INPUT = MLOW
IMPORTING
OUTPUT = MLOW1
EXCEPTIONS
LENGTH_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.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'"CONVERSION ROUTINE FOR MHIGH
EXPORTING
INPUT = MHIGH
IMPORTING
OUTPUT = MHIGH1
EXCEPTIONS
LENGTH_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.
******************************************************************
* LOGICALLY BUILD A INTERNAL TABLE (RANGE)
******************************************************************
RANGE-SIGN = 'I'. " I OR E
RANGE-OPTION = 'BT'.
RANGE-LOW = MLOW1 .
RANGE-HIGH = MHIGH1 .
APPEND RANGE ."APPEND DATA IN INTERNAL TABLE
******************************************************************
PERFORM FETCH_DATA .
PERFORM DISPLAY_DATA .
WHEN 'BACK' OR 'EXIT' or 'CANCEL'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_9001 INPUT
*&---------------------------------------------------------------------*
*& Form FETCH_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FETCH_DATA .
SELECT MATNR
ERNAM
ERSDA
PSTAT
MBRSH
FROM MARA
INTO CORRESPONDING FIELDS OF TABLE T_MARA
WHERE MATNR IN RANGE .
ENDFORM. " FETCH_DATA
*&---------------------------------------------------------------------*
*& Form DISPLAY_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DISPLAY_DATA .
LEAVE TO LIST-PROCESSING .
W_FCAT-TABNAME = 'MARA'.
W_FCAT-FIELDNAME = 'MATNR'.
W_FCAT-SELTEXT_M = 'Material No'.
APPEND w_fcat to t_Fcat .
W_FCAT-TABNAME = 'MARA'.
W_FCAT-FIELDNAME = 'ERSDA'.
W_FCAT-SELTEXT_M = 'Created On'.
APPEND w_fcat to t_Fcat .
W_FCAT-TABNAME = 'MARA'.
W_FCAT-FIELDNAME = 'ERNAM'.
W_FCAT-SELTEXT_M = 'Name of Person'.
APPEND w_fcat to t_Fcat .
W_FCAT-TABNAME = 'MARA'.
W_FCAT-FIELDNAME = 'PSTAT'.
W_FCAT-SELTEXT_M = 'Maintenance status'.
APPEND w_fcat to t_Fcat .
W_FCAT-TABNAME = 'MARA'.
W_FCAT-FIELDNAME = 'MBRSH'.
W_FCAT-SELTEXT_M = 'Industry sector'.
APPEND w_fcat to T_FCAT.
W_LAYO-ZEBRA = 'X'.
W_LAYO-COLWIDTH_OPTIMIZE = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
* I_CALLBACK_PROGRAM = ' '
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME = 'MARA'
* I_BACKGROUND_ID = ' '
I_GRID_TITLE ='MATERIAL REPORT'
* I_GRID_SETTINGS =
IS_LAYOUT = W_LAYO
IT_FIELDCAT = T_FCAT
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* I_HTML_HEIGHT_TOP = 0
* I_HTML_HEIGHT_END = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* IR_SALV_FULLSCREEN_ADAPTER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = T_MARA[]
* 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.
ENDFORM. " DISPLAY_DATA
*& Include MZ_SWRANI01
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9001 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9001 INPUT.
CASE SY-UCOMM.
WHEN 'EXECUTE'."FC-CODE OF ENTER BUTTON
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT' "CONVERSION ROUTINE FOR MLOW
EXPORTING
INPUT = MLOW
IMPORTING
OUTPUT = MLOW1
EXCEPTIONS
LENGTH_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.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'"CONVERSION ROUTINE FOR MHIGH
EXPORTING
INPUT = MHIGH
IMPORTING
OUTPUT = MHIGH1
EXCEPTIONS
LENGTH_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.
******************************************************************
* LOGICALLY BUILD A INTERNAL TABLE (RANGE)
******************************************************************
RANGE-SIGN = 'I'. " I OR E
RANGE-OPTION = 'BT'.
RANGE-LOW = MLOW1 .
RANGE-HIGH = MHIGH1 .
APPEND RANGE ."APPEND DATA IN INTERNAL TABLE
******************************************************************
PERFORM FETCH_DATA .
PERFORM DISPLAY_DATA .
WHEN 'BACK' OR 'EXIT' or 'CANCEL'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_9001 INPUT
*&---------------------------------------------------------------------*
*& Form FETCH_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FETCH_DATA .
SELECT MATNR
ERNAM
ERSDA
PSTAT
MBRSH
FROM MARA
INTO CORRESPONDING FIELDS OF TABLE T_MARA
WHERE MATNR IN RANGE .
ENDFORM. " FETCH_DATA
*&---------------------------------------------------------------------*
*& Form DISPLAY_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DISPLAY_DATA .
LEAVE TO LIST-PROCESSING .
W_FCAT-TABNAME = 'MARA'.
W_FCAT-FIELDNAME = 'MATNR'.
W_FCAT-SELTEXT_M = 'Material No'.
APPEND w_fcat to t_Fcat .
W_FCAT-TABNAME = 'MARA'.
W_FCAT-FIELDNAME = 'ERSDA'.
W_FCAT-SELTEXT_M = 'Created On'.
APPEND w_fcat to t_Fcat .
W_FCAT-TABNAME = 'MARA'.
W_FCAT-FIELDNAME = 'ERNAM'.
W_FCAT-SELTEXT_M = 'Name of Person'.
APPEND w_fcat to t_Fcat .
W_FCAT-TABNAME = 'MARA'.
W_FCAT-FIELDNAME = 'PSTAT'.
W_FCAT-SELTEXT_M = 'Maintenance status'.
APPEND w_fcat to t_Fcat .
W_FCAT-TABNAME = 'MARA'.
W_FCAT-FIELDNAME = 'MBRSH'.
W_FCAT-SELTEXT_M = 'Industry sector'.
APPEND w_fcat to T_FCAT.
W_LAYO-ZEBRA = 'X'.
W_LAYO-COLWIDTH_OPTIMIZE = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
* I_CALLBACK_PROGRAM = ' '
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME = 'MARA'
* I_BACKGROUND_ID = ' '
I_GRID_TITLE ='MATERIAL REPORT'
* I_GRID_SETTINGS =
IS_LAYOUT = W_LAYO
IT_FIELDCAT = T_FCAT
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* I_HTML_HEIGHT_TOP = 0
* I_HTML_HEIGHT_END = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* IR_SALV_FULLSCREEN_ADAPTER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = T_MARA[]
* 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.
ENDFORM. " DISPLAY_DATA
No comments:
Post a Comment