on 04-13-2015 1:20 PM
Hi friends,
As per the user requirement, I need to send the BEx report through open hub/APD to application server (AL11) in .txt format with 'tab' delimiter.
I am aware that it can be done in .csv format but not about .txt.
Please help me with urgent requirement.
Regards,
Ankita
Hi Ankita,
Did you got the solution? I have a similar requirement, where I need to create a csv file & then upload it in AL11 at a specified path.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Ankit,
I have done one similar requirement where we select any file from desk top and then upload it to AL11 folder.
I think below code will solve your issue..
***********************************************************************************************
************************** Code Starts *****************************************************
REPORT zupload_al11_test.
******************** Data Declaration Starts ***************************
DATA: ifile TYPE filetable,
l_pcfile TYPE sapb-sappfad,
lv_len TYPE i,
lv_len1 TYPE i,
counter TYPE i,
lv_c(1) TYPE c,
lv_total TYPE i,
xfile LIKE LINE OF ifile,
rc TYPE i.
******************** Data Declaration Ends *****************************
******************** Declaration for Selction Screen Starts ************
***Test start
SELECTION-SCREEN BEGIN OF SCREEN 200 AS WINDOW.
PARAMETERS: p_file TYPE localfile.
DATA:l_serfil TYPE sapb-sappfad.
SELECTION-SCREEN END OF SCREEN 200.
CALL SELECTION-SCREEN '0200' STARTING AT 10 10.
*** Test end
*SELECTION-SCREEN: BEGIN OF BLOCK b WITH FRAME .
*PARAMETERS:
** p_radio1 RADIOBUTTON GROUP gr1 DEFAULT 'X' ,"USER-COMMAND vend
** p_radio2 RADIOBUTTON GROUP gr1,
** p_radio3 RADIOBUTTON GROUP gr1,
** p_radio4 RADIOBUTTON GROUP gr1,
* p_file TYPE localfile.
*DATA:l_serfil TYPE sapb-sappfad. "Server File & path
*SELECTION-SCREEN: END OF BLOCK b.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
******************** Declaration for Selction Screen Ends ***************
IF p_file IS INITIAL.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
initial_directory = 'C:\' " Default drive C for F4 help
CHANGING
file_table = ifile
rc = rc.
READ TABLE ifile INTO xfile INDEX 1.
CHECK sy-subrc = 0.
p_file = xfile-filename.
ENDIF.
START-OF-SELECTION.
l_pcfile = p_file.
IF l_pcfile IS NOT INITIAL.
lv_len = strlen( l_pcfile ).
lv_total = lv_len.
lv_len1 = lv_len - 1.
lv_c = l_pcfile+lv_len1(1).
counter = 0.
WHILE lv_c <> '\'.
lv_len = lv_len - 1.
lv_len1 = lv_len1 - 1.
lv_c = l_pcfile+lv_len1(1).
counter = counter + 1.
ENDWHILE.
lv_total = lv_total - counter.
CONCATENATE '/usr/sap/tmp' l_pcfile+lv_total(counter) INTO l_serfil.
DATA : LD_TGT_FILE TYPE STRING,
LD_SRC_FILE TYPE STRING.
LD_SRC_FILE = l_serfil.
CONCATENATE '/oracle/' l_pcfile+lv_total(counter)'_' SY-DATUM '_' SY-UZEIT '_' SY-UNAME INTO LD_TGT_FILE.
"
PERFORM COPY_FILE_IN_APP_SERVER USING LD_SRC_FILE
LD_TGT_FILE.
CALL FUNCTION 'ARCHIVFILE_CLIENT_TO_SERVER'
EXPORTING
path = l_pcfile " SOURCE FILE NAME
targetpath = l_serfil " TARGET FILE NAME
EXCEPTIONS
error_file = 1
OTHERS = 2.
CALL FUNCTION 'BP_EVENT_RAISE'
EXPORTING
eventid = 'ZTEST_ENIGMA_FILE_UPLOAD'
* EVENTPARM = '' " Calling Event with PARAMETER
EXCEPTIONS
BAD_EVENTID = 1
EVENTID_DOES_NOT_EXIST = 2
EVENTID_MISSING = 3
RAISE_FAILED = 4
OTHERS = 5.
IF sy-subrc <> 0.
* Write: 'Event failed to trigger'.
* else.
* Write: 'Event triggered'.
ENDIF.
IF sy-subrc EQ 0.
MESSAGE 'File Uploaded Successfully.....' TYPE 'S'.
ELSE.
MESSAGE : 'File Uploaded With Errors.....' TYPE 'S' .
ENDIF.
ELSE.
MESSAGE: 'Source or Target File Path is Empty.......' TYPE 'S' .
ENDIF.
FORM COPY_FILE_IN_APP_SERVER USING LV_SRC_FILE TYPE STRING
LV_TGT_FILE TYPE STRING.
DATA: LV_STR TYPE STRING.
" OPEN DATASET FILE FROM SERVER FOR READING
OPEN DATASET LV_SRC_FILE FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC = 0.
OPEN DATASET LV_TGT_FILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
DO.
READ DATASET LV_SRC_FILE INTO LV_STR.
IF SY-SUBRC = 0.
TRANSFER LV_STR TO LV_TGT_FILE.
CLEAR LV_STR.
ELSE.
EXIT.
ENDIF.
ENDDO.
ENDIF.
CLOSE DATASET LV_SRC_FILE.
CLOSE DATASET LV_TGT_FILE.
ENDFORM.
******************************** Code Ends ****************************************************
Copy and paste above code in SE38.
1) select file from desktop using F4 help
2) Execute Program----->The file will get on AL11 folder "/usr/sap/tmp"
3) My additional requirement is :- If user is uploading file with the same name then previous uploaded file get archive to some folder with sy-uname and timestamp ... here i am doing this(archiving activity) in folder /oracle/
----------------------------------------------------------------------------------------------------------------------------------------
@ ankita:- I think u need to make some changes to this code. As mentioned, this program take file from desktop user selected location.. so instead of this u need to take it from open hub....
Regards,
Hitesh
Hi Ankita,
Perhaps an ABAPer may help you with this TXT file format as output..
Regards,
Loed
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 3 | |
| 3 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.