ABAP 分货日报表
*&---------------------------------------------------------------------*
*& Report ZSDR031
*&
*&---------------------------------------------------------------------*
*&程序名称:分货日报表导出
*&事物代码:
*&导入模板:分货日报表模板.xls(上传对象名为:ZSD_XLS_011)
*&作者:
*&时间:
*&更新时间:
*&----------------------------------
REPORT zsdr031.
TABLES: vttp,lips,likp,kna1 ,vttk, ztmm001,ztbjdyzt.
INCLUDE ole2incl.
FIELD-SYMBOLS: <f_fs1> , <f_fs2>.
DATA: gs_fcat TYPE lvc_s_fcat,
gt_fcat TYPE lvc_t_fcat,
gs_layo TYPE lvc_s_layo,
gs_grid TYPE lvc_s_glay.
DATA: gt_event TYPE slis_t_event WITH HEADER LINE,
gt_event_exit TYPE slis_t_event_exit WITH HEADER LINE.
DATA: ref_grid TYPE REF TO cl_gui_alv_grid .
DATA: excel TYPE ole2_object,
workbook TYPE ole2_object,
sheet TYPE ole2_object,
cell TYPE ole2_object,
column TYPE ole2_object,
row TYPE ole2_object.
TYPES: BEGIN OF ty_all,
vbeln LIKE likp-vbeln, "交货单号
btgew LIKE likp-btgew, "总重量
ntgew LIKE likp-ntgew, "净重量
gewei LIKE likp-gewei, "重量单位
vstel LIKE likp-vstel, "装运点
vstel_txt LIKE tvstt-vtext, "装运点描述
route LIKE likp-route, "路线
route_txt LIKE tvrot-bezei, "路线描述
lfart LIKE likp-lfart, "交货类型
lfart_txt LIKE tvlkt-vtext, "交货类型描述
vbtyp LIKE likp-vbtyp, "凭证类型
kunag LIKE likp-kunag, "售达方
kunag_txt LIKE kna1-name1, "售达方名称
kunnr LIKE likp-kunnr, "送达方
kunnr_txt LIKE kna1-name1, "送达方名称
erdat LIKE likp-erdat, "交货单创建日期
vgbel LIKE lips-vgbel, "参考的销售订单
wbstk LIKE vbuk-wbstk, "货物移动状态
posnr LIKE lips-posnr, "项目
matnr LIKE lips-matnr, "物料代码
lfimg LIKE lips-lfimg, "交货数量
vrkme LIKE lips-vrkme , "单位
beizhu(30) TYPE c, "备注
END OF ty_all.
TYPES:BEGIN OF ty_header,
vbeln LIKE likp-vbeln, "交货单号
btgew LIKE likp-btgew, "总重量
ntgew LIKE likp-ntgew, "净重量
gewei LIKE likp-gewei, "重量单位
vstel LIKE likp-vstel, "装运点
vstel_txt LIKE tvstt-vtext, "装运点描述
route LIKE likp-route, "路线
route_txt LIKE tvrot-bezei, "路线描述
lfart LIKE likp-lfart, "交货类型
lfart_txt LIKE tvlkt-vtext, "交货类型描述
vbtyp LIKE likp-vbtyp, "凭证类型
kunag LIKE likp-kunag, "售达方
kunag_txt LIKE kna1-name1, "售达方名称
kunnr LIKE likp-kunnr, "送达方
kunnr_txt LIKE kna1-name1, "送达方名称
erdat LIKE likp-erdat, "交货单创建日期
vgbel LIKE lips-vgbel, "参考的销售订单
wbstk LIKE vbuk-wbstk, "货物移动状态
beizhu(30) TYPE c, "备注
END OF ty_header.
*单据抬头结束
*单据明细开始
TYPES:BEGIN OF ty_items,
vbeln LIKE lips-vbeln, "交货单号
posnr LIKE lips-posnr, "项目
matnr LIKE lips-matnr, "物料代码
lfimg LIKE lips-lfimg, "交货数量
vrkme LIKE lips-vrkme , "单位
beizhu(30) TYPE c, "备注
END OF ty_items.
*单据明细结束
DATA:wa_all TYPE ty_all,
gt_all TYPE ty_all OCCURS 0.
DATA:wa_header TYPE ty_header,
gt_header TYPE ty_header OCCURS 0.
DATA:wa_items TYPE ty_items,
gt_items TYPE ty_items OCCURS 0.
DATA: gt_selected_header TYPE ty_header OCCURS 0.
DATA: gt_selected_items TYPE ty_items OCCURS 0.
*定义传入到smartforms的变量开始
DATA:fm_name TYPE rs38l_fnam.
DATA:itemsname(32) TYPE c.
DATA:headername(32) TYPE c.
*定义传入到smartforms的变量结束
*定义存储ALV向smartforms传入数据的内表开始
DATA:gt_header_temp TYPE ty_header OCCURS 0.
DATA:gt_items_temp TYPE ty_items OCCURS 0.
DATA:gt_all_temp TYPE ty_all OCCURS 0.
*定义存储ALV向smartforms传入数据的内表结束
"控制smartforms参数声明开始
DATA :control_parameters TYPE ssfctrlop.
"控制smartforms参数声明结束
DATA:gt_dc TYPE STANDARD TABLE OF ztbjdyzt.
DATA:wa_dc TYPE ztbjdyzt.
TYPES: BEGIN OF ty_sum ,
vbeln LIKE lips-vbeln, "交货单号
matnr LIKE lips-matnr, "物料代码
lfimg LIKE lips-lfimg, "交货数量
vrkme LIKE lips-vrkme , "单位
END OF ty_sum.
DATA : itab TYPE ty_sum OCCURS 0 ."WITH HEADER LINE ."从数据库中取出的数放入的内表
DATA : hs_sum TYPE HASHED TABLE OF ty_sum WITH UNIQUE KEY matnr vrkme vbeln WITH HEADER LINE .
DATA : gt_sum TYPE STANDARD TABLE OF ty_sum WITH HEADER LINE .
DATA : gt_selected_sum TYPE STANDARD TABLE OF ty_sum WITH HEADER LINE .
TYPES: BEGIN OF ty_row_to_col,"行列转换后的内表
vstel LIKE likp-vstel, "装运点
vbeln LIKE lips-vbeln, "交货单号
kunnr LIKE kna1-kunnr, "客户代码
kunnr_txt LIKE kna1-name1,
btgew LIKE likp-btgew, "总重量
ntgew LIKE likp-ntgew, "净重量
01 TYPE i,
02 TYPE i,
03 TYPE i,
04 TYPE i,
05 TYPE i,
06 TYPE i,
07 TYPE i,
08 TYPE i,
09 TYPE i,
10 TYPE i,
11 TYPE i,
12 TYPE i,
13 TYPE i,
14 TYPE i,
15 TYPE i,
16 TYPE i,
17 TYPE i,
18 TYPE i,
19 TYPE i,
20 TYPE i,
21 TYPE i,
22 TYPE i,
23 TYPE i,
24 TYPE i,
25 TYPE i,
26 TYPE i,
gewei
LIKE likp-gewei, "重量单位
END OF ty_row_to_col.
DATA:itab_out TYPE ty_row_to_col OCCURS 0 WITH HEADER LINE ."声明要导出数据的内表结构
TYPES: BEGIN OF ty_col ,"存储动态显示列的内表结构
matnr
LIKE lips-matnr, "物料编码
"arktx LIKE lips-arktx, "物料描述
END OF ty_col.
DATA : hs_col TYPE HASHED TABLE OF ty_col WITH UNIQUE KEY matnr WITH HEADER LINE .
DATA : itab_col TYPE STANDARD TABLE OF ty_col WITH HEADER LINE .
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
SELECT-OPTIONS:
s_vbeln
FOR likp-vbeln,
s_vstel
FOR likp-vstel OBLIGATORY,
s_erdat
FOR likp-erdat,
s_lfart
FOR likp-lfart.
SELECTION-SCREEN END OF BLOCK blk1.
*SELECTION-SCREEN BEGIN OF BLOCK blk2 WITH FRAME TITLE text-002.
*PARAMETERS: r1 RADIOBUTTON GROUP gr1 DEFAULT 'X' USER-COMMAND radio.
*PARAMETERS: r2 RADIOBUTTON GROUP gr1.
*SELECTION-SCREEN END OF BLOCK blk2.
INITIALIZATION.
START-OF-SELECTION.
PERFORM frm_getdata.
PERFORM frm_outdata.
"parameters: p_fname like RLGRAP-FILENAME default 'C:\Users\DONG\Desktop\model.xls'.
FORM frm_getdata.
SELECT vbuk~wbstk
likp
~btgew likp~ntgew likp~gewei likp~vstel likp~route likp~lfart likp~vbtyp
likp
~kunag likp~kunnr likp~vbeln likp~erdat
lips
~posnr lips~matnr lips~lfimg lips~vgbel lips~vrkme
INTO CORRESPONDING FIELDS OF TABLE gt_all
FROM likp
INNER
JOIN lips
ON likp~vbeln = lips~vbeln
INNER
JOIN vbuk
ON likp~vbeln = vbuk~vbeln
WHERE vbuk~wbstk <> 'C' AND likp~vbtyp = 'J'
AND likp~vstel IN s_vstel
AND likp~vbeln IN s_vbeln
AND likp~erdat IN s_erdat
AND likp~lfart IN s_lfart.
LOOP AT gt_all INTO wa_all.
SELECT SINGLE vtext INTO wa_all-vstel_txt
FROM tvstt
WHERE vstel EQ wa_all-vstel.
SELECT SINGLE bezei INTO wa_all-route_txt
FROM tvrot
WHERE route EQ wa_all-route.
SELECT SINGLE vtext INTO wa_all-lfart_txt
FROM tvlkt
WHERE lfart EQ wa_all-lfart.
SELECT SINGLE name1 INTO wa_all-kunag_txt
FROM kna1
WHERE kunnr EQ wa_all-kunag.
SELECT SINGLE name1 INTO wa_all-kunnr_txt
FROM kna1
WHERE kunnr EQ wa_all-kunnr.
MODIFY gt_all FROM wa_all.
ENDLOOP.
MOVE-CORRESPONDING gt_all TO gt_header.
MOVE-CORRESPONDING gt_all TO gt_items.
SORT gt_header BY vbeln.
DELETE ADJACENT DUPLICATES FROM gt_header.
LOOP AT gt_items INTO wa_items.
MOVE-CORRESPONDING wa_items TO hs_sum.
COLLECT hs_sum.
ENDLOOP.
gt_sum[]
= hs_sum[].
ENDFORM. " GETDATA
*&---------------------------------------------------------------------*
*& Form FIXDATA
*&---------------------------------------------------------------------*
FORM fixdata." TABLES gt_selected_header TYPE STANDARD TABLE ty_header.
DATA: index LIKE sy-tabix .
LOOP AT gt_selected_header INTO wa_header.
LOOP AT gt_sum.
IF wa_header-vbeln EQ gt_sum-vbeln.
APPEND gt_sum TO gt_selected_sum.
MOVE-CORRESPONDING gt_sum TO hs_col.
COLLECT hs_col.
ENDIF.
ENDLOOP.
ENDLOOP.
itab_col[]
= hs_col[]."搜集到需要显示的物料
LOOP AT gt_selected_sum .
itab_out
-vbeln = gt_selected_sum-vbeln.
SELECT SINGLE kunnr vstel INTO ( itab_out-kunnr ,itab_out-vstel )
FROM likp
WHERE vbeln EQ gt_selected_sum-vbeln.
"itab_out-kunnr = gt_selected_sum-kunnr.
SELECT SINGLE name1 INTO itab_out-kunnr_txt
FROM kna1
WHERE kunnr EQ itab_out-kunnr.
READ TABLE itab_col WITH KEY matnr = gt_selected_sum-matnr .
index = sy-tabix + 6."6这个数字代表itab_sum内表有几列是固定不变的
ASSIGN COMPONENT index OF STRUCTURE itab_out TO <f_fs1>.
<f_fs1>
= gt_selected_sum-lfimg.
COLLECT itab_out.
SORT itab_out ASCENDING BY vbeln.
CLEAR itab_out.
ENDLOOP.
LOOP AT itab_out.
SELECT SINGLE btgew ntgew INTO ( itab_out-btgew, itab_out-ntgew )
FROM likp
WHERE vbeln EQ itab_out-vbeln.
SELECT SINGLE gewei INTO itab_out-gewei
FROM likp
WHERE vbeln EQ itab_out-vbeln.
CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'
EXPORTING
input = itab_out-btgew
round_sign
= 'X'
unit_in
= itab_out-gewei
unit_out
= 'KG'
IMPORTING
output = itab_out-btgew
EXCEPTIONS
conversion_not_found
= 01
division_by_zero
= 02
input_invalid
= 03.
CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'
EXPORTING
input = itab_out-ntgew
round_sign
= 'X'
unit_in
= itab_out-gewei
unit_out
= 'KG'
IMPORTING
output = itab_out-ntgew
EXCEPTIONS
conversion_not_found
= 01
division_by_zero
= 02
input_invalid
= 03.
MODIFY itab_out.
ENDLOOP.
* SORT itab_out BY vbeln.
* DELETE ADJACENT DUPLICATES FROM itab_out.
ENDFORM. " FIXDATA
FORM frm_catlg_set USING p_field p_text p_key p_edit p_no_out p_do_sum p_no_zero.
gs_fcat
-fieldname = p_field.
gs_fcat
-reptext = p_text.
gs_fcat
-key = p_key.
gs_fcat
-edit = p_edit.
gs_fcat
-no_out = p_no_out.
gs_fcat
-do_sum = p_do_sum.
gs_fcat
-no_zero = p_no_zero.
IF p_field = 'LINE_SUM'.
gs_fcat
-emphasize = 'C700'.
ENDIF.
APPEND gs_fcat TO gt_fcat .
CLEAR gs_fcat .
ENDFORM. "frm_catlg_set
FORM fieldcat_init .
DATA: c(2) TYPE n,txt(20) TYPE c .
PERFORM frm_catlg_set USING:
'VBELN' '交货单号' 'X' '' '' '' 'X',
'ERDAT' '创建日期' '' '' '' '' 'X' ,
'wbstk' '交货状态' '' '' '' '' '',
'BTGEW' '总重量' '' '' '' '' '',
'NTGEW' '净重量' '' '' '' '' '',
'GEWEI' '重量单位' '' '' '' '' '',
"'VSTEL' '装运点' '' '' '' '' '',
'VSTEL_TXT' '装运点描述' '' '' '' '' '',
"'ROUTE' '路线' '' '' '' '' '',
'ROUTE_TXT' '路线描述' '' '' '' '' '',
"'LFART' '交货类型' '' '' '' '' '',
'LFART_TXT' '交货类型描述' '' '' '' '' '',
"'VBTYP' '凭证类别' '' '' '' '' '',
"'KUNAG' '售达方' '' '' '' '' 'X',
'KUNAG_TXT' '售达方名称' '' '' '' '' 'X',
"'KUNNR' '送达方' '' '' '' '' 'X',
'KUNNR_TXT' '送达方名称' '' '' '' '' 'X',
'VGBEL' '销售订单' '' '' '' '' 'X',
'BEIZHU' '备注' '' 'X' 'X' '' ''.
gs_layo
-zebra = 'X'.
gs_layo
-cwidth_opt = 'X'.
ENDFORM. "fieldcat_init
FORM frm_outdata .
IF gt_header[] IS INITIAL.
MESSAGE '没有数据显示!' TYPE 'I'.
RETURN.
ENDIF.
PERFORM fieldcat_init .
PERFORM show_alv TABLES gt_fcat gt_header[]
USING gs_layo.
ENDFORM. " outdata
FORM show_alv TABLES pt_fcat pt_tab USING ps_layout.
DATA: gt_sort TYPE lvc_t_sort WITH HEADER LINE.
* gt_sort-spos = '1'.
* gt_sort-fieldname = 'TKNUM'.
* gt_sort-up = 'X'.
* APPEND gt_sort.
* gt_sort-spos = '2'.
* gt_sort-fieldname = 'kunnr_name'.
* gt_sort-up = 'X'.
* APPEND gt_sort.
gs_grid
-edt_cll_cb = 'X'."当屏幕失去焦点时,自动刷新
gt_event
-name = 'CALLER_EXIT'. "slis_ev_caller_exit_at_start事件
gt_event
-form = 'FM_BUTTON'.
APPEND gt_event .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program
= sy-repid
i_callback_user_command
= 'USER_COMMAND'
i_grid_settings
= gs_grid
i_callback_pf_status_set
= 'SET_PF_STATUS'
is_layout_lvc
= ps_layout
"it_sort_lvc = gt_sort[]
it_fieldcat_lvc
= pt_fcat[]
it_events
= gt_event[]
i_save
= 'X'
* it_event_exit = gt_event_exit[]
TABLES
t_outtab
= pt_tab
EXCEPTIONS
program_error
= 1
OTHERS = 2.
ENDFORM. "csalv_set_fcat
FORM user_command USING r_ucomm LIKE sy-ucomm rs_selfield TYPE slis_selfield.
CASE r_ucomm.
WHEN '&DATA_SAVE'.
WHEN '&SAVE' OR '&EXPORT' .
"PERFORM PRINT.
DATA: path LIKE rlgrap-filename..
DATA :file_path LIKE rlgrap-filename.
DATA:ls_row TYPE lvc_s_row,
lt_rows
TYPE lvc_t_row.
"获取ALV选中的行开始
CALL METHOD ref_grid->get_selected_rows
IMPORTING
et_index_rows
= lt_rows.
"获取ALV选中的行结束
LOOP AT lt_rows INTO ls_row.
READ TABLE gt_header INTO wa_header INDEX ls_row-index.
APPEND wa_header TO gt_selected_header.
ENDLOOP.
PERFORM fixdata.
"设置文件存放路径调用函数开始
"PERFORM set_file_path CHANGING path.
PERFORM frm_get_filepath CHANGING path.
IF path IS INITIAL.
MESSAGE '已取消!'TYPE 'E'.
RETURN.
ENDIF.
"设置文件存放路径调用函数结束
"file_path = path && '\分货日报表.xls'.
PERFORM frm_download_template USING path.
PERFORM data_to_excel USING path.
CLEAR:hs_col[],itab_col[],gt_selected_header[],gt_selected_sum[],itab_out[].
WHEN '&BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDFORM. "user_command
*&---------------------------------------------------------------------*
*& Form SET_PF_STATUS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->RT_EXTAB text
*----------------------------------------------------------------------*
FORM set_pf_status USING rt_extab TYPE slis_t_extab..
SET PF-STATUS 'STANDARD'.
ENDFORM. "SET_PF_STATUS
*&---------------------------------------------------------------------*
*& Form fm_button
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->E_GRID text
*----------------------------------------------------------------------*
FORM fm_button USING e_grid TYPE slis_data_caller_exit.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
* EXPORTING
* IR_SALV_FULLSCREEN_ADAPTER =
IMPORTING
* ET_EXCLUDING =
* E_REPID =
* E_CALLBACK_PROGRAM =
* E_CALLBACK_ROUTINE =
e_grid
= ref_grid
* ET_FIELDCAT_LVC =
* ER_TRACE =
* E_FLG_NO_HTML =
* ES_LAYOUT_KKBLO =
* ES_SEL_HIDE =
* ET_EVENT_EXIT =
* ER_FORM_TOL =
* ER_FORM_EOL =
.
* CALL METHOD ref_grid->check_changed_data.
* 设置enter事件
CALL METHOD ref_grid->register_edit_event
EXPORTING
i_event_id
= cl_gui_alv_grid=>mc_evt_enter
EXCEPTIONS
error
= 1
OTHERS = 2.
"CREATE OBJECT gt_event_receiver.
"SET HANDLER gt_event_receiver->handle_modify FOR ref_grid.
ENDFORM. "FM_BUTTON
FORM fill_cell USING i_row i_col p_value.
CALL METHOD OF excel 'CELLS' = cell
EXPORTING #1 = i_row #2 = i_col.
SET PROPERTY OF cell 'VALUE' = p_value.
ENDFORM. "fill_cell
FORM frm_insert_col USING position.
CALL METHOD OF excel 'COLUMNS' = column EXPORTING #1 = position .
CALL METHOD OF column 'INSERT'.
* CALL METHOD OF l_excel 'COLUMNS' = l_column
* EXPORTING
* #1 = 2.
ENDFORM.
FORM data_to_excel USING c_path.
DATA: txt(60).
* Create an Excel object and start Excel.
CREATE OBJECT excel 'EXCEL.APPLICATION'.
IF sy-subrc <> 0.
MESSAGE 'The excel object can''t be created' TYPE 'I'.
ENDIF.
* Create an Excel workbook Object.
CALL METHOD OF excel 'WORKBOOKS' = workbook .
* Transfer the header line to Excel.
CALL METHOD OF workbook 'OPEN' EXPORTING #1 = c_path.
"READ TABLE gt_header_show INTO wa_header INDEX 1.
DATA : cols TYPE i VALUE 7."物料开始的列
DATA : rows TYPE i VALUE 2."行开始位置
DATA : count_matnr TYPE i VALUE 0. "统计物料种类数量
DATA :l_col TYPE sy-index.
FIELD-SYMBOLS: <f>.
DESCRIBE TABLE itab_col[] LINES count_matnr.
LOOP AT itab_col.
SELECT SINGLE maktx INTO txt
FROM makt
WHERE matnr EQ itab_col-matnr.
"txt = txt && ':' && itab_col-matnr.
txt
= txt && '(数量)'.
PERFORM fill_cell USING 1 cols txt.
cols
= cols + 1.
CLEAR txt.
ENDLOOP.
CLEAR cols.
LOOP AT itab_out .
* PERFORM fill_cell USING rows 1 itab_out-vstel.
* PERFORM fill_cell USING rows 2 itab_out-kunnr.
* PERFORM fill_cell USING rows 3 itab_out-vbeln.
* PERFORM fill_cell USING rows 4 itab_out-kunnr_txt.
* PERFORM fill_cell USING rows 5 itab_out-btgew.
* PERFORM fill_cell USING rows 6 itab_out-ntgew.
CLEAR l_col.
"ADD 1 TO l_col.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE itab_out TO <f>.
IF sy-index GT ( count_matnr + 6 ).
EXIT.
ENDIF.
ADD 1 TO l_col.
IF <f> IS INITIAL .
"<f> = ''.
PERFORM fill_cell USING rows l_col ''. "wa_sum-matnr.
ELSE.
IF l_col EQ 1.
SELECT SINGLE vtext INTO txt
FROM tvstt
WHERE vstel EQ <f>.
PERFORM fill_cell USING rows l_col txt.
ELSE.
PERFORM fill_cell USING rows l_col <f>.
ENDIF.
ENDIF.
ENDDO.
rows = rows + 1.
ENDLOOP.
CLEAR rows.
GET PROPERTY OF excel 'ACTIVEWORKBOOK' = workbook.
* release and exit Excel.
CALL METHOD OF workbook 'SAVE'.
CALL METHOD OF excel 'QUIT'.
* Free all objects
FREE OBJECT cell.
FREE OBJECT workbook.
FREE OBJECT excel.
excel
-handle = -1.
FREE OBJECT row.
ENDFORM.
FORM frm_download_template USING c_path .
DATA: lv_objdata LIKE wwwdatatab,
lv_obj_name
LIKE wwwdatatab-objid,
lv_destination
LIKE rlgrap-filename,
lv_objid
LIKE sy-repid,
lv_subrc
LIKE sy-subrc.
DATA:l_ret TYPE abap_bool, lv_answer
.
DATA:lv_file TYPE string.
MOVE c_path TO lv_file.
CALL METHOD cl_gui_frontend_services=>file_exist
EXPORTING
file
= lv_file
RECEIVING
result
= l_ret
EXCEPTIONS
cntl_error
= 1
error_no_gui
= 2
wrong_parameter
= 3
not_supported_by_gui
= 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EXIT.
ENDIF.
IF l_ret EQ 'X'.
* 模版已存在,是否覆盖
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
text_question
= '模版已存在,是否覆盖?'
text_button_1
= '是'(001)
text_button_2
= '否'(002)
IMPORTING
answer
= lv_answer
EXCEPTIONS
text_not_found
= 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
IF lv_answer EQ 'A'. "取消
EXIT.
ELSEIF lv_answer NE '1'. "否
"p_filepath = c_path.
ENDIF.
ELSE.
lv_answer
= '1'.
ENDIF.
CREATE OBJECT excel 'EXCEL.APPLICATION'.
GET PROPERTY OF excel 'Workbooks' = workbook .
CALL METHOD OF workbook
'Close'.
IF lv_answer EQ '1'.
MOVE 'ZSD_XLS_011' TO lv_obj_name."引用传入到服务器中xls模板
SELECT relid objid
FROM wwwdata
INTO CORRESPONDING FIELDS OF lv_objdata
UP TO 1 ROWS
WHERE srtf2 = 0 AND relid = 'MI'
AND objid = lv_obj_name.
ENDSELECT.
CALL FUNCTION 'DOWNLOAD_WEB_OBJECT'
EXPORTING
key = lv_objdata
destination
= c_path
IMPORTING
rc
= lv_subrc.
* IF lv_subrc = 0.
* p_filepath = c_path.
* ENDIF.
ENDIF.
FREE OBJECT sheet.
"FREE OBJECT g_applica.
FREE OBJECT workbook.
FREE OBJECT excel.
ENDFORM. "frm_download_template
FORM set_file_path CHANGING filepath LIKE rlgrap-filename.
DATA: gd_path TYPE string.
DATA: it_tab TYPE filetable,
gd_subrc
TYPE i.
DATA: ld_filename TYPE string,
ld_path
TYPE string,
ld_fullpath
TYPE string,
ld_result
TYPE i,
gd_file
TYPE c.
DATA:"filepath LIKE rlgrap-filename,
openfile
LIKE rlgrap-filename.
CALL METHOD cl_gui_frontend_services=>directory_browse
EXPORTING
window_title
= '文件路径选择'
initial_folder
= 'C:'
CHANGING
selected_folder
= gd_path.
CALL METHOD cl_gui_cfw=>flush.
CONCATENATE gd_path '' INTO filepath.
IF filepath IS INITIAL.
MESSAGE '已取消!' TYPE 'E'.
RETURN.
ENDIF.
ENDFORM.
FORM frm_coverted_name USING usrid TYPE sy-uname
CHANGING name.
DATA: l_name_last TYPE adrp-name_last,
l_name_first
TYPE adrp-name_first,
l_persnumber
TYPE usr21-persnumber.
SELECT SINGLE persnumber INTO l_persnumber
FROM usr21
WHERE bname EQ usrid.
SELECT SINGLE name_last INTO l_name_last
FROM adrp
WHERE persnumber EQ l_persnumber.
SELECT SINGLE name_first INTO l_name_first
FROM adrp
WHERE persnumber EQ l_persnumber.
CONCATENATE l_name_last l_name_first INTO name.
ENDFORM.
FORM frm_get_filepath CHANGING p_file.
DATA: rc TYPE i,
f_table
TYPE filetable.
FIELD-SYMBOLS: <f> TYPE file_table .
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title
= '选择文件'
default_filename
= '分货日报表.xls'
file_filter
= 'Excel文件(*.XLS,*.XLSX)|*.XLS;*.XLSX|全部文件 (*.*)|*.*|'
initial_directory
= 'C:\'
multiselection
= ' '
CHANGING
file_table
= f_table
rc
= rc
EXCEPTIONS
cntl_error
= 1
file_open_dialog_failed
= 2
error_no_gui
= 3.
CALL METHOD cl_gui_cfw=>flush
EXCEPTIONS
cntl_error
= 1
cntl_system_error
= 2.
CLEAR p_file.
READ TABLE f_table ASSIGNING <f> INDEX 1.
IF sy-subrc EQ 0.
p_file
= <f>-filename.
ENDIF.
ENDFORM.
ABAP 分货日报表的更多相关文章
- Silverlight——施工计划日报表(一)
前一段时间,客户需要一个施工计划报表,要求能够直观的看到各个计划的实施时间,而且能够修改.琢磨着,决定用Silverlight搞定好了.效果如下: 用户可以通过右键菜单的[完成]选项来标记完成,左键选 ...
- Silverlight——施工计划日报表(二)
近来一直在加班,基本上没有个人时间.所以更新不会很即时. 长话短说,先从界面代码开始吧.界面代码很简单,如下所示: <UserControl xmlns:sdk="http://sch ...
- MyBatis mysal 日报表,月,年报表的统计
mysql 按日.周.月.年统计sql语句整理,实现报表统计可视化 原文地址:http://blog.csdn.net/u010543785/article/details/52354957 最近在做 ...
- RS报表从按月图表追溯到按日报表
相信很多COGNOS开发人员看到这个标题就会感觉很轻松,追溯无非是COGNOS自带的一个下钻的功能,但是这里却是固定的条件: 要求1:A报表显示按月的图表B报表显示按日的明细 2:追溯到B的时候B的开 ...
- sql:[dbo].[smt_MES_RptProductDaily] 生产日报表
USE [ChangHongMES_904]GO/****** Object: StoredProcedure [dbo].[smt_MES_RptProductDaily] Script Date: ...
- 这些.NET开源项目你知道吗?.NET平台开源文档与报表处理组件集合(三)
在前2篇文章这些.NET开源项目你知道吗?让.NET开源来得更加猛烈些吧 和这些.NET开源项目你知道吗?让.NET开源来得更加猛烈些吧!(第二辑)中,大伙热情高涨.再次拿出自己的私货,在.NET平台 ...
- ABAP面试问题及侧重点
ABAP面试 1.简单的Report包括哪些东西 2.Dialog 逻辑流以及相应的处理内容 3.用过的几种增强方式:怎么找增强 4.接口和函数的使用,一般遇到自己不会的函数怎么处理 5.关联查询:I ...
- Erp:原料投入产出报表
USE [ChangHongWMS612]GO /****** Object: StoredProcedure [dbo].[st_WMS_RptMaterialInOutDaily] Script ...
- 5、VS2010+ASP.NET MVC4+EF4+JqueryEasyUI+Oracle该项目的开发——使用datagrid做报表
来点需要:我使用的数据库访问EF框架,但是,因为使用一个动态表来的统计报告中.单独是每天产生基于数据表,它是很难使用EF加盟前.所以我包装在两组数据库存取层的框内,一个是EF,一种是传统的ADO.NE ...
随机推荐
- Dump中查看DataTime时间方法
例如: 步骤一:根据DumpVC命令获取时间对象信息.需要MT 和 Value参数. 步骤二:根据得到上上面值,执行:? & 0x3FFFFFFFFFFFFFFF.注意:0n 签名是零,不是英 ...
- linux下,Python 多版本共存,及Pip,Easy_install 安装扩展包
Python2与Python3共存 安装Python3后,建立ln,使用Python(Python2),Python3 来区分两个版本 使用sudo apt-get install python3-s ...
- python基础-牛逼的三层循环,实现想在那里退出,就在那里退出。
#!/usr/bin/env python # -*- coding:utf-8 -*- #Author: nulige tag=True #设置tag控制他,只要一输入Flash就退出整个循环 wh ...
- TCP 三次握手四次挥手, ack 报文的大小.tcp和udp的不同之处、tcp如何保证可靠的、tcp滑动窗口解释
一.TCP三次握手和四次挥手,ACK报文的大小 首先连接需要三次握手,释放连接需要四次挥手 然后看一下连接的具体请求: [注意]中断连接端可以是Client端,也可以是Server端. [注意] 在T ...
- apt-get 相關設定
/etc/apt/apt.conf.d/01proxy 若加了以下這行,則 apt-get 都會透過下方網址get Acquire::http::Proxy "http://aptcache ...
- spring 整合 mongo
spring 非常强大,不仅在jdbc访问提供了jdbctemplate,而且在mongo访问上提供了mongoTemplate.闲话不多说,下边开始整合mongoTemplate. ONE: 添加s ...
- jprofiler_监控远程linux服务器的JVM进程(实践)
几天前写了一篇文章,jprofiler_监控远程linux服务器的tomcat进程(实践),介绍了使用jprofiler怎样监控远程linux的tomcat进程,这两天想了想,除了可以监控tomcat ...
- jdbc-批量插入、批量删除、批量更新
一.JDBC的批量插入 JDBC批量插入主要用于数据导入和日志记录因为日志一般都是先写在文件下的等. 我用Mysql5.1.5的JDBC driver 分别对三种比较常用的方法做了测试 方法 ...
- mysql返回最后一列数据
获取MySQL的表中每个userid最后一条记录的方法,并且针对userid不唯一的情况,需要的朋友可以参考下 表结构 CREATE TABLE `t1` ( `userid` int(11) DEF ...
- Ubuntu学习总结-07 Nodejs和npm的安装
一 安装NodeJS 1 下载nodejs源码 从以下网址下载最新的Nodejs源码 https://nodejs.org/en/download/ 2 安装依赖的 python,gcc,g++ 函数 ...