Wednesday, August 8, 2007

What is the difference between a BAPI,Idoc and an RFC?

What is the difference between a BAPI and an RFC?
BAPI stands for Business Application Programming Interface. It is a library of functions that are released to the public as an interface into an existing SAP system from an external system.
RFC is the protocol used to call functions in an R/3 system by a caller external to R/3 or to call programs external to R/3 from an R/3 system.
Functions can only be called via RFC, if they are tagged as RFC functions in the SAP development workbench. They are then called RFC function modules. BAPIs are complete sets of (BAPI) function modules that model a business application.When you are familiar with web developments: RFC can be compared to HTTP and BAPIs are CGI applications.
In other words: A BAPI function is a function module that can be called remotely using the RFC technology.
BAPIs, RFCs and IDOCs are often confused. This section will help you to understand how RFCs relate to BAPIs.
BAPI is a business object. An RFC is functional code. IDOCs OR intermediate documents are standard data structures for electronic data interchange (EDI) between application programs. IDocs are used for asynchronous transactions: each IDoc generated exists as a self-contained text file that can then be transmitted to the requesting workstation without connecting to the central database.
IDoc
IDoc (for intermediate document) is a standard data structure for electronic data interchange (EDI) between application programs written for the popular SAP business system or between an SAP application and an external program. IDocs serve as the vehicle for data transfer in SAP's Application Link Enabling (ALE) system. IDocs are used for asynchronous transactions: each IDoc generated exists as a self-contained text file that can then be transmitted to the requesting workstation without connecting to the central database. Another SAP mechanism, the Business Application Programming Interface (BAPI) is used for synchronous transactions.
A large enterprise's networked computing environment is likely to connect many geographically distributed computers to the main database. These computers are likely to use different hardware and/or operating system platforms. An IDoc encapsulates data so that it can be exchanged between different systems without conversion from one format to another.
IDoc types define different categories of data, such as purchase orders or invoices, which may then be broken down into more specific categories called message types. Greater specificity means that an IDoc type is capable of storing only the data required for a particular transaction, which increases efficiency and decreases resource demands.
An IDoc can be generated at any point in a transaction process. For example, during a shipping transaction process, an IDoc may be generated that includes the data fields required to print a shipping manifest. After a user performs an SAP transaction, one or more IDocs are generated in the sending database and passed to the ALE communication layer. The communication layer performs a Remote Function Call (RFC), using the port definition and RFC destination specified by the customer model. The IDoc is transmitted to the receiver, which may be an R/3, R/2, or some external system.
Remote Function Call
RFC is also an abbreviation for Request for Comments.
A Remote Function Call (RFC) is an application program interface to R/3 applications from SAP, the German company that sells a coordinated set of applications and databases to Fortune 1000 companies. SAP customers who wish to write other applications that communicate with R/3 applications and databases can use the RFC interface to do so.

Thursday, August 2, 2007

How to find a Badi for a program or TCODE


First go to any transaction->iN THE menu bar SYSTEM->STATUS->Get the program name ->double click->u will go to the program attached to the tcode. Now search term will be CALL CL_EXITHANDLER. Now u will get list of BADI'S available..
Goto SE24->Give class name as CL_EXITHANDLER->Display->double click on get_instance mathod->Now u will go inside the method->Now put break point on the cl_exithandler. Now go to any transaction code and pass dat..U will see that it will be stopped on the break point which u set on the cl_exithandler...In the exit name u can find list of badi's attached to the tcode..
There are multiple ways of searching for BADI.
Ø Finding BADI Using CL_EXITHANDLER=>GET_INSTANCE
Ø Finding BADI Using SQL Trace (TCODE-ST05).
Ø Finding BADI Using Repository Information System (TCODE- SE84).

1. Go to the Transaction, for which we want to find the BADI, take the example of Transaction VD02. Click on System->Status. Double click on the program name. Once inside the program search for ‘CL_EXITHANDLER=>GET_INSTANCE’.Make sure the radio button “In main program” is checked. A list of all the programs with call to the BADI’s will be listed.The export parameter ‘EXIT_NAME’ for the method GET_INSTANCE of class CL_EXITHANDLER will have the user exit assigned to it. The changing parameter ‘INSTANCE’ will have the interface assigned to it. Double click on the method to enter the source code.Definition of Instance would give you the Interface name.

2. Start transaction ST05 (Performance Analysis).Set flag field "Buffer trace" Remark: We need to trace also the buffer calls, because BADI database tables are buffered. (Especially view V_EXT_IMP and V_EXT_ACT)Push the button "Activate Trace". Start transaction VA02 in a new GUI session. Go back to the Performance trace session. Push the button "Deactivate Trace".Push the button "Display Trace".The popup screen "Set Restrictions for Displaying Trace" appears.Now, filter the trace on Objects: • V_EXT_IMP • V_EXT_ACT Push button "Multiple selections" button behind field Objects Fill: V_EXT_IMP and V_EXT_ACT All the interface class names of view V_EXT_IMP start with IF_EX_. This is the standard SAP prefix for BADI class interfaces. The BADI name is after the IF_EX_.So the BADI name of IF_EX_CUSTOMER_ADD_DATA is CUSTOMER_ADD_DATA

3. Go to “Maintain Transaction” (TCODE- SE93).Enter the Transaction VD02 for which you want to find BADI.Click on the Display push buttons.Get the Package Name. (Package VS in this case) Go to TCode: SE84->Enhancements->Business Add-inns->DefinitionEnter the Package Name and Execute. Here you get a list of all the Enhancement BADI’s for the given package MB. The simplese way for finding BADI is 1. chooes Tcode Program & package for that Tcode.2. Go to Tcode se18. Press F4. search by package or by program.

