http://wwsheng009.blog.163.com/blog/static/2302061201541271917929/?newFollowBlog
最近股市行情异常火爆,牵动了无数股市的心。可是在上班时间盯股票可是件危险的事,所以就有了各种伪装的看股软件。以下我们就在SAP中伪装股票软件,把股票行情隐藏在报表中。
让我们先看看效果:
图一,股票行情查看
图二,K线图
功能十分简单:
1.从新浪网站读取股票信息,解析并显示。
2.调用新浪接口,显示分时图,K线图。
3.定时刷新,默认是5秒。
实现过程。
1.首先需要保证你的SAP服务器能访问外网。
2.事务码SE38,新建程序,把源代码粘贴进去。
3.新建屏幕100。增加4个自定义控件,分别命名为F_CONTROL,R_CONTROL,Z_CONTROL,Y_CONTROL。
源代码:
*&---------------------------------------------------------------------*
*& Report Z_HTTP_STOCK
*&
*&---------------------------------------------------------------------*
*&Author: Alan Gu
*&本程序只作个人测试用途,
*http://blog.itpub.net/73630/viewspace-1028306/
*&五秒钟更新一次
*&双击股票代码可以查看相关的K线图
*&---------------------------------------------------------------------*
REPORT z_http_stock.
TYPE-POOLS: abap,slis.
*INCLUDE zstock_json_util.
DATA:f_picture TYPE REF TO cl_gui_picture,
r_picture TYPE REF TO cl_gui_picture,
z_picture TYPE REF TO cl_gui_picture,
y_picture TYPE REF TO cl_gui_picture.
DATA: f_container TYPE REF TO cl_gui_custom_container,
r_container TYPE REF TO cl_gui_custom_container,
y_container TYPE REF TO cl_gui_custom_container,
z_container TYPE REF TO cl_gui_custom_container.
DATA:f_url TYPE cndp_url,
r_url TYPE cndp_url,
z_url TYPE cndp_url,
y_url TYPE cndp_url.
DATA:stock_url(20) TYPE c.
DATA:ok_code LIKE sy-ucomm.
DATA :
ls_layout TYPE slis_layout_alv,
lt_sort TYPE slis_t_sortinfo_alv,
ls_sort TYPE slis_sortinfo_alv,
lt_event_exit TYPE slis_t_event_exit,
ls_event_exit TYPE slis_event_exit.
*-----------------------*
* ALV SYSTEM VARIABLES *
*-----------------------*
DATA: fieldtab TYPE slis_t_fieldcat_alv,
wa_fieldtab TYPE LINE OF slis_t_fieldcat_alv,
heading TYPE slis_t_listheader,
layout TYPE slis_layout_alv,
events TYPE slis_t_event,
excluding TYPE slis_t_extab,
filter TYPE slis_t_filter_alv,
repname LIKE sy-repid VALUE sy-repid,
f2code LIKE sy-ucomm VALUE '&ETA',
g_save TYPE c,
g_exit TYPE c,
g_variant LIKE disvariant,
gx_variant LIKE disvariant.
FIELD-SYMBOLS: TYPE STANDARD TABLE,
,
.
DATA: dy_table TYPE REF TO data,
dy_line TYPE REF TO data,
xfc TYPE lvc_s_fcat,
ifc TYPE lvc_t_fcat.
DATA: num(6) TYPE c.
DATA: BEGIN OF wa_num,
num(6) TYPE c,
END OF wa_num.
DATA: BEGIN OF wa_lin,
str TYPE string,
END OF wa_lin.
DATA: it_num LIKE TABLE OF wa_num WITH HEADER LINE,
it_res LIKE TABLE OF wa_lin WITH HEADER LINE.
DATA: tmp_num(6) TYPE n,
idx TYPE i,
idx_tmp TYPE i.
TYPES: BEGIN OF ty_list,
fl(30),
END OF ty_list.
DATA: it_list TYPE TABLE OF ty_list WITH HEADER LINE.
TYPES: BEGIN OF ty_sina_live,
sname TYPE char20,"股票名字
topen TYPE char20,"今日开盘价
yclose TYPE char20,"昨日收盘价;
cprice TYPE char20,"当前价格;
thigh TYPE char20,"当日最高价
tlow TYPE char20,"今日最低价
buy TYPE char20,"竞买价,即“买一”报价;
sale TYPE char20,"竞卖价,即“卖一”报价;
number TYPE char20,"成交的股票数
buy11 TYPE char20,"买一,数量
buy12 TYPE char20,"买一,报价
buy21 TYPE char20,"买二,数量
buy22 TYPE char20,"买二,报价
buy31 TYPE char20,"买三,数量
buy32 TYPE char20,"买三,报价
buy41 TYPE char20,"买四,数量
buy42 TYPE char20,"买四,报价
buy51 TYPE char20,"买五,数量
buy52 TYPE char20,"买五,报价
sale11 type char20,"卖一,数量
sale12 type char20,"卖一,报价
sale21 type char20,"卖二,数量
sale22 type char20,"卖二,报价
sale31 type char20,"卖三,数量
sale32 type char20,"卖三,报价
sale41 type char20,"卖四,数量
sale42 type char20,"卖四,报价
sale51 type char20,"卖五,数量
sale52 type char20,"卖五,报价
date type char20,"日期
time type char20,"时间
END OF ty_sina_live.
*----------------------------------------------------------------------*
* CLASS lcl_receiver DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
handle_finished FOR EVENT finished OF cl_gui_timer.
ENDCLASS. "lcl_receiver DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_receiver IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_receiver IMPLEMENTATION.
METHOD handle_finished.
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code = '&NTE'.
ENDMETHOD. "handle_finished
ENDCLASS. "lcl_receiver IMPLEMENTATION
DATA: receiver TYPE REF TO lcl_receiver,
timer TYPE REF TO cl_gui_timer.
DEFINE init_field.
clear &1.
&1-fieldname = &2.
&1-reptext_ddic = &3.
&1-hotspot = &4.
if &5 = 'X'.
&1-emphasize = 'X'.
endif.
append &1 to fieldtab.
END-OF-DEFINITION.
DEFINE init_ifc.
clear xfc.
xfc-fieldname = &1.
xfc-datatype = &2.
xfc-inttype = &3.
xfc-intlen = &4.
xfc-decimals = &5.
xfc-hotspot = &6.
append xfc to ifc.
END-OF-DEFINITION.
SELECT-OPTIONS:
s_num FOR num.
INITIALIZATION.
*默认自己设的变式U+登录用户名
PERFORM init_variant.
START-OF-SELECTION .
CREATE OBJECT timer.
CREATE OBJECT receiver.
SET HANDLER receiver->handle_finished FOR timer.
timer->interval = 5.
PERFORM set_number.
PERFORM read_data.
PERFORM write_grid_output.
*&---------------------------------------------------------------------*
*& Form READ_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM read_data.
PERFORM send_http TABLES it_num it_res.
PERFORM build_filedcat1.
PERFORM process_data.
CALL METHOD timer->run.
ENDFORM. "READ_DATA
*&---------------------------------------------------------------------*
*& Form send_http
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PT_NUM text
* -->RT_TAB text
*----------------------------------------------------------------------*
FORM send_http TABLES pt_num STRUCTURE wa_num rt_tab STRUCTURE wa_lin.
DATA: loc_conv TYPE REF TO cl_abap_conv_in_ce,
http_client TYPE REF TO if_http_client,
abap_encoding TYPE abap_encoding,
l_str TYPE string,
l_xstr TYPE xstring,
l_tmp TYPE string,
l_url TYPE string,
l_result TYPE string,
r_str TYPE string.
DATA: result_tab TYPE TABLE OF string WITH HEADER LINE.
IF pt_num[] IS INITIAL.
RETURN.
ENDIF.
CLEAR:it_res.
REFRESH:it_res.
LOOP AT pt_num.
CLEAR l_tmp.
IF pt_num-num(1) < 6.
CONCATENATE 'sz' pt_num-num INTO l_tmp.
ENDIF.
IF pt_num-num(1) = '6'.
CONCATENATE 'sh' pt_num-num INTO l_tmp.
ENDIF.
CONCATENATE l_str l_tmp INTO l_str SEPARATED BY ','.
ENDLOOP.
IF l_str(1) = ','.
SHIFT l_str LEFT DELETING LEADING ','.
ENDIF.
CONCATENATE '' l_str INTO l_url .
CALL METHOD cl_http_client=>create_by_url
EXPORTING
url = l_url
IMPORTING
client = http_client
EXCEPTIONS
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
OTHERS = 4.
CALL METHOD http_client->request->set_header_field
EXPORTING
name = 'Content-Type'
value = 'text/html;charset=utf-8'."发送字符串时只能用utf-8编码
CALL METHOD http_client->send
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2.
CALL METHOD http_client->receive
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3.
CLEAR l_result .
l_xstr = http_client->response->get_data( ).
* l_str = http_client->response->get_data( ).
IF sy-subrc = 0 .
http_client->close( ).
ENDIF.
CALL METHOD cl_abap_conv_in_ce=>create
EXPORTING
input = l_xstr
encoding = '8400'
replacement = '?'
ignore_cerr = abap_true
RECEIVING
conv = loc_conv.
TRY.
CALL METHOD loc_conv->read
IMPORTING
data = l_str.
CATCH cx_sy_conversion_codepage.
CATCH cx_sy_codepage_converter_init.
CATCH cx_parameter_invalid_type.
CATCH cx_parameter_invalid_range.
ENDTRY.
* SPLIT l_str AT 'var' INTO TABLE rt_tab .
* write w_result. "这样会输出乱码
REFRESH result_tab .
* SPLIT l_str AT cl_abap_char_utilities=>cr_lf INTO TABLE result_tab .
SPLIT l_str AT cl_abap_char_utilities=>newline INTO TABLE result_tab .
* SPLIT l_str AT '#' INTO TABLE result_tab .
* READ TABLE result_tab INTO r_str INDEX 1.
DATA: line LIKE LINE OF rt_tab.
DATA: lv_len TYPE int4.
LOOP AT result_tab.
line-str = result_tab.
* lv_len = strlen( line-str ).
* lv_len = lv_len - 11.
* line-str = line-str+11(lv_len).
* shift line-str LEFT DELETING LEADING ''
APPEND line TO rt_tab.
* APPEND result_tab to rt_tab.
* append r_str to rt_tab.
* APPEND rt_tab.
ENDLOOP.
* rt_tab[] = result_tab[].
ENDFORM. "send_http
FORM build_filedcat1.
IF ifc IS INITIAL.
init_ifc 'SCODE' 'CHAR' 'C' 6 0 'X'.
init_ifc 'SNAME' 'CHAR' 'C' 20 0 'X'.
init_ifc 'TOPEN' 'CHAR' 'C' 20 0 ' '.
init_ifc 'YCLOSE' 'CHAR' 'C' 20 0 ' '.
init_ifc 'CPRICE' 'CHAR' 'C' 20 0 ' '.
init_ifc 'THIGH' 'CHAR' 'C' 20 0 ' '.
init_ifc 'TLOW' 'CHAR' 'C' 20 0 ' '.
init_ifc 'BUY' 'CHAR' 'C' 20 0 ' '.
init_ifc 'SALE' 'CHAR' 'C' 20 0 ' '.
init_ifc 'NUMBER' 'CHAR' 'C' 20 0 ' '.
init_ifc 'AMOUNT' 'CHAR' 'C' 20 0 ' '.
init_ifc 'BUY11' 'CHAR' 'C' 20 0 ' '.
init_ifc 'BUY12' 'CHAR' 'C' 20 0 ' '.
init_ifc 'BUY21' 'CHAR' 'C' 20 0 ' '.
init_ifc 'BUY22' 'CHAR' 'C' 20 0 ' '.
init_ifc 'BUY31' 'CHAR' 'C' 20 0 ' '.
init_ifc 'BUY32' 'CHAR' 'C' 20 0 ' '.
init_ifc 'BUY41' 'CHAR' 'C' 20 0 ' '.
init_ifc 'BUY42' 'CHAR' 'C' 20 0 ' '.
init_ifc 'BUY51' 'CHAR' 'C' 20 0 ' '.
init_ifc 'BUY52' 'CHAR' 'C' 20 0 ' '.
init_ifc 'SALE11' 'CHAR' 'C' 20 0 ' '.
init_ifc 'SALE12' 'CHAR' 'C' 20 0 ' '.
init_ifc 'SALE21' 'CHAR' 'C' 20 0 ' '.
init_ifc 'SALE22' 'CHAR' 'C' 20 0 ' '.
init_ifc 'SALE31' 'CHAR' 'C' 20 0 ' '.
init_ifc 'SALE32' 'CHAR' 'C' 20 0 ' '.
init_ifc 'SALE41' 'CHAR' 'C' 20 0 ' '.
init_ifc 'SALE42' 'CHAR' 'C' 20 0 ' '.
init_ifc 'SALE51' 'CHAR' 'C' 20 0 ' '.
init_ifc 'SALE52' 'CHAR' 'C' 20 0 ' '.
init_ifc 'DATE' 'CHAR' 'C' 20 0 ' '.
init_ifc 'TIME' 'CHAR' 'C' 20 0 ' '.
*颜色控制
CLEAR xfc.
xfc-fieldname = 'T_CELLCOLORS'.
xfc-ref_field = 'COLTAB'.
xfc-ref_table = 'CALENDAR_TYPE'.
APPEND xfc TO ifc.
*
***ALV field category
init_field wa_fieldtab 'SCODE' '代码' 'X' '' .
init_field wa_fieldtab 'SNAME' '名称' 'X' '' .
init_field wa_fieldtab 'TOPEN' '开盘价' '' '' .
init_field wa_fieldtab 'YCLOSE' '昨收价' '' '' .
init_field wa_fieldtab 'CPRICE' '现价' '' '' .
init_field wa_fieldtab 'THIGH' '最高价' '' '' .
init_field wa_fieldtab 'TLOW' '最低价' '' '' .
init_field wa_fieldtab 'BUY' '买一价' '' '' .
init_field wa_fieldtab 'SALE' '卖一价' '' '' .
init_field wa_fieldtab 'NUMBER' '成交数量' '' '' .
init_field wa_fieldtab 'AMOUNT' '成交金额' '' '' .
init_field wa_fieldtab 'BUY11' '买一数量' '' '' .
init_field wa_fieldtab 'BUY12' '买一金额' '' '' .
init_field wa_fieldtab 'BUY21' '买二数量' '' '' .
init_field wa_fieldtab 'BUY22' '买二金额' '' '' .
init_field wa_fieldtab 'BUY31' '买三数量' '' '' .
init_field wa_fieldtab 'BUY32' '买三金额' '' '' .
init_field wa_fieldtab 'BUY41' '买四数量' '' '' .
init_field wa_fieldtab 'BUY42' '买四金额' '' '' .
init_field wa_fieldtab 'BUY51' '买五数量' '' '' .
init_field wa_fieldtab 'BUY52' '买五金额' '' '' .
init_field wa_fieldtab 'SALE11' '卖一数量' '' '' .
init_field wa_fieldtab 'SALE12' '卖一金额' '' '' .
init_field wa_fieldtab 'SALE21' '卖二数量' '' '' .
init_field wa_fieldtab 'SALE22' '卖二金额' '' '' .
init_field wa_fieldtab 'SALE31' '卖三数量' '' '' .
init_field wa_fieldtab 'SALE32' '卖三金额' '' '' .
init_field wa_fieldtab 'SALE41' '卖四数量' '' '' .
init_field wa_fieldtab 'SALE42' '卖四金额' '' '' .
init_field wa_fieldtab 'SALE51' '卖五数量' '' '' .
init_field wa_fieldtab 'SALE52' '卖五金额' '' '' .
init_field wa_fieldtab 'DATE' '日期' '' '' .
init_field wa_fieldtab 'TIME' '时间' '' '' .
* Create dynamic internal table and assign to FS
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = ifc
IMPORTING
ep_table = dy_table.
ASSIGN dy_table->* TO .
* Create dynamic work area and assign to FS
CREATE DATA dy_line LIKE LINE OF .
ASSIGN dy_line->* TO .
ELSE.
CLEAR .
REFRESH: .
ENDIF.
endform .
*&---------------------------------------------------------------------*
*& Form build_fieldcat
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM build_fieldcat.
IF ifc IS INITIAL.
init_ifc 'STNUM' 'CHAR' 'C' 6 0 'X'.
init_ifc 'STNAM' 'CHAR' 'C' 20 0 ' '.
init_ifc 'OPPRI' 'CHAR' 'C' 20 0 ' '. " openning price
init_ifc 'CLPRI' 'CHAR' 'C' 20 0 ' '. " closing price of last day
init_ifc 'CRPRI' 'CHAR' 'C' 20 0 ' '. " current price
init_ifc 'HIPRI' 'CHAR' 'C' 20 0 ' '. " high price
init_ifc 'LOPRI' 'CHAR' 'C' 20 0 ' '. " low price
init_ifc 'BYPRI' 'CHAR' 'C' 20 0 ' '. " buying price 1
init_ifc 'SLPRI' 'CHAR' 'C' 20 0 ' '. " selling price 1
init_ifc 'DUQTY' 'CHAR' 'C' 30 0 ' '. " due quantity
init_ifc 'DUAMT' 'CHAR' 'C' 30 0 ' '. " due amount
*颜色控制
CLEAR xfc.
xfc-fieldname = 'T_CELLCOLORS'.
xfc-ref_field = 'COLTAB'.
xfc-ref_table = 'CALENDAR_TYPE'.
APPEND xfc TO ifc.
*
***ALV field category
init_field wa_fieldtab 'STNUM' '代码' 'X' '' .
init_field wa_fieldtab 'STNAM' '名称' '' '' .
init_field wa_fieldtab 'OPPRI' '开盘价' '' '' .
init_field wa_fieldtab 'CLPRI' '昨日收盘价' '' '' .
init_field wa_fieldtab 'CRPRI' '现价' '' '' .
init_field wa_fieldtab 'HIPRI' '最高价' '' '' .
init_field wa_fieldtab 'LOPRI' '最低价' '' '' .
init_field wa_fieldtab 'BYPRI' '买一价' '' '' .
init_field wa_fieldtab 'SLPRI' '卖一价' '' '' .
init_field wa_fieldtab 'DUQTY' '成交数' '' '' .
init_field wa_fieldtab 'DUAMT' '成交金额' '' '' .
* Create dynamic internal table and assign to FS
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = ifc
IMPORTING
ep_table = dy_table.
ASSIGN dy_table->* TO .
* Create dynamic work area and assign to FS
CREATE DATA dy_line LIKE LINE OF .
ASSIGN dy_line->* TO .
ELSE.
CLEAR .
REFRESH: .
ENDIF.
ENDFORM. " BUILD_FIELDCAT
*&---------------------------------------------------------------------*
*& Form write_grid_output
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM write_grid_output.
DEFINE m_sort.
add 1 to ls_sort-spos.
ls_sort-fieldname = &1.
append ls_sort to lt_sort.
END-OF-DEFINITION.
DEFINE m_event_exit.
clear ls_event_exit.
ls_event_exit-ucomm = &1.
ls_event_exit-after = 'X'.
append ls_event_exit to lt_event_exit.
END-OF-DEFINITION.
m_event_exit '&NTE'. " Refresh
ls_layout-zebra = 'X'.
ls_layout-colwidth_optimize = 'X'.
m_sort 'SCODE'.
g_save = 'A'.
ls_layout-coltab_fieldname = 'T_CELLCOLORS'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-cprog
i_callback_user_command = 'USER_COMMAND'
is_layout = ls_layout
it_fieldcat = fieldtab
i_default = 'A'
i_save = g_save
it_sort = lt_sort
it_event_exit = lt_event_exit
TABLES
t_outtab = .
IF sy-subrc <> 0.
WRITE: 'SY-SUBRC: ', sy-subrc, 'REUSE_ALV_GRID_DISPLAY'.
ENDIF.
ENDFORM. " WRITE_GRID_OUTPUT
*&---------------------------------------------------------------------*
*& Form process_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM process_data .
FIELD-SYMBOLS: TYPE lvc_t_scol.
DATA:wa_cellcolors TYPE LINE OF lvc_t_scol.
DATA:xj TYPE p DECIMALS 2,
zj TYPE p DECIMALS 2.
LOOP AT it_res.
CLEAR it_list[].
IF strlen( it_res-str ) < 30.
CONTINUE.
ENDIF.
CLEAR:xj,zj.
SPLIT it_res-str AT ',' INTO TABLE it_list .
"代码
READ TABLE it_list INDEX 1.
idx = 1.
ASSIGN COMPONENT idx
OF STRUCTURE TO .
= it_list-fl+13(6).
"名称
idx = 2.
ASSIGN COMPONENT idx
OF STRUCTURE TO .
= it_list-fl+21.
idx = 2.
WHILE idx < 33.
READ TABLE it_list INDEX idx.
idx = idx + 1.
ASSIGN COMPONENT idx
OF STRUCTURE TO .
= it_list-fl.
IF idx = 4.
zj = .
ENDIF.
IF idx = 5.
xj = .
ENDIF.
ENDWHILE.
ASSIGN COMPONENT 'T_CELLCOLORS'
OF STRUCTURE TO .
CLEAR:wa_cellcolors.
IF zj >= xj.
wa_cellcolors-color-col = '5'. "跌
ELSE.
wa_cellcolors-color-col = '6'. "涨
ENDIF.
APPEND wa_cellcolors TO .
APPEND TO .
CLEAR .
ENDLOOP.
ENDFORM. " process_data
*&---------------------------------------------------------------------*
*& Form set_number
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM set_number .
LOOP AT s_num.
CLEAR it_num.
IF s_num-option = 'EQ' .
IF s_num-low <> '' .
it_num-num = s_num-low.
APPEND it_num.
ENDIF.
IF s_num-high <> '' .
it_num-num = s_num-high.
APPEND it_num.
ENDIF.
ENDIF.
IF s_num-option = 'BT'.
tmp_num = s_num-low.
WHILE tmp_num <= s_num-high.
CLEAR it_num.
it_num-num = tmp_num.
APPEND it_num.
tmp_num = tmp_num + 1.
ENDWHILE.
ENDIF.
ENDLOOP.
ENDFORM. " set_number
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS'.
*分时图
IF f_picture IS INITIAL.
CREATE OBJECT f_container
EXPORTING
container_name = 'F_CONTROL'.
CREATE OBJECT f_picture
EXPORTING
parent = f_container.
CALL METHOD f_picture->set_3d_border
EXPORTING
border = 1.
CALL METHOD f_picture->load_picture_from_url_async
EXPORTING
url = f_url.
ELSE.
CALL METHOD f_picture->load_picture_from_url_async
EXPORTING
url = f_url.
ENDIF.
*日K线图
IF r_picture IS INITIAL.
CREATE OBJECT r_container
EXPORTING
container_name = 'R_CONTROL'.
CREATE OBJECT r_picture
EXPORTING
parent = r_container.
CALL METHOD r_picture->set_3d_border
EXPORTING
border = 1.
CALL METHOD r_picture->load_picture_from_url_async
EXPORTING
url = r_url.
ELSE.
CALL METHOD r_picture->load_picture_from_url_async
EXPORTING
url = r_url.
ENDIF.
*周K线图
IF z_picture IS INITIAL.
CREATE OBJECT z_container
EXPORTING
container_name = 'Z_CONTROL'.
CREATE OBJECT z_picture
EXPORTING
parent = z_container.
CALL METHOD z_picture->set_3d_border
EXPORTING
border = 1.
CALL METHOD z_picture->load_picture_from_url_async
EXPORTING
url = z_url.
ELSE.
CALL METHOD z_picture->load_picture_from_url_async
EXPORTING
url = z_url.
ENDIF.
*月K线图
IF y_picture IS INITIAL.
CREATE OBJECT y_container
EXPORTING
container_name = 'Y_CONTROL'.
CREATE OBJECT y_picture
EXPORTING
parent = y_container.
CALL METHOD y_picture->set_3d_border
EXPORTING
border = 1.
CALL METHOD y_picture->load_picture_from_url_async
EXPORTING
url = y_url.
ELSE.
CALL METHOD y_picture->load_picture_from_url_async
EXPORTING
url = y_url.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Form F_USER_COMMAND
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->R_UCOMM text
* -->RS_SELFIELD text
*----------------------------------------------------------------------*
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
CASE r_ucomm.
WHEN '&IC1'.
CLEAR: f_url,z_url,r_url,y_url.
f_url = 'http://image.sinajs.cn/newchart/min/n/'.
z_url = 'http://image.sinajs.cn/newchart/weekly/n/'.
r_url = 'http://image.sinajs.cn/newchart/daily/n/'.
y_url = 'http://image.sinajs.cn/newchart/monthly/n/'.
CHECK rs_selfield-fieldname CS 'SCODE'.
IF rs_selfield-value+0(1) = 0.
CONCATENATE 'sz' rs_selfield-value '.gif' INTO stock_url.
ELSE.
CONCATENATE 'sh' rs_selfield-value '.gif' INTO stock_url.
ENDIF.
CHECK stock_url IS NOT INITIAL.
CONCATENATE f_url stock_url INTO f_url.
CONCATENATE z_url stock_url INTO z_url.
CONCATENATE y_url stock_url INTO y_url.
CONCATENATE r_url stock_url INTO r_url.
CALL SCREEN 0100.
WHEN '&NTE'.
PERFORM read_data.
rs_selfield-refresh = 'X'.
CALL METHOD timer->run.
ENDCASE.
ENDFORM. "F_USER_COMMAND
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_EXIT INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_exit INPUT.
CASE ok_code.
WHEN 'EXIT' OR 'BACK' OR 'CANC'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_EXIT INPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
CASE ok_code.
WHEN 'REF'.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Form INIT_VARIANT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM init_variant .
DATA: h_variant LIKE rsvar-variant.
DATA: h_subrc LIKE sy-subrc.
CLEAR: h_variant,h_subrc .
CHECK sy-tcode <> 'SE38' AND sy-tcode <> 'SA38' .
h_variant = 'U_'.
WRITE sy-uname TO h_variant+2.
CALL FUNCTION 'RS_VARIANT_EXISTS'
EXPORTING
report = sy-repid
variant = h_variant
IMPORTING
r_c = h_subrc.
IF h_subrc = 0.
* g_feldlist-g_var_flag = 'X'.
CALL FUNCTION 'RS_SUPPORT_SELECTIONS'
EXPORTING
report = sy-repid
variant = h_variant
EXCEPTIONS
variant_not_existent = 01
variant_obsolete = 02.
ENDIF.
ENDFORM. " INIT_VARIANT
阅读(4054) | 评论(1) | 转发(0) |