This program takes an existing ABAP report, and does the following:

- Attempts to
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 data elements, parameters, and select-options that are defined using the LIKE or FOR statement
- For ENDLOOP/ENDSELECT
adds comment identify the LOOP/SELECT that is being closed
- For FORM/ENDFORM
adds comment identify the FORM that is being closed
- 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.
- Calls function PRETTY_PRINTER to do the SAP standard pretty print after the custom comments have been created.

*-----------------------------------------------------------*
*-----------------------------------------------------------*
* Pretty Report - format the ABAP Program
*-----------------------------------------------------------*

REPORT zabap_pretty_report .
TABLES:
e071 , " Objects of a request or task (E070)
tadir , " Catalog of R/3 Repository objects
trdir , " System table TRDIR
dd02t . " R/3-DD: SAP Table Texts
DATA: BEGIN OF mtab_old_prog OCCURS 0,
line(72) TYPE c,
END OF mtab_old_prog.
DATA: BEGIN OF mtab_new_prog OCCURS 0,
line(72) TYPE c,
END OF mtab_new_prog.
DATA: BEGIN OF mtab_statement OCCURS 0,
line(72) TYPE c,
END OF mtab_statement.
DATA:
* Hold an entire statement, even if it spans multiple lines
BEGIN OF mtab_long_line OCCURS 0,
start TYPE i,
end TYPE i,
code(5000) TYPE c,
END OF mtab_long_line.
DATA: BEGIN OF mtab_tabname OCCURS 0,
tabname LIKE dd02t-tabname, " Table name
tabdesc LIKE dd02t-ddtext, "Short text describing ABAP/4 Dictio
END OF mtab_tabname.
* Queue to hold list of internal table names for commenting the ENDLOOP
* line

DATA: BEGIN OF mtab_itab_names OCCURS 0,
tabname(40) TYPE c,
END OF mtab_itab_names.
* Queue to hold list of table names for commenting the ENDSELECT line
DATA: BEGIN OF mtab_tab_names OCCURS 0,
tabname(40) TYPE c,
END OF mtab_tab_names.
DATA: BEGIN OF mtab_form_names OCCURS 0,
tabname(40) TYPE c,
END OF mtab_form_names.
PARAMETERS:
p_report LIKE sy-repid, " Program: Name of ABAP/4 program
p_test AS CHECKBOX DEFAULT 'X'.
START-OF-SELECTION.
PERFORM get_program_code TABLES mtab_old_prog
USING p_report.
END-OF-SELECTION.
PERFORM create_condensed_table TABLES mtab_old_prog
mtab_long_line.
PERFORM format_program.
CALL FUNCTION 'PRETTY_PRINTER'
EXPORTING
inctoo = space
TABLES
ntext = mtab_new_prog
otext = mtab_new_prog
EXCEPTIONS
enqueue_table_full = 1
include_enqueued = 2
include_readerror = 3
include_writeerror = 4
OTHERS = 5.
IF p_test = space.
PERFORM save_program.
ENDIF.
LOOP AT mtab_new_prog.
IF mtab_new_prog = space.
SKIP 1.
ENDIF.
WRITE: / mtab_new_prog.
ENDLOOP. " LOOP AT MTAB_NEW_PROG
*-----------------------------------------------------------*
* FORM GET_PROGRAM_CODE *
*-----------------------------------------------------------*
* --> FTAB_OLD_PROG *
* --> F_REPORT *
*-----------------------------------------------------------*
FORM get_program_code TABLES ftab_old_prog STRUCTURE mtab_old_prog
USING f_report.
* Read the program code into an internal table
REFRESH ftab_old_prog.
READ REPORT f_report INTO ftab_old_prog.
SELECT SINGLE * FROM trdir WHERE name = f_report.
IF sy-subrc NE 0.
WRITE: / 'Unable to read report:', f_report.
WRITE: / 'Exiting program'.
ENDIF.
ENDFORM. "
FORM GET_PROGRAM_CODE
*-----------------------------------------------------------*
* FORM CREATE_CONDENSED_TABLE *
*-----------------------------------------------------------*
* Create a table that has all statements condensed onto 1 line *
*-----------------------------------------------------------*
* --> FTAB_OLD_PROG *
* --> FTAB_long_line *
*-----------------------------------------------------------*
FORM create_condensed_table
TABLES ftab_old_prog STRUCTURE mtab_old_prog
ftab_long_line STRUCTURE mtab_long_line.
DATA:
* Structure to hold program code/comment
BEGIN OF fstr_line,
code(72) TYPE c, " Program Code
comment(72) TYPE c, " Inline comments
END OF fstr_line.
LOOP AT ftab_old_prog.
IF ftab_long_line-start = 0.
ftab_long_line-start = ftab_long_line-end + 1.
CLEAR ftab_long_line-end.
ENDIF.
* Strip off any inline comments so they do not get in the way
* If comments are not separated, then words in the comments could
* look like keywords, and cause problems

SPLIT ftab_old_prog-line AT '"' INTO fstr_line-code
fstr_line-comment.
* Align all statements to be left justified
SHIFT fstr_line-code LEFT DELETING LEADING space.
* Put all lines that make up a single statement into one field
* This will make it easier to isolate key words. For example, if you
* want to process a TABLES statement, but exclude the TABLES part
* of a function call, or a subroutine call.

CONCATENATE ftab_long_line-code
fstr_line-code
INTO ftab_long_line-code SEPARATED BY space.
IF fstr_line-code CA '.' OR " Period means end of statement
fstr_line-code(1) = '*' OR " Comment Line
fstr_line-code CO space. " Blank Line
* Keep track of the table index that the statement ends on
ftab_long_line-end = sy-tabix.
* Remove delimiter from concatenation of fields
SHIFT ftab_long_line-code LEFT BY 1 PLACES.
APPEND ftab_long_line.
CLEAR: ftab_long_line-code,
ftab_long_line-start.
* Don't clear out fstr_long_line-end yet. It is used to calc
* fstr_long_line-start.

