Thursday, October 29, 2009

How to modify any code in Quality or Production without the need for a access key.

How to modify any code in Quality or Production without the need for a access key.
Imagine, you are doing a unit test for a object in QA, suddenly a test case fails and oh! come one you have to change this one line again in development and move it to Quality to test. That will take definetly at least 5 minutes to 30 minutes, depending on how your system is configured. How about changing the code directly in quality and continuing the testing. One little suggestion before we proceed with the tutorial, always use this trick only in quality and not in production or it may create chaos. I work on 4.6c and have not used this trick in all the other sap versions. Please try it and let me know your comments.
When you click on the change button in quality, you will get a screen like this saying 'Error in Object Editing'.
Now, we will work out a way to skip this message and make the change to the code. You will need this handy debugger to start the debugger from a popup.
Drag the debug tool and place it on the above popup. then, Click Continue or Press Enter. This will take you into ABAP Debugger. Click on Call stack button –> double click on Function TRINT_CORR_CHECK.
Now click on Fields button and then set a break point on the line LV_SUBRC = SY-SUBRC ( see image below) after the call to the function module 'TRINT_CORR_CHECK'.
Press F8 and the code will stop on the line 'LV_SUBRC = SY-SUBRC'. Double click on SY-SUBRC and the value must be '12′ now change the value to '0′. Now, press F8 again, this should bring you back to the editor with change mode.
Wait, there is an another step to it. Once you edit the code and make the changes and press activate. The program will again bring you to the same window saying 'Error in Editing Object'.
Now, again drag and drop our little Debug Tool. Then click continue or press enter. This will take you to the ABAP Debugger, well this is a similar code, but it's a different include so you have to carry the steps again. Click on Call stack button –> double click on Function TRINT_CORR_CHECK. Now, you will get a screen like below.
Now, set the break-point at line 'When 0′. Press F8 and now change the value of SY-SUBRC from '12′ to '0′.
Press F8(execute) and now the program will going through a set of break-points set by you. Change the value everytime from '12′ to '0′ and press F8. Finally after three or four execute sy-subrc changes, the program will finally get activate and you will have the new modified code available to execute.
Do you know about the syntax 'INSERT REPORT'. We can also modify the code using it.
 
 
Regards,
Ankur Bhandari
Capgemini Development Lead
Envision Project
+1 847 345 8004
 
 
 

Assign a role to a USER

Using the following function module you can assign a role to a user in DEV and Quality environment since you would have access to SE37.
ISAI_USER_ROLES_MAINTAIN Assign Role to User
 
 
 
Regards,
Ankur Bhandari
Capgemini Development Lead
Envision Project
+1 847 345 8004
 
 
 

Program to change SAP source code without Key

Program to change SAP source code without Key
 
  • RS_REPAIR_SOURCE
 
 
 

Report Program to find which transaction was used by which User in the past month.

REPORT YBAS_CHECK_TRANS_USE NO STANDARD PAGE HEADING LINE-SIZE 255.
*----------------------------------------------------------------------
*
* THIS CODE IS TO BE CHANGED ONLY ON DEV ECC !!
*----------------------------------------------------------------------
*
* PROGRAM INFORMATION
*----------------------------------------------------------------------
*
* DESCRIPTION   : Collect transaction usage info.
*
* NOTES         : Collects the usage of a transaction code for a period.
*
* APPLICATION   : BC
*
* RESTART       : Anytime
*
*----------------------------------------------------------------------
*
* MODIFICATION LOG
*----------------------------------------------------------------------
\
tables: usr21, adrp.

DATABEGIN OF SERVLIST OCCURS 25.
        
INCLUDE STRUCTURE MSXXLIST.
DATAEND OF SERVLIST.
DATABEGIN OF i_APPLICATION_STATISTIC OCCURS 5000.
        
INCLUDE STRUCTURE SAPWLUSTCX.
DATAEND OF i_APPLICATION_STATISTIC.

DATABEGIN OF I_trans_user OCCURS 100,
        entry_id  
like I_APPLICATION_STATISTIC-entry_id,
        account    
like usr21-bname.
DATAEND OF I_trans_user.

DATA: COLLECT_TIME LIKE SY-UZEIT.
DATA: COLLECT_DATE LIKE SY-DATUM.
DATA: CLEANUP_DATE LIKE SY-DATUM.

DATA: INSTANCE LIKE SAPWLSERV-NAME.
DATA: i_RECORD_COUNT(9).
DATA: i_RECORD_PROCESSED(9).
DATA: i_temp(80).
data: P_period(1).

PARAMETER: P_trans LIKE I_APPLICATION_STATISTIC-entry_id,
           P_sdate 
like sy-datum default SY-DATUM,
           P_day 
radiobutton group per,
           P_mon 
radiobutton group per default 'X',
           P_wk 
radiobutton group per.

