*----------------------------------------------------------------------* * DECLARATIONS * *----------------------------------------------------------------------* TYPES: BEGIN OF kcde_intern_struc. INCLUDE STRUCTURE kcde_cells. TYPES: END OF kcde_intern_struc. TYPES: kcde_intern TYPE kcde_intern_struc OCCURS 0. DATA: gt_input TYPE kcde_intern, gs_input LIKE LINE OF gt_input, gv_username LIKE bapibname-bapibname, gs_pwd TYPE bapipwd, gs_pwdx TYPE bapipwdx, gt_return TYPE bapiret2 OCCURS 0, gs_return LIKE LINE OF gt_return. *----------------------------------------------------------------------* * LAYOUT * *----------------------------------------------------------------------* SELECTION-SCREEN: BEGIN OF LINE, COMMENT (30) TEXT-001,"File TXT separato da TAB END OF LINE. SELECTION-SCREEN: BEGIN OF LINE, COMMENT (30) TEXT-002,"File CSV separato da ";" END OF LINE. PARAMETERS: pa_flcl TYPE localfile. *----------------------------------------------------------------------* * EVENTS * *----------------------------------------------------------------------* AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_flcl. DATA: lt_filetab TYPE filetable, ls_file TYPE localfile, lv_rc TYPE i. cl_gui_frontend_services=>file_open_dialog( EXPORTING window_title = 'Apri file' default_filename = '*.csv;*.txt' initial_directory = 'C:\' multiselection = ' ' CHANGING file_table = lt_filetab rc = lv_rc ). READ TABLE lt_filetab INTO ls_file INDEX 1. pa_flcl = ls_file. *----------------------------------------------------------------------* * PROGRAM BODY * *----------------------------------------------------------------------* START-OF-SELECTION. CALL FUNCTION 'KCD_CSV_FILE_TO_INTERN_CONVERT' EXPORTING i_filename = pa_flcl i_separator = ';' TABLES e_intern = gt_input EXCEPTIONS upload_csv = 1 upload_filetype = 2 OTHERS = 3. gs_pwdx-bapipwd = 'X'. LOOP AT gt_input INTO gs_input. CASE gs_input-col. WHEN 1. gv_username = gs_input-value. WHEN 2. gs_pwd-bapipwd = gs_input-value. CALL FUNCTION 'BAPI_USER_CHANGE' EXPORTING username = gv_username password = gs_pwd passwordx = gs_pwdx TABLES return = gt_return. LOOP AT gt_return INTO gs_return WHERE type = 'E'. WRITE / gs_return-message. ENDLOOP. CLEAR gt_return[]. ENDCASE. ENDLOOP. END-OF-SELECTION. EXIT. *----------------------------------------------------------------------*
mercoledì 22 marzo 2017
Modifica massiva degli utenti
Iscriviti a:
Commenti sul post (Atom)
Nessun commento:
Posta un commento