Advertisement
yaramohamed78

Untitled

Mar 14th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.08 KB | None | 0 0
  1. *&---------------------------------------------------------------------*
  2. *& Generates the ALV on the Selection Screen itself
  3. *&
  4. *&---------------------------------------------------------------------*
  5. REPORT Z_YY_DISPOSAL_REQ_INQ.
  6.  
  7. TYPES: BEGIN OF ty_req,
  8. company_code TYPE ZFI_DISPOSAL_REQ-ZZCOMPANY_CODE,
  9. cost_center TYPE ZFI_DISPOSAL_REQ-ZZCOST_CENTER,
  10. END OF ty_req.
  11. DATA: gwa_req TYPE ty_req,
  12. gt_req TYPE TABLE OF ty_req,
  13. gt_return TYPE TABLE OF ddshretval,
  14. gwa_return TYPE ddshretval,
  15. gwa_dynpfields TYPE dynpread,
  16. gt_dynpfields TYPE TABLE OF dynpread,
  17. gv_company_code TYPE ZFI_DISPOSAL_REQ-ZZCOMPANY_CODE.
  18. *
  19. *----------------------------------------------------------------------*
  20. * Local class for report
  21. *----------------------------------------------------------------------*
  22. CLASS lcl_report DEFINITION.
  23. *
  24. PUBLIC SECTION.
  25. *
  26. DATA: t_data TYPE STANDARD TABLE OF ZFI_DISPOSAL_REQ, " Output dat
  27. r_carrid TYPE RANGE OF sflight-carrid. " Select Option
  28. *
  29. METHODS:
  30. get_data,
  31. *
  32. generate_output.
  33. *
  34. ENDCLASS. "lcl_report DEFINITION
  35. *
  36. DATA: lo_report TYPE REF TO lcl_report.
  37. *
  38. DATA: w_carrid TYPE sflight-carrid.
  39. *
  40. ** Selection Screen
  41. SELECTION-SCREEN BEGIN OF BLOCK SELECTION WITH FRAME TITLE text-001.
  42.  
  43. SELECTION-SCREEN BEGIN OF LINE.
  44. SELECTION-SCREEN COMMENT (20) text-002 FOR FIELD COM_CODE .
  45. PARAMETERS : COM_CODE LIKE ZFI_DISPOSAL_REQ-ZZCOMPANY_CODE DEFAULT '1200'.
  46. SELECTION-SCREEN POSITION 35.
  47. SELECTION-SCREEN COMMENT (20) text-003 FOR FIELD COST_CNT .
  48. PARAMETERS : COST_CNT LIKE ZFI_DISPOSAL_REQ-ZZCOST_CENTER.
  49. SELECTION-SCREEN POSITION 70.
  50. SELECTION-SCREEN END OF LINE.
  51. SELECTION-SCREEN BEGIN OF LINE.
  52. SELECTION-SCREEN COMMENT (20) text-004 FOR FIELD SER_NO .
  53. PARAMETERS : SER_NO LIKE ZFI_DISPOSAL_REQ-ZZSR_NUMBER.
  54. *SELECTION-SCREEN POSITION 10.
  55. SELECTION-SCREEN COMMENT (20) text-005 FOR FIELD SRV_TYPE .
  56. PARAMETERS : SRV_TYPE LIKE ZFI_DISPOSAL_REQ-ZZSERVICE_TYPE.
  57. SELECTION-SCREEN POSITION 70.
  58. SELECTION-SCREEN END OF LINE.
  59. SELECTION-SCREEN BEGIN OF LINE.
  60. SELECTION-SCREEN COMMENT (20) text-006 FOR FIELD DATE .
  61. PARAMETERS : DATE LIKE ZFI_DISPOSAL_REQ-ZZDATE.
  62. *SELECTION-SCREEN POSITION 35.
  63. SELECTION-SCREEN COMMENT (20) text-007 FOR FIELD REQ_STS .
  64. PARAMETERS : REQ_STS LIKE ZFI_DISPOSAL_REQ-ZZRQSTTS.
  65. SELECTION-SCREEN PUSHBUTTON (10) BUT1 USER-COMMAND SEARCH.
  66. SELECTION-SCREEN PUSHBUTTON (10) BUT2 USER-COMMAND RESET.
  67. SELECTION-SCREEN END OF LINE.
  68. SELECTION-SCREEN END OF BLOCK SELECTION.
  69. *
  70. WRITE : / 'ERROR2'.
  71. AT SELECTION-SCREEN ON VALUE-REQUEST FOR COST_CNT.
  72. WRITE : / 'WELCOME1'.
  73. REFRESH gt_dynpfields.
  74.  
  75. gwa_dynpfields-fieldname = 'COM_CODE'.
  76. APPEND gwa_dynpfields TO gt_dynpfields.
  77.  
  78. CALL FUNCTION 'DYNP_VALUES_READ'
  79. EXPORTING
  80. DYNAME = sy-repid
  81. DYNUMB = sy-dynnr
  82. TABLES
  83. DYNPFIELDS = gt_dynpfields
  84. EXCEPTIONS
  85. INVALID_ABAPWORKAREA = 1
  86. INVALID_DYNPROFIELD = 2
  87. INVALID_DYNPRONAME = 3
  88. INVALID_DYNPRONUMMER = 4
  89. INVALID_REQUEST = 5
  90. NO_FIELDDESCRIPTION = 6
  91. INVALID_PARAMETER = 7
  92. UNDEFIND_ERROR = 8
  93. DOUBLE_CONVERSION = 9
  94. STEPL_NOT_FOUND = 10
  95. OTHERS = 11
  96. .
  97. READ TABLE gt_dynpfields INTO gwa_dynpfields
  98. WITH KEY fieldname = 'COM_CODE'.
  99.  
  100. IF SY-SUBRC = 0.
  101. gv_company_code = gwa_dynpfields-fieldvalue.
  102. * MESSAGE ID 'ZALV_ERRORS' TYPE 'I' NUMBER '000' WITH gv_company_code.
  103. ELSE.
  104. WRITE : / 'ERROR1'.
  105. ENDIF.
  106.  
  107. SELECT ZZCOMPANY_CODE ZZCOST_CENTER
  108. INTO TABLE gt_req
  109. FROM ZFI_DISPOSAL_REQ
  110. WHERE ZZCOMPANY_CODE = gv_company_code.
  111.  
  112. CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
  113. EXPORTING
  114. RETFIELD = 'COST_CENTER'
  115. VALUE_ORG = 'S'
  116. TABLES
  117. VALUE_TAB = gt_req
  118. RETURN_TAB = gt_return
  119. EXCEPTIONS
  120. PARAMETER_ERROR = 1
  121. NO_VALUES_FOUND = 2
  122. OTHERS = 3
  123. .
  124.  
  125. READ TABLE gt_return INTO gwa_return INDEX 1.
  126.  
  127. IF SY-SUBRC = 0.
  128. COST_CNT = gwa_return-fieldval.
  129. ELSE.
  130. WRITE : / 'ERROR2'.
  131. ENDIF.
  132.  
  133.  
  134.  
  135. ** Initialization
  136. INITIALIZATION.
  137. BUT1 = 'Search'.
  138. BUT2 = 'Reset'.
  139. * object for the report
  140. CREATE OBJECT lo_report.
  141. * generate output
  142. lo_report->generate_output( ).
  143. *
  144. ** Start of Selection
  145. START-OF-SELECTION.
  146. * Get data
  147. * lo_report->r_carrid = s_carrid[].
  148. lo_report->get_data( ).
  149. *
  150. *----------------------------------------------------------------------*
  151. * Local Class Implementation
  152. *----------------------------------------------------------------------*
  153. CLASS lcl_report IMPLEMENTATION.
  154. *
  155. METHOD get_data.
  156. *
  157. * data selection
  158. SELECT * FROM ZFI_DISPOSAL_REQ
  159. INTO TABLE me->t_data.
  160. IF sy-dbcnt IS INITIAL.
  161. MESSAGE s398(00) WITH 'No data selected'.
  162. ENDIF.
  163. *
  164. * export to memory
  165. EXPORT data = me->t_data TO MEMORY ID sy-cprog.
  166. *
  167. ENDMETHOD. "get_data
  168. *
  169. METHOD generate_output.
  170. *
  171. * local data
  172. DATA: lo_dock TYPE REF TO cl_gui_docking_container,
  173. lo_cont TYPE REF TO cl_gui_container,
  174. lo_alv TYPE REF TO cl_salv_table.
  175. *
  176. * import output table from the memory and free afterwards
  177. IMPORT data = me->t_data FROM MEMORY ID sy-cprog.
  178. FREE MEMORY ID sy-cprog.
  179. *
  180. * Only if there is some data
  181. CHECK me->t_data IS NOT INITIAL.
  182. *
  183. * Create a docking control at bottom
  184. CHECK lo_dock IS INITIAL.
  185. CREATE OBJECT lo_dock
  186. EXPORTING
  187. repid = sy-cprog
  188. dynnr = sy-dynnr
  189. ratio = 80
  190. side = cl_gui_docking_container=>dock_at_bottom
  191. name = 'DOCK_CONT'.
  192. IF sy-subrc <> 0.
  193. MESSAGE 'Error in the Docking control' TYPE 'S'.
  194. ENDIF.
  195. *
  196. * Create a SALV for output
  197. CHECK lo_alv IS INITIAL.
  198. TRY.
  199. * Narrow Casting: To initialize custom container from
  200. * docking container
  201. lo_cont ?= lo_dock.
  202. *
  203. * SALV Table Display on the Docking container
  204. CALL METHOD cl_salv_table=>factory
  205. EXPORTING
  206. list_display = if_salv_c_bool_sap=>false
  207. r_container = lo_cont
  208. container_name = 'DOCK_CONT'
  209. IMPORTING
  210. r_salv_table = lo_alv
  211. CHANGING
  212. t_table = me->t_data.
  213. CATCH cx_salv_msg .
  214. ENDTRY.
  215. *
  216. * Pf status
  217. DATA: lo_functions TYPE REF TO cl_salv_functions_list.
  218. lo_functions = lo_alv->get_functions( ).
  219. lo_functions->set_default( abap_true ).
  220. *
  221. * output display
  222. lo_alv->display( ).
  223. *
  224. ENDMETHOD. "generate_output
  225. *
  226. ENDCLASS. "lcl_report IMPLEMENTATION
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement