cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to download file to application server

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

Looks like sy-subrc value after opendataset is 8 and at write statement is 4.

Raj

Former Member
0 Kudos

Hi Raj,

Sy-subrc is 8 after open dataset means that you have problem with operating system in opening file.

Just check Function Module results once for '/SAPDMC/LSM_F4_SERVER_FILE'. I hope may have problem with this Function Module.

Regards,

Vinay

Former Member
0 Kudos

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.

Former Member
0 Kudos

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.

Former Member
0 Kudos

Hi John,

how can we download data to app server by using GUI_DOWNLOAD?, I believe that is not possible... if there is any way plz let me know

Former Member
0 Kudos

Hi,

Check whether your internal table itab_ls has values.

Put a sy-subrc check after the select.

Regards,

GSR.