2007 Jun 13 8:03 AM
how to upload the data from both application server & presentation server?
2007 Jun 13 8:08 AM
Hi
To Upload from Presentation Server You can use the FM GUI_UPLOAD. And to upload from Application Server You can use OPEN_DATASET...
See the examples below for Both......
PARAMETERS:p_upload(60) DEFAULT 'C:\Biju\Today\FINDING_GAPS_INPUT.TXT'.
DATA:p_file TYPE string,v.
p_file = p_upload.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:\Documents and Settings\Desktop\retro_stat_pr_oslr_MY03_for_test_now.txt'
filename = p_file
FILETYPE = 'ASC'
has_field_separator = '#'
HEADER =
TABLES
data_tab = it_file.
FORM dt_val_warn.
DATA : var_msg(50).
DATA: e_lfile LIKE rlgrap-filename .
DATA : flname(500) TYPE c.
CONCATENATE p_spath 'LOG' sy-datum sy-uzeit '.LOG' INTO flname.
e_lfile = flname.
SELECT MAX( crdate ) INTO g_date FROM zirl01_day_bal2 WHERE crdate <= p_date.
IF sy-subrc = 0.
IF ( g_date <> p_pdate AND p_skipw <> 'X' ).
CONCATENATE g_date ' is the available maximum date ' INTO var_msg.
var_msg = ''.
log_line = var_msg.
APPEND log_line TO itab_log.
OPEN DATASET e_lfile FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc <> 0.
PERFORM log_writing.
ENDIF.
MESSAGE e398(00) WITH var_msg.
ENDIF.
ENDIF.
ENDFORM.
Revert Back If you have any doubts......
Reward All Helpfull Answers......
Hi
To Upload from Presentation Server You can use the FM GUI_UPLOAD. And to upload from Application Server You can use OPEN_DATASET...
See the examples below for Both......
PARAMETERS:p_upload(60) DEFAULT 'C:\Biju\Today\FINDING_GAPS_INPUT.TXT'.
DATA:p_file TYPE string,v.
p_file = p_upload.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:\Documents and Settings\Desktop\retro_stat_pr_oslr_MY03_for_test_now.txt'
filename = p_file
FILETYPE = 'ASC'
has_field_separator = '#'
HEADER =
TABLES
data_tab = it_file.
FORM dt_val_warn.
DATA : var_msg(50).
DATA: e_lfile LIKE rlgrap-filename .
DATA : flname(500) TYPE c.
CONCATENATE p_spath 'LOG' sy-datum sy-uzeit '.LOG' INTO flname.
e_lfile = flname.
SELECT MAX( crdate ) INTO g_date FROM zirl01_day_bal2 WHERE crdate <= p_date.
IF sy-subrc = 0.
IF ( g_date <> p_pdate AND p_skipw <> 'X' ).
CONCATENATE g_date ' is the available maximum date ' INTO var_msg.
var_msg = ''.
log_line = var_msg.
APPEND log_line TO itab_log.
OPEN DATASET e_lfile FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc <> 0.
PERFORM log_writing.
ENDIF.
MESSAGE e398(00) WITH var_msg.
ENDIF.
ENDIF.
ENDFORM.
Revert Back If you have any doubts......
Reward All Helpfull Answers......
2007 Jun 13 8:04 AM
Hi,
use Datasets: Applicationserver
OpenDataset,CloseDataset,Readdataset..Transfer.
use function moduels for presentation server:
gui_upload,
Gui_Download.
reward points if helpful,
Regard's
Raghunath.S
2007 Jun 13 8:06 AM
2007 Jun 13 8:11 AM
Hi
If you need Option for both In the Selection-Screen make two Checkboxes. In program according to this check box value you can call different Performs. Checkbox variable will be 'X' when it is selected....
Reward All helpfull Answers.........
2007 Jun 13 8:07 AM
Hi,
*&---------------------------------------------------------------------*
*& Report ZUPLOADTAB *
*& *
*&---------------------------------------------------------------------*
*& Example of Uploading tab delimited file *
*& *
*&---------------------------------------------------------------------*
REPORT zuploadtab .
PARAMETERS: p_infile LIKE rlgrap-filename
OBLIGATORY DEFAULT '/usr/sap/'..
DATA: ld_file LIKE rlgrap-filename.
*Internal tabe to store upload data
TYPES: BEGIN OF t_record,
name1 like pa0002-VORNA,
name2 like pa0002-name2,
age type i,
END OF t_record.
DATA: it_record TYPE STANDARD TABLE OF t_record INITIAL SIZE 0,
wa_record TYPE t_record.
*Text version of data table
TYPES: begin of t_uploadtxt,
name1(10) type c,
name2(15) type c,
age(5) type c,
end of t_uploadtxt.
DATA: wa_uploadtxt TYPE t_uploadtxt.
*String value to data in initially.
DATA: wa_string(255) type c.
constants: con_tab TYPE x VALUE '09'.
*If you have Unicode check active in program attributes then you will
*need to declare constants as follows:
*class cl_abap_char_utilities definition load.
*constants:
* con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB.
************************************************************************
*START-OF-SELECTION
START-OF-SELECTION.
ld_file = p_infile.
OPEN DATASET ld_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
ELSE.
DO.
CLEAR: wa_string, wa_uploadtxt.
READ DATASET ld_file INTO wa_string.
IF sy-subrc NE 0.
EXIT.
ELSE.
SPLIT wa_string AT con_tab INTO wa_uploadtxt-name1
wa_uploadtxt-name2
wa_uploadtxt-age.
MOVE-CORRESPONDING wa_uploadtxt TO wa_upload.
APPEND wa_upload TO it_record.
ENDIF.
ENDDO.
CLOSE DATASET ld_file.
ENDIF.
************************************************************************
*END-OF-SELECTION
END-OF-SELECTION.
*!! Text data is now contained within the internal table IT_RECORD
* Display report data for illustration purposes
loop at it_record into wa_record.
write:/ sy-vline,
(10) wa_record-name1, sy-vline,
(10) wa_record-name2, sy-vline,
(10) wa_record-age, sy-vline.
endloop.Regards
Sudheer
2007 Jun 13 8:08 AM
Hi
To Upload from Presentation Server You can use the FM GUI_UPLOAD. And to upload from Application Server You can use OPEN_DATASET...
See the examples below for Both......
PARAMETERS:p_upload(60) DEFAULT 'C:\Biju\Today\FINDING_GAPS_INPUT.TXT'.
DATA:p_file TYPE string,v.
p_file = p_upload.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:\Documents and Settings\Desktop\retro_stat_pr_oslr_MY03_for_test_now.txt'
filename = p_file
FILETYPE = 'ASC'
has_field_separator = '#'
HEADER =
TABLES
data_tab = it_file.
FORM dt_val_warn.
DATA : var_msg(50).
DATA: e_lfile LIKE rlgrap-filename .
DATA : flname(500) TYPE c.
CONCATENATE p_spath 'LOG' sy-datum sy-uzeit '.LOG' INTO flname.
e_lfile = flname.
SELECT MAX( crdate ) INTO g_date FROM zirl01_day_bal2 WHERE crdate <= p_date.
IF sy-subrc = 0.
IF ( g_date <> p_pdate AND p_skipw <> 'X' ).
CONCATENATE g_date ' is the available maximum date ' INTO var_msg.
var_msg = ''.
log_line = var_msg.
APPEND log_line TO itab_log.
OPEN DATASET e_lfile FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc <> 0.
PERFORM log_writing.
ENDIF.
MESSAGE e398(00) WITH var_msg.
ENDIF.
ENDIF.
ENDFORM.
Revert Back If you have any doubts......
Reward All Helpfull Answers......
2007 Jun 13 8:14 AM
Hi soumya,
Use the function module in the F4 help of file
CALL FUNCTION 'F4_DXFILENAME_TOPRECURSION'
EXPORTING
I_LOCATION_FLAG = ' '
I_SERVER = '?'
FILEMASK = '.'
FILEOPERATION = 'R'
IMPORTING
O_LOCATION_FLAG = FLAG
O_PATH = PATH.
FILENAME = PATH.
After executing this FM,you will be getting a dilaog asking which server you want,
If you want application server FLAG will be set to 'A', else if you want presentation server FLAG will be set to 'P' .
declare the importing variables like
DATA:FLAG LIKE DXFIELDS-LOCATION,
PATH LIKE DXFIELDS-LONGPATH.
Then check manually for the FLAG value.
IF FLAG = 'A'.
OPEN DATASET FILENAME FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC = 0.
DO.
READ DATASET FILENAME INTO LINE.
ENDIF.
ENDIF.
IF FLAG = 'P'.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = FILENAME
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = ITAB.
ENDIF.
reward points if useful
thanks
rami
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |