Zmalv output type_v1.1

813 views

Published on

ALV Report

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
813
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
44
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Zmalv output type_v1.1

  1. 1. *&---------------------------------------------------------------------**& Report ZDEMO_ALV_NEST*&*&---------------------------------------------------------------------**&*&*&---------------------------------------------------------------------*REPORT ZDEMO_ALV_NEST.TABLES: T001T,TNAPR,VBRP,T001F.********************Data Declaration**************TYPES: BEGIN OF ST_NAST, KAPPL TYPE NAST-KAPPL, OBJKY TYPE VBELN, KSCHL TYPE NAST-KSCHL, ERDAT TYPE NAST-ERDAT, SPRAS TYPE NAST-SPRAS, END OF ST_NAST.TYPES : BEGIN OF ST_VBRK, VBELN TYPE VBRK-VBELN, VKORG TYPE VBRK-VKORG, BUKRS TYPE VBRK-BUKRS, LAND1 TYPE VBRK-LAND1, KUNAG TYPE VBRK-KUNAG, ZTERM TYPE VBRK-ZTERM, ZLSCH TYPE VBRK-ZLSCH, END OF ST_VBRK.TYPES : BEGIN OF ST_TVKOT, VKORG TYPE VKORG, VTXTK TYPE VTXTK, END OF ST_TVKOT.TYPES : BEGIN OF ST_T001T, BUKRS TYPE T001T-BUKRS, LTEXT TYPE T001T-LTEXT, END OF ST_T001T.TYPES: BEGIN OF ST_T001F, BUKRS TYPE T001T-BUKRS, PROGNAME TYPE PROGRAMM, TDSFNAME TYPE TDSFNAME, END OF ST_T001F.TYPES: BEGIN OF ST_FINAL, KAPPL TYPE NAST-KAPPL, OBJKY TYPE VBELN, KSCHL TYPE NAST-KSCHL, ERDAT TYPE NAST-ERDAT,
  2. 2. VBELN TYPE VBRK-VBELN, VKORG TYPE VBRK-VKORG, BUKRS TYPE VBRK-BUKRS, LAND1 TYPE VBRK-LAND1, ZTERM TYPE VBRK-ZTERM, ZLSCH TYPE VBRK-ZLSCH, SPRAS TYPE SPRAS, VTXTK TYPE VTXTK, KUNAG TYPE VBRK-KUNAG, LTEXT TYPE T001T-LTEXT, PROGNAME TYPE PROGNAME, TDSFNAME TYPE TDSFNAME, END OF ST_FINAL.DATA: PAYMENT_TERM TYPE VBRK-ZTERM, PAYMENT_METHOD TYPE VBRK-ZLSCH.DATA: IT_FINAL TYPE TABLE OF ST_FINAL, WA_FINAL TYPE ST_FINAL.DATA: IT_NAST TYPE TABLE OF ST_NAST, WA_NAST TYPE ST_NAST.DATA: IT_VBRK TYPE TABLE OF ST_VBRK, WA_VBRK TYPE ST_VBRK.DATA: IT_TNAPR TYPE TABLE OF TNAPR, WA_TNAPR TYPE TNAPR.DATA: IT_TVKOT TYPE TABLE OF ST_TVKOT, WA_TVKOT TYPE ST_TVKOT.DATA: IT_T001 TYPE TABLE OF ST_T001T, WA_T001 TYPE ST_T001T.DATA: IT_FIELDCAT TYPE LVC_T_FCAT, WA_FIELDCAT TYPE LVC_S_FCAT.DATA:O_DOCKING TYPE REF TO CL_GUI_DOCKING_CONTAINER, O_SPLIT TYPE REF TO CL_GUI_EASY_SPLITTER_CONTAINER, O_TOP_CONTAINER TYPE REF TO CL_GUI_CONTAINER, O_BOTTOM_CONTAINER TYPE REF TO CL_GUI_CONTAINER, O_DOCUMENT TYPE REF TO CL_DD_DOCUMENT, O_GRID TYPE REF TO CL_GUI_ALV_GRID.DATA: LV_RECORD TYPE SDYDO_TEXT_ELEMENT, LV_RECORD1 TYPE I, LV_APPL TYPE SDYDO_TEXT_ELEMENT, LV_LOW TYPE SDYDO_TEXT_ELEMENT, LV_HIGH TYPE SDYDO_TEXT_ELEMENT, LV_P_TYPE TYPE SDYDO_TEXT_ELEMENT, LV_P_METHOD TYPE SDYDO_TEXT_ELEMENT, LV_COMBINE TYPE SDYDO_TEXT_ELEMENT.
  3. 3. *----------------------------------------------------------------------** CLASS ZCL_EVENT_HANDLER DEFINITION*----------------------------------------------------------------------***----------------------------------------------------------------------*CLASS ZCL_EVENT_HANDLER DEFINITION. " To handle events of first screen oops alv PUBLIC SECTION. METHODS: HANDLE_HOTSPOT_CLICK FOR EVENT HOTSPOT_CLICK OF CL_GUI_ALV_GRID IMPORTING E_ROW_ID E_COLUMN_ID. "method to handle hotspot eventENDCLASS. "ZCL_EVENT_HANDLER DEFINITION*----------------------------------------------------------------------** CLASS ZCL_EVENT_HANDLER IMPLEMENTATION*----------------------------------------------------------------------***----------------------------------------------------------------------*CLASS ZCL_EVENT_HANDLER IMPLEMENTATION. METHOD HANDLE_HOTSPOT_CLICK. IF E_COLUMN_ID = PROGRAMM. PERFORM HANDLE_HOTSPOT_ON_CUSTOMER_NUM USING E_ROW_ID. " Subroutine to handle hotspot on customer number ENDIF. ENDMETHOD. "HANDLE_HOTSPOT_CLICKENDCLASS. "ZCL_EVENT_HANDLER IMPLEMENTATIONDATA: GV_EVENTS TYPE REF TO ZCL_EVENT_HANDLER.***************Selection Screen Logic**********************SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.SELECTION-SCREEN: BEGIN OF LINE.SELECTION-SCREEN COMMENT 1(31) TEXT-002 FOR FIELD APPL.PARAMETERS : APPL TYPE T681A-KAPPL DEFAULT V3 .SELECTION-SCREEN COMMENT 40(10) TEXT-003 FOR FIELD V2.PARAMETERS: V2 TYPE CHAR10 NO-DISPLAY .SELECTION-SCREEN: END OF LINE.SELECT-OPTIONS : OUTPUT FOR TNAPR-KSCHL.SELECT-OPTIONS : CRT_DATE FOR VBRP-ERDAT OBLIGATORY.PARAMETERS: PAY_T TYPE VBRK-ZTERM MATCHCODE OBJECT ZSEARCH_HELP_ZTERM,
  4. 4. PAY_M TYPE VBRK-ZLSCH.SELECTION-SCREEN : END OF BLOCK B1.INITIALIZATION. CRT_DATE-OPTION = GT. CRT_DATE-SIGN = I. CRT_DATE-LOW = SY-DATUM - 90. CRT_DATE-HIGH = SY-DATUM. APPEND CRT_DATE.AT SELECTION-SCREEN OUTPUT. LOOP AT SCREEN. IF SCREEN-NAME = APPL OR SCREEN-NAME = V2. SCREEN-INPUT = 0. MODIFY SCREEN. ENDIF. ENDLOOP.************************Selection Logic********************** LV_APPL = APPL. LV_LOW = CRT_DATE-LOW. LV_HIGH = CRT_DATE-HIGH. LV_P_TYPE = PAY_T. LV_P_METHOD = PAY_T. CONCATENATE FROM LV_LOW TO LV_HIGH INTO LV_COMBINE SEPARATED BY SPACE.START-OF-SELECTION. SELECT KAPPL OBJKY KSCHL ERDAT SPRAS FROM NAST INTO CORRESPONDING FIELDS OF TABLE IT_NAST WHERE KAPPL = APPL AND KSCHL IN OUTPUT AND ERDAT IN CRT_DATE. IF IT_NAST IS NOT INITIAL. SELECT VBELN VKORG BUKRS LAND1 KUNAG ZTERM ZLSCH FROM VBRK INTO CORRESPONDING FIELDS OF TABLE IT_VBRK FOR ALL ENTRIES IN IT_NAST WHERE VBELN = IT_NAST-OBJKY. SELECT VKORG VTEXT FROM TVKOT INTO CORRESPONDING FIELDS OF TABLE IT_TVKOT FOR ALL ENTRIES IN IT_VBRK WHERE VKORG = IT_VBRK-VKORG. SELECT BUKRS LTEXT FROM T001T INTO
  5. 5. CORRESPONDING FIELDS OF TABLE IT_T001 FOR ALL ENTRIES IN IT_VBRK WHERE BUKRS = IT_VBRK-BUKRS. SELECT KSCHL PGNAM FONAM FROM TNAPR INTO CORRESPONDING FIELDS OF TABLE IT_TNAPR FOR ALL ENTRIES IN IT_NAST WHERE KSCHL = IT_NAST-KSCHL. ENDIF.LOOP AT IT_TNAPR INTO WA_TNAPR. WA_FINAL-KSCHL = WA_TNAPR-KSCHL. WA_FINAL-PROGNAME = WA_TNAPR-PGNAM. WA_FINAL-TDSFNAME = WA_TNAPR-FONAM.READ TABLE IT_NAST INTO WA_NAST WITH KEY KSCHL = WA_FINAL-KSCHL. WA_FINAL-KAPPL = WA_NAST-KAPPL. WA_FINAL-OBJKY = WA_NAST-OBJKY. WA_FINAL-KSCHL = WA_NAST-KSCHL. WA_FINAL-ERDAT = WA_NAST-ERDAT. WA_FINAL-SPRAS = WA_NAST-SPRAS. READ TABLE IT_VBRK INTO WA_VBRK WITH KEY VBELN = WA_FINAL-OBJKY. WA_FINAL-VBELN = WA_VBRK-VBELN. WA_FINAL-VKORG = WA_VBRK-VKORG. WA_FINAL-BUKRS = WA_VBRK-BUKRS. WA_FINAL-LAND1 = WA_VBRK-LAND1. WA_FINAL-KUNAG = WA_VBRK-kunag.READ TABLE IT_VBRK INTO WA_VBRK WITH KEY KUNAG = WA_FINAL-KUNAG. IF WA_VBRK-ZTERM = PAY_T. WA_FINAL-ZTERM = Yes. ELSE. WA_FINAL-ZTERM = No. ENDIF. IF WA_VBRK-ZLSCH = PAY_M. WA_FINAL-ZLSCH = Yes. ELSE. WA_FINAL-ZLSCH = No. ENDIF. READ TABLE IT_TVKOT INTO WA_TVKOT WITH KEY VKORG = WA_FINAL-VKORG. WA_FINAL-VTXTK = WA_TVKOT-VTXTK. READ TABLE IT_T001 INTO WA_T001 WITH KEY BUKRS = WA_FINAL-BUKRS. WA_FINAL-LTEXT = WA_T001-LTEXT.
  6. 6. ENDLOOP. DESCRIBE TABLE IT_FINAL LINES LV_RECORD1. LV_RECORD = LV_RECORD1. PERFORM FIELDCAT USING: KSCHL X Output Type 1 , SPRAS X Language 2 , VKORG X Sales Org 3 , VTEXT X Sales Org name 4 , BURKS X Company Code 5 , LTEXT X Company code name 6 , LAND1 X Country 7 , ZTERM X Payment Term found 8 , ZLSCH X Payment Method found 9 , PROGRAMM X Program name 10 X, FORNR_SSF X Form Name 11 X. CALL SCREEN 9000.*&---------------------------------------------------------------------**& Module STATUS_9000 OUTPUT*&---------------------------------------------------------------------** text*----------------------------------------------------------------------*MODULE STATUS_9000 OUTPUT. SET PF-STATUS ZCUSTOM1. SET TITLEBAR xxx. CREATE OBJECT O_DOCKING EXPORTING RATIO = 95. CREATE OBJECT O_SPLIT EXPORTING PARENT = O_DOCKING SASH_POSITION = 30 WITH_BORDER = 0. O_TOP_CONTAINER = O_SPLIT->TOP_LEFT_CONTAINER . O_BOTTOM_CONTAINER = O_SPLIT->BOTTOM_RIGHT_CONTAINER . CREATE OBJECT O_GRID EXPORTING I_PARENT = O_BOTTOM_CONTAINER.
  7. 7. CREATE OBJECT O_DOCUMENT EXPORTING STYLE = ALV_GRID.CALL METHOD O_DOCUMENT->ADD_PICTURE EXPORTING PICTURE_ID = TRVPICTURE01 WIDTH = 50.CALL METHOD O_DOCUMENT->NEW_LINE.CALL METHOD O_DOCUMENT->ADD_TEXT EXPORTING TEXT = Total Records- SAP_EMPHASIS = CL_DD_AREA=>STRONG. " For boldCALL METHOD O_DOCUMENT->ADD_GAP EXPORTING WIDTH = 12.CALL METHOD O_DOCUMENT->ADD_TEXT EXPORTING TEXT = LV_RECORD.CALL METHOD O_DOCUMENT->NEW_LINE.CALL METHOD O_DOCUMENT->ADD_TEXT EXPORTING TEXT = Application- SAP_EMPHASIS = CL_DD_AREA=>STRONG. " For boldCALL METHOD O_DOCUMENT->ADD_GAP EXPORTING WIDTH = 16.CALL METHOD O_DOCUMENT->ADD_TEXT EXPORTING TEXT = LV_APPL.CALL METHOD O_DOCUMENT->NEW_LINE.CALL METHOD O_DOCUMENT->ADD_TEXT EXPORTING TEXT = Creation Date- SAP_EMPHASIS = CL_DD_AREA=>STRONG. " For boldCALL METHOD O_DOCUMENT->ADD_GAP EXPORTING WIDTH = 12.CALL METHOD O_DOCUMENT->ADD_TEXT EXPORTING TEXT = LV_COMBINE.CALL METHOD O_DOCUMENT->NEW_LINE.
  8. 8. CALL METHOD O_DOCUMENT->ADD_TEXT EXPORTING TEXT = Payment Term- SAP_EMPHASIS = CL_DD_AREA=>STRONG. " For bold CALL METHOD O_DOCUMENT->ADD_GAP EXPORTING WIDTH = 13. CALL METHOD O_DOCUMENT->ADD_TEXT EXPORTING TEXT = LV_P_TYPE. CALL METHOD O_DOCUMENT->NEW_LINE. CALL METHOD O_DOCUMENT->ADD_TEXT EXPORTING TEXT = Payment Method- SAP_EMPHASIS = CL_DD_AREA=>STRONG. " For bold CALL METHOD O_DOCUMENT->ADD_GAP EXPORTING WIDTH = 11. CALL METHOD O_DOCUMENT->ADD_TEXT EXPORTING TEXT = LV_P_METHOD. CALL METHOD O_DOCUMENT->DISPLAY_DOCUMENT EXPORTING PARENT = O_TOP_CONTAINER. CALL METHOD O_GRID->LIST_PROCESSING_EVENTS EXPORTING I_EVENT_NAME = TOP_OF_PAGE I_DYNDOC_ID = O_DOCUMENT. CALL METHOD O_GRID->SET_TABLE_FOR_FIRST_DISPLAY EXPORTING* I_STRUCTURE_NAME = ST_FINAL CHANGING IT_OUTTAB = IT_FINAL IT_FIELDCATALOG = IT_FIELDCAT* IT_SORT =* IT_FILTER =* EXCEPTIONS* INVALID_PARAMETER_COMBINATION = 1* PROGRAM_ERROR = 2* TOO_MANY_LINES = 3
  9. 9. * OTHERS = 4 . IF SY-SUBRC <> 0.* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. CREATE OBJECT GV_EVENTS. SET HANDLER GV_EVENTS->HANDLE_HOTSPOT_CLICK FOR O_GRID.ENDMODULE. " STATUS_9000 OUTPUT*&---------------------------------------------------------------------**& Form FIELDCAT*&---------------------------------------------------------------------** text*----------------------------------------------------------------------** -->FIELDNAME text* -->KEY text* -->EDIT text* -->COLTEXT text* -->COLPOS text*----------------------------------------------------------------------*FORM FIELDCAT USING FIELDNAME KEY EDIT COLTEXT COLPOS HOTSPOT. WA_FIELDCAT-FIELDNAME = FIELDNAME. WA_FIELDCAT-KEY = KEY. WA_FIELDCAT-EDIT = EDIT. WA_FIELDCAT-COLTEXT = COLTEXT. WA_FIELDCAT-COL_POS = COLPOS. WA_FIELDCAT-HOTSPOT = HOTSPOT. APPEND WA_FIELDCAT TO IT_FIELDCAT. CLEAR WA_FIELDCAT.ENDFORM. "FIELDCAT*&---------------------------------------------------------------------**& Module USER_COMMAND_9000 INPUT*&---------------------------------------------------------------------** text*----------------------------------------------------------------------*MODULE USER_COMMAND_9000 INPUT. CASE SY-UCOMM. WHEN BACK. PERFORM FREE_OBJECT.
  10. 10. LEAVE TO SCREEN 0. WHEN CANC OR EXIT. PERFORM FREE_OBJECT. LEAVE PROGRAM. WHEN DOWNLOAD. DATA: P_FILE TYPE DXFIELDS-LONGPATH.* CALL FUNCTION F4_FILENAME* EXPORTING* PROGRAM_NAME = SYST-CPROG* DYNPRO_NUMBER = SYST-DYNNR* FIELD_NAME = * IMPORTING* FILE_NAME = P_FILE. DATA: DIR TYPE STRING. DIR = 192.168.2.173qfilesvr400ec2usrsapTST. CALL FUNCTION /SAPDMC/LSM_F4_SERVER_FILE EXPORTING DIRECTORY = DIR FILEMASK = IMPORTING SERVERFILE = P_FILE EXCEPTIONS CANCELED_BY_USER = 1 OTHERS = 2. PERFORM FREE_OBJECT. IF P_FILE IS NOT INITIAL. OPEN DATASET P_FILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT. LOOP AT IT_FINAL INTO WA_FINAL. IF SY-SUBRC = 0. TRANSFER WA_FINAL TO P_FILE. ENDIF. ENDLOOP. ENDIF. ENDCASE.ENDMODULE. " USER_COMMAND_9000 INPUT*&---------------------------------------------------------------------**& Form HANDLE_HOTSPOT_ON_CUSTOMER_NUM*&---------------------------------------------------------------------*
  11. 11. * text*----------------------------------------------------------------------** -->P_E_ROW_ID text*----------------------------------------------------------------------*FORM HANDLE_HOTSPOT_ON_CUSTOMER_NUM USING VALUE(P_E_ROW_ID). READ TABLE IT_FINAL INTO WA_FINAL INDEX P_E_ROW_ID. SET PARAMETER ID RID FIELD WA_FINAL-PROGNAME.*-------------------------------------------------------------call transaction to display tghe vendor CALL TRANSACTION SE38 AND SKIP FIRST SCREEN.ENDFORM. "HANDLE_HOTSPOT_ON_CUSTOMER_NUM*&---------------------------------------------------------------------**& Form FREE_OBJECT*&---------------------------------------------------------------------** text*----------------------------------------------------------------------** --> p1 text* <-- p2 text*----------------------------------------------------------------------*FORM FREE_OBJECT . CALL METHOD O_GRID->FREE EXCEPTIONS CNTL_ERROR = 1 CNTL_SYSTEM_ERROR = 2 OTHERS = 3. 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 METHOD O_TOP_CONTAINER->FREE EXCEPTIONS CNTL_ERROR = 1 CNTL_SYSTEM_ERROR = 2 OTHERS = 3. CALL METHOD O_BOTTOM_CONTAINER->FREE EXCEPTIONS CNTL_ERROR = 1 CNTL_SYSTEM_ERROR = 2 OTHERS = 3. CALL METHOD O_DOCKING->FREE EXCEPTIONS CNTL_ERROR = 1 CNTL_SYSTEM_ERROR = 2 OTHERS = 3. IF SY-SUBRC <> 0. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF.
  12. 12. ENDFORM. " FREE_OBJECT

×