CL_GUI_FRONTEND_SERVICES- FILE_DELETE -- use???
How to delete a file from the presentation server (desktop) using the following method?? explain in detail with sample code.
CL_GUI_FRONTEND_SERVICES->FILE_DELETE
Regards,
Kalai
pass u r file path name in the presentation server thats it.......
DATA V_RC TYPE I.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_DELETE
EXPORTING
FILENAME = 'C:\LAK1.XLS'
CHANGING
RC = V_RC
EXCEPTIONS
FILE_DELETE_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
FILE_NOT_FOUND = 4
ACCESS_DENIED = 5
UNKNOWN_ERROR = 6
NOT_SUPPORTED_BY_GUI = 7
WRONG_PARAMETER = 8
OTHERS = 9.
IF SY-SUBRC <> 0.
ENDIF
Similar Messages
-
Using CL_GUI_FRONTEND_SERVICES- EXECUTE to open excel
Is there a way to get EXCEL to run a macro when you open it using CL_GUI_FRONTEND_SERVICES? I have seen no documentation about the options of this method.
Thankshi,
Get the filename using the CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DAILOG
Using OLE run the macro using below code
CREATE OBJECT h_excel 'EXCEL.APPLICATION'.
call method of h_excel 'WORKBOOKS' = h_mapl.
set property of h_excel 'VISIBLE' = 0.
call method of h_mapl 'OPEN'
EXPORTING
#1 = d_file.
CALL METHOD OF H_EXCEL 'ActiveWorkbook' = h_book .
CALL METHOD OF H_book 'Activesheet' = H_sheet .
CALL METHOD OF h_excel 'RUN'
EXPORTING
#1 = ld_macro. -
Hello Everyone,
My program not working when sceduled to run in background, but works fine when run in foreground. Think i need to change some funcution modules as the ones i used are, think, referencing for foreground processing. Can anyone point to some function modules which does the job for me.
I am picking up the files from file server.
REPORT zco11n
NO STANDARD PAGE HEADING
LINE-SIZE 255.
INCLUDE zdeclerations. " Data Declarations part
*---------------Get actual filepath from logical filepath---------------------*
CALL FUNCTION 'FILE_GET_NAME'
EXPORTING
* CLIENT = SY-MANDT
logical_filename = 'ZBARCODE_APPLICATION' "logical path
IMPORTING
file_name = pa_file "actual path
EXCEPTIONS
file_not_found = 1
OTHERS = 2
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*---------------Get all the required files from the directory-------------------*
CALL FUNCTION 'TMP_GUI_DIRECTORY_LIST_FILES'
EXPORTING
directory = pa_file "Directory path
filter = '*.CSV'
TABLES
file_table = lt_file "Files in the direcory
dir_table = lt_dir
EXCEPTIONS
cntl_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*-------Get the directory and file name as single path & move to internal table----*
LOOP AT lt_file INTO lw_file.
CONCATENATE pa_file lw_file-pathname INTO lstring.
MOVE lstring TO lw_filename-pathname.
MOVE lw_file-pathname TO lw_filename-filename.
APPEND lw_filename TO lt_filename.
CLEAR lw_filename.
CLEAR lw_file.
ENDLOOP.
START-OF-SELECTION.
LOOP AT lt_filename INTO lw_filename.
file_name = lw_filename-pathname.
*-------Read the contents of the file to an internal table--------------------------*
CALL FUNCTION 'DX_FILE_READ'
EXPORTING
filename = file_name
pc = 'X'
TABLES
data_tab = lt_temp "File contents
EXCEPTIONS
no_file_on_server = 1
no_data_on_server = 2
gui_upload_failed = 3
no_authority = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
*-------------Split and move the contents as required for BDC---------------*
LOOP AT lt_temp INTO lw_temp.
SPLIT lw_temp AT ',' INTO lw_afrud-aufnr lw_afrud-lmnga lw_afrud-budat.
APPEND lw_afrud TO lt_afrud.
ENDLOOP.
************----------Start Of BDC-----------------------***************
LOOP AT lt_afrud INTO lw_afrud.
PERFORM bdc_dynpro USING 'SAPLCORU_S' '0100'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'AFRUD-AUFNR'
lw_afrud-aufnr.
PERFORM bdc_field USING 'AFRUD-LMNGA'
'1'.
PERFORM bdc_field USING 'AFRUD-ISDZ'
'00:00:00'.
PERFORM bdc_field USING 'AFRUD-IEDZ'
'00:00:00'.
PERFORM bdc_field USING 'AFRUD-PEDZ'
'00:00:00'.
PERFORM bdc_field USING 'BDC_CURSOR'
'AFRUD-BUDAT'.
PERFORM bdc_field USING 'AFRUD-BUDAT'
lw_afrud-budat.
PERFORM bdc_dynpro USING 'SAPLCORU_S' '0100'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=BU'.
CALL TRANSACTION 'CO11N' USING lt_bdcdata MODE 'N'
UPDATE 'S' MESSAGES INTO lt_bdcmsgcoll. "#EC CI_CALLTA
ENDLOOP.
*******-----------End of BDC-------------------------------------*******
CLEAR lw_afrud.
REFRESH lt_afrud.
************************File Manipulations*********************
lv_file_name = lw_filename-filename. "Assign the filename to a local variable
CONCATENATE '\CAUVERYSAPBARCODESUCCESS'
lv_file_name INTO lstring_success. "Place holder for BDC Success Files
CONCATENATE '\CAUVERYSAPBARCODEERROR'
lv_file_name INTO lstring_error. "Place holder for BDC Error Files
file_name_source = file_name. "Source file path
file_name_success_dest = lstring_success. "Success file path
file_name_error_dest = lstring_error. "Error file path
*For the files with no data in them, move them to desired(error) folder.
if lt_bdcmsgcoll[] is initial.
CALL METHOD cl_gui_frontend_services=>file_copy
EXPORTING
SOURCE = file_name_source
destination = file_name_error_dest.
endif.
LOOP AT lt_bdcmsgcoll INTO lw_bdcmsgcoll.
IF lw_bdcmsgcoll-msgtyp EQ 'S' AND
lw_bdcmsgcoll-msgnr EQ '110'.
*----------Move the succes files to designated folder---------------*.
CALL METHOD cl_gui_frontend_services=>file_copy
EXPORTING
SOURCE = file_name_source
DESTINATION = file_name_success_dest
overwrite = 'X'
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
wrong_parameter = 3
disk_full = 4
access_denied = 5
file_not_found = 6
destination_exists = 7
unknown_error = 8
path_not_found = 9
disk_write_protect = 10
drive_not_ready = 11
not_supported_by_gui = 12
OTHERS = 13.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ELSE.
*--------Move the error files to designated folder-----------------*.
IF lw_bdcmsgcoll-msgtyp EQ 'E' OR
lt_bdcmsgcoll[] IS INITIAL.
CALL METHOD cl_gui_frontend_services=>file_copy
EXPORTING
SOURCE = file_name_source
DESTINATION = file_name_error_dest
overwrite = 'X'
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
wrong_parameter = 3
disk_full = 4
access_denied = 5
file_not_found = 6
destination_exists = 7
unknown_error = 8
path_not_found = 9
disk_write_protect = 10
drive_not_ready = 11
not_supported_by_gui = 12
OTHERS = 13.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
*----------------Delete file from the directory---------------------------*
CALL METHOD cl_gui_frontend_services=>file_delete
EXPORTING
filename = file_name_source
CHANGING
rc = lv_rc
EXCEPTIONS
file_delete_failed = 1
cntl_error = 2
error_no_gui = 3
file_not_found = 4
access_denied = 5
unknown_error = 6
not_supported_by_gui = 7
wrong_parameter = 8
OTHERS = 9.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
REFRESH lt_bdcmsgcoll.
REFRESH lt_bdcdata.
ENDLOOP.
*& Form bdc_dynpro
* text
* -->PROGRAM text
* -->DYNPRO text
FORM bdc_dynpro USING program dynpro. "#EC *
CLEAR lw_bdcdata.
lw_bdcdata-program = program.
lw_bdcdata-dynpro = dynpro.
lw_bdcdata-dynbegin = 'X'.
APPEND lw_bdcdata TO lt_bdcdata.
ENDFORM. "BDC_DYNPRO
*& Form bdc_field
* text
* -->FNAM text
* -->FVAL text
FORM bdc_field USING fnam fval. "#EC *
IF fval <> space.
CLEAR lw_bdcdata.
lw_bdcdata-fnam = fnam.
lw_bdcdata-fval = fval.
APPEND lw_bdcdata TO lt_bdcdata.
ENDIF.
ENDFORM. "bdc_field
*& Include ZDECLERATIONS
*-----------------------------Types decleration--------------------------*
TYPES: BEGIN OF tw_afrud,
aufnr TYPE aufnr,
lmnga(13) TYPE c,
budat TYPE buchdatum,
END OF tw_afrud,
tt_afrud TYPE STANDARD TABLE OF tw_afrud.
TYPES: BEGIN OF tw_temp,
rec(7000) TYPE c,
END OF tw_temp,
tt_temp TYPE STANDARD TABLE OF tw_temp.
TYPES: BEGIN OF tw_errorlog,
aufnr TYPE aufnr,
message TYPE string,
END OF tw_errorlog,
tt_errorlog TYPE STANDARD TABLE OF tw_errorlog.
TYPES: BEGIN OF tw_file,
pathname TYPE sdok_filnm,
END OF tw_file,
tt_file TYPE STANDARD TABLE OF tw_file.
TYPES: BEGIN OF tw_dir,
pathname1 TYPE sdok_filnm,
END OF tw_dir,
tt_dir TYPE STANDARD TABLE OF tw_dir.
TYPES: BEGIN OF tw_filename,
filename TYPE rlgrap-filename,
pathname TYPE localfile,
END OF tw_filename,
tt_filename TYPE STANDARD TABLE OF tw_filename.
*-------------Variable decleration---------------------------------------*
DATA: pa_file TYPE rlgrap-filename.
DATA: lstring TYPE string,
lstring_success TYPE string,
lstring_error TYPE string,
file_name TYPE dxfile-filename,
lv_rc TYPE i,
file_name_source TYPE string,
file_name_error_dest TYPE string,
file_name_success_dest TYPE string,
lv_file_name TYPE rlgrap-filename.
*---------------Internal tables & Work area's ------------------------------*
DATA : lw_afrud TYPE tw_afrud,
lt_afrud TYPE tt_afrud,
lw_temp TYPE tw_temp,
lt_temp TYPE tt_temp,
lw_file TYPE tw_file,
lt_file TYPE tt_file,
lw_dir TYPE tw_dir, "#EC *
lt_dir TYPE tt_dir,
lw_filename TYPE tw_filename,
lt_filename TYPE tt_filename,
lw_bdcdata TYPE bdcdata,
lt_bdcdata TYPE STANDARD TABLE OF bdcdata,
lw_bdcmsgcoll TYPE bdcmsgcoll,
lt_bdcmsgcoll TYPE STANDARD TABLE OF bdcmsgcoll.
RegardsThe methods of the class
cl_gui_frontend_services
cannot be used in background since they refer to the presentation server. You have to upload the files to the application server to run the program in the background. You can use transaction CG3Z or the function module
ARCHIVFILE_CLIENT_TO_SERVER
to upload the files.
Manoj -
HI ALL,
I AM USING THIS METHD FOR DELETING THE FILE FROM THE
FOLDER BUT I DONT KNOW WHAT VALUE SHULD I PASS TO THE RC.
CALL METHOD cl_gui_frontend_services=>file_delete
EXPORTING
filename = 'E:\FOLDER1\TEST1.XLS'
changing
rc =
THANKS AND REGARDS,
SUGEET.Hi,
You should declare a local variable of TYPE I and pass it to RC. RC is nothing but a return code set by system upon successful deletion or otherwise of the file that you have specified for filename.
Some thing like the following,
DATA: lv_subrc TYPE i.
CALL METHOD cl_gui_frontend_services=>file_delete
EXPORTING
filename = 'E:FOLDER1TEST1.XLS'
changing
rc = lv_subrc.
IF lv_subrc NE 0.
****Deletion failed..
ENDIF.
Hope this helps..
Sri
Message was edited by: Srikanth Pinnamaneni -
Hi SDN
i have a small problem where iam unable to add fields in the final internal table
i have to add two fields i.e., COMMITMENT AND ACTVALUE from ESUH TABLE
AND the final internal table is l_i_ekpo.
we have to add only two fields COMMITMENT and a ....variable = COMMITMENT - ACTVALUE. which is already done in the program.
here iam attaching a program.
TABLES: ekpo.
DATA: i_directory_list LIKE rlgrap-filename OCCURS 0 WITH HEADER LINE.
DATA: i_directory_sel LIKE popuptext OCCURS 0 WITH HEADER LINE.
*{ INSERT PS010306UPGR
CLASS cl_abap_char_utilities DEFINITION LOAD.
*} INSERT
DATA: BEGIN OF tab,
*{ REPLACE PS010306UPGR
T(1) TYPE X VALUE '09', "HEX!
t(1) TYPE c VALUE cl_abap_char_utilities=>horizontal_tab, "Unicode
*} REPLACE
END OF tab.
DATA: ekpo_konnr LIKE ekpo-konnr.
DATA: ekpo_ktpnr LIKE ekpo-ktpnr.
DATA: BEGIN OF t_bapiessrc OCCURS 0.
INCLUDE STRUCTURE zbapiessrc_chars.
DATA: END OF t_bapiessrc.
DATA: t_bapiessrc_tab(301) OCCURS 0." with header line.
DATA: wa_bapiessrc_tab(301).
DATA: BEGIN OF t_headertext OCCURS 0,
ext_number LIKE zbapiessrc_chars-ext_number,
linno(4) TYPE n,
tcode(20),
recordname(30),
txpargraph(2),
txline(72),
text_mark,
END OF t_headertext.
DATA: BEGIN OF t_itemtext OCCURS 0,
ext_number LIKE zbapiessrc_chars-ext_number,
ext_line(18),
linno(4) TYPE n,
tcode(20),
recordname(30),
txpargraph(2),
txline(72),
text_mark,
ext_linno(6),
END OF t_itemtext.
DATA: t_headertext_tab(180) OCCURS 0.
DATA: wa_headertext_tab(180).
DATA: t_itemtext_tab(190) OCCURS 0.
DATA: wa_itemtext_tab(190).
DATA: BEGIN OF t_bapiesllc OCCURS 0.
ext_number like bapiessrc-ext_number.
INCLUDE STRUCTURE zbapiesllc_chars.
DATA: END OF t_bapiesllc.
DATA: t_bapiesllc_tab(650) OCCURS 0." with header line.
DATA: wa_bapiesllc_tab(650).
DATA: no_of_files LIKE sy-index.
DATA: perc_uploaded TYPE i.
DATA: text_uploaded(50).
DATA: text_fi_not_upl1(30), text_fi_not_upl2(30).
DATA: continue_yn.
DATA: file TYPE localfile.
FIELD-SYMBOLS .
DATA: BEGIN OF clbp_content OCCURS 0.
INCLUDE STRUCTURE solisti1.
DATA: END OF clbp_content.
DATA w_mode VALUE 'A'.
CONSTANTS: c_update VALUE 'S'.
DATA: BEGIN OF bdcdata OCCURS 0. " BDC Table
INCLUDE STRUCTURE bdcdata.
DATA: END OF bdcdata.
DATA: BEGIN OF bdcmsgcoll OCCURS 0. " BDC Messages
INCLUDE STRUCTURE bdcmsgcoll.
DATA: END OF bdcmsgcoll.
DATA params LIKE pri_params.
DATA list_text LIKE pri_params-prtxt.
DATA: days(1) TYPE n VALUE 2,
count(3) TYPE n VALUE 1,
valid TYPE c.
DATA t_bapi_essr LIKE bapiessrc OCCURS 0.
DATA t_bapi_essr_log LIKE bapiessrc OCCURS 0 WITH HEADER LINE.
DATA t_bapi_esll LIKE bapiesllc OCCURS 0.
DATA t_bapi_esll_log LIKE bapiesllc OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF output_prot OCCURS 0.
INCLUDE STRUCTURE essr.
INCLUDE STRUCTURE bdcmsgcoll.
DATA: END OF output_prot.
DATA: BEGIN OF i_sgcses_struc OCCURS 0,
po_number LIKE zbapiessrc_chars-po_number,
po_item LIKE zbapiessrc_chars-po_item,
short_text LIKE zbapiessrc_chars-short_text,
xblnr LIKE essr-xblnr,
ref_date LIKE zbapiessrc_chars-ref_date,
service LIKE zbapiesllc_chars-service,
flag,
quantity LIKE zbapiesllc_chars-quantity,
final,
END OF i_sgcses_struc.
start of insert >>>
DATA: l_ses_no LIKE essr-lblni.
TYPES: BEGIN OF t_ekpo,
ebeln LIKE ekpo-ebeln,
ebelp LIKE ekpo-ebelp,
werks LIKE ekpo-werks,
packno LIKE ekpo-packno,
END OF t_ekpo.
DATA: i_ekpo TYPE STANDARD TABLE OF t_ekpo.
end of insert <<<
$$----
S E L E C T I O N S C R E E N -
PARAMETERS: p_path TYPE localfile DEFAULT
'C: empBasellInterfacesSesSES-Daten'.
***parameters: p_dismod type ctu_mode default 'A'.
PARAMETERS: p_dismod TYPE ctu_mode DEFAULT 'E'.
PARAMETERS: p_spnam TYPE tsp01-rq2name DEFAULT 'SES_UPL.....'
OBLIGATORY.
PARAMETERS: cb_serv AS CHECKBOX DEFAULT 'X'.
PARAMETERS: cb_text AS CHECKBOX DEFAULT 'X'.
PARAMETERS: cb_chck AS CHECKBOX DEFAULT 'X'.
$$----
A T S E L E C T I O N S C R E E N -
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
DATA: len TYPE i,
testchar(1).
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
mask = 'C:*.txt'
static = 'X'
CHANGING
file_name = p_path.
DESCRIBE FIELD p_path LENGTH len IN CHARACTER MODE.
DO len TIMES.
len = len - 1.
testchar = p_path+len(1).
IF testchar = ''.
len = len + 1.
p_path = p_path(len).
EXIT.
ENDIF.
ENDDO.
$$----
S T A R T O F S E L E C T I O N -
START-OF-SELECTION.
PERFORM select_files.
PERFORM spool_settings.
PERFORM upload_files.
PERFORM select_additional_data.
$$----
E N D O F S E L E C T I O N -
END-OF-SELECTION.
PERFORM spool_settings.
CLEAR: perc_uploaded, no_of_files, text_uploaded.
DESCRIBE TABLE t_bapiessrc LINES no_of_files.
Loop over header-records: for each header-record one call transaction:
LOOP AT t_bapiessrc.
perc_uploaded = ( 100 * sy-tabix ) / no_of_files.
IF cb_serv = 'X'.
PERFORM prepare_clipboard.
Upload Service Entry Sheets:
PERFORM call_transaction_upload.
Italian Version begin
IMPORT output_prot FROM MEMORY ID 'OUT_PROT'.
PERFORM write_prot_to_spool.
FREE MEMORY ID 'OUT_PROT'.
REFRESH: output_prot.
Italian Version end
PERFORM find_ses_number.
PERFORM check_estimated_value.
ENDIF.
IF cb_text = 'X'.
Upload SES Texts:
PERFORM upload_texts.
ENDIF.
start of insert >>>
PERFORM change_account.
IF cb_serv = 'X'.
PERFORM release_ses.
ENDIF.
end of insert <<<
ENDLOOP.
In case only text and no services shall be uploaded:
IF NOT cb_text IS INITIAL.
In case also services are uploaded this loop won't apply cause
t_headertext-entries are deleted after they were processed in the
loop above!
LOOP AT t_headertext.
MOVE t_headertext-ext_number TO t_bapiessrc-ext_number.
*only for test cases since data file is not correct:
move t_headertext-ext_number to t_bapiessrc-ref_doc_no.
*only for test cases since data file is not correct:END
PERFORM upload_texts.
ENDLOOP.
ENDIF.
PERFORM log_upload_success.
NEW-PAGE PRINT OFF.
PERFORM delete_files.
WRITE: / text-001.
write: / 'Check spools for correct processing (Transaction SP01)!'.
$$----
T O P O F P A G E -
TOP-OF-PAGE.
*--at user-command--
AT USER-COMMAND.
*--top of page-during line selection--
TOP-OF-PAGE DURING LINE-SELECTION.
$$----
F O R M - R O U T I N E S -
*& Form SPLIT_BAPIESSRC
FORM split_bapiessrc.
DATA: l_score_time(3),
l_score_qual(3),
l_essr_lblni LIKE essr-lblni.
start of insert >>>
TABLES: esuc.
DATA: l_packno LIKE ekpo-packno.
end of insert <<<
CLEAR: t_bapiessrc, ekpo_konnr, ekpo_ktpnr, ekpo.
TRANSLATE doc_content-line USING '#;'. ZBAPIESSRC_CHARS
SPLIT AT '§' INTO
t_bapiessrc-sheet_no t_bapiessrc-ext_number
t_bapiessrc-person_int t_bapiessrc-person_ext
t_bapiessrc-location t_bapiessrc-ref_date
t_bapiessrc-begdate t_bapiessrc-enddate
t_bapiessrc-pckg_no t_bapiessrc-short_text
Only for testing due to wrong data
t_bapiessrc-po_number t_bapiessrc-po_item
ekpo_konnr ekpo_ktpnr
Only for testing due to wrong data END
t_bapiessrc-block_ind t_bapiessrc-score_time
t_bapiessrc-score_qual t_bapiessrc-doc_date
t_bapiessrc-post_date t_bapiessrc-ref_doc_no
Only for testing due to wrong data
t_bapiessrc-po_number t_bapiessrc-po_item
Only for testing due to wrong data END
t_bapiessrc-accasscat t_bapiessrc-comm_no
t_bapiessrc-user_field t_bapiessrc-acceptance
Only for testing due to wrong data
ekpo_konnr ekpo_ktpnr t_bapiessrc-final.
Only for testing due to wrong data END
MOVE '0000000001' TO t_bapiessrc-pckg_no.
SHIFT t_bapiessrc-po_item RIGHT DELETING TRAILING space.
TRANSLATE t_bapiessrc-po_item USING ' 0'.
start of delete >>>
IF NOT ekpo_konnr IS INITIAL AND NOT ekpo_ktpnr IS INITIAL.
SELECT SINGLE konnr ktpnr FROM ekpo
INTO (ekpo-konnr, ekpo-ktpnr)
WHERE ebeln = t_bapiessrc-po_number
AND ebelp = t_bapiessrc-po_item.
IF NOT sy-subrc IS INITIAL.
WRITE:/ text-101, t_bapiessrc-ext_number,
text-102,
t_bapiessrc-po_number,
text-103,
t_bapiessrc-po_item,
text-104.
WRITE: / text-105.
EXIT.
ELSE.
IF ekpo_konnr NE ekpo-konnr OR ekpo_ktpnr NE ekpo-ktpnr.
WRITE:/ text-101, t_bapiessrc-ext_number,
text-106,
ekpo_konnr, '/',
ekpo_ktpnr,
text-107,
t_bapiessrc-po_number,
text-103, t_bapiessrc-po_item, ')'.
WRITE: / text-105.
EXIT.
ENDIF.
ENDIF.
ENDIF.
end of delete <<<
start of insert >>>
" check contract number
IF NOT ekpo_konnr IS INITIAL AND NOT ekpo_ktpnr IS INITIAL.
SELECT SINGLE konnr ktpnr packno
FROM ekpo
INTO (ekpo-konnr, ekpo-ktpnr, l_packno)
WHERE ebeln = t_bapiessrc-po_number
AND ebelp = t_bapiessrc-po_item.
IF sy-subrc NE 0.
" no corresponding PO, no update will be performed
WRITE:/ text-101, t_bapiessrc-ext_number,
text-102,
t_bapiessrc-po_number,
text-103,
t_bapiessrc-po_item,
text-104.
WRITE: / text-105.
EXIT.
ELSE.
" check contract number against table ESUC first.
SELECT SINGLE *
FROM esuc
WHERE packno EQ l_packno
AND ebeln EQ ekpo_konnr
AND ebelp EQ ekpo_ktpnr.
IF sy-subrc NE 0.
" check against PO line
IF ekpo_konnr NE ekpo-konnr OR ekpo_ktpnr NE ekpo-ktpnr.
WRITE:/ text-101, t_bapiessrc-ext_number,
text-106,
ekpo_konnr, '/',
ekpo_ktpnr,
text-107,
t_bapiessrc-po_number,
text-103, t_bapiessrc-po_item, ')'.
WRITE: / text-105.
EXIT.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
end of insert <<<
IF cb_chck = 'X'.
SELECT SINGLE lblni FROM essr INTO l_essr_lblni
WHERE loekz = ' '
AND user1 = t_bapiessrc-ext_number.
IF sy-subrc IS INITIAL.
WRITE:/ 'External SES', t_bapiessrc-ext_number,
'is already uploaded. SES-Number: ', l_essr_lblni.
WRITE: / 'No update of this sheet was accomplished!'.
EXIT.
ENDIF.
ENDIF.
APPEND t_bapiessrc.
ENDFORM. " SPLIT_BAPIESSRC
*& Form SPLIT_BAPIESLLC
FORM split_bapiesllc.
DATA: l_outl_level(3), l_ovf_tol(3), l_price_unit(5), l_gr_price(23),
l_target_val(23), l_userf2_num(13), l_quantity(13),
l_form_val1(13), l_form_val2(13), l_form_val3(13),
l_form_val4(13), l_form_val5(13), l_ext_number(16).
CLEAR: t_bapiesllc.
TRANSLATE doc_content-line USING '#;'.
SPLIT AT '§' INTO
t_bapiesllc-ext_number
t_bapiesllc-pckg_no t_bapiesllc-line_no
t_bapiesllc-ext_line t_bapiesllc-outl_level
t_bapiesllc-outl_no t_bapiesllc-outl_ind
t_bapiesllc-subpckg_no t_bapiesllc-service
t_bapiesllc-serv_type t_bapiesllc-edition
t_bapiesllc-ssc_item t_bapiesllc-ext_serv
t_bapiesllc-quantity t_bapiesllc-base_uom
t_bapiesllc-uom_iso t_bapiesllc-ovf_tol
t_bapiesllc-ovf_unlim t_bapiesllc-price_unit
t_bapiesllc-gr_price t_bapiesllc-from_line
t_bapiesllc-to_line t_bapiesllc-short_text
t_bapiesllc-distrib t_bapiesllc-pers_no
t_bapiesllc-wagetype t_bapiesllc-pln_pckg
t_bapiesllc-pln_line t_bapiesllc-con_pckg
t_bapiesllc-con_line t_bapiesllc-tmp_pckg
t_bapiesllc-tmp_line t_bapiesllc-ssc_lim
t_bapiesllc-limit_line t_bapiesllc-target_val
t_bapiesllc-basline_no t_bapiesllc-basic_line
t_bapiesllc-alternat t_bapiesllc-bidder
t_bapiesllc-supp_line t_bapiesllc-open_qty
t_bapiesllc-inform t_bapiesllc-blanket
t_bapiesllc-eventual t_bapiesllc-tax_code
t_bapiesllc-taxjurcode t_bapiesllc-price_chg
t_bapiesllc-matl_group t_bapiesllc-date
t_bapiesllc-begintime t_bapiesllc-endtime
t_bapiesllc-extpers_no t_bapiesllc-formula
t_bapiesllc-form_val1 t_bapiesllc-form_val2
t_bapiesllc-form_val3 t_bapiesllc-form_val4
t_bapiesllc-form_val5 t_bapiesllc-userf1_num
t_bapiesllc-userf2_num t_bapiesllc-userf1_txt
t_bapiesllc-userf2_txt t_bapiesllc-hi_line_no.
start of insert >>> "AP13022007i
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = t_bapiesllc-line_no
IMPORTING
output = t_bapiesllc-line_no.
end of insert <<< "AP13022007i
TRANSLATE t_bapiesllc-quantity USING ',.'.
MOVE '0000000002' TO t_bapiesllc-pckg_no. "TS20082002
APPEND t_bapiesllc.
ENDFORM. " SPLIT_BAPIESLLC
*& Form SELECT_FILES
FORM select_files.
CALL FUNCTION 'KCD_FRONT_END_DIRECTORY_READ'
EXPORTING
i_path = p_path
IMPORTING
E_PURE_PATH =
TABLES
e_directory = i_directory_list
EXCEPTIONS
download = 1
upload = 2
execute = 3
directory_not_exist = 4
directory = 5
OTHERS = 6
IF sy-subrc <> 0.
*{ REPLACE PS010306UPGR
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
MESSAGE w208(00) WITH 'Enter existing directory'(003).
*} REPLACE
EXIT.
ENDIF.
LOOP AT i_directory_list.
CHECK i_directory_list(1) CA 'KPLT'.
check i_directory_list cs '.XLS' or i_directory_list cs '.TXT'.
CHECK i_directory_list CS '.TXT'.
CLEAR i_directory_sel.
MOVE 'X' TO i_directory_sel-text(1).
MOVE i_directory_list(79) TO i_directory_sel-text+1(79).
APPEND i_directory_sel.
ENDLOOP.
CALL FUNCTION 'Z_SL018_POPUP_WITH_TEXT_TO_SEL'
EXPORTING
popup_title = 'Select Files for SES-Upload'
start_column = 10
start_row = 1
end_column = 50
end_row = 16
IMPORTING
sy_ucomm = sy-ucomm
TABLES
x_popuptext = i_directory_sel.
*Check which Files shall be uploaded:
LOOP AT i_directory_sel.
CHECK i_directory_sel-text(1) NE 'Y'.
DELETE i_directory_sel.
ENDLOOP.
SORT i_directory_sel.
DESCRIBE TABLE i_directory_sel LINES no_of_files.
ENDFORM. " SELECT_FILES
*& Form UPLOAD_FILES
FORM upload_files.
*{ INSERT PS010306UPGR
DATA: fname TYPE string.
*} INSERT
LOOP AT i_directory_sel.
CLEAR: file.
UNASSIGN: .
perc_uploaded = ( 100 * sy-tabix ) / no_of_files.
CONCATENATE i_directory_sel-text+1(31) 'uploaded from disk'
INTO text_uploaded
SEPARATED BY space.
CONCATENATE p_path i_directory_sel-text+1(31) INTO file.
Choose the right structure for <doc_content> and <wa_doc_content>
depending on file type K, P, T or L via assignment of field symbols:
CASE i_directory_sel-text+1(1).
WHEN 'K'. "Kopfdaten
ASSIGN t_bapiessrc_tab TO .
ENDCASE.
*{ REPLACE PS010306UPGR
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
FILENAME = FILE
TABLES
DATA_TAB = <DOC_CONTENT>
EXCEPTIONS
CONVERSION_ERROR = 1
FILE_OPEN_ERROR = 2
FILE_READ_ERROR = 3
INVALID_TABLE_WIDTH = 4
INVALID_TYPE = 5
NO_BATCH = 6
UNKNOWN_ERROR = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
OTHERS = 10.
fname = file.
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = fname
CHANGING
data_tab = 0.
CLEAR: text_fi_not_upl1, text_fi_not_upl2, continue_yn.
CONCATENATE 'File' i_directory_sel-text+1(21) ': upload failed!'
INTO text_fi_not_upl1 SEPARATED BY space.
MOVE 'Continue Program?' TO text_fi_not_upl2.
CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
EXPORTING
defaultoption = 'N'
textline1 = text_fi_not_upl1
textline2 = text_fi_not_upl2
titel = 'Upload Failed'
start_column = 25
start_row = 6
cancel_display = ' '
IMPORTING
answer = continue_yn.
IF continue_yn = 'N'.
EXIT.
ENDIF.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
Move uploaded File records line by line into correct internal table:
t_bapiessrc for K__.txt
t_bapiesllc for P__.txt
t_headertext for T__.txt
t_itemtext for L__.txt
LOOP AT .
IF NOT sy-subrc IS INITIAL. EXIT. ENDIF.
ENDDO.
CASE i_directory_sel-text+1(1).
WHEN 'K'. "Kopfdaten
PERFORM split_bapiessrc.
WHEN 'T'.
PERFORM split_headertext.
WHEN 'P'.
PERFORM split_bapiesllc.
WHEN 'L'.
PERFORM split_itemtext.
ENDCASE.
ENDLOOP.
ENDIF.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
percentage = perc_uploaded
text = text_uploaded.
ENDLOOP.
SORT t_bapiessrc BY ext_number.
SORT t_headertext BY ext_number linno.
SORT t_bapiesllc BY ext_number. "
SORT t_bapiesllc BY ext_number pckg_no line_no.
sort t_bapiesllc by ext_number line_no.
SORT t_itemtext BY ext_number ext_linno ext_line linno.
ENDFORM. " UPLOAD_FILES
*& Form PREPARE_CLIPBOARD
FORM prepare_clipboard.
CLEAR: clbp_content.
REFRESH: clbp_content.
DATA: l_line TYPE n.
DATA: l_tabix LIKE sy-tabix.
CLEAR l_tabix.
*Assemble the File-Structure out of the internal tables t_bapiessrc
and t_bapiesllc which is expected by the user exit
exit_saplmlsx_002 and move it to the clipboard:
MOVE 'K' TO clbp_content(1). "Flag for header record
MOVE t_bapiessrc TO clbp_content+1(246).
APPEND clbp_content.
READ TABLE t_bapiesllc WITH KEY ext_number = t_bapiessrc-comm_no
BINARY SEARCH.
CHECK sy-subrc IS INITIAL.
MOVE sy-tabix TO l_tabix.
insert dummy row for connection between pach_no and sub_packno:
CLEAR l_line.
CLEAR: clbp_content, t_bapiesllc.
ADD 1 TO l_line.
MOVE 'P' TO clbp_content(1). "Flag for service-record
MOVE l_line TO clbp_content+1(1).
MOVE '0000000001' TO t_bapiesllc-pckg_no.
MOVE '0000000002' TO t_bapiesllc-subpckg_no.
WRITE t_bapiesllc16(245) TO clbp_content3(245).
APPEND clbp_content.
CLEAR clbp_content.
ADD 1 TO l_line.
MOVE 'P' TO clbp_content(1).
MOVE l_line TO clbp_content+1(1).
WRITE t_bapiesllc261(245) TO clbp_content3(245).
APPEND clbp_content.
APPEND clbp_content.
CLEAR clbp_content.
ADD 1 TO l_line.
MOVE 'P' TO clbp_content(1).
MOVE l_line TO clbp_content+1(1).
MOVE 'E' TO clbp_content+2(1).
WRITE t_bapiesllc506(27) TO clbp_content3(245).
APPEND clbp_content.
CLEAR clbp_content.
end insert
LOOP AT t_bapiesllc FROM l_tabix.
CLEAR l_line.
CLEAR clbp_content.
IF t_bapiesllc-ext_number NE t_bapiessrc-ext_number.
EXIT.
ENDIF.
ADD 1 TO l_line.
MOVE 'P' TO clbp_content(1). "Flag for service-record
'P'-service records are split into three clipbord-lines since
structure t_bapiesllc is too long for one line
MOVE l_line TO clbp_content+1(1).
WRITE t_bapiesllc16(245) TO clbp_content3(245).
APPEND clbp_content.
CLEAR clbp_content.
ADD 1 TO l_line.
MOVE 'P' TO clbp_content(1).
MOVE l_line TO clbp_content+1(1).
WRITE t_bapiesllc261(245) TO clbp_content3(245).
APPEND clbp_content.
CLEAR clbp_content.
ADD 1 TO l_line.
MOVE 'P' TO clbp_content(1).
MOVE l_line TO clbp_content+1(1).
MOVE 'E' TO clbp_content+2(1).
WRITE t_bapiesllc506(27) TO clbp_content3(245).
APPEND clbp_content.
CLEAR clbp_content.
ENDLOOP.
******Italy version of upload
PERFORM include_italy.
export t_bapiessrc to memory id 'GER_ESSRC'.
export t_bapiesllc to memory id 'GER_ESLLC'.
EXPORT t_bapi_essr TO MEMORY ID 'GER_ESSRC'.
EXPORT t_bapi_esll TO MEMORY ID 'GER_ESLLC'.
CHECK 1 = 2.
******Italy version of upload END
CALL FUNCTION 'CLPB_EXPORT'
TABLES
data_tab = clbp_content
EXCEPTIONS
clpb_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " PREPARE_CLIPBOARD
*& Form CALL_TRANSACTION_UPLOAD
FORM call_transaction_upload.
REFRESH bdcdata.
PERFORM bdc_dynpro USING: 'RM11RL00' '1000'.
PERFORM bdc_field USING: 'BDC_OKCODE' '=UPL'.
PERFORM bdc_field USING: 'S_LBLNI-LOW' ' '.
PERFORM bdc_field USING: 'S_LBLNI-HIGH' ' '.
PERFORM bdc_field USING: 'P_BSTNR' ' '.
PERFORM bdc_field USING: 'S_BSTPO-LOW' ' '.
PERFORM bdc_field USING: 'S_BSTPO-HIGH' ' '.
*Italian upload version -> comments set|remove comments for Germ.Version
perform bdc_dynpro using: 'SAPLMLSX' '0480'.
perform bdc_field using: 'BDC_OKCODE' '=EXEC'.
perform bdc_dynpro using: 'SAPLGRAP' '0210'.
perform bdc_field using: 'BDC_OKCODE' '=UPL_FR_CLP'.
PERFORM bdc_dynpro USING: 'SAPMSSY0' '0120'.
perform bdc_field using: 'MARKIERT' 'X'.
*Italian upload version -> comments set; END
CASE p_dismod.
WHEN 'A'.
PERFORM bdc_field USING: 'BDC_OKCODE' '=LITE'.
WHEN 'N'.
PERFORM bdc_field USING: 'BDC_OKCODE' '=HIND'.
WHEN 'E'.
PERFORM bdc_field USING: 'BDC_OKCODE' '=DARK'.
ENDCASE.
Here the call transcation of SAP-standard takes place for creating the
service entry sheet
After SAP-standard call transaction: analyze the popup with the
*Italian upload version -> comments set|remove comments for Germ.Version
PERFORM bdc_dynpro USING: 'SAPMSSY0' '0120'.
perform bdc_field using: 'BDC_OKCODE' '=PRI'.
perform bdc_dynpro using: 'SAPLSPRI' '0100'.
perform bdc_field using: 'BDC_OKCODE' '=PRIN'.
perform bdc_field using: 'PRI_PARAMS-PLIST' p_spnam.
perform bdc_field using: 'PRI_PARAMS-PRIMM' ' '.
perform bdc_field using: 'PRI_PARAMS-PRREL' ' '.
perform bdc_field using: 'PRI_PARAMS-PRNEW' ' '.
perform bdc_dynpro using: 'SAPMSSY0' '0120'.
perform bdc_field using: 'BDC_OKCODE' '=EXEC'.
*Italian upload version -> remove the following line for Germ. version:
PERFORM bdc_field USING: 'BDC_OKCODE' '/00'.
w_mode = p_dismod.
currently w_mode and p_dismod are set to the same value:
foregroud, background or error. But it could also be set to differnt
values: Foreground for upload clipboard,
CALL TRANSACTION 'ML81' USING bdcdata MODE w_mode UPDATE c_update
MESSAGES INTO bdcmsgcoll.
ENDFORM. " CALL_TRANSACTION_UPLOAD
*& Form BDC_DYNPRO
FORM bdc_dynpro
USING program TYPE c
dynpro TYPE c.
CLEAR bdcdata.
bdcdata-program = program.
bdcdata-dynpro = dynpro.
bdcdata-dynbegin = 'X'.
APPEND bdcdata.
ENDFORM. " BDC_DYNPRO
*& Form BDC_FIELD
FORM bdc_field
USING fnam TYPE c
fval TYPE c.
CLEAR bdcdata.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
APPEND bdcdata.
ENDFORM. " BDC_FIELD
*& Form UPLOAD_TEXTS
FORM upload_texts.
DATA l_lblni LIKE essr-lblni.
DATA l_tabix_header_start LIKE sy-tabix.
DATA l_tabix_item_start LIKE sy-tabix.
DATA: p(2) TYPE c.
DATA: w LIKE sy-index.
DATA: w_field(20) TYPE c.
DATA: l_ext_line_save LIKE t_itemtext-ext_line.
DATA: l_ext_linno_save LIKE t_itemtext-ext_linno.
DATA: l_extrow(10)." like ml_esll-extrow.
DATA: l_messg LIKE message.
DATA: l_msgno LIKE sy-msgno.
*only for test cases since data file is not correct:
read table t_headertext with key ext_number = t_bapiessrc-ref_doc_no.
READ TABLE t_headertext WITH KEY ext_number = t_bapiessrc-ext_number
BINARY SEARCH.
*only for test cases since data file is not correct:END
IF NOT sy-subrc IS INITIAL.
MESSAGE ID 'ZV' TYPE 'I' NUMBER '011'
WITH text-202.
WRITE: / text-202.
EXIT.
ENDIF.
l_tabix_header_start = sy-tabix.
SELECT SINGLE MAX( lblni ) FROM essr INTO l_lblni
where xblnr = t_headertext-ext_number.
WHERE user1 = t_headertext-ext_number
AND loekz = ' '.
IF NOT sy-subrc IS INITIAL.
MESSAGE ID 'ZV' TYPE 'I' NUMBER '011'
WITH text-203.
WRITE: / text-203.
EXIT.
ENDIF.
CLEAR: bdcdata, bdcmsgcoll.
REFRESH: bdcdata, bdcmsgcoll.
PERFORM bdc_dynpro USING 'RM11RL00' '1000'.
PERFORM bdc_field USING 'BDC_OKCODE' '=ONLI'.
PERFORM bdc_field USING 'S_LBLNI-LOW' l_lblni. " '1000001748'.
PERFORM bdc_field USING 'BDC_CURSOR' 'P_LIST'.
PERFORM bdc_field USING 'P_LIST' ' '.
PERFORM bdc_field USING 'P_DIRECT' 'X'.
PERFORM bdc_field USING 'P_LISTU' ' '.
PERFORM bdc_dynpro USING 'SAPLMLSR' '0100'.
PERFORM bdc_field USING 'BDC_OKCODE' '=TXT'.
perform bdc_field using 'ESSR-TXZ01' t_headertext-txline(40).
PERFORM bdc_dynpro USING 'SAPLSTXX' '1100'.
PERFORM bdc_field USING 'BDC_OKCODE' '=TXBA'.
CLEAR w.
ADD 1 TO w.
LOOP AT t_headertext FROM l_tabix_header_start.
Is t_bapiessrc-ext_number really filled?
IF t_headertext-ext_number NE t_bapiessrc-ext_number.
EXIT.
ENDIF.
ADD 1 TO w.
UNPACK w TO p.
CLEAR w_field.
w_field+00(17) = 'RSTXT-TXPARGRAPH('.
w_field+17(02) = p.
w_field+19(01) = ')'.
PERFORM bdc_field USING w_field t_headertext-txpargraph.
CLEAR w_field.
w_field+00(13) = 'RSTXT-TXLINE('.
w_field+13(02) = p.
w_field+15(01) = ')'.
PERFORM bdc_field USING w_field t_headertext-txline .
delete line from internal table so that Upload Texts is not
processed twice when perform_upload_texts is called without up-
loading services:
DELETE t_headertext.
ENDLOOP.
PERFORM bdc_dynpro USING 'SAPLMLSR' '0100'.
PERFORM bdc_field USING 'BDC_OKCODE' '=SERV'.
PERFORM bdc_dynpro USING 'SAPLMLSP' '0210'.
PERFORM bdc_field USING 'BDC_OKCODE' 'ENTER'.
READ TABLE t_itemtext WITH KEY
ext_number = t_bapiessrc-ext_number.
l_tabix_item_start = sy-tabix.
CLEAR l_ext_line_save.
LOOP AT t_itemtext FROM l_tabix_item_start.
IF t_itemtext-ext_number NE t_bapiessrc-ext_number.
EXIT.
ENDIF.
SHIFT t_itemtext-ext_line RIGHT DELETING TRAILING space.
TRANSLATE t_itemtext-ext_line USING ' 0'.
IF ( t_itemtext-ext_line NE l_ext_line_save )
OR ( t_itemtext-ext_linno NE l_ext_linno_save ).
***find line number:
break michalska.
SELECT SINGLE extrow FROM ml_esll INTO l_extrow
WHERE extrow = t_itemtext-ext_linno
AND srvpos = t_itemtext-ext_line
AND ebeln = l_lblni.
IF NOT sy-subrc IS INITIAL.
CONTINUE.
ENDIF.
PERFORM bdc_dynpro USING 'SAPLMLSP' '0210'.
PERFORM bdc_field USING 'BDC_OKCODE' 'ENTER'.
PERFORM bdc_field USING 'RM11P-NEW_ROW' l_extrow.
PERFORM bdc_dynpro USING 'SAPLMLSP' '0210'.
PERFORM bdc_field USING 'BDC_OKCODE' '=ZLT'.
PERFORM bdc_field USING 'BDC_CURSOR' 'ESLL-EXTROW(01)'.
PERFORM bdc_field USING 'RM11P-SELKZ(01)' 'X'.
PERFORM bdc_dynpro USING 'SAPLSTXX' '1100'.
PERFORM bdc_field USING 'BDC_OKCODE' '=TXBA'.
CLEAR w.
ADD 1 TO w.
ENDIF.
ADD 1 TO w.
UNPACK w TO p.
CLEAR w_field.
w_field+00(17) = 'RSTXT-TXPARGRAPH('.
w_field+17(02) = p.
w_field+19(01) = ')'.
PERFORM bdc_field USING w_field t_itemtext-txpargraph.
CLEAR w_field.
w_field+00(13) = 'RSTXT-TXLINE('.
w_field+13(02) = p.
w_field+15(01) = ')'.
PERFORM bdc_field USING w_field t_itemtext-txline .
l_ext_line_save = t_itemtext-ext_line.
l_ext_linno_save = t_itemtext-ext_linno.
ENDLOOP.
PERFORM bdc_dynpro USING 'SAPLMLSP' '0210'.
PERFORM bdc_field USING 'BDC_OKCODE' '=SAV'.
CALL TRANSACTION 'ML81' USING bdcdata MODE p_dismod UPDATE c_update
MESSAGES INTO bdcmsgcoll.
LOOP AT bdcmsgcoll.
IF sy-tabix = 1.
WRITE AT: /1 text-002,
write at: /1 'Log for text uploads of entry sheet ',
37 l_lblni, 48 ':'.
ENDIF.
check bdcmsgcoll-msgtyp = 'E' or bdcmsgcoll-msgtyp = 'A'.
CHECK bdcmsgcoll-msgnr CO ' 0123456789'.
MOVE bdcmsgcoll-msgnr TO l_msgno.
CALL FUNCTION 'WRITE_MESSAGE'
EXPORTING
msgid = bdcmsgcoll-msgid
msgno = l_msgno
msgty = bdcmsgcoll-msgtyp
msgv1 = bdcmsgcoll-msgv1
msgv2 = bdcmsgcoll-msgv2
msgv3 = bdcmsgcoll-msgv3
msgv4 = bdcmsgcoll-msgv4
IMPORTING
messg = l_messg.
WRITE AT: /3 l_messg-msgtx.
ENDLOOP.
ENDFORM. " UPLOAD_TEXTS
*& Form SPLIT_HEADERTEXT
FORM split_headertext.
DATA: l_essr_lblni LIKE essr-lblni.
CLEAR: t_headertext.
TRANSLATE doc_content-line USING '#;'. ZBAPIESSRC_CHARS
SPLIT AT '§' INTO
t_headertext-ext_number
t_headertext-linno
t_headertext-tcode
t_headertext-recordname
t_headertext-txpargraph
t_headertext-txline
t_headertext-text_mark.
start of insert >>>
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = t_headertext-linno
IMPORTING
output = t_headertext-linno.
end of insert <<<
IF cb_chck = 'X'.
SELECT SINGLE lblni FROM essr INTO l_essr_lblni
WHERE loekz = ' '
AND user1 = t_headertext-ext_number.
IF sy-subrc IS INITIAL.
IF t_headertext-linno = 1.
WRITE:/ 'External SES', t_headertext-ext_number,
'is already uploaded. SES-Number: ', l_essr_lblni.
WRITE: / 'No update of this sheet-texts was accomplished!'.
ENDIF.
EXIT.
ENDIF.
ENDIF.
start of insert >>>
IF NOT cb_serv IS INITIAL.
" check
READ TABLE t_bapiessrc WITH KEY ext_number = t_headertext-ext_number
BINARY SEARCH.
IF sy-subrc NE 0.
EXIT.
ENDIF.
ENDIF.
end of insert <<<
APPEND t_headertext.
ENDFORM. " SPLIT_HEADERTEXT
*& Form SPLIT_ITEMTEXT
FORM split_itemtext.
DATA: l_essr_lblni LIKE essr-lblni.
CLEAR: t_itemtext.
TRANSLATE doc_content-line USING '#;'. ZBAPIESSRC_CHARS
SPLIT AT '§' INTO
t_itemtext-ext_number
t_itemtext-ext_line
t_itemtext-linno
t_itemtext-tcode
t_itemtext-recordname
t_itemtext-txpargraph
t_itemtext-txline
t_itemtext-text_mark
t_itemtext-ext_linno.
start of insert >>>
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = t_itemtext-ext_linno
IMPORTING
output = t_itemtext-ext_linno.
end of insert <<<
IF cb_chck = 'X'.
SELECT SINGLE lblni FROM essr INTO l_essr_lblni
WHERE loekz = ' '
AND user1 = t_itemtext-ext_number.
IF sy-subrc IS INITIAL.
write:/ 'External SES', t_itemtext-ext_number,
'is already uploaded. SES-Number: ', l_essr_lblni.
write: / 'No update of this sheet was accomplished!'.
EXIT.
ENDIF.
ENDIF.
APPEND t_itemtext.
ENDFORM. " SPLIT_ITEMTEXT
start of delete >>>
*& Form SPOOL_SETTINGS
*FORM spool_settings.
MOVE p_spnam TO list_text.
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING " destination = 'dest'
copies = 1
list_name = p_spnam
list_text = list_text
immediately = ' '
release = ' '
new_list_id = ' '
expiration = 9
line_size = 125
line_count = 23
layout = 'X_65_132'
sap_cover_page = ' '
receiver = 'SAP*'
department = 'System'
no_dialog = 'X'
IMPORTING
out_parameters = params
valid = valid.
IF valid <> space.
NEW-PAGE PRINT ON PARAMETERS params NO DIALOG.
ENDIF.
*ENDFORM. " SPOOL_SETTINGS
end of delete <<<
*& Form DELETE_FILES
text
--> p1 text
<-- p2 text
FORM delete_files.
*{ REPLACE PS010306UPGR
DATA: l_return.
DATA: l_return TYPE i.
DATA: fname TYPE string.
*} REPLACE
LOOP AT i_directory_sel.
move space to i_directory_sel-text(1).
MOVE 'X' TO i_directory_sel-text(1).
MODIFY i_directory_sel.
ENDLOOP.
*{ REPLACE
CLEAR i_directory_sel.
MOVE'Xdir_file.bat' TO i_directory_sel-text.
APPEND i_directory_sel.
CLEAR i_directory_sel.
MOVE'Xdir_file.txt' TO i_directory_sel-text.
APPEND i_directory_sel.
DATA: l_directory_list LIKE rlgrap-filename OCCURS 0 WITH HEADER LINE.
CALL FUNCTION 'KCD_FRONT_END_DIRECTORY_READ'
EXPORTING
i_path = p_path
TABLES
e_directory = l_directory_list
EXCEPTIONS
OTHERS = 6.
IF sy-subrc <> 0.
LOOP AT l_directory_list.
IF l_directory_list CS 'dir_file.bat'.
CLEAR i_directory_sel.
MOVE'Xdir_file.bat' TO i_directory_sel-text.
APPEND i_directory_sel.
ELSEIF l_directory_list CS 'dir_file.txt'.
CLEAR i_directory_sel.
MOVE'Xdir_file.txt' TO i_directory_sel-text.
APPEND i_directory_sel.
ENDIF.
ENDLOOP.
ENDIF.
CALL FUNCTION 'Z_SL018_POPUP_WITH_TEXT_TO_SEL'
EXPORTING
popup_title = 'Select Files for DELETION'
start_column = 10
start_row = 1
end_column = 50
end_row = 16
IMPORTING
sy_ucomm = sy-ucomm
TABLES
x_popuptext = i_directory_sel.
*Check which Files shall be uploaded:
CHECK sy-ucomm = 'OK'.
LOOP AT i_directory_sel.
CHECK i_directory_sel-text(1) = 'Y'.
CLEAR file.
CONCATENATE p_path i_directory_sel-text+1(31) INTO file.
*{ REPLACE PS010306UPGR
CALL FUNCTION 'WS_FILE_DELETE'
EXPORTING
FILE = FILE
IMPORTING
RETURN = L_RETURN.
fname = file.
CALL METHOD cl_gui_frontend_services=>file_delete
EXPORTING
filename = fname
CHANGING
rcHI
add that fileds in the all locations where you need it like
in internal table declaration , write statement , select statement
these are the main areas where you have to add that 2 fileds -
Hi all,
Can I copy a file from one folder to other folder and delete this file from the first folder using abap?
For example there is a folder at
C:\Etc\Test and I want to copy this file to folder xyz as:
C:\XYZ\Test
How can I do that and delete the C:\Etc\Test?
Thanks.
deniz.Hi,
Check this code...
DATA: w_file_name TYPE string,
w_file_path TYPE string,
full_path TYPE string,
action TYPE i,
name TYPE string VALUE 'SAVE',
filetable TYPE filetable,
file TYPE string,
rc TYPE i.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
* EXPORTING
* window_title =
* default_extension =
* default_filename =
* file_filter =
* with_encoding =
* initial_directory =
* multiselection =
CHANGING
file_table = filetable
rc = rc
READ TABLE filetable INTO file index 1.
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
* window_title = name
* initial_directory = 'c:\Documents and Settings\2q\Desktop'
* prompt_on_overwrite = 'X'
default_file_name = name
CHANGING
filename = w_file_name
path = w_file_path
fullpath = full_path
user_action = action
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
CALL METHOD cl_gui_frontend_services=>file_copy
EXPORTING
SOURCE = file
DESTINATION = full_path
CALL METHOD cl_gui_frontend_services=>file_delete
EXPORTING
filename = file
CHANGING
rc = rc.
Edited by: Sukriti Saha on Nov 5, 2008 1:09 PM -
Delete flat file from the local drive after downloading in the program
how to <b>delete flat file from the local drive after downloading in the program</b>
I am using gui_upload to upload flat file data in internal table. and after that i dont want that flat file in the disk. i want to delete it.Once the file has been uploaded into the internal table call the<b> FILE_DELETE </b>method of the class <b>CL_GUI_FRONTEND_SERVICES</b>.
DATA: v_rc TYPE i.
CALL METHOD cl_gui_frontend_services=>file_delete
EXPORTING
filename = 'C:\TEMP\MATERIAL.TXT'
CHANGING
rc = v_rc
EXCEPTIONS
file_delete_failed = 1
cntl_error = 2
error_no_gui = 3
file_not_found = 4
access_denied = 5
unknown_error = 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
Kathirvel -
Function module to read the directory list and also run in background
Hi All,
I need to read few files from a folder in the server and upload the data in the file using a BDC. This process has to happen in the background as I am going to schedule the program. I had used the function module "EPS_GET_DIRECTORY_LISTING" to list the file names, it is working properly but when I schedule the program this function module does not work, the jobs gets finished in 0 secs. I am suspecting that it is not running in back ground. Can any one suggest me the function module which runs in background to read the files or an alternate method.
AjeethaThanks for the reply.
Sorry, this function module is working properly, why I assumed it is not working is that the background job got completed in 0 secs which made me feel that the function module is not working. Also I am subsequently copying the file to another folder and deleting it from the source folder, actually thiese two functionalities are not working in background. which added to my conclusion that all the function modules are not working in background. I am using two methods to copy and delete files, they are
CL_GUI_FRONTEND_SERVICES=>FILE_COPY,
CL_GUI_FRONTEND_SERVICES=>FILE_DELETE.
as these are not working in background, now I need to replace them with a method or function module which will run in background.
As I have mentioned earlier, my main objective is to upload the data in the file using a bdc. If I am not able to delete the file in the source folder, then duplicate upload will happen which I have to avoid. So, if someone could help me to find a way to delete the file will be of great help to me.
Ajeetha -
How to delete a local file in the presentation server.
Hi All,
How to delete a local file in the presentation server. As we do using 'delete dataset dsn' in application server. How can i achieve this. My requirement is after uploading file using gui_upload, i want to delete that source file. Please let me know, how can i achieve this.
Thanks in advance.
Regards,
Vishaldata: l_rc type i.
data: f_name type string.
move 'c:\YourFile.txt' to f_name.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_DELETE
EXPORTING
FILENAME = f_name
CHANGING
RC = l_rc
EXCEPTIONS
FILE_DELETE_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
FILE_NOT_FOUND = 4
ACCESS_DENIED = 5
UNKNOWN_ERROR = 6
NOT_SUPPORTED_BY_GUI = 7
WRONG_PARAMETER = 8
others = 9
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF. -
Issue in Download file - If the file name is same
Hi Experts,
I have a requirement to download the company code hierarchy data into a file. On selection screen I am giving the file path along with the file name If I run the report it is downloading the data into the particular file in the file path this is expected result but if i am running the report with same filename which is already exists in the same path then instead of replacing the file with new data it is appending the data to that file.
But my expected result is: If the file name is same, file should be replaced with the Current Data instead of Appending the file.
And this issue is happening for the file formats TXT and CSV and also this issue is happening only when i am saving to the local drive.
I executed the report by giving the file name Eg: " XXXX.xls" extension even in this case the records getting replaced with the new data, problem is when the file extension is with TXT and CSV formats.
FYI... to download the data i am using the below funtion module and i am passing the below parameters: Please correct me if i am wrong.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = G_LFILE
FILETYPE = G_FILETYPE
APPEND = 'X'
WRITE_FIELD_SEPARATOR = GC_FIELDSEP " Passing X
TRUNC_TRAILING_BLANKS = GC_TRUNCBLNKS " Passing X
DAT_MODE = GC_DATMODE "Passing X
CODEPAGE = G_LCODEPAGE
TABLES
DATA_TAB = GT_ITAB_HIER1
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22
IF SY-SUBRC <> 0.
G_FNAME = G_LFILE.
MESSAGE E043(ZFI) WITH G_FNAME.
ENDIF.
Can any one please provide me the solution.
Thanks in advance.
KoushikHi all,
Issue got resolve. I have used the class CL_GUI_FRONTEND_SERVICES
and the methods file_delete and file_exist. below is the sample code :
1) Write the below code in subroutine “PEFORM FILL_DATA_FILE” to check the given file exists in the directory or not.
DATA: lv_FILENAME TYPE STRING,
lv_RESULT TYPE C,
lv_rc TYPE i.
lv_FILENAME = g_lfile.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_EXIST
EXPORTING
FILE = lv_FILENAME
RECEIVING
RESULT = lv_RESULT
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
WRONG_PARAMETER = 3
NOT_SUPPORTED_BY_GUI = 4
OTHERS = 5.
IF lv_RESULT = 'X'.
lV_RC = '1'.
ELSE.
lV_RC = '0'.
ENDIF.
2) If the given file is exists in the directory(or in the given file path) delete or modify that file with the current data
for that add the below code :
IF lv_rc = 1.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_DELETE
EXPORTING
FILENAME = lv_FILENAME
CHANGING
RC = lv_RC
EXCEPTIONS
FILE_DELETE_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
FILE_NOT_FOUND = 4
ACCESS_DENIED = 5
UNKNOWN_ERROR = 6
NOT_SUPPORTED_BY_GUI = 7
WRONG_PARAMETER = 8
OTHERS = 9.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
Thanks,
koushik -
hi,
i am using gui_down load fm to down load the data into excel,but i need the excel sheet with headers,how to extract the data with field names.
i am using following code.
*& Report ZTEST *
REPORT ZTEST .
*DATA: BEGIN OF IT_PO_HEADER OCCURS 20,
BSART LIKE EKKO-BSART,
EBELN LIKE EKKO-EBELN,
SUPERFIELD LIKE MEPO_TOPLINE-SUPERFIELD,
BEDAT LIKE EKKO-BEDAT,
ZTERM LIKE EKKO-ZTERM,
NETWR LIKE EKKO-NETWR,
TABLES: EKKO.
*PARAMETERS : P_EBELN TYPE EBELN.
SELECT-OPTIONS: S_EBELN FOR EKKO-EBELN OBLIGATORY.
TYPES: BEGIN OF T_PO,
EBELN TYPE EBELN,
END OF T_PO.
DATA: IT_PO TYPE STANDARD TABLE OF T_PO,
WA_PO TYPE T_PO.
DATA : IT_ITEMS TYPE TABLE OF BAPIEKPO WITH HEADER LINE.
DATA: PO_ITEMS_SHEDULE TYPE TABLE OF BAPIEKET WITH HEADER LINE.
DATA: PO_ITEM_TEXT TYPE TABLE OF BAPIEKPOTX WITH HEADER LINE.
DATA: PO_ITEM_ACCOUNT_ASSIGNMENT TYPE TABLE OF BAPIEKKN
WITH HEADER LINE.
DATA: PO_HEADER_TEXTS TYPE TABLE OF BAPIEKKOTX WITH HEADER LINE.
DATA: PO_HEADER TYPE BAPIEKKOL.
DATA: RETURN1 TYPE TABLE OF BAPIRETURN WITH HEADER LINE.
data : begin of itab1 occurs 0,
line(750) type c,
end of itab1.
SELECT EBELN INTO TABLE IT_PO FROM EKKO WHERE EBELN IN S_EBELN.
PERFORM DOWNLOAD_DATA: TABLES IT_ITEMS USING SPACE.
LOOP AT IT_PO INTO WA_PO.
CLEAR: PO_HEADER_TEXTS[], IT_ITEMS[], PO_ITEM_ACCOUNT_ASSIGNMENT[],
PO_ITEMS_SHEDULE[], PO_ITEM_TEXT[], RETURN1[].
CALL FUNCTION 'BAPI_PO_GETDETAIL'
EXPORTING
PURCHASEORDER = WA_PO-EBELN
ITEMS = 'X'
ACCOUNT_ASSIGNMENT = 'x'
SCHEDULES = ' '
HISTORY = 'X'
ITEM_TEXTS = 'X'
HEADER_TEXTS = 'X'
TABLES
PO_HEADER_TEXTS = PO_HEADER_TEXTS
PO_ITEMS = IT_ITEMS
PO_ITEM_ACCOUNT_ASSIGNMENT = PO_ITEM_ACCOUNT_ASSIGNMENT
PO_ITEM_SCHEDULES = PO_ITEMS_SHEDULE
PO_ITEM_TEXTS = PO_ITEM_TEXT
RETURN = RETURN1.
PERFORM DOWNLOAD_DATA: TABLES PO_HEADER_TEXTS USING 'X',
TABLES IT_ITEMS USING 'X',
TABLES PO_ITEM_ACCOUNT_ASSIGNMENT USING 'X',
TABLES PO_ITEMS_SHEDULE USING 'X',
TABLES PO_ITEM_TEXT USING 'X'.
ENDLOOP.
*& Form DOWNLOAD_DATA
FORM DOWNLOAD_DATA TABLES IT_TAB
USING P_APP.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = 'C:/poextract.xls'
APPEND = P_APP
WRITE_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = IT_TAB
FIELDNAMES = FIELDNAME
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DOWNLOAD_DATA
Thanks,
Rammohan.Hi Ram
Please try with below code and let us know if you are still encountering the problem while downloading headers:
TABLES: EKKO.
*PARAMETERS : P_EBELN TYPE EBELN.
SELECT-OPTIONS: S_EBELN FOR EKKO-EBELN OBLIGATORY.
TYPES: BEGIN OF T_PO,
EBELN TYPE EBELN,
END OF T_PO.
DATA: IT_PO TYPE STANDARD TABLE OF T_PO,
WA_PO TYPE T_PO.
DATA : IT_ITEMS TYPE TABLE OF BAPIEKPO WITH HEADER LINE.
DATA: PO_ITEMS_SHEDULE TYPE TABLE OF BAPIEKET WITH HEADER LINE.
DATA: PO_ITEM_TEXT TYPE TABLE OF BAPIEKPOTX WITH HEADER LINE.
DATA: PO_ITEM_ACCOUNT_ASSIGNMENT TYPE TABLE OF BAPIEKKN
WITH HEADER LINE.
DATA: PO_HEADER_TEXTS TYPE TABLE OF BAPIEKKOTX WITH HEADER LINE.
DATA: PO_HEADER TYPE BAPIEKKOL.
DATA: RETURN1 TYPE TABLE OF BAPIRETURN WITH HEADER LINE.
DATA: RC TYPE I.
SELECT EBELN INTO TABLE IT_PO FROM EKKO WHERE EBELN IN S_EBELN.
PERFORM FILE_DELETE.
LOOP AT IT_PO INTO WA_PO.
CLEAR: PO_HEADER_TEXTS[], IT_ITEMS[], PO_ITEM_ACCOUNT_ASSIGNMENT[],
PO_ITEMS_SHEDULE[], PO_ITEM_TEXT[], RETURN1[].
CALL FUNCTION 'BAPI_PO_GETDETAIL'
EXPORTING
PURCHASEORDER = WA_PO-EBELN
ITEMS = 'X'
ACCOUNT_ASSIGNMENT = 'X'
SCHEDULES = ' '
HISTORY = 'X'
ITEM_TEXTS = 'X'
HEADER_TEXTS = 'X'
TABLES
PO_HEADER_TEXTS = PO_HEADER_TEXTS
PO_ITEMS = IT_ITEMS
PO_ITEM_ACCOUNT_ASSIGNMENT = PO_ITEM_ACCOUNT_ASSIGNMENT
PO_ITEM_SCHEDULES = PO_ITEMS_SHEDULE
PO_ITEM_TEXTS = PO_ITEM_TEXT
RETURN = RETURN1.
PERFORM DOWNLOAD_DATA: TABLES PO_HEADER_TEXTS USING 'BAPIEKKOTX',
TABLES IT_ITEMS USING 'BAPIEKPO',
TABLES PO_ITEM_ACCOUNT_ASSIGNMENT USING
'BAPIEKKN',
TABLES PO_ITEMS_SHEDULE USING 'BAPIEKET',
TABLES PO_ITEM_TEXT USING 'BAPIEKPOTX'.
ENDLOOP.
*& Form DOWNLOAD_DATA
FORM DOWNLOAD_DATA TABLES IT_TAB
USING STRUC_NAME.
DATA: IT_DD03P TYPE TABLE OF DD03P WITH HEADER LINE,
IT_DD03P1 TYPE TABLE OF DD03P WITH HEADER LINE.
DATA: IT_HEAD TYPE TABLE OF STRING,
WA_HEAD TYPE STRING.
DATA: L_TAB(1) TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
IF NOT IT_TAB[] IS INITIAL.
CALL FUNCTION 'DD_GET_DD03P_ALL'
EXPORTING
TABNAME = STRUC_NAME
TABLES
A_DD03P_TAB = IT_DD03P
N_DD03P_TAB = IT_DD03P1
EXCEPTIONS
ILLEGAL_VALUE = 1
OTHERS = 2.
IF SY-SUBRC EQ 0.
LOOP AT IT_DD03P.
IF SY-TABIX EQ 1.
MOVE IT_DD03P-DDTEXT TO WA_HEAD.
ELSE.
CONCATENATE WA_HEAD IT_DD03P-DDTEXT INTO WA_HEAD SEPARATED BY L_TAB.
ENDIF.
ENDLOOP.
APPEND WA_HEAD TO IT_HEAD.
ENDIF.
ENDIF.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = 'C:poextract.xls'
APPEND = 'X'
WRITE_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = IT_HEAD
* FIELDNAMES = IT_HEAD
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22.
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 FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = 'C:poextract.xls'
APPEND = 'X'
WRITE_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = IT_TAB
* FIELDNAMES = IT_HEAD
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DOWNLOAD_DATA
*& Form FILE_DELETE
FORM FILE_DELETE .
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_DELETE
EXPORTING
FILENAME = 'C:poextract.xls'
CHANGING
RC = RC
EXCEPTIONS
FILE_DELETE_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
FILE_NOT_FOUND = 4
ACCESS_DENIED = 5
UNKNOWN_ERROR = 6
NOT_SUPPORTED_BY_GUI = 7
WRONG_PARAMETER = 8
OTHERS = 9.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " FILE_DELETE
Kind Regards
Eswar -
HOW TO EXTRACT THE PO CONDITIONS
HI,
i am using the following code,but in this i am not geting the po conditions values,is there any way to get the condition values into excel sheet.
report ztest1.
TABLES: EKKO.
*PARAMETERS : P_EBELN TYPE EBELN.
SELECT-OPTIONS: S_EBELN FOR EKKO-EBELN OBLIGATORY.
TYPES: BEGIN OF T_PO,
EBELN TYPE EBELN,
END OF T_PO.
DATA: IT_PO TYPE STANDARD TABLE OF T_PO,
WA_PO TYPE T_PO.
DATA : IT_ITEMS TYPE TABLE OF BAPIEKPO WITH HEADER LINE.
DATA: PO_ITEMS_SHEDULE TYPE TABLE OF BAPIEKET WITH HEADER LINE.
DATA: PO_ITEM_TEXT TYPE TABLE OF BAPIEKPOTX WITH HEADER LINE.
DATA: PO_ITEM_ACCOUNT_ASSIGNMENT TYPE TABLE OF BAPIEKKN
WITH HEADER LINE.
DATA: PO_HEADER_TEXTS TYPE TABLE OF BAPIEKKOTX WITH HEADER LINE.
DATA: PO_HEADER TYPE BAPIEKKOL.
DATA: RETURN1 TYPE TABLE OF BAPIRETURN WITH HEADER LINE.
DATA: RC TYPE I.
SELECT EBELN INTO TABLE IT_PO FROM EKKO WHERE EBELN IN S_EBELN.
PERFORM FILE_DELETE.
LOOP AT IT_PO INTO WA_PO.
CLEAR: PO_HEADER_TEXTS[], IT_ITEMS[], PO_ITEM_ACCOUNT_ASSIGNMENT[],
PO_ITEMS_SHEDULE[], PO_ITEM_TEXT[], RETURN1[].
CALL FUNCTION 'BAPI_PO_GETDETAIL'
EXPORTING
PURCHASEORDER = WA_PO-EBELN
ITEMS = 'X'
ACCOUNT_ASSIGNMENT = 'X'
SCHEDULES = ' '
HISTORY = 'X'
ITEM_TEXTS = 'X'
HEADER_TEXTS = 'X'
TABLES
PO_HEADER_TEXTS = PO_HEADER_TEXTS
PO_ITEMS = IT_ITEMS
PO_ITEM_ACCOUNT_ASSIGNMENT = PO_ITEM_ACCOUNT_ASSIGNMENT
PO_ITEM_SCHEDULES = PO_ITEMS_SHEDULE
PO_ITEM_TEXTS = PO_ITEM_TEXT
RETURN = RETURN1.
PERFORM DOWNLOAD_DATA: TABLES PO_HEADER_TEXTS USING 'BAPIEKKOTX',
TABLES IT_ITEMS USING 'BAPIEKPO',
TABLES PO_ITEM_ACCOUNT_ASSIGNMENT USING
'BAPIEKKN',
TABLES PO_ITEMS_SHEDULE USING 'BAPIEKET',
TABLES PO_ITEM_TEXT USING 'BAPIEKPOTX'.
ENDLOOP.
*& Form DOWNLOAD_DATA
FORM DOWNLOAD_DATA TABLES IT_TAB
USING STRUC_NAME.
DATA: IT_DD03P TYPE TABLE OF DD03P WITH HEADER LINE,
IT_DD03P1 TYPE TABLE OF DD03P WITH HEADER LINE.
DATA: IT_HEAD TYPE TABLE OF STRING,
WA_HEAD TYPE STRING.
DATA: L_TAB(1) TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
IF NOT IT_TAB[] IS INITIAL.
CALL FUNCTION 'DD_GET_DD03P_ALL'
EXPORTING
TABNAME = STRUC_NAME
TABLES
A_DD03P_TAB = IT_DD03P
N_DD03P_TAB = IT_DD03P1
EXCEPTIONS
ILLEGAL_VALUE = 1
OTHERS = 2.
IF SY-SUBRC EQ 0.
LOOP AT IT_DD03P.
IF SY-TABIX EQ 1.
MOVE IT_DD03P-DDTEXT TO WA_HEAD.
ELSE.
CONCATENATE WA_HEAD IT_DD03P-DDTEXT INTO WA_HEAD SEPARATED BY L_TAB.
ENDIF.
ENDLOOP.
APPEND WA_HEAD TO IT_HEAD.
ENDIF.
ENDIF.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = 'C:\poextract.xls'
APPEND = 'X'
WRITE_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = IT_HEAD
FIELDNAMES = IT_HEAD
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22.
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 FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = 'C:\poextract.xls'
APPEND = 'X'
WRITE_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = IT_TAB
FIELDNAMES = IT_HEAD
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DOWNLOAD_DATA
*& Form FILE_DELETE
FORM FILE_DELETE .
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_DELETE
EXPORTING
FILENAME = 'C:\poextract.xls'
CHANGING
RC = RC
EXCEPTIONS
FILE_DELETE_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
FILE_NOT_FOUND = 4
ACCESS_DENIED = 5
UNKNOWN_ERROR = 6
NOT_SUPPORTED_BY_GUI = 7
WRONG_PARAMETER = 8
OTHERS = 9.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " FILE_DELETEHI Ram
Am not able to access SAP now, I guess FM: 'BAPI_PO_GETDETAIL' itself can return PO conditions as well. Please check the same.
Kind Regards
Eswar -
Documets remain in temp folder after viewing localy in SAP DMS
hi,
The wheever user view any docs using cv02n/cv03n the documetns are temporaly stored in user local temp folder.
as the documetns are still there after log off from SAP.
this way imp files are visible to other user.
is there any way to delete the file when we logoff from sap
ShivHi Shiv,
if you are using ECL Viewer or Office Integration for displaying originals in CV02N/CV03N you can use the OLE2 flag which is mentioned in SAP note 741388.
If you are using an external Viewer (%AUTO%) the OLE2 flag is not working.
As possible solution I can only offer you the following possibility.
Some time ago we developed a special solution for another customer
with the help of an implementation of BADI DOCUMENT_FILES01.
There exists the BAdI method DOCUMENT_FILES01~AFTER_START_APPL .
You can have an implementation like this, which might help to solve
your problem. This deletes the file even when the user is viewing
the file. So no copy will be left on the PC of the user.
method IF_EX_DOCUMENT_FILES01~AFTER_START_APPL .
DATA :
l_str_file TYPE string,
l_i_retval TYPE i.
l_str_file = TARGET_FILE-FILENAME.
CALL METHOD cl_gui_frontend_services=>file_delete
EXPORTING
filename = l_str_file
CHANGING
rc = l_i_retval
EXCEPTIONS
file_delete_failed = 1
cntl_error = 2
error_no_gui = 3
file_not_found = 4
access_denied = 5
unknown_error = 6
not_supported_by_gui = 7
wrong_parameter = 8.
endmethod.
I hope this solution may help to solve this issue.
Best regards,
Christoph -
WF_DOC or SOFM to document in DMS.
Hello all.
I have a workflow that at some point has an instance of a workflow document (MS Word), Object type WF_DOC. It is possible to convert that to a SOFM object instance.
I want to be able to create a document in DMS and place this MS Word file in the DMS document. It is possible to use function module BAPI_DOCUMENT_CREATE2 to create documents in DMS, but this function module expects that any files that will be part of the document, come from a local or network drive.
Any ideas?
Thanks
LandeJust for the record, I will give the highlights of the way the problem was solved.
I did not find a way to checkin the word file in WF_DOC format into the DMS document. I had to save it in a local drive and use this saved file to checkin.
1. Get the contents of the file in WF_DOC format using SWUO_GET_DOCUMENT_CONTENT.
2. Prepare table with binary contents of Word document
FORM prepare_contents .
DATA: w_contents TYPE LINE OF solix_tab,
w_target TYPE sdokcntbin.
LOOP AT lt_contents INTO w_contents.
MOVE w_contents-line TO w_target-line.
APPEND w_target TO lt_target.
ENDLOOP.
ENDFORM. " prepare_contents
3. Download file to local drive using METHOD cl_gui_frontend_services=>gui_download
4. Create the DMS document using BAPI_DOCUMENT_CREATE2
5. Check in the file in the local drive using BAPI_DOCUMENT_CHECKIN2
6. Delete the file in the local drive with METHOD cl_gui_frontend_services=>file_delete. -
DMS--- C Drive frontentd document storage Issue
Hello Guys,
This doubt is pertaining to DMS ,
We all know that once the originals are Saved in secured storage area inside DIR and while accessing the originals for DISPLAY /EDIT OR CHANGE mode in the front end system the copy of originals are stored automatically,
For example: i have set my Data carrier path as C:\temp\ and when ever i process a copy will get save in frontend system.
i knew its a standard practise but i was shocked seeing my C drive its completely packed with more GB of Originals.
My request to all is
1) Will not be after an year my c drive is complely jam, my system performance will get slow due to that.
2) is there any work around so that C drive dost affect and i can still store my documehts on other disk(is this advisable)?
3) Also if the design dept when they use just imagine we have transformer pro\e(igs data) which is huge in size .just 5 files occupies huge space.
This issue strucks the whole implementation of DMS...
Help me out in this regard by suggesting a suitable method to solve this issue.
Regards,
Murali.SHi,
please see the SAP note 741388 which explains how to set the OLE2 flag and avoid that the local created copy for displaying remains on your PC. Without the OLE flag the system always creates a copy under C:\temp (maintained in DC20). But with the OLE2 flag this copy will be removed after you close the display again.
To avoid completely the copy of an temporary file to your PC you can use a BADI implementation.
There exists the BAdI method DOCUMENT_FILES01~AFTER_START_APPL .
You can implement the following coding, which deletes the file even when the user is viewing the file. I hope this solution is useful for you.
method IF_EX_DOCUMENT_FILES01~AFTER_START_APPL .
DATA :
l_str_file TYPE string,
l_i_retval TYPE i.
l_str_file = TARGET_FILE-FILENAME.
CALL METHOD cl_gui_frontend_services=>file_delete
EXPORTING
filename = l_str_file
CHANGING
rc = l_i_retval
EXCEPTIONS
file_delete_failed = 1
cntl_error = 2
error_no_gui = 3
file_not_found = 4
access_denied = 5
unknown_error = 6
not_supported_by_gui = 7
wrong_parameter = 8.
endmethod.
Best regards,
Christoph
Please reward points if this is useful.
Maybe you are looking for
-
The cursor on my intel 64 bit macbook pro won't click on anything. I boot it up and can log into my account and move the cursor around just fine along with multitouch gestures working fine too. hovering over items on the dock even makes the program n
-
Epson printer not working after maverick 10.9.5 update
I recently updated my 2011 Macbook Pro with the OSX 10.9.5 software. Since then I have had a lot of trouble printing on my EPSON NX430 small in one wireless printer. I have tried deleting the printer from the printer list as well as removing the EPSO
-
My screen shut off but my iPhone is still on. What can I do?
My screen shut off but my iPhone is still on. What can I do?????????
-
Hi all.... I wonder if anyone could give me any tips about call the following program from an applet? Basically i am going to send a dataset to this program from an applet and i want it to display the graph that is created... I realise i will have to
-
I was wondering how to insert a text across a report and put it as a background. For example, I am trying to insert "SAMPLE" on a diagonal across the report and select the "move to back" option. When I do this, the bottom half of the report gets move