<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Max Titov IV @ TechSplice &#187; data</title>
	<atom:link href="http://www.blog.techsplice.com/archives/tag/data/feed" rel="self" type="application/rss+xml" />
	<link>http://www.blog.techsplice.com</link>
	<description>The most beautiful music of all is the music of what happens.</description>
	<lastBuildDate>Tue, 20 Dec 2011 18:56:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Retrieving user data [ABAP]</title>
		<link>http://www.blog.techsplice.com/archives/9</link>
		<comments>http://www.blog.techsplice.com/archives/9#comments</comments>
		<pubDate>Fri, 24 Aug 2007 03:43:56 +0000</pubDate>
		<dc:creator>maxtmax</dc:creator>
				<category><![CDATA[SAP/ABAP]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[interface]]></category>
		<category><![CDATA[sap]]></category>
		<category><![CDATA[user]]></category>

		<guid isPermaLink="false">http://www.blog.techsplice.com/?p=9</guid>
		<description><![CDATA[In this example we will explore attempts to gather information from SAP database tables. We aim to collect user information and display it on the screen using SELECT statements and internal TABLE variables. For the purposes of this example we will be collecting information from the table USR02. In order to access that information the [...]]]></description>
			<content:encoded><![CDATA[<p>In this example we will explore attempts to gather information from SAP database tables. We aim to collect user information and display it on the screen using <a href="http://en.wikipedia.org/wiki/Select_(SQL)" target="_blank">SELECT</a> statements and internal TABLE variables.</p>
<p>For the purposes of this example we will be collecting information from the table USR02.<br />
In order to access that information the program must explicitly reference the desired tables at the header of the file.</p>
<blockquote><p> <code>REPORT Z_USERS.<br />
* Import the USR02 table in to the program.<br />
TABLES: USR02.</code></p></blockquote>
<p>Next we want to create a internal table for gathering information from the database.  We will create a local variable table &#8216;USERS&#8217; with two attributes.  All variables used within the ABAP/4 program must be declared with DATA statements.</p>
<p><strong>DATA</strong><br />
<strong>&lt;name&gt; </strong>                 Name of the variable<br />
<strong>TYPE or LIKE </strong>     Indicates the variable type.<br />
<strong>    VALUE</strong>                         Initial value of the variable.<br />
<strong> DECIMAL</strong>                  Can only be used with appropriate types. Specifies the number of decimal places in the number.</p>
<blockquote><p><code>* Define USERS internal table.<br />
DATA: BEGIN OF USERS OCCURS 100,<br />
NAME LIKE USR02-BNAME,<br />
DATE LIKE USR02-TRDAT,<br />
END OF USERS.</code></p></blockquote>
<p><strong>BEGIN OF USERS OCCURS 100</strong>: Specifies the name of the variable table &#8216;USERS&#8217; and states that the table will contain a 100 records.<br />
The <strong>two attributes</strong> that the table will contain are <em>NAME</em> and <em>DATE</em> with the same characteristics as <em>BNAME</em> and <em>TRDAT</em> attributes found in the USR02 table.  The BNAME attribute stores the name of the user while the TRDAT attribute stores when the user previously logged in.<br />
<strong> END OF USERS</strong> is a closing statement for the BEGIN statement.</p>
<p>The next step will be to use a <a href="http://en.wikipedia.org/wiki/Select_(SQL)" target="_blank">SELECT</a> statement to gather information from the USR02 table and populate our local USERS table.</p>
<blockquote><p><code>* Select information from the USR02 table.<br />
SELECT * FROM USR02.</code></p>
<p><code>CLEAR USERS.<br />
* Copy over the information.<br />
USERS-NAME = USR02-BNAME.<br />
USERS-DATE = USR02-TRDAT.<br />
APPEND USERS.</code></p>
<p><code>ENDSELECT.</code></p></blockquote>
<p>The <a href="http://en.wikipedia.org/wiki/Select_(SQL)" target="_blank">SELECT</a> statement acts like a &#8216;loop&#8217; if you will.  Record by record the information will be gathered up from the USR02 table and transfered in to the <strong>USERS</strong> table.  After going through each record the data is added to the <strong>USERS</strong> table using the <strong>APPEND</strong> statement.</p>
<p>Now that we gathered some information about the users that reside in the system lets display that info.<br />
First lets find out how many users there are in total.  To do that we will use the <strong>DESCRIBE</strong> statement that will return an attribute <strong>LENGTH</strong> of all the fields in the <strong>USER</strong> table.</p>
<blockquote><p><code>* How many users were retrieved.<br />
DESCRIBE TABLE USERS LINES LENGTH.<br />
* Output the information on the screen.<br />
WRITE: / 'There are: ', LENGTH, 'USERS'.</code></p></blockquote>
<p>The final step in our program will include the displayed of collected user information.<br />
Using a <strong>LOOP</strong> statement we will go through each element in the <strong>USERS</strong> table and output the information on the screen.</p>
<blockquote><p><code>LOOP AT USERS.<br />
WRITE: / USERS-NAME, USERS-DATE.<br />
ENDLOOP.</code></p></blockquote>
<p>Notice that the <strong>LOOP</strong> statement terminates with a corresponding <strong>ENDLOOP</strong> statement.</p>
<p>And this completes our glimpse of data gathering in <a href="http://www.sap.com/index.epx" target="_blank">SAP</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.techsplice.com/archives/9/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.629 seconds -->

