Skip to Content
0
Former Member
Feb 02, 2006 at 01:30 PM

Unable to download file to application server

191 Views

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