yaramohamed78

Untitled

Mar 13th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.49 KB | None | 0 0
  1. *&---------------------------------------------------------------------*
  2. *& Generates the ALV on the Selection Screen itself
  3. *&
  4. *&---------------------------------------------------------------------*
  5. REPORT zalv_on_sel_screen.
  6. *
  7. *----------------------------------------------------------------------*
  8. * Local class for report
  9. *----------------------------------------------------------------------*
  10. CLASS lcl_report DEFINITION.
  11. *
  12. PUBLIC SECTION.
  13. *
  14. DATA: t_data TYPE STANDARD TABLE OF sflight, " Output dat
  15. r_carrid TYPE RANGE OF sflight-carrid. " Select Option
  16. *
  17. METHODS:
  18. get_data,
  19. *
  20. generate_output.
  21. *
  22. ENDCLASS. "lcl_report DEFINITION
  23. *
  24. DATA: lo_report TYPE REF TO lcl_report.
  25. *
  26. DATA: w_carrid TYPE sflight-carrid.
  27. *
  28. ** Selection Screen
  29. SELECTION-SCREEN: BEGIN OF BLOCK blk1 WITH FRAME TITLE aaa.
  30. SELECT-OPTIONS: s_carrid FOR w_carrid.
  31. SELECTION-SCREEN: END OF BLOCK blk1.
  32. *
  33. ** Initialization
  34. INITIALIZATION.
  35. aaa = 'Selection Criteria'.
  36. * object for the report
  37. CREATE OBJECT lo_report.
  38. * generate output
  39. lo_report->generate_output( ).
  40. *
  41. ** Start of Selection
  42. START-OF-SELECTION.
  43. * Get data
  44. lo_report->r_carrid = s_carrid[].
  45. lo_report->get_data( ).
  46. *
  47. *----------------------------------------------------------------------*
  48. * Local Class Implementation
  49. *----------------------------------------------------------------------*
  50. CLASS lcl_report IMPLEMENTATION.
  51. *
  52. METHOD get_data.
  53. *
  54. * data selection
  55. SELECT * FROM sflight
  56. INTO TABLE me->t_data
  57. WHERE carrid IN s_carrid.
  58. IF sy-dbcnt IS INITIAL.
  59. MESSAGE s398(00) WITH 'No data selected'.
  60. ENDIF.
  61. *
  62. * export to memory
  63. EXPORT data = me->t_data TO MEMORY ID sy-cprog.
  64. *
  65. ENDMETHOD. "get_data
  66. *
  67. METHOD generate_output.
  68. *
  69. * local data
  70. DATA: lo_dock TYPE REF TO cl_gui_docking_container,
  71. lo_cont TYPE REF TO cl_gui_container,
  72. lo_alv TYPE REF TO cl_salv_table.
  73. *
  74. * import output table from the memory and free afterwards
  75. IMPORT data = me->t_data FROM MEMORY ID sy-cprog.
  76. FREE MEMORY ID sy-cprog.
  77. *
  78. * Only if there is some data
  79. CHECK me->t_data IS NOT INITIAL.
  80. *
  81. * Create a docking control at bottom
  82. CHECK lo_dock IS INITIAL.
  83. CREATE OBJECT lo_dock
  84. EXPORTING
  85. repid = sy-cprog
  86. dynnr = sy-dynnr
  87. ratio = 80
  88. side = cl_gui_docking_container=>dock_at_bottom
  89. name = 'DOCK_CONT'.
  90. IF sy-subrc <> 0.
  91. MESSAGE 'Error in the Docking control' TYPE 'S'.
  92. ENDIF.
  93. *
  94. * Create a SALV for output
  95. CHECK lo_alv IS INITIAL.
  96. TRY.
  97. * Narrow Casting: To initialize custom container from
  98. * docking container
  99. lo_cont ?= lo_dock.
  100. *
  101. * SALV Table Display on the Docking container
  102. CALL METHOD cl_salv_table=>factory
  103. EXPORTING
  104. list_display = if_salv_c_bool_sap=>false
  105. r_container = lo_cont
  106. container_name = 'DOCK_CONT'
  107. IMPORTING
  108. r_salv_table = lo_alv
  109. CHANGING
  110. t_table = me->t_data.
  111. CATCH cx_salv_msg .
  112. ENDTRY.
  113. *
  114. * Pf status
  115. DATA: lo_functions TYPE REF TO cl_salv_functions_list.
  116. lo_functions = lo_alv->get_functions( ).
  117. lo_functions->set_default( abap_true ).
  118. *
  119. * output display
  120. lo_alv->display( ).
  121. *
  122. ENDMETHOD. "generate_output
  123. *
  124. ENDCLASS. "lcl_report IMPLEMENTATION
Add Comment
Please, Sign In to add comment