1. 问题描述
OA设置每隔1小时从SAP同步采购订单,由于没做筛选每次同步SAP全部数据,响应报文太大导致OA系统卡顿。
2. 解决办法
采购订单抬头(ekko)表,有个字段叫"LASTCHANGEDATETIME",更改时戳,查询采购订单sql语句加上更改时戳大于某个时间点即可。
3. 程序更改和代码
DATA: l_datum_sta TYPE sy-datum, "当前日期往前推n个小时的日期
l_datum_end TYPE sy-datum, "当前日期
l_uzeit_sta TYPE sy-uzeit, "当前日期往前推n个小时的时间
l_uzeit_end TYPE sy-uzeit, "当前时间
l_time_stamp TYPE changedatetime. "转化后的日期时间戳
l_datum_end = sy-datum.
l_uzeit_end = sy-uzeit+0(4) && '00'.
" 获取前2个小时的日期,时间
CALL FUNCTION 'START_TIME_DETERMINE'
EXPORTING
duration = '120' "获取当前时间前2小时的时间戳
unit = 'MIN'
IMPORTING
start_date = l_datum_sta "输出开始日期
start_time = l_uzeit_sta "输出开始时间
CHANGING
end_date = l_datum_end
end_time = l_uzeit_end.
" 将前2个小时的日期,时间转换成时间戳
CONVERT DATE l_datum_sta
TIME l_uzeit_sta
DAYLIGHT SAVING TIME sy-dayst "夏令时
INTO TIME STAMP l_time_stamp
TIME ZONE sy-zonlo. "时区
"sql语句最后加上条件AND lastchangedatetime GE @l_time_stamp
SELECT *
FROM ekko
INTO TABLE @DATA(lt_ekko)
WHERE ebeln IN @s_ebeln
AND bukrs IN @s_bukrs
AND bsart IN @s_bsart
AND ekorg IN @s_ekorg
AND ekgrp IN @s_ekgrp
AND lifnr IN @s_lifnr
AND aedat IN @s_aedat
AND ernam IN @s_ernam
AND lastchangedatetime GE @l_time_stamp.
标签:sy,end,sta,做过,datum,获取,ABAP,uzeit,time
From: https://www.cnblogs.com/yddwinter/p/17130123.html