on 02-02-2006 1:30 PM
Hi,
I am trying to download a file to the application server. I've also attached my code below.After the execution of this program, it is just returning blank values to the application server file. Let me know why it is not populating the values to the files.
Raj.
tables: kna1,
knb1.
DATA: BEGIN OF itab_ls OCCURS 0,
kunnr LIKE kna1-kunnr,
altkn LIKE knb1-altkn,
END OF itab_ls.
TYPES : BEGIN OF t_file,
date(5) TYPE c, " Date
time(5) TYPE c, " Time
end of t_file.
DATA : gt_file TYPE TABLE OF t_file, " File Path
g_spath TYPE fileextern, " Path
g_fieldname TYPE dynfnam. " Field Name
SELECTION-SCREEN BEGIN OF BLOCK b_01 WITH FRAME TITLE text-b01.
SELECT-OPTIONS s_erdat FOR kna1-erdat obligatory.
SELECTION-SCREEN END OF BLOCK b_01.
SELECTION-SCREEN BEGIN OF BLOCK b_02 WITH FRAME TITLE text-b02.
SELECTION-SCREEN BEGIN OF LINE.
Radio button for Presentation server file
PARAMETERS : p_pres RADIOBUTTON GROUP file DEFAULT 'X'
USER-COMMAND file.
SELECTION-SCREEN COMMENT 3(20) text-s01 FOR FIELD p_pres.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 23(22) text-s02 FOR FIELD p_flnam1
MODIF ID com.
Presentation server file Name
PARAMETERS : p_flnam1 TYPE localfile MODIF ID com ."MEMORY ID zp1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
Radio button for Application server file
PARAMETERS : p_app RADIOBUTTON GROUP file .
SELECTION-SCREEN COMMENT 3(20) text-s03 FOR FIELD p_app.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 23(22) text-s04 FOR FIELD p_flnam2
MODIF ID com.
Application server file Name
PARAMETERS : p_flnam2 TYPE localfile MODIF ID com ."MEMORY ID zp2 .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b_02.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_flnam1.
g_fieldname = 'P_PCFILE'.
PERFORM call_pres_help USING g_fieldname
CHANGING p_flnam1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_flnam2.
PERFORM call_app_help CHANGING p_flnam2.
AT SELECTION-SCREEN OUTPUT.
Start-of-selection.
SELECT kna1kunnr knb1altkn kna1ktokd kna1erdat
INTO CORRESPONDING FIELDS OF TABLE itab_ls
FROM kna1 INNER JOIN knb1 ON kna1kunnr = knb1kunnr WHERE kna1~erdat in
s_erdat AND KNA1KTOKD = 'Z002' order by kna1kunnr.
OPEN DATASET p_flnam2 for output IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc EQ 0.
LOOP AT itab_ls.
TRANSFER itab_ls TO p_flnam2.
ENDLOOP.
CLOSE DATASET p_flnam2.
endif.
WRITE:/'SAP Ship-toCustID', 18 'LegacyCustID'.
ULINE.
Loop at itab_ls.
write: /3 itab_ls-KUNNR, 18 itab_ls-ALTKN.
endloop.
PERFORM download_file.
&----
*& Form call_pres_help
&----
text
----
-->P_FIELDNAME text
-->P_PARAMETER text
----
FORM call_pres_help USING p_fieldname TYPE dynfnam
CHANGING p_parameter TYPE localfile.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = sy-repid
dynpro_number = sy-dynnr
field_name = p_fieldname
IMPORTING
file_name = p_parameter.
ENDFORM. "call_pres_help
&----
*& Form call_app_help
&----
text
----
-->P_PARAMETER text
----
FORM call_app_help CHANGING p_parameter TYPE localfile.
CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'
EXPORTING
directory = g_spath
IMPORTING
serverfile = p_parameter
EXCEPTIONS
canceled_by_user = 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. "call_app_help
Hi Raj,
I have the same requirement I need to download from files into application server. Can you please send me the code used for downloading the data in to the application server.
Regards
Line
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
If the SY-SUBRC is equal to 8, then error is nothing but "The file could not be opened". So pls check the file name again.
And for write statement,
If SY-SUBRC = 4 then the Contents of name are invalid, statement could not be executed, and contents of destination remain unchanged. So pls do check this also.
regs,
Venkat Ramanan
Message was edited by: Venkat Ramanan Natarajan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Raj,
Ur code is OK. Lets check few points in debug mode.
1) Just check internal table itab_ls has data or not
2) Is ur p_flnam2 is of character type or not
3) Just check sy-subrc value after OPEN DATASET
Regards,
Vinay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Could you pls check in debugging the sy-subrc value after the open dataset command...to make sure it is trying to transfer the values....
if you have done this already pls ignore my reply....
Thanks,
Renjith.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Raj,
why don't try with this FM
'GUI_DOWNLOAD'
select required fields data into internal table & then transfer it to file on application server.
regards,
John.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Check whether your internal table itab_ls has values.
Put a sy-subrc check after the select.
Regards,
GSR.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.