ENDIF.
ENDLOOP. "
LOOP AT FTAB_OLD_PROG
ENDFORM. "
FORM CREATE_CONDENSED_TABLE
*-----------------------------------------------------------*
* FORM FORMAT_PROGRAM *
*-----------------------------------------------------------*
* ........ *
*-----------------------------------------------------------*
FORM format_program.
DATA: lstr_old_prog LIKE mtab_old_prog.
LOOP AT mtab_long_line.
TRANSLATE mtab_long_line-code TO UPPER CASE.
IF mtab_long_line-code(1) EQ '*'. "
Do not modify Comment Lines
LOOP AT mtab_old_prog FROM mtab_long_line-start
TO mtab_long_line-end.
mtab_new_prog-line = mtab_old_prog-line.
APPEND mtab_new_prog.
ENDLOOP. " LOOP AT MTAB_OLD_PROG
ELSEIF mtab_long_line-code(6) EQ 'TABLES'.
* Reformat any TABLES statements. Will only reformat when TABLES
* is at the start of the statement. Will not try to get table
* descriptions for CALL FUNCTIONS or FORM/PERFORMs
* Get the table names from mstr_long_line.

PERFORM get_table_names_from_statement TABLES mtab_tabname
USING mtab_long_line-code.
* Find the descriptions for each table
PERFORM get_table_descriptions TABLES mtab_tabname.
* create the new statement
PERFORM build_new_tables_statement USING mtab_long_line.
ELSE. " All other modifications to the code handled here
LOOP AT mtab_old_prog FROM mtab_long_line-start
TO mtab_long_line-end.
* Remove extra spaces from line for comparisons
lstr_old_prog = mtab_old_prog.
CONDENSE lstr_old_prog.
TRANSLATE lstr_old_prog TO UPPER CASE.
IF lstr_old_prog-line CS '"'. "
Comments
mtab_new_prog-line = mtab_old_prog-line.
ELSE.
IF lstr_old_prog-line CS ' LIKE ' OR
lstr_old_prog-line CS ' FOR '.
PERFORM get_for_like_comment USING mtab_old_prog
CHANGING mtab_new_prog.
ELSEIF lstr_old_prog-line(7) = 'LOOP AT '.
* save table name into a queue
PERFORM enqueue_itab_name USING mtab_long_line-code.
mtab_new_prog-line = mtab_old_prog-line.
ELSEIF lstr_old_prog-line(7) = 'ENDLOOP'.
* get name off of queue and add it as a comment to the ENDLOOP line
PERFORM add_comment_to_endloop USING mtab_old_prog-line
CHANGING mtab_new_prog-line.
ELSEIF lstr_old_prog-line(7) EQ 'SELECT ' AND
lstr_old_prog-line(13) NE 'SELECT SINGLE'.
* save table name into a queue
PERFORM enqueue_tab_name USING mtab_old_prog-line.
mtab_new_prog-line = mtab_old_prog-line.
ELSEIF lstr_old_prog-line(9) = 'ENDSELECT'.
* get name off of queue and add it as a comment to the ENDSELECT
PERFORM add_comment_to_select USING mtab_old_prog-line
CHANGING mtab_new_prog-line.
ELSEIF lstr_old_prog-line(5) = 'FORM '.
* save form name into a queue
PERFORM enqueue_form_name USING mtab_old_prog-line.
mtab_new_prog-line = mtab_old_prog-line.
ELSEIF lstr_old_prog-line(7) = 'ENDFORM'.
* get name off of queue and add it as a comment to the ENDFORM
PERFORM add_comment_to_endform USING mtab_old_prog-line
CHANGING mtab_new_prog-line.
ELSE.
" Any other lines
mtab_new_prog-line = mtab_old_prog-line.
ENDIF.
ENDIF.
PERFORM format_comments CHANGING mtab_new_prog-line.
APPEND mtab_new_prog.
ENDLOOP.
" LOOP AT MTAB_OLD_PROG
ENDIF.
ENDLOOP.
" LOOP AT MTAB_LONG_LINE
ENDFORM.
" FORM CREATE_CONDENSED_TABLE
*-----------------------------------------------------------*
* FORM GET_TABLE_NAMES_FROM_STATEMENT *
*-----------------------------------------------------------*
* ........ *
*-----------------------------------------------------------*
* --> FTAB_TABNAME *
* --> FC_STATEMENT *
*-----------------------------------------------------------*
FORM get_table_names_from_statement
TABLES ftab_tabname STRUCTURE mtab_tabname
USING fc_statement.
CLEAR ftab_tabname.
REFRESH ftab_tabname.
REPLACE 'TABLES' WITH space INTO fc_statement.
TRANSLATE fc_statement USING '. '. "
Replace periods
TRANSLATE fc_statement USING ', '. "
Replace commas
TRANSLATE fc_statement USING ': '. "
Replace colons
CONDENSE fc_statement. "
Remove all extra spaces
SPLIT fc_statement AT space INTO TABLE ftab_tabname.
ENDFORM. "
FORM GET_TABLE_NAMES_FROM_STATEMENT
*-----------------------------------------------------------*
* FORM GET_TABLE_DESCRIPTIONS *
*-----------------------------------------------------------*
* ........ *
*-----------------------------------------------------------*
* --> FTAB_TABNAME *
* --> LOOP *
* --> AT*
* --> FTAB_TABNAME *
*-----------------------------------------------------------*
FORM get_table_descriptions TABLES ftab_tabname STRUCTURE mtab_tabname.
LOOP AT ftab_tabname.
SELECT SINGLE * FROM dd02t
WHERE tabname = ftab_tabname-tabname
AND ddlanguage = sy-langu.
IF sy-subrc = 0.
ftab_tabname-tabdesc = dd02t-ddtext.
MODIFY ftab_tabname.
ENDIF.
ENDLOOP. "
LOOP AT FTAB_TABNAME
ENDFORM. " FORM GET_TABLE_DESCRIPTIONS
*-----------------------------------------------------------*
* FORM BUILD_NEW_TABLES_STATEMENT *
*-----------------------------------------------------------*
* ........ *
*-----------------------------------------------------------*
* --> FSTR_LONG_LINE *
*-----------------------------------------------------------*
FORM build_new_tables_statement
USING fstr_long_line LIKE mtab_long_line.
DATA: lc_sep(1) TYPE c,
li_rows TYPE i.
DESCRIBE TABLE mtab_tabname LINES li_rows.
mtab_new_prog-line = 'TABLES:'.
APPEND mtab_new_prog.
LOOP AT mtab_tabname.
IF sy-tabix = li_rows.
lc_sep = '.'.
ELSE.
lc_sep = ','.
ENDIF.
CONCATENATE '~~'
mtab_tabname-tabname
lc_sep
'"'
mtab_tabname-tabdesc
INTO mtab_new_prog SEPARATED BY space.
TRANSLATE mtab_new_prog USING '~ '.
APPEND mtab_new_prog.
ENDLOOP. "
LOOP AT MTAB_TABNAME
ENDFORM. "
FORM BUILD_NEW_TABLES_STATEMENT
*-----------------------------------------------------------*
* FORM GET_FOR/LIKE_COMMENT *
*-----------------------------------------------------------*
* ........ *
*-----------------------------------------------------------*
* --> F_OLD_PROG *
* --> F_NEW_PROG *
*-----------------------------------------------------------*
FORM get_for_like_comment USING value(f_old_prog) LIKE mtab_old_prog
CHANGING f_new_prog.
DATA:
lc_dummy(1) TYPE c,
lc_tabname(40) TYPE c,
ltab_nametab LIKE dntab OCCURS 0 WITH HEADER LINE,
BEGIN OF lstr_field,
tabname LIKE dd02t-tabname, "
Table name
fldname LIKE dd02t-tabname, "
Table name
END OF lstr_field.
IF f_old_prog-line CA '"' OR "
Line already commented
f_old_prog-line(1) = '*'.
f_new_prog = f_old_prog.
EXIT.
ELSEIF f_old_prog CS ' LIKE '.
SPLIT f_old_prog AT ' LIKE ' INTO lc_dummy
lc_tabname.
ELSEIF f_old_prog CS ' FOR '.
SPLIT f_old_prog AT ' FOR ' INTO lc_dummy
lc_tabname.
ELSE.
f_new_prog = f_old_prog.
EXIT.
ENDIF.
* If there is anything following the table-field in a LIKE or FOR
* clause it will be removed so that only the table-field remains

SPLIT lc_tabname AT space INTO lc_tabname
lc_dummy.
TRANSLATE lc_tabname USING '. '. "
Remove periods
TRANSLATE lc_tabname USING ', '. "
Remove commas
CONDENSE lc_tabname. "
Remove extra white space
SPLIT lc_tabname AT '-' INTO lstr_field-tabname
lstr_field-fldname.
* The system variables are actually defined in DDIC structure SYST
IF lstr_field-tabname = 'SY'.
lstr_field-tabname = 'SYST'.
ENDIF.
CALL FUNCTION 'NAMETAB_GET'
EXPORTING
langu = sy-langu
only = ' '
tabname = lstr_field-tabname
TABLES
nametab = ltab_nametab
EXCEPTIONS
OTHERS = 4.
READ TABLE ltab_nametab
WITH KEY tabname = lstr_field-tabname
fieldname = lstr_field-fldname.
IF sy-subrc = 0.
CONCATENATE f_old_prog
'"'
ltab_nametab-fieldtext
INTO f_new_prog SEPARATED BY space.
ELSE.
f_new_prog = f_old_prog.
ENDIF.
ENDFORM.
" FORM BUILD_NEW_TABLES_STATEMENT
*-----------------------------------------------------------*
* FORM SAVE_PROGRAM *
*-----------------------------------------------------------*
* ........ *
*-----------------------------------------------------------*
FORM save_program.
DATA:
lc_saveok(1) TYPE c.
DATA:
lstr_message LIKE message.
* Check to see if the program is a local private object ($TMP)
SELECT SINGLE * FROM tadir
WHERE pgmid = 'R3TR'
AND object = 'PROG'
AND obj_name = p_report.
IF sy-subrc = 0.
IF tadir-devclass = '$TMP'. "
Local Private Object
lc_saveok = 'X'.
ELSE.
* Check to see if the person trying to update the source is the
* same one who last changed the program

SELECT SINGLE * FROM trdir
WHERE name = p_report.
IF sy-subrc = 0 AND
trdir-unam <> sy-uname.
lc_saveok = space.
MESSAGE ID 'ZSK' TYPE 'I' NUMBER 000
WITH 'You are not the user who last changed this program.'
' Program changes not saved.'.
ELSE.
* Check to see if the program is on a request. If it is not,
* do not allow it to be updated. If the user cannot update the
* program, then this program won't either.

SELECT SINGLE * FROM e071
WHERE ( ( pgmid = 'R3TR' AND object = 'PROG' ) OR
( pgmid = 'LIMU' AND object = 'REPS' ) ) AND
obj_name = p_report AND
lockflag = 'X'.
IF sy-subrc = 0 AND e071-lockflag = 'X'.
lc_saveok = 'X'.
ELSE.
lc_saveok = space.
MESSAGE ID 'ZSK' TYPE 'I' NUMBER 000
WITH 'Program must be on a transport, or be a local'
'private object. Program changes not saved.'.
ENDIF.
ENDIF.
ENDIF.
ELSE.
lc_saveok = space.
MESSAGE ID 'ZSK' TYPE 'I' NUMBER 000
WITH 'Program not saved'.
ENDIF.
CHECK lc_saveok = 'X'.
*-- Check to see if the program is locked
CALL FUNCTION 'ENQUEUE_ESRDIRE'
EXPORTING
mode_trdir = 'X' "
Exclusive Lock
name = p_report
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
CASE sy-subrc.
WHEN 0. " OK
INSERT REPORT p_report FROM mtab_new_prog.
IF sy-subrc = 0.
FORMAT COLOR COL_POSITIVE.
WRITE: / 'Program now has fields commented.'.
ELSE.
FORMAT COLOR COL_NEGATIVE.
WRITE: / 'Error saving program'.
ENDIF.
CALL FUNCTION 'DEQUEUE_ESRDIRE'
EXPORTING
mode_trdir = 'E'
name = p_report.
WHEN 1. "
Locked by another user
CALL FUNCTION 'WRITE_MESSAGE'
EXPORTING
msgid = 'EU'
msgno = '510'
msgty = 'S'
msgv1 = sy-msgv1
msgv2 = sy-msgv2
msgv3 = sy-msgv3
msgv4 = sy-msgv4
msgv5 = space
IMPORTING
messg = lstr_message
EXCEPTIONS
OTHERS = 1.
IF sy-subrc = 0.
FORMAT COLOR COL_NEGATIVE INTENSIFIED OFF.
WRITE: / lstr_message-msgtx,
/ 'No changes made to program', p_report.
ENDIF.
WHEN 2.
CALL FUNCTION 'WRITE_MESSAGE'
EXPORTING
msgid = 'EU'
msgno = '510'
msgty = 'S'
msgv1 = sy-msgv1
msgv2 = sy-msgv2
msgv3 = sy-msgv3
msgv4 = sy-msgv4
msgv5 = space
IMPORTING
messg = lstr_message
EXCEPTIONS
OTHERS = 1.
IF sy-subrc = 0.
FORMAT COLOR COL_NEGATIVE INTENSIFIED OFF.
WRITE: / lstr_message-msgtx,
/ 'No changes made to program', p_report.
ENDIF.
ENDCASE.
FORMAT COLOR COL_NORMAL.
SKIP 2.
ENDFORM. "
FORM SAVE_PROGRAM
*-----------------------------------------------------------*
* FORM ENQUEUE_ITAB_NAME*
*-----------------------------------------------------------*
* ........ *
*-----------------------------------------------------------*
* --> F_LINE *
*-----------------------------------------------------------*
FORM enqueue_itab_name USING value(f_line) LIKE mtab_long_line-code.
DATA:
lc_dummy(1) TYPE c,
lc_itab(40) TYPE c.
TRANSLATE f_line TO UPPER CASE.
SPLIT f_line AT 'LOOP AT ' INTO lc_dummy
lc_itab.
SPLIT lc_itab AT space INTO lc_itab
lc_dummy.
TRANSLATE lc_itab USING '. '.
CONDENSE lc_itab.
mtab_itab_names = lc_itab.
* Always have the most recent LOOP AT table as the first entry in the
* queue

INSERT mtab_itab_names INDEX 1.
ENDFORM. "
ENQUEUE_ITAB_NAME
*-----------------------------------------------------------*
* FORM ADD_COMMENT_TO_ENDLOOP *
*-----------------------------------------------------------*
* ........ *
*-----------------------------------------------------------*
* --> FSTR_LONG_LINE *
* --> F_PROG_LINE *
*-----------------------------------------------------------*
FORM add_comment_to_endloop USING fstr_long_line
LIKE mtab_old_prog-line CHANGING f_prog_line.
IF mtab_old_prog-line NA '"'. "
No comments
* Get the internal table from the queue
READ TABLE mtab_itab_names INDEX 1.
CONCATENATE mtab_old_prog-line
'"'
'LOOP AT'
mtab_itab_names-tabname
INTO f_prog_line SEPARATED BY space.
* Dequeue the itab name
DELETE mtab_itab_names INDEX 1.
ELSE.
f_prog_line = mtab_old_prog-line.
ENDIF.
ENDFORM.
" FORM SAVE_PROGRAM
*-----------------------------------------------------------*
* FORM ENQUEUE_TAB_NAME *
*-----------------------------------------------------------*
* ........ *
*-----------------------------------------------------------*
* --> F_LINE *
*-----------------------------------------------------------*
FORM enqueue_tab_name USING f_line LIKE mtab_old_prog-line.
DATA:
lc_dummy(1) TYPE c,
lc_tab(40) TYPE c.
TRANSLATE f_line TO UPPER CASE.
SPLIT f_line AT ' FROM ' INTO lc_dummy
lc_tab.
CONDENSE lc_tab. "
Remove leading/trailing extra spaces
SPLIT lc_tab AT space INTO lc_tab
lc_dummy.
TRANSLATE lc_tab USING '. '.
CONDENSE lc_tab.
mtab_tab_names = lc_tab.
* Always have the most recent LOOP AT table as the first entry in the
* queue

INSERT mtab_tab_names INDEX 1.
ENDFORM. "
FORM BUILD_NEW_TABLES_STATEMENT
*-----------------------------------------------------------*
* FORM ADD_COMMENT_TO_SELECT *
*-----------------------------------------------------------*
* ........ *
*-----------------------------------------------------------*
* --> FSTR_LONG_LINE *
* --> F_PROG_LINE *
*-----------------------------------------------------------*
FORM add_comment_to_select USING fstr_long_line LIKE mtab_old_prog-line
CHANGING f_prog_line.
IF mtab_old_prog-line NA '"'. "
No comments
* Get the table from the queue
READ TABLE mtab_tab_names INDEX 1.
CONCATENATE mtab_old_prog-line
'"'
'SELECT FROM'
mtab_tab_names-tabname
INTO f_prog_line SEPARATED BY space.
* Dequeue the tab name
DELETE mtab_tab_names INDEX 1.
ELSE.
f_prog_line = mtab_old_prog-line.
ENDIF.
ENDFORM. " FORM SAVE_PROGRAM
*-----------------------------------------------------------*
* FORM ADD_COMMENT_TO_ENDFORM *
*-----------------------------------------------------------*
* ........ *
*-----------------------------------------------------------*
* --> FSTR_LONG_LINE *
* --> F_NEW_PROG *
*-----------------------------------------------------------*
FORM add_comment_to_endform USING fstr_long_line
LIKE mtab_old_prog-line CHANGING f_prog_line.
IF mtab_old_prog-line NA '"'. "
No comments
* Get the table from the queue
READ TABLE mtab_form_names INDEX 1.
CONCATENATE mtab_old_prog-line
'"'
'FORM'
mtab_form_names-tabname
INTO f_prog_line SEPARATED BY space.
* Dequeue the form name
DELETE mtab_form_names INDEX 1.
ELSE.
f_prog_line = mtab_old_prog-line.
ENDIF.
ENDFORM. "
FORM SAVE_PROGRAM
*-----------------------------------------------------------*
* FORM ENQUEUE_FORM_NAME*
*-----------------------------------------------------------*
* ........ *
*-----------------------------------------------------------*
* --> F_LINE *
*-----------------------------------------------------------*
FORM enqueue_form_name USING f_line.
DATA:
lc_dummy(1) TYPE c,
lc_tab(40) TYPE c.
TRANSLATE f_line TO UPPER CASE.
SPLIT f_line AT 'FORM ' INTO lc_dummy
lc_tab.
CONDENSE lc_tab. "
Remove leading/trailing extra spaces
SPLIT lc_tab AT space INTO lc_tab
lc_dummy.
TRANSLATE lc_tab USING '. '.
CONDENSE lc_tab.
mtab_form_names = lc_tab.
* Always have the most recent LOOP AT table as the first entry in the
* queue

INSERT mtab_form_names INDEX 1.
ENDFORM. "
FORM ENQUEUE_FORM_NAME
*-----------------------------------------------------------*
* FORM format_comments *
*-----------------------------------------------------------*
* This routine has not been well tested, so there may be *
* some unanticipated features present! *
*-----------------------------------------------------------*
* --> F_PROGLINE *
*-----------------------------------------------------------*
FORM format_comments CHANGING f_progline LIKE mtab_new_prog-line.
DATA: li_pos TYPE i,
li_code_len TYPE i, "
Length of the code
li_comm_len TYPE i, "
length of the comment
lc_line LIKE mtab_new_prog-line,
lc_comment LIKE mtab_new_prog-line.
*-- Make sure there is an inline comment on the line
CHECK f_progline CS '"'.
*-- Separate program code from comments
SPLIT f_progline AT '"' INTO lc_line
lc_comment.
CONCATENATE '"'
lc_comment
INTO lc_comment SEPARATED BY space.
f_progline = lc_line.
li_code_len = STRLEN( lc_line ).
li_comm_len = STRLEN( lc_comment ).
li_pos = 70 - li_code_len - li_comm_len.
IF li_pos GE 45 AND
li_pos GT li_code_len.
f_progline+li_pos = lc_comment.
ENDIF.
ENDFORM."
format_comments


*source=Internet


The following program when generated will display a list of all User-Exits and BADI (Business Add-Ins) for the specified T-Code.


*-----------------------------------------------------------*
*& Report ZRPT_EXIT_BADI *
*-----------------------------------------------------------*
*& User exits/BADIs for T-code *
*-----------------------------------------------------------*
report zrpt_userexit_badi .
tables : tstc,
tadir,
modsapt,
modact,
trdir,
tfdir,
enlfdir,
sxs_attrt ,
tstct.
data : jtab like tadir occurs 0 with header line.
data : field1(30).
data : v_devclass like tadir-devclass.
parameters : p_tcode like tstc-tcode,
p_pgmna like tstc-pgmna .
data wa_tadir type tadir.
start-of-selection.
if not p_tcode is initial.
select single * from tstc where tcode eq p_tcode.
elseif not p_pgmna is initial.
tstc-pgmna = p_pgmna.
endif.
if sy-subrc eq 0.
select single * from tadir
where pgmid = 'R3TR'
and object = 'PROG'
and obj_name = tstc-pgmna.
move : tadir-devclass to v_devclass.
if sy-subrc ne 0.
select single * from trdir
where name = tstc-pgmna.
if trdir-subc eq 'F'.
select single * from tfdir
where pname = tstc-pgmna.
select single * from enlfdir
where funcname = tfdir-funcname.
select single * from tadir
where pgmid = 'R3TR'
and object = 'FUGR'
and obj_name eq enlfdir-area.
move : tadir-devclass to v_devclass.
endif.
endif.
select * from tadir into table jtab
where pgmid = 'R3TR'
and object in ('SMOD', 'SXSD')
and devclass = v_devclass.
select single * from tstct
where sprsl eq sy-langu
and tcode eq p_tcode.
format color col_positive intensified off.
write:/(19) 'Transaction Code - ',
20(20) p_tcode,
45(50) tstct-ttext.
skip.
if not jtab[] is initial.
write:/(105) sy-uline.
format color col_heading intensified on.
* SORTING THE INTERNAL TABLE
sort jtab by object.
data : wf_txt(60) type c,
wf_smod type i ,
wf_badi type i ,
wf_object2(30) type c.
clear : wf_smod, wf_badi , wf_object2.
*GET THE TOTAL SMOD.
loop at jtab into wa_tadir.
at first.
format color col_heading intensified on.
write:/1 sy-vline,
2 'Enhancement/ Business Add-in',
41 sy-vline ,
42 'Description',
105 sy-vline.
write:/(105) sy-uline.
endat.
clear wf_txt.
at new object.
if wa_tadir-object = 'SMOD'.
wf_object2 = 'Enhancement' .
elseif wa_tadir-object = 'SXSD'.
wf_object2 = ' Business Add-in'.
endif.
format color col_group intensified on.
write:/1 sy-vline,
2 wf_object2,
105 sy-vline.
endat.
case wa_tadir-object.
when 'SMOD'.
wf_smod = wf_smod + 1.
select single modtext into wf_txt
from modsapt
where sprsl = sy-langu
and name = wa_tadir-obj_name.
format color col_normal intensified off.
when 'SXSD'.
* FOR BADIS
wf_badi = wf_badi + 1 .
select single text into wf_txt
from sxs_attrt
where sprsl = sy-langu
and exit_name = wa_tadir-obj_name.
format color col_normal intensified on.
endcase.
write:/1 sy-vline,
2 wa_tadir-obj_name hotspot on,
41 sy-vline ,
42 wf_txt,
105 sy-vline.
at end of object.
write : /(105) sy-uline.
endat.
endloop.
write:/(105) sy-uline.
skip.
format color col_total intensified on.
write:/ 'No.of Exits:' , wf_smod.
write:/ 'No.of BADis:' , wf_badi.
else.
format color col_negative intensified on.
write:/(105) 'No userexits or BADis exist'.
endif.
else.
format color col_negative intensified on.
write:/(105) 'Transaction does not exist'.
endif.
at line-selection.
data : wf_object type tadir-object.
clear wf_object.
get cursor field field1.
check field1(8) eq 'WA_TADIR'.
read table jtab with key obj_name = sy-lisel+1(20).
move jtab-object to wf_object.
case wf_object.
when 'SMOD'.
set parameter id 'MON' field sy-lisel+1(10).
call transaction 'SMOD' and skip first screen.
when 'SXSD'.
set parameter id 'EXN' field sy-lisel+1(20).
call transaction 'SE18' and skip first screen.
endcase.

* Source = Internet

Everything function that is to performed in SAP is represented in the form of a Transaction and to execute that Transaction, SAP provide a Transaction Code (T-Code). On the SAP Intial Screen, you can enter this T-Code in the T-Code field provided at the top.


You can execute the following commands in the transaction code (tcode) field with Enter. You will find some useful transaction codes below to work in tandem with the following commands:
To call a transaction - In the same session (window) Enter: /nxxxx (xxxx = transaction code). - In an additional session, Enter: /oxxxx (xxxx = transaction code).
If you enter this function before any of the tcodes below, you are able to break out of your current screen/business and begin a completely new session. Otherwise, the current business process has to be terminated, and return to the initial user screen (the main menu) has to be initiated before entering tcode spro). /o tcode saves you the effort of having to do this.

To end the current transaction Enter: /n. Caution: Unsaved changes are lost without warning
To delete the current session. Enter: /i.
To generate a session list Enter: /o. To log off from the system Enter: /nend.
(OSS Note 0026171 has additional information on OKCodes in SAP, and is a very useful read)

Now, since I am on ABAP module, T-Codes related to the module are marked as bold in the following list.



First Steps:
AL08 List of All Users Logged On
RZ20 CCMS Monitor Sets
SA38 ABAP Program Execution
SCC4 Display View “Clients”
SE11 ABAP Dictionary
SE16 Data Browser
SE38 ABAP Editor
SE80 Object Navigator (ABAP Workbench)
SE93 Maintain Transaction
SLICENSE SAP License Administration
SM02 System Messages
SM04 User List
SM12 Select Lock Entries
SM13 Update Requests
SM21 System Log
SM28 SAP Initial Consitency Check
SM31 Maintain Table Views
SM37 Simple Job Selection
SM50 Process Overview
SM51 SAP Servers
SM66 Global Work Process Overview
SMLT Language Management
SR13 Administration of the SAP Library
SU01 User Maintenance

Software Logistics
SAINT Add-On Installation Tool
SE01 Transport Organizer (Extended View)
SE03 Transport Organizer Tools
SE09 Transport Organizer
SPAM Support Package Manager
SPAU Modification Adjustment
SPDD Modification Adjustment Dictionary
SPRO Customizing: Execute Project
SPRO_ADMIN Customizing: Project Administration
STMS Transport Management System

Client Administration
BDLS Tool: Conversion of Logical System Names
SCC1 Copy by Transport Request
SCC3 Client Copy / Transport Log Analysis
SCC4 Display View “Clients”
SCC7 Post-Client Import Methods
SCC8 Client Export
SCC9 Remote Client Copy
SCCL Local Client Copy
SCMP View / Table Comparison
SCU0 Customizing Cross-System Viewer
SE01 Transport Organizer (Extended View)
STMS Transport Management System

User & Authorization
BD82 Generate Partner Profile
LICENSE_ADMIN License Administration Workbench
PFCG Profile Generator / Role Maintenance
SCUG Central User Administration - Transfer Users
SM19 Security Audit: Administer Audit Profile
SM20 Analysis of Security Audit Log
SU01 User Maintenance
SU05 Maintain Internet User
SU10 User Maintenance: Mass Changes
SU20 Maintain Authorization Fields
SU21 Maintain Authorization Objects
SU24 Maintain Assignmt. of Authorization Objects
SU25 Profile Generator: Upgrade / First Install.
SU3 Maintain User Profile
SU53 Display Authorization Data for User
SUCOMP User Company Address Maintenance
SUGR Maintain User Groups
USMM System Measurement

Background Processing
RZ01 Job Scheduling Monitor
RZ04 CCMS: Maintain Operation Modes/Instances
SM36 Define Background Job
SM37 Simple Job Selection
SM37C Extended Job Selection
SM49 External Operating System Commands
SM61 Background Controller List
SM62 Event History
SM64 Background Events
SM65 Analysis Tool - Background Processing
SM69 External Operating System Commands
SMX Job Overview

Update
SM12 Lock Entries
SM13 Update Requests
SM14 Update Program Administration
Output Configuration & Administration
SPAD Spool Administration
SP01 Output Controller: Spool Request Selection
SP12 TemSe - Admin. of Temp. Sequential Data

Data Archiving
AOBJ View Cluster Maintenance
DB15 Tables and Archiving Objects
FILE Logical File Path Definition
OAAD ArchiveLink: Admin. of Stored Documents
OAC0 Content Repositories
OAM1 ArchiveLink: Monitor
SARA Archiv Administration
SARI Archive Info System: Central Management
SF01 Logical File Names, Client-Specific
SM37 Simple Job Selection

Data Transfer & Exchange
BAPI BAPI Explorer
BD73 Error Handlung for Non-Posted IDocs
BD82 Generate Partner Profile
BDM2 IDoc Tracing
BMV0 Manage Data Transfer
IDOC IDoc and EDI Basis: Repair & Check
RZ12 RFC Server Groutp Maintenance
SCOT SAPConnect: Administration
SHDB Transaction Recorder: Recording Overview
SM35 Batch Input: Session Overview
SM58 Transactional RFC
SM59 Configuration of RFC Connections
SMQ1 qRFC Monitor - Outbound Queue
SMQ2 qRFC Monitor - Inbound Queue
SMQR qRFC Monitor - QIN Scheduler
SMT1 Disply and Maintain Trusted Systems
SOST SAPConnect: Transmissen Requests
SXDA Data Transfer Workbench
WE05 IDOC List
WE21 Ports in IDoc Processing

Instance Maintenance
RZ03 Server Statuses and Alerts
RZ04 Maintain Operation Modes and Instances
RZ10 Edit Profiles
RZ11 Maintain Profile Parameters
RZ12 RFC Server Group Maintenance
SM50 Process Overview
SM63 Display/Maintain Operation Mode Set
SMGW Gateway Monitor / Active Connections
SMLG Maintain Logon Groups
SMMS Message Server Monitor

System Monitoring
AL08 List of All Users Logged On
AL11 SAP-Directories
DB13 DBA Cockpit: System Config. Maintenance
DB24 Logs for Adminstrative Database Operations
OS03 Parameter Changes in Operation System
OS07 Operation System Monitor
RZ03 Disply Server Statuses and Alerts
RZ20 CCMS Monitor Sets
SM04 User List
SM12 Select Lock Entries
SM14 Update Program Administration
SM21 System Log: Local Analysis
SM35 Batch Input: Session Overview
SM37 Simple Job Selection
SM50 Process Overview
SM51 SAP Servers
SM58 Transactional
RFCSM66 Global Work Process Overview
SMGW Gateway Monitor / Active Connections
SMICM ICM Monitor
SMMS Message Server Monitor
SMQ1 qRFC Monitor - Outbound Queue
SMQ2 qRFC Monitor - Inbound Queue
SP01 Output Controller: Spool Request Selection
SSAA Administrative Activities
ST01 System Trace
ST02 Tune Summary
ST03, ST03N Workload Monitor
ST04 Maintain Database Integration
ST05 Performance Analysis
ST06 Operation System Monitor
ST07 Application Monitor: User Distribution
ST10 Table Call Statistics
ST11 Error Log Files
ST22 ABAP Runtime Error
ST30 Global Performance Analysis
STAD SAP Workload: Business Transact. Analysis
TU02 Parameter Changes in SAPSYSTEM

Monitoring Architecture
AL15 SAPOSCOL Destination
OS07 Operating System Monitor
RZ04 Maintain Operation Modes and Instances
RZ20 CCMS Monitor Sets
RZ21 Monitoring: Properties and Methods
SE91 Message Maintenance
SE92 System Log Message Maintenance
SM21 System Log: Local Analysis
ST02 Tune Summary

Miscellaneous T-Codes
LSMW Legacy System Migration Workbench
OSS1 SAP Online Service System
SNOTE SAP Note Assistant
SCAT Computer Aided Test Tool
SCU0 Compare Tables
SE18 Business Add-Ins: Definitions
SE19 Business Add-Ins: Implementations
SE24 Class Builder
SE32 ABAP/4 Text Element Maintenance
SE35 ABAP/4 Dialog Modules
SE36 ABAP/4: Logical Databases
SE37 ABAP/4 Function Modules
SE41 Menu Painter
SE43 Maintain Area Menu
SE51 Screen Painter: Initial Screen
SE71 SAPScript Layouts Create/Change
SE72 SAPscript styles
SE73 SAPscript font maintenance (revised)
SE74 SAPscript format conversion
SE75 SAPscript Settings
SE76 SAPscript Translation Layout Sets
SE77 SAPscript Translation Styles
SE93 Maintain Transaction
SHD0 Transaction variant maintenance
SM30 Maintain Table Views
SM35 View Batch Input Sessions
SM37 View background job
SM50 Process Overview
SPRO Start SAP IMG (Implementation Guide)
SQ00 ABAP/4 Query: Start Queries
SQ01 ABAP/4 Query: Maintain Queries
SQ02 ABAP/4 Query: Maintain Funct. Areas
SQ03 ABAP/4 Query: Maintain User Groups
SQ07 ABAP/4 Query: Language Comparison
OAER Image Upload
SNRO/NRIV Maintain Number Ranges
SE54 Maintain Authorization Groups



