10-07-2007 3:12 PM
Hi Gurus,
Please i need an urgent help from you guys. There is a demand file which consits of (Siteno(plant), Item No ,Item Description, Delivery due date) will be placed in a unix system or windows system. I need to write an interface which shows a radiobutton for unix & windows and fileupload button & download button.When user clicks should be able to select only one radiobutton (unix or windows) to upload or download.When the user clicks the fileupload / download button,it should pick up the file or drop the file at particular unix or windows system.
Please help me or give me sample code where in i can select the radiobutton and i can upload / download from unix or windows path. and during upload process (for both unix/windows) ,i should be able to persist into a custom table (ztable,if iam not wrong) and while downloading read the records from custome table and create an excel file to be placedon unix/windows based on the radio button.
Thanks in advance, i need ur help please.
Regards
Bruno
10-07-2007 4:44 PM
Hi
do like this
Report Zreport.
data: itab like Ztable occurs 0 with header line.
DATA: it_record TYPE STANDARD TABLE OF ztable INITIAL SIZE 0,
wa_record TYPE ztable.
DATA: ld_file LIKE rlgrap-filename.
DATA: wa_uploadtxt TYPE ztable.
*String value to data in initially.
DATA: wa_string(255) type c.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECTION-SCREEN BEGIN OF LINE.
Upload file
PARAMETERS: p_upload RADIOBUTTON GROUP g1 DEFAULT 'X'.
SELECTION-SCREEN COMMENT 3(20) text-004 FOR FIELD p_upload.
SELECTION-SCREEN END OF LINE.
Download File
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: p_download RADIOBUTTON GROUP g1 .
SELECTION-SCREEN COMMENT 3(20) text-005 FOR FIELD p_download.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
SELECTION-SCREEN BEGIN OF LINE.
Unix file
PARAMETERS: p_unix RADIOBUTTON GROUP g2 DEFAULT 'X'.
SELECTION-SCREEN COMMENT 3(20) text-002 FOR FIELD p_unix.
SELECTION-SCREEN END OF LINE.
Windows file
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: p_windows RADIOBUTTON GROUP g2 .
SELECTION-SCREEN COMMENT 3(20) text-003 FOR FIELD p_windows.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b1.
File Name
PARAMETERS: p_file TYPE rlgrap-filename.
SELECTION-SCREEN END OF BLOCK b2.
Start-of-selection.
if p_upload = 'X'.
if p_windows = 'X'.
Call function GUI_UPLOAD with flat file
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = p_file
filetype = 'DAT' "or 'ASC'
TABLES
data_tab = itab
EXCEPTIONS
conversion_error = 1
invalid_table_width = 2
invalid_type = 3
no_batch = 4
unknown_error = 5
gui_refuse_filetransfer = 6
OTHERS = 7.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Modify the Ztable with the Uploaded file
MODIFY ZTABLE from table itab.
else. " Unix file
OPEN DATASET ...
READ table ITAB...
TRANSFER itab to ..DATASET..
CLOSE datset.
endif.
else. " Download file
if p_windows = 'X'.
clear itab. refresh itab.
select * from Ztable into table itab.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = p_file
filetype = 'DAT' "or 'ASC'
TABLES
data_tab = itab
EXCEPTIONS
conversion_error = 1
invalid_table_width = 2
invalid_type = 3
no_batch = 4
unknown_error = 5
gui_refuse_filetransfer = 6
OTHERS = 7.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
else. " Unix
id_file = p_file.
OPEN DATASET id_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-f1
wa_uploadtxt-f2
wa_uploadtxt-f3.
MOVE-CORRESPONDING wa_uploadtxt TO wa_upload.
APPEND wa_upload TO it_record.
ENDIF.
ENDDO.
CLOSE DATASET id_file.
ENDIF.
endif.
endif.
Regards
Anji
10-07-2007 4:44 PM
Hi
do like this
Report Zreport.
data: itab like Ztable occurs 0 with header line.
DATA: it_record TYPE STANDARD TABLE OF ztable INITIAL SIZE 0,
wa_record TYPE ztable.
DATA: ld_file LIKE rlgrap-filename.
DATA: wa_uploadtxt TYPE ztable.
*String value to data in initially.
DATA: wa_string(255) type c.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECTION-SCREEN BEGIN OF LINE.
Upload file
PARAMETERS: p_upload RADIOBUTTON GROUP g1 DEFAULT 'X'.
SELECTION-SCREEN COMMENT 3(20) text-004 FOR FIELD p_upload.
SELECTION-SCREEN END OF LINE.
Download File
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: p_download RADIOBUTTON GROUP g1 .
SELECTION-SCREEN COMMENT 3(20) text-005 FOR FIELD p_download.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
SELECTION-SCREEN BEGIN OF LINE.
Unix file
PARAMETERS: p_unix RADIOBUTTON GROUP g2 DEFAULT 'X'.
SELECTION-SCREEN COMMENT 3(20) text-002 FOR FIELD p_unix.
SELECTION-SCREEN END OF LINE.
Windows file
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: p_windows RADIOBUTTON GROUP g2 .
SELECTION-SCREEN COMMENT 3(20) text-003 FOR FIELD p_windows.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b1.
File Name
PARAMETERS: p_file TYPE rlgrap-filename.
SELECTION-SCREEN END OF BLOCK b2.
Start-of-selection.
if p_upload = 'X'.
if p_windows = 'X'.
Call function GUI_UPLOAD with flat file
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = p_file
filetype = 'DAT' "or 'ASC'
TABLES
data_tab = itab
EXCEPTIONS
conversion_error = 1
invalid_table_width = 2
invalid_type = 3
no_batch = 4
unknown_error = 5
gui_refuse_filetransfer = 6
OTHERS = 7.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Modify the Ztable with the Uploaded file
MODIFY ZTABLE from table itab.
else. " Unix file
OPEN DATASET ...
READ table ITAB...
TRANSFER itab to ..DATASET..
CLOSE datset.
endif.
else. " Download file
if p_windows = 'X'.
clear itab. refresh itab.
select * from Ztable into table itab.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = p_file
filetype = 'DAT' "or 'ASC'
TABLES
data_tab = itab
EXCEPTIONS
conversion_error = 1
invalid_table_width = 2
invalid_type = 3
no_batch = 4
unknown_error = 5
gui_refuse_filetransfer = 6
OTHERS = 7.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
else. " Unix
id_file = p_file.
OPEN DATASET id_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-f1
wa_uploadtxt-f2
wa_uploadtxt-f3.
MOVE-CORRESPONDING wa_uploadtxt TO wa_upload.
APPEND wa_upload TO it_record.
ENDIF.
ENDDO.
CLOSE DATASET id_file.
ENDIF.
endif.
endif.
Regards
Anji
10-07-2007 7:06 PM
Thanks a lot and appreciate your quick response. I will definitely issue points to you.
Does this interface program shows a radiobutton for Unix and Windows (allowing user to select one) and picking the file using a dialog box to give the path ?
Will this show a 2 buttons (upload/ download) to upload the excel file into custom table and download file into excel from the database table ?
Can i have your email id also ?
Thanks in advance
Praveen
10-07-2007 7:08 PM
Anji,
Sorry i'm new to abap programming and ignorance.
Thanks
Bruno
10-07-2007 8:15 PM
Hi
Just copy and paste this code in SE38
Only thing is for the Upload of file to UNIX was not written by me completely
just you have to code as per the logic mentioned.It will work
First copy it in SE38 and correct the small syntax errors and do
this will work correctly
Regards
Anji