2011年4月13日 星期三

[Link] ABAP FAQS

This Document Provides Answers to Frequently Asked Questions

http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/840ad679-0601-0010-cd8e-9989fd650822

2011年4月8日 星期五

[Link] MassDownload


News: 2012/03/11 Mass Download Program version update to 1.5.1
Mass Download is the successor to Direct Download, the same basic idea but with a totally new code base. The program has all the same features as before but has been updated to take advantage off some of the new features and changes that have arrived in the latest version of SAP.

Change document

customer master object: (Block customer):
TABLE       CDHDR/CDPOS
OBJECTCLAS  = DEBI
OBJECTID    = <Customer number>
TCODE       = VD05

OBJECTCLAS

可以由底下 Table 取得:
SWECDOBTYP  指派更改文件 / 工作流程物件類型
TCDOB       變更文件建立的物件
FUNCTION C14O_CH_DOC_OBJ_NAME_GET:
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"       IMPORTING
*"             VALUE(I_TABLENAME) TYPE  ESP1_TAB_NAME
*"       EXPORTING
*"             VALUE(E_OBJ_NAME) LIKE  TCDOB-OBJECT
*"       EXCEPTIONS
*"              ILLEGAL_INPUT<
*"              CHNG_DOC_OBJ_NOT_FOUND
*"----------------------------------------------------------------------
CDNAMES_GET
Transport Chnge doc.obj. via shadow tab.

訂單文件修改查詢

範例程式:RVSCD100:
CALL FUNCTION 'CHANGEDOCUMENT_READ_HEADERS'
  EXPORTING
    DATE_OF_CHANGE    = CDHDR-UDATE
    OBJECTCLASS       = CDHDR-OBJECTCLAS
    OBJECTID          = CDHDR-OBJECTID
    TIME_OF_CHANGE    = CDHDR-UTIME
    USERNAME          = CDHDR-USERNAME
  TABLES
    I_CDHDR           = ICDHDR
  EXCEPTIONS
    NO_POSITION_FOUND = 1
    OTHERS            = 2.

CALL FUNCTION 'CHANGEDOCUMENT_READ_POSITIONS'
  EXPORTING
    CHANGENUMBER      = ICDHDR-CHANGENR
    TABLEKEY          = CDPOS-TABKEY
    TABLENAME         = CDPOS-TABNAME
  IMPORTING
    HEADER            = CDHDR
  TABLES
    EDITPOS           = ICDSHW
  EXCEPTIONS
    NO_POSITION_FOUND = 1
    OTHERS            = 2.

[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.

[Code] Abap list Total Pages

如何印出 [ 頁次/總頁數 ] 的樣式呢?
在每一頁的表頭上,總頁數先用特別的字串代表,特別的字串必須不會與其他的字串重複,以免後面要取代時會有失誤。
假設表頭總頁數的代表字串是 '----' ,取代的程式如下,在列印工作完成之後:
   WRITE SY-PAGNO TO TO_PAGE LEFT-JUSTIFIED.
   DO SY-PAGNO TIMES.
      READ LINE 3 OF PAGE SY-INDEX.
      REPLACE '----' WITH TO_PAGE INTO SY-LISEL.
      MODIFY CURRENT LINE.
   ENDDO.

Passing data from one ABAP program to another

1. You have to define an internal table ITAB in program AAA. 
2. In the program AAA you export your ITAB to the memory. 
    EXPORT ITAB TO MEMORY ID 'TD' (ID is the name of memory, you don't need to create it ). 
3. In program BBB you have to declare The same table (same table's name and same fields). 
4. In BBB you can import ITAB : 
    IMPORT ITAB FROM MEMORY ID 'TD' 
5. Now you can export it to AAA after modifications. 
    EXPORT ITAB TO MEMORY ID 'TD'
6. In AAA : 
    IMPORT ITAB FROM MEMORY ID 'TD'
This solution is independant to SUBMIT. 
 
Best regards,
SAP Basis, ABAP Programming and Other IMG Stuff
http://www.sap-img.com/ab020.htm