Subtract the comment lines from an ABAP source for documentation purposes

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.

Speed up a program by pausing all the other work processes

REPORT ZHGUPALL NO STANDARD PAGE HEADING.
************************************************************************
* This is a test program to measure - how much faster a program can
* process it's job if all the other workprocesses are halted.
* The program identifies the dialog and batch workprocesses that are
* running other abaps and sends them a UNIX 24 (halt) signal.
* When it has finished the job, it releases the other workprocesses
* by sending them a signal 26. This method can be hazardous too.
* One such situation can be a deadlock, when the program requires a 
* resource, that is locked by an abap that has been paused.
************************************************************************
PARAMETERS: SELFISH.
TABLES: TRDIR.
DATA: T1 TYPE I,
      T2 TYPE I,
      STRING(20) VALUE 'load',
      LOCK(30) VALUE 'kill -24',
      ULOCK(30) VALUE 'kill -26',
      OPCODE TYPE X VALUE 2.
DATA: BEGIN OF LIST OCCURS 10.
        INCLUDE STRUCTURE MSXXLIST.
DATA: END OF LIST.
DATA: BEGIN OF WPLIST OCCURS 10.
        INCLUDE STRUCTURE WPINFO.
DATA: END OF WPLIST.
DATA: BEGIN OF TABL OCCURS 0,
      LINE(200),
END OF TABL.
DATA: BEGIN OF ITAB OCCURS 500,
      LINE(72),
END OF ITAB.
*
* Get the list of dialog workprocesses
CALL FUNCTION 'TH_SERVER_LIST'
     TABLES
          LIST = LIST.
READ TABLE LIST WITH KEY HOST = SY-HOST.
CALL FUNCTION 'TH_WPINFO'
     EXPORTING
          SRVNAME = LIST-NAME
     TABLES
          WPLIST  = WPLIST.
*
* Lock all the DIA and BTC but mine
IF SELFISH = 'Y'.
  LOOP AT WPLIST.
    IF WPLIST-WP_TYP = 'DIA' OR WPLIST-WP_TYP = 'BTC'.
      IF WPLIST-WP_BNAME <> SY-UNAME.
        LOCK+11(8) = WPLIST-WP_PID.
        WRITE: / LOCK.
        CALL 'SYSTEM' ID 'COMMAND' FIELD LOCK
        ID 'TAB'     FIELD TABL-*SYS*.
      ENDIF.
    ENDIF.
  ENDLOOP.
ENDIF.
SKIP.
*
* Measure runtime
GET RUN TIME FIELD T1.
*
* This is my processing section VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
SELECT * FROM TRDIR WHERE NAME LIKE 'I%'.
  READ REPORT TRDIR-NAME INTO ITAB.
  LOOP AT ITAB.
    IF ITAB-LINE CS STRING.
      WRITE: / TRDIR-NAME.
      EXIT.
    ENDIF.
  ENDLOOP.
ENDSELECT.
* End of processing ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
************************************************************************
*
* Measure runtime
GET RUN TIME FIELD T2.
T2 = T2 - T1.
SKIP.
WRITE: 'runtime:', T2.
SKIP.
*
* Unock the other guys
IF SELFISH = 'Y'.
  LOOP AT WPLIST.
    IF WPLIST-WP_TYP = 'DIA' OR WPLIST-WP_TYP = 'BTC'.
      IF WPLIST-WP_BNAME <> SY-UNAME.
        ULOCK+11(8) = WPLIST-WP_PID.
        WRITE: / ULOCK.
        CALL 'SYSTEM' ID 'COMMAND' FIELD ULOCK
        ID 'TAB'     FIELD TABL-*SYS*.
      ENDIF.
    ENDIF.
  ENDLOOP.
ENDIF.

System Field SY-DATAR

SAP ECC 6.0 [SAP_BASIS 700]

The goal is to understand whether the user enters something on the screen, so I can do a check for necessity of confirmation message.

System field SY-DATAR (Selection for Screen Field Input) exactly does the same thing. If there is a input by user, SY-DATAR = X.

Dynamic where clauses for selects

Use the following function modules to help build your dynamic where clauses for your select statements….

  • DYNSQL_GENERATE_WHERE_CLAUSE
  • CONVERT_SELECT_INTO_WHERE
  • FREE_SELECTIONS_RANGE_2_WHERE
  • ADSPC_CREATE_WHERE_CLAUSE

Displaying BAPI messages

Use the following code to display the messages returned from a BAPI call….

CALL FUNCTION ’BAPI_SALESORDER_CHANGE’
EXPORTING
salesdocument    = gv_vbeln
order_header_in  = wa_order_header_in
order_header_inx = wa_order_header_inx
TABLES
return           = itab_return
order_item_in    = lt_order_item_in
order_item_inx   = lt_order_item_inx
schedule_lines   = lt_schedule_lines
schedule_linesx  = lt_schedule_linesx.