Michael Joseph Jackson known as the King of Pop, died this June 25. With his death, gone what we can call as 'Michael Era' of pop.
I still remember my school days where I used to listen a lot of his albums. I started following him pretty late by his HIStory Album, to be precise. After that I got hold of all his previous works listening to great lyrics and wonderful music.
Years havn't passed easily for him. He always remains in contraversies either by his appearance, or eccentric behavior, child abuse or his financial status.




A Brief History

Michael Joseph Jackson (August 29, 1958 – June 25, 2009) was an American recording artist, entertainer and businessman. The seventh child of the Jackson family, he made his debut onto the professional music scene at the age of 11 as a member of The Jackson 5 in 1969, and later began a solo career in 1971 while still a member of the group. Referred to as the "King of Pop" in subsequent years, his 1982 album Thriller remains the world's best-selling record of all time and four of his other solo studio albums are among the world's best-selling records: Off the Wall (1979), Bad (1987), Dangerous (1991) and HIStory (1995).


In the early 1980s, he became a dominant figure in popular music and the first African American entertainer to amass a strong crossoverfollowing on MTV. The popularity of his music videos airing on MTV, such as "Beat It", "Billie Jean" and "Thriller"—widely credited with transforming the music video from a promotional tool into an art form—helped bring the relatively new channel to fame. Videos such as "Black or White" and "Scream" made Jackson an enduring staple on MTV in the 1990s. With stage performances and music videos, Jackson popularized a number of physically complicated dance techniques, such as the robot and the moonwalk. His distinctive musical sound and vocal style influenced many hip hop, pop and contemporary R&B artists.

Jackson donated and raised millions of dollars for beneficial causes through his foundations, charity singles, and support of 39 charities. Other aspects of his personal life, including his often changing appearances and eccentric behavior, generated significant controversy which damaged his public image. Though he was accused of child sexual abuse in 1993, the criminal investigation was closed due to lack of evidence and Jackson was not charged. The singer had experienced health concerns since the early 1990s and conflicting reports regarding the state of his finances since the late 1990s. Jackson married twice and fathered three children, all of which caused further controversy. In 2005, Jackson was tried and acquitted of further sexual abuse allegations and several other charges.

One of the few artists to have been inducted into the Rock and Roll Hall of Fame twice, his other achievements include multiple Guinness World Records—including one for "Most Successful Entertainer of All Time"—13 Grammy Awards, 13 number one singles in his solo career, and the sale of 750 million records worldwide. Jackson's highly publicized personal life, coupled with his successful career, made him a part of popular culture for almost four decades. Michael Jackson died on June 25, 2009, aged 50. The specific cause of death has yet to be determined. Before his death, Jackson had announced a 50-date sell-out This Is It comeback tour, in London, England.






Ten Things for which Michael will always be remembered:

01. AMAZINGLY TALENTED CHILD PERFORMER
02. THRILLER - established him as the King of Pop
03. THE MOONWALK
04. BAD
05. BUBBLES - This chimpanzee was adopted by Jackson from a cancer research clinic in Texas in 1985. This bizarre friendship started to turn the King of Pop into Wacko Jacko.
06. NEVERLAND - Named after the fantasy island inhabited by Peter Pan, Jackson opened the California ranch in 1988. Featuring a zoo and a theme park, the over-the-top estate was at the centre of foreclosure proceedings in 2007.
07. HIS FACE - The mystery of his transformation from a fresh-faced 11-year-old to his unusual appearance in his later years has long been a talking point.
08. EARTH SONG
09. CHILD ABUSE ALLEGATIONS
10. HIS DEATH




RIP Michael...you will be always in our hearts and your music will live forever !



Lets have a bit of Introduction to the Platform I work, i.e. SAP - ABAP .... B-).
It is the programming language on SAP Platform. I won't go into the details of the language this time, Instead provided links at last where interested people can visit for more related information, but sure you can expect more of such posts related to programming and new findings in the language and SAP as a whole.



ABAP (Advanced Business Application Programming, originally Allgemeiner Berichts-Aufbereitungs-Prozessor, German for "general report creation processor") is a very high level programming language created by the German software company SAP.

It is currently positioned, alongside the more recently introduced Java, as the language for programming SAP's Web Application Server, part of its NetWeaver platform for building business applications. Its syntax is somewhat similar to COBOL.


Introduction

ABAP is one of the many application-specific fourth-generation languages (4GLs) first developed in the 1980s. It was originally the report language for SAP R/2, a platform that enabled large corporations to build mainframe business applications for materials management and financial and management accounting.

ABAP used to be an abbreviation of Allgemeiner Berichtsaufbereitungsprozessor, the German meaning of "generic report preparation processor", but was later renamed to Advanced Business Application Programming. ABAP was one of the first languages to include the concept of Logical Databases (LDBs), which provides a high level of abstraction from the basic database level.

The ABAP programming language was originally used by developers to develop theSAP R/3 platform. It was also intended to be used by SAP customers to enhance SAP applications – customers can develop custom reports and interfaces with ABAP programming. The language is fairly easy to learn for programmers but it is not a tool for direct use by non-programmers. Good programming skills, including knowledge of relational database design and preferably also of object-oriented concepts, are required to create ABAP programs.

ABAP remains the language for creating programs for the client-server R/3 system, which SAP first released in 1992. As computer hardware evolved through the 1990s, more and more of SAP's applications and systems were written in ABAP. By 2001, all but the most basic functions were written in ABAP. In 1999, SAP released an object-oriented extension to ABAP called ABAP Objects, along with R/3 release 4.6.

SAP's most recent development platform, NetWeaver, supports both ABAP and Java.





Related Links: