SAP ERP ECC6.0标准功能提供给了金税接口,对于一般的公司来说,这个接口基本也够了。
事务代码:GT_DLN 下载SAP发票信息;
事务代码:GT_ULN 上传金税信息到SAP中;
前提条件:SAP ERP ECC6.0 功能增强包EHp3及以上。
激活业务功能事务代码 SFW5选择业务功能FIN_LOC_CI_1,点击激活按钮。
激活业务功能包后,系统将执行一个后台任务,执行可能需要长达一小时。
参见SAP Note:Note 1290073 – China Golden Tax Switch ActivateNote 1380072 – China Golden Tax Interface Legal Change for GTS 6.1x补充说明SAP 还提供了在创建系统发票时,根据发票限额自动进行分拆的程序原理是在复制控制中利用例程(roution)实现。参见SAP NoteNote 192558 – Template for invoice split with a maximum
amount per
invoice
下面是自开发的EXCEL版的金税下载程序。
*&---------------------------------------------------------------------*
*& Report ZSD_JSEXCEL
*&
*&---------------------------------------------------------------------*
*&
*&bruce 20131205
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*use the customer namespace. ZINV, Zbillexp, ZI, appended structure.
REPORT ZSD_JSEXCEL NO STANDARD PAGE HEADING MESSAGE-ID ZLC LINE-SIZE 255.
INCLUDE ZBILLTOP_TT1.
*INCLUDE ZBILLTOP.
INCLUDE ZSELECT_TT1.
*INCLUDE ZSELECT.
INITIALIZATION.
PERFORM INITIALIZATION.
AT SELECTION-SCREEN.
PERFORM CHECK_INPUT.
PERFORM AUTHORITY_CHECK USING ‘04‘ RC VKORG FKART.
START-OF-SELECTION.
* Get billing document header
PERFORM GET_VBRK.
END-OF-SELECTION.
SET PF-STATUS ‘LIST‘.
SET TITLEBAR ‘LIST‘.
PERFORM WRITE_BODY.
TOP-OF-PAGE.
SET LEFT SCROLL-BOUNDARY COLUMN 32.
PERFORM WRITE_TOPPAGE.
TOP-OF-PAGE DURING LINE-SELECTION.
SET LEFT SCROLL-BOUNDARY COLUMN 32.
PERFORM WRITE_TOPPAGE.
AT LINE-SELECTION.
CHECK NOT LIST_VBRK-VBELN IS INITIAL.
SET PARAMETER ID ‘VF‘ FIELD LIST_VBRK-VBELN.
CALL TRANSACTION ‘VF03‘ AND SKIP FIRST SCREEN.
AT USER-COMMAND.
CASE SY-UCOMM.
WHEN ‘SEL‘.
PERFORM SELECT_ALL.
WHEN ‘DSEL‘.
PERFORM DESELECT_ALL.
WHEN ‘PSEL‘.
PERFORM SELECT_PARTIAL.
WHEN ‘DNLD‘.
* Download billing document to file
PERFORM DOWNLOAD.
ENDCASE.
*&---------------------------------------------------------------------*
*& Form INITIALIZATION
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM INITIALIZATION.
FKART-LOW = ‘ZF2‘.
FKART-SIGN = ‘I‘.
FKART-OPTION = ‘EQ‘.
APPEND FKART.
FKART-LOW = ‘ZS2‘.
FKART-SIGN = ‘I‘.
FKART-OPTION = ‘EQ‘.
APPEND FKART.
FKART-LOW = ‘ZRE‘.
FKART-SIGN = ‘I‘.
FKART-OPTION = ‘EQ‘.
APPEND FKART.
WAERK-LOW = ‘RMB‘.
WAERK-SIGN = ‘I‘.
WAERK-OPTION = ‘EQ‘.
APPEND WAERK.
FKDAT-LOW = SY-DATUM.
FKDAT-HIGH = SY-DATUM.
FKDAT-SIGN = ‘I‘.
FKDAT-OPTION = ‘BT‘.
APPEND FKDAT.
* CALL CUSTOMER-FUNCTION ‘006‘
* TABLES
* VBELN = VBELN
* FKART = FKART
* KUNRG = KUNRG
* VSBED = VSBED
* BZIRK = BZIRK
* VKORG = VKORG
* VTWEG = VTWEG
* SPART = SPART
* WAERK = WAERK
* FKDAT = FKDAT
* CHANGING
* COMBINE = COMBINE
* EXCEPTIONS
* OTHERS = 1.
ENDFORM. " INITIALIZATION
*&---------------------------------------------------------------------*
*& Form CHECK_INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_INPUT.
IF VBELN IS INITIAL AND FKDAT IS INITIAL AND FKART IS INITIAL
AND VSBED IS INITIAL AND KUNRG IS INITIAL AND BZIRK IS INITIAL
AND VKORG IS INITIAL AND VTWEG IS INITIAL AND SPART IS INITIAL.
MESSAGE E201.
ENDIF.
IF FKDAT IS INITIAL AND VBELN IS INITIAL.
MESSAGE W202.
ENDIF.
IF NOT BZIRK IS INITIAL.
MOVE ‘I‘ TO: TEMP_VKORG-SIGN,
TEMP_VTWEG-SIGN,
TEMP_SPART-SIGN,
TEMP_KUNRG-SIGN.
MOVE ‘EQ‘ TO: TEMP_VKORG-OPTION,
TEMP_VTWEG-OPTION,
TEMP_SPART-OPTION,
TEMP_KUNRG-OPTION.
SELECT * FROM KNVV
WHERE KUNNR IN KUNRG
AND VKORG IN VKORG
AND VTWEG IN VTWEG
AND SPART IN SPART
AND BZIRK IN BZIRK.
MOVE KNVV-KUNNR TO TEMP_KUNRG-LOW.
MOVE KNVV-VKORG TO TEMP_VKORG-LOW.
MOVE KNVV-VTWEG TO TEMP_VTWEG-LOW.
MOVE KNVV-SPART TO TEMP_SPART-LOW.
COLLECT: TEMP_KUNRG, TEMP_VKORG, TEMP_VTWEG, TEMP_SPART.
ENDSELECT.
IF SY-SUBRC <> 0.
MESSAGE E205.
ELSE.
REFRESH: KUNRG, VKORG, VTWEG, SPART.
APPEND LINES OF: TEMP_KUNRG TO KUNRG,
TEMP_VKORG TO VKORG,
TEMP_VTWEG TO VTWEG,
TEMP_SPART TO SPART.
ENDIF.
ENDIF.
SELECT SINGLE * FROM VBRK
WHERE VBELN IN VBELN
AND FKART IN FKART
AND KUNRG IN KUNRG
AND VKORG IN VKORG
AND VTWEG IN VTWEG
AND VSBED IN VSBED
AND FKDAT IN FKDAT
AND SPART IN SPART
AND WAERK IN WAERK .
IF SY-SUBRC <> 0.
MESSAGE E203.
ENDIF.
IF NOT ‘RMB‘ IN WAERK.
MESSAGE W204.
ENDIF.
ENDFORM. " CHECK_INPUT
*&---------------------------------------------------------------------*
*& Form GET_VBRK
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_VBRK.
REFRESH LIST_VBRK.
SELECT * FROM VBRK
WHERE VBELN IN VBELN
AND FKART IN FKART
AND KUNRG IN KUNRG
AND VKORG IN VKORG
AND VTWEG IN VTWEG
AND VSBED IN VSBED
AND FKDAT IN FKDAT
AND SPART IN SPART
AND WAERK IN WAERK.
* and SFAKN = ‘ ‘.
MOVE-CORRESPONDING VBRK TO LIST_VBRK.
MOVE ‘X‘ TO LIST_VBRK-FLAG.
* Count the number of none-zero-items in a billing document
* The resault may not correct at this moment since there could
* be items combinated later.
SELECT COUNT(*) FROM VBRP INTO LIST_VBRK-NUM
WHERE VBELN = VBRK-VBELN
AND NETWR >< 0.
* Ignore the billing doc. if no none-zero-items exist
CHECK LIST_VBRK-NUM >< 0.
* Get the customer name and address as the invoice require.
SELECT SINGLE * FROM KNVP
WHERE KUNNR = VBRK-KUNRG
AND PARVW = ‘RE‘.
IF SY-SUBRC = 0.
SELECT SINGLE * FROM KNA1
WHERE KUNNR = KNVP-KUNN2.
ELSE.
SELECT SINGLE * FROM KNA1
WHERE KUNNR = VBRK-KUNRG.
ENDIF.
*get customer more name and address infomation.
CLEAR ADRC.
SELECT SINGLE * FROM ADRC
WHERE ADDRNUMBER = KNA1-ADRNR.
* Check for one time customer.
IF SY-SUBRC >< 0. "one time customer
MOVE ‘321000000000000‘ TO LIST_VBRK-STCD1.
ELSE.
CONCATENATE KNA1-NAME1
KNA1-NAME2
INTO LIST_VBRK-NAME1.
* Customer may store the tax number in different location
* a) kna1-stceg+2(15)
* b) kna1-stcd1
MOVE KNA1-STCD1 TO LIST_VBRK-STCD1.
MOVE KNA1-STCEG TO LIST_VBRK-STCD1.
*浪潮存税号于街道五字段中
MOVE ADRC-LOCATION TO LIST_VBRK-STCD1.
CALL CUSTOMER-FUNCTION ‘002‘
EXPORTING
VBRK = VBRK
KNA1 = KNA1
CHANGING
STCD1 = LIST_VBRK-STCD1
EXCEPTIONS
OTHERS = 1.
STRLEN3 = STRLEN( KNA1-TELF1 ).
STRLEN2 = STRLEN( KNA1-STRAS )
+ STRLEN( ADRC-STR_SUPPL3 ) + STRLEN3.
STRLEN1 = STRLEN2 + STRLEN( KNA1-PSTLZ ).
SELECT SINGLE *
FROM ADR2
WHERE ADR2~ADDRNUMBER = KNA1-ADRNR.
CONCATENATE ADR2-TEL_NUMBER ADR2-TEL_EXTENS
INTO ADR2-TELNR_CALL.
* 50(length of address)-5(space)-4(text)*2 = 37
IF STRLEN1 <= 80.
CONCATENATE KNA1-STRAS ADRC-STR_SUPPL3
ADR2-TELNR_CALL
* ‘ZIP:‘(002) KNA1-PSTLZ "邮编
INTO LIST_VBRK-ADDR SEPARATED BY ‘ ‘.
* 50(length of address)-3(space)-4(text) = 43
ELSEIF STRLEN2 <= 80.
CONCATENATE KNA1-STRAS ADRC-STR_SUPPL3
ADR2-TELNR_CALL
INTO LIST_VBRK-ADDR SEPARATED BY ‘ ‘.
ELSE.
CONCATENATE KNA1-ORT01 KNA1-STRAS ADRC-STR_SUPPL3
INTO LIST_VBRK-ADDR SEPARATED BY ‘ ‘.
* STRLEN1 = STRLEN( LIST_VBRK-NAME1 ) + STRLEN3.
** 50(length of name1)-2(space)-4(text) = 44
* IF STRLEN1 <= 44.
* CONCATENATE LIST_VBRK-NAME1
* ‘Tel:‘(001) KNA1-TELF1
* INTO LIST_VBRK-NAME1 SEPARATED BY ‘ ‘.
* ENDIF.
ENDIF.
* Add memo to the invoce as the customer require
CALL CUSTOMER-FUNCTION ‘003‘
EXPORTING
VBRK = VBRK
KNA1 = KNA1
CHANGING
MEMO = LIST_VBRK-MEMO
EXCEPTIONS
OTHERS = 1.
* Get bank name and account number.
CONCATENATE KNA1-NAME3 KNA1-NAME4
INTO LIST_VBRK-BANKN SEPARATED BY ‘ ‘.
* SELECT SINGLE * FROM KNBK CLIENT SPECIFIED
* WHERE KUNNR = VBRK-KUNRG.
* IF SY-SUBRC = 0.
* SELECT SINGLE * FROM BNKA
* WHERE BANKS = KNBK-BANKS
* AND BANKL = KNBK-BANKL .
* STRLEN1 = STRLEN( BNKA-BANKA ) + STRLEN( KNBK-BANKN ).
* IF STRLEN1 < 50.
* CONCATENATE BNKA-BANKA KNBK-BANKN
* INTO LIST_VBRK-BANKN SEPARATED BY ‘ ‘.
* ELSE.
* MOVE BNKA-BANKA TO LIST_VBRK-BANKN.
* STRLEN2 = STRLEN( KNBK-BANKN ).
* STRLEN1 = 50 - STRLEN2 + 1.
* LIST_VBRK-BANKN+STRLEN1(1) = ‘ ‘ .
* ADD 1 TO STRLEN1.
* LIST_VBRK-BANKN+STRLEN1(STRLEN2) = KNBK-BANKN.
* ENDIF.
* ENDIF.
ENDIF.
APPEND LIST_VBRK.
CLEAR LIST_VBRK.
ENDSELECT.
ENDFORM. " GET_VBRK
*&---------------------------------------------------------------------*
*& Form WRITE_TOPPAGE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM WRITE_TOPPAGE.
FORMAT COLOR COL_HEADING.
WRITE: (253) SY-ULINE.
WRITE: / SY-VLINE, 2(2) ‘F‘(020),
4 SY-VLINE, 5(8) ‘Status‘(021),
13 SY-VLINE, 14(10) ‘Bill Doc.‘(022),
25 SY-VLINE, 26(4) ‘BTyp‘(023),
31 SY-VLINE, 32(4) ‘SCon‘(024),
37 SY-VLINE, 38(4) ‘S.O.‘(025).
WRITE: 43 SY-VLINE, 44(4) ‘D.C.‘(026),
49 SY-VLINE, 50(4) ‘Div.‘(027).
WRITE: 55 SY-VLINE, 56(10) ‘Bill.Date‘(028).
WRITE: 67 SY-VLINE, 68(17) ‘Net Value‘(029).
WRITE: 88 SY-VLINE, 89(5) ‘Curr.‘(030).
WRITE: 95 SY-VLINE, 96(40) ‘Customer Name‘(031).
WRITE: 136 SY-VLINE, 137(3) ‘Num‘(032).
WRITE: 141 SY-VLINE, 142(15) ‘VAT reg.no.‘(033).
WRITE: 158 SY-VLINE, 159(50) ‘Customer Address ‘(034).
WRITE: 208 SY-VLINE, 209(50) ‘Bank name and Account number‘(035).
WRITE: 260 SY-VLINE.
WRITE: (260) SY-ULINE.
ENDFORM. " WRITE_TOPPAGE
*&---------------------------------------------------------------------*
*& Form WRITE_BODY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM WRITE_BODY.
DATA K TYPE N.
* format color col_normal.
SORT LIST_VBRK BY VBELN FKART.
K = 0.
LOOP AT LIST_VBRK.
FORMAT COLOR COL_KEY.
IF K = 1.
FORMAT INTENSIFIED ON.
K = 0.
ELSE.
FORMAT INTENSIFIED OFF.
K = 1.
ENDIF.
WRITE: / SY-VLINE.
WRITE: 2 LIST_VBRK-FLAG AS CHECKBOX NO-GAP .
WRITE: 4 SY-VLINE.
IF LIST_VBRK-FKART = ‘ZS2‘ OR LIST_VBRK-FKART = ‘ZRE‘.
IF NOT LIST_VBRK-ZZCANCEL IS INITIAL.
WRITE: 5(8) ‘Exported‘(050) COLOR COL_NEGATIVE NO-GAP.
ELSE.
WRITE: 5(8) ‘Not Exp.‘(051) COLOR COL_POSITIVE NO-GAP.
ENDIF.
ELSE.
IF NOT LIST_VBRK-ZZFLAG IS INITIAL.
WRITE: 5(8) ‘Exported‘(050) COLOR COL_NEGATIVE NO-GAP.
ELSE.
WRITE: 5(8) ‘Not Exp.‘(051) COLOR COL_POSITIVE NO-GAP.
ENDIF.
ENDIF.
WRITE: 13 SY-VLINE, 14(10) LIST_VBRK-VBELN NO-GAP.
HIDE LIST_VBRK-VBELN.
WRITE: 25 SY-VLINE, 26(4) LIST_VBRK-FKART NO-GAP.
WRITE: 31 SY-VLINE.
FORMAT COLOR COL_NORMAL.
WRITE: 32(4) LIST_VBRK-VSBED NO-GAP.
WRITE: 37 SY-VLINE, 38(4) LIST_VBRK-VKORG NO-GAP.
WRITE: 43 SY-VLINE, 44(4) LIST_VBRK-VTWEG NO-GAP.
WRITE: 49 SY-VLINE, 50(4) LIST_VBRK-SPART NO-GAP.
WRITE: 55 SY-VLINE, 56(10) LIST_VBRK-FKDAT NO-GAP.
WRITE: 67 SY-VLINE, 68(17) LIST_VBRK-NETWR
CURRENCY LIST_VBRK-WAERK.
WRITE: 88 SY-VLINE, 89(5) LIST_VBRK-WAERK NO-GAP.
WRITE: 95 SY-VLINE, 96(40) LIST_VBRK-NAME1 NO-GAP.
WRITE: 136 SY-VLINE, 137(3) LIST_VBRK-NUM NO-ZERO NO-GAP.
WRITE: 141 SY-VLINE, 142(15) LIST_VBRK-STCD1 NO-GAP.
* write: 132 sy-vline, 133(15) list_vbrk-stceg no-gap.
WRITE: 158 SY-VLINE, 159(50) LIST_VBRK-ADDR NO-GAP.
WRITE: 208 SY-VLINE, 209(50) LIST_VBRK-BANKN NO-GAP.
WRITE: 260 SY-VLINE.
ENDLOOP.
WRITE : (260) SY-ULINE.
ENDFORM. " WRITE_BODY
*&---------------------------------------------------------------------*
*& Form DOWNLOAD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DOWNLOAD.
DATA K TYPE I.
* DATA L TYPE I.
* Copy user selection from screen list to list_vbrk
K = FIRST_LIST_LINE.
LOOP AT LIST_VBRK.
*根据取消发票和被取消的发票日期是否在同一月来确定是否
*发票是否为作废.同时设置打印作废发票标志
SELECT SINGLE * FROM VBRK INTO WA_VBRK
WHERE VBELN = LIST_VBRK-SFAKN.
IF SY-SUBRC = 0.
IF LIST_VBRK-FKDAT(6) = WA_VBRK-FKDAT(6).
LIST_VBRK-ZUOFEI = ‘X‘.
ENDIF.
ENDIF.
READ LINE K FIELD VALUE LIST_VBRK-FLAG.
*如果存在作废的单据.
IF LIST_VBRK-ZUOFEI = ‘X‘ AND LIST_VBRK-FLAG = ‘X‘.
FLAG_PRINTZUOFEI = ‘X‘.
ENDIF.
MODIFY LIST_VBRK TRANSPORTING FLAG ZUOFEI.
K = K + 1.
ENDLOOP.
*******************注销TXT文本格式下载 dingyang 20131205
* READ TABLE LIST_VBRK WITH KEY FLAG = ‘X‘.
* IF SY-SUBRC = 0.
* CLEAR FILENAME.
* CLEAR FILENAME1.
** download itab_
* IF FLAG_PRINTZUOFEI = ‘X‘.
* IF FILENAME1 IS INITIAL.
* REFRESH ITAB_HEADER.
* ITAB_HEADER-BDBJ = ‘SJJK0102‘.
* ITAB_HEADER-BDMC = ‘作废销售单据传入‘.
* ITAB_HEADER-FZ = ‘附注‘.
* APPEND ITAB_HEADER.
* CALL FUNCTION ‘DOWNLOAD‘
* EXPORTING
* FILENAME = ‘c:\invoice\作废单据传入文件.txt‘
* FILETYPE = ‘ASC‘
* ITEM = ‘Export Invoice‘
* IMPORTING
* ACT_FILENAME = FILENAME1
* TABLES
* DATA_TAB = ITAB_HEADER
** FIELDNAMES =
* EXCEPTIONS
* INVALID_FILESIZE = 1
* INVALID_TABLE_WIDTH = 2
* INVALID_TYPE = 3
* NO_BATCH = 4
* UNKNOWN_ERROR = 5
* OTHERS = 6.
*
* IF SY-SUBRC >< 0.
* MESSAGE E210.
* ENDIF.
* ENDIF.
* ENDIF.
**download itab_header.
* IF FILENAME IS INITIAL.
* REFRESH ITAB_HEADER.
* ITAB_HEADER-BDBJ = ‘SJJK0101‘.
* ITAB_HEADER-BDMC = ‘销售单据传入‘.
* ITAB_HEADER-FZ = ‘附注‘.
* APPEND ITAB_HEADER.
* CALL FUNCTION ‘DOWNLOAD‘
* EXPORTING
* FILENAME = ‘c:\invoice\销售单据传入文件.txt‘
* FILETYPE = ‘ASC‘
* ITEM = ‘Export Invoice‘
* IMPORTING
* ACT_FILENAME = FILENAME
* TABLES
* DATA_TAB = ITAB_HEADER
** FIELDNAMES =
* EXCEPTIONS
* INVALID_FILESIZE = 1
* INVALID_TABLE_WIDTH = 2
* INVALID_TYPE = 3
* NO_BATCH = 4
* UNKNOWN_ERROR = 5
* OTHERS = 6.
*
* IF SY-SUBRC >< 0.
* MESSAGE E210.
* ENDIF.
* ENDIF.
* ENDIF.
*******************注销TXT文本格式下载 dingyang 20131205
K = 0.
* CLEAR FILENAME.
LOOP AT LIST_VBRK WHERE NOT FLAG IS INITIAL.
IF LIST_VBRK-ZUOFEI <> ‘X‘.
PERFORM GET_VBRP.
* Finally get the number of line items
DESCRIBE TABLE ITAB_VBRP LINES LIST_VBRK-NUM.
* REFRESH ITAB_VBRK.
CLEAR ITAB_VBRK.
MOVE-CORRESPONDING LIST_VBRK TO ITAB_VBRK.
* CLEAR L.
* L = LIST_VBRK-NUM.
* DO L TIMES.
APPEND ITAB_VBRK.
* ENDDO.
*******************注销TXT文本格式下载 dingyang 20131205
* IF FILENAME IS INITIAL.
* CALL FUNCTION ‘DOWNLOAD‘
* EXPORTING
** BIN_FILESIZE = ‘ ‘
** CODEPAGE = ‘ ‘
* FILENAME = ‘c:\invoice\销售单据传入文件.txt‘
* FILETYPE = ‘ASC‘
* ITEM = ‘Export Invoice‘
** MODE = ‘ ‘
** WK1_N_FORMAT = ‘ ‘
** WK1_N_SIZE = ‘ ‘
** WK1_T_FORMAT = ‘ ‘
** WK1_T_SIZE = ‘ ‘
** FILEMASK_MASK = ‘ ‘
** FILEMASK_TEXT = ‘ ‘
** FILETYPE_NO_CHANGE = ‘ ‘
** FILEMASK_ALL = ‘ ‘
** FILETYPE_NO_SHOW = ‘ ‘
** SILENT = ‘S‘
** col_select = ‘ ‘
** COL_SELECTMASK = ‘ ‘
** data_tab = ‘ ‘
* IMPORTING
* ACT_FILENAME = FILENAME
** ACT_FILETYPE =
** FILESIZE =
** CANCEL =
* TABLES
* DATA_TAB = ITAB_VBRK
** FIELDNAMES =
* EXCEPTIONS
* INVALID_FILESIZE = 1
* INVALID_TABLE_WIDTH = 2
* INVALID_TYPE = 3
* NO_BATCH = 4
* UNKNOWN_ERROR = 5
* OTHERS = 6.
*
* IF SY-SUBRC >< 0.
* MESSAGE E210.
* ENDIF.
*
* IF FILENAME IS INITIAL. EXIT. ENDIF.
* ELSE.
* CALL FUNCTION ‘WS_DOWNLOAD‘
* EXPORTING
** BIN_FILESIZE = ‘ ‘
** CODEPAGE = ‘ ‘
* FILENAME = FILENAME
* FILETYPE = ‘ASC‘
* MODE = ‘A‘
* TABLES
* DATA_TAB = ITAB_VBRK
** FIELDNAMES =
* EXCEPTIONS
* FILE_OPEN_ERROR = 1
* FILE_WRITE_ERROR = 2
* INVALID_FILESIZE = 3
* INVALID_TABLE_WIDTH = 4
* INVALID_TYPE = 5
* NO_BATCH = 6
* UNKNOWN_ERROR = 7
* OTHERS = 8.
*
* IF SY-SUBRC >< 0.
* MESSAGE E209 WITH FILENAME.
* ENDIF.
* ENDIF.
*******************注销TXT文本格式下载 dingyang 20131205
* Download the billing itmes to file
PERFORM DOWNLOAD_VBRP.
K = K + 1.
IF LIST_VBRK-ZZFLAG >< ‘X‘ AND LIST_VBRK-FKART = ‘ZF2‘.
LIST_VBRK-ZZFLAG = ‘X‘.
LIST_VBRK-ZZERNAM = SY-UNAME.
LIST_VBRK-ZZERZET = SY-UZEIT.
LIST_VBRK-ZZERDAT = SY-DATUM.
MODIFY LIST_VBRK TRANSPORTING ZZFLAG.
UPDATE VBRK SET ZZFLAG = ‘X‘
ZZERNAM = SY-UNAME
ZZERZET = SY-UZEIT
ZZERDAT = SY-DATUM
WHERE VBELN = LIST_VBRK-VBELN.
ELSEIF ( LIST_VBRK-ZZFLAG >< ‘X‘ OR LIST_VBRK-ZZCANCEL <> ‘X‘ )
AND LIST_VBRK-FKART <> ‘ZF2‘ .
LIST_VBRK-ZZCANCEL = ‘X‘.
LIST_VBRK-ZZERNAM = SY-UNAME.
LIST_VBRK-ZZERZET = SY-UZEIT.
LIST_VBRK-ZZERDAT = SY-DATUM.
MODIFY LIST_VBRK TRANSPORTING ZZFLAG ZZCANCEL.
UPDATE VBRK SET ZZFLAG = ‘X‘
ZZCANCEL = ‘X‘
ZZERNAM = SY-UNAME
ZZERZET = SY-UZEIT
ZZERDAT = SY-DATUM
WHERE VBELN = LIST_VBRK-VBELN.
ENDIF.
IF SY-SUBRC >< 0.
MESSAGE W213 WITH LIST_VBRK-VBELN.
ENDIF.
* 下载作废单据传入文件
****************注销作废单据处理dingyang 20131205
* ELSE.
* ITAB_ZUOFEI-VBELN = LIST_VBRK-SFAKN.
* APPEND ITAB_ZUOFEI.
* PERFORM DOWNLOAD_ZUOFEI.
* K = K + 1.
* IF LIST_VBRK-ZZFLAG >< ‘X‘ OR LIST_VBRK-ZZCANCEL <> ‘X‘.
* LIST_VBRK-ZZFLAG = ‘X‘.
* LIST_VBRK-ZZERNAM = SY-UNAME.
* LIST_VBRK-ZZERZET = SY-UZEIT.
* LIST_VBRK-ZZERDAT = SY-DATUM.
* LIST_VBRK-ZZCANCEL = ‘X‘.
* MODIFY LIST_VBRK TRANSPORTING ZZFLAG ZZCANCEL.
*
* UPDATE VBRK SET ZZFLAG = ‘X‘
* ZZERNAM = SY-UNAME
* ZZERZET = SY-UZEIT
* ZZERDAT = SY-DATUM
* ZZCANCEL = ‘X‘
* WHERE VBELN = LIST_VBRK-VBELN.
* ENDIF.
*
* IF SY-SUBRC >< 0.
* MESSAGE W213 WITH LIST_VBRK-VBELN.
* ENDIF.
* CONTINUE.
****************注销作废单据处理dingyang 20131205
ENDIF.
ENDLOOP.
****************拼接表头和详细信息dingyang 20131205
**************处理备注信息dingyang 20131206
**************取*号后的数据为备注
DATA:N1(100),N2(100).
LOOP AT ITAB_VBRK.
SEARCH ITAB_VBRK-NAME1 FOR ‘*‘.
IF SY-SUBRC = 0.
CLEAR:N1,N2.
SPLIT ITAB_VBRK AT ‘*‘ INTO N1 N2.
ITAB_VBRK-MEMO = N2.
MODIFY ITAB_VBRK.
ENDIF.
ENDLOOP.
**************处理备注信息dingyang 20131206
LOOP AT DL_VBRP.
READ TABLE ITAB_VBRK WITH KEY VBELN = DL_VBRP-VBELN.
IF SY-SUBRC = 0 .
DL_VBRP-NAME1 = ITAB_VBRK-NAME1.
DL_VBRP-STCD1 = ITAB_VBRK-STCD1.
* CONCATENATE ‘*‘ ITAB_VBRK-STCD1 INTO DL_VBRP-STCD1.
DL_VBRP-NUM = ITAB_VBRK-NUM.
DL_VBRP-ADDR = ITAB_VBRK-ADDR.
DL_VBRP-BANKN = ITAB_VBRK-BANKN.
DL_VBRP-MEMO = ITAB_VBRK-MEMO.
DL_VBRP-FHR = ‘刘艳秀‘.
DL_VBRP-SKR = ‘门爱萍‘.
* DL_VBRP-XFYHZH = ITAB_VBRK-XFYHZH.
ENDIF.
MODIFY DL_VBRP.
ENDLOOP.
*******************加入excel表头dingyang 20131205
IT_FNAMES-NAME =‘凭证号‘.
APPEND IT_FNAMES.
IT_FNAMES-NAME =‘行数‘.
APPEND IT_FNAMES.
IT_FNAMES-NAME =‘客户名称‘.
APPEND IT_FNAMES.
IT_FNAMES-NAME =‘货物名称‘.
APPEND IT_FNAMES.
IT_FNAMES-NAME =‘规格型号‘.
APPEND IT_FNAMES.
IT_FNAMES-NAME =‘单位‘.
APPEND IT_FNAMES.
IT_FNAMES-NAME =‘数量‘.
APPEND IT_FNAMES.
IT_FNAMES-NAME =‘含税金额‘.
APPEND IT_FNAMES.
IT_FNAMES-NAME =‘税率‘.
APPEND IT_FNAMES.
IT_FNAMES-NAME =‘税额‘.
APPEND IT_FNAMES.
IT_FNAMES-NAME =‘税号‘.
APPEND IT_FNAMES.
IT_FNAMES-NAME =‘地址电话‘.
APPEND IT_FNAMES.
IT_FNAMES-NAME =‘开户银行‘.
APPEND IT_FNAMES.
IT_FNAMES-NAME =‘备注‘.
APPEND IT_FNAMES.
IT_FNAMES-NAME =‘复核人‘.
APPEND IT_FNAMES.
IT_FNAMES-NAME =‘收款人‘.
APPEND IT_FNAMES.
CLEAR DL_VBRP.
****************加入excel表头
***************导出EXCEL dingyang 20131205
CALL FUNCTION ‘MS_EXCEL_OLE_STANDARD_DAT‘
EXPORTING
FILE_NAME = ‘C:\销售单据\金税导出文件‘
* CREATE_PIVOT = 0
* DATA_SHEET_NAME = ‘金税‘
* PIVOT_SHEET_NAME = ‘ ‘
* PASSWORD = ‘ ‘
* PASSWORD_OPTION = 0
TABLES
* PIVOT_FIELD_TAB =
DATA_TAB = DL_VBRP
FIELDNAMES = IT_FNAMES.
* EXCEPTIONS
* FILE_NOT_EXIST = 1
* FILENAME_EXPECTED = 2
* COMMUNICATION_ERROR = 3
* OLE_OBJECT_METHOD_ERROR = 4
* OLE_OBJECT_PROPERTY_ERROR = 5
* INVALID_FILENAME = 6
* INVALID_PIVOT_FIELDS = 7
* DOWNLOAD_PROBLEM = 8
* OTHERS = 9.
***************导出EXCEL dingyang 20131205
IF SY-SUBRC NE 0.
MESSAGE I214. "no bill document is selected.
ELSE.
IF K > 0.
MESSAGE S206 WITH K FILENAME.
PERFORM WRITE_BODY.
SY-LSIND = SY-LSIND - 1.
ENDIF.
ENDIF.
ENDFORM. " DOWNLOAD
*&---------------------------------------------------------------------*
*& Form GET_VBRP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_VBRP.
DATA REVERSE.
* list_vbrk-fkart " RE
CLEAR REVERSE.
CALL CUSTOMER-FUNCTION ‘004‘
EXPORTING
VBRK = LIST_VBRK
CHANGING
REVERSE = REVERSE
EXCEPTIONS
OTHERS = 1.
*反冲的发票数量设置为负.
IF LIST_VBRK-FKART = ‘ZS2‘ OR LIST_VBRK-FKART = ‘ZRE‘.
REVERSE = ‘X‘.
ENDIF.
REFRESH ITAB_VBRP.
SELECT * FROM VBRP
WHERE VBELN = LIST_VBRK-VBELN
AND NETWR >< 0.
* ITAB_VBRP-VBELN = VBRP-VBELN.
ITAB_VBRP-ARKTX = VBRP-ARKTX.
IF REVERSE = ‘X‘.
ITAB_VBRP-FKIMG = 0 - VBRP-FKIMG.
ITAB_VBRP-NETWR = 0 - VBRP-NETWR.
ITAB_VBRP-MWSBP = 0 - VBRP-MWSBP.
ITAB_VBRP-KZWI2 = 0 - VBRP-KZWI1 - VBRP-KZWI2.
* itab_vbrp-kzwi2 = 0 - vbrp-kzwi2.
* itab_vbrp-kzwi3 = vbrp-kzwi3.
* itab_vbrp-kzwi4 = 0 - vbrp-kzwi4.
ITAB_VBRP-KZWI4 = 0 - VBRP-KZWI3.
* itab_vbrp-kzwi5 = vbrp-kzwi5.
ELSE.
ITAB_VBRP-FKIMG = VBRP-FKIMG.
ITAB_VBRP-NETWR = VBRP-NETWR.
ITAB_VBRP-MWSBP = VBRP-MWSBP.
* itab_vbrp-kzwi2 = vbrp-kzwi2.
ITAB_VBRP-KZWI2 = VBRP-KZWI1 + VBRP-KZWI2.
* itab_vbrp-kzwi3 = 0 - vbrp-kzwi3.
* itab_vbrp-kzwi4 = vbrp-kzwi4.
ITAB_VBRP-KZWI4 = VBRP-KZWI3.
* itab_vbrp-kzwi5 = 0 - vbrp-kzwi5.
ENDIF.
ITAB_VBRP-TAX = ITAB_VBRP-MWSBP / ITAB_VBRP-NETWR.
CALL CUSTOMER-FUNCTION ‘005‘
EXPORTING
VBRP = VBRP
CHANGING
TAX = ITAB_VBRP-TAX
EXCEPTIONS
OTHERS = 1.
SELECT SINGLE * FROM T006A
WHERE SPRAS = SY-LANGU
AND MSEHI = VBRP-VRKME.
MOVE T006A-MSEH3 TO ITAB_VBRP-MSEH3.
SELECT SINGLE KBETR FROM KONV INTO ITAB_KONV-KBETR
WHERE KNUMV = LIST_VBRK-KNUMV
AND KSCHL = KSCHL1.
ITAB_VBRP-TAX = ITAB_KONV-KBETR / 1000.
* SELECT knumv KWERT FROM KONV INTO TABLE ITAB_KONV
* where knumv = list_vbrk-knumv
* and kposn = vbrp-posnr
* and ( kschl = kschl1 or kschl = kschl2 ).
* LOOP AT ITAB_KONV.
* AT END OF KNUMV.
* SUM.
* MOVE ITAB_KONV-KWERT TO ITAB_VBRP-kwert.
* ENDAT.
* ENDLOOP.
SELECT SINGLE * FROM MARA
WHERE MATNR = VBRP-MATNR.
LEN = STRLEN( MARA-GROES ).
* SEARCH mara-groes FOR ‘. .‘.
* number = sy-fdpos.
* itab_vbrp-arktx = mara-groes(number).
************************************************************************
*Modify by qijsh 2010.04.02
************************************************************************
* itab_vbrp-arktx = mara-groes.
IF MARA-MTART = ‘Z011‘ OR MARA-MTART = ‘Z012‘ OR MARA-MTART = ‘Z021‘ OR MARA-MTART = ‘Z022‘ OR MARA-MTART = ‘Z023‘ OR MARA-MTART = ‘Z024‘.
IF MARA-SPART = ‘30‘.
ITAB_VBRP-ARKTX = ‘浪潮存储‘.
ELSE.
SELECT SINGLE WGBEZ
INTO ITAB_VBRP-ARKTX
FROM T023T
WHERE MATKL = MARA-MATKL.
IF MARA-SPART = ‘20‘ AND ( MARA-MTART = ‘Z012‘ OR MARA-MTART = ‘Z022‘).
CONCATENATE ITAB_VBRP-ARKTX ‘服务器‘ INTO ITAB_VBRP-ARKTX.
ENDIF.
IF MARA-SPART = ‘40‘ AND ( MARA-MTART = ‘Z024‘ OR MARA-MTART = ‘Z012‘ ) .
CONCATENATE ‘高性能‘ ITAB_VBRP-ARKTX INTO ITAB_VBRP-ARKTX.
ENDIF.
ENDIF.
ELSE.
ITAB_VBRP-ARKTX = MARA-GROES.
ENDIF.
************************************************************************
* number = number + 1.
* len = len - number.
* itab_vbrp-groes = mara-groes+number(len).
SELECT SINGLE PRODH
INTO ITAB_VBRP-GROES
FROM LIPS
WHERE VBELN = VBRP-VGBEL
AND POSNR = VBRP-VGPOS.
ITAB_VBRP-GROES = VBRP-MATNR.
ITAB_VBRP-VBELN = VBRP-VBELN.
ITAB_VBRP-POSNR = VBRP-POSNR.
IF NOCOMB = ‘X‘.
APPEND ITAB_VBRP.
ELSEIF COMBINE = ‘X‘.
READ TABLE ITAB_VBRP INTO WA_VBRP
WITH KEY ARKTX = VBRP-ARKTX.
MYTABIX = SY-TABIX.
IF SY-SUBRC <> 0.
APPEND ITAB_VBRP.
ELSE.
WA_VBRP-KZWI2 = WA_VBRP-KZWI2 + ITAB_VBRP-KZWI2.
WA_VBRP-KZWI3 = WA_VBRP-KZWI3 + ITAB_VBRP-KZWI3.
WA_VBRP-KZWI4 = WA_VBRP-KZWI4 + ITAB_VBRP-KZWI4.
WA_VBRP-KZWI5 = WA_VBRP-KZWI5 + ITAB_VBRP-KZWI5.
* wa_vbrp-tax = wa_vbrp-kzwi4 / wa_vbrp-kzwi2.
* wa_vbrp-tax1 = wa_vbrp-kzwi5 / wa_vbrp-kzwi3.
MODIFY ITAB_VBRP FROM WA_VBRP INDEX MYTABIX.
ENDIF.
* collect itab_vbrp.
ELSEIF HEBINLG = ‘X‘.
READ TABLE ITAB_VBRP INTO WA_VBRP
WITH KEY ARKTX = ITAB_VBRP-ARKTX.
MYTABIX = SY-TABIX.
IF SY-SUBRC <> 0.
APPEND ITAB_VBRP.
ELSE.
WA_VBRP-KZWI2 = WA_VBRP-KZWI2 + ITAB_VBRP-KZWI2.
WA_VBRP-KZWI3 = WA_VBRP-KZWI3 + ITAB_VBRP-KZWI3.
WA_VBRP-KZWI4 = WA_VBRP-KZWI4 + ITAB_VBRP-KZWI4.
WA_VBRP-KZWI5 = WA_VBRP-KZWI5 + ITAB_VBRP-KZWI5.
* wa_vbrp-tax = wa_vbrp-kzwi4 / wa_vbrp-kzwi2.
* wa_vbrp-tax1 = wa_vbrp-kzwi5 / wa_vbrp-kzwi3.
MODIFY ITAB_VBRP FROM WA_VBRP INDEX MYTABIX.
ENDIF.
* collect itab_vbrp.
ENDIF.
* IF COMBINE IS INITIAL.
* APPEND ITAB_VBRP.
* ELSE.
* COLLECT ITAB_VBRP.
* ENDIF.
ENDSELECT.
ENDFORM. "GET_VBRP
*&---------------------------------------------------------------------*
*& Form DOWNLOAD_VBRP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DOWNLOAD_VBRP.
CLEAR DL_VBRP.
* move ‘0000‘ to dl_vbrp-catalog. "default 0000, stand for unused
* move ‘0‘ to dl_vbrp-discount.
* move ‘"‘ to: dl_vbrp-pp1,
* dl_vbrp-pp2,
* dl_vbrp-pp3,
* dl_vbrp-pp4.
LOOP AT ITAB_VBRP.
DL_VBRP-ARKTX = ITAB_VBRP-ARKTX.
DL_VBRP-VBELN = ITAB_VBRP-VBELN.
*Modified by c0125 单位->单位描述
* dl_vbrp-mseh3 = itab_vbrp-mseh3.
SELECT SINGLE * FROM T006A
WHERE SPRAS = SY-LANGU
AND MSEH3 = ITAB_VBRP-MSEH3.
MOVE T006A-MSEHT TO DL_VBRP-MSEHT.
* Modified by c0125
* 物料号->工业标准
* 2004.01.08
***********************************************************************
*Modify by qijsh 2010.04.02
***********************************************************************
* select single NORMT from mara
* into dl_vbrp-groes
* where matnr = itab_vbrp-groes.
DATA: S_MS LIKE DL_VBRP-GROES.
CLEAR S_MS.
SELECT SINGLE * FROM MARA WHERE MATNR = ITAB_VBRP-GROES.
IF MARA-MTART = ‘Z011‘ OR MARA-MTART = ‘Z012‘ OR MARA-MTART = ‘Z021‘ OR MARA-MTART = ‘Z022‘ OR MARA-MTART = ‘Z023‘ OR MARA-MTART = ‘Z024‘.
IF MARA-SPART = ‘30‘.
SELECT SINGLE MAKTX
INTO DL_VBRP-GROES
FROM MAKT
WHERE MATNR = ITAB_VBRP-GROES.
SPLIT DL_VBRP-GROES AT ‘/‘ INTO DL_VBRP-GROES S_MS.
ELSE.
SELECT SINGLE VTEXT
INTO DL_VBRP-GROES
FROM T179T
WHERE PRODH IN
( SELECT PRODH
FROM VBRP
WHERE VBELN = ITAB_VBRP-VBELN AND POSNR = ITAB_VBRP-POSNR ) AND
SPRAS = ‘1‘.
IF SY-SUBRC = ‘0‘.
SPLIT DL_VBRP-GROES AT ‘/‘ INTO DL_VBRP-GROES S_MS.
ELSE.
SELECT SINGLE WGBEZ
INTO DL_VBRP-GROES
FROM T023T
WHERE MATKL = MARA-MATKL.
IF MARA-SPART = ‘20‘ AND ( MARA-MTART = ‘Z012‘ OR MARA-MTART = ‘Z022‘).
CONCATENATE DL_VBRP-GROES ‘服务器‘ INTO DL_VBRP-GROES.
ENDIF.
IF MARA-SPART = ‘40‘ AND ( MARA-MTART = ‘Z024‘ OR MARA-MTART = ‘Z012‘ ) .
CONCATENATE ‘高性能‘ DL_VBRP-GROES INTO DL_VBRP-GROES.
ENDIF.
ENDIF.
ENDIF.
ELSE.
SELECT SINGLE NORMT FROM MARA
INTO DL_VBRP-GROES
WHERE MATNR = ITAB_VBRP-GROES.
ENDIF.
***********************************************************************
* dl_vbrp-groes = itab_vbrp-groes.
* dl_vbrp-tax = itab_vbrp-tax.
DL_VBRP-TAX = ‘0.17‘.
DL_VBRP-FKIMG = ITAB_VBRP-FKIMG.
* DL_VBRP-DISMWSBP = DISMWSBP.
DL_VBRP-NETWR = ITAB_VBRP-KZWI2.
DL_VBRP-MWSBP = ITAB_VBRP-KZWI4.
* DL_VBRP-DISCOUNT = ITAB_VBRP-KZWI3.
* DL_VBRP-DISMWSBP = ITAB_VBRP-KZWI5.
SHIFT DL_VBRP-FKIMG RIGHT CIRCULAR.
SHIFT DL_VBRP-NETWR RIGHT CIRCULAR.
SHIFT DL_VBRP-MWSBP RIGHT CIRCULAR.
* SHIFT DL_VBRP-DISCOUNT RIGHT CIRCULAR.
* SHIFT DL_VBRP-DISMWSBP RIGHT CIRCULAR.
CONDENSE DL_VBRP-FKIMG NO-GAPS.
CONDENSE DL_VBRP-NETWR NO-GAPS.
CONDENSE DL_VBRP-MWSBP NO-GAPS.
* CONDENSE DL_VBRP-DISCOUNT NO-GAPS.
* CONDENSE DL_VBRP-DISMWSBP NO-GAPS.
APPEND DL_VBRP.
ENDLOOP.
*******************注销TXT文本格式下载 dingyang 20131205
* CALL FUNCTION ‘WS_DOWNLOAD‘
* EXPORTING
** BIN_FILESIZE = ‘ ‘
** CODEPAGE = ‘ ‘
* FILENAME = FILENAME
* FILETYPE = ‘ASC‘
* MODE = ‘A‘
* TABLES
* DATA_TAB = DL_VBRP
** FIELDNAMES =
* EXCEPTIONS
* FILE_OPEN_ERROR = 1
* FILE_WRITE_ERROR = 2
* INVALID_FILESIZE = 3
* INVALID_TABLE_WIDTH = 4
* INVALID_TYPE = 5
* NO_BATCH = 6
* UNKNOWN_ERROR = 7
* OTHERS = 8.
*
* IF SY-SUBRC >< 0.
* MESSAGE E209 WITH FILENAME.
* ENDIF.
*******************注销TXT文本格式下载 dingyang 20131205
ENDFORM. " DOWNLOAD_VBRP
*&---------------------------------------------------------------------*
*& Form SELECT_ALL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SELECT_ALL.
DATA K TYPE I.
K = FIRST_LIST_LINE.
LOOP AT LIST_VBRK.
READ LINE K.
MODIFY LINE K FIELD VALUE LIST_VBRK-FLAG FROM ‘X‘.
K = K + 1.
ENDLOOP.
ENDFORM. " SELECT_ALL
*&---------------------------------------------------------------------*
*& Form DESELECT_ALL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DESELECT_ALL.
DATA K TYPE I.
K = FIRST_LIST_LINE.
* LOOP AT LIST_VBRK INTO VBRK.
LOOP AT LIST_VBRK.
READ LINE K.
MODIFY LINE K FIELD VALUE LIST_VBRK-FLAG FROM ‘‘.
K = K + 1.
ENDLOOP.
ENDFORM. " DESELECT_ALL
*&---------------------------------------------------------------------*
*& Form SELECT_PARTIAL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SELECT_PARTIAL.
DATA K TYPE I.
K = FIRST_LIST_LINE.
LOOP AT LIST_VBRK.
READ LINE K.
IF LIST_VBRK-ZZFLAG IS INITIAL.
MODIFY LINE K FIELD VALUE LIST_VBRK-FLAG FROM ‘X‘.
ELSE.
MODIFY LINE K FIELD VALUE LIST_VBRK-FLAG FROM ‘‘.
ENDIF.
K = K + 1.
ENDLOOP.
ENDFORM. " SELECT_PARTIAL
*&---------------------------------------------------------------------*
*& Form AUTHORITY_CHECK
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM AUTHORITY_CHECK USING US_ACTVT US_SUBRC
US_VKORG US_FKART .
US_SUBRC = 0.
AUTHORITY-CHECK OBJECT ‘V_VBRK_VKO‘
ID ‘VKORG‘ FIELD US_VKORG
ID ‘ACTVT‘ FIELD US_ACTVT.
IF SY-SUBRC NE 0.
US_SUBRC = SY-SUBRC.
CASE US_ACTVT.
WHEN ‘04‘.
MESSAGE E518(VF) WITH US_VKORG.
WHEN ‘03‘.
MESSAGE E514(VF) WITH US_VKORG.
WHEN ‘02‘.
MESSAGE E515(VF) WITH US_VKORG.
WHEN OTHERS.
MESSAGE E011 WITH US_VKORG.
* when ‘01‘.
* xkomfk-fxmsg = ‘515‘.
* perform vbfs_hinzufuegen using ‘000000‘ ‘515‘ us_vkorg
* space space.
ENDCASE.
ENDIF.
AUTHORITY-CHECK OBJECT ‘V_VBRK_FKA‘
ID ‘FKART‘ FIELD US_FKART
ID ‘ACTVT‘ FIELD US_ACTVT.
IF SY-SUBRC NE 0.
US_SUBRC = SY-SUBRC.
CASE US_ACTVT.
WHEN ‘04‘.
MESSAGE E519(VF) WITH US_FKART.
WHEN ‘03‘.
MESSAGE E516(VF) WITH US_FKART.
WHEN ‘02‘.
MESSAGE E517(VF) WITH US_FKART.
WHEN OTHERS.
MESSAGE E012 WITH US_FKART.
* when ‘01‘.
* xkomfk-fxmsg = ‘517‘.
* perform vbfs_hinzufuegen using ‘000000‘ ‘517‘ us_fkart
* space space.
ENDCASE.
ENDIF.
ENDFORM. " AUTHORITY_CHECK
*&---------------------------------------------------------------------*
*& Form download_zuofei
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
*FORM DOWNLOAD_ZUOFEI.
* CALL FUNCTION ‘WS_DOWNLOAD‘
* EXPORTING
** BIN_FILESIZE = ‘ ‘
** CODEPAGE = ‘ ‘
* FILENAME = FILENAME1
* FILETYPE = ‘ASC‘
* MODE = ‘A‘
* TABLES
* DATA_TAB = ITAB_ZUOFEI
** FIELDNAMES =
* EXCEPTIONS
* FILE_OPEN_ERROR = 1
* FILE_WRITE_ERROR = 2
* INVALID_FILESIZE = 3
* INVALID_TABLE_WIDTH = 4
* INVALID_TYPE = 5
* NO_BATCH = 6
* UNKNOWN_ERROR = 7
* OTHERS = 8.
*
* IF SY-SUBRC >< 0.
* MESSAGE E009 WITH FILENAME.
* ENDIF.
*
*ENDFORM. " download_zuofei
原文地址:http://blog.csdn.net/champaignwolf/article/details/45364009