首页 > 代码库 > 汇率同步接口

汇率同步接口

FUNCTION zrfc_mm009.
*"----------------------------------------------------------------------
*"*"Local interface:
*"  IMPORTING
*"     VALUE(CALLNO) TYPE  ZCALLNO
*"  EXPORTING
*"     VALUE(FLAG) LIKE  BAPIRET2-TYPE
*"     VALUE(MESSAGE) LIKE  BAPIRET2-MESSAGE
*"  TABLES
*"      TCURR STRUCTURE  TCURR
*"----------------------------------------------------------------------
DATA: ls_tcurr TYPE tcurr,
      ukurs(15),
      ffact(9),
      tfact(9),
      lv_datano TYPE zdatano,
      lv_date1(12),
      lv_flag(1),
      lv_date(8).
FIELD-SYMBOLS <fs> TYPE tcurr.

SELECT * INTO TABLE tcurr FROM tcurr WHERE kurst = M.
  IF sy-subrc = 0.
      flag = S.
      message = 执行成功.
      ELSE.
      flag = E.
      message = 执行失败.
  ENDIF.

LOOP AT tcurr ASSIGNING <fs>.
  CLEAR: lv_flag,lv_date1,lv_date.
  CALL FUNCTION CONVERSION_EXIT_INVDT_OUTPUT
    EXPORTING
      input         = <fs>-gdatu
   IMPORTING
     output        =  lv_date1.

  lv_flag = lv_date1+4(1).
  CALL FUNCTION CONVERT_DATE_TO_INTERNAL
    EXPORTING
      date_external                  = lv_date1
     accept_initial_date             = lv_flag
   IMPORTING
     date_internal                   = lv_date
   EXCEPTIONS
     date_external_is_invalid        = 1
     OTHERS                          = 2.
    IF sy-subrc = 0.
    <fs>-gdatu = lv_date.
    ENDIF.
ENDLOOP.

*日志记录
   CLEAR:gt_log,gs_log.
   LOOP AT tcurr INTO ls_tcurr.
    lv_datano = lv_datano + 1.
    gs_log-datano = lv_datano.
    ukurs = ls_tcurr-ukurs.
    gs_log-name   = ZRFC_MM009.
    gs_log-cdate  = sy-datum.
    GET TIME.
    gs_log-ctime  = sy-uzeit.
    gs_log-callno = callno.
    gs_log-flag   = flag.
    gs_log-log    = message.

    CONCATENATE ls_tcurr-kurst  ls_tcurr-fcurr  ls_tcurr-tcurr  ls_tcurr-gdatu  ukurs
                 ffact          tfact
    INTO gs_log-content SEPARATED BY  .
    SHIFT message LEFT DELETING LEADING  .
    CONDENSE gs_log-content NO-GAPS.
    gs_log-length = STRLEN( gs_log-content ).
    APPEND gs_log TO gt_log.
    CLEAR: gs_log,ls_tcurr,ukurs.
   ENDLOOP.

   IF gt_log IS NOT INITIAL.
     INSERT zrfc_mm01in_log FROM TABLE gt_log.
     IF sy-subrc = 0.
       COMMIT WORK.
     ENDIF.
   ENDIF.
ENDFUNCTION.

 

汇率同步接口