ITPub博客

首页 > IT基础架构 > 网络安全 > 批导入Internet Service程序

批导入Internet Service程序

原创 网络安全 作者:jiang2008 时间:2007-03-07 12:56:02 0 删除 编辑
批导入Internet Service程序[@more@]

关键词批导入 Service

*&---------------------------------------------------------------------*
*& Report ZSCIF
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZSCIF.
DATA:BEGIN OF F1 OCCURS 0,
SERVICE(30),
TEXT(32),
TXT(32),
END OF F1.

DATA:BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
DATA:MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.

DATA:LIN TYPE I.
DATA:T_TEXT TYPE ICF_DOCU70.

SELECTION-SCREEN BEGIN OF BLOCK BLK WITH FRAME TITLE TEXT-001.
PARAMETERS:P_TYPE TYPE ICF_DYNPTYPE OBLIGATORY DEFAULT 'SERVICE',"层次结构类型
P_HOST TYPE ICF_HOST OBLIGATORY DEFAULT 'DEFAULT_HOST',"虚拟主机
P_URL TYPE ICFREQUEST_PATH OBLIGATORY VISIBLE LENGTH 60
DEFAULT '/sap/bc/gui/sap/its/'. "服务路径
SELECTION-SCREEN END OF BLOCK BLK.

SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-002.
PARAMETERS:P_FILE LIKE RLGRAP-FILENAME OBLIGATORY.
PARAMETERS:P_ROW TYPE I DEFAULT 2.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(8) TEXT-700 FOR FIELD P_MODE.
PARAMETERS:P_MODE TYPE C DEFAULT 'E'.
SELECTION-SCREEN COMMENT 13(60) TEXT-701 FOR FIELD P_MODE.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK BLK1.


SELECTION-SCREEN BEGIN OF BLOCK BLK2 WITH FRAME TITLE TEXT-003.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(6) TEXT-800 FOR FIELD PIAC1.
PARAMETERS:PIAC1 LIKE IAC_PARAMETER-NAME VISIBLE LENGTH 20
DEFAULT '~TRANSACTION'.
SELECTION-SCREEN COMMENT 30(4) TEXT-801 FOR FIELD PVAL1.
PARAMETERS:PVAL1 LIKE IAC_PARAMETER-VALUE VISIBLE LENGTH 15.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(6) TEXT-802 FOR FIELD PIAC2.
PARAMETERS:PIAC2 LIKE IAC_PARAMETER-NAME VISIBLE LENGTH 20
DEFAULT '~GENERATEDYNPRO'.
SELECTION-SCREEN COMMENT 30(4) TEXT-803 FOR FIELD PVAL2.
PARAMETERS:PVAL2 LIKE IAC_PARAMETER-VALUE VISIBLE LENGTH 15
DEFAULT '1'.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(6) TEXT-804 FOR FIELD PIAC3.
PARAMETERS:PIAC3 LIKE IAC_PARAMETER-NAME VISIBLE LENGTH 20
DEFAULT '~NOHEADEROKCODE'.
SELECTION-SCREEN COMMENT 30(4) TEXT-805 FOR FIELD PVAL3.
PARAMETERS:PVAL3 LIKE IAC_PARAMETER-VALUE VISIBLE LENGTH 15
DEFAULT '1'.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK BLK2.

SELECTION-SCREEN BEGIN OF BLOCK BLK3 WITH FRAME TITLE TEXT-004.
PARAMETERS:P_DEV LIKE KO007-L_DEVCLASS DEFAULT 'ZR01',
P_REQ LIKE KO008-TRKORR DEFAULT ' '.
SELECTION-SCREEN END OF BLOCK BLK3.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
* DEF_FILENAME = ' .xls'
DEF_PATH = 'C:'
MASK = ',*.xls,*.XLS.'
MODE = 'O'
TITLE = '选择上传文件'
IMPORTING
FILENAME = P_FILE
EXCEPTIONS
INV_WINSYS = 1
NO_BATCH &bsp; = 2
SELECTION_CANCEL = 3
SELECTION_ERROR = 4
OTHERS = 5.

INITIALIZATION.

TOP-OF-PAGE.

END-OF-PAGE.

START-OF-SELECTION.
PERFORM MAIN.

END-OF-SELECTION.

*&---------------------------------------------------------------------*
*& Form MAIN
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM MAIN.
PERFORM UPLOAD_DATA USING P_FILE.
PERFORM BDC_PROCESS.
ENDFORM. "MAIN