START-
OF-SELECTION.

  
TRANSLATE P_trans TO UPPER CASE.
  COLLECT_DATE = SY-DATUM.
  COLLECT_TIME = SY-UZEIT.

if P_day = 'X'.
   P_period = 
'D'.
else.
   
if P_mon = 'X'.
      P_period = 
'M'.
   
else.
      P_period = 
'W'.
   
endif.
endif.

  
PERFORM GET_SERVER_LIST.
  
LOOP AT SERVLIST.
    
CLEAR INSTANCE.
    INSTANCE = SERVLIST-NAME.
    
PERFORM GET_TRANS_STATS.
    i_RECORD_COUNT = 
0.
    i_RECORD_PROCESSED = 
0.
    
LOOP AT i_APPLICATION_STATISTIC.
      
clear I_trans_user.
*      i_RECORD_COUNT = i_RECORD_COUNT + 1.
      if i_APPLICATION_STATISTIC-entry_id(20eq P_trans(20).
        I_trans_user-entry_id = i_APPLICATION_STATISTIC-entry_id(
20).
        I_trans_user-account = i_APPLICATION_STATISTIC-account.
        
append I_trans_user.
        i_RECORD_PROCESSED = i_RECORD_PROCESSED + 
1.
      
ENDIF.
    
ENDLOOP.
  
ENDLOOP.

  
write:/ 'Report YBAS_CHECK_TRANS_USE Rundate:', COLLECT_DATE, 'Runtime:',COLLECT_TIME.
  
write:/ 'Transaction: '14 P_trans, 24 'was executed by user(s):'.
  
uline.
  
loop at I_trans_user.
    
select * from usr21 where bname = I_trans_user-account.
      
if sy-subrc = 0.
        
select * from adrp where persnumber = usr21-persnumber.
          
if sy-subrc = 0.
          
clear i_temp.
          
concatenate adrp-name_first adrp-name_last into i_temp separated by ' '.
          
write:/ I_trans_user-account, ' - ', i_temp.
          
else.
            
write:/ I_trans_user-account, ' name not found.'.
          
endif.
          
endselect.
        
else.
          
write:/ I_trans_user-account, ' name not found.'.
        
endif.
        
endselect.
      
endloop.
      
uline.
      
write:/ 'Total users that executed this transaction:', i_RECORD_PROCESSED.

END-OF-SELECTION.
*
FORM GET_TRANS_STATS.

  
CALL FUNCTION 'SAPWL_WORKLOAD_GET_STATISTIC'
    EXPORTING
      PERIODTYPE                 = P_period
      HOSTID                     = 
' '
      STARTDATE                  = P_sDATE
      ONLY_APPLICATION_STATISTIC = 
'X'
      INSTANCE                   = INSTANCE
    
TABLES
      APPLICATION_STATISTIC      = i_APPLICATION_STATISTIC
    
EXCEPTIONS
      UNKNOWN_PERIODTYPE         = 1
      NO_DATA_FOUND              = 2
      NO_SERVER_GIVEN            = 3
      OTHERS                     = 4.

ENDFORM.                    "GET_TRANS_STATS

*&---------------------------------------------------------------------*
*&      Form  GET_SERVER_LIST
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM GET_SERVER_LIST.

  
CALL FUNCTION 'TH_SERVER_LIST'
    TABLES
      LIST = SERVLIST.

ENDFORM.        .                    "GET_SERVER_LIST
 
 
 
Ankur
 
 

Run T-Code in SAP without authority

Using Function Modules
  • ALINK_CALL_TRANSACTION
 
  • C160_TRANSACTION_CALL
 
AND ALSO USING PROGRAM
 
  • RSDEMO04
 
 
 

Thursday, October 22, 2009

Find the BADI in a different way.

Find the BADI in a different way.
  1. Enter SE37, display Function Module - SXV_GET_CLIF_BY_NAME.
  2. Set a BREAKPOINT in call function SXV_ADD_PREFIX .
  3. In another SESSION run the transaction, parameter 'name' gives the BADI; parameter 'clif ' gives implementation, e.g. for TCode MIGO name = MB_MIGO_BADI, clif = CL_EX_MB_MIGO_BADI .


Code
FUNCTION sxv_get_clif_by_name .
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"  IMPORTING
*"     VALUE(NAME)
*"     VALUE(PREFIX) TYPE  SEEX_CLIF_PREFIX
*"  EXPORTING
*"     VALUE(CLIF) TYPE  SEOCLSNAME
*"----------------------------------------------------------------------
  CALL FUNCTION 'SXV_ADD_PREFIX'
       EXPORTING
            name     = name
            prefix   = prefix
       IMPORTING
            new_name = clif.
ENDFUNCTION.
 
 

Thursday, October 01, 2009

Workflow Container.

RSWF_CNT_EDIT: Can be used to edit container values of the workflow.
 
Regards,
Ankur Bhandari
Capgemini Development Lead
Envision Project
+1 847 345 8004