Excel file located in application server to be uploaded
Hello friends,
Please tell me what are the steps to be followed while uploading the data from a file in EXCEL format located in application server in to SAP data base using BDC.
Thanks in advance,
Ram.
declarations:
DATA:IT_EXCEL LIKE TABLE OF ALSMEX_TABLINE WITH HEADER LINE.
I guess u r familiar with notepad upload.....just use your declaration as it is. Below is a basic demonstration of uploading data from excel...reward if useful.
Excel file Locating.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-002.
PARAMETERS: P_FILE TYPE LOCALFILE OBLIGATORY .
SELECTION-SCREEN END OF BLOCK B1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
STATIC = 'X'
CHANGING
FILE_NAME = P_FILE.
Check whether the uploaded fiel is excel or not
AT SELECTION-SCREEN ON P_FILE.
WK_LEN = P_FILE.
CONDENSE WK_LEN NO-GAPS.
LENT = STRLEN( WK_LEN ).
WK_ALP = LENT - 4.
B = WK_LEN+WK_ALP(LENT).
IF ( B NE '.xls' AND B NE '.XLS' ).
MESSAGE E939.
CLEAR P_FILE.
STOP.
ENDIF.
START-OF-SELECTION.
do all the othre process here
PERFORM FETCH_FROM_FLAT_FILE.
store the values to your normal itab and the process.
LOOP AT IT_EXCEL.
CASE IT_EXCEL-COL.
WHEN '0001'.
MOVE: IT_EXCEL-VALUE TO RECORD1-MATNR_005.
WHEN '0002'.
MOVE: IT_EXCEL-VALUE TO WK_WERKS.
WHEN '0003'.
MOVE: IT_EXCEL-VALUE TO RECORD1-BUDAT_002.
WHEN '0004'.
MOVE: IT_EXCEL-VALUE TO RECORD1-BKTXT_004.
WHEN '0005'.
MOVE: IT_EXCEL-VALUE TO RECORD1-ERFMG_007.
WHEN '0006'.
MOVE: IT_EXCEL-VALUE TO RECORD1-ERFMG_008.
ENDCASE.
AT END OF ROW.
APPEND RECORD1.
CLEAR RECORD1.
ENDAT.
ENDLOOP.
**Here record1 is the internal table holding the data fetched from excel
end-of-selection.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = P_FILE
I_BEGIN_COL = 1 "From 1st Column
I_BEGIN_ROW = 2 "From 2nd row
I_END_COL = 6 "Till 6th Column
I_END_ROW = 65536 "Till Row
TABLES
INTERN = IT_EXCEL
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
CLEAR IT_EXCEL.
DESCRIBE TABLE IT_EXCEL.
IF SY-TFILL = 0.
MESSAGE I937.
STOP.
ENDIF.
Similar Messages
-
Upload and download of excel file in the application server in background
Hi all,
i want to download the excel file from application server into internal table and after processing i have to upload to excel file in the application server in the background mode..
i mean i'll schedule the program in background.
im using FM ALSM_EXCEL_TO_INTERNAL_TABLE its working fine in fore ground but not in back ground.
what method i have to follow ?Hi Ankit,
I think this is not possible to open a Excel-File from the application server because the Excel format before Office 2007 where a binary format (Suffix: .xls). The newer Office file format (Suffix: xlsx) is a zipped XML Format. To read the binary Excel-Format you need an OLE Connection between SAP GUI and Office. But at the application server in background you doesn't have this OLE Connection.
In my opinion you have two possibilities:
1. Convert all files in the CSV format. This file format can be read with open dataset.
2. Upload the files from the presentation server in forground. There are some funktion modules in the standard which can read the xls format. But they have some limits regarding the length of cells content.
My recommendation is solution no. 1. If you know an VBA expert, he can write an Excel-macro which converts all Excel Files in the CSV-Fomat.
Regards
Dirk -
Excel file creation on application server
Gurus,
I have seen a lot of threads on excel file creation in application server, but failed to see if anyone had a solution.
Problem: In background execution I need to create an excel sheet on application server, the data would be contained in internal table, The FM like WS_DOWNLOAD etc..cannot support these as they have GUI component.
All the documentation that I have been through states to use dataset which saves the file in.csv or txt format seperated by delimiter, is it possible to save as a true excel file.
same as this thread:
Re: Excel download in Application Server
let me know,
Thanks in advance .* Write column headers, if required
IF column_headers = 'X'.
* ... override field names with LABELS_IN, if specified
IF NOT labels_in[] IS INITIAL.
DESCRIBE TABLE labels_in LINES num_lines.
IF num_lines > num_fields.
RAISE too_many_labels.
ELSEIF num_lines < num_fields.
RAISE too_few_labels.
ENDIF.
ASSIGN COMPONENT 1 OF STRUCTURE labels_in TO <f>.
LOOP AT fields_in.
READ TABLE labels_in INDEX sy-tabix.
fields_in-name = labels_in-name.
MODIFY fields_in.
ENDLOOP.
ENDIF.
* ...write column headers to file...
position = 0.
LOOP AT fields_in.
IF fixed_length NE space.
*** INSERT: DAR was here for Issue 17817 --------------- dar012009 ---v
field_len = STRLEN( fields_in-name ).
*** INSERT: DAR was here for Issue 17817 --------------- dar012009 ---^
DO fields_in-len TIMES.
offset = sy-index - 1.
* IF sy-index > 15. dar012009
IF sy-index > field_len. "dar012009
line_out+position(1) = space.
ELSEIF fields_in-name+offset(1) NE space.
line_out+position(1) = fields_in-name+offset(1).
ELSE.
line_out+position(1) = space.
ENDIF.
position = position + 1.
ENDDO.
ELSE.
CONCATENATE line_out fields_in-name INTO line_out
SEPARATED BY delimiter.
ENDIF.
ENDLOOP.
IF fixed_length EQ space.
SHIFT line_out LEFT DELETING LEADING delimiter.
ENDIF.
IF no_write IS INITIAL. "dar041505
TRANSFER line_out TO file_out.
ENDIF. "dar041505
data_out = line_out. APPEND data_out. "dar041505
ENDIF.
* Write lines to file...
LOOP AT data_in.
CLEAR line_out.
position = 0.
DO num_fields TIMES.
ASSIGN COMPONENT sy-index OF STRUCTURE data_in TO <f>. -
Excel File downloaded from application server is also opening in notepad
Hi Friends,
While downlaoding an excel file from the application server,we are able to open in notepad also.But this does not conatin the excel properties and hence happening.File should only oopen with excel and no other file type
Can any open help on this
ld_file = '/usr/sap/trans/abap/HR_DATA.xls'.
OPEN DATASET ld_file FOR OUTPUT in text mode ENCODING DEFAULT .
IF sy-subrc = 0.
LOOP AT int_final.
CLEAR wa_string.
CONCATENATE int_final-employee_sno int_final-employee_code INTO wa_string SEPARATED BY con_tab.
CONCATENATE wa_string int_final-first_name INTO wa_string SEPARATED BY con_tab.
please help...
Edited by: Neliea on Oct 29, 2009 1:11 PMHi,
Please refer to these links.
[url]Re: Internal table to excel download?;url]
[url]Re: Transfer from Internal Table to EXCEL file...;url]
Regards,
Aditya -
Open a pdf file located on Application Server from forms 10g
Dear all,
I want to open a pdf file which is stored in a folder on Application Server.
I have the following codes but could not be able to open the file.
1. host('rundll32 url.dll,FileProtocolHandler C:\REP012.pdf');
in this code I mentioned the path on local machine which is okey.
but the question is that how to open the file which is located in a folder on application server?
the following code don't show and file or error:
host('rundll32 url.dll,FileProtocolHandler /EMS/MANUALS/ACC001.PDF');
This is the file on Application Server not on local machine.
2. web.show_document('//EMS/MANUALS/ACC001.PDF/','_blank');
This give HTTP 404 NOT FOUND error
I think the problem is in path, how to mention the path of my Application Server file?
Regards:
Muhammad NadeemHi,
Did you find a solution to this?
We are running into the same problem where we need to open a file present on the application server (path /opt/webapps/applications/ISL/)
When we try this from the local machine it works (path D:/forms) however it does not work while trying to open it from the application server.
Regards,
Pooja -
Creation of xml file in r3 application server (AL11)
Hi All
I need to create xml file in r3 application server (AL11) using PI.Can we achieve this using file adapter or we need to proceed with proxy. As I tried with file adapter with FTP transport protocol. Its giving the error as "Unable to create new pooled resource:FTPEx:Login incorrect".
Thanks in advance
Regards,
KartikeyaHi
need to create xml file in r3 application server (AL11) using PI.Can we achieve this using file adapter or we need to proceed with proxy.
To generate file at AL11 file directory use File adapter. Proxy is not required for this
Its giving the error as "Unable to create new pooled resource:FTPEx:Login incorrect".
1. Check with the Login credentials for the FTP service.
2. FTP User you use in communication channel must have 777 access to FTP location.
Thanks
Gaurav -
File from the Application server
Hi gurus,
I am working on a scenario where I need to get a file from the application server and for this I need to ask user to enter the location and that too at the selection screen and then I need to read this location using open data set and read data set in my program , once I am done with this I need to do some other validations. so can you please help me out how to achieve this.
Thanks
Rajeev GuptaHi
Declare the selection screen with file as parameter so that the user enter the application server file..
the use the OPEND DATASET as mentioned in below code and process
Refer this:
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3ca6358411d1829f0000e829fbfe/frameset.htm
ABAP code for uploading a TAB delimited file into an internal table. See code below for structures.
*& 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
Anji -
Printing files on the application server
Hi,
I am looking for ways to print files residing on the application server. Do you know of any function modules/transaction code that can do this?
Here is my situation:
I am using GRAPH_PRINT_POSTSCRIPT_FILE to print postscript file to the printer. I have no problem using this FM. The issue is that this function only prints files residing on the PC/local computer. It doesn't print any files on the application server.
Thanks in advance for any help you can provide.Hi,
use
CALL FUNCTION 'F4_DXFILENAME_4_DYNP'
EXPORTING
dynpfield_filename = 'P_FNAME'
dyname = 'ZFILE_HELP'
dynumb = sy-dynnr
filetype = 'P'
location = 'A'.
Thanks,
NN. -
Urgent :- Unable to deploy EAR file in Oracle application server
Hello folks,
I am trying to deploy an application containing jsps and servlets
packaged into EAR using ant. However when am trying to do so by using
the Deploy EAR option in the Enterprise manager, it throws the
following error -
"Invalid J2EE application file specified - Jar file:
/var/tmp/jar47241.tmp is missing its standard xml descriptor located at
META-INF/ejb-jar.xml"
I suspect that something could be wrong with regards to the way the ear
file has been created.
Please if someone could pin point the problem and help me understand
the the above error message , it will be of great help to me and I d
really appreciate this.
Many Thanks,
Ramn.Hello,
I try to deploy an ear file (contains jar and war files) in Oracle Application server in linux, but the time is so long. The same file I deploy in a OAS in windows and the deploy time was 2 minutes, but in linux I leave the hole night and the session close and the deploy in unable.
I don't know if I need configure an especial option in the OAS in Linux, how I can load my ear file.
The OAS in windows was installed with oc4j options only, but the OAS in linux was full installation
Please help me....
Thanks. -
File transfer into application server
Hi folks.
I need to retrieve header records from table MCHB and RESB and transfer it into file.
Again for the corresponding header record, i need to transfer item records retrived from table MKOL and LFA1 as well.
One file each is to be create per plant.
But,i am not able to get item data into file.
My coding....
LOOP AT i_mchb INTO wa_mchb.
l_clabs = wa_mchb-clabs.
SHIFT l_clabs LEFT DELETING LEADING space.
Summarize requirement quantity
LOOP AT i_resb INTO wa_resb.
wa_sum-charg = wa_resb-charg.
wa_sum-bdmng = wa_resb-bdmng.
COLLECT wa_sum INTO i_sum.
SORT i_sum BY charg.
ENDLOOP.
READ TABLE i_sum INTO wa_sum WITH KEY charg = wa_mchb-charg.
IF sy-subrc EQ 0.
l_bdmng = wa_sum-bdmng.
SHIFT l_bdmng LEFT DELETING LEADING space.
ENDIF.
Calculation on Available quantity
l_avqty = l_bdmng - l_clabs.
SHIFT l_avqty LEFT DELETING LEADING space.
AT NEW werks.
*Creation of file
PERFORM sub_create_file.
Open File on the application server for processing
OPEN DATASET g_file_name FOR OUTPUT IN TEXT MODE
ENCODING DEFAULT.
IF sy-subrc NE 0.
*Display error message
MESSAGE i055 WITH g_file_name.
" Error in opening file
LEAVE LIST-PROCESSING.
ENDIF.
ENDAT.
Transfering data to file
CONCATENATE c_header "Header indentification
wa_mchb-matnr " Material number
wa_mchb-werks " Plant
wa_mchb-lgort " Storage location
wa_mchb-charg " Batch number
l_clabs " Valuated stock-unrestricted use
l_bdmng " Requirement quantity
l_avqty " Avalable quantity.
INTO l_record.
TRANSFER l_record TO g_file_name.
CLEAR: l_clabs,
l_bdmng,
l_avqty,
l_record.
READ TABLE i_mkol INTO wa_mkol WITH KEY matnr = wa_mchb-matnr
werks = wa_mchb-werks
lgort = wa_mchb-lgort
charg = wa_mchb-charg
BINARY SEARCH.
IF sy-subrc EQ 0.
l_tabix = sy-tabix.
LOOP AT i_mkol INTO wa_mkol FROM l_tabix.
*Population of consignment stock-unrestricted use
l_slabs = wa_mkol-slabs.
SHIFT l_slabs LEFT DELETING LEADING space.
READ TABLE i_lfa1 INTO wa_lfa1 WITH KEY lifnr = wa_mkol-lifnr.
sy-subrc check not done
CONCATENATE c_item " Item identification
l_slabs
" Consignment stock-unrestricted use
wa_mkol-lifnr " Vendor account number
wa_lfa1-name1 " Vendor name
INTO l_record.
TRANSFER l_record TO g_file_name.
CLEAR: l_slabs,
l_record.
ENDLOOP.
ENDIF.
AT END OF werks.
Close File
CLOSE DATASET g_file_name.
CLEAR g_file_name.
ENDAT.
ENDLOOP.Hi,
Yes thats correct. When using AT NEW. The field in internal table after the WERKS field will have ASTERSIK .
So before AT NEW. Assign the work area to another work area. Eg.
WA_mchb1 = wa_mchb.
Later on i.e. After ENDAT use everywhere WA_MCHB1 and not not WA_MCHB.
This will solve the problem.
wa_sum-charg = wa_resb-charg.
wa_sum-bdmng = wa_resb-bdmng.
COLLECT wa_sum INTO i_sum.
SORT i_sum BY charg.
ENDLOOP.
READ TABLE i_sum INTO wa_sum WITH KEY charg = wa_mchb-charg.
IF sy-subrc EQ 0.
l_bdmng = wa_sum-bdmng.
SHIFT l_bdmng LEFT DELETING LEADING space.
ENDIF.
Calculation on Available quantity
l_avqty = l_bdmng - l_clabs.
SHIFT l_avqty LEFT DELETING LEADING space.
<b>clear wa_mchb_new.</b>
<b>wa_mchb_new = wa_mchb.</b>
AT NEW werks.
*Creation of file
PERFORM sub_create_file.
Open File on the application server for processing
OPEN DATASET g_file_name FOR OUTPUT IN TEXT MODE
ENCODING DEFAULT.
IF sy-subrc NE 0.
*Display error message
MESSAGE i055 WITH g_file_name.
" Error in opening file
LEAVE LIST-PROCESSING.
ENDIF.
ENDAT.
Transfering data to file
CONCATENATE c_header "Header indentification
<b>wa_mchb_new-matnr " Material number
wa_mchb_new-werks " Plant
wa_mchb_new-lgort " Storage location
wa_mchb_new-charg " Batch number</b>l_clabs " Valuated stock-unrestricted use
l_bdmng " Requirement quantity
l_avqty " Avalable quantity.
INTO l_record.
TRANSFER l_record TO g_file_name.
CLEAR: l_clabs,
l_bdmng,
l_avqty,
l_record.
READ TABLE i_mkol INTO wa_mkol WITH KEY matnr = <b>wa_mchb_new-matnr
werks = wa_mchb_new-werks
lgort = wa_mchb_new-lgort
charg = wa_mchb_new-charg</b>BINARY SEARCH.
IF sy-subrc EQ 0.
l_tabix = sy-tabix.
LOOP AT i_mkol INTO wa_mkol FROM l_tabix.
*Population of consignment stock-unrestricted use
l_slabs = wa_mkol-slabs.
SHIFT l_slabs LEFT DELETING LEADING space.
READ TABLE i_lfa1 INTO wa_lfa1 WITH KEY lifnr = wa_mkol-lifnr.
sy-subrc check not done
CONCATENATE c_item " Item identification
l_slabs
" Consignment stock-unrestricted use
wa_mkol-lifnr " Vendor account number
wa_lfa1-name1 " Vendor name
INTO l_record.
TRANSFER l_record TO g_file_name.
CLEAR: l_slabs,
l_record.
ENDLOOP.
ENDIF.
AT END OF werks.
Close File
CLOSE DATASET g_file_name.
CLEAR g_file_name.
ENDAT.
ENDLOOP.
Best regards,
Prashant
PS : Please reward all helpful answers
Message was edited by: Prashant Patil
Message was edited by: Prashant Patil -
Split tab delimited file coming from application server.
Hi,
i have received a tab delimited file from the application server.it contains # instead of tab at the application server.
i want to know how to split it.
i tried decalring constant as:
c_tab type x value'09'.
but it gives an error saying only c,n,d and t types are allowed.
please gelp.
Thanks,
Anand.Hi,
Do like this
*--Local Variables
DATA : l_file TYPE string,
l_line TYPE string.
*--Clear
CLEAR : l_file.
l_file = p_ipfile.
*--Read the data from application server file.
OPEN DATASET l_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
*--Error in opening file
MESSAGE i368(00) WITH text-005.
ENDIF.
*--Get all the records from the specified location.
DO.
READ DATASET l_file INTO l_line.
IF sy-subrc NE 0.
EXIT.
ELSE.
SPLIT l_line AT cl_abap_char_utilities=>horizontal_tab
INTO st_ipfile-vbeln
st_ipfile-posnr
st_ipfile-edatu
st_ipfile-wmeng.
APPEND st_ipfile TO it_ipfile.
ENDIF.
ENDDO.
*--Close dataset
CLOSE DATASET l_file.
Regards,
Prashant -
Maximum length of header in the file on the application server?
Hi there,
I am uploading a file on the application server. I am writing the header separately which is column heading in char format. Then I am writing the data to that file.
Now the problem is, I am unable to get more than 256 chars for each line in the file, including header, in <b>AL11 file view</b> and while I am <b>downloading that file on to my desktop</b>, I am <b>not</b> getting more than 256 chars from <b>header </b> line in my excel sheet however I am getting all the chars i.e. more than 256 chars of all the <b>data line</b>.
Please can you tell,what could be the problem or let me know any way to see and download all the header line fields.I am using more than 256 chars at both the places i.e. header and data line. Still I am not getting more than 256 chars in the file.
However while downloading that file onto the desktop, it is not showing more than 256 chars for the header part, but it showing all the values of data line, exceeding 256 chars. -
Convert file path in application server as link
How can we convert file path in application server as link to send email.
Thanks
SureshYour app server folders have a mappable location on your network, e.g,
server\path\filename. Use an HTML anchor tag and build the link with code. You'd be better off storing files on a file server (write to a mapped location from the app server) and link to there (same process). -
Excel file cannot connect to server, offline copy
Good day,
I have a user in my company's portal (SharePoint 2007) that cannot upload changes made in excel file.
He needs to have the compatibility view active in IE in order to be able to open the documents.
If he does not have the compatibility view of IE for the application he gets an error saying that "cannot connect to the server".
With the compatibility view the user is able to open documents, but what happens is that the excel file connection to the server.
So changes to the excel file are not submitted to the server.
Does anyone have any idea of how to fix this issue?
Is there any other information i can provide that can help on this issue?
Thank you.What is the OS version?
What is the Office version ?
Regards,
Pratik Vyas | SharePoint Consultant |
http://sharepointpratik.blogspot.com
Posting is provided AS IS with no warranties, and confers no rights
Please remember to click Mark As Answer if a post solves your problem or
Vote As Helpful if it was useful. -
How to see the file at the application server
HI TO ALL SDNERS ,
THIS IS MY CODE WHERE TO CHECK THE DOWNLOADED FILE AT THE APPLICATION SERVER.IN TCODE AL11 I HAVE SEEN THERE IS NO FILE GETTING CREATED.WHEN TRANSFERRING THE SY-SUBRC VALUE IS ZERO.
Program Name : ZME11_BDC.
Title : PURCHASE INFORMATION RECORD LOAD PROGRAM
Program Objective : THIS PROGRAM READS IN THE PURCHASE
INFORMATION FILE. IT CREATES A BDC SESSION TO
USE TO LOAD THE PURCHASE INFORMATION RECORDS
INTO SAP using the ME11 Transaction.
REPORT ZME11_BDC no standard page heading MESSAGE-ID ZHNC line-size 55.
constants declaration
constants: c_x value 'X',
c_sess type apqi-groupid value 'zcustomer',
c_xd01 type tstc-tcode value 'ME11'.
DECLARING VARIABLES
DATA: V_MSG(255),
V_ERREC TYPE I,"NO OF FAILED RECORDS
V_LINES."NO OF RECORDS
FLAG DECLARATIONS
DATA: FG_DATA_EXIST VALUE 'X',"CHECK FOR DATA
FG_SESSION_OPEN VALUE ''.
STRUCTURES AND INTERNAL TABLE DECLARATIONS
TYPES :BEGIN OF TY_PIR,
LIFNR TYPE EINA-LIFNR,
MATNR TYPE EINA-MATNR,
EKORG TYPE EINE-EKORG,
WERKS TYPE EINE-WERKS,
VERKF TYPE EINA-VERKF,"sales person
TELF1 TYPE EINA-TELF1,"telephone
URZLA TYPE EINA-URZLA,"country
REGIO TYPE EINA-REGIO,"region
APLFZ(5),"plan deleivery time
EKGRP TYPE EINE-EKGRP,"purchase group
NORBM(13),
NETPR(13),
END OF TY_PIR.
DATA : IT_PIR TYPE TABLE OF TY_PIR,
WA_PIR LIKE LINE OF IT_PIR.
DATA: BEGIN OF IT_BDCDATA.
INCLUDE STRUCTURE BDCDATA.
DATA END OF IT_BDCDATA.
DATA : BEGIN OF IT_BDCMSG.
INCLUDE STRUCTURE BDCMSGCOLL.
DATA END OF IT_BDCMSG.
SELECTION SCREEN
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETER : FNAME TYPE RLGRAP-FILENAME.
SELECTION-SCREEN END OF BLOCK B1.
AT SELECTION ON VALUE REQUEST
AT SELECTION-SCREEN ON VALUE-REQUEST FOR FNAME.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
IMPORTING
FILE_NAME = FNAME.
START OF SELECTION
START-OF-SELECTION.
PERFORM F_GET_DATA USING FNAME
CHANGING IT_PIR.
PERFORM F_GENERATE_DATASET USING FNAME
CHANGING IT_PIR WA_PIR.
*& Form F_GET_DATA
text
-->P_V_FNAME text
<--P_IT_PIR text
FORM F_GET_DATA USING P_FNAME LIKE FNAME
CHANGING P_IT_PIR LIKE IT_PIR.
DATA: LV_FILE TYPE STRING.
LV_FILE = FNAME.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = LV_FILE
FILETYPE = 'DAT'
HAS_FIELD_SEPARATOR = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
DATA_TAB = P_IT_PIR
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
IF P_IT_PIR IS INITIAL.
FG_DATA_EXIST = ''.
ENDIF.
ENDFORM. " F_GET_DATA
*& Form F_GENERATE_DATASET
text
-->P_V_FNAME text
<--P_IT_PIR text
FORM F_GENERATE_DATASET USING P_V_FNAME LIKE FNAME
CHANGING P_IT_PIR LIKE IT_PIR
P_WA_PIR LIKE WA_PIR.
MESSAGE I001(ZHNC).
*OPENING FILE AT THE APPLICATION SERVER FOR WRITING
OPEN DATASET FNAME FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC EQ 0.
MESSAGE I002(ZHNC).
LOOP AT P_IT_PIR INTO P_WA_PIR.
SPLIT P_WA_PIR AT '*' INTO P_WA_PIR-LIFNR
P_WA_PIR-MATNR
P_WA_PIR-EKORG
P_WA_PIR-WERKS
P_WA_PIR-VERKF
P_WA_PIR-TELF1
P_WA_PIR-URZLA
P_WA_PIR-REGIO
P_WA_PIR-APLFZ
P_WA_PIR-EKGRP
P_WA_PIR-NORBM.
*TRANSFER THE FILE FROM INTERNAL TABLE TO APPLICATION SERVER
MESSAGE I003(ZHNC).
TRANSFER P_WA_PIR TO FNAME.
ENDLOOP.
*CLOSING THE FILE AT THE APPLICATION SERVER
CLOSE DATASET FNAME.
ENDIF.Hello,
I made a similar program. You can have a look at it.
*& Form write_to_app_server
text
--> p1 text
<-- p2 text
FORM write_to_app_server.
To get filename
PERFORM get_filename.
To write into the application server
OPEN DATASET g_filename_with_path FOR OUTPUT IN TEXT MODE.
IF sy-subrc = 0.
LOOP AT <l_table> INTO <l_line>.
TRANSFER <l_line> TO g_filename_with_path.
ENDLOOP.
CLOSE DATASET g_filename_with_path.
ELSE.
CLOSE DATASET g_filename_with_path.
ENDIF.
To send mail
PERFORM send_mail.
ENDFORM. " write_to_app_server
*& Form get_filename
text
--> p1 text
<-- p2 text
FORM get_filename.
DATA : l_log_path TYPE filepath-pathintern
VALUE 'Y28M_DOWNLOADS_BACKGROUND' .
CALL FUNCTION 'FILE_GET_NAME_USING_PATH'
EXPORTING
client = sy-mandt
logical_path = l_log_path
operating_system = sy-opsys
file_name = p_fname
IMPORTING
file_name_with_path = g_filename_with_path
EXCEPTIONS
path_not_found = 1
missing_parameter = 2
operating_system_not_found = 3
file_system_not_found = 4
OTHERS = 5.
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. " get_filename
You may find it useful.
Regards,
Karuna.
Maybe you are looking for
-
Work flow is indesign + XML How to export the incopy file form indesign application file When I export the content form the application file most of the text disappear in the incopy file. Warm regards Sreekarthikeyan k
-
USB 2 card for a Gigabit PowerMac
I own a Year 2000 Gigabit PowerMac. I also own a 2nd generation iPod, powered by Firewire. However, I'm looking at getting a new iPod, which no longer supports Firewire. I'm hoping that I will be able to once again upgrade my current PowerMac and ins
-
I have an arraycollection, Called myPrices. I just want to display the Product number from the arraycollection. I dont know the syntax. This gets me [Object.object] <mx:Text text="{myPrices}"/> If I make a datagrid and make one column be PWDL01 I get
-
Is "Clustering" Computers Intangible or Possibly Useful for Rendering?
I have no money. However, I do have two computers available to me. From what I've heard, it may be possible to "cluster" these computers to be able to use the utilities on both; what I mean; Computer A has Processor 1 Computer B has Processor 2 Whe
-
Display residual leave in team calender
Hi, when clicking in the team calender on a certain absence details will be shown below. The detail data does not include the residual leave although we have a screenshot where the residual leave is shown. Does anyone know how to make the residual le