ABAP 实时查看股票 - 摘自 《SAP ABAP面向对象程序设计:原则、模式及实践》

ABAP 查看股票 SALV版本:

 

执行界面:

 

 

 

代码:

  1 REPORT zrep_ooalv_stock.
  2 
  3 *********************************************************************
  4 *使用方法:
  5 *输入股票号码,获得新浪财经API实时沪深两市股票数据,双击可显示个股K线
  6 *代码移植:
  7 *在SAP SE38中创建报表ZREP_OOALV_STOCK,粘贴代码
  8 *需要双击屏幕号码 Screen 100并激活
  9 *双击状态 SET PF-STATUS 'ALV1'的 'ALV1',设置'BACK'按钮,激活
 10 *声明:
 11 *程序仅供参考,不能作为投资依据. Aaron Hao - 2017/11/11
 12 *********************************************************************
 13 
 14 
 15 "定义股票信息结构体
 16 TYPES: BEGIN OF ty_stock_live,
 17          sid    TYPE char10,  sname  TYPE char10,
 18          topen  TYPE char10,  yclose TYPE char10,
 19          cprice TYPE char10,  thigh  TYPE char10,
 20          tlow   TYPE char10,  buy    TYPE char10,
 21          sale   TYPE char10,  number TYPE char20,
 22          amount TYPE char20,  buy11  TYPE char10,
 23          buy12  TYPE char10,  buy21  TYPE char10,
 24          buy22  TYPE char10,  buy31  TYPE char10,
 25          buy32  TYPE char10,  buy41  TYPE char10,
 26          buy42  TYPE char10,  buy51  TYPE char10,
 27          buy52  TYPE char10,  sale11 TYPE char10,
 28          sale12 TYPE char10,  sale21 TYPE char10,
 29          sale22 TYPE char10,  sale31 TYPE char10,
 30          sale32 TYPE char10,  sale41 TYPE char10,
 31          sale42 TYPE char10,  sale51 TYPE char10,
 32          sale52 TYPE char10,  date   TYPE char15,
 33          time   TYPE char15,  color  TYPE lvc_t_scol, "Color.
 34        END OF ty_stock_live.
 35 
 36 TYPES: BEGIN OF ty_stock_id,
 37          stock_id TYPE char6,
 38        END OF ty_stock_id.
 39 
 40 TYPES ty_tab_stock_id TYPE STANDARD TABLE OF ty_stock_id.
 41 
 42 TYPES ty_tab_stock_live TYPE STANDARD TABLE OF ty_stock_live.
 43 
 44 DATA: gv_stock_id(6) TYPE c.
 45 DATA: tmp_num(6) TYPE n,
 46       idx        TYPE i,
 47       idx_tmp    TYPE i.
 48 
 49 "定义内表,定义SALV 的类CL_GUI_SALV_TABLE的对象变量
 50 DATA gt_stock_id TYPE ty_tab_stock_id.
 51 DATA gs_stock_id TYPE ty_stock_id.
 52 
 53 "定义股票信息内表
 54 DATA gt_stock TYPE ty_tab_stock_live .
 55 DATA gs_stock TYPE  ty_stock_live.
 56 DATA: gt_stock_pub_list TYPE TABLE OF string.
 57 
 58 "定义股票信息OOALV相关类
 59 DATA go_table TYPE REF TO cl_salv_table.
 60 DATA go_functions TYPE REF TO cl_salv_functions_list.
 61 DATA: go_columns TYPE REF TO cl_salv_columns_table.
 62 DATA: go_column TYPE REF TO cl_salv_column_table.
 63 DATA: go_column_list TYPE REF TO cl_salv_column_list.
 64 DATA:go_container TYPE REF TO cl_gui_custom_container.
 65 DATA: go_dock TYPE REF TO cl_gui_docking_container,
 66       go_picture   TYPE REF TO cl_gui_picture.
 67 DATA: gv_url        TYPE char256,
 68       gt_data           TYPE STANDARD TABLE OF x255.
 69 
 70 "本地类用于获得股票信息
 71 CLASS lcl_stock DEFINITION DEFERRED.
 72 "本地类用于处理双击事件
 73 CLASS lcl_event_handler DEFINITION DEFERRED.
 74 
 75 DATA go_stock TYPE REF TO lcl_stock.
 76 DATA: go_timer TYPE REF TO cl_gui_timer,
 77       go_evt_hndl TYPE REF TO lcl_event_handler.
 78 
 79 "定义本地类
 80 CLASS lcl_stock DEFINITION.
 81   PUBLIC SECTION.
 82     TYPES:
 83       BEGIN OF ty_stock_live,
 84              sid    TYPE char10, "股票ID
 85              sname  TYPE char10, "股票名字
 86              topen  TYPE char10, "今日开盘价
 87              yclose TYPE char10, "昨日收盘价;
 88              cprice TYPE char10, "当前价格;
 89              thigh  TYPE char10, "当日最高价
 90              tlow   TYPE char10, "今日最低价
 91              buy    TYPE char10, "竞买价,即“买一”报价;
 92              sale   TYPE char10, "竞卖价,即“卖一”报价;
 93              number TYPE char20, "成交的股票数
 94              amount TYPE char20, "成交金额
 95              buy11  TYPE char10, "买一,数量
 96              buy12  TYPE char10, "买一,报价
 97              buy21  TYPE char10, "买二,数量
 98              buy22  TYPE char10, "买二,报价
 99              buy31  TYPE char10, "买三,数量
100              buy32  TYPE char10, "买三,报价
101              buy41  TYPE char10, "买四,数量
102              buy42  TYPE char10, "买四,报价
103              buy51  TYPE char10, "买五,数量
104              buy52  TYPE char10, "买五,报价
105              sale11 TYPE char10, "卖一,数量
106              sale12 TYPE char10, "卖一,报价
107              sale21 TYPE char10, "卖二,数量
108              sale22 TYPE char10, "卖二,报价
109              sale31 TYPE char10, "卖三,数量
110              sale32 TYPE char10, "卖三,报价
111              sale41 TYPE char10, "卖四,数量
112              sale42 TYPE char10, "卖四,报价
113              sale51 TYPE char10, "卖五,数量
114              sale52 TYPE char10, "卖五,报价
115              date   TYPE char15, "日期
116              time   TYPE char15, "时间
117              color  TYPE lvc_t_scol, "Color.
118            END OF ty_stock_live .
119     TYPES:
120       ty_tab_stock_live TYPE STANDARD TABLE OF ty_stock_live .
121     TYPES:
122       BEGIN OF ty_stock_id,
123              stock_id TYPE char6,
124            END OF ty_stock_id .
125     TYPES:
126       ty_tab_stock_id TYPE STANDARD TABLE OF ty_stock_id .
127 
128     DATA gv_stock_id TYPE char6 .
129     DATA mt_stock TYPE ty_tab_stock_live .
130     DATA ms_stock TYPE ty_stock_live .
131     DATA mt_stock_id TYPE ty_tab_stock_id .
132     DATA ms_stock_id TYPE ty_stock_id .
133     DATA:
134       mt_stock_pub_list TYPE TABLE OF string .
135 
136     METHODS get_live_stock_info
137       IMPORTING
138         !it_stock_id TYPE ty_tab_stock_id .
139     METHODS fill_alv
140       CHANGING
141         VALUE(ct_stock) TYPE ty_tab_stock_live .
142   PROTECTED SECTION.
143   PRIVATE SECTION.
144 ENDCLASS.
145 
146 
147 
148 CLASS lcl_stock IMPLEMENTATION.
149   "定义本地类方法用于获得新浪财经实时股票信息
150   METHOD get_live_stock_info.
151     DATA: lo_abap_conv     TYPE REF TO cl_abap_conv_in_ce,
152           li_http_client   TYPE REF TO if_http_client,
153          lv_stock_pub_url TYPE string VALUE 'http://hq.sinajs.cn/list=',
154           abap_encoding    TYPE abap_encoding,
155           l_str            TYPE string,
156           l_xstr           TYPE xstring,
157           l_tmp            TYPE string,
158           l_url            TYPE string.
159     DATA: BEGIN OF wa_num,
160             num(6) TYPE c,
161           END OF wa_num.
162     DATA: BEGIN OF wa_lin,
163             str TYPE string,
164           END OF wa_lin.
165     DATA: it_num    LIKE TABLE OF wa_num,
166           it_restab LIKE TABLE OF wa_num,
167           it_res    LIKE TABLE OF wa_lin.
168     IF it_stock_id[] IS INITIAL.
169       RETURN.
170     ENDIF.
171     CLEAR:it_res.
172     REFRESH:it_res.
173     LOOP AT it_stock_id INTO ms_stock_id.
174       CLEAR l_tmp.
175       IF ms_stock_id-stock_id(1) < 6.
176         CONCATENATE 'sz' ms_stock_id-stock_id INTO l_tmp.
177       ENDIF.
178       IF ms_stock_id-stock_id(1) = '6'.
179         CONCATENATE 'sh' ms_stock_id-stock_id INTO l_tmp.
180       ENDIF.
181       CONCATENATE l_str l_tmp INTO l_str SEPARATED BY ','.
182     ENDLOOP.
183     IF l_str(1) = ','.
184       SHIFT l_str LEFT DELETING LEADING ','.
185     ENDIF.
186     CONCATENATE lv_stock_pub_url l_str INTO l_url.
187     CALL METHOD cl_http_client=>create_by_url
188       EXPORTING
189         url                = l_url
190       IMPORTING
191         client             = li_http_client
192       EXCEPTIONS
193         argument_not_found = 1
194         plugin_not_active  = 2
195         internal_error     = 3
196         OTHERS             = 4.
197     CALL METHOD li_http_client->request->set_header_field
198       EXPORTING
199         name  = 'Content-Type'
200         value = 'text/html;charset=utf-8'. " utf-8
201     CALL METHOD li_http_client->send
202       EXCEPTIONS
203         http_communication_failure = 1
204         http_invalid_state         = 2.
205     CALL METHOD li_http_client->receive
206       EXCEPTIONS
207         http_communication_failure = 1
208         http_invalid_state         = 2
209         http_processing_failed     = 3.
210     l_xstr = li_http_client->response->get_data( ).
211     IF sy-subrc = 0 .
212       li_http_client->close( ).
213     ENDIF.
214     CALL METHOD cl_abap_conv_in_ce=>create
215       EXPORTING
216         input       = l_xstr
217         encoding    = '8400'
218         replacement = '?'
219         ignore_cerr = abap_true
220       RECEIVING
221         conv        = lo_abap_conv.
222     TRY.
223         CALL METHOD lo_abap_conv->read
224           IMPORTING
225             data = l_str.
226       CATCH cx_sy_conversion_codepage.
227       CATCH cx_sy_codepage_converter_init.
228       CATCH cx_parameter_invalid_type.
229       CATCH cx_parameter_invalid_range.
230     ENDTRY.
231     REFRESH mt_stock_pub_list.
232     SPLIT l_str AT cl_abap_char_utilities=>newline
233     INTO TABLE mt_stock_pub_list.
234 
235   ENDMETHOD.
236   "定义本地类方法用于填充股票信息内表
237   METHOD fill_alv.
238     DATA lt_res TYPE TABLE OF string.
239     DATA l_str TYPE string.
240     DATA l_str_field TYPE string.
241     FIELD-SYMBOLS: <fs_value> TYPE any.
242 
243     FIELD-SYMBOLS: <fs_stock> TYPE ty_stock_live.
244     DATA: ls_color               TYPE lvc_s_scol.
245     DATA: tmp_num(6) TYPE n,
246           idx        TYPE i,
247           idx_tmp    TYPE i.
248 
249     REFRESH lt_res.
250     REFRESH mt_stock.
251     LOOP AT mt_stock_pub_list INTO l_str.
252       IF strlen( l_str ) < 30.
253         CONTINUE.
254       ENDIF.
255       SPLIT l_str AT ',' INTO TABLE lt_res.
256       READ TABLE lt_res INDEX 1 INTO l_str_field.
257       ms_stock-sid = l_str_field+13(6).
258       ms_stock-sname = l_str_field+21.
259 
260       idx = 2.
261       WHILE idx < 33.
262         READ TABLE lt_res INDEX idx INTO l_str_field.
263         idx = idx + 1.
264         ASSIGN COMPONENT idx OF STRUCTURE ms_stock TO <fs_value>.
265         <fs_value> = l_str_field.
266       ENDWHILE.
267 
268       INSERT ms_stock INTO TABLE mt_stock.
269     ENDLOOP.
270 
271     "填充股票信息内表的颜色列
272     LOOP AT mt_stock ASSIGNING <fs_stock>.
273       REFRESH <fs_stock>-color.
274       IF <fs_stock>-cprice > <fs_stock>-topen.
275         ls_color-color-col = 6. "上涨,红色
276         ls_color-color-int = 1.
277         ls_color-color-inv = 0.
278         APPEND ls_color TO <fs_stock>-color.
279       ELSE.
280         IF <fs_stock>-cprice < <fs_stock>-topen.
281           ls_color-color-col = 5." 下跌,绿色
282           ls_color-color-int = 0.
283           ls_color-color-inv = 0.
284           APPEND ls_color TO <fs_stock>-color.
285         ENDIF.
286       ENDIF.
287     ENDLOOP.
288 
289     ct_stock = mt_stock.
290 
291   ENDMETHOD.
292 
293 
294 ENDCLASS.
295 
296 
297 
298 "定义ALV双击事件类
299 CLASS lcl_handle_events DEFINITION.
300   PUBLIC SECTION.
301     METHODS: on_double_click FOR EVENT double_click OF
302 cl_salv_events_table
303       IMPORTING
304           row "事件触发所在的行号
305           column."事件触发所在的列名
306     METHODS: on_user_command FOR EVENT added_function OF
307 cl_salv_events_table
308       IMPORTING e_salv_function.
309 ENDCLASS.
310 
311 CLASS lcl_handle_events IMPLEMENTATION.
312   METHOD on_double_click.
313     PERFORM show_stock_details
314     USING row column.
315   ENDMETHOD.
316   METHOD on_user_command.
317     PERFORM handle_user_command USING e_salv_function.
318   ENDMETHOD.
319 ENDCLASS.
320 
321 "程序开始
322 
323 START-OF-SELECTION.
324   SELECT-OPTIONS:
325   s_sid FOR gv_stock_id.
326   PERFORM init_timer.
327   PERFORM show_grid.
328 
329   "获得输入的股票号码
330 FORM get_input_stock_id.
331   LOOP AT s_sid.
332     CLEAR gs_stock_id.
333     IF s_sid-option = 'EQ' .
334       IF s_sid-low <> '' .
335         gs_stock_id-stock_id = s_sid-low.
336         INSERT gs_stock_id INTO TABLE gt_stock_id.
337       ENDIF.
338       IF s_sid-high <> '' .
339         gs_stock_id-stock_id = s_sid-high.
340         INSERT gs_stock_id INTO TABLE gt_stock_id.
341       ENDIF.
342     ENDIF.
343     IF s_sid-option = 'BT'.
344       tmp_num = s_sid-low.
345       WHILE tmp_num <= s_sid-high.
346         gs_stock_id-stock_id = tmp_num.
347         INSERT gs_stock_id INTO TABLE gt_stock_id.
348         tmp_num = tmp_num + 1.
349       ENDWHILE.
350     ENDIF.
351   ENDLOOP.
352 ENDFORM.
353 
354 
355 "创建OOALV表格表头等信息
356 FORM build_alv.
357   DEFINE init_alv.
358     go_column->set_long_text( &1 ).
359     go_column->set_medium_text( &1 ).
360     go_column->set_short_text( &1 ).
361   END-OF-DEFINITION.
362 
363 
364   TRY.
365       "调用类方法创建类对象
366       CALL METHOD cl_salv_table=>factory
367         IMPORTING
368           r_salv_table = go_table
369         CHANGING
370           t_table      = gt_stock.
371     CATCH cx_salv_msg.
372   ENDTRY.
373 
374 
375   TRY.
376       go_columns = go_table->get_columns( ).
377       go_column ?= go_columns->get_column('SID').
378       init_alv '股票号码'.
379       go_column ?= go_columns->get_column('SNAME').
380       init_alv '股票名称'.
381       go_column ?= go_columns->get_column('TOPEN').
382       init_alv '开盘价'.
383       go_column ?= go_columns->get_column('YCLOSE').
384       init_alv '昨收价'.
385       go_column ?= go_columns->get_column('CPRICE').
386       init_alv '现价'.
387       go_column ?= go_columns->get_column('THIGH').
388       init_alv '最高价'  .
389       go_column ?= go_columns->get_column('TLOW').
390       init_alv '最低价'   .
391       go_column ?= go_columns->get_column('BUY').
392       init_alv '买一价'.
393       go_column ?= go_columns->get_column('SALE').
394       init_alv '卖一价'.
395       go_column ?= go_columns->get_column('NUMBER').
396       init_alv '成交数量'.
397       go_column ?= go_columns->get_column('AMOUNT').
398       init_alv '成交金额'.
399       go_column ?= go_columns->get_column('BUY11').
400       init_alv '买一数量'.
401       go_column ?= go_columns->get_column('BUY12').
402       init_alv '买一金额'.
403       go_column ?= go_columns->get_column('BUY21').
404       init_alv '买二数量'.
405       go_column ?= go_columns->get_column('BUY22').
406       init_alv '买二金额'.
407       go_column ?= go_columns->get_column('BUY31').
408       init_alv '买三数量'.
409       go_column ?= go_columns->get_column('BUY32').
410       init_alv '买三金额'.
411       go_column ?= go_columns->get_column('BUY41').
412       init_alv '买四数量'.
413       go_column ?= go_columns->get_column('BUY42').
414       init_alv '买四金额'.
415       go_column ?= go_columns->get_column('BUY51').
416       init_alv '买五数量'.
417       go_column ?= go_columns->get_column('BUY52').
418       init_alv '买五金额'.
419       go_column ?= go_columns->get_column('SALE11').
420       init_alv '卖一数量'.
421       go_column ?= go_columns->get_column('SALE12').
422       init_alv '卖一金额'.
423       go_column ?= go_columns->get_column('SALE21').
424       init_alv '卖二数量'.
425       go_column ?= go_columns->get_column('SALE22').
426       init_alv '卖二金额'.
427       go_column ?= go_columns->get_column('SALE31').
428       init_alv '卖三数量'.
429       go_column ?= go_columns->get_column('SALE32').
430       init_alv '卖三金额'.
431       go_column ?= go_columns->get_column('SALE41').
432       init_alv '卖四数量'.
433       go_column ?= go_columns->get_column('SALE42').
434       init_alv '卖四金额'.
435       go_column ?= go_columns->get_column('SALE51').
436       init_alv '卖五数量'.
437       go_column ?= go_columns->get_column('SALE52').
438       init_alv '卖五金额'.
439       go_column ?= go_columns->get_column('DATE').
440       init_alv   '日期'  .
441       go_column ?= go_columns->get_column('TIME').
442       init_alv   '时间'.
443 
444     CATCH cx_salv_not_found.                            "#EC NO_HANDLER
445   ENDTRY.
446 
447 
448   "为内表设置一个特殊的列, COLOR,然后为该列赋值即可控制每一行的颜色
449   TRY.
450       CALL METHOD go_columns->set_color_column
451         EXPORTING
452           value = 'COLOR'.
453     CATCH cx_salv_data_error.
454   ENDTRY.
455 
456   "调用类方法显示SALV
457   go_functions = go_table->get_functions( ).
458   go_functions->set_all( abap_true ).
459 
460   TRY.
461       "设置热点列
462       "go_columns = go_table->get_columns( ).
463       "go_column ?= go_columns->get_column( 'SID').
464       "go_column->set_cell_type( if_salv_c_cell_type=>hotspot ).
465 
466       "=====获取事件对象
467       DATA: lr_event TYPE REF TO cl_salv_events_table.
468       lr_event = go_table->get_event( ).
469 
470       "=====事件注册
471       DATA: mo_handle_event TYPE REF TO lcl_handle_events.
472       CREATE OBJECT mo_handle_event.
473       SET HANDLER mo_handle_event->on_double_click FOR lr_event.
474     CATCH cx_salv_not_found.
475   ENDTRY.
476 ENDFORM .
477 
478 
479 "显示股票详细信息K线图
480 FORM show_stock_details USING p_row TYPE i
481                           p_column TYPE lvc_fname.
482 
483   DATA: l_row TYPE char10.
484   WRITE p_row TO l_row LEFT-JUSTIFIED.
485 
486   READ TABLE gt_stock INDEX l_row INTO gs_stock.
487   IF sy-subrc = 0.
488     gv_stock_id = gs_stock-sid.
489     "调用屏幕,显示图片
490     CALL SCREEN 100.
491   ENDIF.
492 
493 ENDFORM.
494 
495 "刷新,暂时不用
496 FORM handle_user_command USING p_function TYPE salv_de_function.
497   CASE p_function.
498     WHEN 'REFRESH'.
499       go_table->refresh( ).
500   ENDCASE.
501 ENDFORM.
502 
503 "调用上述方法,显示ALV结果
504 FORM show_grid.
505 
506   "获取输入的股票号码列表
507   PERFORM get_input_stock_id.
508 
509   "创建本地类实例,获取实时股票信息,转化为内表格式
510   CREATE OBJECT go_stock.
511   go_stock->get_live_stock_info( gt_stock_id ).
512   CALL METHOD go_stock->fill_alv
513   CHANGING ct_stock = gt_stock.
514 
515   "创建OOALV,因为有SCREEN ,只能采用面向对象与面向过程的ABAP混编
516   PERFORM build_alv.
517   "显示OOALV
518   go_table->display( ).
519 
520 ENDFORM.
521 
522 "获得新浪财经API的个股K线图
523 FORM show_picture USING i_stock_id.
524 
525   DATA: l_tmp TYPE string.
526 
527   CLEAR l_tmp.
528   IF i_stock_id(1) < 6.
529     CONCATENATE 'http://image.sinajs.cn/newchart/daily/n/'
530     'sz' i_stock_id  '.gif' INTO l_tmp.
531   ENDIF.
532   IF i_stock_id(1) = '6'.
533     CONCATENATE 'http://image.sinajs.cn/newchart/daily/n/'
534     'sh' i_stock_id '.gif' INTO l_tmp.
535   ENDIF.
536   gv_url = l_tmp.
537 
538   "创建容器
539   CREATE OBJECT go_dock
540     EXPORTING
541       repid     = sy-repid
542       dynnr     = sy-dynnr
543       side      = go_dock->dock_at_left
544       extension = 620.
545   IF sy-subrc NE 0 .
546     "Instantiate container Error!
547   ENDIF.
548 
549   "创建图片
550   IF go_dock IS NOT INITIAL.
551     CREATE OBJECT go_picture
552       EXPORTING
553         parent =  go_dock
554       EXCEPTIONS
555         OTHERS = 1.
556     IF sy-subrc NE 0 .
557       "Instantiate Picture Error!
558     ENDIF.
559   ENDIF.
560 
561   "获取URL
562   CALL FUNCTION 'DP_CREATE_URL'
563     EXPORTING
564       type                       = 'JPG/GIF'
565       subtype                    = cndp_sap_tab_unknown
566     TABLES
567       data                       = gt_data
568     CHANGING
569       url                        = gv_url
570    EXCEPTIONS
571      dp_invalid_parameter       = 1
572      dp_error_put_table         = 2
573      dp_error_general           = 3
574      OTHERS                     = 4.
575   IF sy-subrc <> 0.
576     "Get URL Error!
577   ENDIF.
578 
579   "显示图片
580   CALL METHOD go_picture->load_picture_from_url
581     EXPORTING
582       url = gv_url.
583 
584 *  CALL METHOD go_picture->set_display_mode
585 *    EXPORTING
586 *      display_mode = 3.
587 
588 
589 ENDFORM.
590 
591 
592 
593 "定时器设定
594 CLASS lcl_event_handler DEFINITION.
595   PUBLIC SECTION.
596     METHODS:
597       handle_timer FOR EVENT finished OF cl_gui_timer.
598 ENDCLASS.
599 
600 CLASS lcl_event_handler IMPLEMENTATION.
601   METHOD handle_timer.
602     "重新连接API,获取最新数据
603     go_stock->get_live_stock_info( gt_stock_id ).
604     "填充内表
605     CALL METHOD go_stock->fill_alv
606 CHANGING ct_stock = gt_stock.
607     "刷新ALV组件
608     go_table->refresh( ).
609 
610     CALL METHOD go_timer->run
611       EXCEPTIONS
612         OTHERS = 9.
613   ENDMETHOD.
614 ENDCLASS.
615 
616 
617 FORM init_timer.
618   IF go_timer IS NOT BOUND.
619     CREATE OBJECT go_timer
620       EXCEPTIONS
621         OTHERS = 9.
622     CREATE OBJECT go_evt_hndl.
623   ENDIF.
624   SET HANDLER go_evt_hndl->handle_timer FOR go_timer.
625   "10秒钟刷新一次
626   go_timer->interval = 10.
627   CALL METHOD go_timer->run
628     EXCEPTIONS
629       OTHERS = 9.
630 ENDFORM.
631 
632 "屏幕100是为K线图片专用的
633 MODULE status_0100 OUTPUT.
634   SET PF-STATUS 'ALV1'.
635   "屏幕显示后,调用图片显示
636   PERFORM show_picture USING gv_stock_id.
637 ENDMODULE.
638 
639 "屏幕100是为K线图片专用的
640 MODULE user_command_0100 INPUT.
641   CASE sy-ucomm.
642     WHEN 'BACK'.
643       "返回前一个界面,先删除容器组件,再删除图片组件
644       CALL METHOD go_picture->free( ).
645       CALL METHOD go_dock->free( ).
646       "返回ALV屏幕
647       LEAVE TO SCREEN 0.
648     WHEN OTHERS.
649   ENDCASE.
650 ENDMODULE.                 " USER_COMMAND_0100  INPUT

 

posted @ 2017-11-12 01:35 techtalk 阅读(...) 评论(...)  编辑 收藏