03-05-2009 2:15 AM
Hi to all experts,
my requirement is download a file at the application server with the physical inventory document no
for example the 123149394.txt that i have done if the already exist then i have to give a message to the user that the file already exist , for that i have used the fm POPUP_WITH_2_BUTTONS_TO_CHOOSE yes or no (2 buttons) but the problem know is that if there are 1000 files than the users have to click 1000 times yes or no . I have display all the files at once and ask user just once for yes or no
here is my code please can u help me with this requirement.
LOOP AT it_output INTO wa_output.
CONCATENATE wa_output-iblnr 'txt' INTO f_filename SEPARATED BY '.'.
CONCATENATE p_file '\' wa_output-iblnr '.txt' INTO fname.
*checking whether file exist already in the directory
READ TABLE it_filelist INTO wa_filelist
WITH KEY name = f_filename BINARY SEARCH.
IF sy-subrc EQ 0.
* if the file already exist giving message.
PERFORM popup_to_confirm.
IF gc_answer EQ '1'.
OPEN DATASET fname FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
PERFORM transfer_file.
ELSE.
CONTINUE.
ENDIF.
ELSE.
OPEN DATASET fname FOR APPENDING IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc EQ 0.
PERFORM transfer_file.
ENDIF.
ENDIF.
CLOSE DATASET fname.
CLEAR: wa_output,f_filename, wa_filelist,gc_answer.
ENDLOOP.
FORM popup_to_confirm .
CALL FUNCTION 'POPUP_WITH_2_BUTTONS_TO_CHOOSE'
EXPORTING
DEFAULTOPTION = '1'
diagnosetext1 = text-005
DIAGNOSETEXT2 = 'Enter Yes Or NO'
DIAGNOSETEXT3 = 'YES'
textline1 = 'Enter Yes Or NO'
TEXTLINE2 = ' '
TEXTLINE3 = ' '
text_option1 = 'YES'
text_option2 = 'NO'
titel = 'FILE ALREADY EXIST DO WANT TO CONTINUE'
IMPORTING
answer = gc_answer
.
ENDFORM. " popup_to_confirm
&----
*& Form delimit_file
&----
FORM transfer_file .
DATA: output TYPE string.
CONCATENATE wa_output-iblnr
wa_output-zeili
wa_output-matnr
wa_output-werks
wa_output-lgort
wa_output-bstar
wa_output-erfme
wa_output-maktx
wa_output-lgpbe
INTO output SEPARATED BY '|'.
transfering the file contents to the
TRANSFER output TO fname .
ENDFORM.
03-05-2009 2:22 AM
how about
CONCATENATE p_file '\' wa_output-iblnr sy-datum '.txt' INTO fname no gaps.
In this way there is not chance of file already being existings..
03-05-2009 2:22 AM
how about
CONCATENATE p_file '\' wa_output-iblnr sy-datum '.txt' INTO fname no gaps.
In this way there is not chance of file already being existings..
03-05-2009 2:33 AM
Hi J@Y.
u didnt get my requirement i want to display all the files that exist as a pop up message
03-05-2009 2:40 AM
try something like this
program BALV_POPUP_TO_SELECT_2 or BALVPOP*UP
or
FM
REUSE_ALV_POPUP_TO_SELECT
regards
Prabhu
03-05-2009 2:35 AM
Hi,
Just a suggestion, why dont you create another field in your internal table that will serve as a FLAG whether the filename is existing or not..mark it during your first loop..then after the loop read the internal table if there's an existing filename. if there is, then ask the user via POP_UP_TO_CONFIRM if he/she wants to continue, his/her answer will be for all the files with existing filenames..if he/she wants to continue then loop again to your internal table with existing filenames and do your process..
Regards,
Leonard Chomi
03-05-2009 3:53 AM
03-05-2009 4:27 AM
Hi,
just some modifications made...see if this helps u...
changed the structure of the internal table it_output as
data: begin of it_output,
.......,
flg type c.
end of it_output.
added one more field as flg.
LOOP AT it_output INTO wa_output.
CONCATENATE wa_output-iblnr 'txt' INTO f_filename SEPARATED BY '.'.
CONCATENATE p_file '\' wa_output-iblnr '.txt' INTO fname.
*checking whether file exist already in the directory
READ TABLE it_filelist INTO wa_filelist
WITH KEY name = f_filename BINARY SEARCH.
IF sy-subrc EQ 0.
if the file already exist giving message.
PERFORM popup_to_confirm. --->comment this and just give wa_output-flg = 'X'.
ELSE.
OPEN DATASET fname FOR APPENDING IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc EQ 0.
PERFORM transfer_file.
ENDIF.
ENDIF.
CLOSE DATASET fname.
modify it_output with wa_output transporting flg.-->add this line
CLEAR: wa_output,f_filename, wa_filelist,gc_answer.
ENDLOOP.
loop at it_output into wa_output where flg is not initial.
PERFORM popup_to_confirm
IF gc_answer EQ '1'.
OPEN DATASET fname FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
PERFORM transfer_file.
ELSE.
CONTINUE.
ENDIF.
endloop.--->so now the popup will be called for those entries for which the filename already exists
Keerthi
Edited by: Keerthy K on Mar 5, 2009 5:29 AM
03-05-2009 5:50 AM
Hi,
You can have a look at these FMs and change logic accordingly...
EPS_GET_DIRECTORY_LISTING - Lists filenames from the application server
TMP_GUI_GET_FILE_EXIST u2013 Checks existence of a file
TMP_GUI_READ_DIRECTORY - Lists files in a directory
See if it helps...
Regards.