Archive for the 'Technical' Category

ABAP Debugging a Popup Window

To enter a debugging mode we simply type “/h” in the command field. But do you ever wonder how to enter a debugging mode on a popup window? I mean there is no command field to type in the “/h”.

I stumble upon this really great SDN article about ABAP debugging tips and found out that there is actually 2 ways to debug a popup window.

Option 1: From any SAP windows click the “Generate a Shortcut” button sap_shortcuticon and in the window that appears make the below changes and click “Finish”. A file will be generated on the location you specified. Now drag the file onto the popup window and your ABAP debugger should be switched on!

Make sure to set the Title, Type, Command, and Location.
sap_shortcut

Option 2: Create a text file (any file name will do) anywhere on your computer where you could easily get it, and type the code below and save it:
[codesyntax lang="c++" lines="no" title=""]
[FUNCTION]
Command=/h
Title=Debugger
Type=SystemCommand
[/codesyntax]

Same thing with option 1, you may drag this file onto the popup window to switched on the ABAP debugger.
Enjoy!

Creative Commons License

SAP: Quick Way To Search For Enhancement Points

Enhancement Points allow you to modify standard SAP code, but in a structured way that will allow you to upgrade and deploy enhancement packs without the conflicts of traditional modifications. Enhancement points are basically can be found at certain defined points within the ABAP code. This allow you to add your own custom code which will be executed as if it had been hard coded into the code using a modification. Unlike hard coded modifications, these will not be lost during upgrade or patching exercises.

It is hard to tell which enhancement points are available for the process you want to customize. There’s very little documentation, and it could take an SAP developer several hours to find the best point. But thanks to Panaya team, we can now enjoy ABAPNinja.

ABAPNinja is a free web site that allows us to quickly search for the best enhancement points for our business process. How did they do it? According to their website, deciding which enhancement points impact a given transaction, directly or indirectly, is not an easy feat, to say the least. There are some 13,000 enhancement points, and over 60,000 SAP transactions, which gives over a billion possible combinations. They have have analyzed close to 250 Million lines of ERP 6.0 code, using Panaya’s program comprehension technology, and a grid of 50 servers over a period of one month, to compile this huge database. Then then used Ruby on Rails to format the data as web pages.

Try it out now, go to www.abapninja.org and enjoy searching for enhancement points!
ABAPNinja.org

Where to download MiniSAP

MiniSAP is a trial version or sneak preview of SAP software. It is a downscaled version of SAP system without the SAP applications (FI, CO, MM, SD, HR etc.). This is very helpful to those who are just starting to learn ABAP.

MiniSAP are available via the SAP Developer Network (SDN)
- register yourself.
- go to software download page.
- you will see different trial versions of SAP software with different system requirements.

Below are the links on some of the trial version of SAP you can download:

-SAP NetWeaver AS ABAP 7.02 SP6 32-bit Trial
-SAP NetWeaver 7.01 SR1 SP3 Developer Edition
-SAP NetWeaver 7.01 SR1 SP3 ABAP Trial Version
-SAP NetWeaver 7.01 ABAP Trial Version
-SAP NetWeaver 7.0 - Trial Version on Linux

Once you finished installing a MiniSAP, you have to determine your hardware key to apply for an evaluation license key: You may refer to SAP Sneak Preview License Key Request for a complete instructions.

Creative Commons License

SAPlink

Ever wonder if it is possible to copy or download your ABAP programs, functions, classes, tables, smartforms, etc. and share it to other programmers or use it when you needed it on other SAP systems? Well EnterpriseGeeks created a project called SAPlink which enables us to share abap codes, objects and components.

SAPlink is a project that aims to make it easier to share ABAP developments between programmers. It provides the ability to easily distribute and package custom objects.

Below is the site for the complete instructions on how to install and use SAPlink.
SAPlink User Documentation

Creative Commons License

Step-by-Step Saprouter Certificate Renewal

1. You need to remove the old generated files(certreq, cred_v2, local.pse, srcert) from previous certificate request. To do this you can either rename these files or create a new folder and move these files into it.

2. Login to http://service.sap.com/saprouter-sncadd and click the “Apply now” button. From the list of SAProuters registered to your installation, choose the relevant “Distinguished Name”.

3. Generate the certificate Request. To do this go to your SAProuter server and run this command on the saprouter directory.