*&---------------------------------------------------------------------*
*& Form UPLOAD_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->FILE text
*----------------------------------------------------------------------*
FORM UPLOAD_DATA USING FILE LIKE RLGRAP-FILENAME.
*声明变量
DATA:LV_INDEX TYPE I.
*常量声明
CONSTANTS:
LC_START_COL TYPE I VALUE '1',
* LC_START_ROW TYPE I VALUE '2',
LC_END_COL TYPE I VALUE '256',
LC_END_ROW TYPE I VALUE '65536'.

DATA:LC_START_ROW TYPE I.

FIELD-SYMBOLS: .
*内表声明
DATA:ITAB TYPE KCDE_CELLS OCCURS 0 WITH HEADER LINE.

CLEAR ITAB.
REFRESH ITAB.

LC_START_ROW = P_ROW.
CALL FUNCTION'KCD_EXCEL_OLE_TO_INT_CONVERT'
EXPORTING
FILENAME = P_FILE
I_BEGIN_COL = LC_START_COL
I_BEGIN_ROW = LC_START_ROW
I_END_COL = LC_END_COL
I_END_ROW = LC_END_ROW

TABLES
INTERN = ITAB
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2.


IF NOT SY-SUBRC IS INITIAL.
MESSAGE E002(FB).
ENDIF.

CHECK NOT ITAB[] IS INITIAL.

SORT ITAB BY ROW COL.

*将EXCEL中数据写入内表中
LOOP AT ITAB.
MOVE:ITAB-COL TO LV_INDEX.
ASSIGN COMPONENT LV_INDEX OF STRUCTURE F1 TO .
MOVE:ITAB-VALUE TO .

AT END OF ROW.
APPEND F1.
CLEAR F1.
ENdAT.
ENDLOOP.
DESCRIBE TABLE F1 LINES LIN.
IF LIN = 0.
MESSAGE I001(00) WITH '没有上载数据'.
STOP.
ENDIF.
ENDFORM. "UPLOAD_DATA

*&---------------------------------------------------------------------*
*& Form BDC_PROCESS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM BDC_PROCESS.
CLEAR:MESSTAB.
REFRESH:MESSTAB.
LOOP AT F1.
CLEAR T_TEXT.
CONCATENATE F1-TXT '->' F1-TEXT INTO T_TEXT.
REFRESH BDCDATA.
PVAL1 = F1-SERVICE.
PERFORM BDC.
CALL TRANSACTION 'SICF' USING BDCDATA MODE 'E'
MESSAGES INTO MESSTAB.
ENDLOOP.
ENDFORM. "BDC_PROCESS

