ABAP program to output data from SAP table to an XML format file?
hello ABAP experts,
Does anyone know how to output data from SAP table to an XML format file? Would be appreciated if someone show the detailed sample codes and we will give you reward points!
Thanks!
Edited by: Jose Hugo De la cruz on Aug 19, 2009 8:23 PM
Similar Messages
-
Craete a simple abap object to select data from a table and display
Hi,
I know the concept of abap objects but i never worked on it,
can any one give me simple example of how to create an abap object to display data from mara table.also please send me documents or info regd ABAP OBJECTS.
I want to write a simple report in terms of abap object
Regards,
Sowjanyahi,
Here is hte sample program in se38.
REPORT ZFGLI00003
*-- Include for data declarations and performs
include ZFGLI00003_f01.
*--Include for Classes and their Implementation
include ZFGLI00003_cl.
* selection-screen *
*-- Selection Values : Block1
selection-screen begin of block b1 with frame title text-001.
*-- Ledger
parameters: p_rldnr like zzprodnt-rldnr default 'NP'.
*-- Fiscal year
parameters: p_ryear like zzprodnt-ryear.
*-- Period(month)
parameters: p_rpmax like zzprodnt-rpmax.
selection-screen end of block b1.
*-- Selection Values : Block2
selection-screen begin of block b2 with frame title text-002.
*-- Company ID's
select-options : s_glcomp for ZZPRODNT-ROBUKRS .
*-- Profit Center
select-options : s_prctr for ZZPRODNT-RPRCTR .
*-- Product Assignment
select-options : s_prasn for ZZPRODNT-RZZWWZ01 .
*-- Corporate Brand
select-options : s_crpbd for ZZPRODNT-RZZWWZ05 .
selection-screen end of block b2.
*-- Selection Values : Block3 Download Options
selection-screen begin of block b3 with frame title text-003.
parameters : p_local radiobutton group 1,
p_unix radiobutton group 1,
p_path like rlgrap-filename obligatory
default 'C:P20Z_Formatted.txt'(009).
selection-screen end of block b3.
* At Selection-Selection on value-request for file path *
at selection-screen on value-request for p_path.
if p_unix <> 'X'.
*-- Getting F4 help for output file
perform get_filename changing p_path.
else.
message i999(zi) with
'Sorry !! Function not available for UNIX file.'(i01).
endif.
*-- At selection screen validations
at selection-screen on p_path.
if p_unix <> 'X'.
*-- Validate local file
if p_path+1(2) <> ':'.
message e999(zi) with 'Invalid file path'(006).
endif.
else.
*-- Validate unix file
if p_path+0(1) <> '/'.
message e999(zi) with 'Invalid file path'(006).
endif.
endif.
* Initialization *
initialization.
*-- Initialize the period
perform init_period changing p_rpmax p_ryear.
* start-of-selection *
start-of-selection.
data : o_tm1_intf type ref to lcl_tm1_intf.
create object o_tm1_intf.
*-- Extract the data from ZZPRODNT
call method o_tm1_intf->get_data exporting e_rldnr = p_rldnr
e_ryear = p_ryear
e_rpmax = p_rpmax
e_glcomp = s_glcomp[]
e_prctr = s_prctr[]
e_prasn = s_prasn[]
e_crpbd = s_crpbd[]
importing i_subrc = v_subrc.
* INCLUDE ZFGLI00003_CL *
* CLASS lcl_tm1_intf IMPLEMENTATION
class lcl_tm1_intf definition.
public section.
*-- Data Declaration
data : lv_date type sy-datum, "Date
lv_time type sy-uzeit, "Time
lv_count type i, "Count for total records
lv_acsline type zfgl014-acsline,"ACS line code
lv_amt_curr type zzprodnt-kslvt, "current month amount
lv_amt_ytd type zzprodnt-kslvt, "YTD Amount
lv_check, "check if any record is
"downloaded
lv_msg(100), "message
lv_count_s(5) , "Count for total(char)
lv_amt_curr_s(23), "Current month amount(char)
lv_amt_ytd_s(23), "YTD Amount(char)
lv_ksl_pd(17), "KSLxx
lv_period(2) type n. "month(period)
*-- Types Declaration
types : ty_rldnr type zzprodnt-rldnr, "Type for Ledger
ty_ryear type zzprodnt-ryear, "Type for Fiscal Year
ty_rpmax type zzprodnt-rpmax, "Type for Period
ty_glcomp type range of char4, "Type for company selection
ty_prctr type range of char10, "Type for profit center sel
ty_prasn type range of char6, "Type for prod assignmt sel
ty_crpbd type range of char4, "Type for Corp Brand sel
begin of ty_file, "Type for File
line(150),
end of ty_file,
begin of ty_ZZPRODNT, "Type-ledger summary table
company type OBUKR, "Company
gl_acct type RACCT, "GL Account
cst_ctr type KOSTL, "Cost Center
prt_ctr type PRCTR, "Profit Center
rfarea type FKBER, "Functional Area
wbs_ele type PS_POSID, "WBS Element
prd_*** type RKEG_WWZ01, "Product Assignment
corp_bd type RKEG_WWZ05, "Corporate Brand
ksl01 type KSLXX9, "Total of transactions - 01
ksl02 type KSLXX9, "Total of transactions - 02
ksl03 type KSLXX9, "Total of transactions - 03
ksl04 type KSLXX9, "Total of transactions - 04
ksl05 type KSLXX9, "Total of transactions - 05
ksl06 type KSLXX9, "Total of transactions - 06
ksl07 type KSLXX9, "Total of transactions - 07
ksl08 type KSLXX9, "Total of transactions - 08
ksl09 type KSLXX9, "Total of transactions - 09
ksl10 type KSLXX9, "Total of transactions - 10
ksl11 type KSLXX9, "Total of transactions - 11
ksl12 type KSLXX9, "Total of transactions - 12
ksl13 type KSLXX9, "Total of transactions - 13
ksl14 type KSLXX9, "Total of transactions - 14
ksl15 type KSLXX9, "Total of transactions - 15
ksl16 type KSLXX9, "Total of transactions - 16
end of ty_ZZPRODNT.
*-- Structure Declaration
* Structure for final file
data : x_file type ty_file,
* Structure for Product Ledger Summary table
x_ZZPRODNT type ty_ZZPRODNT,
* Structure for Functional Area to ACS line mapping
x_zfgl014 type zfgl014.
*-- Internal Table Declaration
* Table for records of Product Ledger Summary table
data : it_ZZPRODNT type table of ty_ZZPRODNT,
* Table for final file
it_file type table of ty_file,
* Table for Functional Area to ACS line mapping
it_zfgl014 type table of zfgl014.
*-- Method Declaration.
methods : get_data importing e_rldnr type ty_rldnr
e_ryear type ty_ryear
e_rpmax type ty_rpmax
e_glcomp type ty_glcomp
e_prctr type ty_prctr
e_prasn type ty_prasn
e_crpbd type ty_crpbd
exporting i_subrc type sy-subrc.
endclass. "lcl_tm1_intf DEFINITION
* CLASS lcl_tm1_intf IMPLEMENTATION
class lcl_tm1_intf implementation.
*-- Method get_data selects the North American Product Ledger Summary
* table data and then maps the Functional Area to ACS line to get
* the ACS line code
method get_data.
*-- Local Variable
DATA: L_ZZPRODNT TYPE TY_ZZPRODNT.
*-- Get the data from North American Product Ledger Summary table
select robukrs
racct
rcntr
rprctr
rfarea
rzzwbs_el
rzzwwz01
rzzwwz05
ksl01
ksl02
ksl03
ksl04
ksl05
ksl06
ksl07
ksl08
ksl09
ksl10
ksl11
ksl12
ksl13
ksl14
ksl15
ksl16
from zzprodnt
into table it_ZZPRODNT
where rldnr = e_rldnr
and ryear = e_ryear
and rpmax = e_rpmax
and ROBUKRS in e_glcomp
and RPRCTR in e_prctr
and RZZWWZ01 in e_prasn
and RZZWWZ05 in e_crpbd.
if sy-subrc = 0.
loop at it_ZZPRODNT into l_zzprodnt.
condense l_ZZPRODNT-rfarea no-gaps.
if l_ZZPRODNT-rfarea is initial.
delete it_ZZPRODNT.
endif.
endloop.
*-- Get the Functional Area to ACS line code mapping data
select *
from zfgl014
into table it_zfgl014
for all entries in it_ZZPRODNT
where fkber = it_ZZPRODNT-rfarea .
if sy-subrc = 0.
endif.
endif.
i_subrc = sy-subrc.
endmethod. "get_data
endclass. "lcl_tm1_intf IMPLEMENTATION
* INCLUDE ZFGLI00003_F01 *
* Table
tables : zzprodnt.
* Data Declaration
data : v_subrc type sy-subrc.
*& Form get_filename
* Description : This subroutine is used for F4 Prompting
form get_filename changing p_path like rlgrap-filename.
*-- Local variables
data : lv_file like ibipparms-path, "Local file for upload/download
lv_repid like syst-cprog, "ABAP program, caller in external
"procedures
lv_dynnr type syst-dynnr. "Current screen No
lv_repid = syst-cprog.
lv_dynnr = syst-dynnr.
*-- Function module used for F4 help
call function 'F4_FILENAME'
exporting
program_name = lv_repid
dynpro_number = lv_dynnr
importing
file_name = lv_file.
move lv_file to p_path.
endform. " get_filename
*& Form init_period
FORM init_period changing p_rpmax p_ryear.
if sy-datum+4(2) = 01.
p_rpmax = 12.
p_ryear = sy-datum+0(4) - 1.
else.
p_rpmax = sy-datum+4(2) - 1.
p_ryear = sy-datum+0(4).
endif.
ENDFORM. " init_period
Hope this helps.
Regards,
Richa -
Extract program to extract data from SAP into multiple worksheets of excel
Hi , I am currently facing an issue.
Extracting the data during data extraction, conversion into an excel and also into multiple worksheets withing a excel file.
What is the function which can help me. Also how do you give refernce to multiple worksheets to be created withing a excel file (which is the destination)
Any sample program extracting data from SAP tables into a excel with multiple worksheet will be of immense help
Please respond. Appreciate it.
Rgds
MadhuHi Madhu,
Here is the program for creating the excel file and creating the multiple worksheets.
*& Report ZEXCEL_UPLOAD2
REPORT ZEXCEL_UPLOAD2.
INCLUDE ole2incl.
DATA: application TYPE ole2_object,
workbook TYPE ole2_object,
sheet TYPE ole2_object,
cells TYPE ole2_object.
CONSTANTS: row_max TYPE i VALUE 256.
DATA index TYPE i.
DATA: BEGIN OF itab1 OCCURS 0, first_name(10), END OF itab1.
DATA: BEGIN OF itab2 OCCURS 0, last_name(10), END OF itab2.
DATA: BEGIN OF itab3 OCCURS 0, formula(50), END OF itab3.
*START-OF-SELECTION
START-OF-SELECTION.
APPEND: 'Peter' TO itab1, 'Ivanov' TO itab2,
'=Sheet1!A1 & " " & Sheet2!A1' TO itab3,
'John' TO itab1, 'Smith' TO itab2,
'=Sheet1!A2 & " " & Sheet2!A2' TO itab3.
CREATE OBJECT application 'excel.application'.
SET PROPERTY OF application 'visible' = 0.
CALL METHOD OF application 'Workbooks' = workbook.
CALL METHOD OF workbook 'Add'.
Create first Excel Sheet
CALL METHOD OF application 'Worksheets' = sheet
EXPORTING #1 = 1.
CALL METHOD OF sheet 'Activate'.
SET PROPERTY OF sheet 'Name' = 'Sheet1'.
LOOP AT itab1.
index = row_max * ( sy-tabix - 1 ) + 1. " 1 - column name
CALL METHOD OF sheet 'Cells' = cells EXPORTING #1 = index.
SET PROPERTY OF cells 'Value' = itab1-first_name.
ENDLOOP.
Create second Excel sheet
CALL METHOD OF application 'Worksheets' = sheet
EXPORTING #1 = 2.
SET PROPERTY OF sheet 'Name' = 'Sheet2'.
CALL METHOD OF sheet 'Activate'.
LOOP AT itab2.
index = row_max * ( sy-tabix - 1 ) + 1. " 1 - column name
CALL METHOD OF sheet 'Cells' = cells EXPORTING #1 = index.
SET PROPERTY OF cells 'Value' = itab2-last_name.
ENDLOOP.
Create third Excel sheet
CALL METHOD OF application 'Worksheets' = sheet
EXPORTING #1 = 3.
SET PROPERTY OF sheet 'Name' = 'Sheet3'.
CALL METHOD OF sheet 'Activate'.
LOOP AT itab3.
index = row_max * ( sy-tabix - 1 ) + 1. " 1 - column name
CALL METHOD OF sheet 'Cells' = cells EXPORTING #1 = index.
SET PROPERTY OF cells 'Formula' = itab3-formula.
SET PROPERTY OF cells 'Value' = itab3-formula.
ENDLOOP.
Save excel speadsheet to particular filename
CALL METHOD OF sheet 'SaveAs'
EXPORTING #1 = 'c:\temp\exceldoc1.xls' "filename
#2 = 1. "fileFormat
Closes excel window, data is lost if not saved
SET PROPERTY OF application 'visible' = 0.
**Quick guide to some of the OLE statements for OLE processing in this program as well as a few other ones.
Save Excel speadsheet to particular filename
CALL METHOD OF sheet 'SaveAs'
EXPORTING #1 = 'C:\Users\dprasad\Desktop\excel_sheet.xls' "filename
#2 = 1. "fileFormat
Save Excel document
CALL METHOD OF sheet 'SAVE'.
Quits out of Excel document
CALL METHOD OF sheet 'QUIT'.
Closes visible Excel window, data is lost if not saved
SET PROPERTY OF application 'visible' = 0. -
Transfer data from SAP TABLES to a SQL table
Hi,
I need to transfer data from SAP tables to a SQL table. Please suggest the best way as well as the steps please.
Regards,
KamleshHi
Step 1: Create an entry for the External database in DBCON table using Trxn: DBCA.
Field Name Description Value (For: E.g.:)
CON_NAME Logical name
for database con RAJ
DBMS Database system MSS
USER_NAME Database user <username>
PASSWORD Password for setting up
the connection
to the database <pwd>/<pwd>
CON_ENV Database-specific MSSQL_SERVER=depotserver MSSQL_DBNAME=HOF_INDORE
DB_RECO Availability type for an open database connect
Then, you can define internal table and code the following way:
DATA: BEGIN OF wa,
c_locid(3),
c_locname(50),
c_locstate(5),
END OF wa.
EXEC SQL.
CONNECT TO 'RAJ' AS 'V'
ENDEXEC.
EXEC SQL.
SET CONNECTION 'V'
ENDEXEC.
< Populate SAP data into an internal table >
Loop on itab.
EXEC SQL.
< code here for populating data into MS-SQL Server table>
ENDEXEC.
Endloop.
Regards,
Raj -
Inserting data from a table to an XML file
I want to insert the values from this xml file emp.xml into a table Employees :
<EMPLOYEES>
<EMP>
<EMPNO>7369</EMPNO>
<ENAME>SMITH</ENAME>
<JOB>CLERK</JOB>
<HIREDATE>17-DEC-80</HIREDATE>
<SAL>800</SAL>
</EMP>
<EMP>
<EMPNO>7499</EMPNO>
<ENAME>ALLEN</ENAME>
<JOB>SALESMAN</JOB>
<HIREDATE>20-FEB-81</HIREDATE>
<SAL>1600</SAL>
<COMM>300</COMM>
</EMP>
<EMP>
</EMPLOYEES>
and here is my Employee table in Oracle 9i database
SQL> DESC EMPLOYEE;
Name Null? Type
EMPNO NUMBER
EMPNAME VARCHAR2(10)
JOB VARCHAR2(10)
HIREDATE DATE
SAL NUMBER
After getting help from the members i was able to do the insert of data from the xml file to the table..how to do the insert of data from the table to the xml file.
Regards,
RenuHello michaels , thank you for the solution, still i am having some problems
Here is what i have done :
1.
SQL> CREATE DIRECTORY my_table_dir AS 'E:\table_files'
2 ;
Directory created.
2.
SQL> select * from myemp;
ENAME
SMITH
ALLEN
3.
This is the content of the existing xml file saved in the directory E:\table_files as emp.xml
<EMPLOYEES>
<EMP>JIM</EMP>
<EMP>RICK</EMP>
</EMPLOYEES>
4.
Now i executed this code :
declare
emp_xml xmltype;
begin
select sys_xmlagg (column_value, sys.xmlformat ('EMPLOYEES')) emp_xml
into emp_xml
from table (xmlsequence (cursor (select *
from myemp
where ename in ('SMITH', 'ALLEN')),
sys.xmlformat ('EMP')
dbms_xslprocessor.clob2file (emp_xml.getclobval (), 'E:\table_files', 'emp.xml');
end;
And the Error i got is :
declare
ERROR at line 1:
ORA-29280: invalid directory path
ORA-06512: at "SYS.UTL_FILE", line 18
ORA-06512: at "SYS.UTL_FILE", line 424
ORA-06512: at "XDB.DBMS_XSLPROCESSOR", line 46
ORA-06512: at line 12 -
How to access data from SAP Tables from a Webi report
hi all,
I have a webi report for financial data and from a Bex query which is build on a Cube (this has data from 2 SAP ECC systems)
i want to build a functionality where in i can call some SAP Table data from this webi report. i should be able to pass information or some hard code where it can understand the source system it has to pick data from.
in SAP BI, we have this ption wherein we can achieve this through RRI..
is this possible in Webi ?
Thanks
SKSHi.
Create a universe on top of SAP Tables and create a webi report.
Using hyper link /open doc we can call this report from the webi report created on top of your Cube .
@Sri -
To write ABAP code to retrieve data from RSTMANPART table
hello everyone...
Actually, i need help to write a ABAP code....
i need to record the number of data records which is transferred and added to 3 cubes... i need to read the latest request number from the RSSTATMANPART table, for the 3 datatargets, and gather the transferred records, added records , start time n end time from that specific req num....
And i have to store it in an internal table....
Please help me with the same.....
Thanks....
Edited by: neethacj on Dec 2, 2010 10:27 AMDear Neetha,
The table name is RSSTATMANPART.
Now the relevant fields are
DTA(Data Target)
DTA_TYPE(Data Target Type = Cube)
RNR (Request ID)
STATUS(Data Load Status )
TSTATUS(Technical Status)
DATUM_ANF(Request date)
DATUM_VERB(Loaded Date)
ZEIT_ANF(Start Time)
ZEIT_VERB(Finishing Time)-->just do one load and compare the entries with Process monitor
OLTPSOURCE(Datasource).
ANZ_RECS(Transferred Records)
INSERT_RECS(Inserted Records)
*Create an Internal Table :
DATA: IT_MANPART1 TYPE TABLE OF RSSTATMANPART,
IT_MANPART2 TYPE TABLE OF RSSTATMANPART,
IT_MANPART3 TYPE TABLE OF RSSTATMANPART,
WA_MANPART LIKE LINE OF IT_MANPART1.
*Fill the internal table
SELECT * FROM RSSTATMANPART INTO TABLE IT_MANPART1 WHERE
DTA = 'CUBE1'.
SELECT * FROM RSSTATMANPART INTO TABLE IT_MANPART2 WHERE
DTA = 'CUBE1'.
SELECT * FROM RSSTATMANPART INTO TABLE IT_MANPART3 WHERE
DTA = 'CUBE1'.
SORT IT_RSSTATMANPART1 BY RNR DESCENDING.
SORT IT_RSSTATMANPART1 BY RNR DESCENDING.
SORT IT_RSSTATMANPART1 BY RNR DESCENDING.
It will fill up your Internal table with all the requests of the RSSTATMANPART for the three Infocubes.The requests have been sorted in descending order ,the most latest will be at the top.
You can do whatever you want to do with these three internal tables..you can have them in one talbe also..depends on ur exact requirement.
Regards,
RK -
Issues in exporting data from SAP tables in SE16 to excel
1.How can I save an sap table (displayed through SE16) in ECC6 into a pivot table in excel. [ I have seen this option in R/3 4.7, but do not see it in ECC.]
2.How can I copy all the rows of a 3000 row SAP table in SE16 and paste the values into excel. I need to do this in one shot and not page by page.
3.What option do I need to select inorder to preserve the formating of the values while saving as a local file in a spreadsheet format. All the values with leading zeros,like company codes gets saved with only their numeric portion when I save a SAP table as a local file. for eg company code 0001 gets saved in excel as just 1,company code 0056 gets saved as 56 etc. How do I prevent this? What option do I need to set in SAP in order for the values to be downloaded as is, without any truncation of leading zeros.1. I don't know. How about creating a pivot after exporting data
2. System->List->Save->local file->clipboard
Then paste whole lot in Excel
3. This is a problem with Excel, not SAP. SAP exports with leading zeroes.
You could export as flat file & import into Excel into a spreadsheet with an appropriate numbering format. -
Problem Outputting Data From Second Table Based On ID in FIrst Table
Hi Everyone: I have been stuck for a couple of days on a
couple of issues. Here is one:
I have a COURSES table. I also have a COURSES Summary page
that displays all of the courses and related info.
When a user clicks on a specific course it takes them to a
courses detail page for that specific course. PROBLEM: Everything
is working ok except: I have a separate table that has the teachers
information in it. The two tables are related by The Primary Key
(PERSONNEL_ID) in the Teachers table (Called PERSONNEL_LISTS) and
MT_ID in the COURSES TABLE. I don't want the MT_ID to be displayed
on the details page: I want the teachers first and last name.
Here are the two tables:
http://www.coolflasher.com/Courses_table.gif
http://www.coolflasher.com/Personnel_table.gif
The SQL that is currently being used on the Course Details
page is:
<cfparam name="URL.COURSE_ID" default="-1">
<cfparam name="URL_COURSE_ID"
default="#URL.COURSE_ID#">
<cfparam name="SESSION._Insert_COURSES" default="-1">
<cfquery name="COURSES"
datasource="SCHEDULING_TRACKER">
SELECT *
FROM COURSES
WHERE COURSE_ID = <cfqueryparam value="#URL.COURSE_ID#"
cfsqltype="cf_sql_numeric"> OR ( -1= <cfqueryparam
value="#URL_COURSE_ID#" cfsqltype="cf_sql_numeric"> AND
COURSE_ID=<cfqueryparam value="#SESSION._Insert_COURSES#"
cfsqltype="cf_sql_numeric">)
</cfquery>
And I'm outputting the MT_Code:
<cfoutput>#COURSES.MT_ID#</cfoutput>
I tried adding the PERSONNEL_LISTS table to the query, but I
can't figure out how to get it to output the FIRST_NAME and
LAST_NAME column that correspond with the MT_ID in the COURSES
table.
Courses
TableSomething like this maybe?
(NOTE: you should explicitly list column names from both
tables instead of using *)
<cfquery name="COURSES"
datasource="SCHEDULING_TRACKER">
SELECT t.FIRST_NAME,
t.LAST_NAME,
c.COURSE_NAME,
c.COURSE_ID,
---whatever other fields that you want to select
FROM COURSES AS c
INNER JOIN PERSONNEL_LISTS AS t ON c.MT_ID = t.PERSONNEL_ID
WHERE c.COURSE_ID = <cfqueryparam value="#URL.COURSE_ID#"
cfsqltype="cf_sql_numeric">
OR ( -1 = <cfqueryparam value="#URL_COURSE_ID#"
cfsqltype="cf_sql_numeric">
AND c.COURSE_ID=<cfqueryparam
value="#SESSION._Insert_COURSES#" cfsqltype="cf_sql_numeric">)
</cfquery>
Also, not sure what you are expecting -1 = <cfqueryparam
value="#URL_COURSE_ID#" cfsqltype="cf_sql_numeric"> to do.
Phil -
Retreive data from a table in a typical format
Hi,
I am trying to retreive the telephone no.'s of all employees from a table. Where in the data entered into the table by users is in free style as in (111)111-1111 or 214-548-9874 or 587-632-ABCD or 1 985 657 4879 or 001 987-587-3654.
There could be any combinations of the format. There could be '-' or <space> or <( )> in between or alphanumeric values to enter the no.
My requirement is to fetch only the 10 digits of a number (or less if any) irrespective of the country code from the table.
Note:The users cannot be restricted to put their contact no. in a particular format while making a data entry. :(((
Pls let me know how can I accomplish this.
Thanks!
Edited by: 807404 on Nov 3, 2010 12:49 PMHi,
807404 wrote:
Hi,
The same thing is happening with the Translate function as well.
If the user has entered telephone number in less than 10 digits, it gives me null.
Edited by: 807404 on Nov 3, 2010 1:20 PMIt works for me.
Post some test data (CREATE TABLE and INSERT statemnts), the results you want from that data, and the query you're running.
For example, with this data:
CREATE TABLE table_x
( x_id NUMBER
, phone_num VARCHAR2 (30)
INSERT INTO table_x (x_id, phone_num) VALUES (0 , NULL);
INSERT INTO table_x (x_id, phone_num) VALUES (1 , '(111)111-1111');
INSERT INTO table_x (x_id, phone_num) VALUES (2 , ' 214-548-9874');
INSERT INTO table_x (x_id, phone_num) VALUES (3 , '587-632-ABCD');
INSERT INTO table_x (x_id, phone_num) VALUES (4 , '1 985 657 4879');
INSERT INTO table_x (x_id, phone_num) VALUES (5 , '001 987-587-3654');
INSERT INTO table_x (x_id, phone_num) VALUES (11, '12 ext. 34');
INSERT INTO table_x (x_id, phone_num) VALUES (12, '5-6-7');
INSERT INTO table_x (x_id, phone_num) VALUES (21, '(+++) +++-++++');
COMMIT;I expect (and actually get) these results:
` X_ID PHONE_NUM STANDARDIZED
0
1 (111)111-1111 1111111111
2 214-548-9874 2145489874
3 587-632-ABCD 587632ABCD
4 1 985 657 4879 9856574879
5 001 987-587-3654 9875873654
11 12 ext. 34 12ext34
12 5-6-7 567
21 (+++) +++-++++using this query:
SELECT table_x.*
, SUBSTR ( ' ' || TRANSLATE ( phone_num
, 'A ()[].-_/+'
, 'A'
, -10
) AS standardized
FROM table_x
ORDER BY x_id
;The standardized column is NULL only for x_id=0 (where phone_num itself is NULL) and x_id=21 (where phone_num contains only designated bad characters).
For the rows with "numbers" containing fewer than 10 characters (x_id=11 and x_id=12), the results are padded with blanks. If you'd prefer just the non-blank characters, use LTRIM. -
Exporting data from database tables to a XML file
Hi,
We want to export data from Oracle database tables to an XML
file. What tool can we use for this purpose, and how do we go
about it ?
Can we extract data only from an Oracle8 database, or can we
extract data from Oracle7.3 databases too ?
Any help in this regard would be appreciated.
Thanks
Dipanjan
nullDipanjan (guest) wrote:
: Hi,
: We want to export data from Oracle database tables to an XML
: file. What tool can we use for this purpose, and how do we go
: about it ?
: Can we extract data only from an Oracle8 database, or can we
: extract data from Oracle7.3 databases too ?
: Any help in this regard would be appreciated.
: Thanks
: Dipanjan
Start by downloading the XML SQL Utility and make sure you have
the approriate JDBC 1.1 drivers installed for your database.
There are samples which will get you going included in the
archive.
Oracle XML Team
http://technet.oracle.com
Oracle Technology Network
null -
Question in ABAP syntax, read & insert data from internal table, while loop
Hi, SDN Fellow.
I am from Java background and learnt ABAP, I don't usually write much ABAP code.
I am trying to implement the following logic in a RFC now.
I have one z-custom database table, the structure as the following:
It has two columns, with these sample data.
Says datable table is ZEMPMGRTAB.
EmployeeID,ManagerID
user10,user1
user9,user1
user8,user1
user7,user2
user6,user2
user5,user2
user4,user2
user2,user1
The logic is this:
I have a input parameter, userid. I am using this parameter to have a select statement to query the record into export table,EXPTAB 'LIKE' table ZEMPMGRTAB.
SELECT * FROM ZEMPMGRTAB
into table EXPTAB
WHERE EMPLOYEEID = USERID.
Say, my parameter value, USERID ='USER4'.
Referring to the sample data above, I can get the record of this in my EXPTAB,
EmployeeID,ManagerID
user4,user2
Now, I want to iterately use the EXPTABLE-ManagerID
as the USERID input in SELECT statement, until it has no return result. Then, insert the new records in
EXPTAB.
In above new loop case, we will get this table content in EXPTAB,
EmployeeID,ManagerID
user4,user2
user2,user1
I kind of think of the pseudocode logic as below:
(These may not be a valid ABAP code, so I need help to convert/correct them)
DATA:
IWA TYEP ZZEMPMGRTAB,
ITAB
HASHED TABLE OF ZZEMPMGRTAB
WITH UNIQUE KEY EMPLOYEEID.
SELECT * FROM ZEMPMGRTAB
into table ITAB
WHERE EMPLOYEEID = USERID.
*Question 1: I cannot insert a internal table to export table, it is *incompatible type, what is the alternative way fo this?
*Question 2: How can I access thedata of the internal table like this,ITAB-MANAGERID? As if I can, I would do this:
* IWA-EMPLOYEEE = ITAB-EMPLOYEEID. IWA-MANAGERID = IWA-MANAGERID. INSERT IWA INTO TABLE EXPTAB.
* Question 3: Is the 'NE NULL' - 'not equal to NULL' is right syntax?
IF ITAB NE NULL.
INSERT ITAB INTO EXPTAB.
ENDIF
* Question 4: Is my WHILE loop setup right here? And are the syntax right?
WHILE ITAB NE NULL.
SELECT * FROM ZEMPMGRTAB
into table ITAB
WHERE EMPLOYEEID = ITAB-MANAGERID.
IF ITAB NE NULL.
INSERT ITAB INTO EXPTAB.
ENDIF
REFRESH ITAB.
ENDWHILE.
Assume all the syntax and logic are right, I should get this result:
EmployeeID,ManagerID
user4,user2
user2,user1
If I have a new entry in datable table,ZEMPMGRTAB like this:
user1,user0
My pseudocode logic will get this result:
EmployeeID,ManagerID
user4,user2
user2,user1
user1,user0
I truly appreciate if you can help me to validate the above syntax and pseudocode logic.
Thanks in advance.
KCHi,
FUNCTION ZGETSOMEINFO3.
*"*"Local Interface:
*" IMPORTING
*" VALUE(USERID) TYPE AWTXT
*" VALUE(FMTYPEID) TYPE AWTXT
*" EXPORTING
*" VALUE(RETURN) TYPE BAPIRETURN
*" TABLES
*" APPROVERT STRUCTURE ZTAB_FMAPPROVER
*" ACTOWNERT STRUCTURE ZTAB_FMACTOWNER
DATA: T_RESULT TYPE STANDARD TABLE OF ZTAB_FMAPPROVER.
**Question 1: For this line, I got an error says "Program ''USERID" *not found. Is the syntax right, as the USERID is a parameter for the function.
perform add_line(USERID).
ENDFUNCTION.
form add_line using i_user type ZTAB_FMAPPROVER.EMPLOYEEID
changing T_RESULT TYPE ZTAB_FMAPPROVER.
data: ls_row type ZTAB_FMAPPROVER.
* Get record for i_user
select single * into ls_row from ZTAB_FMAPPROVER
where EmployeeID = i_user.
if sy-subrc NE 0.
* Do nothing, there is not manager for this employee
else.
* Store result
QUESTION 2: I am still got stuck on this line of code. It still *says that "T_RESULT" is not an internal table "OCCURS n" *specification is missing. I thought the line: "T_RESULT TYPE *ZTAB_FMAPPROVER" means declare internal table, T_RESULT as type of ZTAB_FMAPPROVER". Am I understand it wrongly?
append ls_row to t_result.
* Call recursion
perform add_line using ls_row-ManagerID
changing t_result.
endif.
endform.
Thanks,
KC -
Error in Abap code when combining data from two tables
Hi,
I got error in my code when i try to select data based on two tables
error message Unknown column name "(" field list. field list. field list. field list.
select ( WLK1~ARTNR )
into ZOXE1D0041-ZZPROMO
from WLK1 INNER JOIN T001W
ON WLK1FILIA = T001WKUNNR.
where WLK1-PFLKN NE 'P' AND
WLK1-QUELL NE '2'.
Table 1 WLK1
ARTNR FILIA PFLKN QUELL
001 C001 P 2
002 C001 A 1
Table 2 T001W
KUNNR WERKS
C001 P001
My requirement is to extract from article number from table WLK1 where the customer number (FILIA) matches with Customer number from (T001W) and plant (WERKS).
In conclusion I like to have this only this row
ARTNR FILIA PFLKN QUELL
002 C001 A 1Hi
You need to append every article number after each select is performed
is this an intermal table ZOXE1D0041 with header line ? if yes
then do this way
select WLK1~ARTNR
into ZZARTICLE
from WLK1 INNER JOIN T001W
ON WLK1FILIA = T001WKUNNR
where WLK1~PFLKN NE 'P' AND
WLK1~PFLKN NE 'S' AND
WLK1~QUELL NE '2'.
ZOXE1D0041-ZZLISTARTICLE = ZZARTICLE.
Append ZOXE1D0041. " <edited>
endselect.
then ZOXE1D0041 will have all article numbers.
Edited by: Sonal Patel on Sep 5, 2009 10:27 AM -
How to retrieve the data from SAP database.
Hi Pals,
How to retrieve data from SAP R/3 System to my third party software. I will make my query little bit more clear. There is a list of assets entered and stored in the SAP system. For example 3 mobile phones.
1) Mobile 1- Nokia
2) Mobile 2 - Samsung
3) Mobile 3 u2013 Sony
Now think I do not know what all assets is there. I have to retrieve the data and get it on my third party software. Just display the list of assets. Lets say SAP XI is also there. Now how will I map it and get the details.
Please give me step by step method.
N.B: Just to read the data from SAP database.
Please make the flow clear step by step.
Thanking you
AKHi,
You can use RFC or ABAP Proxy to make synchronous call with SAP.
Under RFC or ABAP Proxy Program you can get the data from SAP tables. Direct access to SAP Database is not preferrable even if its possible.
The better way to go for RFC or PROXY.
You will send the request from Third party system and the it will be as input parameters from RFC/ Proxy it will response based on it.
This got it all..
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/5474f19e-0701-0010-4eaa-97c4f78dbf9b
/people/siva.maranani/blog/2005/09/03/invoke-webservices-using-sapxi
/people/stefan.grube/blog/2006/09/21/using-the-soap-inbound-channel-of-the-integration-engine
/people/arpit.seth/blog/2005/06/27/rfc-scenario-using-bpm--starter-kit - File to RFC
HTTP to RFC - A Starter Kit
/people/community.user/blog/2006/12/12/http-to-rfc--a-starter-kit
Refer
Thanks
Swarup
Edited by: Swarup Sawant on Jun 4, 2008 9:32 AM -
What is the best way to get data from SAP into BPC?What about getting data from BPC (like a template) into back into SAP?
Hi Sam,
Please find here the steps you should do
Step#1: In SAP With the help of ABAP program update data into a table.
Step#2: In regular interval pull data from SAP table to BPC staging tables in SQL server.
Step#3: Run import data manager package to update FACT tables from BPC staging tables on demand.
This is the best way and best approach to pull data from SAP to BPC.
Thanks and Regards,
Rajesh Muppala.
Maybe you are looking for
-
Airport Extreme Network - Changing from Verizon DSL to Fios (with TV)
I am currently using Verizon DSL for internet access. My present network is stable with an Airport Extreme Base (New version) and two Airport Express running MDS for range extension, providing wireless access for a Macbook and a PC laptop (my wife's
-
Hi there Hope everyone is doing well...... I have been trying to get this to work but cant figure it out...... First.... What I want is to be able to put an 'on sale' image ...... preferably an animated gif.... (little red flame circle with animated
-
Why is the installer stuck on "Checking System Profile-"?
I'm trying to install Flash Catalyst Beta on a MacBook Pro running OS 10.6.1 (Snow Leopard). The installer starts to work, but then it stops at the point where it checks the system profile (see attached screenshot). It doesn't seem to have crashed as
-
Unable to find product categories after client copy
Hi all, We have copied clients from an existing ones for both SRM and ECC. After client copy we have followed standard procedure after client copy i.e. Run transcation BDLS created new RFC connections changed attributes using the Attributes replace
-
Where can I get a copy of iTunes 5 and how do I keep my purchased music?
Hi all: I am using iTunes 5 (5.0.0.35) and want to reinstall it as I get the following error message from the iTunes Setup Assistant when iTunes starts up: "Warning! The registry settings used by the iTunes drivers for importing and burning CDs and D