2011年4月8日 星期五

[Func] SD_CONDITION_TIME_INTERVAL_GET

依照篩選條件取回日期區間內生效的價格條件
FUNCTION SD_CONDITION_TIME_INTERVAL_GET :
CALL FUNCTION 'SD_CONDITION_TIME_INTERVAL_GET'
    EXPORTING
      VALUE(KOMG_I)             LIKE  KOMG STRUCTURE  KOMG OPTIONAL
      VALUE(KOMK_I)             LIKE  KOMK STRUCTURE  KOMK OPTIONAL
      VALUE(KOMP_I)             LIKE  KOMP STRUCTURE  KOMP OPTIONAL
      VALUE(DATVO_I)            LIKE  A000-DATAB
      VALUE(DATBI_I)            LIKE  A000-DATBI
      VALUE(KVEWE_I)            LIKE  T681V-KVEWE DEFAULT 'A'
      VALUE(KAPPL_I)            LIKE  T681A-KAPPL DEFAULT 'V '
      VALUE(KOMK_KOMP_FIELDS_I) LIKE  SY-MARKY DEFAULT ' '
    TABLES
      PERIODS_TAB               STRUCTURE  WPPERIOD
      KSCHL_TAB                 STRUCTURE  WPKSCHL
    EXCEPTIONS
      NO_CONDITIONS.
Example:
KOMG-VKORG = P_VKORG.
      KOMG-VTWEG = P_VTWEG.
      KOMG-MATNR = IMATNR-MATNR.
      KOMG-KUNNR = IKUNNR-KUNNR.
      CALL FUNCTION 'SD_CONDITION_TIME_INTERVAL_GET'
        EXPORTING
          KOMG_I      = KOMG
          DATVO_I     = S_DATAB-LOW
          DATBI_I     = S_DATAB-HIGH
        TABLES
          PERIODS_TAB = GT_PREDATE
          KSCHL_TAB   = GT_TKSCH
        EXCEPTIONS
          OTHERS      = 1.
      READ TABLE GT_PREDATE INDEX 1.
      CHECK SY-SUBRC = 0.
      LOOP AT GT_PREDATE.
        GT_ITAB-MATNR   = IMATNR-MATNR.
        GT_ITAB-KUNNR   = IKUNNR-KUNNR.
        GT_ITAB-NAME1   = IKUNNR-NAME1.
        GT_ITAB-KOTABNR = GT_PREDATE-KOTABNR.
        GT_ITAB-VTWEG   = P_VTWEG.
        GT_ITAB-KSCHL   = P_KSCHL.
        GT_ITAB-DATAB   = GT_PREDATE-DATAB.
        GT_ITAB-DATBI   = GT_PREDATE-DATBI.
        SELECT SINGLE H~ERNAM H~ERDAT P~KBETR
            INTO (GT_ITAB-ERNAM, GT_ITAB-ERDAT,GT_ITAB-KBETR)
            FROM KONH AS H
            JOIN KONP AS P
              ON P~KNUMH = H~KNUMH
           WHERE H~KNUMH = GT_PREDATE-KNUMH.
        APPEND GT_ITAB.
        LT_DD02T-KOTABNR = GT_PREDATE-KOTABNR.
        APPEND LT_DD02T.
      ENDLOOP.

沒有留言:

張貼留言