Advertisement
yaramohamed78

Untitled

Mar 20th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.26 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 IT_req,
  8. zzcompany_code TYPE ZFI_DISPOSAL_REQ-ZZCOMPANY_CODE,
  9. zzcost_center TYPE ZFI_DISPOSAL_REQ-ZZCOST_CENTER,
  10. zzsr_number TYPE ZFI_DISPOSAL_REQ-ZZSR_NUMBER,
  11. zzdate TYPE ZFI_DISPOSAL_REQ-ZZDATE,
  12. zzservice_type TYPE ZFI_DISPOSAL_REQ-ZZSERVICE_TYPE,
  13. zzrqstts TYPE ZFI_DISPOSAL_REQ-ZZRQSTTS,
  14. crea_user TYPE ZFI_DISPOSAL_REQ-CREA_USER,
  15. crea_time TYPE ZFI_DISPOSAL_REQ-CREA_TIME,
  16. chng_user TYPE ZFI_DISPOSAL_REQ-CHNG_USER,
  17. chng_time TYPE ZFI_DISPOSAL_REQ-CHNG_TIME,
  18. s_zzdesc TYPE ZFI_LOOKUP-ZZDESC,
  19. rs_zzdesc TYPE ZFI_LOOKUP-ZZDESC,
  20. END OF IT_req.
  21.  
  22. DATA : it_reqs TYPE TABLE OF it_req.
  23. TYPES: BEGIN OF ty_req,
  24. company_code TYPE ZFI_DISPOSAL_REQ-ZZCOMPANY_CODE,
  25. cost_center TYPE ZFI_DISPOSAL_REQ-ZZCOST_CENTER,
  26. END OF ty_req.
  27. TYPES: BEGIN OF ty_lookup,
  28. code TYPE ZFI_LOOKUP-ZZCODE,
  29. END OF ty_lookup.
  30. DATA: gwa_req TYPE ty_req,
  31. gt_req TYPE TABLE OF ty_req,
  32. gwa_lookup TYPE ty_lookup,
  33. gt_lookup TYPE TABLE OF ty_lookup,
  34. gt_return TYPE TABLE OF ddshretval,
  35. gwa_return TYPE ddshretval,
  36. gwa_dynpfields TYPE dynpread,
  37. gt_dynpfields TYPE TABLE OF dynpread,
  38. gv_company_code TYPE ZFI_DISPOSAL_REQ-ZZCOMPANY_CODE,
  39. gv_type TYPE ZFI_LOOKUP-ZZTYPE.
  40.  
  41. DATA: wa_req TYPE ZFI_DISPOSAL_REQ,
  42. wa_service TYPE ZFI_LOOKUP,
  43. wa_req_status TYPE ZFI_LOOKUP.
  44.  
  45. DATA: wa_reqs TYPE it_req.
  46.  
  47.  
  48. *
  49. *----------------------------------------------------------------------*
  50. * Local class for report
  51. *----------------------------------------------------------------------*
  52. CLASS lcl_report DEFINITION.
  53. *
  54. PUBLIC SECTION.
  55. *
  56. TYPES: BEGIN OF ty_data,
  57. serial_no TYPE ZFI_DISPOSAL_REQ-ZZSR_NUMBER,
  58. company_code TYPE ZFI_DISPOSAL_REQ-ZZCOMPANY_CODE,
  59. cost_center TYPE ZFI_DISPOSAL_REQ-ZZCOST_CENTER,
  60. date TYPE ZFI_DISPOSAL_REQ-ZZDATE,
  61. service_type TYPE ZFI_DISPOSAL_REQ-ZZSERVICE_TYPE,
  62. request_status TYPE ZFI_DISPOSAL_REQ-ZZRQSTTS,
  63. create_user TYPE ZFI_DISPOSAL_REQ-CREA_USER,
  64. create_time TYPE ZFI_DISPOSAL_REQ-CREA_TIME,
  65. change_user TYPE ZFI_DISPOSAL_REQ-CHNG_USER,
  66. change_time TYPE ZFI_DISPOSAL_REQ-CHNG_TIME,
  67. END OF ty_data.
  68.  
  69. DATA: t_data TYPE STANDARD TABLE OF ty_data, " Output dat
  70. r_carrid TYPE RANGE OF sflight-carrid. " Select Option
  71. *
  72. METHODS:
  73. get_data,
  74. *
  75. generate_output.
  76. *
  77. ENDCLASS. "lcl_report DEFINITION
  78. *
  79. DATA: lo_report TYPE REF TO lcl_report.
  80. *
  81. DATA: w_carrid TYPE sflight-carrid.
  82. *
  83. ** Selection Screen
  84. SELECTION-SCREEN BEGIN OF BLOCK SELECTION WITH FRAME TITLE text-001.
  85.  
  86. SELECTION-SCREEN BEGIN OF LINE.
  87. SELECTION-SCREEN COMMENT (20) text-002 FOR FIELD COM_CODE .
  88. PARAMETERS : COM_CODE LIKE ZFI_DISPOSAL_REQ-ZZCOMPANY_CODE DEFAULT '1200'.
  89. SELECTION-SCREEN POSITION 35.
  90. SELECTION-SCREEN COMMENT (20) text-003 FOR FIELD COST_CNT .
  91. PARAMETERS : COST_CNT LIKE ZFI_DISPOSAL_REQ-ZZCOST_CENTER.
  92. SELECTION-SCREEN POSITION 70.
  93. SELECTION-SCREEN END OF LINE.
  94. SELECTION-SCREEN BEGIN OF LINE.
  95. SELECTION-SCREEN COMMENT (20) text-004 FOR FIELD SER_NO .
  96. PARAMETERS : SER_NO LIKE ZFI_DISPOSAL_REQ-ZZSR_NUMBER.
  97. *SELECTION-SCREEN POSITION 10.
  98. SELECTION-SCREEN COMMENT (20) text-005 FOR FIELD SRV_TYPE .
  99. PARAMETERS : SRV_TYPE LIKE ZFI_LOOKUP-ZZCODE.
  100. SELECTION-SCREEN POSITION 70.
  101. SELECTION-SCREEN END OF LINE.
  102. SELECTION-SCREEN BEGIN OF LINE.
  103. SELECTION-SCREEN COMMENT (20) text-006 FOR FIELD DATE .
  104. PARAMETERS : DATE LIKE ZFI_DISPOSAL_REQ-ZZDATE.
  105. *SELECTION-SCREEN POSITION 35.
  106. SELECTION-SCREEN COMMENT (20) text-007 FOR FIELD REQ_STS .
  107. PARAMETERS : REQ_STS LIKE ZFI_LOOKUP-ZZCODE.
  108. SELECTION-SCREEN PUSHBUTTON (10) BUT1 USER-COMMAND SEARCH.
  109. SELECTION-SCREEN PUSHBUTTON (10) BUT2 USER-COMMAND RESET.
  110. SELECTION-SCREEN END OF LINE.
  111. SELECTION-SCREEN END OF BLOCK SELECTION.
  112. *
  113. WRITE : / 'ERROR2'.
  114. AT SELECTION-SCREEN ON VALUE-REQUEST FOR COST_CNT.
  115. WRITE : / 'WELCOME1'.
  116. REFRESH gt_dynpfields.
  117.  
  118. gwa_dynpfields-fieldname = 'COM_CODE'.
  119. APPEND gwa_dynpfields TO gt_dynpfields.
  120.  
  121. CALL FUNCTION 'DYNP_VALUES_READ'
  122. EXPORTING
  123. DYNAME = sy-repid
  124. DYNUMB = sy-dynnr
  125. TABLES
  126. DYNPFIELDS = gt_dynpfields
  127. EXCEPTIONS
  128. INVALID_ABAPWORKAREA = 1
  129. INVALID_DYNPROFIELD = 2
  130. INVALID_DYNPRONAME = 3
  131. INVALID_DYNPRONUMMER = 4
  132. INVALID_REQUEST = 5
  133. NO_FIELDDESCRIPTION = 6
  134. INVALID_PARAMETER = 7
  135. UNDEFIND_ERROR = 8
  136. DOUBLE_CONVERSION = 9
  137. STEPL_NOT_FOUND = 10
  138. OTHERS = 11
  139. .
  140. READ TABLE gt_dynpfields INTO gwa_dynpfields
  141. WITH KEY fieldname = 'COM_CODE'.
  142.  
  143. IF SY-SUBRC = 0.
  144. gv_company_code = gwa_dynpfields-fieldvalue.
  145. * MESSAGE ID 'ZALV_ERRORS' TYPE 'I' NUMBER '000' WITH gv_company_code.
  146. ELSE.
  147. WRITE : / 'ERROR1'.
  148. ENDIF.
  149.  
  150. SELECT ZZCOMPANY_CODE ZZCOST_CENTER
  151. INTO TABLE gt_req
  152. FROM ZFI_DISPOSAL_REQ
  153. WHERE ZZCOMPANY_CODE = gv_company_code.
  154.  
  155. CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
  156. EXPORTING
  157. RETFIELD = 'COST_CENTER'
  158. VALUE_ORG = 'S'
  159. TABLES
  160. VALUE_TAB = gt_req
  161. RETURN_TAB = gt_return
  162. EXCEPTIONS
  163. PARAMETER_ERROR = 1
  164. NO_VALUES_FOUND = 2
  165. OTHERS = 3
  166. .
  167.  
  168. READ TABLE gt_return INTO gwa_return INDEX 1.
  169.  
  170. IF SY-SUBRC = 0.
  171. COST_CNT = gwa_return-fieldval.
  172. ELSE.
  173. WRITE : / 'ERROR2'.
  174. ENDIF.
  175.  
  176. AT SELECTION-SCREEN ON VALUE-REQUEST FOR REQ_STS.
  177. REFRESH gt_dynpfields.
  178.  
  179. SELECT ZZCODE
  180. INTO TABLE gt_lookup
  181. FROM ZFI_LOOKUP
  182. WHERE ZZTYPE = '1'.
  183.  
  184. CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
  185. EXPORTING
  186. RETFIELD = 'TYPE'
  187. VALUE_ORG = 'S'
  188. TABLES
  189. VALUE_TAB = gt_lookup
  190. RETURN_TAB = gt_return
  191. EXCEPTIONS
  192. PARAMETER_ERROR = 1
  193. NO_VALUES_FOUND = 2
  194. OTHERS = 3
  195. .
  196.  
  197. READ TABLE gt_return INTO gwa_return INDEX 1.
  198.  
  199. IF SY-SUBRC = 0.
  200. REQ_STS = gwa_return-fieldval.
  201. ELSE.
  202. WRITE : / 'ERROR2'.
  203. ENDIF.
  204.  
  205. AT SELECTION-SCREEN ON VALUE-REQUEST FOR SRV_TYPE.
  206. REFRESH gt_dynpfields.
  207.  
  208. SELECT ZZCODE
  209. INTO TABLE gt_lookup
  210. FROM ZFI_LOOKUP
  211. WHERE ZZTYPE = '2'.
  212.  
  213. CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
  214. EXPORTING
  215. RETFIELD = 'TYPE'
  216. VALUE_ORG = 'S'
  217. TABLES
  218. VALUE_TAB = gt_lookup
  219. RETURN_TAB = gt_return
  220. EXCEPTIONS
  221. PARAMETER_ERROR = 1
  222. NO_VALUES_FOUND = 2
  223. OTHERS = 3
  224. .
  225.  
  226. READ TABLE gt_return INTO gwa_return INDEX 1.
  227.  
  228. IF SY-SUBRC = 0.
  229. SRV_TYPE = gwa_return-fieldval.
  230. ELSE.
  231. WRITE : / 'ERROR2'.
  232. ENDIF.
  233.  
  234. ** Initialization
  235. INITIALIZATION.
  236. BUT1 = 'Search'.
  237. BUT2 = 'Reset'.
  238. AT SELECTION-SCREEN.
  239. CASE sy-ucomm.
  240.  
  241. when 'SEARCH'.
  242. MESSAGE ID 'ZALV_ERRORS' TYPE 'I' NUMBER '000' WITH REQ_STS.
  243. PERFORM SEARCH.
  244.  
  245. WHEN 'RESET'.
  246. PERFORM RESET.
  247. ENDCASE.
  248.  
  249. * object for the report
  250. CREATE OBJECT lo_report.
  251. * generate output
  252. lo_report->generate_output( ).
  253. *
  254. ** Start of Selection
  255. START-OF-SELECTION.
  256. * Get data
  257. * lo_report->r_carrid = s_carrid[].
  258. lo_report->get_data( ).
  259. *
  260. *----------------------------------------------------------------------*
  261. * Local Class Implementation
  262. *----------------------------------------------------------------------*
  263. CLASS lcl_report IMPLEMENTATION.
  264. *
  265. METHOD get_data.
  266. *
  267. * data selection
  268. * SELECT ZZSR_NUMBER ZZCOMPANY_CODE ZZCOST_CENTER ZZDATE ZZSERVICE_TYPE ZZRQSTTS CREA_USER CREA_TIME CHNG_USER CHNG_TIME FROM ZFI_DISPOSAL_REQ
  269. * INTO TABLE me->t_data.
  270. me->t_data = it_reqs.
  271. IF sy-dbcnt IS INITIAL.
  272. MESSAGE s398(00) WITH 'No data selected'.
  273. ENDIF.
  274. *
  275. * export to memory
  276. EXPORT data = me->t_data TO MEMORY ID sy-cprog.
  277. *
  278. ENDMETHOD. "get_data
  279. *
  280. METHOD generate_output.
  281. *
  282. * local data
  283. DATA: lo_dock TYPE REF TO cl_gui_docking_container,
  284. lo_cont TYPE REF TO cl_gui_container,
  285. lo_alv TYPE REF TO cl_salv_table.
  286. *
  287. * import output table from the memory and free afterwards
  288. IMPORT data = me->t_data FROM MEMORY ID sy-cprog.
  289. FREE MEMORY ID sy-cprog.
  290. *
  291. * Only if there is some data
  292. CHECK me->t_data IS NOT INITIAL.
  293. *
  294. * Create a docking control at bottom
  295. CHECK lo_dock IS INITIAL.
  296. CREATE OBJECT lo_dock
  297. EXPORTING
  298. repid = sy-cprog
  299. dynnr = sy-dynnr
  300. ratio = 80
  301. side = cl_gui_docking_container=>dock_at_bottom
  302. name = 'DOCK_CONT'.
  303. IF sy-subrc <> 0.
  304. MESSAGE 'Error in the Docking control' TYPE 'S'.
  305. ENDIF.
  306. *
  307. * Create a SALV for output
  308. CHECK lo_alv IS INITIAL.
  309. TRY.
  310. * Narrow Casting: To initialize custom container from
  311. * docking container
  312. lo_cont ?= lo_dock.
  313. *
  314. * SALV Table Display on the Docking container
  315. CALL METHOD cl_salv_table=>factory
  316. EXPORTING
  317. list_display = if_salv_c_bool_sap=>false
  318. r_container = lo_cont
  319. container_name = 'DOCK_CONT'
  320. IMPORTING
  321. r_salv_table = lo_alv
  322. CHANGING
  323. t_table = me->t_data.
  324. CATCH cx_salv_msg .
  325. ENDTRY.
  326. *
  327. * Pf status
  328. DATA: lo_functions TYPE REF TO cl_salv_functions_list.
  329. lo_functions = lo_alv->get_functions( ).
  330. lo_functions->set_default( abap_true ).
  331. *
  332. * output display
  333. lo_alv->display( ).
  334. *
  335. ENDMETHOD. "generate_output
  336. *
  337.  
  338.  
  339.  
  340.  
  341.  
  342. ENDCLASS.
  343.  
  344. FORM SEARCH.
  345. WRITE : / 'WELCOME'.
  346. wa_req-ZZCOMPANY_CODE = COM_CODE.
  347. wa_req-ZZCOST_CENTER = COST_CNT.
  348. wa_req-ZZSR_NUMBER = SER_NO.
  349. wa_req-ZZDATE = DATE.
  350. wa_req_status-ZZCODE = REQ_STS.
  351. wa_service-ZZCODE = SRV_TYPE.
  352.  
  353.  
  354. CALL FUNCTION 'Z_REQ_FN_INQUIRY'
  355. EXPORTING
  356. WA_REQ = WA_REQ
  357. WA_REQ_STATUS = WA_REQ_STATUS
  358. WA_SERVICE = WA_SERVICE
  359. TABLES
  360. QT_REQ = it_reqs
  361. .
  362. loop at it_reqs INTO wa_reqs.
  363. * MESSAGE ID 'ZALV_ERRORS' TYPE 'I' NUMBER '000' WITH wa_reqs-zzcompany_code.
  364. ENDLOOP.
  365.  
  366. ENDFORM.
  367.  
  368. FORM RESET.
  369. CLEAR COST_CNT.
  370. CLEAR SER_NO.
  371. CLEAR DATE.
  372. CLEAR REQ_STS.
  373. CLEAR SRV_TYPE.
  374. ENDFORM.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement