<?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>ABAP Tutorials &#187; difference between</title>
	<atom:link href="http://www.abap-tutorials.com/tag/difference-between/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.abap-tutorials.com</link>
	<description>ABAP Tutorials, Guides, Training, Manuals</description>
	<lastBuildDate>Thu, 17 Nov 2011 07:43:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Smartforms Vs SAPScript, the Battle Royale in SAP</title>
		<link>http://www.abap-tutorials.com/2009/07/21/smartforms-vs-sapscript-the-battle-royale/</link>
		<comments>http://www.abap-tutorials.com/2009/07/21/smartforms-vs-sapscript-the-battle-royale/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 12:15:18 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[SAPScript]]></category>
		<category><![CDATA[Smartforms]]></category>
		<category><![CDATA[ABAP]]></category>
		<category><![CDATA[difference between]]></category>
		<category><![CDATA[SAP]]></category>

		<guid isPermaLink="false">http://naveenvishal.wordpress.com/?p=361</guid>
		<description><![CDATA[Samrtforms and SAPScript both used for creating and maintaining forms for mass printing in SAP Systems. But where does the difference lies ? The Following are the differences between Smartforms and SAPScripts :- a) Multiple page formats are possible in smartforms which is not the case in SAPScripts b) It is possible to have a [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">Samrtforms and SAPScript both used for creating and maintaining forms for mass printing in SAP Systems. But where does the difference lies ?</p>
<p style="text-align:justify;"><span id="more-361"></span></p>
<p style="text-align:justify;">The Following are the differences between Smartforms and SAPScripts :-</p>
<p style="text-align:justify;">a) Multiple page formats are possible in smartforms which is not the case in SAPScripts</p>
<p style="text-align:justify;">b) It is possible to have a smartform without a main window, but it is mandatory to have that in SAPScript</p>
<p style="text-align:justify;">c) Labels cannot be created in smartforms, but in SAPScript you can create Labels</p>
<p style="text-align:justify;">d) Routines can be written in smartforms tool</p>
<p style="text-align:justify;">e) Smartforms generates a function module when activated- which is used to call the Smartform, nothing like such in SAPScript</p>
<p style="text-align:justify;">f) Use RSTXSCRP to download SAPScript to your Harddisk, whereas in Smartfrom (Utilities -&gt; Upload/Download form) it is a built-in as a utility, to download in XML format</p>
<p style="text-align:justify;">g) The protect and endprotect command in sapscript doesn&#8217;t work with smartforms</p>
<p style="text-align:justify;">h) The output medium for Smartforms support printer, fax, e-mail, or the Internet (by using the generated XML output), whereas in case of SAPScript, it is restricted to printer</p>


