07-05-2007 7:03 AM
hi
cl_gui_front_end_services-->FILE_OPEN_DIALOG
i want to use this method to get a file name to upload data into itab in BDC .
what shud i do for better performance..like shal i load this class to my program..is there any way??
syntax plz
07-05-2007 7:13 AM
Hi,
No need to load the class.
Just use as below
************************************************************************
Minimal demo report for Virus Scan Interface.
For a functionally more complete example see report RSVSCANTEST.
************************************************************************
REPORT zvscandemo.
************************************************************************
Selection screen
************************************************************************
PARAMETERS:
profile TYPE vscan_prof-profile,
file TYPE localfile.
************************************************************************
Events
************************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR file.
PERFORM file_f4.
START-OF-SELECTION.
PERFORM main.
************************************************************************
Main program
************************************************************************
FORM main.
IF file IS INITIAL.
MESSAGE s058(vscan) DISPLAY LIKE 'E'.
EXIT. " =================== EXIT =====================
ENDIF.
Access file and create XSTRING
TYPES:
ty_xline(1024) TYPE x.
DATA:
lf_file TYPE string,
lf_filelength TYPE i,
lt_datatab TYPE STANDARD TABLE OF ty_xline.
lf_file = file.
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = lf_file
filetype = 'BIN'
IMPORTING
filelength = lf_filelength
CHANGING
data_tab = lt_datatab
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
DISPLAY LIKE 'E'
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EXIT. " =================== EXIT =====================
ENDIF.
Recombine binary data
DATA:
lf_tabline TYPE ty_xline,
lf_data TYPE xstring.
LOOP AT lt_datatab INTO lf_tabline.
CONCATENATE
lf_data
lf_tabline
INTO
lf_data
IN BYTE MODE.
ENDLOOP.
lf_data = lf_data(lf_filelength).
Get scanner instance
DATA:
lo_vsi TYPE REF TO cl_vsi.
CALL METHOD cl_vsi=>get_instance
EXPORTING
if_profile = profile
IMPORTING
eo_instance = lo_vsi
EXCEPTIONS
configuration_error = 1
profile_not_active = 2
internal_error = 3
OTHERS = 4.
CASE sy-subrc.
No error.
WHEN 0.
" Nothing to do
Profile not active. For this report, this is an information message.
WHEN 2.
MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
DISPLAY LIKE 'I'
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EXIT. " =================== EXIT =====================
All other exceptions are issued as errors.
WHEN OTHERS.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
DISPLAY LIKE 'E'
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EXIT. " =================== EXIT =====================
ENDCASE.
Perform virus scan
DATA:
lf_scanrc TYPE vscan_scanrc.
CALL METHOD lo_vsi->scan_bytes
EXPORTING
if_data = lf_data
IMPORTING
ef_scanrc = lf_scanrc
EXCEPTIONS
not_available = 1
configuration_error = 2
internal_error = 3
OTHERS = 4.
All exceptions here are errors
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
DISPLAY LIKE 'E'
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EXIT. " =================== EXIT =====================
ENDIF.
Print return code and text
DATA:
lf_text TYPE string.
lf_text = cl_vsi=>get_scanrc_text( lf_scanrc ).
WRITE: / 'Result of virus scan: ', lf_scanrc, '(', lf_text, ')'.
IF lf_scanrc = cl_vsi=>con_scanrc_ok.
WRITE: / 'File is clean'.
ELSE.
WRITE: / 'File was either infected',
'or could not be scanned',
'or was ignored'.
'Or another problem occurred'.
ENDIF.
ENDFORM.
************************************************************************
F4-help for filename
************************************************************************
FORM file_f4.
DATA:
lt_filetable TYPE filetable,
lf_rc TYPE i.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
multiselection = abap_false
CHANGING
file_table = lt_filetable
rc = lf_rc
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 ID sy-msgid TYPE 'S' NUMBER sy-msgno
DISPLAY LIKE 'E'
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EXIT.
ENDIF.
Number of selected filed must be equal to one.
CHECK lf_rc = 1.
Access selected file
DATA:
ls_file TYPE file_table.
READ TABLE lt_filetable INTO ls_file INDEX 1.
CHECK sy-subrc = 0.
file = ls_file-filename.
ENDFORM.
Regards,
Atish
07-05-2007 7:13 AM
Hi,
No need to load the class.
Just use as below
************************************************************************
Minimal demo report for Virus Scan Interface.
For a functionally more complete example see report RSVSCANTEST.
************************************************************************
REPORT zvscandemo.
************************************************************************
Selection screen
************************************************************************
PARAMETERS:
profile TYPE vscan_prof-profile,
file TYPE localfile.
************************************************************************
Events
************************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR file.
PERFORM file_f4.
START-OF-SELECTION.
PERFORM main.
************************************************************************
Main program
************************************************************************
FORM main.
IF file IS INITIAL.
MESSAGE s058(vscan) DISPLAY LIKE 'E'.
EXIT. " =================== EXIT =====================
ENDIF.
Access file and create XSTRING
TYPES:
ty_xline(1024) TYPE x.
DATA:
lf_file TYPE string,
lf_filelength TYPE i,
lt_datatab TYPE STANDARD TABLE OF ty_xline.
lf_file = file.
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = lf_file
filetype = 'BIN'
IMPORTING
filelength = lf_filelength
CHANGING
data_tab = lt_datatab
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
DISPLAY LIKE 'E'
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EXIT. " =================== EXIT =====================
ENDIF.
Recombine binary data
DATA:
lf_tabline TYPE ty_xline,
lf_data TYPE xstring.
LOOP AT lt_datatab INTO lf_tabline.
CONCATENATE
lf_data
lf_tabline
INTO
lf_data
IN BYTE MODE.
ENDLOOP.
lf_data = lf_data(lf_filelength).
Get scanner instance
DATA:
lo_vsi TYPE REF TO cl_vsi.
CALL METHOD cl_vsi=>get_instance
EXPORTING
if_profile = profile
IMPORTING
eo_instance = lo_vsi
EXCEPTIONS
configuration_error = 1
profile_not_active = 2
internal_error = 3
OTHERS = 4.
CASE sy-subrc.
No error.
WHEN 0.
" Nothing to do
Profile not active. For this report, this is an information message.
WHEN 2.
MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
DISPLAY LIKE 'I'
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EXIT. " =================== EXIT =====================
All other exceptions are issued as errors.
WHEN OTHERS.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
DISPLAY LIKE 'E'
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EXIT. " =================== EXIT =====================
ENDCASE.
Perform virus scan
DATA:
lf_scanrc TYPE vscan_scanrc.
CALL METHOD lo_vsi->scan_bytes
EXPORTING
if_data = lf_data
IMPORTING
ef_scanrc = lf_scanrc
EXCEPTIONS
not_available = 1
configuration_error = 2
internal_error = 3
OTHERS = 4.
All exceptions here are errors
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
DISPLAY LIKE 'E'
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EXIT. " =================== EXIT =====================
ENDIF.
Print return code and text
DATA:
lf_text TYPE string.
lf_text = cl_vsi=>get_scanrc_text( lf_scanrc ).
WRITE: / 'Result of virus scan: ', lf_scanrc, '(', lf_text, ')'.
IF lf_scanrc = cl_vsi=>con_scanrc_ok.
WRITE: / 'File is clean'.
ELSE.
WRITE: / 'File was either infected',
'or could not be scanned',
'or was ignored'.
'Or another problem occurred'.
ENDIF.
ENDFORM.
************************************************************************
F4-help for filename
************************************************************************
FORM file_f4.
DATA:
lt_filetable TYPE filetable,
lf_rc TYPE i.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
multiselection = abap_false
CHANGING
file_table = lt_filetable
rc = lf_rc
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 ID sy-msgid TYPE 'S' NUMBER sy-msgno
DISPLAY LIKE 'E'
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EXIT.
ENDIF.
Number of selected filed must be equal to one.
CHECK lf_rc = 1.
Access selected file
DATA:
ls_file TYPE file_table.
READ TABLE lt_filetable INTO ls_file INDEX 1.
CHECK sy-subrc = 0.
file = ls_file-filename.
ENDFORM.
Regards,
Atish
07-05-2007 7:21 AM
07-05-2007 7:23 AM
Hi,
It will work for all kind of files.
After that use FM ALSM_EXCEL_TO_INTERNAL_TABLE instead of GUI_UPLOAD.
Reward all useful answers.
Regards,
Atish
07-05-2007 1:46 PM
Hello
Assuming that you have stored your data as <i>.csv </i>file you can use the following coding:
CALL METHOD cl_gui_frontend_services=>gui_upload " for uploading the file
The itab for the data upload should be unstructured (line type = string or C-container).
Next you convert the unstructured data into your BDC data using function module <b>TEXT_CONVERT_CSV_TO_SAP</b>.
Regards
Uwe
07-05-2007 7:15 AM
you can see the above code on
http://help.sap.com/saphelp_nw2004s/helpdata/en/71/9f893f17493c17e10000000a114084/content.htm
Regards,
Atish
07-11-2007 9:47 AM