*&---------------------------------------------------------------------*
*& Form BDC
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM BDC.
perform bdc_dynpro using 'RSICFTREE' '1000'.
perform bdc_field using 'BDC_CURSOR'
'ICF_URL'.
perform bdc_field using 'BDC_OKCODE'
'=ONLI'.
perform bdc_field using 'ICF_TYPE-LOW'
P_TYPE.
perform bdc_field using 'ICF_HOST'
P_HOST.
perform bdc_field using 'ICF_URL'
P_URL.
perform bdc_field using 'PA_LANGU'
'ZH'.
perform bdc_dynpro using 'RSICFTREE' '0100'.
perform bdc_field using 'BDC_OKCODE'
'=ADDSON'.
perform bdc_field using 'ICF_HOST'
P_HOST.
perform bdc_field using 'ICF_URL'
P_URL.
perform bdc_field using 'PA_LANGU'
&nsp; 'ZH'.
perform bdc_dynpro using 'SAPMSSY0' '0120'.
perform bdc_field using 'BDC_OKCODE'
'=DBAC'.
perform bdc_dynpro using 'RSICFTREE' '0200'.
perform bdc_field using 'BDC_CURSOR'
'IO_ICFOUT-ORIG_NAME'.
perform bdc_field using 'BDC_OKCODE'
'=ENTER'.
perform bdc_field using 'IO_ICFOUT-ORIG_NAME'
F1-SERVICE.
perform bdc_field using 'IO_SERVICEFLAG'
'X'.
perform bdc_dynpro using 'RSICFTREE' '0201'.
perform bdc_field using 'BDC_OKCODE'
'=ITSCUS'.
perform bdc_field using 'IO_ICFDOCU-ICF_LANGU'
'ZH'.
perform bdc_field using 'IO_DOCU1'
T_TEXT.
perform bdc_field using 'BDC_CURSOR'
'IO_ICFOUT-ICFGUILNK'.
*perform bdc_field using 'IO_ICFOUT-ICF_TIME'
* record-ICF_TIME_012.
perform bdc_field using 'IO_ICFOUT-ICFGUILNK'
'Y'.
perform bdc_dynpro using 'SAPLSITS_SERVICE_PARAMETER' '0100'.
perform bdc_field using 'BDC_OKCODE'
'=SAVE'.
perform bdc_field using 'BDC_CURSOR'
'IAC_PARAMETER-VALUE(03)'.
perform bdc_field using 'IAC_PARAMETER-NAME(01)'
PIAC1.
perform bdc_field using 'IAC_PARAMETER-NAME(02)'
PIAC2.
perform bdc_field using 'IAC_PARAMETER-NAME(03)'
PIAC3.
perform bdc_field using 'IAC_PARAMETER-VALUE(01)'
PVAL1.
perform bdc_field using 'IAC_PARAMETER-VALUE(02)'
PVAL2.
perform bdc_field using 'IAC_PARAMETER-VALUE(03)'
PVAL3.
perform bdc_dynpro using 'RSICFTREE' '0201'.
perform bdc_field using 'BDC_OKCODE'
'=HANDLER'.
perform bdc_field using 'IO_ICFDOCU-ICF_LANGU'
'ZH'.
perform bdc_field using 'IO_DOCU1'
T_TEXT.
perform bdc_field using 'BDC_CURSOR'
'IO_ICFOUT-NOHEREDITY'.
*perform bdc_field using 'IO_ICFOUT-ICF_TIME'
* record-ICF_TIME_022.
perform bdc_field using 'IO_ICFOUT-ICFGUILNK'
'Y'.
perform bdc_dynpro using 'RSICFTREE' '0201'.
perform bdc_field using 'BDC_OKCODE'
'=SAVE'.
perform bdc_field&bsp; using 'IO_ICFDOCU-ICF_LANGU'
'ZH'.
perform bdc_field using 'IO_DOCU1'
T_TEXT.
perform bdc_field using 'BDC_CURSOR'
'GT_HAND_CTRL-ICFHANDLER(01)'.
perform bdc_field using 'GT_HAND_CTRL-ICFHANDLER(01)'
'CL_HTTP_EXT_ITS'.
perform bdc_dynpro using 'SAPLSTRD' '0100'.
perform bdc_field using 'BDC_CURSOR'
'KO007-L_DEVCLASS'.
perform bdc_field using 'BDC_OKCODE'
'=ADD'.
perform bdc_field using 'KO007-L_DEVCLASS'
P_DEV.
perform bdc_field using 'KO007-L_AUTHOR'
SY-UNAME.
perform bdc_dynpro using 'SAPLSTRD' '0300'.
perform bdc_field using 'BDC_CURSOR'
'KO008-TRKORR'.
perform bdc_field using 'BDC_OKCODE'
'=LOCK'.
perform bdc_field using 'KO008-TRKORR'
P_REQ.
ENDFORM. "BDC
*&---------------------------------------------------------------------*
*& Form BDC_DYNPRO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PROGRAM text
* -->DYNPRO text
*----------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR BDCDATA.
BDCDATA-PROGRAM = PROGRAM.
BDCDATA-DYNPRO = DYNPRO.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA.
ENDFORM. "BDC_DYNPRO

*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
CLEAR BDCDATA.
BDCDATA-FNAM = FNAM.
BDCDATA-FVAL = FVAL.
APPEND BDCDATA.
ENDFORM. "BDC_FIELD

*&---------------------------------------------------------------------*
*& Form BDC_TRANSACTION
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->TCODE text
*----------------------------------------------------------------------*
FORM BDC_TRANSACTION USING TCODE.
DATA: L_MSTRING(480).
DATA: L_SUBRC LIKE SY-SUBRC.
* batch input session

REFRESH MESSTAB.
CALL TRANSACTION TCODE USING BDCDATA
MODE 'A'
* UPDATE CUPDATE
MESSAGES INTO MESSTAB.
*
REFRESH BDCDATA.
ENDFORM. "BDC_TRANSACTION

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/581999/viewspace-903198/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
  • 博文量
    171
  • 访问量
    2895740