Upload text file from PC to table control
Hi Experts,
I realize that this question was posted many times in SDN, but I am not able to find a clear answer. I have uploaded the file into internal table using GUI_UPLOAD function module (PAI module - MODULE UPLOAD_FROM_PC - I have created a push button using screen painter and included the logic based of fcode). Now, I want to append this internal table to the internal table linked to the table control. But I am not able to find the internal table which is linked to the table control. The EXTRACT is not an internal table. So, could you tell me how I could accomplish this logic.
PROCESS BEFORE OUTPUT.
MODULE LISTE_INITIALISIEREN.
LOOP AT EXTRACT WITH CONTROL TCTRL_ZKK_EXAMPLE1 CURSOR NEXTLINE.
MODULE LISTE_SHOW_LISTE.
ENDLOOP.
PROCESS AFTER INPUT.
MODULE LISTE_EXIT_COMMAND AT EXIT-COMMAND.
MODULE LISTE_BEFORE_LOOP.
LOOP AT EXTRACT.
MODULE LISTE_INIT_WORKAREA.
CHAIN.
FIELD ZKK_EXAMPLE1-ANLKL .
MODULE SET_UPDATE_FLAG ON CHAIN-REQUEST.
ENDCHAIN.
FIELD VIM_MARKED MODULE LISTE_MARK_CHECKBOX.
CHAIN.
FIELD ZKK_EXAMPLE1-ANLKL .
MODULE LISTE_UPDATE_LISTE.
ENDCHAIN.
ENDLOOP.
MODULE UPLOAD_FROM_PC.
MODULE LISTE_AFTER_LOOP.
Thanks
Sri
Hi
First of all convert excel or text file into tabular format
(meanse same as we use in BDC).
here table I_EXCL structure is same as your table control structure.
for ex.
yr table control structure is
u can write down this coding in yr button press event.
data:begin of extract occurs 0,
matnr like matnr,
maktx like maktx,
end of extract.
data:i_excl like extract occurs 0 with header line.
GET THE FILE PATH
DATA:W_FILENAME LIKE RLGRAP-FILENAME.
CLEAR:W_FILENAME,extract[].
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
PROGRAM_NAME = SYST-REPID
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
STATIC = ' '
MASK = ' '
CHANGING
FILE_NAME = W_FILENAME
EXCEPTIONS
MASK_TOO_LONG = 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.
IF W_FILENAME IS NOT INITIAL.
CONVERT EXCEL FILE INTO INTERNAL TABLE
CLEAR:I_EXCL.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
CODEPAGE = ' '
FILENAME = W_FILENAME
FILETYPE = 'DAT'
HEADLEN = ' '
LINE_EXIT = ' '
TRUNCLEN = ' '
USER_FORM = ' '
USER_PROG = ' '
DAT_D_FORMAT = ' '
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = I_EXCL
EXCEPTIONS
CONVERSION_ERROR = 1
FILE_OPEN_ERROR = 2
FILE_READ_ERROR = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_WIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
NO_AUTHORITY = 10
OTHERS = 11
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
After this in PBO module u can write
process before output
MODULE TAB_ENTRY_CHANGE_TC_ATTR.
MODULE TAB_ENTRY_CHANGE_TC_ATTR.
loop at i_excl.
extract-matnr = i_excl-matnr.
extract-maktx = i_excl-maktx.
append extract.
endloop.
endmodule.
I hope this is helpfull to solve yr problem.
Edited by: Pavan Gajjar on Mar 26, 2008 9:57 AM
Similar Messages
-
How to upload a text file from a shared folder and provide an o/p
how to upload a text file from a shared folder and provide an o/p containing the details in each order in the text file
Hi,
Use <b>GUI_UPLOAD</b> to upload a text file from a shared folder.
Use <b>GUI_DOWNLOAD</b> to download data in a file on the presentation server or use <b>OPEN DATASET, TRANSFER</b> and <b>CLOSE DATASET</b> statements to download data to the application server.
Now, I hope the code for data fetching, if required, is already present in the report.
Reward points if the answer is helpful.
Regards,
Mukul -
'No Upload Authorization' While Uploading a Text File from Multiple Select
Hi all,
The User is trying to upload a text file from Multiple Selection screen of a Query in BEx and it gives the error message of 'No Upload Authorization' (Error DB886).
In 'Logon data' tab of Tcode SU01, it has 'User' for 'User Group for Authorization check' for this User.
I could upload a text file from Multiple Selection screen with my User Id.
An idea about this error, PLEASE ?
Thanks,
Venkat.Hi Ron,
This User does not have the access to Tcode ST01.
The user executed Tcode SU53 immediately following the authorization failure to see the authorization objects. The 'Authorization obj' is blank and under the Description it has 'The last Authorization check was successful' with green tick mark.
Any further suggestions, PLEASE.
Thanks. -
Upload text file to oracle table with checking and aggregation
Hi Friends,
I am new to ODI. I have encountered a problem which is specific to ODI 11G (11.1.1.6.3) to upload text file to oracle table with checking and aggregation. Would you please teach me how to implement the following requirement in ODI 11G?
Input text file a:
staffCode, staffCat, status, data
input text file b:
staffCodeStart, staffCodeEnd, staffCat
temp output oracle table c:
staffCat, data
output oracle table d:
staffCat, data
order:
a.staffCode, a.staffCat, a.status
filter:
a.status = ‘active’
join:
a left outerjoin b on a.staffCode between b.staffCodeStart and b.staffCodeEnd
insert temp table c:
c.staffCat = if b.staffCat is not null then b.staffCat else a.staffCat
c.data = a.data
insert table d:
if c.staffCat between 99 and 1000 then d.staffCat = c.staffCat, d.data = sum(c.data)
else d.staffCat = c.staffCat, d.data = LAST(c.data)
Any help on fixing this is highly appreciated. Thanks!!
Thanks,
ChrisDear Santy,
Many thanks for your prompt reply. May I have more information about the LAST or SUM step?
I was successful to create and run the following interfaces p and q
1. Drag text file a to a newly created interface panel p
2. Filter text file a : a.status = ‘active’
3. Lookup text file a to text file b : a.staffCode between b.staffCodeStart and b.staffCodeEnd
4. Drag oracle temp table c to interface panel p
5. Set c.staffCat : CASE WHEN b.staffCat IS NULL THEN a.staffCat ELSE b.staffCat END
6. Set c.data : a.data
7. Drag oracle temp table c to a newly created interface panel q
8. Drag oracle table d to interface panel q
9. Set UK to d.staffCat
10. Set Distinct Rows to table d
11. Set d.staffCat = c.staffCat
12. Set d.data = SUM(c.data)
However, the interface q should be more than that:
If c.staffCat is between 99 and 1000, then d.data = the last record c.data; else d.data = sum(c.data)
Would you please teach me how to do the LAST or SUM steps? Moreover, can interface p and interface q be combined to one interface and do not use the temp table c? Millions thanks!
Regards,
Chris -
Uploading a text file from webi filter area as part of the query condition
Post Author: balasura
CA Forum: Publishing
Requirement : Uploading a text file from webi filter area as part of the query condition Hi, I am in a serious requirement which I am not sure available in BO XI. Can some one help me plz. I am using BO XI R2, webi I am generating a ad-hoc report, when I want to give a filter condition for a report, the condition should be uploaded from a .txt file. In the current scenario we have LOV, but LOV could hold only a small number of value, my requirement is just like a lov but the list of values will be available in a text file ( which could number to 2000 or 2500 rows). I would like to upload this 2500 values in the form of a flat text file to make a query and genrate report. Is it possible in BO XI? For Eg:- Select * from Shipment Where u201CShipment id = u2018SC4539u2019 or Shipment id = u2018SC4598u2019u201D The u201Cwhereu201D condition (filter) which has shipment id will be available in a text file and it needs to be loaded in the form of .txt file so that it will be part of the filter condition. Content of a .txt file could be this shipment.txt =============== SC4539 sc2034 SC2343 SC3892 . . . . etc upto 2500 shipment Ids I will be very glad if some could provide me a solution. Thanks in advance. - BalaHi Ron,
This User does not have the access to Tcode ST01.
The user executed Tcode SU53 immediately following the authorization failure to see the authorization objects. The 'Authorization obj' is blank and under the Description it has 'The last Authorization check was successful' with green tick mark.
Any further suggestions, PLEASE.
Thanks. -
Generating Text file from table using Shell script
I am using KSH for generating and FTPing a text file from a table.
While generating Text file I am not getting my Column names in orderly manner.
q2="select COLUMN1||' '||COLUMN2||' '||COLUMN3 from table1;"
set pagesize 0
set head off
set trimspool on
set trimout on
set colsep ' '
set linesize 1500
set trimspool on
spool /ss/app11/oastss/reports/$file2
select 'COLUMN1'||' '||'COLUMN2'||' '||'COLUMN3' from dual;
$q2
spool off;
EOF
I am getting the result some what like below in text file
COLUMN1 COLUMN2 COLUMN3
MALLIK_ACCT 17-SEP-11 908030482
MALLIK_ACCT 17-SEP-11 908266967
MALLIK_ACCT 17-SEP-11 909570766
I want the format like below
COLUMN1........ COLUMN2 .... COLUMN3
MALLIK_ACCT ...17-SEP-11 .... 908030482
MALLIK_ACCT ...17-SEP-11 .... 908266967
MALLIK_ACCT ...17-SEP-11 .... 909570766
I put dots(.) for illustration purpose.
column data length may icrease some times . it shoudl automatically adjust column and data so that they are in alignment. thanks in advance.Mallik wrote:
Hi my question is to format the headers so that they will be in alignment with column data and readable.So you want to output a query as a fixed width format data file? How about this (rather than using scripts)...
As sys user:
CREATE OR REPLACE DIRECTORY TEST_DIR AS '\tmp\myfiles'
GRANT READ, WRITE ON DIRECTORY TEST_DIR TO myuser
/As myuser:
CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2
,p_dir IN VARCHAR2
,p_header_file IN VARCHAR2
,p_data_file IN VARCHAR2 := NULL) IS
v_finaltxt VARCHAR2(4000);
v_v_val VARCHAR2(4000);
v_n_val NUMBER;
v_d_val DATE;
v_ret NUMBER;
c NUMBER;
d NUMBER;
col_cnt INTEGER;
f BOOLEAN;
rec_tab DBMS_SQL.DESC_TAB;
col_num NUMBER;
v_fh UTL_FILE.FILE_TYPE;
v_samefile BOOLEAN := (NVL(p_data_file,p_header_file) = p_header_file);
BEGIN
c := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
d := DBMS_SQL.EXECUTE(c);
DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
FOR j in 1..col_cnt
LOOP
CASE rec_tab(j).col_type
WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);
WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);
ELSE
DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
END CASE;
END LOOP;
-- This part outputs the HEADER
v_fh := UTL_FILE.FOPEN(upper(p_dir),p_header_file,'w',32767);
FOR j in 1..col_cnt
LOOP
CASE rec_tab(j).col_type
WHEN 1 THEN v_finaltxt := v_finaltxt||rpad(lower(rec_tab(j).col_name),rec_tab(j).col_max_len,' ');
WHEN 2 THEN v_finaltxt := v_finaltxt||rpad(lower(rec_tab(j).col_name),rec_tab(j).col_max_len,' ');
WHEN 12 THEN v_finaltxt := v_finaltxt||rpad(lower(rec_tab(j).col_name),greatest(19,length(rec_tab(j).col_name)),' ');
END CASE;
END LOOP;
UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
IF NOT v_samefile THEN
UTL_FILE.FCLOSE(v_fh);
END IF;
-- This part outputs the DATA
IF NOT v_samefile THEN
v_fh := UTL_FILE.FOPEN(upper(p_dir),p_data_file,'w',32767);
END IF;
LOOP
v_ret := DBMS_SQL.FETCH_ROWS(c);
EXIT WHEN v_ret = 0;
v_finaltxt := NULL;
FOR j in 1..col_cnt
LOOP
CASE rec_tab(j).col_type
WHEN 1 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
v_finaltxt := v_finaltxt||rpad(nvl(v_v_val,' '),rec_tab(j).col_max_len,' ');
WHEN 2 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
v_finaltxt := v_finaltxt||rpad(nvl(to_char(v_n_val,'fm99999999999999999999999999999999999999'),' '),rec_tab(j).col_max_len,' ');
WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
v_finaltxt := v_finaltxt||rpad(nvl(to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'),' '),greatest(19,length(rec_tab(j).col_name)),' ');
END CASE;
END LOOP;
UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
END LOOP;
UTL_FILE.FCLOSE(v_fh);
DBMS_SQL.CLOSE_CURSOR(c);
END;This allows for the header row and the data to be written to seperate files if required.
e.g.
SQL> exec run_query('select * from emp','TEST_DIR','output.txt');
PL/SQL procedure successfully completed.Output.csv file contains:
empno ename job mgr hiredate sal comm deptno
7369 SMITH CLERK 7902 17/12/1980 00:00:00800 20
7499 ALLEN SALESMAN 7698 20/02/1981 00:00:001600 300 30
7521 WARD SALESMAN 7698 22/02/1981 00:00:001250 500 30
7566 JONES MANAGER 7839 02/04/1981 00:00:002975 20
7654 MARTIN SALESMAN 7698 28/09/1981 00:00:001250 1400 30
7698 BLAKE MANAGER 7839 01/05/1981 00:00:002850 30
7782 CLARK MANAGER 7839 09/06/1981 00:00:002450 10
7788 SCOTT ANALYST 7566 19/04/1987 00:00:003000 20
7839 KING PRESIDENT 17/11/1981 00:00:005000 10
7844 TURNER SALESMAN 7698 08/09/1981 00:00:001500 0 30
7876 ADAMS CLERK 7788 23/05/1987 00:00:001100 20
7900 JAMES CLERK 7698 03/12/1981 00:00:00950 30
7902 FORD ANALYST 7566 03/12/1981 00:00:003000 20
7934 MILLER CLERK 7782 23/01/1982 00:00:001300 10
The procedure allows for the header and data to go to seperate files if required. Just specifying the "header" filename will put the header and data in the one file.
Adapt to output different datatypes and styles are required (this is currently coded for VARCHAR2, NUMBER and DATE) -
Upload xml file from aplication server using read dataset, parser error.
Hi,
I would like to upload xml file from app. server but parser failed. If I upload this xml file from workstation (using ws_upload) it is correct. For uploading xml file from app. server I use open dataset... read dataset. In loop section I remove '#' char. How do You upload xml file from app server? What Could be incorrect.
I try to open dataset in binary mode, text mode...
TYPES: BEGIN OF xml_line,
data(255) TYPE c,
END OF xml_line.
DATA: gt_xml_table TYPE TABLE OF xml_line,
gs_xml_structure TYPE xml_line,
gv_xml_table_size TYPE i.
OPEN DATASET s FOR INPUT IN BINARY MODE.
IF sy-subrc <> 0.
MESSAGE e001(zet) WITH '....'.
ENDIF.
DO.
READ DATASET s INTO gs_xml_structure.
IF sy-subrc <> 0.
EXIT.
ELSE.
len = STRLEN( gs_xml_structure ).
len = len - 1.
check len > 0.
WRITE gs_xml_structure(len) TO gs_xml_structure.
APPEND gs_xml_structure TO gt_xml_table.
ENDIF.
ENDDO.You Can do this too
parameters: p_file like rlgrap-filename.
data: subrc like sy-subrc.
create object me.
REFRESH t_data.
* Open XML File
CALL METHOD me->CREATE_WITH_FILE
EXPORTING
filename = p_file
RECEIVING
retcode = subrc.
* Saves Data in an itab from XML File.
CALL METHOD me->get_data
IMPORTING
retcode = subrc
CHANGING
dataobject = t_data[].
Regards,
Claudio. -
Download text file from application server to client server.
Hi all,
I am facing a format issue while downloading text file from application server to the client machine.
The issue is that, say I have 6 to 10 lines in my text file in application server. but when i store it on the hard drive,
it shoes all the data in a single line. Where as i need to download data in same format as in application server.
Awaiting for your responses.
Regards,
JoseHi,
If we want to upload file data from the application server to the internal table, there is no function module or class static method which we can use, we must wirte the code by ourselves.
1. For the file data which has no seperator between field columns.
PARAMETERS p_file TYPE dxfile-filename.
START-OF-SELECTION.
OPEN DATASET p_file IN TEXT MODE ENCODING DEFAULT FOR INPUT.
DO.
READ DATASET p_file INTO gds_data.
IF sy-subrc <> 0.
EXIT.
ENDIF.
APPEND gds_data TO gdt_data.
ENDDO.
CLOSE DATASET p_file.2. For the file data which has tab separator between field columns.
DATA: gds_field_split type gts_data.
FIELD-SYMBOLS: <fs_field> TYPE gts_data.
PARAMETERS p_file TYPE dxfile-filename.
START-OF-SELECTION.
OPEN DATASET prf_file IN TEXT MODE ENCODING DEFAULT FOR INPUT.
DO.
READ DATASET p_file INTO gds_field.
SPLIT gds_field AT cl_abap_char_utilities=>horizontal_tab
INTO TABLE gdt_field_split.
LOOP AT gdt_field_split into gds_field_split.
gdf_index = gdf_index + 1.
ASSIGN COMPONENT gdf_index OF STRUCTURE
gds_data to <fs_field>.
IF sy-subrc = 0.
<fs_field> = gds_field_split.
ENDIF.
ENDLOOP.
APPEND gds_data TO gdt_data.
ENDDO.
CLOSE DATASET p_file.
Thanks & regards,
ShreeMohan -
Upload XML file data into internal table
Hi,
I need help from you.
I am uploading XML file from Application server.
1.In application server under directory it may have several XML files and i need to upload all the XML files when we gave only directory name. So, what is the function module for that logic . If possible code also.
2.Once we get the files into some internal table we need to upload data from that files to internal table.
So what is the logic for that , if possible code also.
I am giving sample directory:
For example in this directory assume 3 xml files are there.
I need to upload those files and data from that in to internal table.
Thanks & Regards
VSRBelow code will give you an idea.
TYPE-POOLS: ixml. "iXML Library Types
*TABLES : rbkp.
TYPE DECLERATIION
TYPES: BEGIN OF type_tabpo,
ebeln TYPE ekko-ebeln, "PO document number
ebelp TYPE ekpo-ebelp, "PO line item
END OF type_tabpo.
TYPES: BEGIN OF type_ekbe,
belnr TYPE rbkp-belnr, "Invoice document
gjahr TYPE rbkp-gjahr, "fiscal year
END OF type_ekbe.
TYPES: BEGIN OF type_invoice,
belnr TYPE rbkp-belnr, "PO document number
gjahr TYPE rbkp-gjahr, "Fiscal Year
rbstat TYPE rbkp-rbstat, "invoice status
END OF type_invoice.
TYPES: BEGIN OF t_xml_line, "Structure for holding XML data
data(256) TYPE x,
END OF t_xml_line.
INTERNAL TABLE DECLERATIION
DATA: gi_tabpo TYPE STANDARD TABLE OF type_tabpo,
gi_ekbe TYPE STANDARD TABLE OF type_ekbe,
gi_invoice TYPE STANDARD TABLE OF type_invoice,
gi_bapiret2 TYPE STANDARD TABLE OF bapiret2.
DATA: l_ixml TYPE REF TO if_ixml,
l_streamfactory TYPE REF TO if_ixml_stream_factory.
DATA: l_xml_table TYPE TABLE OF t_xml_line, " XML Table of the structure
l_xml_line TYPE t_xml_line, " Record of structure t_xml_line
l_xml_table_size TYPE i. " XML table size
DATA: l_filename TYPE string.
WORK AREA DECLARATION
DATA: gw_tabpo TYPE type_tabpo,
gw_ekbe TYPE type_ekbe,
gw_invoice TYPE type_invoice,
gw_bapiret2 TYPE bapiret2.
BEGIN OF SELECTION SCREEN
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
PARAMETERS: p_file TYPE pathintern LOWER CASE DEFAULT '/usr/sap/tmp/'.
Validation of XML file: Only DTD included in XML document is supported
SELECTION-SCREEN END OF BLOCK blk1.
SELECTION SCREEN VALIDATION
AT SELECTION-SCREEN.
To validate p_file is not initial
PERFORM sub_validate_file.
PERFORM sub_validate_path.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
Request for filename for xml file from the application server
PERFORM sub_get_filename_appl USING p_file.
START OF SELECTION SCREEN
START-OF-SELECTION.
PERFORM sub_fetch_po_details.
PERFORM sub_get_invoice.
PERFORM sub_rel_invoice.
END OF SELECTION SCREEN
END-OF-SELECTION.
*& Form sub_validate_file
To Validate the file
FORM sub_validate_file .
IF p_file IS INITIAL.
MESSAGE e000. "specify the file path
ENDIF.
ENDFORM. " sub_validate_file
*& Form sub_get_filename_appl
form sub_get_filename_appl USING l_fname TYPE any.
DATA: l_fname TYPE filename-fileintern. " File name
*GET THE FILENAME FROM THE APPLICATION SERVER
CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'
EXPORTING
directory = l_fname
filemask = '*'
IMPORTING
serverfile = l_fname
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. " sub_get_filename_appl
*& Form sub_fetch_po_details
To fetch the PO details from the application server
Format of file is XML
FORM sub_fetch_po_details .
TYPE DECLERATIION
l_ixml = cl_ixml=>create( ).
Creating a stream factory
l_streamfactory = l_ixml->create_stream_factory( ).
PERFORM get_xml_table.
LOOP AT gi_tabpo INTO gw_tabpo.
WRITE:/ gw_tabpo.
ENDLOOP.
ENDFORM. " sub_fetch_po_details
*& Form get_xml_table
Read from the xml file
FORM get_xml_table .
Local variable declarations
DATA: l_len TYPE i,
l_len2 TYPE i,
l_tab TYPE tsfixml,
l_content TYPE string,
l_str1 TYPE string,
c_conv TYPE REF TO cl_abap_conv_in_ce,
l_itab TYPE TABLE OF string.
l_filename = p_file.
code to upload data from application server
OPEN DATASET l_filename FOR INPUT IN BINARY MODE.
IF sy-subrc 0.
WRITE:/ 'invalid file path'.
ENDIF.
DO.
READ DATASET l_filename INTO l_xml_line.
IF sy-subrc EQ 0.
APPEND l_xml_line TO l_xml_table.
ELSE.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET l_filename.
code to find the table size
DESCRIBE TABLE l_xml_table.
l_xml_table_size = ( sy-tleng ) * ( sy-tfill ).
*code to convert hexadecimal to XML
LOOP AT l_xml_table INTO l_xml_line.
c_conv = cl_abap_conv_in_ce=>create( input = l_xml_line-data
replacement
= space ).
c_conv->read( IMPORTING data = l_content len = l_len ).
CONCATENATE l_str1 l_content INTO l_str1.
ENDLOOP.
l_str1 = l_str1+0(l_xml_table_size).
SPLIT l_str1 AT cl_abap_char_utilities=>cr_lf INTO TABLE l_itab.
LOOP AT l_itab INTO l_str1.
REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>horizontal_tab IN
l_str1 WITH space.
ENDLOOP.
CALL TRANSFORMATION ('ID') " code to put in internal table
SOURCE XML l_str1
RESULT tab = gi_tabpo[].
ENDFORM. " get_xml_table -
hi
i want to create BDC program for the data uploding.. but i dont hv much knwloadge of about it. i need to sample code the data upload program. i hv to upload text file format. im using gui_upload funtion if u hv any sample plz send me it plz... thnx
regad
nawaCheck the following code:
Selection screen :
SELECTION-SCREEN BEGIN OF BLOCK b4 WITH FRAME TITLE text-020.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001 .
PARAMETERS: p_locl RADIOBUTTON GROUP g1 " desktop file
DEFAULT 'X' USER-COMMAND fil,
p_phys RADIOBUTTON GROUP g1. " appln server file
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002 .
PARAMETERS: p_ifile TYPE dxfile-filename LOWER CASE, " source file
p_afile TYPE dxfile-filename LOWER CASE, " asset class file
p_cfile TYPE dxfile-filename LOWER CASE, " Cost center file
p_dfile TYPE dxfile-filename LOWER CASE, " Depr key file
p_ofile TYPE dxfile-filename LOWER CASE. " Audit file
SELECTION-SCREEN END OF BLOCK b2.
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-015.
PARAMETERS: p_test RADIOBUTTON GROUP g2 DEFAULT 'X', " test run
p_create RADIOBUTTON GROUP g2. " data migretion
SELECTION-SCREEN END OF BLOCK b3.
SELECTION-SCREEN END OF BLOCK b4.
Main program :
REPORT zfaac900
LINE-SIZE 132
LINE-COUNT 65
NO STANDARD PAGE HEADING
MESSAGE-ID ZFAA.
* includes
INCLUDE: zfaac900_top,
zfaac900_selection_screen,
zfaac900_subroutine.
* AT SELECTION SCREEN ON VALUE REQUEST
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_ifile.
PERFORM help_input_file USING p_phys p_locl CHANGING p_ifile.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_afile.
PERFORM help_asset_file USING p_phys p_locl CHANGING p_afile.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_cfile.
PERFORM help_cost_file USING p_phys p_locl CHANGING p_cfile.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_dfile.
PERFORM help_depr_file USING p_phys p_locl CHANGING p_dfile.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_ofile.
PERFORM help_audit_file USING p_phys p_locl CHANGING p_ofile.
* AT SELECTION-SCREEN
AT SELECTION-SCREEN.
PERFORM check_screen USING p_ifile p_afile p_cfile p_dfile
p_ofile p_locl p_phys.
* TOP-OF-PAGE
TOP-OF-PAGE.
ULINE.
PERFORM sjm_heading IN PROGRAM zacai0005.
ULINE.
* START_OF_SELECTION
START-OF-SELECTION.
PERFORM get_input USING p_ifile p_afile p_cfile p_dfile
CHANGING i_input i_asset i_cost i_depr.
Subroutines :
*& Form help_input_file
* text
FORM help_input_file USING p_phys_file TYPE c
p_locl_file TYPE c
CHANGING p_source_path TYPE any.
IF p_phys_file EQ 'X'.
CALL FUNCTION 'F4_DXFILENAME_4_DYNP'
EXPORTING
dynpfield_filename = 'P_IFILE'
dyname = sy-repid
dynumb = sy-dynnr
filetype = 'P'
location = 'A'.
ELSEIF p_locl_file EQ 'X'.
PERFORM help_local_file CHANGING p_source_path.
ENDIF.
ENDFORM. " help_input_file
*& Form help_asset_file
* text
FORM help_asset_file USING p_phys_file TYPE c
p_locl_file TYPE c
CHANGING p_source_path TYPE any.
IF p_phys_file EQ 'X'.
CALL FUNCTION 'F4_DXFILENAME_4_DYNP'
EXPORTING
dynpfield_filename = 'P_AFILE'
dyname = sy-repid
dynumb = sy-dynnr
filetype = 'P'
location = 'A'.
ELSEIF p_locl_file EQ 'X'.
PERFORM help_local_file CHANGING p_source_path.
ENDIF.
ENDFORM. " help_asset_file
*& Form help_cost_file
* text
FORM help_cost_file USING p_phys_file TYPE c
p_locl_file TYPE c
CHANGING p_source_path TYPE any.
IF p_phys_file EQ 'X'.
CALL FUNCTION 'F4_DXFILENAME_4_DYNP'
EXPORTING
dynpfield_filename = 'P_CFILE'
dyname = sy-repid
dynumb = sy-dynnr
filetype = 'P'
location = 'A'.
ELSEIF p_locl_file EQ 'X'.
PERFORM help_local_file CHANGING p_source_path.
ENDIF.
ENDFORM. " help_cost_file
*& Form help_depr_file
* text
FORM help_depr_file USING p_phys_file TYPE c
p_locl_file TYPE c
CHANGING p_source_path TYPE any.
IF p_phys_file EQ 'X'.
CALL FUNCTION 'F4_DXFILENAME_4_DYNP'
EXPORTING
dynpfield_filename = 'P_DFILE'
dyname = sy-repid
dynumb = sy-dynnr
filetype = 'P'
location = 'A'.
ELSEIF p_locl_file EQ 'X'.
PERFORM help_local_file CHANGING p_source_path.
ENDIF.
ENDFORM. " help_depr_file
*& Form help_audit_file
* text
FORM help_audit_file USING p_phys_file TYPE c
p_locl_file TYPE c
CHANGING p_audit_path TYPE any.
IF p_phys_file EQ 'X'.
CALL FUNCTION 'F4_DXFILENAME_4_DYNP'
EXPORTING
dynpfield_filename = 'P_OFILE'
dyname = sy-repid
dynumb = sy-dynnr
filetype = 'P'
location = 'A'.
ELSEIF p_locl_file EQ 'X'.
PERFORM help_local_file CHANGING p_audit_path.
ENDIF.
ENDFORM. " help_audit_file
*& Form help_local_file
* Local File Path
FORM help_local_file CHANGING p_path TYPE any .
DATA: lt_file_table TYPE filetable,
la_file_table LIKE LINE OF lt_file_table,
l_rc TYPE i,
l_pcdsn TYPE cffile-filename.
REFRESH lt_file_table.
CLEAR la_file_table.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
CHANGING
file_table = lt_file_table
rc = l_rc.
READ TABLE lt_file_table INTO la_file_table INDEX 1.
l_pcdsn = la_file_table-filename.
MOVE l_pcdsn TO p_path.
ENDFORM. " help_local_file
*& Form check_phys_file
* Validation of Physical File
FORM check_phys_file USING p_file TYPE any.
DATA: l_str(300) TYPE c.
CLEAR l_str.
OPEN DATASET p_file IN TEXT MODE FOR INPUT ENCODING DEFAULT.
IF sy-subrc <> 0.
IF g_file_flag = 'I'.
MESSAGE e000 WITH text-021.
ELSEIF g_file_flag = 'A'.
MESSAGE e000 WITH text-095.
ELSEIF g_file_flag = 'C'.
MESSAGE e000 WITH text-096.
ELSEIF g_file_flag = 'D'.
MESSAGE e000 WITH text-097.
ENDIF.
ENDIF.
READ DATASET p_file INTO l_str.
IF sy-subrc <> 0.
IF g_file_flag = 'I'.
MESSAGE e000 WITH text-017.
ELSEIF g_file_flag = 'A'.
MESSAGE e000 WITH text-098.
ELSEIF g_file_flag = 'C'.
MESSAGE e000 WITH text-099.
ELSEIF g_file_flag = 'D'.
MESSAGE e000 WITH text-100.
ENDIF.
ENDIF.
CLEAR: g_file_flag.
CLOSE DATASET p_file.
ENDFORM. " check_phys_file
*& Form check_local_file
* Validation of Local File
FORM check_local_file USING p_file TYPE any.
DATA: l_size TYPE i.
CLEAR: l_size.
CALL FUNCTION 'TMP_GUI_GET_FILE_EXIST'
EXPORTING
fname = p_file
IMPORTING
* exist = l_exist
filesize = l_size
EXCEPTIONS
fileinfo_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
IF g_file_flag = 'I'.
MESSAGE e000 WITH text-016.
ELSEIF g_file_flag = 'A'.
MESSAGE e000 WITH text-101.
ELSEIF g_file_flag = 'C'.
MESSAGE e000 WITH text-102.
ELSEIF g_file_flag = 'D'.
MESSAGE e000 WITH text-103.
ENDIF.
ENDIF.
IF l_size IS INITIAL.
IF g_file_flag = 'I'.
MESSAGE e000 WITH text-024.
ELSEIF g_file_flag = 'A'.
MESSAGE e000 WITH text-107.
ELSEIF g_file_flag = 'C'.
MESSAGE e000 WITH text-108.
ELSEIF g_file_flag = 'D'.
MESSAGE e000 WITH text-109.
ENDIF.
ENDIF.
CLEAR: g_file_flag.
ENDFORM. " check_local_file
*& Form get_input
* To gate input data from local file or from application server
FORM get_input USING p_ifilename TYPE any
p_afilename TYPE any
p_cfilename TYPE any
p_dfilename TYPE any
CHANGING p_input_table TYPE t_input_table
p_asset_table TYPE t_asset_table
p_cost_table TYPE t_cost_table
p_depr_table TYPE t_depr_table.
* to populate the input table
PERFORM upload_file USING p_ifilename CHANGING i_local.
g_file_flag = 'I'.
PERFORM split_localtable CHANGING p_input_table p_asset_table
p_cost_table p_depr_table.
CLEAR g_file_flag.
REFRESH i_local.
* to populate the asset class table
PERFORM upload_file USING p_afilename CHANGING i_local.
g_file_flag = 'A'.
PERFORM split_localtable CHANGING p_input_table p_asset_table
p_cost_table p_depr_table .
CLEAR g_file_flag.
REFRESH i_local.
* to populate the cost center table
PERFORM upload_file USING p_cfilename CHANGING i_local.
g_file_flag = 'C'.
PERFORM split_localtable CHANGING p_input_table p_asset_table
p_cost_table p_depr_table .
CLEAR g_file_flag.
REFRESH i_local.
* to populate the depr key table
PERFORM upload_file USING p_dfilename CHANGING i_local.
g_file_flag = 'D'.
PERFORM split_localtable CHANGING p_input_table p_asset_table
p_cost_table p_depr_table .
CLEAR g_file_flag.
REFRESH i_local.
ENDFORM. " get_input
*& Form upload_file
* text
FORM upload_file USING p_filename TYPE any
CHANGING p_local_table TYPE t_local_table.
* To get the input data from desktop file
IF p_locl = 'X'.
DATA: l_file TYPE string.
CLEAR: l_file,
p_local_table.
l_file = p_filename.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = l_file
filetype = 'ASC'
TABLES
data_tab = p_local_table
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 e002 WITH l_file.
ENDIF.
ELSE.
* To get the data from application server file
OPEN DATASET p_filename IN TEXT MODE FOR INPUT ENCODING DEFAULT.
IF sy-subrc <> 0.
MESSAGE e001 WITH p_filename.
ENDIF.
CLEAR: wa_local.
DO.
READ DATASET p_filename INTO wa_local.
IF sy-subrc <> 0.
EXIT.
ENDIF.
APPEND wa_local TO p_local_table.
CLEAR: wa_local.
ENDDO.
CLOSE DATASET p_filename.
ENDIF.
ENDFORM. " upload_file
*& Form split_localtable
* text
FORM split_localtable CHANGING p_input_tab TYPE t_input_table
p_asset_tab TYPE t_asset_table
p_cost_tab TYPE t_cost_table
p_depr_tab TYPE t_depr_table.
DATA: l_cnt TYPE i.
CLEAR: l_cnt, wa_local.
LOOP AT i_local INTO wa_local.
REFRESH i_split[].
SPLIT wa_local AT c_tab INTO TABLE i_split.
CLEAR l_cnt.
ADD 1 TO l_cnt.
CLEAR wa_split.
LOOP AT i_split INTO wa_split.
IF g_file_flag = 'I'.
ASSIGN COMPONENT l_cnt OF STRUCTURE wa_input TO <fs_field>.
ELSEIF g_file_flag = 'A'.
ASSIGN COMPONENT l_cnt OF STRUCTURE wa_asset TO <fs_field>.
ELSEIF g_file_flag = 'C'.
ASSIGN COMPONENT l_cnt OF STRUCTURE wa_cost TO <fs_field>.
ELSEIF g_file_flag = 'D'.
ASSIGN COMPONENT l_cnt OF STRUCTURE wa_depr TO <fs_field>.
ENDIF.
CLEAR <fs_field>.
<fs_field> = wa_split-col.
ADD 1 TO l_cnt.
CLEAR wa_split.
ENDLOOP.
IF g_file_flag = 'I'.
APPEND wa_input TO p_input_tab.
CLEAR: wa_input .
ELSEIF g_file_flag = 'A'.
APPEND wa_asset TO p_asset_tab.
CLEAR: wa_asset .
ELSEIF g_file_flag = 'C'.
APPEND wa_cost TO p_cost_tab.
CLEAR: wa_cost .
ELSEIF g_file_flag = 'D'.
APPEND wa_depr TO p_depr_tab.
CLEAR: wa_depr .
ENDIF.
CLEAR: wa_local .
ENDLOOP.
ENDFORM. " split_localtable -
Upload a file from unix environment
hi
does anybody know which fm to use to upload a file from unix environment?
anjalihi sia,
try this.
parameters: p_file like rlgrap-filename obligatory
default '/usr/sap/upload.xls'.
types: begin of t_data,
vbeln like vbap-vbeln,
posnr like vbap-posnr,
matnr like vbap-matnr,
werks like vbap-werks,
megne like vbap-zmeng,
end of t_data.
data: it_data type standard table of t_data,
wa_data type t_data.
open dataset p_file for output in text mode encoding default.
if sy-subrc ne 0.
write:/ 'Unable to open file:', p_file.
else.
do.
read dataset p_file into wa_data.
if sy-subrc ne 0.
exit.
else.
append wa_data to it_data.
endif.
enddo.
close dataset p_file.
endif.
rgds
anver -
No Authorization To Upload Text file for a Variable
Hi Experts,
I am trying to upload a text file from Multiple Selection screen of a Query in Business Explorer and it gives the error message of 'No Upload Authorization'
An additional Information: I could able to Upload the text file when we were in SP17. Its recently upgraded to SP 21. Does this Upgradation of service pack has any Impact on this??
An idea about this error, PLEASE ?
Many Thanks in Advance.
Cheers,
KrishnaHi Panagiotis,
Have a look into the Portal Desktop link below.
http://help.sap.com/saphelp_nw70/helpdata/EN/ac/dc4f3eeb684212e10000000a11405a/frameset.htm
Somewhere mid section, you will find Portal Favourites (http://help.sap.com/saphelp_nw70/helpdata/EN/3a/d609e5803111d5992f00508b6b8b11/frameset.htm).
Make sure that Knowledge Management is installed on your system and that you have activated the Add to Portal Favorites property (this entry is displayed in the options menu of your page title bar).
http://help.sap.com/erp2005_ehp_03/helpdata/EN/84/a30a48887d4cb690b4f1754f651ba1/frameset.htm
If all above if set, then checkout the needed activities within the Portal Favourite iview setting.
http://help.sap.com/saphelp_nw70/helpdata/EN/1e/62eae2357c4596bda2476d0a6503e3/frameset.htm
Checkout on both the page title bar Options menu and the context menu of the Detailed Navigation iView display an Add to Portal Favorites item, allowing users to store links to favorites (thats where I believe your missing permission).
The Portal Favorites iView is part of the Knowledge Management installation and is integrated into the portal. Thus if the above steps are done and the settings activated, then your standard user should not see error in the Portal Favourites with the role that you have already assigned to the user.
Also look into Standard User (eu_role), which basic functionality (portal personalization iViews) for the core portal platform and default content for the Knowledge Management and Collaboration capabilities of SAP NetWeaver. By default, the Everyone group in the portal is assigned to this role.
http://help.sap.com/saphelp_nw70/helpdata/EN/47/f0f7415e639c39e10000000a155106/frameset.htm
Hope that helps.
Ray -
How to upload XML file from Application server.
Hi,
How to upload XML file from Application server.Please tell me as early as possible.
Regards,
Sagar.Hi,
parameters : p_file type ibipparms-path obligatory.
***DOWNLOAD---->SAP INTO EXCEL
filename1 = p_file.
call function 'GUI_DOWNLOAD'
exporting
BIN_FILESIZE =
filename = filename1
filetype = 'ASC'
APPEND = ' '
WRITE_FIELD_SEPARATOR = 'X'
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
CONFIRM_OVERWRITE = ' '
NO_AUTH_CHECK = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = ' '
TRUNC_TRAILING_BLANKS_EOL = 'X'
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
IMPORTING
FILELENGTH =
tables
data_tab = it_stock
FIELDNAMES =
exceptions
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
others = 22
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
Regards,
Deepthi. -
Upload text files with non-english characters
I use an Apex page to upload text files. Then i retrieve the contents of files from wwv_flow_files.blob_content and convert them to varchar2 with utl_raw.cast_to_varchar2, but characters like ò, à, ù become garbage.
What could be the problem? Are characters lost when files are stored in wwv_flow_files or when i do the conversion?
Some other info:
* I see wwv_flow_files.DAD_CHARSET is set to "ascii", wwv_flow_files.FILE_CHARSET is null.
* Trying utl_raw.cast_to_varchar2( utl_raw.cast_to_raw('àòèù') ) returns 'àòèù' correctly;
* NLS_CHARACTERSET parameter is AL32UTF8 (not just english ASCII)Hi
Have a look at csv upload -- suggestion needed with non-English character in csv file it might help you.
Thanks,
Manish -
Upload excel file (xls) into internal table in SRM 4.0
Hi experts!
I need upload a xls file into internal table (in ABAP report) in EBP machine for i work with data in the sheets. Can you help me?
Best Regard!Hi Zeky,
Try GUI_UPLOAD method of the class CL_GUI_FRONTEND_SERVICES
or FM ALSM_EXCEL_TO_INTERNAL_TABLE
Please look at this threads too:
/people/thomas.jung3/blog/2004/09/02/creating-a-bsp-extension-for-downloading-a-table
Upload XLS file from Application server into internal table.
Regards,
Marcin Gajewski
please reward points for helpful answers
Maybe you are looking for
-
How do I export addresses from a sent email to a group vcard?
I sent many of my existing contacts an email and now want to group those contacts in a vcard. They are all already in my address book but as there are several hundred contacts that I want to group together, I don't want to do this one by one. Does
-
Firmware 1.0.1 is out.
just installed it via iTunes. no idea what it does.
-
FREE SOFTWARE AND TRAINING FOR 'INSTANT E-COMMERCE' IN EUROPE
FREE SOFTWARE AND TRAINING FOR 'INSTANT E-COMMERCE' from BEA Systems - the E-Commerce Transactions Company Attend BEA's free technical seminars, and you'll walk away with both the knowledge and the BEA WebLogic software
-
IRecruitment new Functionality in R12.1
Can anyone share a Presentation of the coming new functionality in iRecruitment release 12.1? Thanks
-
Major Printing bug in 10.4.8?
I have three computers networked on wifi and ethernet; 2 macs and a PC. Mac 1 is an iMac G4 flat panel (ethernet) running 10.4.8. Mac 2 is a G4 Powerbook (wifi) running 10.3.9, and the PC is XP (wifi). I can print to my LaserJet2600n without a proble