<p>You might also be interested in these posts:<ol><li><a href='http://www.abap-tutorials.com/2009/07/23/advantage-smartform-migrating-sapscript-to-smartforms/' rel='bookmark' title='Advantage Smartform: Migrating SAPScript to Smartforms in SAP'>Advantage Smartform: Migrating SAPScript to Smartforms in SAP</a></li>
<li><a href='http://www.abap-tutorials.com/2009/07/23/debugging-smartforms-and-sapscript/' rel='bookmark' title='Debugging Smartforms and SAPScript in ABAP'>Debugging Smartforms and SAPScript in ABAP</a></li>
<li><a href='http://www.abap-tutorials.com/2009/08/21/formatting-sapscript-smartforms-in-sap/' rel='bookmark' title='Formatting SAPScript / SMARTFORMS in SAP'>Formatting SAPScript / SMARTFORMS in SAP</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.abap-tutorials.com/2009/07/21/smartforms-vs-sapscript-the-battle-royale/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LOOP AT WHERE.   Vs     LOOP.IF.    in ABAP</title>
		<link>http://www.abap-tutorials.com/2009/07/16/loop-at-where-vs-loop-if/</link>
		<comments>http://www.abap-tutorials.com/2009/07/16/loop-at-where-vs-loop-if/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 02:04:00 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[ABAP]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[difference between]]></category>
		<category><![CDATA[if]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[SAP]]></category>
		<category><![CDATA[where]]></category>

		<guid isPermaLink="false">http://naveenvishal.wordpress.com/?p=149</guid>
		<description><![CDATA[At first sight, both the statements ( loop at itab where &#60;key&#62; = &#60;val&#62; ;   loop at itab. if &#60;key&#62; = &#60;val&#62;. ) looks like performing the same task. But when it comes to performance, both beats each other in there own domain. It all comes down to number of &#8220;&#8216;matches&#8221; in the WHERE/IF-clause. In case [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">At first sight, both the statements ( loop at itab where &lt;key&gt; = &lt;val&gt; ;   loop at itab. if &lt;key&gt; = &lt;val&gt;. ) looks like performing the same task.</p>
<p style="text-align:justify;">But when it comes to performance, both beats each other in there own domain.</p>
<p style="text-align:justify;"><span id="more-149"></span></p>
<p style="text-align:justify;">It all comes down to number of &#8220;&#8216;matches&#8221; in the WHERE/IF-clause.</p>
<p style="text-align:justify;">In case you have a rare match, the WHERE-method is better.<br />
In case you have an always match, the IF-method is better.</p>
<p style="text-align:justify;">When the match was done on<strong> 1-out-1000</strong>:</p>
<div class="mceTemp mceIEcenter" style="text-align:justify;">
<dl class="wp-caption aligncenter">
<dt class="wp-caption-dt"><img class="size-medium wp-image-150" title="loopatwhereif" src="http://naveenvishal.files.wordpress.com/2009/07/loopatwhereif.jpg?w=300" alt="match ratio: 1 - out of - 1000" width="300" height="269" /></dt>
<dd class="wp-caption-dd">match ratio: 1 &#8211; out of &#8211; 1000</dd>
</dl>
</div>
<p style="text-align:justify;">When the match was done at <strong>1 &#8211; out of -2 </strong>:</p>
<div class="mceTemp mceIEcenter" style="text-align:justify;">
<dl class="wp-caption aligncenter">
<dt class="wp-caption-dt"><img class="size-medium wp-image-151" title="loopatwhereif2" src="http://naveenvishal.files.wordpress.com/2009/07/loopatwhereif2.jpg?w=300" alt="match ratio: 1 - out of - 2" width="300" height="270" /></dt>
<dd class="wp-caption-dd">match ratio: 1 &#8211; out of &#8211; 2</dd>
</dl>
</div>
<p style="text-align:justify;">and when the &#8220;match&#8221; is <strong>matching every line</strong></p>
<div class="mceTemp mceIEcenter" style="text-align:justify;">
<dl class="wp-caption aligncenter">
<dt class="wp-caption-dt"><img class="size-medium wp-image-152" title="loopatwhereif3" src="http://naveenvishal.files.wordpress.com/2009/07/loopatwhereif3.jpg?w=300" alt="Match ratio : matching every line " width="300" height="267" /></dt>
<dd class="wp-caption-dd">Match ratio : matching every line </dd>
</dl>
</div>
<p style="text-align:justify;"> </p>
<p style="text-align:justify;">*source = Harry Dietz</p>


<p>You might also be interested in these posts:<ol><li><a href='http://www.abap-tutorials.com/2009/07/11/best-way-to-loop-at-standard-internal-table/' rel='bookmark' title='Best way to Loop At &#8216;Standard&#8217; Internal Table in ABAP'>Best way to Loop At &#8216;Standard&#8217; Internal Table in ABAP</a></li>
<li><a href='http://www.abap-tutorials.com/2009/07/15/my-inactive-programs/' rel='bookmark' title='ABAP Program to show My Inactive Programs'>ABAP Program to show My Inactive Programs</a></li>
<li><a href='http://www.abap-tutorials.com/2009/07/18/create-a-tcode-for-an-abap-query/' rel='bookmark' title='Create a TCODE for an ABAP Query'>Create a TCODE for an ABAP Query</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.abap-tutorials.com/2009/07/16/loop-at-where-vs-loop-if/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Pretty Report Vs Pretty Printer in ABAP</title>
		<link>http://www.abap-tutorials.com/2009/07/05/pritty-report-vs-pritty-printer/</link>
		<comments>http://www.abap-tutorials.com/2009/07/05/pritty-report-vs-pritty-printer/#comments</comments>
		<pubDate>Sun, 05 Jul 2009 12:53:17 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[ABAP]]></category>
		<category><![CDATA[Sample Code]]></category>
		<category><![CDATA[Utility]]></category>
		<category><![CDATA[difference between]]></category>
		<category><![CDATA[pretty printer]]></category>
		<category><![CDATA[Pretty Report]]></category>
		<category><![CDATA[SAP]]></category>

		<guid isPermaLink="false">http://naveenvishal.wordpress.com/?p=32</guid>
		<description><![CDATA[This program takes an existing ABAP report, and does the following:move comments to the end of the line. Added because pretty printer in 4.6 no longer does this - Adds comments (table name) for the tables listed after a TABLES statement if the line has not been commented already. - Adds comments (field name) for [...]]]></description>
			<content:encoded><![CDATA[<p><span style="font-size: small;">This program takes an existing ABAP report, and does the following:</span><strong><span style="font-size: small;">move comments to the end of the line</span></strong><span style="font-size: small;">. Added because pretty printer in 4.6 no longer does this<br />
- Adds </span><strong><span style="font-size: small;">comments (table name) for the tables listed after a TABLES statement</span></strong><span style="font-size: small;"> if the line has not been commented already.<br />
- Adds </span><strong><span style="font-size: small;">comments (field name) for data elements, parameters, and select-options</span></strong><span style="font-size: small;"> that are defined using the LIKE or FOR statement<br />
- For ENDLOOP/ENDSELECT </span><strong><span style="font-size: small;">adds comment identify the LOOP/SELECT</span></strong><span style="font-size: small;"> that is being closed<br />
- For FORM/ENDFORM </span><strong><span style="font-size: small;">adds comment identify the FORM</span></strong><span style="font-size: small;"> that is being closed<br />
- Checks to ensure that the program being modified is either a Local Private Object, or on a transport that belongs to the person running this program. This is to help prevent screwups.<br />
- Calls function PRETTY_PRINTER to do the SAP standard pretty print after the custom comments have been created.</span></p>
<p><span style="font-size: small;">- Attempts to move comments to the end of the line.  Added because pretty printer in 4.6 no longer does this.<br />
</span><br />
<span id="more-32"></span></p>
<p>*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*</p>
<p>*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* Pretty Report &#8211; format the ABAP Program<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
REPORT zabap_pretty_report .<br />
TABLES:<br />
e071 , &#8221; Objects of a request or task (E070)<br />
tadir , &#8221; Catalog of R/3 Repository objects<br />
trdir , &#8221; System table TRDIR<br />
dd02t . &#8221; R/3-DD: SAP Table Texts<br />
DATA: BEGIN OF mtab_old_prog OCCURS 0,<br />
line(72) TYPE c,<br />
END OF mtab_old_prog.<br />
DATA: BEGIN OF mtab_new_prog OCCURS 0,<br />
line(72) TYPE c,<br />
END OF mtab_new_prog.<br />
DATA: BEGIN OF mtab_statement OCCURS 0,<br />
line(72) TYPE c,<br />
END OF mtab_statement.<br />
DATA:<br />
* Hold an entire statement, even if it spans multiple lines<br />
BEGIN OF mtab_long_line OCCURS 0,<br />
start TYPE i,<br />
end TYPE i,<br />
code(5000) TYPE c,<br />
END OF mtab_long_line.<br />
DATA: BEGIN OF mtab_tabname OCCURS 0,<br />
tabname LIKE dd02t-tabname, &#8221; Table name<br />
tabdesc LIKE dd02t-ddtext, &#8220;Short text describing ABAP/4 Dictio<br />
END OF mtab_tabname.<br />
* Queue to hold list of internal table names for commenting the ENDLOOP<br />
* line<br />
DATA: BEGIN OF mtab_itab_names OCCURS 0,<br />
tabname(40) TYPE c,<br />
END OF mtab_itab_names.<br />
* Queue to hold list of table names for commenting the ENDSELECT line<br />
DATA: BEGIN OF mtab_tab_names OCCURS 0,<br />
tabname(40) TYPE c,<br />
END OF mtab_tab_names.<br />
DATA: BEGIN OF mtab_form_names OCCURS 0,<br />
tabname(40) TYPE c,<br />
END OF mtab_form_names.<br />
PARAMETERS:<br />
p_report LIKE sy-repid, &#8221; Program: Name of ABAP/4 program<br />
p_test AS CHECKBOX DEFAULT &#8216;X&#8217;.<br />
START-OF-SELECTION.<br />
PERFORM get_program_code TABLES mtab_old_prog<br />
USING p_report.<br />
END-OF-SELECTION.<br />
PERFORM create_condensed_table TABLES mtab_old_prog<br />
mtab_long_line.<br />
PERFORM format_program.<br />
CALL FUNCTION &#8216;PRETTY_PRINTER&#8217;<br />
EXPORTING<br />
inctoo = space<br />
TABLES<br />
ntext = mtab_new_prog<br />
otext = mtab_new_prog<br />
EXCEPTIONS<br />
enqueue_table_full = 1<br />
include_enqueued = 2<br />
include_readerror = 3<br />
include_writeerror = 4<br />
OTHERS = 5.<br />
IF p_test = space.<br />
PERFORM save_program.<br />
ENDIF.<br />
LOOP AT mtab_new_prog.<br />
IF mtab_new_prog = space.<br />
SKIP 1.<br />
ENDIF.<br />
WRITE: / mtab_new_prog.<br />
ENDLOOP. &#8221; LOOP AT MTAB_NEW_PROG<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* FORM GET_PROGRAM_CODE *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* &#8211;&gt; FTAB_OLD_PROG *<br />
* &#8211;&gt; F_REPORT *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
FORM get_program_code TABLES ftab_old_prog STRUCTURE mtab_old_prog<br />
USING f_report.<br />
* Read the program code into an internal table<br />
REFRESH ftab_old_prog.<br />
READ REPORT f_report INTO ftab_old_prog.<br />
SELECT SINGLE * FROM trdir WHERE name = f_report.<br />
IF sy-subrc NE 0.<br />
WRITE: / &#8216;Unable to read report:&#8217;, f_report.<br />
WRITE: / &#8216;Exiting program&#8217;.<br />
ENDIF.<br />
ENDFORM. &#8220; FORM GET_PROGRAM_CODE<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* FORM CREATE_CONDENSED_TABLE *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* Create a table that has all statements condensed onto 1 line *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* &#8211;&gt; FTAB_OLD_PROG *<br />
* &#8211;&gt; FTAB_long_line *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
FORM create_condensed_table<br />
TABLES ftab_old_prog STRUCTURE mtab_old_prog<br />
ftab_long_line STRUCTURE mtab_long_line.<br />
DATA:<br />
* Structure to hold program code/comment<br />
BEGIN OF fstr_line,<br />
code(72) TYPE c, &#8221; Program Code<br />
comment(72) TYPE c, &#8221; Inline comments<br />
END OF fstr_line.<br />
LOOP AT ftab_old_prog.<br />
IF ftab_long_line-start = 0.<br />
ftab_long_line-start = ftab_long_line-end + 1.<br />
CLEAR ftab_long_line-end.<br />
ENDIF.<br />
* Strip off any inline comments so they do not get in the way<br />
* If comments are not separated, then words in the comments could<br />
* look like keywords, and cause problems<br />
SPLIT ftab_old_prog-line AT &#8216;&#8221;&#8216; INTO fstr_line-code<br />
fstr_line-comment.<br />
* Align all statements to be left justified<br />
SHIFT fstr_line-code LEFT DELETING LEADING space.<br />
* Put all lines that make up a single statement into one field<br />
* This will make it easier to isolate key words. For example, if you<br />
* want to process a TABLES statement, but exclude the TABLES part<br />
* of a function call, or a subroutine call.<br />
CONCATENATE ftab_long_line-code<br />
fstr_line-code<br />
INTO ftab_long_line-code SEPARATED BY space.<br />
IF fstr_line-code CA &#8216;.&#8217; OR &#8221; Period means end of statement<br />
fstr_line-code(1) = &#8216;*&#8217; OR &#8221; Comment Line<br />
fstr_line-code CO space. &#8221; Blank Line<br />
* Keep track of the table index that the statement ends on<br />
ftab_long_line-end = sy-tabix.<br />
* Remove delimiter from concatenation of fields<br />
SHIFT ftab_long_line-code LEFT BY 1 PLACES.<br />
APPEND ftab_long_line.<br />
CLEAR: ftab_long_line-code,<br />
ftab_long_line-start.<br />
* Don&#8217;t clear out fstr_long_line-end yet. It is used to calc<br />
* fstr_long_line-start.<br />
ENDIF.<br />
ENDLOOP. &#8220; LOOP AT FTAB_OLD_PROG<br />
ENDFORM. &#8220; FORM CREATE_CONDENSED_TABLE<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* FORM FORMAT_PROGRAM *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* &#8230;&#8230;.. *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
FORM format_program.<br />
DATA: lstr_old_prog LIKE mtab_old_prog.<br />
LOOP AT mtab_long_line.<br />
TRANSLATE mtab_long_line-code TO UPPER CASE.<br />
IF mtab_long_line-code(1) EQ &#8216;*&#8217;. &#8220; Do not modify Comment Lines<br />
LOOP AT mtab_old_prog FROM mtab_long_line-start<br />
TO mtab_long_line-end.<br />
mtab_new_prog-line = mtab_old_prog-line.<br />
APPEND mtab_new_prog.<br />
ENDLOOP. &#8221; LOOP AT MTAB_OLD_PROG<br />
ELSEIF mtab_long_line-code(6) EQ &#8216;TABLES&#8217;.<br />
* Reformat any TABLES statements. Will only reformat when TABLES<br />
* is at the start of the statement. Will not try to get table<br />
* descriptions for CALL FUNCTIONS or FORM/PERFORMs<br />
* Get the table names from mstr_long_line.<br />
PERFORM get_table_names_from_statement TABLES mtab_tabname<br />
USING mtab_long_line-code.<br />
* Find the descriptions for each table<br />
PERFORM get_table_descriptions TABLES mtab_tabname.<br />
* create the new statement<br />
PERFORM build_new_tables_statement USING mtab_long_line.<br />
ELSE. &#8221; All other modifications to the code handled here<br />
LOOP AT mtab_old_prog FROM mtab_long_line-start<br />
TO mtab_long_line-end.<br />
* Remove extra spaces from line for comparisons<br />
lstr_old_prog = mtab_old_prog.<br />
CONDENSE lstr_old_prog.<br />
TRANSLATE lstr_old_prog TO UPPER CASE.<br />
IF lstr_old_prog-line CS &#8216;&#8221;&#8216;. &#8220; Comments<br />
mtab_new_prog-line = mtab_old_prog-line.<br />
ELSE.<br />
IF lstr_old_prog-line CS &#8216; LIKE &#8216; OR<br />
lstr_old_prog-line CS &#8216; FOR &#8216;.<br />
PERFORM get_for_like_comment USING mtab_old_prog<br />
CHANGING mtab_new_prog.<br />
ELSEIF lstr_old_prog-line(7) = &#8216;LOOP AT &#8216;.<br />
* save table name into a queue<br />
PERFORM enqueue_itab_name USING mtab_long_line-code.<br />
mtab_new_prog-line = mtab_old_prog-line.<br />
ELSEIF lstr_old_prog-line(7) = &#8216;ENDLOOP&#8217;.<br />
* get name off of queue and add it as a comment to the ENDLOOP line<br />
PERFORM add_comment_to_endloop USING mtab_old_prog-line<br />
CHANGING mtab_new_prog-line.<br />
ELSEIF lstr_old_prog-line(7) EQ &#8216;SELECT &#8216; AND<br />
lstr_old_prog-line(13) NE &#8216;SELECT SINGLE&#8217;.<br />
* save table name into a queue<br />
PERFORM enqueue_tab_name USING mtab_old_prog-line.<br />
mtab_new_prog-line = mtab_old_prog-line.<br />
ELSEIF lstr_old_prog-line(9) = &#8216;ENDSELECT&#8217;.<br />
* get name off of queue and add it as a comment to the ENDSELECT<br />
PERFORM add_comment_to_select USING mtab_old_prog-line<br />
CHANGING mtab_new_prog-line.<br />
ELSEIF lstr_old_prog-line(5) = &#8216;FORM &#8216;.<br />
* save form name into a queue<br />
PERFORM enqueue_form_name USING mtab_old_prog-line.<br />
mtab_new_prog-line = mtab_old_prog-line.<br />
ELSEIF lstr_old_prog-line(7) = &#8216;ENDFORM&#8217;.<br />
* get name off of queue and add it as a comment to the ENDFORM<br />
PERFORM add_comment_to_endform USING mtab_old_prog-line<br />
CHANGING mtab_new_prog-line.<br />
ELSE. &#8221; Any other lines<br />
mtab_new_prog-line = mtab_old_prog-line.<br />
ENDIF.<br />
ENDIF.<br />
PERFORM format_comments CHANGING mtab_new_prog-line.<br />
APPEND mtab_new_prog.<br />
ENDLOOP. &#8221; LOOP AT MTAB_OLD_PROG<br />
ENDIF.<br />
ENDLOOP. &#8221; LOOP AT MTAB_LONG_LINE<br />
ENDFORM. &#8221; FORM CREATE_CONDENSED_TABLE<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* FORM GET_TABLE_NAMES_FROM_STATEMENT *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* &#8230;&#8230;.. *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* &#8211;&gt; FTAB_TABNAME *<br />
* &#8211;&gt; FC_STATEMENT *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
FORM get_table_names_from_statement<br />
TABLES ftab_tabname STRUCTURE mtab_tabname<br />
USING fc_statement.<br />
CLEAR ftab_tabname.<br />
REFRESH ftab_tabname.<br />
REPLACE &#8216;TABLES&#8217; WITH space INTO fc_statement.<br />
TRANSLATE fc_statement USING &#8216;. &#8216;. &#8220; Replace periods<br />
TRANSLATE fc_statement USING &#8216;, &#8216;. &#8220; Replace commas<br />
TRANSLATE fc_statement USING &#8216;: &#8216;. &#8220; Replace colons<br />
CONDENSE fc_statement. &#8220; Remove all extra spaces<br />
SPLIT fc_statement AT space INTO TABLE ftab_tabname.<br />
ENDFORM. &#8220; FORM GET_TABLE_NAMES_FROM_STATEMENT<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* FORM GET_TABLE_DESCRIPTIONS *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* &#8230;&#8230;.. *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* &#8211;&gt; FTAB_TABNAME *<br />
* &#8211;&gt; LOOP *<br />
* &#8211;&gt; AT*<br />
* &#8211;&gt; FTAB_TABNAME *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
FORM get_table_descriptions TABLES ftab_tabname STRUCTURE mtab_tabname.<br />
LOOP AT ftab_tabname.<br />
SELECT SINGLE * FROM dd02t<br />
WHERE tabname = ftab_tabname-tabname<br />
AND ddlanguage = sy-langu.<br />
IF sy-subrc = 0.<br />
ftab_tabname-tabdesc = dd02t-ddtext.<br />
MODIFY ftab_tabname.<br />
ENDIF.<br />
ENDLOOP. &#8220; LOOP AT FTAB_TABNAME<br />
ENDFORM. &#8220; FORM GET_TABLE_DESCRIPTIONS<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* FORM BUILD_NEW_TABLES_STATEMENT *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* &#8230;&#8230;.. *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* &#8211;&gt; FSTR_LONG_LINE *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
FORM build_new_tables_statement<br />
USING fstr_long_line LIKE mtab_long_line.<br />
DATA: lc_sep(1) TYPE c,<br />
li_rows TYPE i.<br />
DESCRIBE TABLE mtab_tabname LINES li_rows.<br />
mtab_new_prog-line = &#8216;TABLES:&#8217;.<br />
APPEND mtab_new_prog.<br />
LOOP AT mtab_tabname.<br />
IF sy-tabix = li_rows.<br />
lc_sep = &#8216;.&#8217;.<br />
ELSE.<br />
lc_sep = &#8216;,&#8217;.<br />
ENDIF.<br />
CONCATENATE &#8216;~~&#8217;<br />
mtab_tabname-tabname<br />
lc_sep<br />
&#8216;&#8221;&#8216;<br />
mtab_tabname-tabdesc<br />
INTO mtab_new_prog SEPARATED BY space.<br />
TRANSLATE mtab_new_prog USING &#8216;~ &#8216;.<br />
APPEND mtab_new_prog.<br />
ENDLOOP. &#8220; LOOP AT MTAB_TABNAME<br />
ENDFORM. &#8220; FORM BUILD_NEW_TABLES_STATEMENT<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* FORM GET_FOR/LIKE_COMMENT *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* &#8230;&#8230;.. *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* &#8211;&gt; F_OLD_PROG *<br />
* &#8211;&gt; F_NEW_PROG *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
FORM get_for_like_comment USING value(f_old_prog) LIKE mtab_old_prog<br />
CHANGING f_new_prog.<br />
DATA:<br />
lc_dummy(1) TYPE c,<br />
lc_tabname(40) TYPE c,<br />
ltab_nametab LIKE dntab OCCURS 0 WITH HEADER LINE,<br />
BEGIN OF lstr_field,<br />
tabname LIKE dd02t-tabname, &#8220; Table name<br />
fldname LIKE dd02t-tabname, &#8220; Table name<br />
END OF lstr_field.<br />
IF f_old_prog-line CA &#8216;&#8221;&#8216; OR &#8220; Line already commented<br />
f_old_prog-line(1) = &#8216;*&#8217;.<br />
f_new_prog = f_old_prog.<br />
EXIT.<br />
ELSEIF f_old_prog CS &#8216; LIKE &#8216;.<br />
SPLIT f_old_prog AT &#8216; LIKE &#8216; INTO lc_dummy<br />
lc_tabname.<br />
ELSEIF f_old_prog CS &#8216; FOR &#8216;.<br />
SPLIT f_old_prog AT &#8216; FOR &#8216; INTO lc_dummy<br />
lc_tabname.<br />
ELSE.<br />
f_new_prog = f_old_prog.<br />
EXIT.<br />
ENDIF.<br />
* If there is anything following the table-field in a LIKE or FOR<br />
* clause it will be removed so that only the table-field remains<br />
SPLIT lc_tabname AT space INTO lc_tabname<br />
lc_dummy.<br />
TRANSLATE lc_tabname USING &#8216;. &#8216;. &#8220; Remove periods<br />
TRANSLATE lc_tabname USING &#8216;, &#8216;. &#8220; Remove commas<br />
CONDENSE lc_tabname. &#8220; Remove extra white space<br />
SPLIT lc_tabname AT &#8216;-&#8217; INTO lstr_field-tabname<br />
lstr_field-fldname.<br />
* The system variables are actually defined in DDIC structure SYST<br />
IF lstr_field-tabname = &#8216;SY&#8217;.<br />
lstr_field-tabname = &#8216;SYST&#8217;.<br />
ENDIF.<br />
CALL FUNCTION &#8216;NAMETAB_GET&#8217;<br />
EXPORTING<br />
langu = sy-langu<br />
only = &#8216; &#8216;<br />
tabname = lstr_field-tabname<br />
TABLES<br />
nametab = ltab_nametab<br />
EXCEPTIONS<br />
OTHERS = 4.<br />
READ TABLE ltab_nametab<br />
WITH KEY tabname = lstr_field-tabname<br />
fieldname = lstr_field-fldname.<br />
IF sy-subrc = 0.<br />
CONCATENATE f_old_prog<br />
&#8216;&#8221;&#8216;<br />
ltab_nametab-fieldtext<br />
INTO f_new_prog SEPARATED BY space.<br />
ELSE.<br />
f_new_prog = f_old_prog.<br />
ENDIF.<br />
ENDFORM. &#8221; FORM BUILD_NEW_TABLES_STATEMENT<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* FORM SAVE_PROGRAM *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* &#8230;&#8230;.. *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
FORM save_program.<br />
DATA:<br />
lc_saveok(1) TYPE c.<br />
DATA:<br />
lstr_message LIKE message.<br />
* Check to see if the program is a local private object ($TMP)<br />
SELECT SINGLE * FROM tadir<br />
WHERE pgmid = &#8216;R3TR&#8217;<br />
AND object = &#8216;PROG&#8217;<br />
AND obj_name = p_report.<br />
IF sy-subrc = 0.<br />
IF tadir-devclass = &#8216;$TMP&#8217;. &#8220; Local Private Object<br />
lc_saveok = &#8216;X&#8217;.<br />
ELSE.<br />
* Check to see if the person trying to update the source is the<br />
* same one who last changed the program<br />
SELECT SINGLE * FROM trdir<br />
WHERE name = p_report.<br />
IF sy-subrc = 0 AND<br />
trdir-unam &lt;&gt; sy-uname.<br />
lc_saveok = space.<br />
MESSAGE ID &#8216;ZSK&#8217; TYPE &#8216;I&#8217; NUMBER 000<br />
WITH &#8216;You are not the user who last changed this program.&#8217;<br />
&#8216; Program changes not saved.&#8217;.<br />
ELSE.<br />
* Check to see if the program is on a request. If it is not,<br />
* do not allow it to be updated. If the user cannot update the<br />
* program, then this program won&#8217;t either.<br />
SELECT SINGLE * FROM e071<br />
WHERE ( ( pgmid = &#8216;R3TR&#8217; AND object = &#8216;PROG&#8217; ) OR<br />
( pgmid = &#8216;LIMU&#8217; AND object = &#8216;REPS&#8217; ) ) AND<br />
obj_name = p_report AND<br />
lockflag = &#8216;X&#8217;.<br />
IF sy-subrc = 0 AND e071-lockflag = &#8216;X&#8217;.<br />
lc_saveok = &#8216;X&#8217;.<br />
ELSE.<br />
lc_saveok = space.<br />
MESSAGE ID &#8216;ZSK&#8217; TYPE &#8216;I&#8217; NUMBER 000<br />
WITH &#8216;Program must be on a transport, or be a local&#8217;<br />
&#8216;private object. Program changes not saved.&#8217;.<br />
ENDIF.<br />
ENDIF.<br />
ENDIF.<br />
ELSE.<br />
lc_saveok = space.<br />
MESSAGE ID &#8216;ZSK&#8217; TYPE &#8216;I&#8217; NUMBER 000<br />
WITH &#8216;Program not saved&#8217;.<br />
ENDIF.<br />
CHECK lc_saveok = &#8216;X&#8217;.<br />
*&#8211; Check to see if the program is locked<br />
CALL FUNCTION &#8216;ENQUEUE_ESRDIRE&#8217;<br />
EXPORTING<br />
mode_trdir = &#8216;X&#8217; &#8220; Exclusive Lock<br />
name = p_report<br />
EXCEPTIONS<br />
foreign_lock = 1<br />
system_failure = 2<br />
OTHERS = 3.<br />
CASE sy-subrc.<br />
WHEN 0. &#8221; OK<br />
INSERT REPORT p_report FROM mtab_new_prog.<br />
IF sy-subrc = 0.<br />
FORMAT COLOR COL_POSITIVE.<br />
WRITE: / &#8216;Program now has fields commented.&#8217;.<br />
ELSE.<br />
FORMAT COLOR COL_NEGATIVE.<br />
WRITE: / &#8216;Error saving program&#8217;.<br />
ENDIF.<br />
CALL FUNCTION &#8216;DEQUEUE_ESRDIRE&#8217;<br />
EXPORTING<br />
mode_trdir = &#8216;E&#8217;<br />
name = p_report.<br />
WHEN 1. &#8220; Locked by another user<br />
CALL FUNCTION &#8216;WRITE_MESSAGE&#8217;<br />
EXPORTING<br />
msgid = &#8216;EU&#8217;<br />
msgno = &#8217;510&#8242;<br />
msgty = &#8216;S&#8217;<br />
msgv1 = sy-msgv1<br />
msgv2 = sy-msgv2<br />
msgv3 = sy-msgv3<br />
msgv4 = sy-msgv4<br />
msgv5 = space<br />
IMPORTING<br />
messg = lstr_message<br />
EXCEPTIONS<br />
OTHERS = 1.<br />
IF sy-subrc = 0.<br />
FORMAT COLOR COL_NEGATIVE INTENSIFIED OFF.<br />
WRITE: / lstr_message-msgtx,<br />
/ &#8216;No changes made to program&#8217;, p_report.<br />
ENDIF.<br />
WHEN 2.<br />
CALL FUNCTION &#8216;WRITE_MESSAGE&#8217;<br />
EXPORTING<br />
msgid = &#8216;EU&#8217;<br />
msgno = &#8217;510&#8242;<br />
msgty = &#8216;S&#8217;<br />
msgv1 = sy-msgv1<br />
msgv2 = sy-msgv2<br />
msgv3 = sy-msgv3<br />
msgv4 = sy-msgv4<br />
msgv5 = space<br />
IMPORTING<br />
messg = lstr_message<br />
EXCEPTIONS<br />
OTHERS = 1.<br />
IF sy-subrc = 0.<br />
FORMAT COLOR COL_NEGATIVE INTENSIFIED OFF.<br />
WRITE: / lstr_message-msgtx,<br />
/ &#8216;No changes made to program&#8217;, p_report.<br />
ENDIF.<br />
ENDCASE.<br />
FORMAT COLOR COL_NORMAL.<br />
SKIP 2.<br />
ENDFORM. &#8220; FORM SAVE_PROGRAM<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* FORM ENQUEUE_ITAB_NAME*<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* &#8230;&#8230;.. *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* &#8211;&gt; F_LINE *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
FORM enqueue_itab_name USING value(f_line) LIKE mtab_long_line-code.<br />
DATA:<br />
lc_dummy(1) TYPE c,<br />
lc_itab(40) TYPE c.<br />
TRANSLATE f_line TO UPPER CASE.<br />
SPLIT f_line AT &#8216;LOOP AT &#8216; INTO lc_dummy<br />
lc_itab.<br />
SPLIT lc_itab AT space INTO lc_itab<br />
lc_dummy.<br />
TRANSLATE lc_itab USING &#8216;. &#8216;.<br />
CONDENSE lc_itab.<br />
mtab_itab_names = lc_itab.<br />
* Always have the most recent LOOP AT table as the first entry in the<br />
* queue<br />
INSERT mtab_itab_names INDEX 1.<br />
ENDFORM. &#8220; ENQUEUE_ITAB_NAME<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* FORM ADD_COMMENT_TO_ENDLOOP *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* &#8230;&#8230;.. *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* &#8211;&gt; FSTR_LONG_LINE *<br />
* &#8211;&gt; F_PROG_LINE *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
FORM add_comment_to_endloop USING fstr_long_line<br />
LIKE mtab_old_prog-line CHANGING f_prog_line.<br />
IF mtab_old_prog-line NA &#8216;&#8221;&#8216;. &#8220; No comments<br />
* Get the internal table from the queue<br />
READ TABLE mtab_itab_names INDEX 1.<br />
CONCATENATE mtab_old_prog-line<br />
&#8216;&#8221;&#8216;<br />
&#8216;LOOP AT&#8217;<br />
mtab_itab_names-tabname<br />
INTO f_prog_line SEPARATED BY space.<br />
* Dequeue the itab name<br />
DELETE mtab_itab_names INDEX 1.<br />
ELSE.<br />
f_prog_line = mtab_old_prog-line.<br />
ENDIF.<br />
ENDFORM. &#8221; FORM SAVE_PROGRAM<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* FORM ENQUEUE_TAB_NAME *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* &#8230;&#8230;.. *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* &#8211;&gt; F_LINE *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
FORM enqueue_tab_name USING f_line LIKE mtab_old_prog-line.<br />
DATA:<br />
lc_dummy(1) TYPE c,<br />
lc_tab(40) TYPE c.<br />
TRANSLATE f_line TO UPPER CASE.<br />
SPLIT f_line AT &#8216; FROM &#8216; INTO lc_dummy<br />
lc_tab.<br />
CONDENSE lc_tab. &#8220; Remove leading/trailing extra spaces<br />
SPLIT lc_tab AT space INTO lc_tab<br />
lc_dummy.<br />
TRANSLATE lc_tab USING &#8216;. &#8216;.<br />
CONDENSE lc_tab.<br />
mtab_tab_names = lc_tab.<br />
* Always have the most recent LOOP AT table as the first entry in the<br />
* queue<br />
INSERT mtab_tab_names INDEX 1.<br />
ENDFORM. &#8220; FORM BUILD_NEW_TABLES_STATEMENT<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* FORM ADD_COMMENT_TO_SELECT *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* &#8230;&#8230;.. *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* &#8211;&gt; FSTR_LONG_LINE *<br />
* &#8211;&gt; F_PROG_LINE *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
FORM add_comment_to_select USING fstr_long_line LIKE mtab_old_prog-line<br />
CHANGING f_prog_line.<br />
IF mtab_old_prog-line NA &#8216;&#8221;&#8216;. &#8220; No comments<br />
* Get the table from the queue<br />
READ TABLE mtab_tab_names INDEX 1.<br />
CONCATENATE mtab_old_prog-line<br />
&#8216;&#8221;&#8216;<br />
&#8216;SELECT FROM&#8217;<br />
mtab_tab_names-tabname<br />
INTO f_prog_line SEPARATED BY space.<br />
* Dequeue the tab name<br />
DELETE mtab_tab_names INDEX 1.<br />
ELSE.<br />
f_prog_line = mtab_old_prog-line.<br />
ENDIF.<br />
ENDFORM. &#8221; FORM SAVE_PROGRAM<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* FORM ADD_COMMENT_TO_ENDFORM *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* &#8230;&#8230;.. *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* &#8211;&gt; FSTR_LONG_LINE *<br />
* &#8211;&gt; F_NEW_PROG *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
FORM add_comment_to_endform USING fstr_long_line<br />
LIKE mtab_old_prog-line CHANGING f_prog_line.<br />
IF mtab_old_prog-line NA &#8216;&#8221;&#8216;. &#8220; No comments<br />
* Get the table from the queue<br />
READ TABLE mtab_form_names INDEX 1.<br />
CONCATENATE mtab_old_prog-line<br />
&#8216;&#8221;&#8216;<br />
&#8216;FORM&#8217;<br />
mtab_form_names-tabname<br />
INTO f_prog_line SEPARATED BY space.<br />
* Dequeue the form name<br />
DELETE mtab_form_names INDEX 1.<br />
ELSE.<br />
f_prog_line = mtab_old_prog-line.<br />
ENDIF.<br />
ENDFORM. &#8220; FORM SAVE_PROGRAM<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* FORM ENQUEUE_FORM_NAME*<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* &#8230;&#8230;.. *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* &#8211;&gt; F_LINE *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
FORM enqueue_form_name USING f_line.<br />
DATA:<br />
lc_dummy(1) TYPE c,<br />
lc_tab(40) TYPE c.<br />
TRANSLATE f_line TO UPPER CASE.<br />
SPLIT f_line AT &#8216;FORM &#8216; INTO lc_dummy<br />
lc_tab.<br />
CONDENSE lc_tab. &#8220; Remove leading/trailing extra spaces<br />
SPLIT lc_tab AT space INTO lc_tab<br />
lc_dummy.<br />
TRANSLATE lc_tab USING &#8216;. &#8216;.<br />
CONDENSE lc_tab.<br />
mtab_form_names = lc_tab.<br />
* Always have the most recent LOOP AT table as the first entry in the<br />
* queue<br />
INSERT mtab_form_names INDEX 1.<br />
ENDFORM. &#8220; FORM ENQUEUE_FORM_NAME<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* FORM format_comments *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* This routine has not been well tested, so there may be *<br />
* some unanticipated features present! *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
* &#8211;&gt; F_PROGLINE *<br />
*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*<br />
FORM format_comments CHANGING f_progline LIKE mtab_new_prog-line.<br />
DATA: li_pos TYPE i,<br />
li_code_len TYPE i, &#8220; Length of the code<br />
li_comm_len TYPE i, &#8220; length of the comment<br />
lc_line LIKE mtab_new_prog-line,<br />
lc_comment LIKE mtab_new_prog-line.<br />
*&#8211; Make sure there is an inline comment on the line<br />
CHECK f_progline CS &#8216;&#8221;&#8216;.<br />
*&#8211; Separate program code from comments<br />
SPLIT f_progline AT &#8216;&#8221;&#8216; INTO lc_line<br />
lc_comment.<br />
CONCATENATE &#8216;&#8221;&#8216;<br />
lc_comment<br />
INTO lc_comment SEPARATED BY space.<br />
f_progline = lc_line.<br />
li_code_len = STRLEN( lc_line ).<br />
li_comm_len = STRLEN( lc_comment ).<br />
li_pos = 70 &#8211; li_code_len &#8211; li_comm_len.<br />
IF li_pos GE 45 AND<br />
li_pos GT li_code_len.<br />
f_progline+li_pos = lc_comment.<br />
ENDIF.<br />
ENDFORM.&#8221; format_comments</p>
<p><a href="http://abap4.tripod.com/Beautify_Source_Code.html" target="_blank">*Source = Kevin</a></p>


<p>You might also be interested in these posts:<ol><li><a href='http://www.abap-tutorials.com/2009/09/16/abap-program-for-table-maintenance-in-sap/' rel='bookmark' title='ABAP Program for Table Maintenance in SAP'>ABAP Program for Table Maintenance in SAP</a></li>
<li><a href='http://www.abap-tutorials.com/2009/09/10/displaying-icons-in-alv-abap/' rel='bookmark' title='Displaying Icons in ALV Grid using ABAP'>Displaying Icons in ALV Grid using ABAP</a></li>
<li><a href='http://www.abap-tutorials.com/2009/08/24/tic-tac-toe-game-in-sap/' rel='bookmark' title='Tic-Tac-Toe Game in SAP'>Tic-Tac-Toe Game in SAP</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.abap-tutorials.com/2009/07/05/pritty-report-vs-pritty-printer/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

