1.显示/查找SAP所有可执行程序清单,双击事务码执行、
*&---------------------------------------------------------------------*
*& Report ZCHENH004
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------* REPORT zchenh004.
TABLES: trdir, tstc.
DATA: BEGIN OF gs_data,
sel TYPE boolean, " 用于选择多行
name TYPE trdir-name, " 程序名
subc TYPE trdir-subc, " 程序类型
rstat TYPE trdir-rstat, " 状态
tcode TYPE tstc-tcode, " 事务码
ttext TYPE tstct-ttext, " 事务码描述
cnam TYPE trdir-cnam, " 创建者
cdat TYPE trdir-cdat, " 创建日期
unam TYPE trdir-unam, " 最后修改人
udat TYPE trdir-udat, " 修改日期
END OF gs_data.
DATA: gt_data LIKE TABLE OF gs_data. " ALV显示內表
DATA: line TYPE i." ALV行数
" 选择屏幕
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-.
SELECT-OPTIONS: s_name FOR trdir-name, " 程序名
s_tcode FOR tstc-tcode, " 事务码
s_cnam FOR trdir-cnam, " 创建者
s_unam FOR trdir-unam, " 最后修改人
s_subc FOR trdir-subc DEFAULT , " 程序类型
s_rstat FOR trdir-rstat. " 状态
SELECTION-SCREEN END OF BLOCK b1.
" F8事件 START-OF-SELECTION.
IF s_name[] IS INITIAL AND " 程序名
s_cnam[] IS INITIAL AND " 创建者
s_unam[] IS INITIAL AND " 最后修改人
s_subc[] IS INITIAL AND " 程序类型
s_tcode[] IS INITIAL AND " 事务码
s_rstat[] IS INITIAL. " 状态 MESSAGE '请至少输入一个条件!' TYPE 'S' DISPLAY LIKE 'E'.
EXIT.
ENDIF.
PERFORM get_data.
IF gt_data[] IS INITIAL.
MESSAGE '无符合条件的记录' TYPE 'S' DISPLAY LIKE 'E'.
EXIT.
ENDIF.
PERFORM alv_data.
*&---------------------------------------------------------------------*
*& Form get_data
*&---------------------------------------------------------------------*
* text 获取数据
*----------------------------------------------------------------------*
FORM get_data.
DATA: BEGIN OF ls_tstc,
tcode TYPE tstc-tcode,
ttext TYPE tstct-ttext,
END OF ls_tstc. DATA: lt_tstc LIKE TABLE OF ls_tstc.
" 输入事务码时
IF s_tcode[] IS NOT INITIAL.
SELECT a~tcode
b~name
b~subc
b~rstat
b~cnam
b~cdat
b~unam
b~udat
c~ttext
INTO CORRESPONDING FIELDS OF TABLE gt_data
FROM tstc AS a
INNER JOIN trdir AS b ON a~pgmna = b~name
INNER JOIN tstct AS c ON a~tcode = c~tcode
WHERE a~tcode IN s_tcode
AND b~name IN s_name " 程序名
AND b~cnam IN s_cnam " 创建者
AND b~unam IN s_unam " 最后修改人
AND b~subc IN s_subc " 程序类型
AND b~rstat IN s_rstat. " 状态
ELSE.
" 没有输入事务码时
SELECT
a~name
a~subc
a~rstat
a~cnam
a~cdat
a~unam
a~udat
b~tcode
INTO CORRESPONDING FIELDS OF TABLE gt_data
FROM trdir AS a
LEFT JOIN tstc AS b ON a~name = b~pgmna
WHERE a~name IN s_name " 程序名
AND a~cnam IN s_cnam " 创建者
AND a~unam IN s_unam " 最后修改人
AND a~subc IN s_subc " 程序类型
AND a~rstat IN s_rstat. " 状态 IF gt_data[] IS NOT INITIAL.
" 查询事务码描述文本
SELECT
tcode
ttext
INTO CORRESPONDING FIELDS OF TABLE lt_tstc
FROM tstct
FOR ALL ENTRIES IN gt_data
WHERE tcode = gt_data-tcode. SORT lt_tstc BY tcode." 先排序
LOOP AT gt_data INTO gs_data.
READ TABLE lt_tstc INTO ls_tstc WITH KEY tcode = gs_data-tcode BINARY SEARCH.
IF sy-subrc EQ .
gs_data-ttext = ls_tstc-ttext.
MODIFY gt_data FROM gs_data TRANSPORTING ttext.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
" 统计內表行数
DESCRIBE TABLE gt_data LINES line.
" 排序
SORT gt_data BY cnam cdat.
ENDFORM. "get_data
*&---------------------------------------------------------------------*
*& Form alv_data
*&---------------------------------------------------------------------*
* text 显示ALV数据
*----------------------------------------------------------------------*
FORM alv_data.
DATA: fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
layout TYPE slis_layout_alv. PERFORM get_layout CHANGING layout. " alv布局
PERFORM get_fieldcat TABLES fieldcat. " 控制报表显示哪些栏位 CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid " 程序名
is_layout = layout " 布局
i_callback_pf_status_set = 'PFSTATUS_FORM' " STATUS
i_callback_user_command = 'USER_COMMAND_FORM' " 定义按钮的功能
it_fieldcat = fieldcat[] " alv栏目(显示字段)内表
TABLES
t_outtab = gt_data " 将内表数据赋给ALV
EXCEPTIONS
program_error =
OTHERS = .
IF sy-subrc <> .
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. "alv_data
*&---------------------------------------------------------------------*
*& Form get_layout
*&---------------------------------------------------------------------*
* text ALV布局设置
*----------------------------------------------------------------------*
* -->C_LAYOUT text
*----------------------------------------------------------------------*
FORM get_layout CHANGING c_layout TYPE slis_layout_alv.
CLEAR: c_layout.
c_layout-colwidth_optimize = 'X'." 宽度自动调节
c_layout-box_fieldname = 'SEL'. " 选择多行
c_layout-zebra = 'X'. " 颜色交替显示
ENDFORM. "get_layout
*&---------------------------------------------------------------------*
*& Form USER_COMMAND_FORM
*&---------------------------------------------------------------------*
* text 自定义按钮功能
*----------------------------------------------------------------------*
* -->R_UCOMM text
* -->RS_SELFIELD text
*----------------------------------------------------------------------*
FORM user_command_form USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
READ TABLE gt_data INTO gs_data INDEX rs_selfield-tabindex.
IF sy-subrc EQ AND gs_data-tcode IS NOT INITIAL.
CASE r_ucomm.
WHEN '&IC1'. " 双击事件
CALL TRANSACTION gs_data-tcode. " 调用事务码,运行程序
WHEN OTHERS.
MESSAGE '双击事务码执行' TYPE 'S'.
ENDCASE.
ENDIF.
ENDFORM. "USER_COMMAND_FORM
*&---------------------------------------------------------------------*
*& Form get_fieldcat
*&---------------------------------------------------------------------*
* text 显示字段
*----------------------------------------------------------------------*
* -->CT_TAB text
*----------------------------------------------------------------------*
FORM get_fieldcat TABLES ct_tab TYPE slis_t_fieldcat_alv.
DATA: fcat TYPE slis_fieldcat_alv.
DEFINE add_fcat.
clear fcat.
fcat-fieldname = &. " 字段名
fcat-seltext_l = &. " 显示字段文本
fcat-seltext_m = &.
fcat-seltext_s = &.
fcat-key = &. " 主键
fcat-hotspot = &. " 链接
fcat-checkbox = &. " 复选框
fcat-edit = &. " 是否可修改
fcat-ref_tabname = &. " 参考表
fcat-ref_fieldname = &. " 参考表字段
append fcat to ct_tab.
END-OF-DEFINITION.
add_fcat 'NAME' '程序名' '' '' '' '' '' ''.
add_fcat 'SUBC' '程序类型' '' '' '' '' 'TRDIR' 'SUBC'.
add_fcat 'RSTAT' '状态' '' '' '' '' 'TRDIR' 'RSTAT'.
add_fcat 'TCODE' '事务码' '' '' '' '' '' ''.
add_fcat 'TTEXT' '事务码描述' '' '' '' '' '' ''.
add_fcat 'CNAM' '创建者' '' '' '' '' '' ''.
add_fcat 'CDAT' '创建日期' '' '' '' '' '' ''.
add_fcat 'UNAM' '最后修改人' '' '' '' '' '' ''.
add_fcat 'UDAT' '修改日期' '' '' '' '' '' ''.
ENDFORM. "get_fieldcat
*&---------------------------------------------------------------------*
*& Form pfstatus_form
*&---------------------------------------------------------------------*
* text STATUS
*----------------------------------------------------------------------*
* -->RT_EXTAB text
*----------------------------------------------------------------------*
FORM pfstatus_form USING rt_extab TYPE slis_t_extab.
SET TITLEBAR 'ZCHENH004' WITH line. " 标题
SET PF-STATUS 'ZCHENH004'. " 工具条
ENDFORM. "pfstatus_form </span>
2.程序异常捕获,防止出现ST22的dump页面
*&---------------------------------------------------------------------*
*& Report ZCHENH005
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------* REPORT zchenh005.
DATA:gv_test TYPE i ,
err_text TYPE string,
e TYPE REF TO cx_root.
*捕获异常
TRY.
gv_test = 'X'.
EXIT.
CATCH cx_root INTO e.
err_text = e->get_text( ).
WRITE:err_text. ENDTRY.
TRY.
gv_test = / .
EXIT.
CATCH cx_root INTO e.
err_text = e->get_text( ).
WRITE:err_text.
CLEANUP. * RAISE EXCEPTION e. " 使界面红掉
"
ENDTRY.
*&---------------------------------------------------------------------*
*& Report ZCHENH017
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------* REPORT zchenh017.
DATA:gv_test TYPE i ,
err_text TYPE string,
e TYPE REF TO cx_root.
TRY.
gv_test = 'X'.
* 正常代码部分
*
*
*
* EXIT.
CATCH cx_root INTO e.
err_text = e->get_text( ).
IF sy-batch = 'X'.
WRITE:'后台异常测试:',err_text.
ELSE.
WRITE:'前台异常测试:',err_text.
ENDIF.
CLEANUP.
CLEAR:err_text.
ENDTRY.
WRITE:'前台异常测试:',err_text.
3.ALV快速开发,需要在SE41中拷贝标准状态栏,
*&---------------------------------------------------------------------*
*& Report ZCHENH007
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------* REPORT zchenh007.
TABLES:zchenh001.
DATA:gs_data TYPE zchenh001,
gt_data TYPE zchenh001 OCCURS WITH HEADER LINE.
DATA:BEGIN OF gt_alv OCCURS .
DATA :box(),
exception().
INCLUDE TYPE zchenh001.
DATA END OF gt_alv. PERFORM frm_insert_data.
PERFORM frm_show_data. *&---------------------------------------------------------------------*
*& Form FRM_INSERT_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_insert_data . DO TIMES.
CLEAR:gs_data,gt_data.
gs_data-znum = sy-index.
CONCATENATE '陈辉' 'Test' INTO gs_data-zname.
IF sy-index MOD EQ .
gs_data-zsex = '男'.
ELSE.
gs_data-zsex = '女'.
ENDIF.
gs_data-zhigh = ''.
APPEND gs_data TO gt_data.
ENDDO. * 更新数据库表 等待千分之一秒后提交数据库
MODIFY zchenh001 FROM TABLE gt_data.
WAIT UP TO / SECONDS.
COMMIT WORK. * DELETE zchenh001 FROM TABLE gt_data.
LOOP AT gt_data.
MOVE-CORRESPONDING gt_data TO gt_alv.
gt_alv-exception = ''.
APPEND gt_alv.
ENDLOOP.
ENDFORM. " FRM_INSERT_DATA
*&---------------------------------------------------------------------*
*& Form FRM_SHOW_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_show_data .
DATA: fieldcat TYPE lvc_t_fcat WITH HEADER LINE,
l_grid_settings TYPE lvc_s_glay,
layout TYPE lvc_s_layo,
lv_title TYPE lvc_title.
PERFORM frm_build_fieldcat TABLES fieldcat.
lv_title = '数据展示'.
layout-excp_fname = 'EXCEPTION'.
layout-zebra = 'X'.
layout-cwidth_opt = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = sy-repid
is_layout_lvc = layout
it_fieldcat_lvc = fieldcat[]
i_callback_user_command = 'USER_COMMAND'
i_callback_pf_status_set = 'SET_PF_STATUS'
* i_callback_html_top_of_page = 'TOP_OF_PAGE' "调用TOP_OF_PAGE FORM
i_grid_settings = l_grid_settings
i_grid_title = lv_title
i_save = 'U'
* IT_EVENTS = GT_EVENTS[]
TABLES
t_outtab = gt_alv[]
EXCEPTIONS
program_error =
OTHERS = .
ENDFORM. " FRM_SHOW_DATA
*&---------------------------------------------------------------------*
*& Form FRM_BUILD_FIELDCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_FIELDCAT text
*----------------------------------------------------------------------*
FORM frm_build_fieldcat TABLES fieldcat.
DATA: lt_fieldcat TYPE lvc_t_fcat WITH HEADER LINE.
DEFINE add2fc.
lt_fieldcat-fieldname = &.
lt_fieldcat-scrtext_l = &.
lt_fieldcat-edit = &.
lt_fieldcat-checkbox = &.
lt_fieldcat-ref_table = &.
lt_fieldcat-ref_field = &.
lt_fieldcat-no_zero = 'X'.
lt_fieldcat-fix_column = &.
lt_fieldcat-hotspot = &.
lt_fieldcat-outputlen = .
append lt_fieldcat.
clear lt_fieldcat.
END-OF-DEFINITION.
add2fc:
'BOX' '复选框' 'X' 'X' '' '' 'X' '',
'ZNUM' '序号' '' '' '' '' 'X' '',
'ZNAME' '姓名' '' '' '' '' 'X' '',
'ZSEX' '性别' '' '' '' '' 'X' '',
'ZHIGH' '身高' '' '' '' '' 'X' ''.
fieldcat[] = lt_fieldcat[]. ENDFORM. " FRM_BUILD_FIELDCAT *&---------------------------------------------------------------------*
*& Form frm_set_pf_status_ALL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->RT_EXTAB text
*----------------------------------------------------------------------*
FORM set_pf_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'ZCHENH007'.
ENDFORM. "set_pf_status *&---------------------------------------------------------------------*
*& Form 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 '&F03' OR '&F15' OR '&F12'.
SET SCREEN .
LEAVE SCREEN.
WHEN '&PRINT'.
PERFORM frm_print_data.
WHEN 'ALL'.
LOOP AT gt_alv .
gt_alv-box = 'X'.
MODIFY gt_alv TRANSPORTING box.
ENDLOOP .
WHEN 'SAL'.
LOOP AT gt_alv.
gt_alv-box = ''.
MODIFY gt_alv TRANSPORTING box.
ENDLOOP .
WHEN OTHERS.
ENDCASE.
rs_selfield-refresh = 'X'.
ENDFORM. "frm_user_command_ALL *&---------------------------------------------------------------------*
*& Form FRM_PRINT_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_print_data .
DATA:lt_data TYPE zchenh001 OCCURS WITH HEADER LINE.
LOOP AT gt_alv WHERE box = 'X' AND exception = ''.
MOVE-CORRESPONDING gt_alv TO lt_data.
APPEND lt_data.
ENDLOOP.
EXPORT lt_data TO MEMORY ID 'GT_HEAD'.
ENDFORM. " FRM_PRINT_DATA
事务码:SE41 -> 状态
从程序:SAPLKKBL
状态:STANDARD_FULLSCREEN
到程序:XXXXXXXX
状态:XXXXXXXX
*&---------------------------------------------------------------------*
*& Report ZCHENH011
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------* REPORT zchenh011.
*声明表
* 定义内表 变量 常量 结构
DATA: BEGIN OF gt_alv OCCURS ,
col1 TYPE char50, " alv显示的字段一
col2 TYPE char50, " alv显示的字段二
col3 TYPE char50, " alv显示的字段三
col4 TYPE char50, " alv显示的字段四
exception,
id TYPE icon-id, " 图标
msg(),
END OF gt_alv.
*声明包含文件
*定义选择屏幕
*选择屏幕的PAI PBO
PERFORM frm_get_data.
PERFORM frm_pro_data.
PERFORM frm_show_data.
*&---------------------------------------------------------------------*
*& Form FRM_GET_DATA
*&---------------------------------------------------------------------*
* 从表中或者其他地方抓取数据
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_get_data . ENDFORM. " FRM_GET_DATA
*&---------------------------------------------------------------------*
*& Form FRM_PRO_DATA
*&---------------------------------------------------------------------*
* 对数据进行处理 加工
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_pro_data .
DATA:lv_id TYPE icon-id.
SELECT SINGLE id INTO lv_id FROM icon WHERE name = icon_led_green.
DO TIMES.
gt_alv-col1 = sy-index.
gt_alv-col2 = sy-index + sy-index.
gt_alv-col3 = sy-index * sy-index.
gt_alv-col4 = sy-index MOD .
gt_alv-exception = .
gt_alv-msg = 'OK!'.
gt_alv-id = lv_id.
APPEND gt_alv.
ENDDO.
ENDFORM. " FRM_PRO_DATA
*&---------------------------------------------------------------------*
*& Form FRM_SHOW_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_show_data .
DATA: fieldcat TYPE lvc_t_fcat WITH HEADER LINE,
l_grid_settings TYPE lvc_s_glay,
layout TYPE lvc_s_layo,
lv_title TYPE lvc_title.
PERFORM frm_build_fieldcat TABLES fieldcat.
lv_title = '数据展示'.
layout-excp_fname = 'EXCEPTION'.
layout-zebra = 'X'.
layout-cwidth_opt = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = sy-repid
is_layout_lvc = layout
it_fieldcat_lvc = fieldcat[]
i_callback_user_command = 'USER_COMMAND'
i_callback_pf_status_set = 'SET_PF_STATUS'
* i_callback_html_top_of_page = 'TOP_OF_PAGE' "调用TOP_OF_PAGE FORM
i_grid_settings = l_grid_settings
i_grid_title = lv_title
i_save = 'U'
* IT_EVENTS = GT_EVENTS[]
TABLES
t_outtab = gt_alv[]
EXCEPTIONS
program_error =
OTHERS = .
ENDFORM. " FRM_SHOW_DATA
*&---------------------------------------------------------------------*
*& Form FRM_BUILD_FIELDCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_FIELDCAT text
*----------------------------------------------------------------------*
FORM frm_build_fieldcat TABLES fieldcat.
DATA: lt_fieldcat TYPE lvc_t_fcat WITH HEADER LINE.
DEFINE add2fc.
lt_fieldcat-fieldname = &.
lt_fieldcat-scrtext_l = &.
lt_fieldcat-edit = &.
lt_fieldcat-checkbox = &.
lt_fieldcat-ref_table = &.
lt_fieldcat-ref_field = &.
lt_fieldcat-no_zero = 'X'.
lt_fieldcat-fix_column = &.
lt_fieldcat-hotspot = &.
lt_fieldcat-icon = &.
lt_fieldcat-outputlen = .
append lt_fieldcat.
clear lt_fieldcat.
END-OF-DEFINITION.
add2fc:
'COL1' '字段一' '' '' '' '' 'X' '' '',
'COL2' '字段二' '' '' '' '' 'X' '' '',
'COL3' '字段三' '' '' '' '' 'X' '' '',
'COL4' '字段四' '' '' '' '' 'X' '' '',
'ID' '图标' '' '' '' '' 'X' '' 'X',
'MSG' '消息' '' '' '' '' 'X' '' ''.
fieldcat[] = lt_fieldcat[].
ENDFORM. " FRM_BUILD_FIELDCAT *&---------------------------------------------------------------------*
*& Form frm_set_pf_status_ALL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->RT_EXTAB text
*----------------------------------------------------------------------*
FORM set_pf_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'ZCHENH011'.
ENDFORM. "set_pf_status *&---------------------------------------------------------------------*
*& Form USER_COMMAND
*&---------------------------------------------------------------------*
* 用户在ALV上的命令
*----------------------------------------------------------------------*
* -->R_UCOMM text
* -->RS_SELFIELD text
*----------------------------------------------------------------------*
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
CASE r_ucomm.
WHEN '&F03' OR '&F15' OR '&F12'.
SET SCREEN .
LEAVE SCREEN.
WHEN OTHERS.
ENDCASE. rs_selfield-refresh = 'X'.
ENDFORM. "frm_user_command_ALL
4.有些SE11/SE16表不能修改表中数据时,
通过SE37 -> SE16N_INTERFACE
I_TAB:表名,
I_EDIT :X,
I_SAPEDIT:X
F8执行,选中需要删除或修改的数据
5.SAP中金额转为汉字
示例:100001.11 =》 壹拾万零壹元壹角壹分整
*&---------------------------------------------------------------------*
*& Report ZCHENH008
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------* REPORT zchenh008.
DATA:lv_in TYPE dmbtr,
lv_out TYPE string.
lv_in = '100001.11'.
*lv_in = 0 - lv_in.
PERFORM frm_conv_amount USING lv_in
CHANGING lv_out.
WRITE:/ lv_out.
*&---------------------------------------------------------------------*
*& Form frm_conv_amount
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->VALUE text
* -->(P_SOURCE) text
* -->VALUE text
* -->(P_RESULT) text
*----------------------------------------------------------------------*
FORM frm_conv_amount USING value(p_source)
CHANGING value(p_result). DATA: scr() TYPE c, res() TYPE c.
DATA: len TYPE i, c1 TYPE i, c2 TYPE i, c3 TYPE i.
DATA: d1() TYPE c, d2() TYPE c, d3 TYPE i.
DATA: digit() TYPE c, weight() TYPE c.
DATA: rule1() TYPE c VALUE '零壹贰叁肆伍陆柒捌玖'.
DATA: rule2() TYPE c VALUE '分角元拾佰仟万拾佰仟亿拾佰仟万拾佰仟'. scr = p_source * . CONDENSE scr NO-GAPS. IF scr = ''.
res = '零元'.
ELSE.
len = strlen( scr ).
c1 = .
d1 = ''. CLEAR res. DO len TIMES.
c1 = c1 + .
c2 = len - c1.
MOVE scr+c2() TO d2.
d3 = d2.
MOVE rule1+d3() TO digit.
c3 = ( c1 - ).
MOVE rule2+c3() TO weight.
IF d2 = ''.
IF c1 = .
digit = ''.
ELSEIF c1 = .
digit = ''.
ELSEIF d1 = ''.
digit = ''.
weight = ''.
ELSE.
weight = ''.
ENDIF.
ENDIF. CONCATENATE digit weight res INTO res.
d1 = d2. ENDDO.
ENDIF. CONCATENATE res '整' INTO p_result.
ENDFORM. "frm_conv_amount
6.SE24中使用自定义的类
*&---------------------------------------------------------------------*
*& Report ZCHENH009
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------* REPORT zchenh009.
DATA: object TYPE REF TO zchenh002.
DATA:speed TYPE i. START-OF-SELECTION. CREATE OBJECT object.
CALL METHOD object->show_speed.
CALL METHOD object->add_speed.
CALL METHOD object->show_speed.
speed = .
CALL METHOD object->set_speed
EXPORTING
speed_in = speed.
write:'程序中的Speed-->:',speed.
CLEAR:speed.
CALL METHOD object->add_speed.
CALL METHOD object->get_speed
IMPORTING
speed_out = speed.
write:'程序中的Speed-->:',speed.
7.模拟SM37后台JOB
*&---------------------------------------------------------------------*
*& Report ZCHENH010
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------* REPORT zchenh010.
DATA: jobcount LIKE tbtcjob-jobcount.
DATA: abort TYPE c,
finish TYPE c,
prelim TYPE c,
ready TYPE c,
run TYPE c,
sched TYPE c. PARAMETERS: p_name LIKE tbtcjob-jobname OBLIGATORY DEFAULT 'Z_BARRY_TEST_JOB',
p_date LIKE sy-datum OBLIGATORY,
p_time LIKE sy-uzeit OBLIGATORY,
p_varint LIKE raldb-variant. SELECT-OPTIONS s_rept FOR sy-repid NO INTERVALS OBLIGATORY . START-OF-SELECTION.
CALL FUNCTION 'JOB_OPEN' "定义一个Job
EXPORTING
jobname = p_name
IMPORTING
jobcount = jobcount "Job id
EXCEPTIONS
cant_create_job =
invalid_job_data =
jobname_missing =
OTHERS = .
IF sy-subrc <> .
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF. LOOP AT s_rept .
CALL FUNCTION 'JOB_SUBMIT' "Scheduled 这个Job
EXPORTING
authcknam = sy-uname
jobcount = jobcount
jobname = p_name
report = s_rept-low
variant = p_varint
EXCEPTIONS
bad_priparams =
bad_xpgflags =
invalid_jobdata =
jobname_missing =
job_notex =
job_submit_failed =
lock_failed =
program_missing =
prog_abap_and_extpg_set =
OTHERS = .
IF sy-subrc <> .
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDLOOP. CALL FUNCTION 'JOB_CLOSE' "Release 这个Job
EXPORTING
jobcount = jobcount
jobname = p_name
sdlstrtdt = p_date
sdlstrttm = p_time
EXCEPTIONS
cant_start_immediate =
invalid_startdate =
jobname_missing =
job_close_failed =
job_nosteps =
job_notex =
lock_failed =
OTHERS = .
IF sy-subrc <> .
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF. CALL FUNCTION 'SHOW_JOBSTATE'
EXPORTING
jobcount = jobcount
jobname = p_name
IMPORTING
aborted = abort
finished = finish
preliminary = prelim
ready = ready
running = run
scheduled = sched
EXCEPTIONS
jobcount_missing =
jobname_missing =
job_notex =
OTHERS = .
IF sy-subrc <> .
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF. WRITE : / 'Canceled :' , abort ,
/ 'Finished :' , finish,
/ 'Scheduled Temporarily :' , prelim,
/ 'Ready for Execution :' , ready,
/ 'Active :' , run,
/ 'Scheduling Released :' , sched.
8.内表转JSON字符串 ,JSON转ABAP内表
方法一:
*&---------------------------------------------------------------------*
*& Report ZCHENH012
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------* REPORT zchenh012.
TABLES:zchenh001.
DATA:err_text TYPE string,
e TYPE REF TO cx_root.
DATA: json_ser TYPE REF TO cl_trex_json_serializer,
json_des TYPE REF TO cl_trex_json_deserializer.
DATA: jsonstr TYPE string.
DATA: BEGIN OF itab OCCURS .
INCLUDE TYPE zchenh001.
DATA END OF itab.
DATA:gs_zchenh001 TYPE zchenh001. START-OF-SELECTION.
TRY . SELECT * INTO CORRESPONDING FIELDS OF TABLE itab
FROM zchenh001 UP TO ROWS. ***内表->JSON
CREATE OBJECT json_ser
EXPORTING
data = itab[].
CALL METHOD json_ser->serialize.
CALL METHOD json_ser->get_data
RECEIVING
rval = jsonstr. WRITE:'内表转JSON',/, jsonstr,/. ***JSON->内表
CLEAR:itab,itab[].
CREATE OBJECT json_des.
CALL METHOD json_des->deserialize
EXPORTING
json = jsonstr
IMPORTING
abap = itab[].
WRITE:'JSON转内表',/.
LOOP AT itab INTO gs_zchenh001.
WRITE:gs_zchenh001-znum,gs_zchenh001-zname,gs_zchenh001-zsex,gs_zchenh001-zhigh,/.
ENDLOOP. CATCH cx_root INTO e.
err_text = e->get_text( ).
WRITE:err_text. ENDTRY.
方法二:
*&---------------------------------------------------------------------*
*& Report ZCHENH013
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------* REPORT zchenh013. DATA:err_text TYPE string,
e TYPE REF TO cx_root. DATA:lv_content TYPE string.
DATA:lv_content1 TYPE string.
DATA:lv_json TYPE string .
DATA json_writer TYPE REF TO cl_sxml_string_writer. DATA:gs_zchenh001 TYPE zchenh001.
DATA:gt_oldtab TYPE TABLE OF zchenh001.
DATA:gt_newtab TYPE TABLE OF zchenh001. START-OF-SELECTION.
TRY .
lv_content = 'CONTENT'.
SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_oldtab
FROM zchenh001 UP TO ROWS.
***abap内表->JSON
json_writer = cl_sxml_string_writer=>create( type = if_sxml=>co_xt_json ).
CALL TRANSFORMATION id
SOURCE content = lv_content
itable = gt_oldtab
RESULT XML json_writer.
DATA:json TYPE etxml_line_str.
json = json_writer->get_output( ). CALL FUNCTION 'ECATT_CONV_XSTRING_TO_STRING'
EXPORTING
im_xstring = json
im_encoding = 'UTF-8'
IMPORTING
ex_string = lv_json. " json 转 abap内表
CALL TRANSFORMATION id
SOURCE XML lv_json
RESULT content = lv_content1
itable = gt_newtab. WRITE:'转换后JSON:',lv_json,/,'转换后内表',/.
LOOP AT gt_newtab INTO gs_zchenh001 .
WRITE:gs_zchenh001-znum,gs_zchenh001-zname,gs_zchenh001-zsex,gs_zchenh001-zhigh,/.
ENDLOOP.
CATCH cx_root INTO e.
err_text = e->get_text( ).
WRITE:err_text. ENDTRY.
9.读取SAP的页编码格式
1.登录界面 -> 配置属性 -> 代码页 语言,编码
2.I18N 代码页配置,
*&---------------------------------------------------------------------*
*& Report ZCHENH016
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------* REPORT zchenh016.
*DATA: l_codepage(4) TYPE n .
*
*DATA: l_encoding(20).
*
*CALL FUNCTION 'SCP_CODEPAGE_BY_EXTERNAL_NAME'
* EXPORTING
* external_name = 'GB2312'
* IMPORTING
* sap_codepage = l_codepage.
*
*l_encoding = l_codepage.
*
*WRITE:'--------->',l_encoding.
*SKIP. DATA:name TYPE c,
entry00 LIKE tcp00,
cpisinf1 LIKE rscptype-cpisinf1,
cpusedbyf1 LIKE tcp00-cpcodepage,
cpisinf4 LIKE rscptype-cpisinf4,
cpisinf5 LIKE rscptype-cpisinf5,
cpencoding_text TYPE c,
cpbyteind_text TYPE c,
cpextmeth_text TYPE c,
cpnlsmajor_text TYPE c,
cpsource_text TYPE c,
http_name TYPE c,
java_name TYPE c,
mime_name TYPE c,
cpg_name TYPE c,
fcha_name TYPE c,
matching_ascii TYPE c. DATA:lv_code TYPE tcp00-cpcodepage. DO TIMES.
lv_code = sy-index.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = lv_code
IMPORTING
output = lv_code. CALL FUNCTION 'SCP_CODEPAGE_INFO'
EXPORTING
codepage = lv_code
IMPORTING
name = name
entry00 = entry00
cpisinf1 = cpisinf1
cpusedbyf1 = cpusedbyf1
cpisinf4 = cpisinf4
cpisinf5 = cpisinf5
cpencoding_text = cpencoding_text
cpbyteind_text = cpbyteind_text
cpextmeth_text = cpextmeth_text
cpnlsmajor_text = cpnlsmajor_text
cpsource_text = cpsource_text
http_name = http_name
java_name = java_name
mime_name = mime_name
cpg_name = cpg_name
fcha_name = fcha_name
matching_ascii = matching_ascii
EXCEPTIONS
invalid_codepage =
internal_error =
OTHERS = .
IF sy-subrc <> . ENDIF. WRITE:'NAME',name,/
'ENTRY00',entry00,/
'CPUSEDBYF1',cpusedbyf1. ENDDO.
10.SAP中模糊查询 使用like和 % 通配符
DATA: l_setname TYPE setnamenew. e_ret = 'S'. CONCATENATE i_setname '%' INTO l_setname. * 读取集值
SELECT setname lineid valsign valoption valfrom valto
INTO TABLE t_setleaf
FROM setleaf
WHERE setname LIKE l_setname. IF sy-subrc NE .
e_ret = 'F'.
e_msg = '未取到集数据'. EXIT.
ENDIF.
11.SAP中关于Excel的OLE操作
*&---------------------------------------------------------------------*
*& Report ZCHENH021
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------* REPORT zchenh021.
TYPE-POOLS ole2 .
DATA: count TYPE i,
count_real TYPE i,
application TYPE ole2_object,
workbook TYPE ole2_object,
excel TYPE ole2_object,
sheet TYPE ole2_object,
cells TYPE ole2_object.
CONSTANTS: row_max TYPE i VALUE .
DATA index TYPE i. DATA:
h_cell TYPE ole2_object, " cell
h_f TYPE ole2_object, " font
h_int TYPE ole2_object,
h_width TYPE ole2_object,
h_columns TYPE ole2_object,
h_rows TYPE ole2_object,
h_font TYPE ole2_object,
h_entirecol TYPE ole2_object.
. CREATE OBJECT excel 'EXCEL.APPLICATION'. IF sy-subrc NE .
WRITE: / 'No EXCEL creation possible'.
STOP.
ENDIF. SET PROPERTY OF excel 'DisplayAlerts' = . CALL METHOD OF
excel
'WORKBOOKS' = workbook. SET PROPERTY OF excel 'VISIBLE' = . SET PROPERTY OF excel 'SheetsInNewWorkbook' = .
CALL METHOD OF
workbook
'ADD'. CALL METHOD OF
excel
'WORKSHEETS' = sheet
EXPORTING
# = . SET PROPERTY OF sheet 'NAME' = 'Color Palette'.
CALL METHOD OF
sheet
'ACTIVATE'. DATA: col TYPE i VALUE ,
row TYPE i VALUE ,
col1 TYPE i VALUE ,
col_real TYPE i VALUE . row = .
col = .
CALL METHOD OF
excel
'Cells' = h_cell
EXPORTING
# = row
# = col.
SET PROPERTY OF h_cell 'Value' = 'No.'. col = col + .
CALL METHOD OF
excel
'Cells' = h_cell
EXPORTING
# = row
# = col.
SET PROPERTY OF h_cell 'Value' = 'Background'. col = col + .
CALL METHOD OF
excel
'Cells' = h_cell
EXPORTING
# = row
# = col.
SET PROPERTY OF h_cell 'Value' = 'Foreground with white background'. col = col + .
CALL METHOD OF
excel
'Cells' = h_cell
EXPORTING
# = row
# = col.
SET PROPERTY OF h_cell 'Value' = 'Foreground with black background'. CALL METHOD OF
excel
'Rows' = h_rows
EXPORTING
# = '2:2'.
SET PROPERTY OF h_rows 'WrapText' = . col = .
CALL METHOD OF
excel
'Cells' = h_cell
EXPORTING
# = row
# = col.
SET PROPERTY OF h_cell 'Value' = 'No.'. col = col + .
CALL METHOD OF
excel
'Cells' = h_cell
EXPORTING
# = row
# = col.
SET PROPERTY OF h_cell 'Value' = 'Background'. col = col + .
CALL METHOD OF
excel
'Cells' = h_cell
EXPORTING
# = row
# = col.
SET PROPERTY OF h_cell 'Value' = 'Foreground with white background'.
SET PROPERTY OF h_cell 'Bold' = . col = col + .
CALL METHOD OF
excel
'Cells' = h_cell
EXPORTING
# = row
# = col.
SET PROPERTY OF h_cell 'Value' = 'Foreground with black background'. CALL METHOD OF
excel
'Rows' = h_rows
EXPORTING
# = '1:1'.
SET PROPERTY OF h_rows 'WrapText' = .
GET PROPERTY OF h_rows 'Font' = h_font.
SET PROPERTY OF h_font 'Bold' = . count = .
count_real = count.
row = .
col = .
DO TIMES.
PERFORM write_num_and_color.
ENDDO. CALL METHOD OF
excel
'Columns' = h_columns
EXPORTING
# = 'B:K'.
GET PROPERTY OF h_columns 'EntireColumn' = h_entirecol.
SET PROPERTY OF h_entirecol 'Autofit' = . *&---------------------------------------------------------------------*
*& Form write_num_and_color
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM write_num_and_color. " write the color number
index = row_max * ( row - ) + col.
CALL METHOD OF
sheet
'Cells' = cells
EXPORTING
# = index.
SET PROPERTY OF cells 'Value' = count_real. " write the color as the background
col = col + .
CALL METHOD OF
excel
'Cells' = h_cell
EXPORTING
# = row
# = col.
GET PROPERTY OF h_cell 'Interior' = h_int.
SET PROPERTY OF h_int 'ColorIndex' = count_real. " write the color as the foreground with a white background
col = col + .
CALL METHOD OF
excel
'Cells' = h_cell
EXPORTING
# = row
# = col.
SET PROPERTY OF h_cell 'Value' = 'Sample Text'.
GET PROPERTY OF h_cell 'Font' = h_f.
SET PROPERTY OF h_f 'ColorIndex' = count_real. " write the color as the foreground with a black background
col = col + .
CALL METHOD OF
excel
'Cells' = h_cell
EXPORTING
# = row
# = col.
GET PROPERTY OF h_cell 'Interior' = h_int.
SET PROPERTY OF h_int 'ColorIndex' = .
SET PROPERTY OF h_cell 'Value' = 'Sample Text'.
GET PROPERTY OF h_cell 'Font' = h_f.
SET PROPERTY OF h_f 'ColorIndex' = count_real. row = row + .
col = col - .
count = count + .
IF count = .
count = .
row = .
col = col + .
ENDIF.
count_real = count_real + . ENDFORM. "write_num_and_color
12.SAP中动态内表
*&---------------------------------------------------------------------*
*& Report ZCHENH022
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------* REPORT zchenh022.
TYPE-POOLS: abap.
FIELD-SYMBOLS:<dyn_table> TYPE STANDARD TABLE,
<dyn_wa>,
<dyn_field>.
DATA: dy_table TYPE REF TO data,
dy_line TYPE REF TO data,
xfc TYPE lvc_s_fcat,
ifc TYPE lvc_t_fcat.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
PARAMETERS: p_table() TYPE c DEFAULT 'T001'.
SELECTION-SCREEN END OF BLOCK b1. START-OF-SELECTION.
PERFORM get_structure.
PERFORM create_dynamic_itab.
PERFORM get_data.
PERFORM write_out.
*&--------------------------------------------------------------------*
*& Form get_structure
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM get_structure.
DATA: idetails TYPE abap_compdescr_tab,
xdetails TYPE abap_compdescr.
DATA: ref_table_des TYPE REF TO cl_abap_structdescr.
ref_table_des ?= cl_abap_typedescr=>describe_by_name( p_table ). idetails[] = ref_table_des->components[].
LOOP AT idetails INTO xdetails.
CLEAR xfc.
xfc-fieldname = xdetails-name.
xfc-datatype = xdetails-type_kind.
xfc-inttype = xdetails-type_kind.
xfc-intlen = xdetails-length.
xfc-decimals = xdetails-decimals.
APPEND xfc TO ifc.
ENDLOOP.
ENDFORM. "get_structure
*&--------------------------------------------------------------------*
*& Form create_dynamic_itab
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM create_dynamic_itab.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = ifc
IMPORTING
ep_table = dy_table.
ASSIGN dy_table->* TO <dyn_table>.
CREATE DATA dy_line LIKE LINE OF <dyn_table>.
ASSIGN dy_line->* TO <dyn_wa>.
ENDFORM. "create_dynamic_itab
*&--------------------------------------------------------------------*
*& Form get_data
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM get_data.
SELECT * INTO TABLE <dyn_table> FROM (p_table).
ENDFORM. "get_data
*&--------------------------------------------------------------------*
*& Form write_out
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM write_out.
LOOP AT <dyn_table> INTO <dyn_wa>.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE <dyn_wa> TO <dyn_field>.
IF sy-subrc <> .
EXIT.
ENDIF.
IF sy-index = .
WRITE:/ <dyn_field>.
ELSE.
WRITE: <dyn_field>.
ENDIF.
ENDDO.
ENDLOOP.
ENDFORM. "write_out
13. SAP中XML生成并解析
*&---------------------------------------------------------------------*
*& Report ZCHENH027
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------* REPORT zchenh027.
* 参考江正军的博客:https://www.cnblogs.com/jiangzhengjun/p/4265595.html
TYPE-POOLS: ixml,abap.
TYPES: BEGIN OF xml_line,
data() TYPE x,"这里的长度设置不会影响输出结果,设置成1都可以
END OF xml_line.
DATA: l_ixml TYPE REF TO if_ixml,
l_streamfactory TYPE REF TO if_ixml_stream_factory,
l_ostream TYPE REF TO if_ixml_ostream,
l_renderer TYPE REF TO if_ixml_renderer,
l_document TYPE REF TO if_ixml_document.
DATA: l_element_flights TYPE REF TO if_ixml_element,
l_element_airline TYPE REF TO if_ixml_element,
l_element_flight TYPE REF TO if_ixml_element,
l_element_dummy TYPE REF TO if_ixml_element,
l_value TYPE string.
DATA: l_xml_table TYPE TABLE OF xml_line WITH HEADER LINE,
l_xml_size TYPE i,
l_rc TYPE i.
FIELD-SYMBOLS:<dyn_table> TYPE STANDARD TABLE,
<dyn_wa>,
<dyn_field>.
DATA: path TYPE string VALUE 'd:/users/DNAT10218/Desktop/TEST/XML/\flights.xml'. " xml文件保存的路径
DATA: dy_table TYPE REF TO data,
dy_line TYPE REF TO data,
xfc TYPE lvc_s_fcat,
ifc TYPE lvc_t_fcat. SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
PARAMETERS: p_table() TYPE c DEFAULT 'T001'.
SELECTION-SCREEN END OF BLOCK b1. START-OF-SELECTION. PERFORM frm_get_structure. "获取表结构
PERFORM create_dynamic_itab.
PERFORM frm_get_data. "取数 PERFORM frm_create_xml_file."生成XML数据
PERFORM frm_save_xml_file. "保存到本地XML文件
PERFORM frm_open_xml_file. "打开本地XML文件
PERFORM frm_xml_to_str. "将XML转换成字符串并解析 ****************************************************************
*&---------------------------------------------------------------------*
*& Form GET_STRUCTURE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_get_structure .
* 参考江正军SAP 表的反射 https://www.cnblogs.com/jiangzhengjun/p/4264644.html
DATA: idetails TYPE abap_compdescr_tab,
xdetails TYPE abap_compdescr.
DATA: ref_table_des TYPE REF TO cl_abap_structdescr. * ref_table_des ?= cl_abap_typedescr=>describe_by_name( p_table )."结构类型
ref_table_des ?= cl_abap_tabledescr=>describe_by_name( p_table )."结构类型 idetails[] = ref_table_des->components[]."组成结构体的各个字段组件 LOOP AT idetails INTO xdetails.
CLEAR xfc.
xfc-fieldname = xdetails-name.
xfc-datatype = xdetails-type_kind.
xfc-inttype = xdetails-type_kind.
xfc-intlen = xdetails-length.
xfc-decimals = xdetails-decimals.
APPEND xfc TO ifc.
ENDLOOP.
ENDFORM. " GET_STRUCTURE
*&---------------------------------------------------------------------*
*& Form FRM_GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_get_data .
* SELECT * INTO TABLE <dyn_table> FROM (p_table).
SELECT * FROM (p_table) INTO CORRESPONDING FIELDS OF TABLE <dyn_table> UP TO ROWS.
* SELECT * INTO TABLE <dyn_table> FROM (p_table) UP TO 3 ROWS.
ENDFORM. " FRM_GET_DATA
*&---------------------------------------------------------------------*
*& Form FRM_CREATE_XML_FILE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_create_xml_file .
DATA: lv_idx TYPE string,
name TYPE string,
total TYPE i,
totalcol TYPE string,
totalitem TYPE string,
tablename TYPE string.
tablename = p_table.
* 获取表的总列数
DESCRIBE TABLE ifc LINES total.
totalcol = total.
* 获取内表总条目数
DESCRIBE TABLE <dyn_table> LINES total.
totalitem = total.
LOOP AT <dyn_table> INTO <dyn_wa>. AT FIRST.
* 创建 ixml factory
l_ixml = cl_ixml=>create( ).
* 创建 the dom object model
l_document = l_ixml->create_document( ).
* 填充 root node with value flow
l_element_flights = l_document->create_simple_element(
name = 'TABLESTRUCT'
parent = l_document ).
DATA:date TYPE string,
time TYPE string.
date = sy-datum.
time = sy-uzeit.
* 设置XML元素的属性
l_rc = l_element_flights->set_attribute( name = 'DATE' value = date ).
l_rc = l_element_flights->set_attribute( name = 'TIME' value = time ).
l_rc = l_element_flights->set_attribute( name = '创建者' value = '陈辉' ).
l_rc = l_element_flights->set_attribute( name = 'TABLENAME' value = tablename ).
l_element_airline = l_document->create_simple_element(
name = 'TABLE'
parent = l_element_flights ). "parent为父节点 l_rc = l_element_airline->set_attribute( name = 'TOTALITEM' value = totalitem ).
l_rc = l_element_airline->set_attribute( name = 'TOTALCOL' value = totalcol ). ENDAT. LOOP AT ifc INTO xfc. name = xfc-fieldname. l_element_flight = l_document->create_simple_element(
name = name
parent = l_element_airline ).
l_rc = l_element_flight->set_attribute( name = 'COLNAME' value = name ). CLEAR:l_value.
CONCATENATE '<DYN_WA>-' xfc-fieldname INTO l_value.
FIELD-SYMBOLS <fs>.
ASSIGN (l_value) TO <fs>.
l_value = <fs>.
l_element_dummy = l_document->create_simple_element(
name = 'VALUE'
value = l_value
parent = l_element_flight ).
lv_idx = sy-tabix .
l_rc = l_element_dummy->set_attribute( name = 'INDEX' value = lv_idx ).
UNASSIGN:<fs>.
ENDLOOP.
ENDLOOP.
* Creating a stream factory
l_streamfactory = l_ixml->create_stream_factory( )."[stri:m] 流
* Connect internal XML table to stream factory
l_ostream = l_streamfactory->create_ostream_itable( table = l_xml_table[] ).
* Rendering the document
l_renderer = l_ixml->create_renderer( ostream = l_ostream "
document = l_document )." l_document为根节点
l_rc = l_renderer->render( )."注:执行此句后, l_xml_table内表里才会有数据
l_xml_size = l_ostream->get_num_written_raw( )."取得XML数据大小
ENDFORM. " FRM_CREATE_XML_FILE
*&---------------------------------------------------------------------*
*& Form FRM_SAVE_XML_FILE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_save_xml_file .
**--将xml数据导出到本地
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
bin_filesize = l_xml_size
filename = path
filetype = 'BIN'
CHANGING
data_tab = l_xml_table[].
ENDFORM. " FRM_SAVE_XML_FILE
*&---------------------------------------------------------------------*
*& Form FRM_OPEN_XML_FILE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_open_xml_file .
**--将XML数据导入到内表
DATA xmldata TYPE xstring .
DATA: result_xml TYPE STANDARD TABLE OF smum_xmltb .
DATA: return TYPE STANDARD TABLE OF bapiret2 .
DATA: wa_xml TYPE smum_xmltb.
"如果需要上载XML可以用一下方法
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = path
filetype = 'BIN'
IMPORTING
filelength = l_xml_size
TABLES
data_tab = l_xml_table.
* "将二进制内表转换(拼接)成一个二进制串
CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
EXPORTING
input_length = l_xml_size
IMPORTING
buffer = xmldata
TABLES
binary_tab = l_xml_table.
CALL FUNCTION 'SMUM_XML_PARSE'"解析XML
EXPORTING
xml_input = xmldata
TABLES
xml_table = result_xml
return = return.
WRITE: /, '解析结果如下'.
LOOP AT result_xml INTO wa_xml .
WRITE: / wa_xml-hier,wa_xml-type,wa_xml-cname,wa_xml-cvalue.
ENDLOOP.
ENDFORM. " FRM_OPEN_XML_FILE
*&---------------------------------------------------------------------*
*& Form FRM_XML_TO_STR
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_xml_to_str .
**将XML转换成字符串
DATA: w_string TYPE xstring.
DATA ls_xml TYPE string.
DATA: convin TYPE REF TO cl_abap_conv_in_ce.
DATA: str TYPE string. CALL FUNCTION 'SDIXML_DOM_TO_XML'
EXPORTING
document = l_document
IMPORTING
xml_as_string = w_string
size = l_xml_size
TABLES
xml_as_table = l_xml_table. "创建解码对象
convin = cl_abap_conv_in_ce=>create( input = w_string ). CALL METHOD convin->read
IMPORTING
data = ls_xml.
SKIP .
WRITE:/,'********************************************************************'.
WRITE: / ls_xml.
* BREAK-POINT. " 请查看ls_xml的值 并采用标准解析:http://tool.oschina.net/codeformat/xml/ * 将一个二进制串分割存储到二进制内表中
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = w_string
IMPORTING
output_length = l_xml_size
TABLES
binary_tab = l_xml_table.
* 将二进制内表转换(拼接)成一个字符串
CALL FUNCTION 'SCMS_BINARY_TO_STRING'
EXPORTING
input_length = l_xml_size
IMPORTING
text_buffer = ls_xml
TABLES
binary_tab = l_xml_table.
SKIP .
WRITE:/,'********************************************************************'.
WRITE: / ls_xml.
ENDFORM. " FRM_XML_TO_STR
*&---------------------------------------------------------------------*
*& Form FRM_XML_TO_TABLE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_xml_to_table . ENDFORM. " FRM_XML_TO_TABLE
*&---------------------------------------------------------------------*
*& Form CREATE_DYNAMIC_ITAB
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM create_dynamic_itab .
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = ifc
IMPORTING
ep_table = dy_table.
ASSIGN dy_table->* TO <dyn_table>.
CREATE DATA dy_line LIKE LINE OF <dyn_table>.
ASSIGN dy_line->* TO <dyn_wa>.
ENDFORM. " CREATE_DYNAMIC_ITAB
14.ABAP中递归与迭代的使用(斐波拉列契数据与阶乘问题)
*&---------------------------------------------------------------------*
*& Report ZCHENH031
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------* REPORT zchenh031.
DATA:lv_a TYPE i,
lv_b TYPE i,
lv_c TYPE i,
count TYPE i.
lv_a = .
lv_b = .
* lv_c = lv_a + lv_b.
WRITE:/,'第一次调用递归函数(斐波拉列契数列):'.
PERFORM frm_fbllq USING lv_a lv_b CHANGING lv_c.
WRITE:'最终结果:','A=',lv_a,'B=',lv_b,'C=',lv_c.
SKIP .
CLEAR:lv_a,lv_b,lv_c,count.
lv_a = .
* lv_c = lv_a * (lv_a - 1) * ...* 1.
WRITE:/,'第二次调用递归函数(阶乘):'.
PERFORM frm_jc USING lv_a CHANGING lv_c.
WRITE:'最终结果:','A=',lv_a,'C=',lv_c.
*&---------------------------------------------------------------------*
*& Form frm_fbllq
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_fbllq USING p_a p_b CHANGING p_c.
count = count + .
WRITE:/,count,p_a,p_b,p_c.
IF p_a >= .
EXIT.
ELSE.
p_c = p_a + p_b.
p_a = p_b.
p_b = p_c.
PERFORM frm_fbllq USING p_a p_b CHANGING p_c.
ENDIF.
ENDFORM. " frm_fbllq
*&---------------------------------------------------------------------*
*& Form FRM_JC
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_jc USING p_a CHANGING p_c.
count = count + .
WRITE:/,count,p_a,p_c.
IF p_c IS INITIAL.
p_c = .
ENDIF.
IF p_a = OR p_a <= .
EXIT.
ELSE.
p_c = p_a * p_c.
p_a = p_a - .
PERFORM frm_jc USING p_a CHANGING p_c.
ENDIF.
ENDFORM. " FRM_JC
15.ABAP中测试三位数的水仙花数
*&---------------------------------------------------------------------*
*& Report ZCHENH032
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
*打印出所有的 "水仙花数 ",所谓 "水仙花数 "是指一个三位数,
*其各位数字立方和等于该数本身。例如:153是一个 "水仙花数 ",
*因为153=1的三次方+5的三次方+3的三次方
REPORT zchenh032.
DATA:BEGIN OF gt_sxhs OCCURS ,
sxhs TYPE c LENGTH ,
col1 TYPE i ,
col2 TYPE i ,
col3 TYPE i ,
END OF gt_sxhs. PERFORM frm_get_data.
*&---------------------------------------------------------------------*
*& Form FRM_GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_get_data .
DATA:lv_sxhs TYPE c LENGTH .
DO TIMES.
gt_sxhs-sxhs = sy-index.
APPEND gt_sxhs.
ENDDO.
LOOP AT gt_sxhs WHERE sxhs BETWEEN AND .
gt_sxhs-col1 = gt_sxhs-sxhs+(). " 百位
gt_sxhs-col2 = gt_sxhs-sxhs+(). " 十位
gt_sxhs-col3 = gt_sxhs-sxhs+(). " 个位
lv_sxhs = gt_sxhs-col1 * gt_sxhs-col1 * gt_sxhs-col1 +
gt_sxhs-col2 * gt_sxhs-col2 * gt_sxhs-col2 +
gt_sxhs-col3 * gt_sxhs-col3 * gt_sxhs-col3.
IF lv_sxhs EQ gt_sxhs-sxhs.
WRITE:/,'水仙花数',gt_sxhs-sxhs,'=',gt_sxhs-col1,'的三次方 乘以',gt_sxhs-col2,'的三次方 乘以',gt_sxhs-col3,'的三次方'.
ENDIF.
ENDLOOP. ENDFORM. " FRM_GET_DATA
16.ABAP前台进度条
*&---------------------------------------------------------------------*
*& Report ZCHENH028
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------* REPORT zchenh028. DATA:count TYPE string. " 内表总数据条数
DATA:msg TYPE string. " 显示的消息
DATA:index TYPE string. " 当前处理的索引 DATA:BEGIN OF gt_tab OCCURS ,
col1 TYPE string,
END OF gt_tab . " 插入100条空数据
DO TIMES.
APPEND gt_tab.
ENDDO.
DESCRIBE TABLE gt_tab LINES count. * 进度条显示
LOOP AT gt_tab.
CLEAR:msg,index.
index = sy-tabix.
CONCATENATE '正在处理。。。' index '/' count INTO msg. " 拼接消息
index = index / count * . " 时钟显示的百分比 CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
percentage = index " 处理的百分比
text = msg.
ENDLOOP.
17.ABAP 分组测试
*&---------------------------------------------------------------------*
*& Report ZCHENH029
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------* REPORT zchenh029. TYPES:BEGIN OF gs_tab,
col1(),
col2(),
col3(),
col4(),
END OF gs_tab.
DATA: gt_tab TYPE gs_tab OCCURS WITH HEADER LINE.
DATA: gt_tcd TYPE gs_tab OCCURS WITH HEADER LINE.
DATA: gs_ab TYPE gs_tab.
gs_ab-col1 = ''.gs_ab-col2 = 'aaa1'.gs_ab-col3 = . gs_ab-col4 = 'A'. APPEND gs_ab TO gt_tab.
gs_ab-col1 = ''.gs_ab-col2 = 'aaa2'.gs_ab-col3 = . gs_ab-col4 = 'A'. APPEND gs_ab TO gt_tab.
gs_ab-col1 = ''.gs_ab-col2 = 'aaa2'.gs_ab-col3 = . gs_ab-col4 = 'A'. APPEND gs_ab TO gt_tab.
gs_ab-col1 = ''.gs_ab-col2 = 'aaa2'.gs_ab-col3 = . gs_ab-col4 = 'A'. APPEND gs_ab TO gt_tab.
gs_ab-col1 = ''.gs_ab-col2 = 'aaa3'.gs_ab-col3 = . gs_ab-col4 = 'A'. APPEND gs_ab TO gt_tab.
gs_ab-col1 = ''.gs_ab-col2 = 'aaa3'.gs_ab-col3 = . gs_ab-col4 = 'A'. APPEND gs_ab TO gt_tab. LOOP AT gt_tab.
* AT END OF col4.
AT NEW col4.
APPEND gt_tab TO gt_tcd.
ENDAT.
ENDLOOP. LOOP AT gt_tcd.
WRITE:gt_tcd-col1,' ',gt_tcd-col2,' ',gt_tcd-col3,' ',gt_tcd-col4,' ',/.
ENDLOOP.
18. 修改已经释放的请求
*&---------------------------------------------------------------------*
*& Report ZCHENH026
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------* REPORT zchenh026.
TABLES: e070.
PARAMETERS : p_trkorr LIKE e070-trkorr OBLIGATORY. UPDATE e070 SET trstatus = 'D' "将状态还原成‘可修改’
WHERE trkorr = p_trkorr. "输入的需要处理的TR IF sy-subrc = .
COMMIT WORK.
MESSAGE 'OK' TYPE 'S'.
ELSE.
ROLLBACK WORK.
MESSAGE 'ERROR!' TYPE 'E'.
ENDIF.
19.质数判断
*&---------------------------------------------------------------------*
*& Report ZCHENH054
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
*参考文章:https://blog.csdn.net/codeswarrior/article/details/78053754
REPORT zchenh054.
DATA:start_time TYPE timestamp,
end_time TYPE timestamp,
produce_time TYPE timestamp,
start TYPE brutto. CONSTANTS:lv_max TYPE i VALUE . DATA:BEGIN OF gt_data OCCURS ,
index TYPE sy-index,
num TYPE string,
status,
msg(),
END OF gt_data. START-OF-SELECTION.
GET TIME STAMP FIELD start_time. *gt_data-num = 97.
*PERFORM frm_check_data USING gt_data-num
* CHANGING gt_data-status
* gt_data-msg.
*WRITE:gt_data-msg,/. DO lv_max TIMES.
CLEAR:gt_data.
gt_data-num = sy-index.
PERFORM frm_check_data USING gt_data-num
CHANGING gt_data-status
gt_data-msg.
IF gt_data-status EQ 'S'.
APPEND gt_data.
ENDIF.
ENDDO. LOOP AT gt_data.
CONDENSE:gt_data-msg.
WRITE:sy-tabix,gt_data-msg,/.
ENDLOOP. END-OF-SELECTION.
GET TIME STAMP FIELD end_time.
produce_time = end_time - start_time.
WRITE:'持续运行时间:',produce_time,'秒'. *&---------------------------------------------------------------------*
*& Form FRM_CHECK_DATA
*&---------------------------------------------------------------------*
* 判断一个数是否是质数
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_check_data USING p_num TYPE string
CHANGING p_status TYPE char1
p_msg TYPE char20.
DATA: b TYPE string VALUE ,
c TYPE string VALUE ,
d TYPE string VALUE ,
e TYPE string VALUE . CONDENSE:p_msg.
p_msg = p_num. *1. 特殊质数判断
IF p_num EQ OR p_num EQ .
p_status = 'S'.
CONCATENATE p_msg '是质数' INTO p_msg.
RETURN.
ENDIF. *2.不在6的倍数两侧的一定不是质数
b = p_num MOD .
IF b NE AND b NE .
p_status = 'E'.
CONCATENATE p_msg '不是质数' INTO p_msg.
RETURN.
ENDIF. * 3.在6的倍数两侧的也可能不是质数
b = .
c = sqrt( p_num ).
WHILE b LE c.
d = p_num MOD b.
e = p_num MOD ( b + ).
IF d EQ OR d EQ .
p_status = 'E'.
CONCATENATE p_msg '不是质数' INTO p_msg.
RETURN.
ENDIF.
b = b + .
ENDWHILE. * 4.排除所有,剩余的是质数
p_status = 'S'.
CONCATENATE p_msg '是质数' INTO p_msg.
ENDFORM. " FRM_CHECK_DATA
20.ABAP调用播放器播放文件
*&---------------------------------------------------------------------*
*& Report ZCHENH055
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------* REPORT zchenh055.
*http://blog.sina.com.cn/s/blog_56d71d930101dmeu.html
DATA:ls_parameter TYPE string,
lv_file TYPE string VALUE 'D:\users\DNAT10218\Desktop\三国演义.mp4',
lv_flag.
DATA:times TYPE string VALUE '', " 播放次数
timer TYPE string VALUE ''. " 超时时常 *CONCATENATE 'vbscript createobject("sapi.spvoice").speak("' in_hinttxt '")(windows.close)' INTO ls_parameter. *先判断文件是否存在
CALL METHOD cl_gui_frontend_services=>file_exist
EXPORTING
file = lv_file
RECEIVING
result = lv_flag.
IF lv_flag EQ 'X'. * CONCATENATE 'VBSCRIPT:EXECUTE("DOCUMENT.WRITE ""<BGSOUND SRC=' lv_file '","","/")+"'''
* 'loop=' ''''times'''>"":window.setTimeout ""window.close()"",' timer '")' INTO ls_parameter. CALL METHOD cl_gui_frontend_services=>execute
EXPORTING
document = lv_file
* application = 'MSHTA'
* parameter = ls_parameter
* default_directory =
* maximized =
minimized = 'X'
* synchronous =
operation = 'OPEN'
EXCEPTIONS
cntl_error =
error_no_gui =
bad_parameter =
file_not_found =
path_not_found =
file_extension_unknown =
error_execute_failed =
synchronous_failed =
not_supported_by_gui =
OTHERS = .
ENDIF.
21.ABAP 迷你计算器
*&---------------------------------------------------------------------*
*& Report ZCHENH056
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------* REPORT zchenh056.
DATA: x() TYPE c.
CALL FUNCTION 'FITRV_CALCULATOR'
EXPORTING
input_value = ''
currency = 'RMB'
start_column = ''
start_row = ''
IMPORTING
output_value = x
EXCEPTIONS
invalid_input =
calculation_canceled =
OTHERS = . WRITE:X.
22.ABAP 保存本地程序
*&---------------------------------------------------------------------*
*& Report ZCHENH057
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------* REPORT zchenh057.
TABLES tadir.
DATA: BEGIN OF it_table OCCURS ,
obj_name LIKE tadir-obj_name,
END OF it_table.
DATA report_table TYPE TABLE OF string WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE .
DATA: file TYPE string,
path TYPE string. SELECTION-SCREEN BEGIN OF BLOCK blk01 WITH FRAME." TITLE text-001 .
PARAMETER: obj_name LIKE tadir-obj_name DEFAULT 'ZCHENH05'.
SELECT-OPTIONS: object FOR tadir-object DEFAULT 'PROG',
author FOR tadir-author,
devclass FOR tadir-devclass.
SELECTION-SCREEN END OF BLOCK blk01 . START-OF-SELECTION.
PERFORM frm_save_file.
*&---------------------------------------------------------------------*
*& Form FRM_SAVE_FILE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_save_file . CONCATENATE obj_name '%' INTO obj_name.
SELECT obj_name
INTO TABLE it_table FROM tadir
WHERE obj_name LIKE obj_name
AND object IN object
AND author IN author
AND devclass IN devclass. path = 'D:\ABAP\'.
CONDENSE path NO-GAPS. LOOP AT it_table. READ REPORT it_table-obj_name INTO report_table. CLEAR file.
CONCATENATE path it_table-obj_name '.TXT' INTO file. CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = file
filetype = 'ASC'
TABLES
data_tab = report_table. ENDLOOP.
ENDFORM. " FRM_SAVE_FILE
23.ABAP 动态拼接Where 语句
*&---------------------------------------------------------------------*
*& Report ZCHENH043
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------* REPORT zchenh043.
TABLES: zchenh001. DATA where_tab() OCCURS WITH HEADER LINE.
DATA : count_rec TYPE i. SELECT-OPTIONS: s_zhigh FOR zchenh001-zhigh NO INTERVALS OBLIGATORY DEFAULT ''. MOVE 'zhigh in s_zhigh' TO where_tab.
APPEND where_tab. CONCATENATE 'and zname like' '''%陈辉%'''
INTO where_tab SEPARATED BY space.
APPEND where_tab.
CLEAR where_tab. SELECT COUNT( * ) INTO count_rec
FROM zchenh001
WHERE (where_tab). WRITE:'共查询到',count_rec.
SAP自开发程序的更多相关文章
-
SAP-ABAP系列 第二篇SAP ABAP开发基础
第二章SAP ABAP开发基础 1.ABAP数据类型及定义 ABAP程序*包含8种基本数据类型定义, 类型名称 描述 属性 C Character Text (字符类型) 默认长度=1,默认值 = ...
-
开发程序过程中遇到的调用Web Api小问题
在用Umbraco Web Api开发程序时,前端使用React调用Web Api 当时是有一个页面Search.cshtml,把用React产生的脚本代码,在这个页面进行引用 写了一个Api, 调用 ...
-
php微信支付接口开发程序
php微信支付接口开发程序讲解 微信支付接口现在也慢慢的像支付宝一个可以利用api接口来实现第三方网站或应用进行支付了, 下文整理了一个php微信支付接口开发程序并且己测试,有兴趣的朋友可进入参考. ...
-
TypeScript开发程序
使用TypeScript开发程序 简介 TypeScript一直发展不错,我们公司在开发新功能时,考虑到程序的可维护性,使用了TypeScript编写浏览器上的程序,我们是从零开始使用TypeScri ...
-
VS2010开发程序打包详解
VS2010开发程序打包详解 转自:http://blog.sina.com.cn/s/blog_473b385101019ufr.html 首先打开已经完成的工程,如图: 下面开始制作安装程序包. ...
-
对ios、android开发程序员的14条忠告
————————本文摘自千锋教育(http://www.mobiletrain.org/)对ios\android开发程序员的14条忠告————————— 1.不要害怕在工作中学习. 只要有电脑,就可 ...
-
PHP开发程序员的学习路线
PHP开发程序员的学习路线 兄弟连PHP培训,简单为大家梳理了每个阶段PHP程序员的技术要求,来帮助很多PHP程序做对照设定学习成长目标. 第一阶段:基础阶段(基础PHP程序员) 重点:把LNMP搞熟 ...
-
Java技术开发程序员如果在2019年立足
2019年的互联网环境相对以往来说要更复杂一些,互联网领域也正在经历从消费互联网向产业互联网转型的阵痛期.其实不少公司从2018年开始已经在陆续进行结构化调整,这些调整中的重要内容就是岗位调整,而岗位 ...
-
运行HBase应用开发程序产生异常,提示信息包含org.apache.hadoop.hbase.ipc.controller.ServerRpcControllerFactory的解决办法
Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties Exception in thread ...
随机推荐
-
【ASP.NET实战教程】基于ASP.NET技术下多用户博客系统全程实战开发(NNblog)
岁末主推:牛牛老师主讲,多用户博客系统,基于ASP.NET技术,年后将带来移动业务平台项目项目目标: 打造个性品牌Blogo,定制多用户博客 为每一个博客用户提供个性化的 blogo解决方案,打造精品 ...
-
chrome地址栏搜索直接跳转百度首页?
https://www.baidu.com/s?ie={inputEncoding}&wd=%s
-
db2操作 连接、备份、恢复db2
先deactivate后再start standby再primary报错不能启动hadr standby的时候,先restore,但是别rollback,直接start hadr as standby ...
-
dll强签名的由来和作用
C# dll强签名介绍 之前基本没有这个概念,直到有一天我们的dll被反编译了,导致我们的代码基本上被看到了,才想起来要保护dll的安全性,因为C#语言的在编译过程中会产生中间语言导致dll很容易被反 ...
- java io 流基础
-
RGB,CMYK,HSB各种颜色表示的转换 C#语言
Introduction Why an article on "colors"? It's the same question I asked myself before writ ...
-
【详细贴】Ubuntu Linode搭建海外策略路由VPN IPSec+L2TP(一)
对于码农来说,Google上搜索,*上提问,twitter上交流,这样的国际化开放平台才是码农成长的空间.但是,目前遇到的一些现实的困难,无可避免的带来一些麻烦,不过这难不倒我 ...
-
18 章 CSS 链接、光标、 DHTML 、缩放
1.CSS 中链接的使用 2.CSS 中光标的使用 3.CSS 中 DHTML 的使用 4.CSS 中缩放的使用 1 18 8. .1 1 S CSS 中 链接的使用 超链接伪类属性 a:link ...
-
解决python解析文件时输出乱码
首先获取到json模块,encoding指定文件编码utf-8,errors报错时忽略错误,print()输出结果看看是否有问题. # -*- coding: utf-8 -*- import jso ...
-
遍历文件,读取.wxss文件,在头部添加一条注释
change.pl #!/usr/bin/perl use autodie; use utf8; use Encode qw(decode encode); use v5.26; my $path = ...