标签:other 技术 display 逻辑 选择 head nes tables move
一、1. OAOR 创建模板,
Class name SOFFICEINTEGRATION
Class type OT
Object key ZHRPY0183 (XXX)
2.双击表模板创建Excel 模板,
关键字可以不写
!!!注意关键字 = 文件名
二、程序处理数据准备;
A.程序逻辑处理,得到需要数据gt_bonus[];
B.ALV显示;
*----------------------------------------------------------------------* *TYPES *----------------------------------------------------------------------* TYPES:BEGIN OF ty_bonus_xls, papertype TYPE char20, "*证照类型 icnum TYPE p0185-icnum, "*证照号码 name TYPE pa0002-vnamc, "姓名 skfd TYPE char10, "税款负担方式【自行负担】 qnyc TYPE pc207-betrg, "*全年一次性奖金额 [应发双薪+应发奖金] mssd TYPE char20, "免税所得 【space yxkc TYPE char20, "允许扣除的税费【space else TYPE char20, "其他 【space zykc TYPE char20, "准予扣除的捐赠额【space jmse TYPE char20, "减免税额 【space END OF ty_bonus_xls. DATA:gt_bonus_xls TYPE STANDARD TABLE OF ty_bonus_xls, gw_bonus_xls TYPE ty_bonus_xls. TYPES:BEGIN OF ty_wjgz_xls, papertype TYPE char20, "P0185-SUBTY,"*证照类型 icnum TYPE p0185-icnum, "*证照号码 name TYPE pa0002-vnamc, "姓名 jnts TYPE char20, "境内天数 [选择期间日历天数] jwts TYPE char20, "境外天数【space jnjn TYPE pc207-betrg, "境内所得境内支付[根据员工号和薪资期间, 从RT表中取出。信息类型:WT/401] jnjw TYPE pc207-betrg, "境内所得境外支付【space jwjn TYPE char20, "境外所得境内支付【space jwjw TYPE char20, "境外所得境外支付【space ylao TYPE pc207-betrg, "基本养老保险费 [“外籍人员工资”,则为空] yliao TYPE pc207-betrg, "基本医疗保险费【space sybx TYPE pc207-betrg, "失业保险费 【space zfgjj TYPE pc207-betrg, "住房公积金 【space yxkc TYPE char20, "允许扣除的税费 【space else TYPE char20, "其他 【space zfbt TYPE char20, "住房补贴【space hsbt TYPE char20, "伙食补贴【space xyfei TYPE char20, "洗衣费 【space bqfei TYPE char20, "搬迁费 【space ccbt TYPE char20, "出差补贴【space tqfei TYPE char20, "探亲费 【space yypx TYPE char20, "语言培训费 【space znjy TYPE char20, "子女教育经费【space qtfy TYPE char20, "其他费用 【space zykc TYPE char20, "准予扣除捐赠额【space jmse TYPE char20, "减免税额 【space END OF ty_wjgz_xls. DATA:gt_wjgz_xls TYPE STANDARD TABLE OF ty_wjgz_xls, gw_wjgz_xls TYPE ty_wjgz_xls. TYPES:BEGIN OF ty_jmgz_xls, papertype TYPE char20, "P0185-SUBTY,"*证照类型 icnum TYPE p0185-icnum, "*证照号码 name TYPE pa0002-vnamc, "姓名 skfd TYPE char20, "税款负担方式【固定值:自行负担】 shour TYPE pc207-betrg, "*收入额 [(PC207-BETRG, "人民币收入额).信息类型:WT/401 ] ylao TYPE pc207-betrg, "*基本养老保险费 [信息类型:WT/313 ] yliao TYPE pc207-betrg, "*基本医疗保险费 [信息类型:WT/333] sybx TYPE pc207-betrg, "*失业保险费 [信息类型:WT/323 zfgjj TYPE pc207-betrg, "*住房公积金 [“居民工资”:WT/362+WT/36E ] else TYPE char20, "其他 【space yxkc TYPE char20, "允许扣除的税费 【space yrarj TYPE char20, "年金(个人部分)【space mians TYPE char20, "免税所得 【space zykc TYPE char20, "准予扣除的捐赠额【space jmse TYPE char20, "减免税额【space END OF ty_jmgz_xls. DATA:gt_jmgz_xls TYPE STANDARD TABLE OF ty_jmgz_xls, gw_jmgz_xls TYPE ty_jmgz_xls. *----------------------------------------------------------------------* *DATA/FIELD-SYMBOLS *----------------------------------------------------------------------* *DATA: * BEGIN OF GT_OUTTAB OCCURS 1, * PAPERTYPE TYPE P0185-SUBTY, "证件类型 * ICNUM TYPE P0185-ICNUM, "身份证号码 * TAXITEM TYPE CHAR6, "税目 * TAXSIGN TYPE CHAR1 VALUE 1, "含税标志 * BEGDA TYPE SY-DATUM, "所属期起 * ENDDA TYPE SY-DATUM, "所属期止 * DAYS TYPE CHAR3, "天数 * RMBINC TYPE PC207-BETRG, "人民币收入额 * FORCURINC TYPE PC207-BETRG VALUE SPACE, "外币收入额space * INC TYPE PC207-BETRG, "收入额 * EXPAM TYPE T7CN33-EXPAM, "扣除额 * TAXPAYABLE TYPE PC207-BETRG, "应缴纳税款 * COUNTRYAREA TYPE CHAR3, "国家地区t005-intcn3 * TAXREDANDEXEMPTION TYPE PC207-BETRG VALUE 0, "减免税额space * FORTAXDEDUCTION TYPE PC207-BETRG VALUE 0, "抵扣外币税额space * PAIDINTAX TYPE PC207-BETRG, "实缴税额 * TAXPAYABLE1 TYPE PC207-BETRG, "应缴纳税款 * END OF GT_OUTTAB. *&add by cxiang on 20161011 17:59:00============= *【1】奖金 DATA:BEGIN OF gt_bonus OCCURS 1, papertype TYPE char20, "P0185-SUBTY,"*证照类型 icnum TYPE p0185-icnum, "*证照号码 * NCHMC TYPE PA0002-NCHMC,"(姓) * VNAMC TYPE PA0002-VNAMC,"(名) name TYPE pa0002-vnamc, "姓名 skfd TYPE char20, "税款负担方式【自行负担】 qnyc TYPE pc207-betrg, "*全年一次性奖金额 [应发双薪+应发奖金] mssd TYPE char20, "免税所得 【space yxkc TYPE char20, "允许扣除的税费【space else TYPE char20, "其他 【space zykc TYPE char20, "准予扣除的捐赠额【space jmse TYPE char20, "减免税额 【space * COUNTRYAREA TYPE CHAR3, "国家地区t005-intcn3 END OF gt_bonus. *【2】外籍人员工资 DATA:BEGIN OF gt_wjgz OCCURS 1, papertype TYPE char20, "P0185-SUBTY,"*证照类型 icnum TYPE p0185-icnum, "*证照号码 name TYPE pa0002-vnamc, "姓名 jnts TYPE char20, "境内天数 [选择期间日历天数] jwts TYPE char20, "境外天数【space jnjn TYPE pc207-betrg, "境内所得境内支付[根据员工号和薪资期间, 从RT表中取出。信息类型:WT/401] jnjw TYPE pc207-betrg, "境内所得境外支付【space jwjn TYPE char20, "境外所得境内支付【space jwjw TYPE char20, "境外所得境外支付【space ylao TYPE pc207-betrg, "基本养老保险费 [“外籍人员工资”,则为空] yliao TYPE pc207-betrg, "基本医疗保险费【space sybx TYPE pc207-betrg, "失业保险费 【space zfgjj TYPE pc207-betrg, "住房公积金 【space yxkc TYPE char20, "允许扣除的税费 【space else TYPE char20, "其他 【space zfbt TYPE char20, "住房补贴【space hsbt TYPE char20, "伙食补贴【space xyfei TYPE char20, "洗衣费 【space bqfei TYPE char20, "搬迁费 【space ccbt TYPE char20, "出差补贴【space tqfei TYPE char20, "探亲费 【space yypx TYPE char20, "语言培训费 【space znjy TYPE char20, "子女教育经费【space qtfy TYPE char20, "其他费用 【space zykc TYPE char20, "准予扣除捐赠额【space jmse TYPE char20, "减免税额 【space END OF gt_wjgz. *【3】居民工资 DATA:BEGIN OF gt_jmgz OCCURS 1, papertype TYPE char20, "P0185-SUBTY,"*证照类型 icnum TYPE p0185-icnum, "*证照号码 name TYPE pa0002-vnamc, "姓名 skfd TYPE char20, "税款负担方式【固定值:自行负担】 shour TYPE pc207-betrg, "*收入额 [(PC207-BETRG, "人民币收入额).信息类型:WT/401 ] ylao TYPE pc207-betrg, "*基本养老保险费 [信息类型:WT/313 ] yliao TYPE pc207-betrg, "*基本医疗保险费 [信息类型:WT/333] sybx TYPE pc207-betrg, "*失业保险费 [信息类型:WT/323 zfgjj TYPE pc207-betrg, "*住房公积金 [“居民工资”:WT/362+WT/36E ] else TYPE char20, "其他 【space yxkc TYPE char20, "允许扣除的税费 【space yrarj TYPE char20, "年金(个人部分)【space mians TYPE char20, "免税所得 【space zykc TYPE char20, "准予扣除的捐赠额【space jmse TYPE char20, "减免税额【space END OF gt_jmgz. *&add by cxiang on 20161011 17:59:00============= DATA: gw_layout_alv TYPE slis_layout_alv, gt_event TYPE slis_t_event WITH HEADER LINE, gw_event TYPE slis_alv_event, g_col_pos TYPE i, gt_fieldcat_alv TYPE slis_t_fieldcat_alv WITH HEADER LINE, gw_fieldcat_alv TYPE slis_fieldcat_alv, excelapplication TYPE ole2_object, workbooks TYPE ole2_object, worksheets TYPE ole2_object, cells TYPE ole2_object, range TYPE ole2_object, font TYPE ole2_object, columns TYPE ole2_object, g_path TYPE string, g_pathfilename TYPE string, color TYPE ole2_object, border TYPE ole2_object. DATA:gdf_path TYPE string, "add by shikai.liao gdf_filename TYPE string, gdf_fullpath TYPE string. DATA:g_line TYPE string. *----------------------------------------------------------------------* *SELECTION-SCREEN *----------------------------------------------------------------------* SELECTION-SCREEN BEGIN OF BLOCK blk WITH FRAME TITLE text-s01. "请您选择类型 PARAMETERS:rb_jmgz RADIOBUTTON GROUP rbg, rb_wjgz RADIOBUTTON GROUP rbg, rb_bonus RADIOBUTTON GROUP rbg. "奖金 SELECTION-SCREEN END OF BLOCK blk. *&************************************************************************ *----------------------------------------------------------------------* *MAIN *----------------------------------------------------------------------* INITIALIZATION. "PERFORM frm_initialization. AT SELECTION-SCREEN OUTPUT. PERFORM frm_modify_screen. START-OF-SELECTION. PERFORM frm_modify_screen. *& use FUNCTION HR_INITIALIZE_BUFFER. GET pernr. PERFORM frm_get_pernrdata. END-OF-SELECTION. CASE ‘X‘. WHEN rb_jmgz. g_line = lines( gt_jmgz[] ). WHEN rb_wjgz. g_line = lines( gt_wjgz[] ). WHEN rb_bonus. g_line = lines( gt_bonus[] ). ENDCASE. IF g_line EQ 0. MESSAGE s000(oo) WITH ‘没有找到合适数据!‘ DISPLAY LIKE ‘E‘. STOP. ENDIF. PERFORM frm_display_alv. "PERFORM frm_display_xls CHANGING g_path g_pathfilename. *&************************************************************************ 三、调用OAOR 模板导出; A. user_command中处理导出 B. PERFORM frm_output_excel TABLES gt_bonus_xls USING ‘ZHRPY0183‘ ldf_path. CASE pu_ucomm. WHEN ‘EXCEL‘. "弹出路径框 *&---------------------------------------------------------------------* *& Form frm_alv_user_command *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->PU_UCOMM text * -->PU_SELFIELD text *----------------------------------------------------------------------* FORM frm_alv_user_command USING pu_ucomm TYPE sy-ucomm pu_selfield TYPE slis_selfield. DATA:ldf_path TYPE localfile. CASE pu_ucomm. WHEN ‘EXCEL‘. "弹出路径框 CLEAR: gdf_path, gdf_filename, gdf_fullpath. PERFORM frm_get_path CHANGING gdf_path gdf_filename gdf_fullpath . IF gdf_fullpath IS INITIAL . MESSAGE ‘请选择要保存的文件夹和输入文件名‘ TYPE ‘I‘. ELSE. CLEAR ldf_path. MOVE gdf_fullpath TO ldf_path. *&->add on 20161013 12:50:00 by caixiang. CASE ‘X‘. WHEN rb_jmgz. REFRESH gt_jmgz_xls. LOOP AT gt_jmgz. MOVE-CORRESPONDING gt_jmgz TO gw_jmgz_xls. APPEND gw_jmgz_xls TO gt_jmgz_xls. CLEAR gw_jmgz_xls. ENDLOOP. PERFORM frm_output_excel TABLES gt_jmgz_xls USING ‘ZHRPY0181‘ ldf_path . WHEN rb_wjgz. REFRESH gt_wjgz_xls. LOOP AT gt_wjgz. MOVE-CORRESPONDING gt_wjgz TO gw_wjgz_xls. APPEND gw_wjgz_xls TO gt_wjgz_xls. CLEAR gw_wjgz_xls. ENDLOOP. PERFORM frm_output_excel TABLES gt_wjgz_xls USING ‘ZHRPY0182‘ ldf_path . WHEN rb_bonus. REFRESH gt_bonus_xls. LOOP AT gt_bonus. MOVE-CORRESPONDING gt_bonus TO gw_bonus_xls. APPEND gw_bonus_xls TO gt_bonus_xls. CLEAR gw_bonus_xls. ENDLOOP. PERFORM frm_output_excel TABLES gt_bonus_xls USING ‘ZHRPY0183‘ ldf_path . WHEN OTHERS. ENDCASE. ENDIF. " PERFORM frm_display_xls "USING pu_selfield "CHANGING g_path " g_pathfilename. ENDCASE. ENDFORM. "frm_alv_user_command
标签:other 技术 display 逻辑 选择 head nes tables move
原文地址:http://www.cnblogs.com/rainysblog/p/7783419.html