How to catching selection criteria
Example:
DATA: selection_table LIKE rsparams OCCURS 0 WITH HEADER LINE. CLEAR selection_table. REFRESH selection_table. * Get selection criteria CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'
DATA: selection_table LIKE rsparams OCCURS 0 WITH HEADER LINE. CLEAR selection_table. REFRESH selection_table. * Get selection criteria CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'
FORM screen_clearing_all . DATA: selctab LIKE rsscr OCCURS 20 WITH HEADER LINE, itabname TYPE c LENGTH 30. FIELD-SYMBOLS: <para> TYPE ANY, <sele> TYPE ANY TABLE. CLEAR selctab. REFRESH selctab. * Get selection screen
MATNR DATAB APPOINTFEE ---------------------------------------- MA12345 2008/12/01 500 MA12345 2009/12/01 1,000 MA12345 2009/12/15 2,000
SELECT SINGLE APPOINTFEE INTO GT_ITAB-APPOINTFEE FROM ZSD001 WHERE MATNR = 'MA12345' AND DATAB = ( SELECT MAX( DATAB ) FROM ZSD001 WHERE MATNR EQ 'MA12345' AND DATAB LE '20091202' ). * GT_ITAB-APPOINTFEE == 1,000
SELECT OBJNR FROM JSTO AS A APPENDING CORRESPONDING FIELDS OF TABLE ONR_TAB WHERE A~OBJNR LIKE SDCON-OBJNR_VB AND A~OBJNR IN R_S_OBJNR AND A~OBTYP EQ SDCON-HEADER AND A~STSMA NE STSMA_INI AND EXISTS ( SELECT OBJNR FROM JEST WHERE OBJNR EQ A~OBJNR AND STAT LIKE 'E%' AND INACT EQ SPACE ) ORDER BY OBJNR.
DATA: client LIKE sy-mandt,
user LIKE sy-uname,
message LIKE sm04dic-popupmsg
CALL FUNCTION 'TH_POPUP'
EXPORTING
client = client
user = user
message = message
* BAPI Define
DATA: gw_so_header LIKE bapisdhd1,
gw_so_headerx LIKE bapisdhd1x,
gw_so_logic_switch LIKE bapisdls,
gv_so_doc_in TYPE bapivbeln-vbeln,
gv_so_doc_num TYPE bapivbeln-vbeln,
gt_so_return2 TYPE bapiret2,
gt_so_partners TYPE bapiparnr OCCURS 0 WITH HEADER LINE,
gt_so_items_in TYPE bapisditm OCCURS 0 WITH HEADER LINE,
gt_so_items_inx TYPE bapisditmx OCCURS 0 WITH HEADER LINE,
gt_so_return1 TYPE bapiret2 OCCURS 0 WITH HEADER LINE,
gt_so_conditions_in TYPE bapicond OCCURS 0 WITH HEADER LINE,
gt_so_conditions_inx TYPE bapicondx OCCURS 0 WITH HEADER LINE.
DATA BEGIN OF ITLINE OCCURS 0. INCLUDE STRUCTURE TLINE. DATA END OF ITLINE. DATA G_VGBEL LIKE THEAD-TDNAME. G_VGBEL = VBAK-VBELN. CALL FUNCTION 'READ_TEXT' EXPORTING ID = '0001' LANGUAGE = 'M' NAME = G_VGBEL OBJECT = 'VBBK' TABLES LINES = ITLINE EXCEPTIONS ID = 1 OTHERS = 2.
DATA BEGIN OF ITLINE OCCURS 0. INCLUDE STRUCTURE TLINE. DATA END OF ITLINE. DATA G_VGBEL LIKE THEAD-TDNAME. CONCATENATE VBAP-VBELN VBAP-POSNR G_VGBEL. CALL FUNCTION 'READ_TEXT' EXPORTING ID = '0001' LANGUAGE = 'M' NAME = G_VGBEL OBJECT = 'VBBP' TABLES LINES = ITLINE EXCEPTIONS ID = 1 OTHERS = 2.
IF GT_ITAB-VRKME EQ GT_ITAB-KMEIN OR GT_ITAB-KMEIN EQ SPACE. LV_LFIMG = GT_ITAB-LFIMG. ELSE. CALL FUNCTION 'MATERIAL_UNIT_CONVERSION' EXPORTING INPUT = GT_ITAB-LFIMG KZMEINH = 'X' MATNR = GT_ITAB-MATNR MEINH = GT_ITAB-VRKME MEINS = GT_ITAB-KMEIN TYPE_UMR = '3' IMPORTING OUTPUT = LV_LFIMG. ENDIF.
CALL FUNCTION 'ENQUEUE_E_TRDIR' EXPORTING name = 'PROGRAM_RUNNING' _scope = '1' EXCEPTIONS foreign_lock = 1 system_failure = 2 OTHERS = 3. IF sy-subrc <> 0. CALL FUNCTION 'DEQUEUE_ALL'. MESSAGE e000(zsd01) WITH 'Err: Program running!'. ENDIF.
CALL FUNCTION 'DEQUEUE_ALL'.
TYPE-POOLS: ole2.
* OLE objects Declarations
DATA: w_excel TYPE ole2_object,
w_workbooks TYPE ole2_object,
w_workbook TYPE ole2_object,
w_worksheets TYPE ole2_object,
w_worksheet TYPE ole2_object,
w_columns TYPE ole2_object,
w_column_ent TYPE ole2_object,
w_cell TYPE ole2_object,
w_int TYPE ole2_object,
w_range TYPE ole2_object,
w_font TYPE ole2_object,
w_window TYPE ole2_object.
* =========== ===========
* High Byte Low Byte
* =========== ===========
* 0xA1-0xF9 0x40-0x7E
* or
* 0xA1-0xFE
* =========== ===========
*&---------------------------------------------------------------------* *& Form data_export *&---------------------------------------------------------------------* * 資料匯出至 Excel *----------------------------------------------------------------------* FORM DATA_EXPORT . DATA: XMPL_HEADER LIKE GXXLT_P-TEXT VALUE '交貨明細表'. DATA BEGIN OF XMPLT_O OCCURS 1. INCLUDE STRUCTURE GXXLT_O. DATA END OF XMPLT_O. DATA BEGIN OF XMPLT_P OCCURS 1. INCLUDE STRUCTURE GXXLT_P. DATA END OF XMPLT_P. DATA BEGIN OF XMPLT_V OCCURS 1. INCLUDE STRUCTURE GXXLT_V. DATA END OF XMPLT_V. DATA: BEGIN OF XMPLT_D OCCURS 60, VBELN LIKE LIPS-VBELN, POSNR LIKE LIPS-POSNR, KUNNR LIKE LIKP-KUNNR, NAME1 LIKE KNA1-NAME1, NAME1_SH LIKE KNA1-NAME1, MATNR LIKE LIPS-MATNR, VGBEL LIKE LIPS-VGBEL, KDMAT LIKE LIPS-KDMAT, LFIMG LIKE LIPS-LFIMG, VRKME LIKE LIPS-VRKME, LFDAT LIKE LIKP-LFDAT, END OF XMPLT_D. * 標題列 CLEAR XMPLT_V. XMPLT_V-COL_NO = XMPLT_V-COL_NO + 1. XMPLT_V-COL_NAME = '交貨'. APPEND XMPLT_V. XMPLT_V-COL_NO = XMPLT_V-COL_NO + 1. XMPLT_V-COL_NAME = '項目'. APPEND XMPLT_V. XMPLT_V-COL_NO = XMPLT_V-COL_NO + 1. XMPLT_V-COL_NAME = '收貨人'. APPEND XMPLT_V. XMPLT_V-COL_NO = XMPLT_V-COL_NO + 1. XMPLT_V-COL_NAME = '客戶名稱'. APPEND XMPLT_V. XMPLT_V-COL_NO = XMPLT_V-COL_NO + 1. XMPLT_V-COL_NAME = '出貨對象名稱'. APPEND XMPLT_V. XMPLT_V-COL_NO = XMPLT_V-COL_NO + 1. XMPLT_V-COL_NAME = '物料'. APPEND XMPLT_V. XMPLT_V-COL_NO = XMPLT_V-COL_NO + 1. XMPLT_V-COL_NAME = '採購文件'. APPEND XMPLT_V. XMPLT_V-COL_NO = XMPLT_V-COL_NO + 1. XMPLT_V-COL_NAME = '客戶物料號碼'. APPEND XMPLT_V. XMPLT_V-COL_NO = XMPLT_V-COL_NO + 1. XMPLT_V-COL_NAME = '交貨數量'. APPEND XMPLT_V. XMPLT_V-COL_NO = XMPLT_V-COL_NO + 1. XMPLT_V-COL_NAME = 'SU'. APPEND XMPLT_V. XMPLT_V-COL_NO = XMPLT_V-COL_NO + 1. XMPLT_V-COL_NAME = '發貨日期'. APPEND XMPLT_V. * 資料轉移 LOOP AT GT_ITAB. MOVE-CORRESPONDING GT_ITAB TO XMPLT_D. APPEND XMPLT_D. ENDLOOP. SORT XMPLT_D BY VBELN POSNR. * CALL FUNCTION 'XXL_SIMPLE_API' EXPORTING N_KEY_COLS = 4 FILENAME = 'XMPL0002' HEADER = XMPL_HEADER TABLES DATA = XMPLT_D ONLINE_TEXT = XMPLT_O PRINT_TEXT = XMPLT_P COL_TEXT = XMPLT_V. ENDFORM. " data_export
CALL FUNCTION 'XXL_FULL_API' EXPORTING N_VRT_KEYS = 3 " Of the 9 columns in the list N_ATT_COLS = 6 " \ object, 3 are key columns N_HRZ_KEYS = 3 " Header above the non-key-columns " \ forms a three-level-hierarchy DATA_STARTING_AT = 5 " Only 50 rows out of 60 are DATA_ENDING_AT = 54 " \ really exported FILENAME = 'XMPL0001' HEADER_1 = XMPL_HEADER1 HEADER_2 = XMPL_HEADER2 SEMA_TYPE = 'X' " C-Columns are converted if SEMA " \ definitions require this NO_DIALOG = SPACE " XXL itself prompts for FILENAME TABLES VKEY = XMPLT_V HKEY = XMPLT_H DATA = XMPLT_D SEMA = XMPLT_S ONLINE_TEXT = XMPLT_O PRINT_TEXT = XMPLT_P EXCEPTIONS FILE_OPEN_ERROR = 71 FILE_WRITE_ERROR = 72 INV_WINSYS = 73 INV_XXL = 74 CANCELLED_BY_USER = 75 OTHERS = 99.
CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT' CHANGING VALUE = var_char
TABLES: tvfk. RANGES: gr_fkart FOR vbrk-fkart.
* ------------- * Define Macro * ------------- DEFINE put_ranges. &1-sign = &2. &1-option = &3. &1-low = &4. &1-high = &5. APPEND &1. END-OF-DEFINITION.
DEFINE put_ranges. FIELD-SYMBOLS <PT> LIKE &1. ASSIGN &1 TO <PT>. <PT>-sign = &2. <PT>-option = &3. <PT>-low = &4. <PT>-high = &5. APPEND <PT> TO &1. END-OF-DEFINITION.
SELECT fkarts INTO tvfk-fkarts FROM tvfk WHERE kappl = 'V3'. put_ranges gr_fkart 'E' 'EQ' tvfk-fkarts ''. ENDSELECT.
TABLE CDHDR/CDPOS OBJECTCLAS = DEBI OBJECTID = <Customer number> TCODE = VD05
SWECDOBTYP 指派更改文件 / 工作流程物件類型 TCDOB 變更文件建立的物件
*"---------------------------------------------------------------------- *"*"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 *"----------------------------------------------------------------------
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.
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.
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.