Finding User Exit or Badis

*-----------------------------------------------------------------------
* P R O G R A M H E A D E R
*-----------------------------------------------------------------------
* Version : 1.0
* SAP Version : R/3 System
* Program Name : ZVGENHANCE
* Created on : 20070802
* Program Type : Report
* Description : Program to find User Exits and Badis
*-----------------------------------------------------------------------
REPORT zvgenhance NO STANDARD PAGE HEADING LINE-SIZE 133 LINE-COUNT 80.
*-----------------------------------------------------------------------
* TABLES
*-----------------------------------------------------------------------
TABLES :tstc,
tadir,
modsapt,
modact,
trdir,
tfdir,
enlfdir,
sxs_attrt ,
tstct.
*-----------------------------------------------------------------------
* INTERNAL TABLES
*-----------------------------------------------------------------------
DATA : jtab LIKE tadir OCCURS 0 WITH HEADER LINE.
*-----------------------------------------------------------------------
* WORK AREA
*-----------------------------------------------------------------------
DATA : wa_tadir TYPE tadir.
*-----------------------------------------------------------------------
* VARIABLES
*-----------------------------------------------------------------------
DATA : field1(30).
DATA : v_devclass LIKE tadir-devclass.
*-----------------------------------------------------------------------
* SELECTION SCREEN
*-----------------------------------------------------------------------
SELECTION-SCREEN:BEGIN OF BLOCK b1 WITH FRAME TITLE g_text01,
BEGIN OF LINE,
COMMENT 3(20) g_t01 FOR FIELD p_tcode.
PARAMETERS : p_tcode LIKE tstc-tcode.
SELECTION-SCREEN:END OF LINE,
BEGIN OF LINE,
COMMENT 3(20) g_t02 FOR FIELD p_pgmna.
PARAMETERS : p_pgmna LIKE tstc-pgmna .
SELECTION-SCREEN:END OF LINE,
END OF BLOCK b1.
*-----------------------------------------------------------------------
* INITIALIZATION
*-----------------------------------------------------------------------
INITIALIZATION.
g_text01 = 'Input Details'.
g_t01 = 'TCode'.
g_t02 = 'Program name'.
*-----------------------------------------------------------------------
* START OF SELECTION
*-----------------------------------------------------------------------
START-OF-SELECTION.
IF NOT p_tcode IS INITIAL.
SELECT SINGLE * FROM tstc WHERE tcode EQ p_tcode.
ELSEIF NOT p_pgmna IS INITIAL.
tstc-pgmna = p_pgmna.
ENDIF.
IF sy-subrc EQ 0.
SELECT SINGLE * FROM tadir
WHERE pgmid = 'R3TR'
AND object = 'PROG'
AND obj_name = tstc-pgmna.
MOVE : tadir-devclass TO v_devclass.
IF sy-subrc NE 0.
SELECT SINGLE * FROM trdir
WHERE name = tstc-pgmna.
IF trdir-subc EQ 'F'.
SELECT SINGLE * FROM tfdir
WHERE pname = tstc-pgmna.
SELECT SINGLE * FROM enlfdir
WHERE funcname = tfdir-funcname.
SELECT SINGLE * FROM tadir
WHERE pgmid = 'R3TR'
AND object = 'FUGR'
AND obj_name EQ enlfdir-area.
MOVE : tadir-devclass TO v_devclass.
ENDIF.
ENDIF.
SELECT * FROM tadir INTO TABLE jtab
WHERE pgmid = 'R3TR'
AND object IN ('SMOD', 'SXSD')
AND devclass = v_devclass.
SELECT SINGLE * FROM tstct
WHERE sprsl EQ sy-langu
AND tcode EQ p_tcode.
FORMAT COLOR COL_POSITIVE INTENSIFIED OFF.
WRITE:/(19) 'Transaction Code - ',
20(20) p_tcode,
45(50) tstct-ttext.
SKIP.
IF NOT jtab[] IS INITIAL.
WRITE:/(105) sy-uline.
FORMAT COLOR COL_HEADING INTENSIFIED ON.
SORT jtab BY object.
DATA : wf_txt(60) TYPE c,
wf_smod TYPE i ,
wf_badi TYPE i ,
wf_object2(30) TYPE c.
CLEAR : wf_smod, wf_badi , wf_object2.
LOOP AT jtab INTO wa_tadir.
AT FIRST.
FORMAT COLOR COL_HEADING INTENSIFIED ON.
WRITE:/1 sy-vline,
2 'Enhancement/ Business Add-in',
41 sy-vline ,
42 'Description',
105 sy-vline.
WRITE:/(105) sy-uline.
ENDAT.
CLEAR wf_txt.
AT NEW object.
IF wa_tadir-object = 'SMOD'.
wf_object2 = 'Enhancement' .
ELSEIF wa_tadir-object = 'SXSD'.
wf_object2 = ' Business Add-in'.
ENDIF.
FORMAT COLOR COL_GROUP INTENSIFIED ON.
WRITE:/1 sy-vline,
2 wf_object2,
105 sy-vline.
ENDAT.
CASE wa_tadir-object.
WHEN 'SMOD'.
wf_smod = wf_smod + 1.
SELECT SINGLE modtext INTO wf_txt
FROM modsapt
WHERE sprsl = sy-langu
AND name = wa_tadir-obj_name.
FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
WHEN 'SXSD'.
* For BADis
wf_badi = wf_badi + 1 .
SELECT SINGLE text INTO wf_txt
FROM sxs_attrt
WHERE sprsl = sy-langu
AND exit_name = wa_tadir-obj_name.
FORMAT COLOR COL_NORMAL INTENSIFIED ON.
ENDCASE.
WRITE:/1 sy-vline,
2 wa_tadir-obj_name HOTSPOT ON,
41 sy-vline ,
42 wf_txt,
105 sy-vline.
AT END OF object.
WRITE : /(105) sy-uline.
ENDAT.
ENDLOOP.
WRITE:/(105) sy-uline.
SKIP.
FORMAT COLOR COL_TOTAL INTENSIFIED ON.
WRITE:/ 'No.of Exits:' , wf_smod.
WRITE:/ 'No.of BADis:' , wf_badi.
ELSE.
FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
WRITE:/(105) 'No userexits or BADis exist'.
ENDIF.
ELSE.
FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
WRITE:/(105) 'Transaction does not exist'.
ENDIF.
AT LINE-SELECTION.
DATA : wf_object TYPE tadir-object.
CLEAR wf_object.
GET CURSOR FIELD field1.
CHECK field1(8) EQ 'WA_TADIR'.
READ TABLE jtab WITH KEY obj_name = sy-lisel+1(20).
MOVE jtab-object TO wf_object.
CASE wf_object.
WHEN 'SMOD'.
SET PARAMETER ID 'MON' FIELD sy-lisel+1(10).
CALL TRANSACTION 'SMOD' AND SKIP FIRST SCREEN.
WHEN 'SXSD'.
SET PARAMETER ID 'EXN' FIELD sy-lisel+1(20).
CALL TRANSACTION 'SE18' AND SKIP FIRST SCREEN.
ENDCASE.
*-----------------------------------------------------------------------
* END OF SELECTION
*-----------------------------------------------------------------------

Wednesday, August 1, 2007

Auto Program Generation

*----------------------------------------------------------------------*
* P R O G R A M H E A D E R *
*----------------------------------------------------------------------*
* Program ID : Header n Program Generation *
* Version : 1.0 *
* SAP Version : R/3 System *
* Program Name : ZVGTEST *
* Created by : Vaibhav B Gawali *
* Created on : 20070718 *
* Program Type : Report *
* Description : This reports generated a new report with *
* header and some default values. *
*----------------------------------------------------------------------*
REPORT zprogram2 NO STANDARD PAGE HEADING LINE-SIZE 65 LINE-COUNT 80.
*----------------------------------------------------------------------*
* TYPES *
*----------------------------------------------------------------------*
TYPES : BEGIN OF x_output,
str TYPE char72,
END OF x_output.
*----------------------------------------------------------------------*
* CONSTANTS *
*----------------------------------------------------------------------*
CONSTANTS : c_x TYPE char1 VALUE 'X',
c_i TYPE char1 VALUE 'I',
c_s TYPE char1 VALUE 'S',
c_rid TYPE char3 VALUE 'RID',
c_se38 TYPE char4 VALUE 'SE38',
c_star TYPE char1 VALUE '*',
c_dash TYPE char1 VALUE '-',
c_colon TYPE char1 VALUE ':',
c_01 TYPE char30 VALUE 'Title',
c_02 TYPE char30 VALUE 'Program ID',
c_03 TYPE char30 VALUE 'Version',
c_04 TYPE char30 VALUE 'SAP Version',
c_05 TYPE char30 VALUE 'Program Name',
c_06 TYPE char30 VALUE 'Created by',
c_07 TYPE char30 VALUE 'Created on',
c_08 TYPE char30 VALUE 'Program Type',
c_09 TYPE char30 VALUE 'Message Class',
c_10 TYPE char30 VALUE 'Description',
c_11 TYPE char30 VALUE 'Change History',
c_12 TYPE char30 VALUE 'Change Id',
c_13 TYPE char30 VALUE 'Author',
c_14 TYPE char30 VALUE 'Changed On',
c_15 TYPE char30 VALUE 'Description',
c_incl TYPE char35 VALUE ' INCLUDE',
c_type TYPE char35 VALUE ' TYPES',
c_cons TYPE char35 VALUE ' CONSTANTS',
c_itab TYPE char35 VALUE ' INTERNAL TABLES',
c_wa TYPE char35 VALUE ' WORK AREA',
c_var TYPE char35 VALUE ' VARIABLES',
c_range TYPE char35 VALUE ' RANGE',
c_fs TYPE char35 VALUE ' FIELD SYMBOLS',
c_ss TYPE char35 VALUE ' SELECTION SCREEN',
c_ssa TYPE char35 VALUE ' SELECTION SCREEN VALIDATION',
c_init TYPE char35 VALUE ' INITIALIZATION',
c_sos TYPE char35 VALUE ' START OF SELECTION',
c_eos TYPE char35 VALUE ' END OF SELECTION'.
*----------------------------------------------------------------------*
* INTERNAL TABLES *
*----------------------------------------------------------------------*
DATA :t_output TYPE TABLE OF x_output.
*----------------------------------------------------------------------*
* WORK AREA *
*----------------------------------------------------------------------*
DATA :w_output TYPE x_output.
*----------------------------------------------------------------------*
* VARIABLES *
*----------------------------------------------------------------------*
DATA : g_line TYPE char72.
*----------------------------------------------------------------------*
* FIELD SYMBOLS *
*----------------------------------------------------------------------*
FIELD-SYMBOLS : TYPE x_output.
*----------------------------------------------------------------------*
* SELECTION SCREEN *
*----------------------------------------------------------------------*
*********************************************************************
* Block One for Program Header
*********************************************************************
SELECTION-SCREEN:BEGIN OF BLOCK b1 WITH FRAME TITLE g_text01,
BEGIN OF LINE.
*---------------------------------------------------------------------
* Title
*---------------------------------------------------------------------
PARAMETERS : cb_title TYPE checkbox DEFAULT 'X'.
SELECTION-SCREEN:COMMENT 3(20) g_t01 FOR FIELD p_title.
PARAMETERS : p_title TYPE char50 DEFAULT 'P R O G R A M H E A D E R'.
SELECTION-SCREEN:END OF LINE,
BEGIN OF LINE.
*---------------------------------------------------------------------
* Program ID
*---------------------------------------------------------------------
PARAMETERS : cb_pid TYPE checkbox DEFAULT 'X'.
SELECTION-SCREEN:COMMENT 3(20) g_t02 FOR FIELD p_pid.
PARAMETERS : p_pid TYPE char50.
SELECTION-SCREEN:END OF LINE,
BEGIN OF LINE.
*---------------------------------------------------------------------
* Version
*---------------------------------------------------------------------
PARAMETERS : cb_ver TYPE checkbox DEFAULT 'X'.
SELECTION-SCREEN:COMMENT 3(20) g_t03 FOR FIELD p_ver.
PARAMETERS : p_ver TYPE char5 DEFAULT '1.0'.
SELECTION-SCREEN:END OF LINE,
BEGIN OF LINE.
*---------------------------------------------------------------------
* SAP Version
*---------------------------------------------------------------------
PARAMETERS : cb_sver TYPE checkbox DEFAULT 'X'.
SELECTION-SCREEN:COMMENT 3(20) g_t04 FOR FIELD p_sver.
PARAMETERS : p_sver TYPE char50 DEFAULT 'R/3 System'.
SELECTION-SCREEN:END OF LINE,
BEGIN OF LINE.
*---------------------------------------------------------------------
* Program Name
*---------------------------------------------------------------------
PARAMETERS : cb_repid TYPE checkbox DEFAULT 'X'.
SELECTION-SCREEN:COMMENT 3(20) g_t05 FOR FIELD p_repid.
PARAMETERS : p_repid TYPE char50.
SELECTION-SCREEN:END OF LINE,
BEGIN OF LINE.
*---------------------------------------------------------------------
* Created by
*---------------------------------------------------------------------
PARAMETERS : cb_ernam TYPE checkbox DEFAULT 'X'.
SELECTION-SCREEN:COMMENT 3(20) g_t06 FOR FIELD p_ernam.
PARAMETERS : p_ernam TYPE syuname DEFAULT sy-uname.
SELECTION-SCREEN:END OF LINE,
BEGIN OF LINE.
*---------------------------------------------------------------------
* Created on
*---------------------------------------------------------------------
PARAMETERS : cb_erdat TYPE checkbox DEFAULT 'X'.
SELECTION-SCREEN:COMMENT 3(20) g_t07 FOR FIELD p_erdat.
PARAMETERS : p_erdat TYPE sydatum DEFAULT sy-datum.
SELECTION-SCREEN:END OF LINE,
BEGIN OF LINE.
*---------------------------------------------------------------------
* Program Type
*---------------------------------------------------------------------
PARAMETERS : cb_typ TYPE checkbox DEFAULT 'X'.
SELECTION-SCREEN:COMMENT 3(20) g_t08 FOR FIELD p_typ.
PARAMETERS : p_typ TYPE char50 DEFAULT 'Report'.
SELECTION-SCREEN:END OF LINE,
BEGIN OF LINE.
*---------------------------------------------------------------------
* Message Class
*---------------------------------------------------------------------
PARAMETERS : cb_msgcl TYPE checkbox DEFAULT 'X'.
SELECTION-SCREEN:COMMENT 3(20) g_t09 FOR FIELD p_msgcl.
PARAMETERS : p_msgcl TYPE symsgid.
SELECTION-SCREEN:END OF LINE,
BEGIN OF LINE.
*---------------------------------------------------------------------
* Description
*---------------------------------------------------------------------
PARAMETERS : cb_desc TYPE checkbox DEFAULT 'X'.
SELECTION-SCREEN:COMMENT 3(20) g_t10 FOR FIELD p_desc.
PARAMETERS : p_desc TYPE char50 DEFAULT 'Program description'.
SELECTION-SCREEN:END OF LINE,
END OF BLOCK b1.
*********************************************************************
* Block Two for Change History
*********************************************************************
SELECTION-SCREEN:BEGIN OF BLOCK b2 WITH FRAME TITLE g_text02,
BEGIN OF LINE.
*---------------------------------------------------------------------
* Change History
*---------------------------------------------------------------------
PARAMETERS : cb_chist TYPE checkbox DEFAULT 'X'.
SELECTION-SCREEN:COMMENT 3(20) g_t11 FOR FIELD p_chist.
PARAMETERS : p_chist TYPE char50 DEFAULT 'C H A N G E H I S T O R Y'.
SELECTION-SCREEN:END OF LINE,
BEGIN OF LINE.
*---------------------------------------------------------------------
* Change Id
*---------------------------------------------------------------------
PARAMETERS : cb_cid TYPE checkbox DEFAULT 'X'.
SELECTION-SCREEN:COMMENT 3(20) g_t12 FOR FIELD p_cid.
PARAMETERS : p_cid TYPE char50.
SELECTION-SCREEN:END OF LINE,
BEGIN OF LINE.
*---------------------------------------------------------------------
* Author
*---------------------------------------------------------------------
PARAMETERS : cb_aut TYPE checkbox DEFAULT 'X'.
SELECTION-SCREEN:COMMENT 3(20) g_t13 FOR FIELD p_aut.
PARAMETERS : p_aut TYPE syuname DEFAULT sy-uname.
SELECTION-SCREEN:END OF LINE,
BEGIN OF LINE.
*---------------------------------------------------------------------
* Changed On
*---------------------------------------------------------------------
PARAMETERS : cb_chg TYPE checkbox DEFAULT 'X'.
SELECTION-SCREEN:COMMENT 3(20) g_t14 FOR FIELD p_chg.
PARAMETERS : p_chg TYPE sydatum.
SELECTION-SCREEN:END OF LINE,
BEGIN OF LINE.
*---------------------------------------------------------------------
* Description
*---------------------------------------------------------------------
PARAMETERS : cb_cdesc TYPE checkbox DEFAULT 'X'.
SELECTION-SCREEN:COMMENT 3(20) g_t15 FOR FIELD p_cdesc.
PARAMETERS : p_cdesc TYPE char50 DEFAULT 'Description'.
SELECTION-SCREEN:END OF LINE,
END OF BLOCK b2.
*********************************************************************
* Block Three for Other data
*********************************************************************
SELECTION-SCREEN:BEGIN OF BLOCK b3 WITH FRAME TITLE g_text03,
BEGIN OF LINE.
*----------------------------------------------------------------------
* INCLUDES
*----------------------------------------------------------------------
PARAMETERS : cb_incl TYPE checkbox DEFAULT 'X'.
SELECTION-SCREEN:COMMENT 3(18) g_t16 FOR FIELD cb_incl.
*----------------------------------------------------------------------
* TYPES DECLARATION
*----------------------------------------------------------------------
PARAMETERS : cb_type TYPE checkbox DEFAULT 'X'.
SELECTION-SCREEN:COMMENT 26(18) g_t17 FOR FIELD cb_type.
*----------------------------------------------------------------------
* CONSTANT DECLARATION
*----------------------------------------------------------------------
PARAMETERS : cb_cons TYPE checkbox DEFAULT 'X'.
SELECTION-SCREEN:COMMENT 49(18) g_t18 FOR FIELD cb_cons.
*----------------------------------------------------------------------
* DATA DECLARATION FOR INTERNAL TABLES
*----------------------------------------------------------------------
PARAMETERS : cb_itab TYPE checkbox DEFAULT 'X'.
SELECTION-SCREEN:COMMENT 72(18) g_t19 FOR FIELD cb_itab.
SELECTION-SCREEN:END OF LINE,
BEGIN OF LINE.
*----------------------------------------------------------------------
* DATA DECLARATION FOR WORK AREA
*----------------------------------------------------------------------
PARAMETERS : cb_wa TYPE checkbox DEFAULT 'X'.
SELECTION-SCREEN:COMMENT 3(18) g_t20 FOR FIELD cb_wa.
*----------------------------------------------------------------------
* DATA DECLARATION FOR VARIABLES
*----------------------------------------------------------------------
PARAMETERS : cb_var TYPE checkbox DEFAULT 'X'.
SELECTION-SCREEN:COMMENT 26(18) g_t21 FOR FIELD cb_var.
*----------------------------------------------------------------------
* RANGES
*----------------------------------------------------------------------
PARAMETERS : cb_range TYPE checkbox DEFAULT 'X'.
SELECTION-SCREEN:COMMENT 49(18) g_t22 FOR FIELD cb_range.
*----------------------------------------------------------------------
* FIELD SYMBOLS
*----------------------------------------------------------------------
PARAMETERS : cb_fs TYPE checkbox DEFAULT 'X'.
SELECTION-SCREEN:COMMENT 72(18) g_t23 FOR FIELD cb_fs.
SELECTION-SCREEN:END OF LINE,
BEGIN OF LINE.
*----------------------------------------------------------------------
* SELECTION SCREEN
*----------------------------------------------------------------------
PARAMETERS : cb_ss TYPE checkbox DEFAULT 'X'.
SELECTION-SCREEN:COMMENT 3(18) g_t24 FOR FIELD cb_ss.
*----------------------------------------------------------------------
* SELECTION SCREEN VALIDATION
*----------------------------------------------------------------------
PARAMETERS : cb_ssa TYPE checkbox DEFAULT 'X'.
SELECTION-SCREEN:COMMENT 26(18) g_t25 FOR FIELD cb_ssa.
*----------------------------------------------------------------------
* INITLIZATION
*----------------------------------------------------------------------
PARAMETERS : cb_init TYPE checkbox DEFAULT 'X'.
SELECTION-SCREEN:COMMENT 49(18) g_t26 FOR FIELD cb_init.
SELECTION-SCREEN:END OF LINE,
END OF BLOCK b3.
*********************************************************************
* Block Four for Miscellaneous data
*********************************************************************
SELECTION-SCREEN:BEGIN OF BLOCK b4 WITH FRAME TITLE g_text04,
BEGIN OF BLOCK b5 WITH FRAME TITLE g_text05,
BEGIN OF LINE.
*----------------------------------------------------------------------
* TYPE OF LINE AT OUTPUT DOTTED OR STAR
*----------------------------------------------------------------------
PARAMETERS : rb_dot RADIOBUTTON GROUP rb1.
SELECTION-SCREEN:COMMENT 3(25) g_t27 FOR FIELD rb_dot,
END OF LINE,
BEGIN OF LINE.
PARAMETERS : rb_star RADIOBUTTON GROUP rb1.
SELECTION-SCREEN:COMMENT 3(25) g_t28 FOR FIELD rb_star,
END OF LINE,
END OF BLOCK b5,
BEGIN OF BLOCK b6 WITH FRAME TITLE g_text06 ,
BEGIN OF LINE.
*----------------------------------------------------------------------
* TYPE OF END I.E. OPEN AT ONE END OR CLOSED AT OTHER END
*----------------------------------------------------------------------
PARAMETERS : rb_open RADIOBUTTON GROUP rb2.
SELECTION-SCREEN:COMMENT 3(25) g_t30 FOR FIELD rb_open,
END OF LINE,
BEGIN OF LINE.
PARAMETERS : rb_close RADIOBUTTON GROUP rb2.
SELECTION-SCREEN:COMMENT 3(25) g_t31 FOR FIELD rb_close,
END OF LINE ,
END OF BLOCK b6,
END OF BLOCK b4.
*----------------------------------------------------------------------*
* SELECTION SCREEN VALIDATION *
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON p_repid.
DATA : l_repid TYPE syrepid.
IF p_repid IS INITIAL.
MESSAGE 'Please enter program name' TYPE 'E'.
ELSE.
TRANSLATE p_repid TO UPPER CASE.
SELECT SINGLE progname FROM reposrc INTO l_repid
WHERE progname EQ p_repid.
IF sy-subrc EQ 0.
MESSAGE 'Program already exists' TYPE 'E'.
ENDIF.
ENDIF.
*----------------------------------------------------------------------*
* INITIALIZATION *
*----------------------------------------------------------------------*
INITIALIZATION.
g_text01 = 'Program Header Details'.
g_text02 = 'Change History'.
g_text03 = 'Other Data'.
g_text04 = 'Miscellaneous Data'.
g_text05 = 'Line type'.
g_text06 = 'Open/Closed'.
g_t01 = 'Title'.
g_t02 = 'Program ID'.
g_t03 = 'Version'.
g_t04 = 'SAP Version'.
g_t05 = 'Program Name'.
g_t06 = 'Created by'.
g_t07 = 'Created on'.
g_t08 = 'Program Type'.
g_t09 = 'Message Class'.
g_t10 = 'Description'.
g_t11 = 'Change History'.
g_t12 = 'Change Id'.
g_t13 = 'Author'.
g_t14 = 'Changed On'.
g_t15 = 'Description'.
g_t16 = 'Include'.
g_t17 = 'Types'.
g_t18 = 'Constants'.
g_t19 = 'Internal Tables'.
g_t20 = 'Work Area'.
g_t21 = 'Variables'.
g_t22 = 'Ranges'.
g_t23 = 'Field Symbols'.
g_t24 = 'Selection Screen'.
g_t25 = 'Screen Validation'.
g_t26 = 'Initialization'.
g_t27 = 'Dotted -------------------------'.
g_t28 = 'Star *************************'.
g_t30 = 'Open ended'.
g_t31 = 'Close ended'.
*----------------------------------------------------------------------*
* START OF SELECTION *
*----------------------------------------------------------------------*
START-OF-SELECTION.
*----------------------------------------------------------------------
* TYPE OF LINE DOTTED --------------- OR STAR ***********
*----------------------------------------------------------------------
IF rb_dot EQ c_x.
DO 72 TIMES.
CONCATENATE g_line c_dash INTO g_line.
ENDDO.
ELSE.
DO 72 TIMES.
CONCATENATE g_line c_star INTO g_line.
ENDDO.
ENDIF.
*----------------------------------------------------------------------
* TITLE
*----------------------------------------------------------------------
IF cb_title EQ c_x.
PERFORM build_output USING g_line.
CLEAR w_output .
w_output-str+2 = p_title.
APPEND w_output TO t_output.
PERFORM build_output USING g_line.
ENDIF.
*----------------------------------------------------------------------
* PROGRAM ID
*----------------------------------------------------------------------
IF cb_pid EQ c_x.
PERFORM build_desc USING c_02 p_pid.
ENDIF.
*----------------------------------------------------------------------
* VERSION
*----------------------------------------------------------------------
IF cb_ver EQ c_x.
PERFORM build_desc USING c_03 p_ver.
ENDIF.
*----------------------------------------------------------------------
* SAP VERSION
*----------------------------------------------------------------------
IF cb_sver EQ c_x.
PERFORM build_desc USING c_04 p_sver.
ENDIF.
*----------------------------------------------------------------------
* PROGRAM NAME
*----------------------------------------------------------------------
IF cb_repid EQ c_x.
PERFORM build_desc USING c_05 p_repid.
ENDIF.
*----------------------------------------------------------------------
* CREATED BYE
*----------------------------------------------------------------------
IF cb_ernam EQ c_x.
PERFORM build_desc USING c_06 p_ernam.
ENDIF.
*----------------------------------------------------------------------
* CREATED ON
*----------------------------------------------------------------------
IF cb_erdat EQ c_x.
PERFORM build_desc USING c_07 p_erdat.
ENDIF.
*----------------------------------------------------------------------
* PROGRAM TYPE
*----------------------------------------------------------------------
IF cb_typ EQ c_x.
PERFORM build_desc USING c_08 p_typ.
ENDIF.
*----------------------------------------------------------------------
* MESSAGE CLASS
*----------------------------------------------------------------------
IF cb_msgcl EQ c_x.
PERFORM build_desc USING c_09 p_msgcl.
ENDIF.
*----------------------------------------------------------------------
* PROGRAM DESCRIPTION
*----------------------------------------------------------------------
IF cb_desc EQ c_x.
PERFORM build_desc USING c_10 p_desc.
PERFORM build_output USING g_line.
ENDIF.
PERFORM build_output USING g_line.
*----------------------------------------------------------------------
* CHANGE HISTORY
*----------------------------------------------------------------------
IF cb_chist EQ c_x.
CLEAR w_output.
w_output-str+2 = p_chist.
APPEND w_output TO t_output.
PERFORM build_output USING g_line.
ENDIF.
*----------------------------------------------------------------------
* CHANGE ID
*----------------------------------------------------------------------
IF cb_cid EQ c_x.
PERFORM build_desc USING c_12 p_cid.
ENDIF.
*----------------------------------------------------------------------
* CHANGES BY
*----------------------------------------------------------------------
IF cb_aut EQ c_x.
PERFORM build_desc USING c_13 p_aut.
ENDIF.
*----------------------------------------------------------------------
* CHANGED ON
*----------------------------------------------------------------------
IF cb_chg EQ c_x.
PERFORM build_desc USING c_14 p_chg.
ENDIF.
*----------------------------------------------------------------------
* CHANGE DESCRIPTION
*----------------------------------------------------------------------
IF cb_cdesc EQ c_x.
PERFORM build_desc USING c_15 p_cdesc.
ENDIF.
PERFORM build_output USING g_line.
*----------------------------------------------------------------------
* REPORT NAME
*----------------------------------------------------------------------
CONCATENATE space 'REPORT' p_repid
'NO STANDARD PAGE HEADING LINE-SIZE 65 LINE-COUNT 80.'
INTO w_output-str SEPARATED BY space.
APPEND w_output TO t_output.
*----------------------------------------------------------------------
* INCLUDES
*----------------------------------------------------------------------
IF cb_incl EQ c_x.
PERFORM build_output USING g_line.
PERFORM build_output USING c_incl.
PERFORM build_output USING g_line.
ENDIF.
*----------------------------------------------------------------------
* TYPES DECLARATION
*----------------------------------------------------------------------
IF cb_type EQ c_x.
PERFORM build_output USING g_line.
PERFORM build_output USING c_type.
PERFORM build_output USING g_line.
ENDIF.
*----------------------------------------------------------------------
* CONSTANT DECLARATION
*----------------------------------------------------------------------
IF cb_cons EQ c_x.
PERFORM build_output USING g_line.
PERFORM build_output USING c_cons.
PERFORM build_output USING g_line.
ENDIF.
*----------------------------------------------------------------------
* DATA DECLARATION FOR INTERNAL TABLES
*----------------------------------------------------------------------
IF cb_itab EQ c_x.
PERFORM build_output USING g_line.
PERFORM build_output USING c_itab.
PERFORM build_output USING g_line.
ENDIF.
*----------------------------------------------------------------------
* DATA DECLARATION FOR WORK AREA
*----------------------------------------------------------------------
IF cb_wa EQ c_x.
PERFORM build_output USING g_line.
PERFORM build_output USING c_wa.
PERFORM build_output USING g_line.
ENDIF.
*----------------------------------------------------------------------
* DATA DECLARATION FOR VARIABLES
*----------------------------------------------------------------------
IF cb_var EQ c_x.
PERFORM build_output USING g_line.
PERFORM build_output USING c_var.
PERFORM build_output USING g_line.
ENDIF.
*----------------------------------------------------------------------
* RANGES
*----------------------------------------------------------------------
IF cb_range EQ c_x.
PERFORM build_output USING g_line.
PERFORM build_output USING c_range.
PERFORM build_output USING g_line.
ENDIF.
*----------------------------------------------------------------------
* FIELD SYMBOLS
*----------------------------------------------------------------------
IF cb_fs EQ c_x.
PERFORM build_output USING g_line.
PERFORM build_output USING c_fs.
PERFORM build_output USING g_line.
ENDIF.
*----------------------------------------------------------------------
* SELECTION SCREEN
*----------------------------------------------------------------------
IF cb_ss EQ c_x.
PERFORM build_output USING g_line.
PERFORM build_output USING c_ss.
PERFORM build_output USING g_line.
ENDIF.
*----------------------------------------------------------------------
* SELECTION SCREEN VALIDATION
*----------------------------------------------------------------------
IF cb_ssa EQ c_x.
PERFORM build_output USING g_line.
PERFORM build_output USING c_ssa.
PERFORM build_output USING g_line.
ENDIF.
*----------------------------------------------------------------------
* INITLIZATION
*----------------------------------------------------------------------
IF cb_init EQ c_x.
PERFORM build_output USING g_line.
PERFORM build_output USING c_init.
PERFORM build_output USING g_line.
ENDIF.
*----------------------------------------------------------------------
* START OF SELECTION
*----------------------------------------------------------------------
PERFORM build_output USING g_line.
PERFORM build_output USING c_sos.
PERFORM build_output USING g_line.
*----------------------------------------------------------------------
* END OF SELECTION
*----------------------------------------------------------------------
PERFORM build_output USING g_line.
PERFORM build_output USING c_eos.
PERFORM build_output USING g_line.
LOOP AT t_output ASSIGNING .
IF -str+1(6) NE 'REPORT'.
CONCATENATE c_star -str INTO -str.
IF rb_close EQ c_x.
+71 = c_star.
ENDIF.
ENDIF.
ENDLOOP.
* Create a new report as per the name entered by the user
INSERT REPORT p_repid FROM t_output.
IF sy-subrc EQ 0.
MESSAGE 'Pls save the new program in an requets or local file.'
TYPE c_i.
MESSAGE 'Pls do enter the program title in Menu Goto->Attributes.'
TYPE c_i.
MESSAGE 'Report created sucessfully.' TYPE c_s.
EXPORT p_repid TO MEMORY ID c_rid.
CALL TRANSACTION c_se38 AND SKIP FIRST SCREEN.
ENDIF.
*---------------------------------------------------------------------*
* END OF SELECTION
*---------------------------------------------------------------------*
END-OF-SELECTION.
*&---------------------------------------------------------------------*
*& Form BUILD_DESC
*&---------------------------------------------------------------------*
* -->FP_DATA
*----------------------------------------------------------------------*
FORM build_desc USING fp_desc fp_val.
CLEAR w_output.
w_output-str+2 = fp_desc.
w_output-str+25(1) = c_colon.
w_output-str+27 = fp_val.
APPEND w_output TO t_output.
ENDFORM. " BUILD_DESC
*&---------------------------------------------------------------------*
*& Form build_output
*&---------------------------------------------------------------------*
* -->FP_DATA
*----------------------------------------------------------------------*
FORM build_output USING fp_data.
IF fp_data IS NOT INITIAL.
CLEAR w_output.
w_output-str = fp_data.
APPEND w_output TO t_output.
ENDIF.
ENDFORM. " build_output

Performance Tuning

1.

What are ST05 and SE30 used for?

ST05 SQL Trace transaction

SE30 Run time analysis transaction

2.

What are simple rules for increasing performance?

a. Do not use nested loops / select statements.

b. Always use where in select query.

c. Select only required fields

d. Avoid Select – Endselect instead use Into table

e. Modularize the code.

f. Avoid using move corresponding

g. Always check for sy-subrc before sorting, read, select statements and where ever necessary.

h. Perform code inspector check

Enhancements and Modifications

1

What is a user exit?

User exits (Function module exits) are exits developed by SAP. The exit is implemented as a call to a function module. The code for the function module is written by the developer. You are not writing the code directly in the function module, but in the include that is implemented in the function module.

The naming standard of function modules for function module exits is:
EXIT_<program name><3 digit suffix>

The call to a function module exit is implemented as:
CALL CUSTOMER.-FUNCTION <3 digit suffix>

2.

How to find a exit?

Display the program where you are searching for and exit and search for CALL CUSTOMER-EXIT If you know the Exit name, go to transaction CMOD. Choose menu Utilities->SAP Enhancements. Enter the exit name and press enter. You will now come to a screen that shows the function module exits for the exit.

3.

What are the types of exits?

a. Menu exits add items to the pull down menus in standard SAP applications. You can use these menu items to call up your own screens or to trigger entire add-on applications

b. Screen exits add fields to screens in R/3 applications. SAP creates screen exits by placing special subscreen areas on a standard R/3 screen and calling a customer subscreen from the standard screen’s flow logic.

c. Function module exits add functions to R/3 applications. Function module exits play a role in both menu and screen exits.

4.

Where can we search a user exit?

In SMOD

5.

How do we implement a user exit?

Go to CMOD create a project here include the exit that u want to use and within this exit write the appropriate logic that we want.



BADIS


1.

What are BADIS?

BADIs are Business Add-Ins.
The are used to provide custom extension of a standard functionality.
BADIs are the new form of user exit.
They use ABAP OO.
The support multiple implementation.
BADIs are defined in SE18 and implemented in SE19.
Code in application checks to see if and implementation is "active"
and calls it if it has been implemented.


Difference User Exits Vs Badi




Badis

User Exits

1. Object
Oriented paradigm

1. The more traditional types, are ones controlled and implemented via CMOD/SMOD transitions as includes to function modules

2. BADI's can be used any number of times

2. USER-EXITS can be used only one time

Sap Scripts and Smart Forms

1

Tcode for SAP SCRIPTS

SE71

2.

What are the components of scripts?

a. Pages

b. Windows

c. Page Windows

d. Character and paragraph format

e. Header and basic settings

3.

Where can we design styles for sap scripts?

In SE72

4.

What is the most important componenets in sap script?

A script cannot run without a main window.

5.

What are the types of windows?

a. Main

b. Variable

c. Constant

d. Graph.

6.

How many main windows can exist in a script?

Max of 100, 00 to 99.

7.

Can we write code in script?

Yes we can.

8.

How do we call an external subroutine in scripts?

Use syntax 
In script
/: PERFORM <form> IN PROGRAM <prog>
/: USING &INVAR1&
/: USING &INVAR2&
......
/: CHANGING &OUTVAR1&
/: CHANGING &OUTVAR2&
......
/: ENDPERFORM
 
And in program 
 
FORM <form> TABLES IN_TAB STRUCTURE ITCSY
OUT_TAB STRUCTURE ITCSY.
...
ENDFORM.
 

9.

What are symbols in sap scripts?

They are the places holders for values.

10

What are different types of symbols?

a. Standard

b. System

c. Program

d. Text

11.

Where do we define a standard symbol?

In SO10.

12

Name some system symbols.

Date/Time/Pageno etc

13

How do we call a script from program?

Use the following FM

OPEN_FORM

WRITE_FORM

CLOSE_FORM

14

Can we modify a standard script?

Yes copy the standard script in to Z and make the changes.

15

Can we migrate a script to smart form ? How?

Yes , just go to smartforms and there is a option of migrate from scripts.

16

Where do we maintain the relation between script and print program?

In TCode NACE





Smart Forms



1.

What is the Tcode for smart forms

SMARTFORMS

2.

Where do we design styles?

In SMARTSTYLES

3.

Is it mandatory for a smartform to have a main window?

No

4.

How do we execute a smartforms?

It creates a FM when activated ,just use this FM as normal we use in the program and pass the parameters to it.



Difference between asmartform and script


Sap script

Smartforms

1. Is client dependents

1. Is client Independents

2. Main window is must

2. Main window is optional

3. Coding layout and design is complex

3. It very easy as compared to scripts

4. Data is not maintained in tree format

4. Data is maintained in tree format

5. Debugging is very tedious

5. Debugging is very easy

6. Does not generate a FM

6. Does generate a FM

7. Can be migrated to smartform

7. Cannot be migrated to scripts