Wednesday, August 31, 2011

Do you need to execute a transaction you are not authorized for?

You need to execute a transaction for which you don't have authorization. You need to test something urgentely and you can wait to be authorized. What can you do?

You can set a breakpoint in function module AUTH_CHECK_TCODE, change the value of a variable when the breakpoint is reached and go on! Let see with an example:

I am not authorized for transaction MB11:


Go to SE37 and display the code of function module AUTH_CHECK_TCODE and set a breakpoint here:

  call 'AUTH_CHECK_TCODE'
       id 'TCODE' field tcode.

  if sy-subrc = 0. <--Set your breakpoint in this line*   auth_check_tcode enthält die Prüfungen von tcode_executable,
*   daher im OK-Fall keine Aufruf nötig.
  else.
    perform tcode_executable using tcode.
*   Keine Berechtigung für Transaktion &
    message i077(s#) with tcode raising not_authorized.
  endif.

This is a system function module, so execution won't stop at one breakpoint on it if you don't have System Debug activated. To activate System Debug: System --> Utilities --> Debug System

Once activated, we execute MB11 and the debugger is started:

Press F8 to continue until breakpoint is reached. When it is reached
double click over sy-subrc to be able to change its value from 4 to 0:

Change sy-subrc field content from 4 to 0, press the button with the pencil:
and F8 to continue with the execution and... 

Great! MB11 transaction's initial screen is showed:

  

Monday, August 29, 2011

How to create an incoming IDOC from ABAP program...

If you need to create an incoming IDOC by code in ABAP program, you can use the following function module: IDOC_INBOUND_SINGLE.

You will have to provide IDOC's Control Record information (parameter PI_IDOC_CONTROL_REC_40: structure parameter of type EDI_DC40) and the content of the IDOC you want to create (parameter PT_IDOC_DATA_RECORDS_40: table parameter with records of type EDI_DD40).