CL_GUI_FRONTEND_SERVICES= GET_DESKTOP_DIRECTORY
Hi,
did you ever get a result other than space?
Regards,
Clemens
hmm .. That's weird
I just called
CALL METHOD CL_GUI_CFW=>UPDATE_VIEW
EXPORTING
CALLED_BY_SYSTEM =
EXCEPTIONS
CNTL_SYSTEM_ERROR = 1
CNTL_ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
After the GET_DESKTOP method and it worked.
Regards,
Ravi
Similar Messages
-
How to print the file name in sap
Hi All,
I have requirment like,
there is a folder in my local system, inside that folder there are 10 Excel file like file1.xls,file2.xls..............file10.xls
how to print the file name of all these file in SAp like
file1.xls
file2.xls
file3.xls
file4.xls
file10.xls
Appropriate points will be rewarded.
Thanks in Advance
Arun kumarHi,
Still you are facing any problem with this code expalin the problem with details , otherwise close this thread.
Use Method <b>cl_gui_frontend_services=>directory_list_files</b> to read file names for a given directory
after reading the files then Use FM : <b>RSPO_SX_OUTPUT_TEXTDATA</b> to create spool from internal table data and print the data.
<b>sample code :</b>
data: desktop_dir type string.
data: ifiles type table of string.
data: xfiles type string.
data: count type i.
data: filepath type string.
call method cl_gui_frontend_services=>get_desktop_directory
changing
desktop_directory = desktop_dir .
call method cl_gui_cfw=>flush.
call method cl_gui_frontend_services=>directory_list_files
exporting
directory = desktop_dir
* filter = '*.xls'
files_only = 'X'
* DIRECTORIES_ONLY =
changing
file_table = ifiles
count = count.
DATA : x_name LIKE tsp03d-name,
x_dest LIKE tsp03d-padest VALUE 'LOCL',
x_rows LIKE sxpcklsti1-body_num VALUE 0,
x_startrow LIKE sxpcklsti1-body_start VALUE 1,
x_pages LIKE rspotype-pages VALUE 1,
x_pages_1 TYPE p DECIMALS 2,
x_rqtitle LIKE sxpcklsti1-obj_descr,
x_rqcopies TYPE i VALUE 1,
x_rqowner LIKE trdyse01cm-username,
x_immediate LIKE pri_params-primm VALUE ' ',
x_rqid LIKE tsp01-rqident,
i_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
x_pages = 1.
x_rqowner = sy-uname.
x_dest = 'LOCL'.
x_startrow = 1.
x_rqcopies = 1.
x_immediate = 'X' .
CALL FUNCTION 'RSPO_SX_OUTPUT_TEXTDATA'
EXPORTING
* name = x_name
dest = x_dest
rows = x_rows
startrow = x_startrow
pages = x_pages
rqtitle = x_rqtitle
rqcopies = x_rqcopies
rqowner = x_rqowner
immediately = x_immediate
IMPORTING
rqid = x_rqid
TABLES
text_data = i_contents
EXCEPTIONS
name_missing = 1
name_twice = 2
not_found = 3
illegal_layout = 4
internal_error = 5
size_mismatch = 6
OTHERS = 7.
IF sy-subrc <> 0.
** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
** WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Regards
Appana
*Reward Points for helpful answers
Message was edited by: L Appana -
hi friends,
I need to Download three files , one at a time using GUI_DOWNLOAD .
in the perform i wrote like
perform download using int_tab1 .
for this in the form i will write like
form download using int_tab1 type tfl_tab1 " (type for int_tab1).
so in the GUI_DOWNLOAD i can use int_tab1.
according to my requirement i have three radiobutton . if they click one radio button i will call one perform as i wrote before to download one file.
i need to know can i use only one GUI_DOWNLOAD to download three files each one each three different internal tables in GUI_DOWNLOAD using three different perform but only one
GUI_DOWNLOAD.Hi,
here a short example to have one download-forms which will
be calle with different parameters.
DATA: DATEI_PC TYPE STRING.
DATA: IMARA TYPE TABLE OF MARA.
DATA: ILFA1 TYPE TABLE OF LFA1.
DATA: DO(1) VALUE 'M'.
SELECT * FROM MARA INTO TABLE IMARA UP TO 10 ROWS.
SELECT * FROM LFA1 INTO TABLE ILFA1 UP TO 20 ROWS.
Here the download be called on ciditions.
IF DO = 'M'.
PERFORM DOWNLOAD TABLES IMARA[] USING 'MARA.TXT'.
ELSE.
PERFORM DOWNLOAD TABLES ILFA1[] USING 'LFA1.TXT'.
ENDIF.
FORM DOWNLOAD TABLES ITAB USING FILE.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GET_DESKTOP_DIRECTORY
CHANGING
DESKTOP_DIRECTORY = DATEI_PC.
CALL METHOD CL_GUI_CFW=>FLUSH.
CONCATENATE DATEI_PC FILE INTO DATEI_PC.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
EXPORTING
FILENAME = DATEI_PC
FILETYPE = 'ASC'
CHANGING
DATA_TAB = ITAB[].
ENDFORM. "download
Hope it helps.
regards, Dieter
Message was edited by:
Dieter Gröhn -
HI
I have created an ALV report with 87 fields in it. Whenever I am trying to download that report into excel the number of column breaks into 2 rows. In this case, The downloaded file contains 57 Columns in 1 row and remaining 29 Columns in second row. Can anyone please help me in understanding why this is happening while downloading this report into excel file and what will be the solution to correct it.
Thanks,
Sreekanth.GTry this,
HEADING FOR EXCEL SHEET
DATA: BEGIN OF IT_EXCEL1 OCCURS 0,
SAPID LIKE PERNR-PERNR,
UNAME LIKE SY-UNAME,
END OF IT_EXCEL1.
assigning column names in excel sheet
IT_EXCEL1-SAPID = 'Personnel number'.
IT_EXCEL1-UNAME = 'User Name'.
APPEND IT_EXCEL1.
to get desktop path
DATA : DESKTOP TYPE STRING.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GET_DESKTOP_DIRECTORY
CHANGING
DESKTOP_DIRECTORY = DESKTOP
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
NOT_SUPPORTED_BY_GUI = 3
OTHERS = 4.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD CL_GUI_CFW=>FLUSH
EXCEPTIONS
CNTL_SYSTEM_ERROR = 1
CNTL_ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CONCATENATE DESKTOP '\filename.xls' INTO DESKTOP.
to download into excel sheet
FOR TITLES
CALL FUNCTION 'GUI_DOWNLOAD' " for titles
EXPORTING
BIN_FILESIZE =
FILENAME = DESKTOP
FILETYPE = 'ASC'
WRITE_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = IT_EXCEL1.
FOR DATA
CALL FUNCTION 'GUI_DOWNLOAD' " for data
EXPORTING
FILENAME = DESKTOP
FILETYPE = 'ASC'
APPEND = 'X'
WRITE_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = IT_DOWNLOAD.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>EXECUTE
EXPORTING
DOCUMENT = DESKTOP
APPLICATION =
PARAMETER =
DEFAULT_DIRECTORY =
MAXIMIZED =
MINIMIZED =
SYNCHRONOUS =
OPERATION = 'OPEN'
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
BAD_PARAMETER = 3
FILE_NOT_FOUND = 4
PATH_NOT_FOUND = 5
FILE_EXTENSION_UNKNOWN = 6
ERROR_EXECUTE_FAILED = 7
SYNCHRONOUS_FAILED = 8
NOT_SUPPORTED_BY_GUI = 9
OTHERS = 10
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF. -
Filter in the Dialog box for selection
I have report that contains a file selection dialog using the following code
at selection-screen on value-request for p_file.
perform f_get_file using cl_gui_frontend_services=>filetype_excel.
form f_get_file using p_filetype type string.
data: lt_filetable type filetable,
ls_file type line of filetable,
lv_filename type string,
lv_path type string,
lv_fullname type string,
lv_title type string,
lv_desktop type string,
lv_rc type i,
lv_action type i.
call method cl_gui_frontend_services=>get_desktop_directory
changing
desktop_directory = lv_desktop
exceptions
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
others = 4.
if sy-subrc <> 0.
message e007(zspx) with 'Desktop not found'.
endif.
* Update View
call method cl_gui_cfw=>update_view
exceptions
cntl_system_error = 1
cntl_error = 2
others = 3.
lv_title = text-003.
call method cl_gui_frontend_services=>file_open_dialog
exporting
window_title = lv_title
file_filter = p_filetype
initial_directory = lv_desktop
changing
file_table = lt_filetable
rc = lv_rc
user_action = lv_action
exceptions
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
others = 4.
if sy-subrc = 0 and lv_action ne cl_gui_frontend_services=>action_cancel.
read table lt_filetable into ls_file index 1.
if sy-subrc = 0.
p_file = ls_file-filename.
else.
clear p_file.
endif.
else.
clear p_file.
endif.
endform. " f_get_file
Currently while opening the dialog for file selection its showing the desktop directory. But user can select file from any other directory.
My question is how to restrict this dialog box from which user can select only from desktop directory.
PS : Please don't suggest to validate the file after getting the file that its from desktop or not
a®Hi,
Like the bellow ?
Replace following code
if sy-subrc = 0 and lv_action ne cl_gui_frontend_services=>action_cancel.
read table lt_filetable into ls_file index 1.
if sy-subrc = 0.
p_file = ls_file-filename.
else.
clear p_file.
endif.
else.
clear p_file.
endif.
with the bellow
IF sy-subrc = 0 AND lv_action NE cl_gui_frontend_services=>action_cancel.
READ TABLE lt_filetable INTO ls_file INDEX 1.
IF sy-subrc = 0.
FIND FIRST OCCURRENCE OF lv_desktop IN ls_file-filename.
IF sy-subrc = 0.
p_file = ls_file-filename.
ELSE.
MESSAGE: 'Sorry! you can select file only from Desktop' TYPE 'I'.
PERFORM f_get_file USING cl_gui_frontend_services=>filetype_excel.
ENDIF.
ELSE.
CLEAR p_file.
ENDIF.
ELSE.
CLEAR p_file.
ENDIF.
Regards,
Faisal -
Hi all,
I am having two doubt .
1, i want to convert the classical report to PDF.I am using FM
CONVERT_ABAPSPOOLJOB_2_PDF.
The PDF file is coming correctly when the file is attached sent the mail .
using this FM SO_NEW_DOCUMENT_ATT_SEND_API1 the conveted PDF file is sent to mail it coming correctly.
this one secnario it is working fine .
But ,in other scenario i want to convting the same classical report to PDF and i want to save it in my loca system.
The PDF is converting ,but the file is not opening.
<b>How to convert the classical report to PDF file and downloaded to local system.</b>
2,How to submit the table maintenance view in program.Hi Raja,
try this:
REPORT Z_TEST.
DATA: BEGIN OF ITAB OCCURS 0,
TEXT(72),
END OF ITAB.
DATA: FILESIZE TYPE I.
DATA: PARAMS LIKE PRI_PARAMS,
VALID TYPE C.
DATA: SPOOL_NR LIKE TSP01-RQIDENT,
SPOOL_NR_DEL LIKE TSP01_SP0R-RQID_CHAR.
DATA: BEGIN OF PDF_OUTPUT OCCURS 0.
INCLUDE STRUCTURE TLINE.
DATA: END OF PDF_OUTPUT.
DATA: DATEI TYPE STRING.
START-OF-SELECTION.
Here the Report which you will convert
READ REPORT 'Z_TEST' INTO ITAB.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GET_DESKTOP_DIRECTORY
CHANGING
DESKTOP_DIRECTORY = DATEI.
CALL METHOD CL_GUI_CFW=>FLUSH.
CONCATENATE DATEI '\TEST.PDF' INTO DATEI.
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
DESTINATION = 'LOCA'
LINE_SIZE = 080
IMMEDIATELY = ' '
NO_DIALOG = 'X'
IMPORTING
OUT_PARAMETERS = PARAMS
VALID = VALID.
CHECK VALID <> SPACE.
NEW-PAGE PRINT ON PARAMETERS PARAMS NO DIALOG NO-TITLE NO-HEADING.
LOOP AT ITAB.
WRITE:/ ITAB.
ENDLOOP.
NEW-PAGE PRINT OFF.
SPOOL_NR = SY-SPONO.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = SPOOL_NR
IMPORTING
PDF_BYTECOUNT = FILESIZE
TABLES
PDF = PDF_OUTPUT.
SPOOL_NR_DEL = SPOOL_NR.
CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
EXPORTING
SPOOLID = SPOOL_NR_DEL.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
EXPORTING
BIN_FILESIZE = FILESIZE
FILENAME = DATEI
FILETYPE = 'BIN'
CHANGING
DATA_TAB = PDF_OUTPUT[].
CALL METHOD CL_GUI_FRONTEND_SERVICES=>EXECUTE
EXPORTING
DOCUMENT = DATEI.
END-OF-SELECTION.
Regards, Dieter -
How to change sy=uname value in selection screen?
Hi,
In selection screen i declared a default file path like this..
C:\Documents and Settings\User Name\Vendor\'.
when it displays the path in selection screen, I want to replace that user name with SY-UNAME FIELD.
Can any one let me know where i can change this..
Thanks for ur time.If you are trying to set the the folder for the "windows" user, you can try this instead.
I doubt that the SAP user id is always the same as the local user folder on the frontend.
report zrich_0001.
data: dir type string.
parameters: p_file type localfile.
initialization.
call method cl_gui_frontend_services=>get_desktop_directory
changing
desktop_directory = dir.
call method cl_gui_cfw=>flush.
translate dir to upper case.
replace 'DESKTOP' with 'Vendor' into dir.
p_file = dir.
Regards,
Rich Heilman -
Function module to get desktop path
Hi All,
Is there any function module to get the desktop path?
I have tried using CL_GUI_FRONTEND_SERVICES=>GET_DESKTOP_DIRECTORY, but it is not returning any value.
I can't hardcode "C:\Documents and Settings\<<<user-name>>>\Desktop" as some users have their desktop in "D:\Documents and Settings\<<<user-name>>>\Desktop".
Thanks in advance.
Regards,
Arun MohanHello
No problem:
data: str TYPE string.
CALL METHOD cl_gui_frontend_services=>GET_DESKTOP_DIRECTORY
changing
DESKTOP_DIRECTORY = str
EXCEPTIONS
cntl_error = 1.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD CL_GUI_CFW=>UPDATE_VIEW.
WRITE: str. -
Read multiple excel sheets using dataset...
Hello Experts,
I've searched the forums and I cannot find any suitable threads for regarding my question. Anyway, I wanto to read and .XLS file residing in the application server using the DATASET commands.However, I am having a shortdump saying "An exception with the type CX_SY_CONVERSION_CODEPAGE".Continue.......
IF iref_error->has_failed = 'X'.
CALL METHOD iref_error->raise_message
EXPORTING
type = 'I'.
LEAVE LIST-PROCESSING.
ENDIF.
CALL METHOD iref_document->release_document
* EXPORTING
* no_flush = ' '
IMPORTING
error = iref_error
* retcode =
IF iref_error->has_failed = 'X'.
CALL METHOD iref_error->raise_message
EXPORTING
type = 'I'.
LEAVE LIST-PROCESSING.
ENDIF.
*& Form SUB_FILE_F4
* F4 help for file path
FORM sub_file_f4 .
DATA:
l_desktop TYPE string,
l_i_files TYPE filetable,
l_wa_files TYPE file_table,
l_rcode TYPE int4.
* Finding desktop
CALL METHOD cl_gui_frontend_services=>get_desktop_directory
CHANGING
desktop_directory = l_desktop
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE e001(00) WITH
'Desktop not found'.
ENDIF.
* Update View
CALL METHOD cl_gui_cfw=>update_view
EXCEPTIONS
cntl_system_error = 1
cntl_error = 2
OTHERS = 3.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = 'Select Excel file'
default_extension = '.xls'
* default_filename =
file_filter = '.xls'
* with_encoding =
initial_directory = l_desktop
* multiselection =
CHANGING
file_table = l_i_files
rc = l_rcode
* user_action =
* file_encoding =
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 4
OTHERS = 5
IF sy-subrc <> 0.
MESSAGE e001(00) WITH 'Error while opening file'.
ENDIF.
READ TABLE l_i_files INDEX 1 INTO l_wa_files.
IF sy-subrc = 0.
p_file = l_wa_files-filename.
ELSE.
MESSAGE e001(00) WITH 'Error while opening file'.
ENDIF. -
BPC Mass User Management Tool error in BPC 10
Hello,
I've downloaded tranport files from How to use BPC Mass User Management Tool in Netweaver. But Transport import fails with RC12 without any shortdump. ABAP program ZUJE_MASS_USER_MGMT is not created.
Version used - BPC 10 CPMBPC 801 on Netweaver 7.4 .
Thanks in advance for your inputs.Tried changing transport options but no luck. Transport failed with status RC12 without creating ABAP program. However, Old version transport files imported with error. But I could not find METHOD check_bpc_component_is_valid.
Can anyone please send the updated program.
*& Report ZUJE_MASS_USER_MGMT
*& Created By: Rich Heilman SAP Labs, LLC
*& Created On: 08/2/2010
REPORT zuje_mass_user_mgmt.
TYPE-POOLS: abap, vrm.
* CLASS lcl_application DEFINITION
CLASS lcl_application DEFINITION FINAL.
PUBLIC SECTION.
CONSTANTS: lc_comma TYPE char01 VALUE ',',
lc_pipe TYPE char01 VALUE '|',
lc_tab TYPE char10 VALUE 'TAB'.
TYPES: BEGIN OF t_appldim,
appl_id TYPE uj_appl_id,
dimension TYPE uj_dim_name,
END OF t_appldim.
TYPES: BEGIN OF t_appldimmembers,
appl_id TYPE uj_appl_id,
dimension TYPE uj_dim_name,
member TYPE uj_dim_member,
END OF t_appldimmembers.
CLASS-METHODS: file_f4 RETURNING value(r_file) TYPE string,
directory_f4 RETURNING value(r_path) TYPE string,
get_initial_directory RETURNING value(r_path) TYPE string,
set_delimiter_listbox,
set_delimiter,
export_users_to_file,
import_users_from_file,
export_teams_to_file,
import_teams_from_file,
export_team_assign_to_file,
import_team_assign_from_file,
export_task_profiles_to_file,
import_task_profiles_from_file,
export_mem_profiles_to_file,
import_mem_profiles_from_file,
export_tap_assign_to_file,
import_tap_assign_from_file,
export_map_assign_to_file,
import_map_assign_from_file,
get_appset_data IMPORTING i_appset_id TYPE uj_appset_id
EXCEPTIONS appset_not_found .
PRIVATE SECTION.
CLASS-DATA: lv_appset_id TYPE uja_s_appset_info-appset_id.
CLASS-DATA: lv_delimiter TYPE string.
CLASS-DATA: ls_appset_info TYPE uja_s_appset_info.
CLASS-DATA: lt_appl_info TYPE uja_t_appl_info.
CLASS-DATA: lt_appl_dim TYPE TABLE OF t_appldim.
CLASS-DATA: lt_members TYPE TABLE OF t_appldimmembers.
CLASS-DATA: lt_teams_list TYPE uje_t_team.
CLASS-DATA: lt_users_list TYPE uje_t_user.
CLASS-DATA: lt_tprofs TYPE uje_t_api_profile_id.
CLASS-DATA: lt_mprofs TYPE uje_t_api_profile_id.
CLASS-DATA: lt_tasks TYPE uje_t_role_tskasg.
CLASS-DATA: lt_roles TYPE uje_t_role.
CLASS-DATA: lo_context TYPE REF TO if_uj_context.
CLASS-DATA: lt_alv_messages TYPE uj0_t_message.
CLASS-METHODS: set_global_context,
render_alv,
upload IMPORTING i_filepath TYPE any
RETURNING value(rt_strtab) TYPE stringtab,
download IMPORTING i_filepath TYPE any
it_datatab TYPE STANDARD TABLE,
user_is_valid IMPORTING i_user_id TYPE any
RETURNING value(r_boolean) TYPE abap_bool,
team_is_valid IMPORTING i_team_id TYPE any
RETURNING value(r_boolean) TYPE abap_bool,
tprofile_is_valid IMPORTING i_profile_id TYPE any
RETURNING value(r_boolean) TYPE abap_bool,
mprofile_is_valid IMPORTING i_profile_id TYPE any
RETURNING value(r_boolean) TYPE abap_bool,
role_is_valid IMPORTING i_role_id TYPE any
RETURNING value(r_boolean) TYPE abap_bool,
task_is_valid IMPORTING i_task_id TYPE any
RETURNING value(r_boolean) TYPE abap_bool.
ENDCLASS. "lcl_application DEFINITION
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: p_export RADIOBUTTON GROUP grp1 DEFAULT 'X' USER-COMMAND chk.
PARAMETERS: p_import RADIOBUTTON GROUP grp1.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETERS: p_appset TYPE uja_appset_info-appset_id.
PARAMETERS: p_file TYPE string LOWER CASE.
PARAMETERS: p_delmt TYPE char10 AS LISTBOX VISIBLE LENGTH 20
DEFAULT lcl_application=>lc_comma. "delimiter
SELECTION-SCREEN END OF BLOCK b2.
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-003.
PARAMETERS: p_eusers RADIOBUTTON GROUP grp2 MODIF ID exp.
PARAMETERS: p_eteams RADIOBUTTON GROUP grp2 MODIF ID exp.
PARAMETERS: p_eteama RADIOBUTTON GROUP grp2 MODIF ID exp.
PARAMETERS: p_etprof RADIOBUTTON GROUP grp2 MODIF ID exp.
PARAMETERS: p_emprof RADIOBUTTON GROUP grp2 MODIF ID exp.
PARAMETERS: p_etprfa RADIOBUTTON GROUP grp2 MODIF ID exp.
PARAMETERS: p_emprfa RADIOBUTTON GROUP grp2 MODIF ID exp.
SELECTION-SCREEN END OF BLOCK b3.
SELECTION-SCREEN BEGIN OF BLOCK b4 WITH FRAME TITLE text-004.
PARAMETERS: p_iusers RADIOBUTTON GROUP grp3 MODIF ID imp.
PARAMETERS: p_iteams RADIOBUTTON GROUP grp3 MODIF ID imp.
PARAMETERS: p_iteama RADIOBUTTON GROUP grp3 MODIF ID imp.
PARAMETERS: p_itprof RADIOBUTTON GROUP grp3 MODIF ID imp.
PARAMETERS: p_improf RADIOBUTTON GROUP grp3 MODIF ID imp.
PARAMETERS: p_itprfa RADIOBUTTON GROUP grp3 MODIF ID imp.
PARAMETERS: p_imprfa RADIOBUTTON GROUP grp3 MODIF ID imp.
SELECTION-SCREEN END OF BLOCK b4.
INITIALIZATION.
p_file = lcl_application=>get_initial_directory( ).
lcl_application=>set_delimiter_listbox( ).
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF p_export = abap_true AND screen-group1 = 'IMP'.
screen-active = '0'.
ENDIF.
IF p_import = abap_true AND screen-group1 = 'EXP'.
screen-active = '0'.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
AT SELECTION-SCREEN.
CASE abap_true.
WHEN p_export.
CLEAR: p_iusers, p_iteams, p_iteama, p_itprof,
p_improf, p_itprfa, p_imprfa.
WHEN p_import.
CLEAR: p_eusers, p_eteams, p_eteama, p_etprof,
p_emprof, p_etprfa, p_emprfa.
ENDCASE.
IF sy-ucomm <> 'CHK'.
IF p_appset IS INITIAL.
MESSAGE e001(00) WITH 'Please enter an AppSet Id'.
ENDIF.
IF p_file IS INITIAL.
MESSAGE e001(00) WITH 'Please enter a valid directory or file'.
ENDIF.
IF p_delmt IS INITIAL.
MESSAGE e001(00) WITH 'Please specify a delimiter'.
ENDIF.
ENDIF.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CASE abap_true.
WHEN p_export. p_file = lcl_application=>directory_f4( ).
WHEN p_import. p_file = lcl_application=>file_f4( ).
ENDCASE.
START-OF-SELECTION.
lcl_application=>set_delimiter( ).
lcl_application=>get_appset_data(
EXPORTING
i_appset_id = p_appset
EXCEPTIONS
appset_not_found = 1 ).
IF sy-subrc <> 0.
RETURN.
ENDIF.
CASE abap_true.
WHEN p_eusers. lcl_application=>export_users_to_file( ).
WHEN p_iusers. lcl_application=>import_users_from_file( ).
WHEN p_eteams. lcl_application=>export_teams_to_file( ).
WHEN p_iteams. lcl_application=>import_teams_from_file( ).
WHEN p_eteama. lcl_application=>export_team_assign_to_file( ).
WHEN p_iteama. lcl_application=>import_team_assign_from_file( ).
WHEN p_etprof. lcl_application=>export_task_profiles_to_file( ).
WHEN p_itprof. lcl_application=>import_task_profiles_from_file( ).
WHEN p_emprof. lcl_application=>export_mem_profiles_to_file( ).
WHEN p_improf. lcl_application=>import_mem_profiles_from_file( ).
WHEN p_etprfa. lcl_application=>export_tap_assign_to_file( ).
WHEN p_itprfa. lcl_application=>import_tap_assign_from_file( ).
WHEN p_emprfa. lcl_application=>export_map_assign_to_file( ).
WHEN p_imprfa. lcl_application=>import_map_assign_from_file( ).
ENDCASE.
* CLASS lcl_application IMPLEMENTATION
CLASS lcl_application IMPLEMENTATION.
METHOD file_f4.
DATA: lt_file_table TYPE filetable.
DATA: ls_file_table LIKE LINE OF lt_file_table.
DATA: lv_rc TYPE sy-subrc.
cl_gui_frontend_services=>file_open_dialog(
CHANGING
file_table = lt_file_table
rc = lv_rc ).
CLEAR ls_file_table .
READ TABLE lt_file_table INTO ls_file_table INDEX 1.
IF sy-subrc = 0.
r_file = ls_file_table-filename.
ENDIF.
ENDMETHOD. "file_f4
METHOD directory_f4.
cl_gui_frontend_services=>directory_browse(
CHANGING
selected_folder = r_path
EXCEPTIONS
OTHERS = 4 ).
ENDMETHOD. "directory_f4
METHOD upload.
cl_gui_frontend_services=>gui_upload(
EXPORTING
filename = i_filepath
CHANGING
data_tab = rt_strtab
EXCEPTIONS
OTHERS = 19 ).
IF sy-subrc <> 0.
MESSAGE e001(00) WITH 'File not found, check file path and name'.
ENDIF.
DELETE rt_strtab WHERE table_line IS INITIAL.
ENDMETHOD. "upload
METHOD download.
DATA: lt_datatab TYPE stringtab.
DATA: ls_datatab LIKE LINE OF lt_datatab.
FIELD-SYMBOLS: <ls_data> TYPE ANY.
FIELD-SYMBOLS: <lv_field> TYPE ANY.
* Convert table to delimited string table
LOOP AT it_datatab ASSIGNING <ls_data>.
CLEAR ls_datatab.
DO.
ASSIGN COMPONENT sy-index
OF STRUCTURE <ls_data> TO <lv_field>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
IF ls_datatab IS INITIAL.
ls_datatab = <lv_field>.
ELSE.
CONCATENATE ls_datatab <lv_field>
INTO ls_datatab SEPARATED BY lcl_application=>lv_delimiter.
ENDIF.
ENDDO.
APPEND ls_datatab TO lt_datatab.
ENDLOOP.
cl_gui_frontend_services=>gui_download(
EXPORTING
filename = i_filepath
CHANGING
data_tab = lt_datatab
EXCEPTIONS
OTHERS = 24 ).
IF sy-subrc <> 0.
MESSAGE e001(00)
WITH 'File not downloaded, check file path and name'.
ENDIF.
ENDMETHOD. "download
METHOD get_initial_directory.
cl_gui_frontend_services=>get_desktop_directory(
CHANGING
desktop_directory = r_path ).
cl_gui_cfw=>flush( ).
CONCATENATE r_path '\*.csv' INTO r_path.
ENDMETHOD. "get_initial_directory
METHOD export_users_to_file.
TYPES: BEGIN OF t_output,
user_id TYPE uje_user-user_id,
fullname TYPE uje_user-fullname,
email TYPE uje_user-email,
END OF t_output.
DATA: lt_user_id TYPE uje_t_api_user_id.
DATA: lt_users TYPE uje_t_user.
DATA: ls_users LIKE LINE OF lt_users.
DATA: lt_output TYPE TABLE OF t_output.
DATA: ls_output LIKE LINE OF lt_output.
lcl_application=>set_global_context( ).
CALL FUNCTION 'UJE_API_GET_LIST_USERS'
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
is_user = lcl_application=>lo_context->ds_user
it_user_id = lt_user_id
IMPORTING
et_user = lt_users.
REFRESH lt_output.
LOOP AT lt_users INTO ls_users.
MOVE-CORRESPONDING ls_users TO ls_output.
APPEND ls_output TO lt_output.
ENDLOOP.
* Download table
lcl_application=>download( EXPORTING i_filepath = p_file
it_datatab = lt_output ).
ENDMETHOD. "export_users_to_file
METHOD import_users_from_file.
DATA: lv_action TYPE uj_action.
DATA: lv_success TYPE uj_bool.
DATA: ls_user_info TYPE uje_s_userinfo.
DATA: lt_messages TYPE uj0_t_message.
DATA: ls_alv_messages LIKE LINE OF lt_alv_messages.
DATA: lt_team_asin TYPE uje_t_user_team.
DATA: lt_tprofiles TYPE uje_t_profile_id_act.
DATA: lt_mprofiles TYPE uje_t_profile_id_act.
DATA: lt_strtab TYPE stringtab.
DATA: ls_strtab LIKE LINE OF lt_strtab.
lt_strtab = lcl_application=>upload( p_file ).
LOOP AT lt_strtab INTO ls_strtab.
SPLIT ls_strtab AT lcl_application=>lv_delimiter INTO ls_user_info-user_id
ls_user_info-fullname
ls_user_info-email.
* Check if user already exists, and set action accordingly.
IF lcl_application=>user_is_valid( ls_user_info-user_id ) = abap_false.
lv_action = 'I'.
ELSE.
lv_action = 'M'.
ENDIF.
CALL FUNCTION 'UJE_API_MANAGE_USER2'
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
is_user = lcl_application=>lo_context->ds_user
is_user_info = ls_user_info
i_action = lv_action
it_team_asin = lt_team_asin
it_tprofile_id = lt_tprofiles
it_mprofile_id = lt_mprofiles
IMPORTING
e_success = lv_success
et_message_lines = lt_messages.
IF lv_success = 'Y'.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'S'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'User ID' ls_user_info-user_id
'has been created/updated successfully'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
ELSE.
APPEND LINES OF lt_messages TO lt_alv_messages.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'E'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'User ID' ls_user_info-user_id
'not created/updated due to error'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
ENDIF.
ENDLOOP.
lcl_application=>render_alv( ).
ENDMETHOD. "create_users_from_file
METHOD export_teams_to_file.
TYPES: BEGIN OF t_output,
team_id TYPE uje_s_team-team_id,
description TYPE uje_s_team-description,
END OF t_output.
DATA: lt_teams TYPE uje_t_team.
DATA: ls_teams LIKE LINE OF lt_teams.
DATA: lt_output TYPE TABLE OF t_output.
DATA: ls_output LIKE LINE OF lt_output.
CALL FUNCTION 'UJE_API_GET_TEAMS'
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
is_user = lcl_application=>lo_context->ds_user
IMPORTING
et_team = lt_teams.
REFRESH lt_output.
LOOP AT lt_teams INTO ls_teams.
MOVE-CORRESPONDING ls_teams TO ls_output.
APPEND ls_output TO lt_output.
ENDLOOP.
* Download table
lcl_application=>download( EXPORTING i_filepath = p_file
it_datatab = lt_output ).
ENDMETHOD. "export_teams_to_file
METHOD import_teams_from_file.
DATA: lv_action TYPE uj_action.
DATA: lv_success TYPE uj_bool.
DATA: ls_team TYPE uje_s_team.
DATA: lt_messages TYPE uj0_t_message.
DATA: ls_alv_messages LIKE LINE OF lt_alv_messages.
DATA: lt_users TYPE uje_t_user_team.
DATA: lt_tprofiles TYPE uje_t_profile_id_act.
DATA: lt_mprofiles TYPE uje_t_profile_id_act.
DATA: lt_strtab TYPE stringtab.
DATA: ls_strtab LIKE LINE OF lt_strtab.
lt_strtab = lcl_application=>upload( p_file ).
LOOP AT lt_strtab INTO ls_strtab.
SPLIT ls_strtab AT lcl_application=>lv_delimiter INTO ls_team-team_id
ls_team-description.
* Check if team is already a valid team, set action appropriatly
IF lcl_application=>team_is_valid( ls_team-team_id ) = abap_false.
lv_action = 'I'.
ELSE.
lv_action = 'M'.
ENDIF.
CALL FUNCTION 'UJE_API_MANAGE_TEAM2'
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
is_user = lcl_application=>lo_context->ds_user
is_team = ls_team
i_action = lv_action
it_users = lt_users
it_tprofile_id = lt_tprofiles
it_mprofile_id = lt_mprofiles
IMPORTING
e_success = lv_success
et_message_lines = lt_messages.
IF lv_success = 'Y'.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'S'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'Team' ls_team-team_id
'has been created/updated successfully'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
ELSE.
APPEND LINES OF lt_messages TO lt_alv_messages.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'E'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'Team' ls_team-team_id
'not created/updated due to error'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
ENDIF.
ENDLOOP.
lcl_application=>render_alv( ).
ENDMETHOD. "create_teams_from_file
METHOD export_team_assign_to_file.
TYPES: BEGIN OF t_user_assign,
user_id TYPE uje_s_user_team-user_id,
team_id TYPE uje_s_user_team-team_id,
teamleader TYPE uje_s_user_team-teamleader,
END OF t_user_assign.
DATA: lt_user_det TYPE uje_t_user_detail.
DATA: ls_user_det LIKE LINE OF lt_user_det.
DATA: ls_user_team TYPE uje_s_user_team.
DATA: lt_team_assign TYPE TABLE OF t_user_assign.
DATA: ls_team_assign LIKE LINE OF lt_team_assign.
CALL FUNCTION 'UJE_API_GET_USERDATA'
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
is_user = lcl_application=>lo_context->ds_user
IMPORTING
et_user = lt_user_det.
LOOP AT lt_user_det INTO ls_user_det.
LOOP AT ls_user_det-t_team_id INTO ls_user_team.
MOVE-CORRESPONDING ls_user_team TO ls_team_assign.
APPEND ls_team_assign TO lt_team_assign.
ENDLOOP.
ENDLOOP.
* Download table
lcl_application=>download( EXPORTING i_filepath = p_file
it_datatab = lt_team_assign ).
ENDMETHOD. "export_team_assign_to_file
METHOD import_team_assign_from_file.
TYPES: BEGIN OF t_user_assign,
user_id TYPE uje_s_user_team-user_id,
team_id TYPE uje_s_user_team-team_id,
teamleader TYPE uje_s_user_team-teamleader,
END OF t_user_assign.
DATA: lv_success TYPE uj_bool.
DATA: lt_user_team_temp TYPE uje_t_user_team.
DATA: ls_user_team_temp TYPE uje_s_user_team.
DATA: lt_user_team TYPE uje_t_user_team.
DATA: ls_user_team TYPE uje_s_user_team.
DATA: ls_team_assign TYPE uje_s_user_team.
DATA: lt_messages TYPE uj0_t_message.
DATA: ls_alv_messages LIKE LINE OF lt_alv_messages.
DATA: lt_tprofiles TYPE uje_t_profile_id_act.
DATA: ls_tprofiles LIKE LINE OF lt_tprofiles.
DATA: lt_mprofiles TYPE uje_t_profile_id_act.
DATA: ls_mprofiles LIKE LINE OF lt_mprofiles.
DATA: lt_tprofile_ids TYPE uje_t_api_profile_id.
DATA: ls_tprofile_ids LIKE LINE OF lt_tprofile_ids.
DATA: lt_mprofile_ids TYPE uje_t_api_profile_id.
DATA: ls_mprofile_ids LIKE LINE OF lt_mprofile_ids.
DATA: lt_strtab TYPE stringtab.
DATA: ls_strtab LIKE LINE OF lt_strtab.
DATA: ls_teams_list LIKE LINE OF lt_teams_list.
lt_strtab = lcl_application=>upload( p_file ).
LOOP AT lt_strtab INTO ls_strtab.
SPLIT ls_strtab AT lcl_application=>lv_delimiter INTO ls_team_assign-user_id
ls_team_assign-team_id
ls_team_assign-teamleader.
CLEAR ls_user_team.
ls_user_team-user_id = ls_team_assign-user_id.
ls_user_team-team_id = ls_team_assign-team_id.
ls_user_team-teamleader = ls_team_assign-teamleader.
TRANSLATE ls_user_team-teamleader USING 'YXyX1XxXN n 0 '. "Translate to X or space
APPEND ls_user_team TO lt_user_team.
IF lcl_application=>team_is_valid( ls_team_assign-team_id ) = abap_false.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'E'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'Team' ls_team_assign-team_id 'does not yet exist.'
'No user assigments done.'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
lcl_application=>render_alv( ).
RETURN.
ENDIF.
IF lcl_application=>user_is_valid( ls_team_assign-user_id ) = abap_false.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'E'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'User' ls_team_assign-user_id 'does not yet exist.'
'No user assigments done.'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
lcl_application=>render_alv( ).
RETURN.
ENDIF.
ENDLOOP.
LOOP AT lcl_application=>lt_teams_list INTO ls_teams_list.
REFRESH lt_user_team_temp.
REFRESH lt_tprofile_ids.
REFRESH lt_mprofile_ids.
* Check that there is data for team assignment, otherwise skip
READ TABLE lt_user_team TRANSPORTING NO FIELDS
WITH KEY team_id = ls_teams_list-team_id.
IF sy-subrc <> 0.
CONTINUE.
ENDIF.
* Get existing team data for this team.
CALL FUNCTION 'UJE_API_GET_TEAMDATA'
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
is_user = lcl_application=>lo_context->ds_user
i_team_id = ls_teams_list-team_id
IMPORTING
et_user_team = lt_user_team_temp
et_tprofile_id = lt_tprofile_ids
et_mprofile_id = lt_mprofile_ids.
* Update with new users.
LOOP AT lt_user_team INTO ls_user_team
WHERE team_id = ls_teams_list-team_id.
MOVE-CORRESPONDING ls_user_team TO ls_user_team_temp.
APPEND ls_user_team_temp TO lt_user_team_temp.
ENDLOOP.
* Keep existing profiles.
REFRESH lt_tprofiles.
LOOP AT lt_tprofile_ids INTO ls_tprofile_ids.
ls_tprofiles-profile_id = ls_tprofile_ids-profile_id.
APPEND ls_tprofiles TO lt_tprofiles.
ENDLOOP.
REFRESH lt_mprofiles.
LOOP AT lt_mprofile_ids INTO ls_mprofile_ids.
ls_mprofiles-profile_id = ls_mprofile_ids-profile_id.
APPEND ls_mprofiles TO lt_mprofiles.
ENDLOOP.
* now update the user/team assignments
CALL FUNCTION 'UJE_API_MANAGE_TEAM2'
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
is_user = lcl_application=>lo_context->ds_user
is_team = ls_teams_list
i_action = 'M'
it_users = lt_user_team_temp
it_tprofile_id = lt_tprofiles
it_mprofile_id = lt_mprofiles
IMPORTING
e_success = lv_success
et_message_lines = lt_messages.
IF lv_success = 'Y'.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'S'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'Team' ls_teams_list-team_id 'user assignments'
'have been updated successfully'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
ELSE.
APPEND LINES OF lt_messages TO lt_alv_messages.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'E'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'Team' ls_teams_list-team_id 'user assignments'
'not updated due to error'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
ENDIF.
ENDLOOP.
lcl_application=>render_alv( ).
ENDMETHOD. "import_team_assign_from_file
METHOD export_task_profiles_to_file.
TYPES: BEGIN OF t_output,
identifier TYPE char01, " Row Identifer
profile TYPE uj_profile_id,
values TYPE string,
END OF t_output.
DATA: ls_tprofs LIKE LINE OF lt_tprofs.
DATA: lv_profile TYPE uj_profile_id.
DATA: ls_profile TYPE uje_s_profile.
DATA: lt_role_id TYPE uje_t_api_role_id.
DATA: ls_role_id LIKE LINE OF lt_role_id.
DATA: lt_task_info TYPE uje_t_task_info.
DATA: ls_task_info LIKE LINE OF lt_task_info.
DATA: lt_users_asin TYPE uje_t_api_user_id.
DATA: ls_users_asin LIKE LINE OF lt_users_asin.
DATA: lt_teams_asin TYPE uje_t_api_team_id.
DATA: ls_teams_asin LIKE LINE OF lt_teams_asin.
DATA: lt_output TYPE TABLE OF t_output.
DATA: ls_output LIKE LINE OF lt_output.
LOOP AT lcl_application=>lt_tprofs INTO ls_tprofs.
lv_profile = ls_tprofs-profile_id.
* Get relevant data for task profile
CLEAR ls_profile.
REFRESH: lt_role_id, lt_task_info, lt_users_asin, lt_teams_asin.
CALL FUNCTION 'UJE_API_GET_TPROFILEDATA2'
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
is_user = lcl_application=>lo_context->ds_user
i_profile_id = lv_profile
IMPORTING
es_profile = ls_profile
et_role_id = lt_role_id
et_task_info = lt_task_info
et_user_id = lt_users_asin
et_team_id = lt_teams_asin.
* Write Header row
CLEAR ls_output.
ls_output-identifier = 'H'.
ls_output-profile = lv_profile.
ls_output-values = ls_profile-description.
APPEND ls_output TO lt_output.
* Write task assigments
CLEAR ls_output.
ls_output-identifier = 'K'.
ls_output-profile = lv_profile.
LOOP AT lt_task_info INTO ls_task_info.
ls_output-values = ls_task_info-task_id.
APPEND ls_output TO lt_output.
ENDLOOP.
* Write role assigments
CLEAR ls_output.
ls_output-identifier = 'R'.
ls_output-profile = lv_profile.
LOOP AT lt_role_id INTO ls_role_id.
ls_output-values = ls_role_id-role_id.
APPEND ls_output TO lt_output.
ENDLOOP.
* Write user assignments
CLEAR ls_output.
ls_output-identifier = 'U'.
ls_output-profile = lv_profile.
LOOP AT lt_users_asin INTO ls_users_asin.
ls_output-values = ls_users_asin-user_id.
APPEND ls_output TO lt_output.
ENDLOOP.
* Write team assignments
CLEAR ls_output.
ls_output-identifier = 'T'.
ls_output-profile = lv_profile.
LOOP AT lt_teams_asin INTO ls_teams_asin.
ls_output-values = ls_teams_asin-team_id.
APPEND ls_output TO lt_output.
ENDLOOP.
ENDLOOP.
* Download table
lcl_application=>download( EXPORTING i_filepath = p_file
it_datatab = lt_output ).
ENDMETHOD. "export_task_profiles_to_file
METHOD import_task_profiles_from_file.
TYPES: BEGIN OF t_input,
identifier TYPE char01, " Row Identifer
profile TYPE uj_profile_id,
values TYPE string,
END OF t_input.
TYPES: BEGIN OF t_task_profile,
profile TYPE uje_s_profile,
roles TYPE uje_t_api_role_id,
task_info TYPE uje_t_task_info,
users_asin TYPE uje_t_api_user_id,
teams_asin TYPE uje_t_api_team_id,
END OF t_task_profile.
DATA: lt_task_profile TYPE TABLE OF t_task_profile.
DATA: ls_task_profile LIKE LINE OF lt_task_profile.
DATA: ls_alv_messages LIKE LINE OF lt_alv_messages.
DATA: lt_messages TYPE uj0_t_message.
DATA: lv_action TYPE uj_action.
DATA: lv_success TYPE uj_bool.
DATA: lv_last_profile TYPE uj_profile_id.
DATA: lt_role_id TYPE uje_t_api_role_id.
DATA: ls_role_id LIKE LINE OF lt_role_id.
DATA: lt_task_info TYPE uje_t_task_info.
DATA: ls_task_info LIKE LINE OF lt_task_info.
DATA: lt_users_asin TYPE uje_t_api_user_id.
DATA: ls_users_asin LIKE LINE OF lt_users_asin.
DATA: lt_teams_asin TYPE uje_t_api_team_id.
DATA: ls_teams_asin LIKE LINE OF lt_teams_asin.
DATA: lt_strtab TYPE stringtab.
DATA: ls_strtab LIKE LINE OF lt_strtab.
DATA: lt_input TYPE TABLE OF t_input.
DATA: ls_input LIKE LINE OF lt_input.
DATA: lt_obj_asin TYPE uje_t_profile_asin.
DATA: ls_obj_asin LIKE LINE OF lt_obj_asin.
DATA: lt_task_asin TYPE uje_t_task_id_act.
DATA: ls_task_asin LIKE LINE OF lt_task_asin.
* Upload file
lt_strtab = lcl_application=>upload( p_file ).
* Rip import file into internal table
LOOP AT lt_strtab INTO ls_strtab.
CLEAR ls_input.
SPLIT ls_strtab AT lcl_application=>lv_delimiter INTO ls_input-identifier
ls_input-profile
ls_input-values.
APPEND ls_input TO lt_input.
ENDLOOP.
* Build profile table containing all associated data
SORT lt_input STABLE ASCENDING BY profile identifier values.
LOOP AT lt_input INTO ls_input.
IF ls_input-profile <> lv_last_profile
AND lv_last_profile IS NOT INITIAL.
APPEND ls_task_profile TO lt_task_profile.
CLEAR ls_task_profile.
ENDIF.
* Based on record identifier
CASE ls_input-identifier.
WHEN 'H'. " Header
ls_task_profile-profile-profile_id = ls_input-profile.
ls_task_profile-profile-description = ls_input-values.
WHEN 'K'. " Task info
SPLIT ls_input-values AT lcl_application=>lv_delimiter INTO ls_task_info-task_id
ls_task_info-description.
IF lcl_application=>task_is_valid( ls_task_info-task_id ) = abap_false.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'E'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'Task ID' ls_task_info-task_id 'is not valid.'
'No task profile updates done.'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
lcl_application=>render_alv( ).
RETURN.
ENDIF.
APPEND ls_task_info TO ls_task_profile-task_info.
WHEN 'R'. " Roles
ls_role_id = ls_input-values.
IF lcl_application=>role_is_valid( ls_role_id ) = abap_false.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'E'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'Role ID' ls_role_id 'is not valid.'
-
Dear All,
For example :
I have a file in 'C:\file\' folder as JN01.BP01.01:02:87
Except the first 9 chars JN01.BP01 all the other (01:02:87) will vary time by time.
So how can i set that path for the said above file just by comparing first 9 chars .
Note : The file type could be excel or text file.
regards
Sivathink of some different logic....i agree with Reddy....
is the file u want to read, the last file in that directory....or something else.???
this little piece of code may help u...
this program retrieves the filed and folders in a folder(desktop)...
REPORT program_to_to_show_desktop_files_and_execute_them.
DATA: desktop TYPE string, "---->u can pass ur base folder here
count TYPE i,
files TYPE STANDARD TABLE OF file_info WITH HEADER LINE,
path TYPE string.
cl_gui_frontend_services=>get_desktop_directory( CHANGING desktop_directory = desktop ).
cl_gui_cfw=>flush( ).
cl_gui_frontend_services=>directory_list_files( EXPORTING directory = desktop
CHANGING file_table = files[]
count = count ).
LOOP AT files.
WRITE:/ files-filename.
CLEAR files.
ENDLOOP.
AT LINE-SELECTION.
CONCATENATE desktop '\' sy-lisel INTO path.
cl_gui_frontend_services=>execute( EXPORTING application = path ) . -
Regarding CL_GUI_FRONTEND_SERVICES
Dear forumers,
Is there a method available from the class CL_GUI_FRONTEND_SERVICES that can be used to select and browse for a file in the presentation server?
In other words, is there a method from this class that is similar to the function F4_FILENAME too? Also, is the function F4_FILENAME considered as an obsolete ABAP construct?
I have checked the methods in the class CL_GUI_FRONTEND_SERVICES, and I'm wondering if methods GET_DESKTOP_DIRECTORY or FILE_OPEN_DIALOG can be used for this purpose?
Please help. Thanks.Hi Deborah,
Try method FILE_OPEN_DIALOG in class CL_GUI_FRONTEND_SERVICES.
For its use, refer the following thread:
Re: class and method can be used instead of F4_FILENAME
Regards,
Nitin. -
Hi,
In sap gui was trigered action whih is using smartform and then output was being downloaded and saved as using:
CALL FUNCTION 'GUI_DOWNLOAD' - to
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG
After the ubgrade this action is not working in web ui.
Anyone knows how to change this to work in web ui?
Thank you in advanceHi Tanja Lukovic
Pls check the settings defined in the SPRO path CRM->Basic settings->actions under this select your relevant application area and check whether any start/schedule conditions are not met (check in conditions) , apart from this reason there could be other reasons also pls check the trigger processing type (it should be smart form print).
if the actions are already created , you can change actions and conditions.
Thanks & Regards
Raj -
Hello Experts,
I am currently practicing BDC and I think the first step is to locate where my text file is. Now based on my code below, after selecting my text file nothing happens.
Also, what will be my next after getting the file from a specific location? Thanks guys!
REPORT z_aris_practice_bdc_0
NO STANDARD PAGE HEADING
LINE-SIZE 255
LINE-COUNT 64
MESSAGE-ID zz.
*BDC Data
DATA: BEGIN OF bdc_tab OCCURS 0.
INCLUDE STRUCTURE bdcdata.
DATA: END OF bdc_tab.
*Internal Table
DATA: BEGIN OF it_input OCCURS 0,
user TYPE usr02-bname,
title TYPE sza5_d0700-title_medi,
lname TYPE addr3_data-name_last,
fname TYPE addr3_data-name_first,
initials TYPE addr3_data-initials,
nickname TYPE addr3_data-nickname,
function TYPE addr3_data-function,
END OF it_input.
DATA: gt_lines TYPE sy-tabix,
gt_file TYPE filetable,
wa_file TYPE filetable,
gt_subrc TYPE i.
*CONSTANTS
CONSTANTS: c_mask(60) TYPE c VALUE ',..'.
*Selection Screen
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: p_input LIKE rlgrap-filename.
SELECTION-SCREEN END OF BLOCK b1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_input.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
WINDOW_TITLE =
DEFAULT_EXTENSION =
DEFAULT_FILENAME =
FILE_FILTER =
initial_directory = 'C:\Temp\'
multiselection = 'X'
CHANGING
file_table = gt_file[]
rc = gt_subrc
USER_ACTION =
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*START-OF-SELECTION
START-OF-SELECTION.
PERFORM put_in_itab.
PERFORM process_records.
*& Form get_files
text
FORM put_in_itab.
DATA: lv_file TYPE string.
lv_file = p_input.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = lv_file
FILETYPE = 'ASC'
has_field_separator = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
VIRUS_SCAN_PROFILE =
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
data_tab = it_input
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
DESCRIBE TABLE it_input LINES gt_lines.
ENDIF.
ENDFORM. "get_files
*& Form process_records
text
FORM process_records.
LOOP AT it_input.
ENDLOOP.
ENDFORM. "process_recordsHii viraylab,
go throgh this link..This sample code solves ur problem....
/people/milind.upasani/blog/2007/03/07/step-by-step-approach-to-ceate-simple-bdc-session-program-using-reusable-template
U are new to BDC it seems...
first u read the sap help ... then u will come know what to do after wards....
http://help.sap.com/saphelp_47x200/helpdata/en/fa/097720543b11d1898e0000e8322d00/frameset.htm
Be familiar with the structure BDCDATA.
<b>Data transfers</b> In this page..
Next u need to know about the <b>transaction RECORDER the tcode is SHDB.</b>
Nothing is difficult in this ..
For example When u r creating a data element in SE11 u go through some screens in a flow, by clicking some pushbuttons and by generating some function codes manually, and entering values manually...
But here u wont do it manually, these values will be populated from file into an internal table...
Before calling a transaction into which u r going to populate the data is to be filled into a table with structure <b>BDCDATA.</b>
<b>U need to use CALL TRANSACTION 'SE11' using BDCDATA or
the session method..</b>
Reward points for helpful answers...
sai ramesh -
Error calling class methods CL_GUI_FRONTEND_SERVICES
Hi all,
I have a requirement in BAPI (integrating solman to portal) to download file from app. server to local directory. I used the below FM to get temp directory of presntation server.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GET_TEMP_DIRECTORY
CHANGING
TEMP_DIR = LV_TEMP_DIR
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
NOT_SUPPORTED_BY_GUI = 3
others = 4.
CALL METHOD cl_gui_cfw=>flush.
It works fine in R3, but when i called it from portal it shows Access not possible using 'NULL' object reference with a short dump .
st22 shows
Error in ABAP application program.
The current ABAP program "CL_GUI_FRONTEND_SERVICES======CP" had to be
terminated because one of the
statements could not be executed.
This is probably due to an error in the ABAP program.
An exception occurred. This exception is dealt with in more detail belo
. The exception, which is assigned to the class 'CX_SY_REF_IS_INITIAL',
neither
caught nor passed along using a RAISING clause, in the procedure
"GET_TEMP_DIRECTORY" "(METHOD)"
Since the caller of the procedure could not have expected this exceptio
to occur, the running program was terminated.
The reason for the exception is:
Attempt to access a component using 'NULL' object reference (points
to nothing).
An object reference must point to an object (an instance of a class)
before you can use it to access components (variable:
"CL_GUI_FRONTEND_SERVICES=>HANDLE").
Either the reference has not yet been set, or it has been reset to
'NULL' by a CLEAR statement.
When i put external break point and the dump comes during execution of CALL METHOD cl_gui_cfw=>flush.
Is it not possible to use CL_GUI_FRONTEND_SERVICES in RFC ??.
thanks and regards
Jijo[CL_GUI_FRONTEND_SERVICES|https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=cl_gui_frontend_services+portal&adv=false&sortby=cm_rnd_rankvalue] needs a SAPGUI, so it is not possible to use it in RFC, BSP or other portal.
Regards
Maybe you are looking for
-
Error while posting SOAP request
Hi All, I am working on one SOAP to RFC syncronous scenario, when i am checking the scenario using XML spy i am getting following error, Please help me <?xml version="1.0"?> <!-- see the documentation --> <SOAP:Envelope xmlns:SOAP="http://schemas.
-
How many times can I request a refund on the same in-app puchases?
How many times can I request a refund on the same in-app puchases in one itunes account?
-
Unable to Convert PDF's to Word.
When attempting to convert a PDF to a Word doc in the export function of Adobe XI I get the following error msg "File Failed to be converted using Adobe Export PDF Online" is it possible to get more detail than this? I upgraded my subscription to in
-
Page layout does not support "ä".
Hello. I used design manager to create a page layout (SharePoint 365). No matter what I am not able to fiqure out how to create characters like "ä". Can someone confirm that SharePoint 2013 does not support non-English language page layouts. User
-
I have table with id and 4 measures: Id, M1, M2, M3, M4. I want to present report with the top N ids - but I do not know what measure the user will want to sort by. I can create 4 reports - each report X will present Id, M1, M2, M3, M4 and will have