PERFORM display_messages tables itab_return.


FORM display_messages  tables p_itab_return type BAPIRET2_T.

DATA: ls_msg TYPE bapiret2.

CALL FUNCTION ’MESSAGES_INITIALIZE’.

LOOP AT p_itab_return INTO ls_msg.
CALL FUNCTION ’MESSAGE_STORE’
EXPORTING
arbgb                  = ls_msg-id
msgty                  = ls_msg-type
msgv1                  = ls_msg-message_v1
msgv2                  = ls_msg-message_v2
msgv3                  = ls_msg-message_v3
msgv4                  = ls_msg-message_v4
txtnr                  = ls_msg-number
EXCEPTIONS
message_type_not_valid = 1
not_active             = 2
OTHERS                 = 3.
ENDLOOP.

CALL FUNCTION ’MESSAGES_STOP’
EXCEPTIONS
a_message = 1
e_message = 2
i_message = 3
w_message = 4
OTHERS    = 5.

CALL FUNCTION ’MESSAGES_SHOW’
EXPORTING
show_linno         = ’ ’
EXCEPTIONS
inconsistent_range = 1
no_messages        = 2
OTHERS             = 3.

ENDFORM.                    ” DISPLAY_MESSAGES

SAP BusinessObjects EPM delivers quantifiable benefits – QED

By Richard Barrett, Director of Solution Marketing with SAP

Proven – but not the whole story

Back in May 2010, I was part of the SAP team that worked with Accenture in commissioning Forrester Consulting to examine the total economic impact and potential return on investment (ROI) enterprises may realize by deploying SAP Enterprise Performance Management (EPM) solutions. I must admit I’d forgotten all about it and was pleasantly surprised when the finished study hit my in-box, but I guess setting up global studies and doing the interviews all takes time.

The three core themes that come out of the study are around how finance needs to provide tangible business value; the challenge if keeping up with the increasing demand for finance functions and constant need to embrace technology to keep up with these change. Forrester calls these themes Business Value, Pace and Role of Technology.

Business Value  - Organizations noted three areas of additive value throughout the enterprise beginning within the finance organization and expanding out to specific integration points between Finance and other departments as well as across departments:

  • Process efficiency is a standard objective for all Finance organizations
  • Value beyond process efficiency to measuring functional productivity / business health
  • Aspiration to tie functional and financial performance measures to top level business objectives

Pace – All of the above has to be delivered at the appropriate pace – because the velocity of business is different from company to company and industry to industry. Whereas some organizations depend on information that is virtually real-time, others can make do with periodic reports.

Role of technology – The view of technology benefits was limited to process efficiency with Forrester noting that interviewees had a ‘murky concept’ on how technology could be applied to address strategic business drivers.

In addition to the qualitative interviews with the four multinationals involved in the study, Forrester developed a model to calculate 5 Year Risk Adjusted ROI that incorporated the following:

  • Improved process efficiency – savings within the finance and back-office operations through improved reporting and financial-close efficiency resulting from a reduction in time of key process steps.
  • Improved forecasting from improved visibility -reduced risk of exposure within the budget and forecasting process from greater speed of aggregating data and visibility of changes to information.
  • Improved insight around profitability and cost management. – increased speed and cost in identifying underperforming products and sales channels.
  • Costs – the investment in EPM included the cost of annual license, maintenance, professional support for implementation and strategy, training, and hardware.

Typically breakeven was reached within 24 months with an ROI of 92% and the study goes works through how the ROI was calculated for each solution area – budgeting, cost and profitability reporting etc – which is all good stuff if you’re currently in search of a sound and pragmatic methodology.

However, wisely Forrester restricted their focus to the Finance function so much of the ROI comes from process improvements such as easier and quicker reporting and the commercial benefits of being able to make better business decisions due to quicker and more frequent forecasting or better cost and profitability reports are not included. Perhaps this is just as well as in my experience trying to capture and put a figure on these less tangible – but arguably more important benefits – takes forever and they would still be there today.

Similarly, when they discuss risk, they focus solely on the risks associated with the implementation knowing that attempting to quantify how things such as more frequent forecasting can actually help reduce operational risks that are ultimately reflected in the P&L or more accurate forecasts help reduce reputational risk that is reflected in the stock price. Again – a major task perhaps left to some boffins in a business school with time on their hands.

So overall a sound result – EPM brings tangible benefits. But I still maintain the less tangible benefits are actually more important.

Testing an Inbound Proxy if the test interface is unavailable

If the menu entry test interface is not available, you can use transaction SXI_SUPPORT.

  • Select service selection and check the proxy inbound processing box.
  • In the next screen select your interface and namespace and check XML editor.
  • Upload the payload that you can pull from SXMB_MONI