sapgenpse get_pse -v -r certreq -p local.pse “<Distinguished Name>”

Example:  sapgenpse get_pse -v -r certreq -p local.pse “CN=example, OU=0000123456, OU=SAProuter, O=SAP, C=DE”

You will be asked twice for a PIN here. Please choose a PIN and document it, you have to enter it identically both times. Then you will have to enter the same PIN every time you want to use this PSE.

4. Display the output file “certreq” and with copy&paste (including the BEGIN and END statement) insert the certificate request into the text area of the same form on the SAP Service Marketplace from which you copied the Distinguished Name.

5. In response you will receive the certificate signed by the CA in the Service Marketplace. Copy&paste the text to a new local file named “srcert”, which must be created in the same directory as the sapgenpse executable.

6. With this in turn you can install the certificate in your saprouter by calling: sapgenpse import_own_cert -c srcert -p local.pse

7. Now you will have to create the credentials for the SAProuter with the same program (if you omit -O <user_for_saprouter>, the credentials are created for the logged in user account).

sapgenpse seclogin -p local.pse -O <user_for _saprouter>

Note: The account of the service user should always be entered in full <domainname><username>

8. This will create a file called “cred_v2″ in the same directory as “local.pse”

9. To check if the certificate has been imported successfully, run the following command: sapgenpse get_my_name -v -n Issuer

The name of the Issuer should be: CN=SAProuter CA, OU=SAProuter, O=SAP, C=DE

Creative Commons License

SAP: BDC Upload Program Template

I recently created my own BDC upload template that enables user to choose the processing mode, the update mode and options for Default Size, Continue After Commit, and Not a Batch Input Session easily.

Another good thing with this program is a functionality to generate an excel file template. The image below shows the actual screenshot.

I modified the SAP standard program BDCRECX1 and saved it as ZBDCRECX1. I used this for my BDC upload program instead of the standard BDCRECX1 include. You may download the source code of ZBDCRECX1 on the link below. I also included a sample upload program utilizing the ZBDCRECX1 include.

zbdc_template.zip

Enjoy coding! :)

SAP: How to activate SAP webgui

Below are the steps on how to activate webgui on SAP ECC 6.0:

1. Go to your Instance Profile parameter using tcode RZ10 and set the icm/server_port_0 parameter to PROT=HTTP,PORT=8000

2. Now go to transaction SICF and activate the following:
/sap/public/bc/its/mimes
/sap/bc/gui/sap/its/webgui

3. Run transaction SIAC_PUBLISH_ALL_INTERNAL to publish internet services.

4. Now browse to http://<servername>:<icmport>/sap/bc/gui/sap/its/webgui/

As simple as that, you can now use SAP webgui.

SAP: Export ALV to Excel File


This tutorial will teach you how to export an ALV report to Microsoft Excel  file. This is intended for abap programmers who already have a knowledge in ALV reporting as I will not show here how to create an ALV.

Assuming you already have an ABAP program with ALV report, what you need to do is add a button or menu that will trigger the function that will export the ALV data to Excel file. but before that let’s start first with the declaration of types and variables that we’re going to use.

[codesyntax lang="abap" lines="no" title="VARIABLE DECLARATION"]
TYPE-POOLS ole2. ” we will use OLE objects
DATA: v_excel TYPE ole2_object, ” Excel object
v_wrkbkl TYPE ole2_object, ” list of workbooks
v_wrkbk TYPE ole2_object, ” workbook
v_cell TYPE ole2_object, ” cell
v_font TYPE ole2_object, ” font
v_row TYPE i. ” row
[/codesyntax]

Now we’re done with the variable declaration, let’s proceed to the main program. We will create 3 forms: One is for the preparation of the Excel file, second is for the data export from alv cells to excel cells, and third is for error handling.

The code below is for the preparation of excel application object.

[codesyntax lang="abap" lines="no" title="EXPORT_TO_EXCEL"]
* it_main and wa_main is the tables used in your ALV
FORM export_to_excel TABLES p_it_main STRUCTURE wa_main.

* Create Excel object
CREATE OBJECT v_excel ‘EXCEL.APPLICATION’.

* Call Error_handler form
PERFORM Error_Handler.

* Show excel window
SET PROPERTY OF v_excel ‘Visible’ = 1.

