Showing posts with label ABAP General. Show all posts
Showing posts with label ABAP General. Show all posts

Sunday, August 1, 2010

Few SAP tips

Joyjit Ghosh, Kolkata

1. Maintain single table entry at a time without coding or debugging

Steps:

  • Go to SE16 transaction
  • Give any table name and press Enter , Ex: MARA
  • Now execute (F8) this screen
  • Choose the record you want to manipulate and display (F7)
  • Go to Debug mode (/H) and press ‘Enter’ 2 times
  • Change the value of the variable ‘CODE’. By default, it is 'SHOW'
  • Change the code value as 'EDIT' for modifications, 'INSR' for insert and 'DELE' for delete.

2. Maintain multiple table entries at a time without coding or debugging

Steps:

  • Goto transaction SE16N
  • Give the table name
  • In command box write ‘&sap_edit’ then press ‘Enter’
  • Press execute button

3. Debugging background job

Steps:

  • Goto transaction SM37
  • Select any job that you want to debug
  • Enter 'jdbg' as okcode in command box
  • Press ‘Enter’

Note: You can do the same from transaction SM50 as well

4. Environmental analysis of a program

Steps:

  • Goto Transaction SE38 and key in the program name for which you want to Environmental analysis
  • Press ‘SHIFT+F4’. 'Environment Analysis' pop-up-window opens.
  • Check the required information and press ‘Enter’

Aslo check the programs RSINCL00, RSDEPEND.

5. Start debugging from a popup window

Alernative 1:

Steps:

  • Create a short cut for any transaction from the SAPGUI.
  • Change transaction type to ‘system command’.
  • Enter command as ‘/h’
  • Save this on the desktop.
  • On any screen just drag and drop this shortcut
  • You are all set to debug now

Alternative 2 :

Steps:

  • Create a text file with following commands

*********************

[FUNCTION]

Command=/H

Title=Debugger

Type=SystemCommand

*********************

  • On any screen just drag and drop this shortcut
  • You are all set to debug now

6. Retrieving the deleted program

Steps:

  • Create a program with the same name as earlier (which is deleted)
  • Click on "Utilities" --> "Versions" --> "Version Management"
  • Select the version of your earlier program and click on display.
  • Your earlier program is displayed here.

7. Sending message to other user from SAP

Steps:

  • Go to transaction SE37
  • Execute the FM ‘TH_POPUP’ by mentioning the client , user name and the message text

8. Display icon in selection screen

Steps:

  • Find the hex code of the icon. Hex codes of all the icons are available in type-pool ‘ICON’ or available through the program ‘’ .
  • Now you have to create text-elements using that hex codes.

Ex: @6A@ Click

Thursday, May 21, 2009

How to add new fields in dynamic selection screen

Joyjit Ghosh, Kolkata.

Most of us observe that whenever a logical database is attached with a report, it automatically adds dynamic selection screen button on the report selection screen.

Ex: Transaction FBL1N



If we click on this button, it will open up a separate selection screen that can be dynamically adjusted based on the fields you choose from the left hand side folders (Function groups).

Now our requirement is to add new field in the left hand side folder (as well as in the selection screen) that is not present currently.

1st we need to know the name of the logical database that is attached with the program.

In case of FBL1N, program name is RFITEMAP.

Go to the program’s attribute screen to know the logical database name. In our case it is KDF.

Now go to transaction SE36 and choose the menu Extras → Selection Views.

In the next screen, select Origin of view: SAP and Name of view: STANDARD, and click Display button.

This is the view that SAP uses to generate the dynamic selection screen.

Here three functional groups of fields those are available in the dynamic selections.

01 Vendor Master

02 Company code

03 Document

Each functional group contains fields from the tables that are listed on the right side (LFA1, ADDR1_VAL, etc). The field which is assigned to a functional group will be available in left hand side of the dynamic selection screen under the folder with name of the function group. Notice that for every field assigned to a functional group, there is a “Preselect” checkbox on the right. This checkbox indicates whether the relevant field should be directly available for selection.

As we want to extend the SAP-delivered dynamic selections with new fields, so we must create our own selection view. This view will have CUS as the Origin, and must be named STANDARD. To create such a view, simply use the Copy button on the top of the screen, and copy the SAP delivered view to a CUS view.

Once the customer-defined view is created then go to change mode and add new fields in the functional group.

In this case we have added the field NAME1 in functional group Vendor master (01).

Now save the view , go back to the transaction and open the dynamic selection screen. You can see the new field NAME1 is added in it.

How it works?

When a selection view with origin CUS (customer) and name STANDARD exists, and is assigned to a logical database, then this view takes precedence over the SAP-defined view. When such a view does not exist for a particular logical database, then the selection view SAP – STANDARD is used to

Monday, May 18, 2009

Scheduling background jobs by triggering events

By Joyjit Ghosh

Step1: Create event from transaction SM62.

Give event name and description and press save button

Step2: Create a program that triggers this event by calling the FM ‘BP_EVENT_RAISE’.

*&---------------------------------------------------------------------*
*& Report Z_TRIGGER_EVENT *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT  Z_TRIGGER_EVENT                         .
CALL FUNCTION 'BP_EVENT_RAISE'
EXPORTING
eventid = 'Z_TRIGGER_JOB'
EXCEPTIONS
BAD_EVENTID = 1
EVENTID_DOES_NOT_EXIST = 2
EVENTID_MISSING = 3
RAISE_FAILED = 4
OTHERS = 5
.
IF sy-subrc <> 0.
Write: 'Event failed to trigger'.
else.
Write: 'Event triggered'.
ENDIF.

Step3: Configure the background job from transaction SM36.

In the initial screen give job name and job class and press “Start condition” button.

In the popup screen press “After event” button and give the event name and then press save button.

Now go back to the initial screen and press “Step” button

Provide program and variant name and after providing all the values press save button.

In the initial screen press save button.

Step4: Now execute the program to trigger the event and as well check the background job.

Run transaction SM37

Check the status of job defined above

Now check the spool to see the generated list

Create Dynamic Patterns

By Joyjit Ghosh

Step1
. Create a pattern with only one line that contains *$&$EXIT.

Put this above expression and press save button.

Step2. Now from CMOD create a project and include enhancement SEUED001 in it.

Now select the user exit EXIT_SAPLLOCAL_EDT1_001 and create the include program in it.

Now insert the following code block in the include program and activate it.

*&---------------------------------------------------------------------*
*& Include ZXSEUU26 *
*&---------------------------------------------------------------------*
DATA: w_buffer TYPE string.
CASE keyword.
  WHEN 'DYNAMIC_PATTERN'.
    w_buffer =
'*********************************************************************'.
APPEND w_buffer TO buffer.
w_buffer = '*& Program :'.
APPEND w_buffer TO buffer.
w_buffer = '*& Module :'.
APPEND w_buffer TO buffer.
w_buffer = '*& Sub-Module :'.
APPEND w_buffer TO buffer.
w_buffer = '*& Functional Contact:'.
APPEND w_buffer TO buffer.
w_buffer = '*& Funct. Spec. Ref. :'.
APPEND w_buffer TO buffer.
w_buffer = '*& Developer(Company):'.
APPEND w_buffer TO buffer.
w_buffer = '*& Create Date :'.
APPEND w_buffer TO buffer.
w_buffer = '*& Program Type :'.
APPEND w_buffer TO buffer.
w_buffer = '*& Project Phase :'.
APPEND w_buffer TO buffer.
w_buffer = '*& Description :'.
APPEND w_buffer TO buffer.
w_buffer =
'*********************************************************************'.
APPEND w_buffer TO buffer.
  WHEN OTHERS.
* Do nothing
ENDCASE.

Lastly activate the project



Step3. Insert this newly created pattern in a program and test whether it is displaying the dynamic pattern or not.

SAP code to call the user-exit.

User-exit call

Dynamic pattern



Wednesday, February 11, 2009

Find transaction for table maintenance generator

By Joyjit Ghosh,
Kolkata
, India
.

Sometime we only know that a table has a table maintenance generator but does not have any idea whether any transaction is attached with it or not. To find that go to table TSTCP and in the selection screen against PARAM field give the following string:

*SM30 VIEWNAME=@Table in question@*

Here replace

@Table in question@ by actual table name.

For example if we are searching transaction for table T001CM then resultant string would be:

*SM30 VIEWNAME=T001CM*



Now press execute button, if any transaction is available then it will show the transaction name.

In our case it is “OBZK”.

Note: if you donot find the transaction by using above string then use the table name in lower case (t001cm)in the string and try to search again.

Ex: *SM30 VIEWNAME=t001cm*

Saturday, November 22, 2008

Problem with system refresh

By Joyjit Ghosh,
Kolkata, India.

Problem :

In few cases I have seen that after system refresh custom codes developed in the original system are not editable. This problem mainly happens in a landscape which contains two parallel paths one dedicated to development and another one for maintaining the old code. After a certain point in development cycle it is important to make the 2 paths in sync with each other and that’s why we have to refresh one system by the other. And after this refresh this problem may arise.

