SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Subtract the comment lines from ABAP source



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP Dictionary
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Sat Nov 17, 2007 10:13 pm    Post subject: Subtract the comment lines from ABAP source Reply with quote

Subtract the comment lines from an abap source for documentation purposes

Code:
REPORT ZCOMMENT.
************************************************************************
* This program subtracts the comment lines from a program source.
* To get the line numbers right, run pp before the subtraction.
* It can be useful to document abap developments
************************************************************************
PARAMETERS: PROGRAM LIKE SY-REPID DEFAULT SY-REPID.
DATA :  BEGIN OF SOURCE OCCURS 1000,
     LINE(72),
END OF SOURCE.
DATA: I TYPE I, J TYPE I, K TYPE I, L TYPE I, LNUM(6) TYPE N.
DATA: EMPTY(72) VALUE
'
 '.                                    "Some ugly long line
DATA: P_STATEMENTS LIKE SSTMNT OCCURS 100 WITH HEADER LINE.
DATA: P_TOKENS LIKE STOKEN OCCURS 100 WITH HEADER LINE.
*
READ REPORT PROGRAM INTO SOURCE.
SCAN ABAP-SOURCE SOURCE STATEMENTS INTO P_STATEMENTS  "Comment in chain
                        TOKENS       INTO P_TOKENS.
*
* Remove the statement closing characters
LOOP AT P_STATEMENTS.
  IF P_STATEMENTS-TROW <> 0.
    READ TABLE SOURCE INDEX P_STATEMENTS-TROW.
    SOURCE+P_STATEMENTS-TCOL(1) = ' '.
    MODIFY SOURCE INDEX P_STATEMENTS-TROW.
  ENDIF.
ENDLOOP.
*
* Remove the tokens
LOOP AT P_TOKENS.
  I = P_TOKENS-ROW.
  J = P_TOKENS-COL.
  K = P_TOKENS-LEN - 1.
  L = J + K.
  DO.
    READ TABLE SOURCE INDEX I.
    IF L > 72.                         "Multi line token
      L = L - 72.
      SOURCE+J(72) = EMPTY.
      MODIFY SOURCE INDEX I.
      I = I + 1.
      K = L. J = 0.
    ELSE.
      IF L < 72.
        K = K + 1.
      ENDIF.
      SOURCE+J(K) = EMPTY.
      MODIFY SOURCE INDEX I.
      EXIT.
    ENDIF.
  ENDDO.
ENDLOOP.
*
* Remove ':' (chain statements)
LOOP AT SOURCE.
  CONDENSE SOURCE NO-GAPS.
  IF SOURCE(1) = ':'.
    DELETE SOURCE.
  ENDIF.
ENDLOOP.
*
* Print the result
FORMAT INPUT ON.
LOOP AT SOURCE.
  LNUM = LNUM + 10.
  IF NOT SOURCE IS INITIAL.
    FORMAT INTENSIFIED OFF.FORMAT INVERSE OFF.
    TRANSLATE LNUM USING ' 0'.
    WRITE /(6) LNUM COLOR 2.
    IF SOURCE(1) = '*'.
      FORMAT INTENSIFIED ON.
      WRITE 8 SOURCE COLOR 6.
      FORMAT INTENSIFIED OFF.
    ELSE.
      WRITE 8 SOURCE COLOR 2.
    ENDIF.
  ENDIF.
ENDLOOP.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP Dictionary All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.