* get list of workbooks, initially empty
CALL METHOD OF v_excel ‘Workbooks’ = v_wrkbkl.
PERFORM Error_Handler.

* add a new workbook to workbook list
CALL METHOD OF v_wrkbkl ‘Add’ = v_wrkbk.
PERFORM Error_Handler.

* export ALV column header to Excel
* PERFORM export_data USING rows columns boldfont value
PERFORM export_data USING 1 1 1 ‘header_1'.
PERFORM export_data USING 1 2 1 ‘header_2'.
PERFORM export_data USING 1 3 1 ‘header_3'.
PERFORM export_data USING 1 4 1 ‘header_4'.
PERFORM export_data USING 1 5 1 ‘header_5'.

* Loop through ALV rows and fields and transfer data to Excel
LOOP AT p_it_main INTO wa_main.
v_row = sy-tabix + 1.
PERFORM export_data USING v_row 1 0 wa_bill-field1.
PERFORM export_data USING v_row 2 0 wa_bill-field2.
PERFORM export_data USING v_row 3 0 wa_bill-field3.
PERFORM export_data USING v_row 4 0 wa_bill-field4.
PERFORM export_data USING v_row 5 0 wa_bill-field5.
ENDLOOP.
FREE OBJECT v_excel.
PERFORM error_handler.
ENDFORM.
[/codesyntax]

The next code is for the export_data form.

[codesyntax lang="abap" lines="no" title="EXPORT_DATA"]
FORM export_data USING x y z val.
CALL METHOD OF v_excel ‘Cells’ = v_cell
exporting
#1 = x
#2 = y.
PERFORM error_handler.

SET PROPERTY OF v_cell ‘Value’ = val.
PERFORM error_handler.

GET PROPERTY OF v_cell ‘Font’ = v_font.
PERFORM error_handler.

SET PROPERTY OF v_font ‘Bold’ = z .
PERFORM error_handler.
ENDFORM.
[/codesyntax]

And for the code of error_handler form.

[codesyntax lang="abap" lines="no" title="ERROR_HANDLER"]
FORM error_handler.
IF sy-subrc <> 0.
CALL METHOD OF v_excel ‘QUIT'.
FREE OBJECT v_excel.
v_excel-handle = -1.
MESSAGE: ‘Failed to export to Excel.’ TYPE ‘E'.
ENDIF.
ENDFORM.
[/codesyntax]

Now that we’ve completed all the 3 forms, all you have to do now is call the export_to_excel form to initiate the export. In the example below, I call the export_to_excel form on user command ‘M_EXP’.

[codesyntax lang="abap" lines="no" title="USER_COMMAND"]
FORM f_user_command USING p_ucomm LIKE sy-ucomm.
CASE p_ucomm.
WHEN ‘M_EXP'.
PERFORM export_to_excel TABLES it_main.
WHEN ‘CANCEL’ OR ‘BACK’ OR ‘EXIT'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDFORM.
[/codesyntax]

Creative Commons License

SAP: table JEST (Individual Object Status)

JEST table contains object status that is either system status or a user status. Field STAT corresponds to the Object Status. Field INACT identifies whether the status is currently active or inactive and field CHGNR is the change number that identifies the change documents for an object and is incremented serially.

TJ02 table contains the list of system status and description. All statuses in this table are internal. This means they are consistent across objects and clients. A single object can have multiple active system statuses and user statuses & inactive ones.

TJ30 table contains the list of user status and TJ30T contains their description.

You could use function module STATUS_READ read active object status and STATUS_OBJECT_READ to retrieve the status profile of an object number.

Creative Commons License

SAP: Customized Tcode for View Maintenance Screen

Instead of going to transaction code SM30 to maintain your table, why not create your own t-code for that specific table maintenance screen. To do this, here’s the step by step procedure I stumbled upon on some SAP technical forums:

1. Go to t-code SE93.
2. Type in your customized t-code on the transaction code field.
3. Click on Create button.
4. Give it a short description and tick on the “Transaction with Parameters” radio button.
2. On the next screen, type “SM30″ in the transaction field.
3. Check mark the skip initial screen.
4. type “0″ on screen field
5. Under the Classification area, check mark on Inherit GUI attributes
6. Tick all GUI support checkboxes.
7. On the default value section, give this:

Name of Screen Field: VIEWNAME
Value: Your table name

Name of Screen Field: UPDATE
Value: X X

Creative Commons License