20171104 DOI Excel 导出
1. OAOR 创建模板,
Class name:SOFFICEINTEGRATION
Class type: OT
Object key: ZZCSDRP_0030
2.双击表模板创建Excel 模板,
3.上传成功后可以看到模板,
双击可以显示模板
注意点:关键字可以不写
!!!注意关键字 = 文件名
二、示例
1. 取数据,
2.ALV显示
3. 选中行进行导出
*&---------------------------------------------------------------------*
*& Program Name <程序名称>: ZZCSDRP_0029
*& Purpose <程序用途>: 出口商业发票 导出
*& Project Name <项目名称>: ZC
*& Created by <创 建 人>: ibm-caixiang
*& Created on <创建日期>: 20171013
*& Functional Consultant<功能顾问>: ibm-wugz
*& Description <功能描述>: Function Desc.
*&---------------------------------------------------------------------*
* Modification Log<程序修改日志>
*<日期> <开发者> <功能顾问> <修改描述>
* 20171103 ibm-caixiang ibm-xuj ETDK900085
*&
*&---------------------------------------------------------------------*
REPORT ZZCSDRP_0030 NO STANDARD PAGE HEADING
MESSAGE-ID ZZCSD001. *----------------------------------------------------------------------*
* type-pools define(定义使用到的类型池)
*----------------------------------------------------------------------
TYPE-POOLS:SLIS, "ALV使用到的类库
TRUXS,
ICON. *----------------------------------------------------------------------
* TABLES/Structure
*----------------------------------------------------------------------
TABLES:VBAK, "销售订单抬头表
ADRC, "地址表
VBKD, "销售业务数据表
VBAP, "销售订单项目表
KNA1, "客户数据表
MAKT. "物料描述 *----------------------------------------------------------------------
*内表定义
*----------------------------------------------------------------------
TYPES:BEGIN OF TY_ALV,
**display fields
VBELN LIKE VBAK-VBELN, "销售订单
VTWEG LIKE VBAK-VTWEG, "分销渠道
VTWEGTXT TYPE STRING,
VKGRP LIKE VBAK-VKGRP, "销售组
VKGRPTXT TYPE STRING,
KUNNR LIKE VBAK-KUNNR, "售达方
NAME1 LIKE KNA1-NAME1, "售达方名称
LAND1 LIKE KNA1-LAND1, "国家
LANDX LIKE T005T-LANDX, "国名 **head data
VKBUR LIKE VBAK-VKBUR,
VKBURTXT TYPE STRING,
WERKS LIKE VBAP-WERKS,
LGORT LIKE VBAP-LGORT, VKORG LIKE VBAK-VKORG, "销售组织
VKORGTXT TYPE STRING, "公司名称
VKORGEN TYPE STRING, "英文公司名称
TELF1 LIKE KNA1-TELF1, "电话
TELFX LIKE KNA1-TELFX, "传真
ADDRESS TYPE STRING, "地址
BSTKD LIKE VBKD-BSTKD, "发票号
ZZCDHXXH LIKE VBAK-ZZCDHXXH, "订单号
ZSHADR LIKE VBAK-ZSHADR, "地址
ZSHNAME LIKE VBAK-ZSHNAME, "中茶-收货人
ZSHTEL LIKE VBAK-ZSHTEL, "中茶-收货电话
INCO2 LIKE VBKD-INCO2, "FROM
INCO1 LIKE VBKD-INCO2, "FROM
ERDAT LIKE VBAK-ERDAT,
AUART LIKE VBAK-AUART,
ZZCMT LIKE VBAK-ZZCMT,
WAERK LIKE VBAK-WAERK,
ZZYWY LIKE VBAK-ZZYWY,
ZSL TYPE STRING,
ZJE TYPE STRING,
ZTJ TYPE STRING,
ZJZ TYPE STRING,
ZMZ TYPE STRING,
ZSLEN TYPE STRING,
ZJEEN TYPE STRING,
XM_EN TYPE STRING,
XM_ZH TYPE STRING,
* 装船名 手工输入
* 航期 手工输入
* TO 手工输入
* ZDYCS LIKE ZTZC_PRINT-ZDYCS,
BOX TYPE C,
LIN TYPE SY-TABIX,
END OF TY_ALV.
DATA: GT_ALV TYPE STANDARD TABLE OF TY_ALV,
GS_ALV TYPE TY_ALV,
WA_PRINT TYPE TY_ALV. DATA: BEGIN OF GS_ITEM,
* VBELN
VBELN LIKE VBAK-VBELN, "销售订单
POSNR LIKE VBAP-POSNR,
MATNR LIKE VBAP-MATNR,
ARKTX LIKE VBAP-ARKTX, "品名
VRKME LIKE VBAP-VRKME,
KWMENG LIKE VBAP-KWMENG, "数量
ZZCSJH LIKE VBAP-ZZCSJH, "批次号
VOLUM LIKE VBAP-VOLUM, "体积
NTGEW LIKE VBAP-NTGEW, "净重
BRGEW LIKE VBAP-BRGEW, "毛重
KZWI1 LIKE VBAP-KZWI1,
NETPR TYPE CHAR10,
LGORT LIKE VBAP-LGORT,
CHARG LIKE VBAP-CHARG,
WERKS LIKE VBAP-WERKS,
ZDW TYPE CHAR10,
ZPC TYPE RESB-BDMNG, END OF GS_ITEM.
DATA: GT_ITEM LIKE TABLE OF GS_ITEM. FIELD-SYMBOLS: <FS_ALV> LIKE LINE OF GT_ALV,
<FS_ITEM> LIKE LINE OF GT_ITEM. *----------------------------------------------------------------------
* for DOI
*----------------------------------------------------------------------
DATA:GDF_PATH TYPE STRING, "add by shikai.liao
GDF_FILENAME TYPE STRING,
GDF_FULLPATH TYPE STRING.
DATA:L_IREF_SPREADSHEET TYPE REF TO I_OI_SPREADSHEET. **全局变量
DATA: G_ERR(1),
G_LINES TYPE SY-TABIX,
G_TABIX TYPE SY-TABIX.
**ALV参数定义
DATA: GT_FCAT TYPE LVC_T_FCAT,
GS_FCAT TYPE LVC_S_FCAT.
DATA: GS_STYL TYPE LVC_S_STYL,
GT_STYL TYPE LVC_T_STYL.
DATA: GS_SCOL TYPE LVC_S_SCOL,
GT_SCOL TYPE LVC_T_SCOL.
DATA: G_REPID TYPE SY-REPID,
GS_LAYOUT TYPE LVC_S_LAYO.
DATA: GS_S_GLAY TYPE LVC_S_GLAY."可编辑单元格时回调
DATA: G_GRID TYPE REF TO CL_GUI_ALV_GRID. **常量定义
CONSTANTS:C_ERR(1) TYPE C VALUE 'X',
C_OK(1) TYPE C VALUE 'S'. *======================================================================
*选择屏幕
*======================================================================
SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-001. PARAMETERS: P_VKORG LIKE VBAK-VKORG,
P_VTWEG LIKE VBAK-VTWEG OBLIGATORY DEFAULT '30'. "是否不显示
SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN,
S_AUART FOR VBAK-AUART,
S_KUNNR FOR VBAK-KUNNR,"客户编号
S_ERDAT FOR VBAK-ERDAT."订单创建日期
*PARAMETERS: P_PRINT TYPE C AS CHECKBOX DEFAULT 'X'. SELECTION-SCREEN END OF BLOCK BLK1. SELECTION-SCREEN BEGIN OF BLOCK BLK2 WITH FRAME TITLE TEXT-002.
PARAMETERS: P_PC RADIOBUTTON GROUP RAD1 DEFAULT 'X',
P_MT RADIOBUTTON GROUP RAD1.
SELECTION-SCREEN END OF BLOCK BLK2. *----------------------------------------------------------------------
*程序初始化
*----------------------------------------------------------------------
INITIALIZATION.
* 初始化数据
PERFORM FRM_INITIAL. *----------------------------------------------------------------------
*权限检查事件
*----------------------------------------------------------------------
AT SELECTION-SCREEN.
* 权限检查部分
PERFORM FRM_CHECK_AUTHOR. *======================================================================
* MAIN PROGRAM
*======================================================================
*主程序逻辑
*----------------------------------------------------------------------
START-OF-SELECTION.
**查数据
PERFORM FRM_GET_DATA.
CHECK G_ERR EQ SPACE.
PERFORM FRM_ALV_DISPLAY. *&---------------------------------------------------------------------*
*& Form FRM_INITIAL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_INITIAL . **
**
**
*8 IF S_ERDAT[] IS INITIAL.
S_ERDAT(3) = 'IEQ'.
S_ERDAT-LOW = SY-DATUM+0(6) && '01'.
CALL FUNCTION 'DATE_GET_MONTH_LASTDAY'
EXPORTING
I_DATE
= SY-DATUM
IMPORTING
E_DATE
= S_ERDAT-HIGH.
APPEND S_ERDAT.
ENDIF. LOOP AT SCREEN.
**分销渠道不允许输入
IF SCREEN-NAME = 'P_VTWEG'.
SCREEN-INPUT = 0.
ENDIF.
MODIFY SCREEN.
ENDLOOP. ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_CHECK_AUTHOR
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_CHECK_AUTHOR .
**检查销售组织权限
AUTHORITY-CHECK OBJECT 'V_VBAK_VKO'
ID 'VKORG' FIELD P_VKORG
ID 'VTWEG' FIELD P_VTWEG
ID 'SPART' DUMMY
ID 'ACTVT' FIELD '03'.
IF SY-SUBRC <> 0.
MESSAGE E002 WITH P_VKORG.
ENDIF. ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_GET_DATA .
DATA:LT_ALV LIKE GT_ALV,
LS_ALV
LIKE LINE OF LT_ALV.
DATA:LT_TVAKT LIKE TABLE OF TVAKT,
LS_TVAKT
LIKE LINE OF LT_TVAKT.
DATA:LT_KNA1 LIKE TABLE OF KNA1,
LS_KNA1
LIKE LINE OF LT_KNA1.
DATA:LT_TVKBT LIKE TABLE OF TVKBT,
LS_TVKBT
LIKE LINE OF LT_TVKBT.
DATA:LT_TVGRT LIKE TABLE OF TVGRT,
LS_TVGRT
LIKE LINE OF LT_TVGRT.
DATA:LS_TXTID LIKE THEAD-TDID,
LS_NAME
LIKE THEAD-TDNAME,
LS_OBJECT
LIKE THEAD-TDOBJECT.
DATA:LT_ADRP LIKE TABLE OF ADRP,
LS_ADRP
LIKE LINE OF LT_ADRP.
DATA:LS_SUR21 LIKE USR21.
DATA: LT_TVKOT LIKE TABLE OF TVKOT,
LS_TVKOT
LIKE LINE OF LT_TVKOT.
DATA: LT_T005T LIKE TABLE OF T005T,
LS_T005T
LIKE LINE OF LT_T005T.
DATA: LT_T052U LIKE TABLE OF T052U,
LS_T052U
LIKE LINE OF LT_T052U.
DATA: LT_T005U LIKE TABLE OF T005U,
LS_T005U
LIKE T005U.
DATA: LT_TVTWT LIKE TABLE OF TVTWT,
LS_TVTWT
LIKE TVTWT.
DATA: LS_TVKO LIKE TVKO,
LS_ADRC
LIKE ADRC. SELECT DISTINCT
A
~VBELN
A
~AUART
A
~KUNNR
A
~VKBUR
A
~VKGRP
A
~VKORG
A
~ERDAT
A
~ZZCMT
A
~WAERK
A
~ZZYWY
A
~ZZCDHXXH
A
~VTWEG
"客户地址(收件信息)
A
~ZSHADR
A
~ZSHNAME
A
~ZSHTEL B ~BSTKD
B
~INCO1
B
~INCO2
B
~ZTERM
INTO CORRESPONDING FIELDS OF TABLE GT_ALV
FROM VBAK AS A
JOIN VBKD AS B
ON A~VBELN EQ B~VBELN
WHERE A~VKORG = P_VKORG
AND A~VTWEG EQ P_VTWEG
AND A~VBELN IN S_VBELN
AND A~AUART IN S_AUART
AND A~KUNNR IN S_KUNNR
AND A~ERDAT IN S_ERDAT. **销售部门
SELECT VKBUR BEZEI
INTO CORRESPONDING FIELDS OF TABLE LT_TVKBT
FROM TVKBT
WHERE SPRAS = SY-LANGU.
**销售组 描述-VBAK-VKGRP 【TVGRT-VKGRP】
SELECT VKGRP BEZEI
INTO CORRESPONDING FIELDS OF TABLE LT_TVGRT
FROM TVGRT
WHERE SPRAS EQ SY-LANGU.
**取分销渠道
SELECT VTWEG VTEXT
INTO CORRESPONDING FIELDS OF TABLE LT_TVTWT
FROM TVTWT
WHERE SPRAS EQ SY-LANGU
AND VTWEG = P_VTWEG.
**销售组织描述 【TVKOT】
SELECT SPRAS
VKORG
VTEXT
INTO CORRESPONDING FIELDS OF TABLE LT_TVKOT
FROM TVKOT
WHERE VKORG = P_VKORG. **
SELECT SINGLE VKORG ADRNR
INTO CORRESPONDING FIELDS OF LS_TVKO
FROM TVKO
WHERE VKORG = P_VKORG. SELECT SINGLE ADDRNUMBER
DATE_FROM
NATION
DATE_TO TITLE
NAME1
NAME2
NAME3
NAME4
NAME_TEXT
INTO CORRESPONDING FIELDS OF LS_ADRC
FROM ADRC
WHERE ADDRNUMBER = LS_TVKO-ADRNR
AND DATE_FROM < SY-DATUM
AND DATE_TO > SY-DATUM. **取客户名称 KUNNR-NAME1
LT_ALV
= GT_ALV.
SORT LT_ALV BY KUNNR.
DELETE ADJACENT DUPLICATES FROM LT_ALV COMPARING KUNNR.
IF LT_ALV IS NOT INITIAL.
SELECT KUNNR NAME1 NAME2
TELF1 TELFX
"电话,传真
LAND1 REGIO ORT01 ZZQXMC STRAS
INTO CORRESPONDING FIELDS OF TABLE LT_KNA1
FROM KNA1
FOR ALL ENTRIES IN LT_ALV
WHERE KUNNR = LT_ALV-KUNNR.
SORT LT_KNA1 BY KUNNR.
ENDIF. IF LT_KNA1 IS NOT INITIAL.
SELECT LAND1 BLAND BEZEI
INTO CORRESPONDING FIELDS OF TABLE LT_T005U
FROM T005U
FOR ALL ENTRIES IN LT_KNA1
WHERE SPRAS = SY-LANGU
AND LAND1 = LT_KNA1-LAND1
AND BLAND = LT_KNA1-REGIO.
ENDIF. IF LT_KNA1 IS NOT INITIAL.
**取国名
SELECT LAND1 LANDX
INTO CORRESPONDING FIELDS OF TABLE LT_T005T
FROM T005T
FOR ALL ENTRIES IN LT_KNA1
WHERE SPRAS = SY-LANGU
AND LAND1 = LT_KNA1-LAND1.
SORT LT_T005T BY LAND1.
ENDIF. **取付款方式描述T052U
SELECT ZTERM ZTAGG TEXT1
INTO CORRESPONDING FIELDS OF TABLE LT_T052U
FROM T052U
WHERE SPRAS = SY-LANGU. **DATA processing
LOOP AT GT_ALV ASSIGNING <FS_ALV>. * READ TABLE LT_KNA1 INTO LS_KNA1. **取销售办事处描述 TVKBT-VKBUR
READ TABLE LT_TVKBT INTO LS_TVKBT WITH KEY VKBUR = <FS_ALV>-VKBUR.
IF SY-SUBRC EQ 0.
<FS_ALV>
-VKBURTXT = LS_TVKBT-BEZEI.
ENDIF. **分销渠道
READ TABLE LT_TVTWT INTO LS_TVTWT WITH KEY VTWEG = <FS_ALV>-VTWEG.
IF SY-SUBRC EQ 0.
<FS_ALV>
-VTWEGTXT = LS_TVTWT-VTEXT.
ENDIF.
**销售组
READ TABLE LT_TVGRT INTO LS_TVGRT WITH KEY VKGRP = <FS_ALV>-VKGRP.
IF SY-SUBRC EQ 0.
<FS_ALV>
-VKGRPTXT = LS_TVGRT-BEZEI.
ENDIF.
**销售组织
READ TABLE LT_TVKOT INTO LS_TVKOT WITH KEY VKORG = <FS_ALV>-VKORG
SPRAS
= 'ZH'.
IF SY-SUBRC EQ 0.
<FS_ALV>
-VKORGTXT = LS_TVKOT-VTEXT.
ENDIF.
READ TABLE LT_TVKOT INTO LS_TVKOT WITH KEY VKORG = <FS_ALV>-VKORG
SPRAS
= 'EN'.
IF SY-SUBRC EQ 0.
<FS_ALV>
-VKORGEN = LS_TVKOT-VTEXT.
ENDIF. **库存地点
SELECT SINGLE WERKS LGORT
INTO ( <FS_ALV>-WERKS,<FS_ALV>-LGORT )
FROM VBAP
WHERE VBELN = <FS_ALV>-VBELN
AND POSNR = '000010'. **地址
CONCATENATE <FS_ALV>-ZSHADR <FS_ALV>-ZSHNAME <FS_ALV>-ZSHTEL INTO <FS_ALV>-ZSHADR SEPARATED BY SPACE.
**客户名称
READ TABLE LT_KNA1 INTO LS_KNA1 WITH KEY KUNNR = <FS_ALV>-KUNNR.
IF SY-SUBRC EQ 0.
<FS_ALV>
-NAME1 = LS_KNA1-NAME1 && LS_KNA1-NAME2.
<FS_ALV>
-TELF1 = LS_KNA1-TELF1.
<FS_ALV>
-TELFX = LS_KNA1-TELFX.
<FS_ALV>
-ADDRESS = LS_KNA1-STRAS.
**国名
<FS_ALV>
-LAND1 = LS_KNA1-LAND1.
<FS_ALV>
-LANDX = LS_KNA1-ORT01.
**取客户收货地址
IF <FS_ALV>-ZSHADR EQ SPACE.
READ TABLE LT_T005U INTO LS_T005U WITH KEY LAND1 = LS_KNA1-LAND1
BLAND
= LS_KNA1-REGIO.
IF LS_KNA1-ORT01 = '市辖区'.
<FS_ALV>
-ZSHADR = LS_T005U-BEZEI && LS_KNA1-ZZQXMC && LS_KNA1-STRAS.
ELSE.
<FS_ALV>
-ZSHADR = LS_T005U-BEZEI && LS_KNA1-ORT01 && LS_KNA1-ZZQXMC && LS_KNA1-STRAS.
ENDIF.
ENDIF.
ENDIF. CONCATENATE <FS_ALV>-inco1 <FS_ALV>-INCO2 INTO <FS_ALV>-INCO2 SEPARATED BY space. ENDLOOP. G_LINES = LINES( GT_ALV ).
IF G_LINES EQ 0.
G_ERR
= 'X'.
MESSAGE S004 DISPLAY LIKE 'E'.
ELSE.
MESSAGE S006 WITH G_LINES.
ENDIF. ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_ALV_DISPLAY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_ALV_DISPLAY .
DEFINE GD_FIELDCAT.
CLEAR:GS_FCAT.
GS_FCAT
-TABNAME = 'GT_ALV'.
GS_FCAT
-FIELDNAME = &1.
GS_FCAT
-SCRTEXT_L = &2.
GS_FCAT
-SCRTEXT_M = &2.
GS_FCAT
-SCRTEXT_S = &2.
GS_FCAT
-NO_OUT = &3.
GS_FCAT
-OUTPUTLEN = &4.
GS_FCAT
-DO_SUM = &5.
GS_FCAT
-HOTSPOT = &6.
GS_FCAT
-CHECKBOX = &7.
GS_FCAT
-EDIT = &8.
APPEND GS_FCAT TO GT_FCAT.
END-OF-DEFINITION. REFRESH: GT_FCAT.
GD_FIELDCAT
:
'BOX' '选择' '' '' '' '' 'X' 'X' , 'VBELN ' '销售订单' '' '' '' '' '' '' ,
'VKORG ' '销售组织' '' '' '' '' '' '' ,
'VKORGTXT' '销售组织描述' '' '' '' '' '' '' ,
'VTWEG ' '分销渠道' '' '' '' '' '' '' ,
'VTWEGTXT' '分销渠道描述' '' '' '' '' '' '' ,
'VKBUR ' '销售部门' '' '' '' '' '' '' ,
'VKBURTXT' '销售部门描述' '' '' '' '' '' '' ,
'VKGRP ' '销售组' '' '' '' '' '' '' ,
'VKGRPTXT' '销售组描述' '' '' '' '' '' '' ,
'WERKS' '工厂' '' '' '' '' '' '' ,
'LGORT' '库存地点' '' '' '' '' '' '' , 'KUNNR ' '售达方' '' '' '' '' '' '' ,
'NAME1' '售达方名称' '' '' '' '' '' '' ,
'LANDX' '国家' '' '' '' '' '' '' ,
'ERDAT' '创建日期' '' '' '' '' '' '' . ** layout set
G_REPID
= SY-REPID.
GS_LAYOUT
-ZEBRA = 'X'.
GS_LAYOUT
-CWIDTH_OPT = 'X'.
* GS_LAYOUT-EXCP_FNAME = 'ICON'.
* GS_LAYOUT-EXCP_LED = 'X'.
GS_S_GLAY
-EDT_CLL_CB = 'X'. ** call ALV
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
* I_BUFFER_ACTIVE =
I_CALLBACK_PROGRAM
= G_REPID
I_GRID_SETTINGS
= GS_S_GLAY
I_CALLBACK_PF_STATUS_SET
= 'FRM_SET_PF_STATUS'
I_CALLBACK_USER_COMMAND
= 'FRM_USER_COMMAND'
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
IS_LAYOUT_LVC
= GS_LAYOUT
IT_FIELDCAT_LVC
= GT_FCAT[]
* IT_EXCLUDING =
I_SAVE
= 'A'
TABLES
T_OUTTAB
= GT_ALV
EXCEPTIONS
PROGRAM_ERROR
= 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF. ENDFORM.
*&---------------------------------------------------------------------*
*& Form set_pf_status
*&---------------------------------------------------------------------*
FORM FRM_SET_PF_STATUS USING AB TYPE SLIS_T_EXTAB.
*--- Structure for the excluding table (function codes)
DATA: BEGIN OF EX_TAB OCCURS 0,
FCODE
LIKE RSMPE-FUNC,
END OF EX_TAB. EX_TAB -FCODE = '&PRINT'.
APPEND EX_TAB. SET PF-STATUS 'SET_PF_STATUS' EXCLUDING EX_TAB.
ENDFORM. "set_pf_status
*&---------------------------------------------------------------------*
*& Form user_command
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->R_UCOMM text
* -->rS_SELFIELD text
*----------------------------------------------------------------------*
FORM FRM_USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD
TYPE SLIS_SELFIELD.
DATA: LR_GRID TYPE REF TO CL_GUI_ALV_GRID. CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID
= LR_GRID.
CALL METHOD LR_GRID->CHECK_CHANGED_DATA.
RS_SELFIELD
-REFRESH = 'X'. *
*
CASE R_UCOMM .
WHEN '&ZALL'.
PERFORM FRM_ALL.
WHEN '&ZSAL'.
PERFORM FRM_SALL.
WHEN '&EXCEL'.
READ TABLE GT_ALV INTO GS_ALV WITH KEY BOX = 'X'.
IF SY-SUBRC <> 0.
MESSAGE E007.
ENDIF.
*BREAK IBM-CAIXIANG.
PERFORM FRM_PRINT_EXCEL. WHEN '&IC1'.
**是否需要显示明细?
READ TABLE GT_ALV INTO GS_ALV INDEX RS_SELFIELD-TABINDEX .
IF RS_SELFIELD-FIELDNAME EQ 'VBELN' .
IF GS_ALV-VBELN IS NOT INITIAL .
SET PARAMETER ID 'AUN' FIELD GS_ALV-VBELN.
CALL TRANSACTION 'VA03' WITH AUTHORITY-CHECK AND SKIP FIRST SCREEN.
ENDIF .
ENDIF. WHEN OTHERS.
*'@5C@'."红灯,@5B@ 绿灯
ENDCASE. * PERFORM FRM_REFRESH.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_ALL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_ALL .
LOOP AT GT_ALV ASSIGNING <FS_ALV>.
<FS_ALV>
-BOX = 'X'.
ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_SALL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_SALL .
LOOP AT GT_ALV ASSIGNING <FS_ALV>.
<FS_ALV>
-BOX = ''.
ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_READ_TEXT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LS_TXTID text
* -->P_LS_NAME text
* -->P_LS_OBJECT text
* <--P_<FS_ALV>_DNTXT text
*----------------------------------------------------------------------*
FORM FRM_READ_TEXT USING P_TXTID TYPE THEAD-TDID
P_NAME
TYPE THEAD-TDNAME
P_OBJECT
TYPE THEAD-TDOBJECT
CHANGING P_DNTXT TYPE CHAR255. DATA: BEGIN OF LT_LINES OCCURS 50.
INCLUDE STRUCTURE TLINE.
DATA: END OF LT_LINES.
DATA: S_LINE(255) TYPE C. CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
ID = P_TXTID
LANGUAGE = SY-LANGU
NAME
= P_NAME
OBJECT
= P_OBJECT
* IMPORTING
* HEADER = LS_HEADER
TABLES
LINES = LT_LINES
EXCEPTIONS
ID = 01
LANGUAGE = 02
NAME
= 03
NOT_FOUND
= 04
OBJECT
= 05
REFERENCE_CHECK
= 06
WRONG_ACCESS_TO_ARCHIVE
= 07
OTHERS = 08.
IF SY-SUBRC = 0.
LOOP AT LT_LINES.
IF LT_LINES-TDLINE NE ''.
CONCATENATE S_LINE LT_LINES-TDLINE INTO S_LINE.
ENDIF.
ENDLOOP.
ENDIF. P_DNTXT = S_LINE. ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_GET_ITEM
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_GET_ITEM .
DATA:LT_ITEM LIKE TABLE OF GS_ITEM,
LS_ITEM
LIKE GS_ITEM. SELECT VBELN
POSNR
MATNR
ARKTX
VRKME
KWMENG
ZZCSJH
VOLUM
NTGEW
BRGEW
KZWI1
LGORT
CHARG
WERKS
INTO CORRESPONDING FIELDS OF TABLE GT_ITEM
FROM VBAP
WHERE VBELN = <FS_ALV>-VBELN.
SORT GT_ITEM BY MATNR. LOOP AT GT_ITEM INTO GS_ITEM.
**根据物料汇总
LS_ITEM
-VBELN = GS_ITEM-VBELN.
LS_ITEM
-MATNR = GS_ITEM-MATNR.
LS_ITEM
-ARKTX = GS_ITEM-ARKTX.
LS_ITEM
-KWMENG = GS_ITEM-KWMENG.
LS_ITEM
-VRKME = GS_ITEM-VRKME. LS_ITEM -ZZCSJH = GS_ITEM-ZZCSJH.
LS_ITEM
-VOLUM = GS_ITEM-VOLUM.
LS_ITEM
-NTGEW = GS_ITEM-NTGEW.
LS_ITEM
-BRGEW = GS_ITEM-BRGEW.
LS_ITEM
-KZWI1 = GS_ITEM-KZWI1.
IF GS_ITEM-KWMENG NE 0.
LS_ITEM
-NETPR = GS_ITEM-KZWI1 / GS_ITEM-KWMENG.
ENDIF. **单位文本
SELECT SINGLE MSEHT INTO LS_ITEM-ZDW
FROM T006A
WHERE MSEHI = LS_ITEM-VRKME
AND SPRAS = SY-LANGU. DATA: LV_MENGE LIKE EKPO-MENGE, "收货数量
XL_UNIT
LIKE MARA-MEINS. "目标单位 **转换单位为pc
IF GS_ITEM-VRKME NE 'ST'.
CLEAR: LV_MENGE.
XL_UNIT
= 'ST'.
PERFORM FRM_CONVER_UNIT USING LS_ITEM-MATNR LS_ITEM-VRKME XL_UNIT LS_ITEM-KWMENG
CHANGING LS_ITEM-ZPC.
ELSE.
LS_ITEM
-ZPC = LS_ITEM-KWMENG.
ENDIF. COLLECT LS_ITEM INTO LT_ITEM. <FS_ALV> -ZTJ = GS_ITEM-VOLUM + <FS_ALV>-ZTJ.
<FS_ALV>
-ZJZ = GS_ITEM-NTGEW + <FS_ALV>-ZJZ.
<FS_ALV>
-ZMZ = GS_ITEM-BRGEW + <FS_ALV>-ZMZ.
<FS_ALV>
-ZSL = LS_ITEM-ZPC + <FS_ALV>-ZSL.
<FS_ALV>
-ZJE = GS_ITEM-KZWI1 + <FS_ALV>-ZJE.
ENDLOOP. GT_ITEM = LT_ITEM. **数量总计转大写EN
DATA:LS_SPELL TYPE SPELL,
L_LANGU
TYPE SY-LANGU.
L_LANGU
= 'E'.
CLEAR:LS_SPELL.
* <FS_ALV>-ZSLEN = <FS_ALV>-ZSL / 100.
* <FS_ALV>-ZSLEN = <FS_ALV>-ZSLEN * 100.
G_TABIX
= <FS_ALV>-ZSL. CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
AMOUNT
= G_TABIX
* CURRENCY = 'CNY'
* FILLER = ' '
LANGUAGE = L_LANGU
IMPORTING
IN_WORDS
= LS_SPELL
EXCEPTIONS
NOT_FOUND
= 1
TOO_LARGE
= 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE S001.
" Implement suitable error handling here
ENDIF. <FS_ALV> -ZSLEN = LS_SPELL-WORD. CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
AMOUNT
= <FS_ALV>-ZJE
CURRENCY = 'USD'
* FILLER = ' '
LANGUAGE = L_LANGU
IMPORTING
IN_WORDS
= LS_SPELL
EXCEPTIONS
NOT_FOUND
= 1
TOO_LARGE
= 2
OTHERS = 3.
IF SY-SUBRC <> 0.
" Implement suitable error handling here
ENDIF.
<FS_ALV>
-ZJEEN = LS_SPELL-WORD. ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_PRINT_EXCEL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_PRINT_EXCEL .
DATA:LDF_PATH TYPE LOCALFILE. **选择文件夹
PERFORM FRM_GET_PATH CHANGING GDF_PATH GDF_FILENAME GDF_FULLPATH . IF GDF_FULLPATH IS INITIAL .
MESSAGE I066."'请选择要保存的文件夹和输入文件名' TYPE 'I'.
ELSE. **循环,一张by一张 进行处理
LOOP AT GT_ALV ASSIGNING <FS_ALV> WHERE BOX = 'X'. PERFORM FRM_GET_ITEM.
**一个单据保存一个文件,【出口装箱单:<FS_ALV>-VBELN 】
CLEAR LDF_PATH.
LDF_PATH
= '出口商业发票' && <FS_ALV>-VBELN && '.xls'.
CONCATENATE GDF_PATH LDF_PATH INTO LDF_PATH.
PERFORM FRM_OUTPUT_EXCEL TABLES GT_ITEM USING 'ZZCSDRP_0030' LDF_PATH . ENDLOOP. ENDIF. ENDFORM. *&---------------------------------------------------------------------*
*& Form FRM_GET_PATH
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_GET_PATH CHANGING:FU_PATH
FU_FILENAME
FU_FULLPATH . FU_FILENAME = '出口装箱单:'. CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG
EXPORTING
WINDOW_TITLE
= 'Select Folder and Enter Filename to Save File'
DEFAULT_EXTENSION
= 'xls'
* DEFAULT_FILE_NAME = '出口装箱单:'
* WITH_ENCODING =
FILE_FILTER
= '*.xls'
* INITIAL_DIRECTORY =
* PROMPT_ON_OVERWRITE = 'X'
CHANGING
FILENAME
= FU_FILENAME
PATH
= FU_PATH
FULLPATH
= FU_FULLPATH
* USER_ACTION =
* FILE_ENCODING =
EXCEPTIONS
CNTL_ERROR
= 1
ERROR_NO_GUI
= 2
NOT_SUPPORTED_BY_GUI
= 3
INVALID_DEFAULT_FILE_NAME
= 4
OTHERS = 5.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF. ENDFORM. " FRM_GET_PATH
*&---------------------------------------------------------------------*
*& Form FRM_OUTPUT_EXCEL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_OUTPUT_EXCEL TABLES PT_EXCEL TYPE STANDARD TABLE
USING PV_TEMPLATE TYPE BDS_PROPVA
PV_FILE
TYPE LOCALFILE. DATA:L_IREF_TEMPLATE TYPE REF TO CL_BDS_DOCUMENT_SET,
L_OREF_CONTAINER
TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
L_IREF_CONTROL
TYPE REF TO I_OI_CONTAINER_CONTROL,
L_IREF_ERROR
TYPE REF TO I_OI_ERROR,
L_IREF_DOCUMENT
TYPE REF TO I_OI_DOCUMENT_PROXY,
* L_IREF_SPREADSHEET TYPE REF TO I_OI_SPREADSHEET,
L_RETCODE
TYPE SOI_RET_STRING. DATA:LT_SIGNATURE TYPE SBDST_SIGNATURE,
LW_SIGNATURE
TYPE BAPISIGNAT,
LT_URI
TYPE SBDST_URI,
LW_URI
TYPE BAPIURI,
LT_SHEET
TYPE SOI_SHEETS_TABLE,
L_DOC
TYPE CNTL_HANDLE,
L_APL
TYPE OBJ_RECORD,
LW_SHEET
TYPE SOI_SHEETS. DATA:LT_FIELDS TYPE STANDARD TABLE OF RFC_FIELDS,
LS_FIELDS
TYPE RFC_FIELDS,
LV_LAST_ROW
TYPE I,
LV_LAST_COL
TYPE I.
DATA: GDF_ERROR TYPE REF TO I_OI_ERROR,
GDS_ERRORS
TYPE REF TO I_OI_ERROR OCCURS 0 WITH HEADER LINE. DATA:LDF_OBJECTKEY TYPE BAPIBDS01-OBJKEY.
*&1.创建容器控制器实例
CALL METHOD C_OI_CONTAINER_CONTROL_CREATOR=>GET_CONTAINER_CONTROL
IMPORTING
CONTROL = L_IREF_CONTROL
RETCODE
= L_RETCODE. CHECK L_RETCODE = C_OI_ERRORS=>RET_OK.
*&2.初始化容器
CALL METHOD L_IREF_CONTROL->INIT_CONTROL
EXPORTING
R3_APPLICATION_NAME
= PV_TEMPLATE
INPLACE_ENABLED
= 'X'
INPLACE_SCROLL_DOCUMENTS
= 'X'
PARENT
= L_OREF_CONTAINER
IMPORTING
RETCODE
= L_RETCODE.
IF L_RETCODE <> C_OI_ERRORS=>RET_OK.
MESSAGE E067. "'保存Excel文件出错' TYPE 'E'.
ENDIF. CHECK L_RETCODE = C_OI_ERRORS=>RET_OK.
*&3.上传模板的关键字:SBDST_SIGNATURE
* LW_SIGNATURE-PROP_NAME = 'BDS_KEYWORD'.
* LW_SIGNATURE-PROP_VALUE = PV_TEMPLATE.
* APPEND LW_SIGNATURE TO LT_SIGNATURE. **3取得模板地址
REFRESH LT_URI.
CLEAR LDF_OBJECTKEY.
MOVE PV_TEMPLATE TO LDF_OBJECTKEY.
* BDS对象实例化
CREATE OBJECT L_IREF_TEMPLATE.
* 读取BDS的URL
CALL METHOD L_IREF_TEMPLATE->GET_WITH_URL
EXPORTING
CLASSNAME
= 'SOFFICEINTEGRATION'
CLASSTYPE
= 'OT'
OBJECT_KEY
= LDF_OBJECTKEY
CHANGING
URIS
= LT_URI
* SIGNATURE = LT_SIGNATURE
EXCEPTIONS
NOTHING_FOUND
= 1
ERROR_KPRO
= 2
INTERNAL_ERROR
= 3
PARAMETER_ERROR
= 4
NOT_AUTHORIZED
= 5
NOT_ALLOWED
= 6. CLEAR LW_URI.
READ TABLE LT_URI INTO LW_URI INDEX 1.
IF SY-SUBRC <> 0.
MESSAGE E069. "'请检查EXCEL模板不存在或者设置不正确' TYPE 'E'.
ENDIF. CHECK SY-SUBRC = 0.
**4.容器控制器获得一个EXCEL文档代理
CALL METHOD L_IREF_CONTROL->GET_DOCUMENT_PROXY
EXPORTING
DOCUMENT_TYPE
= 'Excel.Sheet'
IMPORTING
DOCUMENT_PROXY
= L_IREF_DOCUMENT
RETCODE
= L_RETCODE.
IF L_RETCODE <> C_OI_ERRORS=>RET_OK.
MESSAGE E067. "'保存Excel文件出错' TYPE 'E'.
ENDIF.
CHECK L_RETCODE = C_OI_ERRORS=>RET_OK. **容器控制器中打开指定BDS返回的文档
**You use this method to open an existing document. The document must be stored in in internal table in the ABAP program.
CALL METHOD L_IREF_DOCUMENT->OPEN_DOCUMENT
EXPORTING
DOCUMENT_URL
= LW_URI-URI
OPEN_INPLACE
= 'X'
IMPORTING
RETCODE
= L_RETCODE.
IF L_RETCODE <> C_OI_ERRORS=>RET_OK.
MESSAGE E067. "'保存Excel文件出错' TYPE 'E'.
ENDIF. CHECK L_RETCODE = C_OI_ERRORS=>RET_OK.
FREE L_IREF_ERROR.
**创建一个用于管理电子表格界面的实例界面。
**Creates an instance sheet_interface for managing the spreadsheet interface.
CALL METHOD L_IREF_DOCUMENT->GET_SPREADSHEET_INTERFACE
IMPORTING
ERROR
= L_IREF_ERROR
SHEET_INTERFACE
= L_IREF_SPREADSHEET.
**Get the Names of Worksheets
CALL METHOD L_IREF_SPREADSHEET->GET_SHEETS
IMPORTING
SHEETS
= LT_SHEET
ERROR
= L_IREF_ERROR. CHECK L_IREF_ERROR->ERROR_CODE = C_OI_ERRORS=>RET_OK.
CLEAR LW_SHEET. READ TABLE LT_SHEET INTO LW_SHEET INDEX 1.
CHECK SY-SUBRC = 0.
**Activate a Sheet
CALL METHOD L_IREF_SPREADSHEET->SELECT_SHEET
EXPORTING
NAME
= LW_SHEET-SHEET_NAME
IMPORTING
ERROR
= L_IREF_ERROR. CHECK L_IREF_ERROR->ERROR_CODE = C_OI_ERRORS=>RET_OK.
** calculate The columns of Data
* REFRESH LT_FIELDS.
* CALL FUNCTION 'DP_GET_FIELDS_FROM_TABLE'
* TABLES
* DATA = PT_EXCEL
* FIELDS = LT_FIELDS.
* BREAK IBM-CAIXIANG. DATA: LINE TYPE I,
COLUMN
TYPE I. **订单号:
LINE = 10. COLUMN = 2.
PERFORM FILL_CELL USING LINE COLUMN <FS_ALV>-ZZCDHXXH.
**客户:
LINE = 16. COLUMN = 2.
PERFORM FILL_CELL USING LINE COLUMN <FS_ALV>-KUNNR.
**地址:
LINE = 17. COLUMN = 2.
PERFORM FILL_CELL USING LINE COLUMN <FS_ALV>-ZSHADR.
**From:
LINE = 22. COLUMN = 2. PERFORM FILL_CELL USING LINE COLUMN 'XIAMEN'."<FS_ALV>-INCO2 .
**To:手工输入
* LINE = 16. COLUMN = 3.
* PERFORM FILL_CELL USING LINE COLUMN <FS_ALV>-ZSHADR.
**销售组织地址
* LINE = 4. COLUMN = 8.
** COLUMN = 7.
* PERFORM FILL_CELL USING LINE COLUMN <FS_ALV>-ADDRESS.
**发票号
LINE = 10. COLUMN = 7.
PERFORM FILL_CELL USING LINE COLUMN <FS_ALV>-BSTKD.
**日期 = 销售订单日期
LINE = 13. COLUMN = 7.
PERFORM FILL_CELL USING LINE COLUMN <FS_ALV>-ERDAT. IF P_PC EQ 'X'.
**(批次号)
<FS_ALV>
-XM_EN = 'Batch Number'.
<FS_ALV>
-XM_ZH = '(批次号)'.
ELSE.
**(唛头)
<FS_ALV>
-XM_EN = 'Marks'.
<FS_ALV>
-XM_ZH = '(唛头)'.
ENDIF.
LINE = 24. COLUMN = 1.
PERFORM FILL_CELL USING LINE COLUMN <FS_ALV>-XM_EN.
LINE = 25. COLUMN = 1.
PERFORM FILL_CELL USING LINE COLUMN <FS_ALV>-XM_ZH. **--->begin add by ibm_caixiang on 14.12.2017 16:08:06 req by ibm_xxx.
**功能描述:Unit Price
** (单价) 下面的值
LINE = 26. COLUMN = 6.
PERFORM FILL_CELL USING LINE COLUMN <FS_ALV>-INCO2. **--->end add by ibm_caixaing 14.12.2017 16:08:06. **USD/cny
LINE = 26. COLUMN = 7.
PERFORM FILL_CELL USING LINE COLUMN <FS_ALV>-WAERK. **项目写入Excel
LOOP AT GT_ITEM ASSIGNING <FS_ITEM>.
G_TABIX
= SY-TABIX. **格式P_MT显示抬头唛头
IF P_MT EQ 'X'.
<FS_ITEM>
-ZZCSJH = <FS_ALV>-ZZCMT.
ENDIF.
**(批次号)
LINE = G_TABIX + 26. COLUMN = 1.
PERFORM FILL_CELL USING LINE COLUMN <FS_ITEM>-ZZCSJH.
**(件数)
LINE = G_TABIX + 26. COLUMN = 2.
PERFORM FILL_CELL USING LINE COLUMN <FS_ITEM>-ZPC.
**(品名)
LINE = G_TABIX + 26. COLUMN = 3.
PERFORM FILL_CELL USING LINE COLUMN <FS_ITEM>-ARKTX.
**有效期【手工输入】
* LINE = G_TABIX + 25. COLUMN = 7.
* PERFORM FILL_CELL USING LINE COLUMN <FS_ITEM>-VOLUM .
**(数量)
LINE = G_TABIX + 26. COLUMN = 4.
PERFORM FILL_CELL USING LINE COLUMN <FS_ITEM>-KWMENG.
**(单位)
LINE = G_TABIX + 26. COLUMN = 5.
PERFORM FILL_CELL USING LINE COLUMN <FS_ITEM>-ZDW.
**单价
LINE = G_TABIX + 26. COLUMN = 6.
PERFORM FILL_CELL USING LINE COLUMN <FS_ITEM>-NETPR .
**金额
LINE = G_TABIX + 26. COLUMN = 7.
PERFORM FILL_CELL USING LINE COLUMN <FS_ITEM>-KZWI1 . ENDLOOP. **SUM数量
LINE = LINE + 1. COLUMN = 1.
PERFORM FILL_CELL USING LINE COLUMN 'Total:'.
COLUMN
= 2.
PERFORM FILL_CELL USING LINE COLUMN <FS_ALV>-ZSL.
***SUM体积
* COLUMN = 7.
* PERFORM FILL_CELL USING LINE COLUMN <FS_ALV>-ZTJ .
***SUM净重
* COLUMN = 8.
* PERFORM FILL_CELL USING LINE COLUMN <FS_ALV>-ZJZ .
**SUM金额
COLUMN
= 7.
PERFORM FILL_CELL USING LINE COLUMN <FS_ALV>-ZJE . **数量总计
LINE = LINE + 1. COLUMN = 1.
PERFORM FILL_CELL USING LINE COLUMN 'TOTAL:'.
COLUMN
= 2.
PERFORM FILL_CELL USING LINE COLUMN <FS_ALV>-ZSLEN .
**金额总计
LINE = LINE + 1. COLUMN = 1.
PERFORM FILL_CELL USING LINE COLUMN 'TOTAL USD:'.
COLUMN
= 2.
PERFORM FILL_CELL USING LINE COLUMN <FS_ALV>-ZJEEN .
**----------------------------------------------------------------------
* LV_LAST_COL = LINES( LT_FIELDS ).
* CALL METHOD L_IREF_SPREADSHEET->SET_SELECTION
* EXPORTING
* LEFT = 1
* TOP = 2
* ROWS = 4"LV_LAST_ROW
* COLUMNS = 3."LV_LAST_COL.
*
* CALL METHOD L_IREF_SPREADSHEET->INSERT_RANGE
* EXPORTING
* COLUMNS = LV_LAST_COL
* ROWS = LV_LAST_ROW
* NAME = PV_TEMPLATE. * CALL METHOD L_IREF_SPREADSHEET->INSERT_ONE_TABLE
* EXPORTING
* DATA_TABLE = PT_EXCEL[]
* FIELDS_TABLE = LT_FIELDS
* RANGENAME = PV_TEMPLATE.
**---------------------------------------------------------------------- CALL METHOD L_IREF_DOCUMENT->SAVE_AS
EXPORTING
FILE_NAME
= PV_FILE. CALL METHOD L_IREF_DOCUMENT->RELEASE_DOCUMENT
IMPORTING
RETCODE
= L_RETCODE.
IF L_RETCODE <> C_OI_ERRORS=>RET_OK.
MESSAGE E067. "'保存Excel文件出错' TYPE 'E'.
ELSE.
MESSAGE S068. "'Excel文件已保存' TYPE 'S'.
ENDIF.
FREE: L_IREF_SPREADSHEET,
L_IREF_DOCUMENT
. CALL METHOD L_IREF_CONTROL->RELEASE_ALL_DOCUMENTS.
CALL METHOD L_IREF_CONTROL->DESTROY_CONTROL.
ENDFORM. " FRM_OUTPUT_EXCEL *———————————————————————*
* FORM fill_cell *
*———————————————————————*
FORM FILL_CELL USING I J VAL.
DATA: COLUMNS_NUMBER TYPE I,
ROWS_NUMBER
TYPE I. DATA: "SPREADSHEET TYPE REF TO I_OI_SPREADSHEET,
ERROR
TYPE REF TO I_OI_ERROR,
ERRORS
TYPE REF TO I_OI_ERROR OCCURS 0 WITH HEADER LINE.
DATA: RANGEITEM TYPE SOI_RANGE_ITEM.
DATA: RANGES TYPE SOI_RANGE_LIST,
EXCEL_INPUT
TYPE SOI_GENERIC_TABLE,
EXCEL_INPUT_WA
TYPE SOI_GENERIC_ITEM. COLUMNS_NUMBER = 1.
ROWS_NUMBER
= 1.
**根据它的尺寸得到一个范围
CALL METHOD L_IREF_SPREADSHEET->INSERT_RANGE_DIM
EXPORTING
NAME
= 'cell'
NO_FLUSH
= 'X'
TOP
= I
LEFT = J
ROWS = ROWS_NUMBER
COLUMNS
= COLUMNS_NUMBER
IMPORTING
ERROR
= ERRORS.
APPEND ERRORS. REFRESH: RANGES, EXCEL_INPUT.
RANGEITEM
-NAME = 'cell'.
RANGEITEM
-COLUMNS = 1.
RANGEITEM
-ROWS = 1.
APPEND RANGEITEM TO RANGES. EXCEL_INPUT_WA -COLUMN = 1.
EXCEL_INPUT_WA
-ROW = 1.
EXCEL_INPUT_WA
-VALUE = VAL.
APPEND EXCEL_INPUT_WA TO EXCEL_INPUT. * set data
CALL METHOD L_IREF_SPREADSHEET->SET_RANGES_DATA
EXPORTING
RANGES = RANGES
CONTENTS
= EXCEL_INPUT
NO_FLUSH
= 'X'
IMPORTING
ERROR
= ERRORS.
APPEND ERRORS. CALL METHOD L_IREF_SPREADSHEET->FIT_WIDEST
EXPORTING
NAME
= SPACE
NO_FLUSH
= 'X'. REFRESH: RANGES, EXCEL_INPUT. ENDFORM. "fill_cell
*&---------------------------------------------------------------------*
*& Form FRM_CONVER_UNIT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GS_ALV_MEIN2 text
* -->P_LS_RESB_MEINS text
* <--P_1 text
*----------------------------------------------------------------------*
FORM FRM_CONVER_UNIT USING
UV_MATNR
UV_IN
UV_OUT
UV_MENGE
CHANGING
CV_MENGE1
TYPE RESB-BDMNG.
DATA: LV_LVSME LIKE MLGN-LVSME, "仓库单位
LV_MENGE
LIKE EKPO-MENGE. "收货单位
CLEAR:LV_LVSME, LV_MENGE. CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
EXPORTING
I_MATNR
= UV_MATNR
I_IN_ME
= UV_IN "销售单位
I_OUT_ME
= UV_OUT "目标单位
I_MENGE
= 1
IMPORTING
E_MENGE
= LV_MENGE
EXCEPTIONS
ERROR_IN_APPLICATION
= 1
ERROR
= 2
OTHERS = 3. CV_MENGE1 = UV_MENGE * LV_MENGE. ENDFORM.
20171104 DOI Excel 导出的更多相关文章
- [moka同学笔记]PHPexcel之excel导出和导入
原案例来自http://www.sucaihuo.com/有修改 1.目录结构(文件不用解释,应该都可以看得懂,直接看代码)
- 偷懒小工具 - Excel导出公共类
说明 最近接了一个任务,就是做一个列表的Excel导出功能.并且有很多页面都会使用这个功能. 导出的Excel大体格式如图 很简单的列表,标题加背景色,然后不同类型,显示方式不一样.对齐方式不一样.不 ...
- 转:POI操作Excel导出
package com.rd.lh.util.excel; import java.beans.PropertyDescriptor; import java.io.FileOutputStream; ...
- TP5.0源生Excel导出
PHPExcel类在TP5里边并不能很好的兼容,使用起来很麻烦. 不像是tp3.2那样直接import()加进来就能new,因为它里边的命名空间找不到.总是说undefined class. 如果是使 ...
- java反射学习之二万能EXCEL导出
一.EXCEL导出的实现过程 假设有一个对象的集合,现在需要将此集合内的所有对象导出到EXCEL中,对象有N个属性:那么我们实现的方式是这样的: 循环这个集合,在循环集合中某个对象的所有属性,将这个对 ...
- Devexpress EXCEL导出
#region EXCEL导出 /// <summary> /// EXCEL导出 /// </summary> /// <param name="saveFi ...
- 自己写的java excel导出工具类
最近项目要用到excel导出功能,之前也写过类似的代码.因为这次项目中多次用到excel导出.这次长了记性整理了一下 分享给大伙 欢迎一起讨论 生成excel的主工具类: public class E ...
- 发邮件 和 excel导出中文文件名
/** * 发邮件 * @param email * @param subject * @param body * @throws UnsupportedEncodingException */ pu ...
- asp.net(C#) Excel导出类 导出.xls文件
---恢复内容开始--- using Microsoft.Office.Interop.Excel; 针对office 2003需添加引用Microsoft Excel 11.0 Obje ...
随机推荐
- 执行”spark-shell –master yarn –deploy-mode client”,虚拟内存大小溢出,报错
在Hadoop 2.7.2集群下执行如下命令: spark-shell --master yarn --deploy-mode client 爆出下面的错误: org.apache.spark.Sp ...
- 初识Quartz(一)
首先需要一个任务: ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 package quartz_proj ...
- 不同的Linux之间copy文件常用方法
第一种就是ftp,也就是其中一台Linux安装ftp Server,另外一台使用ftp的client程序来进行文件的copy. 第二种方法就是采用samba服务,类似Windows文件copy 的方式 ...
- win10虚拟环境安装scrapy
说明:本人用的是python3.6版本,64位系统. 第一步:创建并激活虚拟环境 virtualenv scrapy scrapy\Scripts\activate 第二步:安装lxml pip in ...
- 李洪强iOS下的实际网络连接状态检测
iOS下的实际网络连接状态检测 序言 网络连接状态检测对于我们的iOS app开发来说是一个非常通用的需求.为了更好的用户体验,我们会在无网络时展现本地或者缓存的内容,并对用户进行合适的提示.对绝大部 ...
- web开发中经常使用的js
将自己在web开发中经经常使用到的一些JS总结一下. 1.改动标签和表单的值 改动标签的值: var customer = document.getElementById("custm&qu ...
- Android Studio--NDK编译C代码为.so文件,JNI调用
前言: 从Android Studio开始,就支持jni和.so库调用了. 环境: Windows 7+Android Studio2.1.2+NDK版本:android-ndk-r10e 准备工作: ...
- <head> 或 <body> 中的 JavaScript
您可以在 HTML 文档中放入不限数量的脚本. 脚本可位于 HTML 的 <body> 或 <head> 部分中,或者同时存在于两个部分中. 通常的做法是把函数放入 <h ...
- Eclipse 窗口说明
Eclipse 窗口说明 Eclipse 工作台(Workbench) 首先,让我们来看一下Eclipse 作台用户界面,和它里面的各种组件. 工作台是多个窗口的集合.每个窗口包含菜单栏,工具栏,快捷 ...
- Struts2上传文件(1)
使用Struts框架后, Struts2框架不会处理multipart/form-data的请求,它需要调用其他的上传文件框架来解析二进制数据.但是Struts在原有的上传解析器基础上做了很多的封装, ...