Solution:

From the above message you can get a hint and based on it you can check the original system name of this program from the menu path (Goto à Object directory) shown below





In this case original system name is different than the current system (BSP) name. This is happened because of system refresh. As code is refreshed from BT1 to BSP; due to this original system name is also changed to BT1 from BSP. And now SAP is considering BT1 as the original system that’s why it is showing this above message and not permitting to edit the program directly.

So to avoid this problem we need to manually change the original system from BT1 to BSP.

Go to transaction SE03. Set the first check box and give the program name to its corresponding text box and press execute button.



In the next screen select program entry and press the change object directory button.



In the next popup screen change the original system and press save button.


You will get the following message:



Now you can edit the program without any problem

Thursday, September 25, 2008

Go to any page of a list directly form selection screen

By Joyjit Ghosh,
Kolkata, India.


Code:

*&---------------------------------------------------------------------*

*& Report Z_DEMO_JG

*&

*&---------------------------------------------------------------------*

*& Go to any page of a list directly form selection screen

*&---------------------------------------------------------------------*

REPORT z_demo_jg LINE-SIZE 80 LINE-COUNT 50

NO STANDARD PAGE HEADING.

TABLES: sflight.

* Type declaration

TYPES : BEGIN OF ty_flight,

carrid(19) TYPE c,

connid(18) TYPE c,

fldate LIKE sflight-fldate,

fldate1(14) TYPE c,

planetype(13) TYPE c,

END OF ty_flight.

* Data declaration

DATA: i_flight TYPE STANDARD TABLE OF ty_flight,

w_flight TYPE ty_flight.

DATA: field(50) TYPE c.

DATA: part1(30) TYPE c,

part2(30) TYPE c.

DATA: l_counter TYPE i.

* Selection screen

SELECT-OPTIONS: s_carrid FOR sflight-carrid.

PARAMETERS: p_page TYPE int3.

START-OF-SELECTION.

* Fetch data from sflight table

SELECT carrid

connid

fldate

planetype

FROM sflight

INTO CORRESPONDING FIELDS OF TABLE i_flight

WHERE carrid IN s_carrid.

CHECK sy-subrc = 0.


* Display final data

PERFORM display_data.

TOP-OF-PAGE.

* Display report header

PERFORM display_column_name.

*&---------------------------------------------------------------------*

*& Form display_column_name

*&---------------------------------------------------------------------*

* Display column header

*----------------------------------------------------------------------*

* None

*----------------------------------------------------------------------*

FORM display_column_name .


WRITE: /10 'Program name:', sy-repid.

WRITE: /10 'Page no:', sy-pagno.

* Store report header texts

w_flight-carrid = 'Airline Code'(001).

w_flight-connid = 'Flight Connection'(002).

w_flight-fldate1 = 'Flight date'(003).

w_flight-planetype = 'Aircraft Type'(004).

* Display report header

SKIP.

ULINE.

FORMAT INTENSIFIED ON COLOR 1.

WRITE: 1 sy-vline,

2 w_flight-carrid,

21 sy-vline,

22 w_flight-connid,

40 sy-vline,

41 w_flight-fldate1,

55 sy-vline,

56 w_flight-planetype,

80 sy-vline.

ULINE.

ENDFORM. " display_column_name

*&---------------------------------------------------------------------*

*& Form display_data

*&---------------------------------------------------------------------*

* Display flight data

*----------------------------------------------------------------------*

* None

*----------------------------------------------------------------------*

FORM display_data .

CLEAR w_flight.

* Display report final data

LOOP AT i_flight INTO w_flight.

w_flight-fldate1 = w_flight-fldate.

FORMAT INTENSIFIED ON COLOR 2.

WRITE: 1 sy-vline,

2 w_flight-carrid,

21 sy-vline,

22 w_flight-connid,

40 sy-vline,

41 w_flight-fldate1,

55 sy-vline,

56 w_flight-planetype,

80 sy-vline.

ULINE.

ENDLOOP.

IF p_page IS NOT INITIAL.

* Check whether any page exist with the number entered

* in the selection screen

READ LINE 1 OF PAGE p_page.

IF sy-subrc = 0.

* If exist then scroll down to that page

SCROLL LIST TO PAGE p_page LINE 1 .

ELSE.

* Otherwise display information message and continue

* processing

MESSAGE i000(z_zzz_ca_messages)

WITH 'Page number does not exist'(001).

ENDIF.

ENDIF.

ENDFORM. " display_data

Screen shots:

Input:

Output:

Input:



Output: