SAP 金税接口代码 供参考
程序可以通过抓取 客户 开票信息等 下载文本 导出
需要事先创建好几个structure
zc0000sdt0016,
zc0000sdt0017
REPORT zc0000sdr0016 NO STANDARD PAGE HEADING
LINE-COUNT
LINE-SIZE .
TABLES:vbrk,vbrp,t001.
*----------------------------------------------------------------------*
* type define
*----------------------------------------------------------------------*
TYPES: BEGIN OF ty_vbrk,
vbeln TYPE vbrk-vbeln,"invoice number
fkart TYPE vbrk-fkart, "ERPInvoiceType
waerk TYPE vbrk-waerk, "Currency
vkorg TYPE vbrk-vkorg, "Sales Organization
vtweg TYPE vbrk-vtweg, "Distribution Channel
knumv TYPE vbrk-knumv,
fkdat TYPE vbrk-fkdat, "Invoice data
gjahr TYPE vbrk-gjahr, "Year
bukrs TYPE vbrk-bukrs,
taxk1 TYPE vbrk-taxk1, "Invoice type(eg:0 - Expore Invoice, 1 - VAT Inovice , 2 - Credit Inovice)BillingType
kunag TYPE vbrk-kunag, "Customer code
sfakn TYPE vbrk-sfakn, "Credit Notes
fksto TYPE vbrk-fksto, "Cancel flag
del TYPE c,
END OF ty_vbrk,
BEGIN OF ty_vbrp,
vbeln TYPE vbrp-vbeln, "Invoice number
posnr TYPE vbrp-posnr, "Item number
fkimg TYPE vbrp-fkimg, "Quantity
vrkme TYPE vbrp-vrkme, "Unit
netwr TYPE vbrp-netwr, "Sum
vbelv TYPE vbrp-vbelv, "First Document
aubel TYPE vbrp-aubel, "Sales Document
matnr TYPE vbrp-matnr, "Material Number
arktx TYPE vbrp-arktx, "Product chinese name
ernam TYPE vbrp-ernam, "Person code
mwsbp TYPE vbrp-mwsbp, "Tax
END OF ty_vbrp,
BEGIN OF ty_out,
txt TYPE string,
END OF ty_out,
BEGIN OF ty_errlog, "Linda 20141120 add
str() TYPE c, "Linda 20141120 add
END OF ty_errlog. "Linda 20141120 add
*----------------------------------------------------------------------*
* Internal Tables define
*----------------------------------------------------------------------*
DATA: it_blitems TYPE STANDARD TABLE OF zc0000sdt0016,"is struction
it_tbillno TYPE STANDARD TABLE OF zc0000sdt0017,"is table,
it_kunnr TYPE jito_kunnr_range_tt,
it_vbeln TYPE jit_vbeln_vl_range_tt,
it_out TYPE STANDARD TABLE OF ty_out,"use for output
it_errlog TYPE STANDARD TABLE OF ty_errlog, "Linda 20141120 add
*----------------------------------------------------------------------*
* Workarea define
*----------------------------------------------------------------------*
iw_vbrk TYPE ty_vbrk,
iw_tbillno TYPE zc0000sdt0017,"is table
iw_blitems TYPE zc0000sdt0016,"is struction
iw_kunnr TYPE jito_kunnr_range,
iw_vbeln TYPE jit_vbeln_vl_range,
iw_out TYPE ty_out,
iw_errlog TYPE ty_errlog, "Linda 20141120 add
*----------------------------------------------------------------------*
* Variables define
*----------------------------------------------------------------------*
w_time TYPE char6, "run time
w_path TYPE rlgrap-filename, "path
w_filename TYPE rlgrap-filename, "file name
w_data1 TYPE i,
w_data2 TYPE i,
w_filter TYPE string." VALUE 'Text Files(*.txt)|*.txt'.Linda 20141024
*----------------------------------------------------------------------*
* Constants define
*----------------------------------------------------------------------*
CONSTANTS: cos_vl TYPE char1 VALUE '\',
cos_open TYPE char4 VALUE 'OPEN',
cos_close TYPE char5 VALUE 'CLOSE',
cos_transfer TYPE char8 VALUE 'TRANSFER',
cos_comma TYPE char1 VALUE ','. "Linda 20141120 add SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-003.
PARAMETERS:"p_batch TYPE char20, "batch 1
p_bukrs TYPE vbrk-bukrs OBLIGATORY. "company
SELECT-OPTIONS:s_fkdat FOR vbrk-fkdat NO-EXTENSION. "Billing date for billing index and printout 2
SELECTION-SCREEN BEGIN OF LINE .
SELECTION-SCREEN COMMENT 1(31) text-009 . "enter data range
PARAMETER p_data1 TYPE char3.
SELECTION-SCREEN COMMENT 40(4) text-010.
PARAMETER p_data2 TYPE char3.
SELECTION-SCREEN COMMENT 70(79) text-008.
SELECTION-SCREEN END OF LINE.
SELECT-OPTIONS:
s_vbeln FOR vbrk-vbeln, "Billing Document 3
s_kunag FOR vbrk-kunag, "Payer 4
s_matnr FOR vbrp-matnr NO-EXTENSION, "Material Number 5
s_aubel FOR vbrp-aubel NO-EXTENSION, "Sales Document 6
s_vkorg FOR vbrk-vkorg NO-EXTENSION OBLIGATORY.
PARAMETERS:p_gjahr TYPE vbrk-gjahr. "Fiscal Year PARAMETERS:p_nonrep TYPE c AS CHECKBOX. "compare or not
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETER p_check3 RADIOBUTTON GROUP rad DEFAULT 'X' USER-COMMAND rad.
SELECTION-SCREEN COMMENT 4(20) text-c03 FOR FIELD p_check3."TXT format
PARAMETER p_check4 RADIOBUTTON GROUP rad.
SELECTION-SCREEN COMMENT 28(30) text-c04 FOR FIELD p_check4."CSV format
SELECTION-SCREEN END OF LINE. SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-002.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETER p_check2 TYPE c RADIOBUTTON GROUP rads DEFAULT 'X' USER-COMMAND rad2.
SELECTION-SCREEN COMMENT 4(20) text-c02 FOR FIELD p_check2."output to server
SELECTION-SCREEN END OF LINE.
PARAMETERS: p_path2(1024) TYPE c LOWER CASE
VISIBLE LENGTH 200.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETER p_check1 RADIOBUTTON GROUP rads.
SELECTION-SCREEN COMMENT 4(20) text-c01 FOR FIELD p_check1."
SELECTION-SCREEN END OF LINE.
PARAMETERS: p_path(1024) TYPE c LOWER CASE
VISIBLE LENGTH 200.
SELECTION-SCREEN END OF BLOCK b3. *----------------------------------------------------------------------*
* INITIALIZATION
*----------------------------------------------------------------------*
INITIALIZATION.
* init *----------------------------------------------------------------------*
* AT SELECTION-SCREEN ON VALUE-REQUEST
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
PERFORM frm_save_file CHANGING p_path.
*----------------------------------------------------------------------*
* AT SELECTION-SCREEN OUTPUT
*----------------------------------------------------------------------*
AT SELECTION-SCREEN OUTPUT.
IF p_data1 <> space AND p_data2 <> space. "Linda 20141120 add
REFRESH:s_fkdat. "Linda 20141024 add
ENDIF. "Linda 20141120 add
IF p_data1 <> space AND p_data2 <> space.
PERFORM frm_chang_data USING p_data1
CHANGING s_fkdat-low. PERFORM frm_chang_data USING p_data2
CHANGING s_fkdat-high.
APPEND s_fkdat. ENDIF. *----------------------------------------------------------------------*
* AT SELECTION-SCREEN
*----------------------------------------------------------------------*
AT SELECTION-SCREEN.
* WHEN 'ONLI'.
PERFORM frm_init.
IF p_path = space AND p_check1 = 'X'.
SET CURSOR FIELD 'P_PATH'.
MESSAGE e001(00) WITH 'Local path can not be space'(018).
ENDIF.
IF p_path2 = space AND p_check2 = 'X'.
SET CURSOR FIELD 'P_PATH2'.
MESSAGE e001(00) WITH 'Server path can not be space'(017).
ENDIF.
CASE sy-ucomm.
WHEN 'RAD' OR 'RAD2'.
* lw_filter = 'Text Files(*.txt)|*.txt|Csv Files(*.csv)|*.csv|Excel Files(*.xls)|*.xls|All Files(*.*)|*.*|'."Text Files(*.txt)|*.txt|'. "All Files(*.*)|*.*|
IF p_check3 = 'X'.
w_filter = 'Text Files(*.txt)|*.txt'().
ELSEIF p_check4 = 'X'.
w_filter = 'Csv Files(*.csv)|*.csv'().
ENDIF.
CLEAR: p_path,
p_path2.
WHEN OTHERS.
ENDCASE.
TRY.
w_data1 = p_data1.
w_data2 = p_data2.
CATCH cx_root.
SET CURSOR FIELD 'P_DATA1'.
MESSAGE e001() WITH 'Data range must be number'().
ENDTRY.
IF w_data1 > w_data2.
SET CURSOR FIELD 'P_DATA1'.
MESSAGE e001() WITH 'Data range must from small to big'().
ENDIF.
*----------------------------------------------------------------------*
* START-OF-SELECTION
*----------------------------------------------------------------------*
START-OF-SELECTION.
w_time = sy-uzeit.
IF s_fkdat[] IS INITIAL AND p_data1 <> space AND p_data2 <> space.
PERFORM frm_chang_data USING p_data1
CHANGING s_fkdat-low. PERFORM frm_chang_data USING p_data2
CHANGING s_fkdat-high.
s_fkdat-sign = 'I'.
s_fkdat-option = 'BT'.
APPEND s_fkdat.
ELSEIF s_fkdat[] IS INITIAL AND p_data1 = space AND p_data2 = space.
MESSAGE s001() WITH text- text- DISPLAY LIKE 'E'.
RETURN.
LEAVE TO LIST-PROCESSING.
ENDIF.
LOOP AT s_kunag.
iw_kunnr-sign = s_kunag-sign.
iw_kunnr-option = s_kunag-option.
iw_kunnr-low = s_kunag-low.
iw_kunnr-high = s_kunag-high. APPEND iw_kunnr TO it_kunnr.
ENDLOOP.
LOOP AT s_vbeln.
iw_vbeln-sign = s_vbeln-sign.
iw_vbeln-option = s_vbeln-option.
iw_vbeln-low = s_vbeln-low.
iw_vbeln-high = s_vbeln-high. APPEND iw_vbeln TO it_vbeln.
ENDLOOP. CHECK it_errlog IS INITIAL.
CALL FUNCTION 'ZBPI_FW_INVOICE_MAHLE_NEW'
EXPORTING
fkdat_fr = s_fkdat-low
vbeln_fr = s_vbeln-low
kunnr_fr = s_kunag-low
matnr_fr = s_matnr-low
fkdat_to = s_fkdat-high
vbeln_to = s_vbeln-high
kunnr_to = s_kunag-high
matnr_to = s_matnr-high
aubel_fr = s_aubel-low
aubel_to = s_aubel-high
vkorg_fr = s_vkorg-low
vkorg_to = s_vkorg-high
* disc_cond_type = p_disc
* unit_cond_type = p_unit
* tax_cond_type = p_tax
bukrs = p_bukrs
nonrepeat = p_nonrep
gjahr = p_gjahr
TABLES
zfw_billing_items = it_blitems
zfw_billingno = it_tbillno
zfw_kunnr = it_kunnr
zfw_vbeln = it_vbeln
EXCEPTIONS
no_data =
lock_errord =
insert_error = .
CASE sy-subrc.
WHEN .
iw_errlog-str = 'No matching data is found.'().
APPEND iw_errlog TO it_errlog.
WHEN .
iw_errlog-str = 'Lock table error.'().
APPEND iw_errlog TO it_errlog.
WHEN .
iw_errlog-str = 'Insert table error.'().
APPEND iw_errlog TO it_errlog.
ENDCASE. CHECK it_errlog IS INITIAL.
**{ Insert started by Linda on 06-Jan-2015 - CRXX
PERFORM frm_modify_blitems.
*
**} Insert ended by Linda on 06-Jan-2015 - CRXX
* background process
IF p_check2 = 'X'.
PERFORM frm_transfer_sever.
ELSE.
* front process
PERFORM frm_transfer_loc.
ENDIF.
*----------------------------------------------------------------------*
* END-OF-SELECTION
*----------------------------------------------------------------------*
END-OF-SELECTION.
* error log print
LOOP AT it_errlog INTO iw_errlog."
WRITE: / iw_errlog-str.
ENDLOOP. FREE:it_tbillno,
it_out,
iw_vbrk,
iw_tbillno,
iw_blitems,
it_vbeln,
it_kunnr,
it_blitems,
w_time,
w_path,
w_filename,
iw_out.
*&---------------------------------------------------------------------*
*& Form frm_transfer_sever
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_transfer_sever .
* 拼接文件名
IF p_check3 = 'X'.
CONCATENATE p_bukrs s_vkorg-low sy-datum "LINDA 20140916
w_time '.txt'
INTO w_filename.
ELSEIF p_check4 = 'X'.
CONCATENATE p_bukrs s_vkorg-low sy-datum "LINDA 20140916
w_time '.csv'
INTO w_filename.
ENDIF.
* 拼接服务器路径
CONCATENATE p_path2 w_filename
INTO w_path SEPARATED BY cos_vl. * 打开服务器文件 编码是非unicode
* OPEN DATASET w_path FOR OUTPUT IN TEXT MODE ENCODING NON-UNICODE.
* 打开服务器文件 编码是unicode
OPEN DATASET w_path FOR OUTPUT IN TEXT MODE ENCODING UTF-.
* 打开成功
IF sy-subrc = .
* 读取
PERFORM frm_write_txt.
* 关闭 DATASET
TRY.
CLOSE DATASET w_path.
IF sy-subrc <> .
* 文件名 &1 &2 &3 操作出错
MESSAGE s001() WITH 'File name' w_filename cos_close 'operate Error' INTO iw_errlog-str. "Linda 20141119
ELSE.
* 导出成功
MESSAGE s001() WITH 'Output successful' INTO iw_errlog-str.
ENDIF.
CATCH cx_root. "#EC CATCH_ALL
MESSAGE s001() WITH 'File name' w_filename cos_close 'operate Error' INTO iw_errlog-str. "Linda 20141119
CLEANUP.
ENDTRY.
ELSE.
* 文件名 &1 &2 &3 操作出错
MESSAGE s001() WITH 'File name' w_filename cos_open 'operate Error' INTO iw_errlog-str. "Linda 20141119
ENDIF.
APPEND iw_errlog TO it_errlog.
CLEAR:w_filename,
w_path.
ENDFORM. " frm_transfer_sever
*&---------------------------------------------------------------------*
*& Form frm_transfer_loc
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->p1 text
* <--p2 text
*----------------------------------------------------------------------*
FORM frm_transfer_loc.
DATA:lw_file TYPE string.
* 拼接download数据
LOOP AT it_blitems INTO iw_blitems.
PERFORM frm_con_string USING iw_blitems
CHANGING iw_out-txt.
APPEND iw_out TO it_out.
CLEAR: iw_blitems,iw_out.
ENDLOOP.
lw_file = p_path. CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = lw_file "string
filetype = 'ASC'
codepage = '' "4110 是utf-8
write_bom = 'X'
TABLES
data_tab = it_out
EXCEPTIONS
file_write_error =
no_batch =
gui_refuse_filetransfer =
invalid_type =
no_authority =
unknown_error =
header_not_allowed =
separator_not_allowed =
filesize_not_allowed =
header_too_long =
dp_error_create =
dp_error_send =
dp_error_write =
unknown_dp_error =
access_denied =
dp_out_of_memory =
disk_full =
dp_timeout =
file_not_found =
dataprovider_exception =
control_flush_error =
OTHERS = .
IF sy-subrc <> .
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
DISPLAY LIKE 'E'
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
iw_errlog-str = 'Output success.'().
APPEND iw_errlog TO it_errlog.
ENDIF.
ENDFORM. " frm_transfer_loc
*&---------------------------------------------------------------------*
*& Form frm_save_file
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--f_path text
*----------------------------------------------------------------------*
FORM frm_save_file CHANGING f_path TYPE file_table-filename.
DATA: lw_fname TYPE string,
lw_path TYPE string,
lw_fpath TYPE string. CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
file_filter = w_filter
CHANGING
filename = lw_fname
path = lw_path
fullpath = lw_fpath
EXCEPTIONS
cntl_error =
error_no_gui =
not_supported_by_gui =
OTHERS = .
IF sy-subrc <> .
MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
f_path = lw_fpath. ENDFORM. " frm_save_file
*&---------------------------------------------------------------------*
*& Form frm_con_string
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->piw_blitem text
* <--pw_txt text
*----------------------------------------------------------------------*
FORM frm_con_string USING piw_blitem TYPE zc0000sdt0016
CHANGING pw_txt TYPE string.
DATA: lw_temp TYPE char1024.
FIELD-SYMBOLS: <fs_temp> TYPE ANY.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE piw_blitem TO <fs_temp>.
IF sy-subrc <> .
EXIT.
ENDIF.
CLEAR lw_temp.
lw_temp = <fs_temp>.
* 去空格
SHIFT lw_temp LEFT DELETING LEADING space. IF sy-index = .
pw_txt = lw_temp.
ELSE.
IF p_check3 = 'X'. "Linda 20141120 add
CONCATENATE pw_txt cl_abap_char_utilities=>horizontal_tab lw_temp
INTO pw_txt. ELSEIF p_check4 = 'X'.
CONCATENATE pw_txt cos_comma lw_temp "Linda 20141120 add
INTO pw_txt.
* ELSE.
* CONCATENATE pw_txt cos_comma lw_temp
* INTO pw_txt.
ENDIF.
ENDIF.
ENDDO.
UNASSIGN <fs_temp>.
ENDFORM. " frm_con_string
*&---------------------------------------------------------------------*
*& Form frm_write_txt
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_write_txt .
DATA:lw_out TYPE string.
** 上传数据头
** 捕获异常
* TRY.
** 上传服务器
* lw_out = LINES( it_blitems ).
* CONCATENATE w_filename '#Record' lw_out
* INTO lw_out.
* CONDENSE lw_out.
* TRANSFER lw_out TO w_path.
** 判断传输是否成功
* IF sy-subrc <> 0.
** 文件名 &1 &2 &3 操作出错
* MESSAGE s001(00) WITH 'File name' w_path cos_transfer 'operate error'.
* ENDIF.
* CATCH cx_root.
* MESSAGE s001(00) WITH 'File name' w_path cos_transfer 'operate error'.
* CLEANUP.
* ENDTRY.
* 上传数据
LOOP AT it_blitems INTO iw_blitems. PERFORM frm_con_string USING iw_blitems
CHANGING lw_out.
TRY.
TRANSFER lw_out TO w_path.
* 判断传输是否成功
IF sy-subrc <> .
* 文件名 &1 &2 &3 操作出错
MESSAGE s001() WITH 'File name' w_path cos_transfer 'operate error'.
ENDIF.
CATCH cx_root.
MESSAGE s001() WITH 'File name' w_path cos_transfer 'operate error'.
CLEANUP.
ENDTRY.
CLEAR: iw_blitems,lw_out.
ENDLOOP.
ENDFORM. " frm_write_txt
*&---------------------------------------------------------------------*
*& Form frm_chang_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->fw_data text
* <--fw_budat text
*----------------------------------------------------------------------*
FORM frm_chang_data USING fw_data
CHANGING fw_budat.
DATA:l_today TYPE p0001-begda,
lw_data TYPE t5a4a-dlydy,
lw_calc TYPE p0001-begda.
* lw_data2 LIKE sy-datum. l_today = sy-datum.
lw_data = fw_data.
IF fw_data = .
fw_budat = sy-datum.
ELSEIF fw_data > .
CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
EXPORTING
date = l_today
days = lw_data
months =
signum = '+'
years =
IMPORTING
calc_date = lw_calc.
fw_budat = lw_calc .
ELSE.
CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
EXPORTING
date = l_today
days = lw_data
months =
signum = '-'
years =
IMPORTING
calc_date = lw_calc. fw_budat = lw_calc .
ENDIF.
ENDFORM. " frm_chang_data
*&---------------------------------------------------------------------*
*& Form frm_init
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_init .
* SELECT * FROM t001 INTO t001. "Linda 20141204 del
* authority-check
AUTHORITY-CHECK OBJECT 'F_BKPF_BUK'
ID 'BUKRS' FIELD p_bukrs
ID 'ACTVT' FIELD ''.
IF sy-subrc <> .
* You have no authorization for Company code
MESSAGE e004(zp001) WITH p_bukrs.
ENDIF.
* ENDSELECT. "Linda 20141204 del ENDFORM. " frm_init
**{ Insert started by Linda on 06-Jan-2015 - CR0001
*&---------------------------------------------------------------------*
*& Form FRM_MODIFY_BLITEMS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_modify_blitems .
DATA:lw_blitems TYPE zc0000sdt0016.
LOOP AT it_blitems INTO lw_blitems.
CALL FUNCTION 'CONVERSION_EXIT_CUNIT_OUTPUT'
EXPORTING
input = lw_blitems-vrkme
language = sy-langu
IMPORTING
* LONG_TEXT =
output = lw_blitems-vrkme
* SHORT_TEXT =
* EXCEPTIONS
* UNIT_NOT_FOUND = 1
* OTHERS = 2
.
IF sy-subrc <> .
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF. MODIFY it_blitems FROM lw_blitems TRANSPORTING vrkme.
ENDLOOP. ENDFORM. " FRM_MODIFY_BLITEMS
发票号码回传程序
REPORT zc0000sdr0017 NO STANDARD PAGE HEADING
LINE-COUNT
LINE-SIZE .
TYPE-POOLS: icon,slis,kcdu,tpit.
TABLES: sscrfields,
zc0000sdt0020.
*----------------------------------------------------------------------*
* type define
*----------------------------------------------------------------------*
TYPES: ty_dir_list TYPE STANDARD TABLE OF salfldir,
BEGIN OF ty_dir,
name TYPE pfeflname,
size TYPE pfeflsize,
name2 TYPE pfeflname,
END OF ty_dir,
BEGIN OF ty_tabl,
line(),
END OF ty_tabl,
BEGIN OF ty_vbeln,
vbeln TYPE vbrk-vbeln,
fkart TYPE vbrk-fkart,
kunrg TYPE vbrk-kunrg,
bukrs TYPE vbrk-bukrs,
fkdat TYPE vbrk-fkdat,
xblnr TYPE xblnr,
gjahr TYPE gjahr,
bktxt TYPE bktxt, "linda 20140918
zline TYPE i, "bseg table lines "Linda 20141023
END OF ty_vbeln,
BEGIN OF ty_vbrk,
vbeln TYPE vbrk-vbeln,
bukrs TYPE vbrk-bukrs,
gjahr TYPE vbrk-gjahr,
xblnr TYPE vbrk-xblnr,
fkdat TYPE vbrk-fkdat,
END OF ty_vbrk,
* add local file read begin
BEGIN OF ty_row,
field TYPE char40,
END OF ty_row,
* add local file read end
BEGIN OF ty_errlog, "Linda 20141120 add
str() TYPE c, "Linda 20141120 add
END OF ty_errlog. "Linda 20141120 add
*----------------------------------------------------------------------*
* Internal Tables define
*----------------------------------------------------------------------*
DATA: it_file TYPE ty_dir_list,
it_file2 TYPE STANDARD TABLE OF ty_dir,
it_errtab TYPE tpit_t_errdoc,
it_buztab TYPE TABLE OF tpit_buztab,
it_fldtab TYPE tpit_t_fname,
it_tabl TYPE STANDARD TABLE OF ty_tabl WITH HEADER LINE,
it_errlog TYPE STANDARD TABLE OF zc0000sdt0020,
it_errlog2 TYPE STANDARD TABLE OF ty_errlog, "Linda 20141120 add
it_fieldcat TYPE slis_t_fieldcat_alv,
it_bseg TYPE STANDARD TABLE OF bseg." Linda 20141024 add
*&---------------------------------------------------------------------*
* Workarea define
*&---------------------------------------------------------------------*
DATA: iw_file TYPE salfldir,
iw_file2 TYPE ty_dir,
iw_ins TYPE ty_vbeln,
iw_vbrk TYPE ty_vbrk,
iw_err TYPE zc0000sdt0020,
iw_errlog TYPE ty_errlog, "Linda 20141120 add
iw_bseg TYPE bseg.
*----------------------------------------------------------------------*
* Global Variables
*----------------------------------------------------------------------*
DATA :w_ret TYPE char1,
w_cmd() TYPE c,
w_date TYPE sy-datum,
w_time TYPE char6,
w_read_file TYPE salfile-longname,
functxt TYPE smp_dyntxt,
ok_code TYPE sy-ucomm,
w_repid TYPE sy-repid,
w_str() TYPE c,
putdahigh TYPE zc0000sdt0020-putda,
puttihigh TYPE zc0000sdt0020-putti,
vbelnhigh TYPE zc0000sdt0020-vbeln,
xblnrhigh TYPE zc0000sdt0020-xblnr,
w_file_path TYPE string,
w_lfile TYPE string, "file name
w_row_num TYPE char4,
w_msg_txt TYPE string.
*----------------------------------------------------------------------*
* Constants define
*----------------------------------------------------------------------*
CONSTANTS: cos_star2() TYPE c VALUE '*.*',
cos_2() TYPE c VALUE '',
cos_1() TYPE c VALUE '',
cos_numc() TYPE c VALUE 'NUMC'. SELECTION-SCREEN: FUNCTION KEY .
SELECTION-SCREEN BEGIN OF LINE.
PARAMETER p_check2 TYPE c RADIOBUTTON GROUP rads DEFAULT 'X'.
SELECTION-SCREEN COMMENT () text-c02 FOR FIELD p_check2."导出到服务器
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
PARAMETERS: p_fpath() TYPE c DEFAULT 'g:\r3ftp\formware\writeback\nonprocess\',"need edit D:\usr\sap\put\Inbound\Nonprocess\
p_bpath(1024) TYPE c DEFAULT 'g:\r3ftp\formware\writeback\bak\'." D:\usr\sap\put\Inbound\Backup\
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETER p_check1 RADIOBUTTON GROUP rads.
SELECTION-SCREEN COMMENT 4(20) text-c01 FOR FIELD p_check1."导出到本地
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-t01.
PARAMETERS: p_flpath(1024) TYPE c DEFAULT ''."need edit D:\usr\sap\put\Inbound\Nonprocess\
* p_blpath(1024) TYPE c DEFAULT 'D:\Backup\'." D:\usr\sap\put\Inbound\Backup\
SELECTION-SCREEN END OF BLOCK b2.
*----------------------------------------------------------------------*
* INITIALIZATION.
*----------------------------------------------------------------------*
INITIALIZATION.
functxt-icon_id = icon_biw_info_catalog.
functxt-icon_text = 'ERROR LOG'.
sscrfields-functxt_01 = functxt.
*----------------------------------------------------------------------*
* AT SELECTION-SCREEN ON VALUE-REQUEST
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_flpath.
PERFORM form_get_file_path_upload.
*----------------------------------------------------------------------*
* START-OF-SELECTION
*----------------------------------------------------------------------*
START-OF-SELECTION.
w_date = sy-datum.
w_time = sy-uzeit.
* file process
IF p_check2 IS NOT INITIAL.
PERFORM frm_file_process.
ELSE.
* local
PERFORM frm_file_process_local.
ENDIF.
*----------------------------------------------------------------------*
* AT SELECTION-SCREEN
*----------------------------------------------------------------------*
AT SELECTION-SCREEN.
IF sy-ucomm = 'ONLI'.
IF p_flpath IS INITIAL AND p_check1 = 'X'.
MESSAGE e001(00) WITH 'local path can not be init'(001).
SET CURSOR FIELD 'P_FLPATH'.
ENDIF.
ENDIF.
CASE sscrfields-ucomm.
WHEN 'FC01'.
CALL SCREEN 9000.
WHEN OTHERS.
...
ENDCASE.
*----------------------------------------------------------------------*
* END-OF-SELECTION
*----------------------------------------------------------------------*
END-OF-SELECTION.
IF w_ret = 'X'.
IF it_errlog IS INITIAL.
WRITE: /1 'Write back fail,please see error log.'(014).
ELSE.
LOOP AT it_errlog INTO iw_errlog."
WRITE: /1 iw_errlog-str.
ENDLOOP.
ENDIF.
ELSE.
WRITE: /1 'Write back success'(012).
ENDIF.
CLEAR:it_errlog,iw_errlog.
*----------------------------------------------------------------------*
* 子程序名称 :文件处理
* 子程序名 :frm_file_process
* 概要 :文件处理
* 参数 :无
* 返回值 :无
*----------------------------------------------------------------------*
FORM frm_file_process.
DATA: lw_path TYPE salfile-longname,
w_cmd1 TYPE string.
* Nonprocess路径名组成
CLEAR lw_path.
lw_path = p_fpath.
* 取得目录中的内容
PERFORM frm_read_directory TABLES it_file
USING lw_path
CHANGING w_ret.
IF w_ret = space.
* 把文件夹Nonprocess下的文件复制到文件夹Backup下 **{ Insert started by ZhouTing on 25-Jan-2015 - CR0010 ** begin of comment by zhou ting
** to use open dataset instead
*
** 这是在Linux系统下用的
** CONCATENATE p_fpath cos_nonprocess cos_star2 "#EC NOTEXT
** INTO w_cmd1.
** 这是在windows系统下用的
* CONCATENATE p_fpath cos_star2 "#EC NOTEXT
* INTO w_cmd1.
*
** 这是在Linux系统下用的 "need be edited
** CONCATENATE 'cp' w_cmd1 p_bpath INTO w_cmd SEPARATED BY space.
** 这是在windows系统下用的
* CONCATENATE 'copy' w_cmd1 p_bpath INTO w_cmd SEPARATED BY space.
***{ Insert started by Linda on 06-Jan-2015 - CR0010
* TRY.
***{ Insert ended by Linda on 06-Jan-2015 - CR0010
* CALL 'SYSTEM' ID 'COMMAND' FIELD w_cmd
* ID 'TAB' FIELD it_tabl-*sys*.
*
* IF sy-subrc <> 0.
* CONCATENATE 'Move file fail'(013) p_bpath INTO iw_errlog-str.
* APPEND iw_errlog TO it_errlog2.
* w_ret = 'X'.
* ENDIF.
***{ Insert started by Linda on 06-Jan-2015 - CR0010
* CATCH cx_root.
* CONCATENATE 'Move file fail'(013) p_bpath INTO iw_errlog-str.
* APPEND iw_errlog TO it_errlog2.
* w_ret = 'X'.
* ENDTRY.
***{ Insert ended by Linda on 06-Jan-2015 - CR0010
** end of comment. PERFORM frm_copy_file USING p_fpath p_bpath it_file
CHANGING w_ret.
IF w_ret <> 0.
CONCATENATE 'Move file fail'(013) p_bpath INTO iw_errlog-str.
APPEND iw_errlog TO it_errlog2.
w_ret = 'X'.
ENDIF. **{ Insert ended by ZhouTing on 25-Jan-2015 - CR0010 * 文件数据传送接口表 PERFORM frm_transfer_data USING lw_path
CHANGING w_ret.
ENDIF. ENDFORM. " FRM_file_process
*----------------------------------------------------------------------*
* 子程序名称 :取得目录中的内容
* 子程序名 :frm_read_directory
* 概要 :取得目录中的内容
* 参数 :fit_dir_bukrs type ty_dir_list 取得的目录列表
* :f_dir_path type salfile-longname 目录路径
* 返回值 :f_ret type c 正常取得:space 未取得:'' 异常:''
*----------------------------------------------------------------------*
FORM frm_read_directory TABLES fit_dir TYPE ty_dir_list
USING f_dir_path TYPE salfile-longname
CHANGING f_ret TYPE c.
DATA: lw_lines TYPE i. CLEAR f_ret.
REFRESH fit_dir.
CALL FUNCTION 'RZL_READ_DIR_LOCAL'
EXPORTING
name = f_dir_path
TABLES
file_tbl = fit_dir
EXCEPTIONS
argument_error = 1
not_found = 2
OTHERS = 3. IF sy-subrc <> 0.
f_ret = cos_2.
RETURN.
ENDIF. lw_lines = LINES( fit_dir ).
IF lw_lines < 3.
f_ret = cos_1.
ENDIF.
ENDFORM. " frm_read_directory
*----------------------------------------------------------------------*
* 子程序名称 :数据传输处理
* 子程序名 :frm_copy_file
* 概要 :把需处理的文件拷贝到bak目录下
* 参数 :i_frompath 目录路径
* i_topath 目录路径
* 返回值 :o_ret 正常:space 异常:''
*----------------------------------------------------------------------*
FORM frm_copy_file USING i_frompath
i_topath
i_filelist TYPE ty_dir_list
CHANGING o_ret. DATA: from_file TYPE string,
to_file TYPE string,
lt_file_content TYPE TABLE OF string,
lv_text TYPE string,
ls_filelist TYPE salfldir. LOOP AT i_filelist FROM 3 INTO ls_filelist. REFRESH lt_file_content. "源文件路径+文件名
CONCATENATE i_frompath ls_filelist-name INTO from_file.
"目标文件路径+文件名
CONCATENATE i_topath ls_filelist-name INTO to_file. "把源文件内容保存进内表
OPEN DATASET from_file FOR INPUT IN TEXT MODE
ENCODING NON-UNICODE
IGNORING CONVERSION ERRORS.
IF sy-subrc NE 0.
o_ret = 4.
EXIT.
ENDIF.
DO.
READ DATASET from_file INTO lv_text.
IF sy-subrc NE 0.
EXIT.
ENDIF.
APPEND lv_text TO lt_file_content.
ENDDO. CLOSE DATASET from_file. "把源文件内容从系统内表中写入目标文件中
OPEN DATASET to_file FOR OUTPUT IN TEXT MODE
ENCODING NON-UNICODE
IGNORING CONVERSION ERRORS. IF sy-subrc NE 0.
o_ret = 4.
EXIT.
ENDIF.
LOOP AT lt_file_content INTO lv_text.
TRANSFER lv_text TO to_file.
ENDLOOP.
CLOSE DATASET to_file. ENDLOOP. ENDFORM. "frm_copy_file
*----------------------------------------------------------------------*
* 子程序名称 :数据传输处理
* 子程序名 :frm_transfer_data
* 概要 :文件数据传送接口表
* 参数 :f_path type salfile-longname 目录路径
* 返回值 :无
*----------------------------------------------------------------------*
FORM frm_transfer_data USING f_path TYPE salfile-longname
CHANGING lw_ret.
DATA: lw_loopc TYPE sy-index,
lw_text(2048) TYPE c,
* lw_ret(1) TYPE c,
lw_zwrit TYPE i,
lw_lines TYPE i,
lw_len TYPE i. * 处理文件名排序的问题
SORT it_file BY name DESCENDING.
lw_lines = LINES( it_file ).
lw_lines = lw_lines - 1.
* 删除无用的2行
DELETE it_file FROM lw_lines.
* 从it_file 取数添加到it_file2 LOOP AT it_file INTO iw_file.
MOVE-CORRESPONDING iw_file TO iw_file2. lw_len = STRLEN( iw_file-name ) - 18. SHIFT iw_file-name BY lw_len PLACES LEFT.
iw_file2-name2 = iw_file-name+0(14).
APPEND iw_file2 TO it_file2.
CLEAR:lw_len,iw_file2.
ENDLOOP. CLEAR iw_file.
* 按文件生成时间排序
SORT it_file2 BY name2.
LOOP AT it_file2 INTO iw_file2.
* 文件路径组
CLEAR w_read_file.
CONCATENATE f_path iw_file2-name INTO w_read_file.
* 打开文件
OPEN DATASET w_read_file FOR INPUT
IN TEXT MODE ENCODING NON-UNICODE.
IF sy-subrc <> 0.
EXIT.
ENDIF.
DO.
lw_loopc = sy-index.
TRY.
CLEAR lw_text.
READ DATASET w_read_file INTO lw_text.
CATCH cx_sy_conversion_codepage.
CLOSE DATASET: w_read_file.
EXIT.
ENDTRY.
* 空文件的情况下
IF sy-subrc <> 0 AND lw_loopc = 1."lw_loopc = 2 带标题的文件
PERFORM frm_get_errno CHANGING lw_zwrit.
iw_err-zwrit = lw_zwrit.
IF p_check1 = 'X'.
iw_err-filen = w_lfile.
ELSE.
iw_err-filen = iw_file2-name.
ENDIF.
iw_err-errin = 'FILE NO DATA'(002).
iw_err-putda = w_date.
iw_err-putti = w_time.
INSERT zc0000sdt0020 FROM iw_err.
CLEAR:iw_err.
lw_ret = 'X'.
" EXIT.
ELSEIF sy-subrc <> 0.
**{ Insert started by ZhouTing on 30-Jan-2015 - CR0010
"lw_ret = 'X'.
**{ Insert ended by ZhouTing on 30-Jan-2015 - CR0010
EXIT.
ENDIF.
* 第一行不是标题
* IF lw_loopc = 1.
* CONTINUE.
* ENDIF.
* 拆分数据并加入接口表
* 0090036259 LR 0000300713 20140525 123456 3000
* vbeln fkart 客户代码 金税号
CHECK lw_ret IS INITIAL.
PERFORM frm_separate_text USING lw_text
CHANGING lw_ret.
CHECK lw_ret IS INITIAL.
PERFORM frm_writeback CHANGING lw_ret.
ENDDO. **{ Insert started by ZhouTing on 27-Jan-2015 - CR0010
CLOSE DATASET w_read_file.
**{ Insert ended by ZhouTing on 27-Jan-2015 - CR0010 DELETE DATASET w_read_file. ENDLOOP.
ENDFORM. " frm_transfer_data
*----------------------------------------------------------------------*
* 子程序名称 :拆分数据并加入接口表
* 子程序名 :frm_separate_text
* 概要 :拆分数据并加入接口表
* 参数 :f_text type c 要拆分的数据
* 返回值 :无
*----------------------------------------------------------------------*
FORM frm_separate_text USING f_text TYPE c
CHANGING f_ret TYPE c.
DATA: lw_value(100) TYPE c,
lw_val(1024) TYPE c,
lw_ret TYPE char1,
lw_zwrit TYPE i.
CLEAR f_ret.
lw_val = f_text. * Sys_Inv_No
SPLIT lw_val AT cl_abap_char_utilities=>horizontal_tab
INTO lw_value lw_val.
IF lw_value = space.
* 检查 发票号是否为空
PERFORM frm_get_errno CHANGING lw_zwrit.
iw_err-zwrit = lw_zwrit.
IF p_check1 = 'X'.
iw_err-filen = w_lfile.
ELSE.
iw_err-filen = iw_file2-name.
ENDIF.
iw_err-errin = 'INVOICENO IS EMPTY'(003).
iw_err-vbeln = lw_value.
iw_err-putda = w_date.
iw_err-putti = w_time.
INSERT zc0000sdt0020 FROM iw_err.
CLEAR:iw_err.
f_ret = 'X'.
ELSE.
* Sys_Inv_No检查
PERFORM frm_numeric_check USING lw_value
CHANGING lw_ret.
IF lw_ret = 'X'.
* 检查 发票是否为数字
PERFORM frm_get_errno CHANGING lw_zwrit.
iw_err-zwrit = lw_zwrit.
IF p_check1 = 'X'.
iw_err-filen = w_lfile.
ELSE.
iw_err-filen = iw_file2-name.
ENDIF.
iw_err-errin = 'INVOICENO IS NOT NUMBER'(004).
iw_err-vbeln = lw_value.
iw_err-putda = w_date.
iw_err-putti = w_time.
INSERT zc0000sdt0020 FROM iw_err.
CLEAR:iw_err.
f_ret = 'X'.
ELSE.
* 检查 发票存在性
PERFORM frm_check_inv USING lw_value
CHANGING lw_ret.
IF lw_ret = 'X'.
PERFORM frm_get_errno CHANGING lw_zwrit.
iw_err-zwrit = lw_zwrit.
IF p_check1 = 'X'.
iw_err-filen = w_lfile.
ELSE.
iw_err-filen = iw_file2-name.
ENDIF.
iw_err-errin = 'INVOICENO IS NOT EXIST'(005).
iw_err-vbeln = lw_value.
iw_err-putda = w_date.
iw_err-putti = w_time.
INSERT zc0000sdt0020 FROM iw_err.
CLEAR:iw_err.
f_ret = 'X'.
ELSEIF lw_val = space." 金税号 为空检查
PERFORM frm_get_errno CHANGING lw_zwrit.
iw_err-zwrit = lw_zwrit.
IF p_check1 = 'X'.
iw_err-filen = w_lfile.
ELSE.
iw_err-filen = iw_file2-name.
ENDIF.
iw_err-errin = 'JINSHUHAO IS EMPTY'(006).
iw_err-vbeln = lw_value.
iw_err-putda = w_date.
iw_err-putti = w_time.
INSERT zc0000sdt0020 FROM iw_err.
CLEAR:iw_err.
f_ret = 'X'.
ELSE.
iw_ins-vbeln = lw_value. "保存 数据
* fkart
CLEAR lw_value.
SPLIT lw_val AT cl_abap_char_utilities=>horizontal_tab
INTO lw_value lw_val.
iw_ins-fkart = lw_value. "保存 数据 *kunrg
CLEAR lw_value.
SPLIT lw_val AT cl_abap_char_utilities=>horizontal_tab
INTO lw_value lw_val.
iw_ins-kunrg = lw_value. "保存 数据
* Year
IF lw_val = space." 年度 为空检查
PERFORM frm_get_errno CHANGING lw_zwrit.
iw_err-zwrit = lw_zwrit.
IF p_check1 = 'X'.
iw_err-filen = w_lfile.
ELSE.
iw_err-filen = iw_file2-name.
ENDIF.
iw_err-errin = 'YEAR IS EMPTY'(007).
iw_err-vbeln = lw_value.
iw_err-putda = w_date.
iw_err-putti = w_time.
INSERT zc0000sdt0020 FROM iw_err.
CLEAR:iw_err.
f_ret = 'X'.
ELSE.
CLEAR lw_value.
SPLIT lw_val AT cl_abap_char_utilities=>horizontal_tab
INTO lw_value lw_val.
iw_ins-gjahr = lw_value+0(4). "保存 数据
*linda 20140806
iw_ins-fkdat = lw_value. "保存 数据
ENDIF.
* VAT_Inv_No
CLEAR lw_value.
SPLIT lw_val AT cl_abap_char_utilities=>horizontal_tab
INTO lw_value lw_val.
iw_ins-xblnr = lw_value. "保存 数据
iw_ins-bktxt = lw_value."Linda 20140918
* bukrs
CLEAR lw_value.
SPLIT lw_val AT cl_abap_char_utilities=>horizontal_tab
INTO lw_value lw_val.
iw_ins-bukrs = lw_value. "保存 数据
ENDIF.
ENDIF.
ENDIF.
ENDFORM. " frm_separate_text
*Sys_Inv_No VAT_Inv_No VAT Issue_date Total_Amount
*0090035243 12345654321 2005-08-10 8
*----------------------------------------------------------------------*
* 子程序名称 :数据类型检查
* 子程序名 :frm_numeric_check
* 概要 :数据类型检查
* 参数 :f_val TYPE c 要检查的数据
* 返回值 :f_ret TYPE c 正常:space 出错:'X'
*----------------------------------------------------------------------*
FORM frm_numeric_check USING f_val TYPE c
CHANGING f_ret TYPE c.
DATA: lw_type TYPE dd01v-datatype. CHECK f_val <> space.
CLEAR f_ret.
CALL FUNCTION 'NUMERIC_CHECK'
EXPORTING
string_in = f_val
IMPORTING
htype = lw_type.
IF lw_type <> cos_numc.
f_ret = 'X'.
ENDIF.
ENDFORM. " frm_numeric_check *&---------------------------------------------------------------------*
*& Form frm_get_errno
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_LW_ZWRIT text
*----------------------------------------------------------------------*
FORM frm_get_errno CHANGING f_zwrit TYPE i.
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
nr_range_nr = '' "snro
object = 'ZWRITEBACK' "snro object "be edit
IMPORTING
number = f_zwrit "所得到的号码
EXCEPTIONS
interval_not_found = 1
number_range_not_intern = 2
object_not_found = 3
quantity_is_0 = 4
quantity_is_not_1 = 5
interval_overflow = 6
buffer_overflow = 7
OTHERS = 8.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 INTO iw_errlog-str.
APPEND iw_errlog TO it_errlog2.
ENDIF. ENDFORM. " frm_get_errno
*&---------------------------------------------------------------------*
*& Form FRM_CHECK_INV
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->f_vbeln text
* <--f_ret text
*----------------------------------------------------------------------*
FORM frm_check_inv USING f_vbeln
CHANGING f_ret.
DATA:lw_count TYPE i.
SELECT COUNT(*)
INTO lw_count
FROM vbrk "(Reference Document Number)
WHERE vbeln = f_vbeln . "Billing Document
IF sy-subrc = 4.
f_ret = 'X'.
ENDIF.
ENDFORM. " FRM_CHECK_INV
*&---------------------------------------------------------------------*
*& Form frm_writeback
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->fw_ret text
*----------------------------------------------------------------------*
FORM frm_writeback CHANGING fw_ret.
DATA:lw_zwrit TYPE i,
lw_count TYPE i,
lw_bktxt TYPE bktxt, "linda 20140916
lw_belnr TYPE bkpf-belnr,
lw_gjahr TYPE char4.
*Select IsExist Invoice
SELECT SINGLE vbeln
bukrs
gjahr
xblnr
fkdat
INTO iw_vbrk
FROM vbrk "(Reference Document Number)
WHERE vbeln = iw_ins-vbeln. "Billing Document
IF iw_vbrk-xblnr <> iw_ins-xblnr.
* 将发票号更新到发票 BKPF-XBLNR(Reference Document Number)
PERFORM frm_vbrk_xblnr USING iw_ins-xblnr
iw_ins-vbeln.
IF w_msg_txt IS NOT INITIAL.
PERFORM frm_get_errno CHANGING lw_zwrit.
iw_err-zwrit = lw_zwrit.
IF p_check1 = 'X'.
iw_err-filen = w_lfile.
ELSE.
iw_err-filen = iw_file2-name.
ENDIF.
iw_err-errin = 'UPDATA VBRK FAIL'(008).
iw_err-vbeln = iw_ins-vbeln.
iw_err-xblnr = iw_ins-xblnr.
iw_err-putda = w_date.
iw_err-putti = w_time.
INSERT zc0000sdt0020 FROM iw_err.
CLEAR:iw_err,w_msg_txt.
fw_ret = 'X'.
ENDIF.
ENDIF.
CHECK fw_ret IS INITIAL.
SELECT SINGLE belnr bktxt "Linda 20140916 xblnr
INTO (lw_belnr,lw_bktxt) "Linda 20140916lw_xblnr
FROM bkpf
WHERE bukrs = iw_vbrk-bukrs
AND awkey = iw_ins-vbeln "BKPF-AWKEY(Reference Key)
AND gjahr = iw_vbrk-fkdat+0(4). IF lw_bktxt <> iw_ins-bktxt.
lw_gjahr = iw_vbrk-fkdat+0(4).
IF lw_belnr IS INITIAL.
PERFORM frm_get_errno CHANGING lw_zwrit.
iw_err-zwrit = lw_zwrit.
IF p_check1 = 'X'.
iw_err-filen = w_lfile.
ELSE.
iw_err-filen = iw_file2-name.
ENDIF.
iw_err-errin = 'Invoice Is Empty'(009).
iw_err-vbeln = iw_ins-vbeln.
iw_err-xblnr = iw_ins-xblnr.
iw_err-putda = w_date.
iw_err-putti = w_time.
INSERT zc0000sdt0020 FROM iw_err.
CLEAR:iw_err,w_msg_txt.
fw_ret = 'X'.
ELSE.
* 将发票号更新到凭证BKPF中的BKPF-XBLNR(Reference Document Number)
* update the GTS No.# to BKPF-XBLNR(Reference Document Number)
* 2 reason:1>.要调用的function 用到了bseg这个结构;
* Call function "'Z_FI_ITEMS_MASS_CHANGE'" using BSEG as import structure
* 2>使用的频率不高,1周1次,每次XX 条,所以即使写成 select * 也对性能影响不大
* The call frequence will be weekly, and the volume is limited, thus should the performance impact is restricted.
SELECT *
INTO TABLE it_bseg
FROM bseg
WHERE bukrs = iw_vbrk-bukrs
AND belnr = lw_belnr
AND gjahr = lw_gjahr. PERFORM frm_bseg_sgtxt USING iw_ins.
IF w_msg_txt IS NOT INITIAL.
PERFORM frm_get_errno CHANGING lw_zwrit.
iw_err-zwrit = lw_zwrit.
IF p_check1 = 'X'.
iw_err-filen = w_lfile.
ELSE.
iw_err-filen = iw_file2-name.
ENDIF.
iw_err-errin = 'BDC update fail'(010).
iw_err-vbeln = iw_ins-vbeln.
iw_err-xblnr = iw_ins-xblnr.
iw_err-putda = w_date.
iw_err-putti = w_time.
INSERT zc0000sdt0020 FROM iw_err.
CLEAR:iw_err,w_msg_txt.
fw_ret = 'X'.
ENDIF. ENDIF.
ENDIF.
CHECK fw_ret IS INITIAL.
SELECT COUNT(*)
FROM zc0000sdt0020
INTO lw_count
WHERE vbeln = iw_ins-vbeln.
IF lw_count > 1.
DELETE FROM zc0000sdt0020 WHERE vbeln = iw_ins-vbeln.
IF sy-subrc = 0.
COMMIT WORK AND WAIT.
ELSE.
ROLLBACK WORK.
ENDIF.
ENDIF.
CLEAR:it_bseg.
ENDFORM. " frm_writeback
*&---------------------------------------------------------------------*
*& Module STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_9000 OUTPUT.
SET PF-STATUS ''.
SET TITLEBAR 'ERROR LOG SEARCH'. ENDMODULE. " STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9000 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_9000 INPUT.
CASE ok_code.
WHEN 'EXECUTE'.
PERFORM frm_data_select. IF it_errlog IS INITIAL.
MESSAGE e001(00) WITH 'NO error log data'(011).
LEAVE TO SCREEN 9000.
ENDIF.
* ALV最后结果输出
PERFORM frm_display_data.
WHEN 'CANCEL'.
LEAVE TO SCREEN 0.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_9000 INPUT
*----------------------------------------------------------------------*
* 子程序名称 :ALV最后结果输出
* 子程序名 :frm_display_data
* 概要 :ALV最后结果输出
* 参数 :无
* 返回值 :无
*----------------------------------------------------------------------*
FORM frm_display_data .
w_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = w_repid
i_structure_name = 'ZC0000SDT0020'
it_fieldcat = it_fieldcat
TABLES
t_outtab = it_errlog.
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. " frm_display_data
*&---------------------------------------------------------------------*
*& Form frm_data_select
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_data_select .
IF zc0000sdt0020-filen IS NOT INITIAL.
CONCATENATE 'FILEN LIKE ''' zc0000sdt0020-filen '%''' INTO w_str.
ENDIF.
**************** putda**************************************
IF zc0000sdt0020-putda IS NOT INITIAL AND putdahigh IS INITIAL.
IF w_str IS NOT INITIAL.
CONCATENATE w_str ' and putda = ZC0000SDT0020-putda' INTO w_str.
ELSE.
w_str = 'putda = ZC0000SDT0020-putda'.
ENDIF.
ENDIF.
IF zc0000sdt0020-putda IS INITIAL AND putdahigh IS NOT INITIAL.
IF w_str IS NOT INITIAL.
CONCATENATE w_str ' and putda = putdahigh' INTO w_str.
ELSE.
w_str = 'putda = putdahigh'.
ENDIF.
ENDIF.
IF zc0000sdt0020-putda IS NOT INITIAL AND putdahigh IS NOT INITIAL.
IF w_str IS NOT INITIAL.
CONCATENATE w_str ' and putda <= putdahigh and putda >= ZC0000SDT0020-putda' INTO w_str.
ELSE.
w_str = 'putda <= putdahigh and putda >= ZC0000SDT0020-putda'.
ENDIF. ENDIF.
* **************** putti**************************************
IF zc0000sdt0020-putti IS NOT INITIAL AND puttihigh IS INITIAL.
IF w_str IS NOT INITIAL.
CONCATENATE w_str ' and putti = ZC0000SDT0020-putti' INTO w_str.
ELSE.
w_str = 'putti = ZC0000SDT0020-putti'.
ENDIF.
ENDIF.
IF zc0000sdt0020-putti IS INITIAL AND puttihigh IS NOT INITIAL.
IF w_str IS NOT INITIAL.
CONCATENATE w_str ' and putti = puttihigh' INTO w_str.
ELSE.
w_str = 'putti = puttihigh'.
ENDIF.
ENDIF.
IF zc0000sdt0020-putti IS NOT INITIAL AND puttihigh IS NOT INITIAL.
IF w_str IS NOT INITIAL.
CONCATENATE w_str ' and putti <= puttihigh and putti >= ZC0000SDT0020-putti' INTO w_str.
ELSE.
w_str = 'putti <= puttihigh and putti >= ZC0000SDT0020-putti'.
ENDIF. ENDIF.
* **************** VBELN**************************************
IF zc0000sdt0020-vbeln IS NOT INITIAL AND vbelnhigh IS INITIAL.
IF w_str IS NOT INITIAL.
CONCATENATE w_str ' and VBELN = ZC0000SDT0020-VBELN' INTO w_str.
ELSE.
w_str = 'VBELN = ZC0000SDT0020-VBELN'.
ENDIF.
ENDIF.
IF zc0000sdt0020-vbeln IS INITIAL AND vbelnhigh IS NOT INITIAL.
IF w_str IS NOT INITIAL.
CONCATENATE w_str ' and VBELN = VBELNHIGH' INTO w_str.
ELSE.
w_str = 'VBELN = VBELNHIGH'.
ENDIF.
ENDIF.
IF zc0000sdt0020-vbeln IS NOT INITIAL AND vbelnhigh IS NOT INITIAL.
IF w_str IS NOT INITIAL.
CONCATENATE w_str ' and VBELN <= VBELNHIGH and VBELN >= ZC0000SDT0020-VBELN' INTO w_str.
ELSE.
w_str = 'VBELN <= VBELNHIGH and VBELN >= ZC0000SDT0020-VBELN'.
ENDIF. ENDIF.
* **************** XBLNR**************************************
IF zc0000sdt0020-xblnr IS NOT INITIAL AND xblnrhigh IS INITIAL.
IF w_str IS NOT INITIAL.
CONCATENATE w_str ' and XBLNR = ZC0000SDT0020-XBLNR' INTO w_str.
ELSE.
w_str = 'XBLNR = ZC0000SDT0020-XBLNR'.
ENDIF.
ENDIF.
IF zc0000sdt0020-xblnr IS INITIAL AND xblnrhigh IS NOT INITIAL.
IF w_str IS NOT INITIAL.
CONCATENATE w_str ' and XBLNR = XBLNRHIGH' INTO w_str.
ELSE.
w_str = 'XBLNR = XBLNRHIGH'.
ENDIF.
ENDIF.
IF zc0000sdt0020-xblnr IS NOT INITIAL AND xblnrhigh IS NOT INITIAL.
IF w_str IS NOT INITIAL.
CONCATENATE w_str ' and XBLNR <= XBLNRHIGH and XBLNR >= ZC0000SDT0020-XBLNR' INTO w_str.
ELSE.
w_str = 'XBLNR <= XBLNRHIGH and XBLNR >= ZC0000SDT0020-XBLNR'.
ENDIF. ENDIF.
* **************** ERRIN**************************************
IF zc0000sdt0020-errin IS NOT INITIAL.
IF w_str IS NOT INITIAL.
CONCATENATE w_str ' and ERRIN LIKE ''' zc0000sdt0020-errin '%''' INTO w_str.
ELSE.
CONCATENATE 'ERRIN LIKE ''' zc0000sdt0020-errin '%''' INTO w_str.
ENDIF.
ENDIF.
SELECT zwrit
filen
putda
putti
vbeln
xblnr
errin
INTO CORRESPONDING FIELDS OF TABLE it_errlog
FROM zc0000sdt0020
WHERE (w_str).
CLEAR:w_str.
ENDFORM. " frm_data_select
*&---------------------------------------------------------------------*
*& Form frm_vbrk_xblnr
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->pf_xblnr text
* -->pf_vbeln text
*----------------------------------------------------------------------*
FORM frm_vbrk_xblnr USING pf_xblnr
pf_vbeln. CALL FUNCTION 'UPDATE_XBLNR_IN_VBRK'
EXPORTING
i_vbeln = pf_vbeln
i_xblnr = pf_xblnr
* I_XBLNR_CHECK =
* IMPORTING
* E_XBLNR =
EXCEPTIONS
document_blocked = 1
update_no_success = 2
OTHERS = 3
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
INTO w_msg_txt
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF. ENDFORM. " FRM_VBRK_BDC
*&---------------------------------------------------------------------*
*& Form FRM_FILE_PROCESS_LOCAL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_file_process_local.
DATA: ls_row TYPE kcdu_srec,
lw_zwrit TYPE i. PERFORM file_format_check.
PERFORM upload_csv. * 文件数据传送接口表
DO.
w_row_num = sy-index.
CLEAR ls_row.
" w_step_ok = 'X'.
CALL FUNCTION 'FILE_NEXT_RECORD'
IMPORTING
next_record = ls_row
EXCEPTIONS
no_record = 1.
IF sy-subrc <> 0 OR ls_row IS INITIAL.
IF w_row_num = 1.
PERFORM frm_get_errno CHANGING lw_zwrit.
iw_err-zwrit = lw_zwrit.
iw_err-filen = w_lfile.
iw_err-errin = 'FILE NO DATA'(002).
iw_err-putda = w_date.
iw_err-putti = w_time.
INSERT zc0000sdt0020 FROM iw_err.
CLEAR:iw_err.
w_ret = 'X'.
ENDIF.
EXIT.
ENDIF. * 第一行不是标题
* IF lw_loopc = 1.
* CONTINUE.
* ENDIF.
* 拆分数据并加入接口表
* 0090036259 LR 0000300713 20140525 123456 3000
* vbeln fkart 客户代码 金税号
CHECK w_ret IS INITIAL.
PERFORM frm_separate_text USING ls_row
CHANGING w_ret.
CHECK w_ret IS INITIAL.
PERFORM frm_writeback CHANGING w_ret. ENDDO. ENDFORM. " frm_file_process_local
*&---------------------------------------------------------------------*
*& Form form_get_file_path_upload
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM form_get_file_path_upload .
DATA:
ld_rc TYPE i,
lw_file TYPE string,
lt_file TYPE filetable. CALL FUNCTION 'GET_DYNP_VALUE'
EXPORTING
i_field = 'P_FLPATH'
i_repid = sy-repid
i_dynnr = ''
CHANGING
o_value = p_flpath. lw_file = p_flpath. CALL FUNCTION 'CH_SPLIT_FILENAME'
EXPORTING
complete_filename = lw_file
IMPORTING
path = w_file_path
EXCEPTIONS
invalid_drive = 1
invalid_path = 2
OTHERS = 3. CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
* window_title =
default_extension = '*.TXT'
default_filename = lw_file
file_filter = '*.TXT'
* with_encoding =
initial_directory = w_file_path
* multiselection =
CHANGING
file_table = lt_file
rc = ld_rc
* user_action =
* file_encoding =
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 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.
ELSE.
READ TABLE lt_file INTO lw_file INDEX 1.
p_flpath = lw_file.
ENDIF. ENDFORM. " form_get_file_path_upload *&---------------------------------------------------------------------*
*& Form file_format_check
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM file_format_check .
DATA:ld_ext TYPE char10,
lw_file TYPE string,
lw_name TYPE string.
lw_file = p_flpath.
CALL FUNCTION 'CH_SPLIT_FILENAME'
EXPORTING
complete_filename = lw_file
IMPORTING
extension = ld_ext
name = lw_name
name_with_ext = w_lfile
EXCEPTIONS
invalid_drive = 1
invalid_path = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 INTO iw_errlog-str.
APPEND iw_errlog TO it_errlog2.
w_ret = 'X'.
ENDIF. IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
CALL FUNCTION 'AIPC_CONVERT_TO_UPPERCASE'
EXPORTING
i_input = ld_ext
i_langu = sy-langu
IMPORTING
e_output = ld_ext.
ENDIF.
ENDFORM. " file_format_check
*&---------------------------------------------------------------------*
*& Form upload_csv
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM upload_csv .
DATA:ld_file TYPE localfile. ld_file = p_flpath. CALL FUNCTION 'FILE_OPEN'
EXPORTING
filnm = ld_file
upl = 'X'
filfmt = 'T'
EXCEPTIONS
logname_not_found = 1
file_not_opened = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 INTO iw_errlog-str.
APPEND iw_errlog TO it_errlog2.
w_ret = 'X'.
ENDIF.
ENDFORM. " upload_csv
*&---------------------------------------------------------------------*
*& Form FRM_BSEG_UPDATE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->pf_bukrs text
* -->pf_belnr text
* -->pf_gjahr text
* -->pf_buzei text
* -->pf_bschl text
* -->pf_bktxt text
*----------------------------------------------------------------------*
FORM frm_bseg_update USING pf_bukrs
pf_belnr
pf_gjahr
pf_buzei
pf_bschl
pf_bktxt. "Linda 20141117
DATA:iw_buztab TYPE tpit_buztab,
iw_fldtab TYPE tpit_fname. * 所改字段之值
* iw_bseg-sgtxt = pf_sgtxt. "Linda 20141117 edi
iw_bseg-sgtxt = pf_bktxt. iw_buztab-bukrs = pf_bukrs.
iw_buztab-belnr = pf_belnr.
iw_buztab-gjahr = pf_gjahr.
iw_buztab-buzei = pf_buzei.
iw_buztab-bschl = pf_bschl. "posting key
* it_buztab-koart = 'S'. "leixing
APPEND iw_buztab TO it_buztab. iw_fldtab-fname = 'SGTXT'.
iw_fldtab-aenkz = 'X'.
APPEND iw_fldtab TO it_fldtab. * copy from FI_ITEMS_MASS_CHANGE , change defult module from asynchronous to synchronous
CALL FUNCTION 'Z_FI_ITEMS_MASS_CHANGE'
EXPORTING
s_bseg = iw_bseg
i_bktxt = pf_bktxt
IMPORTING
errtab = it_errtab
TABLES
it_buztab = it_buztab
it_fldtab = it_fldtab
EXCEPTIONS
bdc_errors = 1
OTHERS = 2.
IF sy-subrc = 0.
COMMIT WORK AND WAIT.
ELSE.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 INTO w_msg_txt.
ENDIF.
CLEAR:it_errtab,it_errtab[],it_buztab,it_buztab[],it_fldtab,it_fldtab[],iw_bseg. ENDFORM. " FRM_BSEG_UPDATE
*&---------------------------------------------------------------------*
*& Form FRM_BSEG_SGTXT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> pf_ins text
*----------------------------------------------------------------------*
FORM frm_bseg_sgtxt USING pf_ins LIKE iw_ins.
DATA:lw_bseg TYPE bseg.
LOOP AT it_bseg INTO lw_bseg. PERFORM frm_bseg_update USING lw_bseg-bukrs
lw_bseg-belnr
lw_bseg-gjahr
lw_bseg-buzei
lw_bseg-bschl
pf_ins-bktxt.
IF w_msg_txt IS NOT INITIAL.
EXIT.
ENDIF.
ENDLOOP.
ENDFORM. " FRM_BSEG_SGTXT
SAP 金税接口代码 供参考的更多相关文章
- SAP 金税接口介绍
一.金税发票与SAP系统发票的税额差异分析 1.1 金税系统中的税额说明 国内企业销售产品给国内客户时,正常产品须要缴纳17%的增值税,而金税(Golden Tax)系统就是用来出具纸面的增值税发票的 ...
- SAP 金税接口增强 BADI
SAP与金税连接有两种方式:组件接口及文本接口. 文本接口为例: 1.SAP取发票数据.主要来自合同,销售订单,交货单.发票,客户供应商主数据等 2.SAP处理:合并.拆分,折扣等 3.导出TXT ...
- C#复制文件全代码--供参考
private void button1_Click(object sender, EventArgs e) { //创建文件对象 FileInfo fi = null; //实例化打开文件对话框 O ...
- php短信接口代码
这篇文章主要为大家详细介绍了php短信接口代码,php短信发送.php批量发送.php获取余额等代码,感兴趣的小伙伴们可以参考一下 本文实例为大家分享了几个常用的php短信接口代码,供大家参考,具体内 ...
- django中使用FastDFS分布式文件系统接口代码实现文件上传、下载、更新、删除
运维使用docker部署好之后FastDFS分布式文件系统之后,提供给我接口如下: fastdfs tracker 192.168.1.216 192.168.1.217 storage 192.16 ...
- NPOI导入导出EXCEL通用类,供参考,可直接使用在WinForm项目中
以下是NPOI导入导出EXCEL通用类,是在别人的代码上进行优化的,兼容xls与xlsx文件格式,供参考,可直接使用在WinForm项目中,由于XSSFWorkbook类型的Write方法限制,Wri ...
- EF封装类,供参考!
以下是我对EF DB FIRST 生成的ObjectContext类进行封装,代码如下,供参考学习: using System; using System.Collections.Generic; u ...
- SAP MM 事务代码MI31之思考
SAP MM 事务代码MI31之思考 1 - MI01之痛 多年SAP项目实施实践中,笔者之前对于SAP系统里盘点凭证创建(MI01)事务代码里的输入界面很是不爽: 第一,MI01输入了一行数据以后, ...
- 我的第一个python web开发框架(33)——接口代码重构
前面ORM模块我们已经完成了开发,接下来要做的就是对项目代码进行重构了.因为对底层数据库操作模块(db_helper.py)进行了改造,之前项目的接口代码全都跑不起来了. 在写ORM模块时,我们已经对 ...
随机推荐
- 菜鸟学SSH(八)——Hibernate对象的三种状态
前面写了几篇关于SSH的博客,但不是Struts就是Spring,Hibernate还从来没写过呢.说好是SSH的,怎么可以光写那两个,而不写Hibernate呢对吧.今天就先说说Hibernate对 ...
- 【小白的CFD之旅】22 好网格与坏网格
网格疏密网格形状其他的一些问题小白的总结郑重申明 网格的作用如此重要,以至于小白纠结了很久.小白知道网格划分过程很大程度上受制于计算资源的限制,但小白还是不太明白,如果计算资源非常充足,不用顾忌资源限 ...
- linux命令(47):Linux下对文件进行按行排序,去除重复行
Linux下对文件进行按行排序:sort 与 uniq 命令简介 Linux | May 24, 2015 | linux sort 命令可针对文本文件的内容,以行为单位进行排序.其基本语法格式为: ...
- 如何打开chrome中flash debug player
If you’ve installed the latest version of Google Chrome, and you are having a problem debugging your ...
- 【ARM】2410裸机系列-中断处理
目的 为了更好地掌握S3C2410中断的原理及中断程序的编写. 内容利用S3C2410的外部中断0和外部中断1实现两个按键功能 原理 本次选择的是外部中断EXTINT0和EXTINT11.中断的产生分 ...
- Android MediaPlayer接口及状态迁移
[时间:2016-09] [状态:Open] [关键词:android,mediaplayer,播放接口,播放状态图] 引言 本文内容相对简单,作为后续处理的起点,简要整理了Android Media ...
- STL之std::set、std::map的lower_bound和upper_bound函数使用说明
由于在使用std::map时感觉lower_bound和upper_bound函数了解不多,这里整理并记录下相关用法及功能. STL的map.multimap.set.multiset都有三个比较特殊 ...
- Android开发(一)——全屏或者取消标题栏
先介绍去掉标题栏的方法: 第一种:也一般入门的时候经常使用的一种方法 requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏 注意这句一定要写在se ...
- Orcale分析函数OVER(PARTITION BY... ORDER BY...)的讲解
顾名思义,PARTITION 中文是分割的意思,ORDER 是排序的意思,所以翻译一下就是先把一组数据按照制定的字段进行分割成各种组,然后组内按照某个字段排序. 以实际案例来说明这个函数的使用, 首先 ...
- 有用sql语句一
DECLARE @retval int, @param1 int EXECUTE @retval=master.dbo.xp_fileexist 'D:\TkSoft\SamplePic\Fabric ...