Translate

Wednesday, 30 May 2012

Valuable Lessons to Make the Most of your SAP Career

1. Hard Work – Nothing can replace the ability in any career, including SAP, of being willing to put in the time to be successful. Malcolm Gladwell’s book Outliers sums it up very well when he says the difference between success and non-success, genius and mediocrity is practice. Anyone from the Beatles to Bill Gates who has succeeded has done so on the back of at least 10,000 hours of practice. I wanted to be good at my SAP career and the fact that I loved my job made it easy to put in the hours it took to be successful, which continues to this day. SAP is competitive industry and if you are not willing to put in the effort someone else will.


2.Information - I realized early on that there was a lot of information available and half the battle was being able to find it. I made a pledge that I would build up a knowledge base of information and would document everything that I worked on or could find that related to SAP. Some of my friends have nicknamed my data repository "The Library" and they are glad to have a card to access it. Make no mistake, this is a very time consuming process and one that I have spent several hours a day on for the last 12 years. I am now sitting on a database of 70,000 organized SAP documents with a good portion of them being specific to Human Capital Management. These documents have turned into a security blanket and allowed me to make the jump to an independent consultant and later to opening my consulting company. With SAP Help, SAP Community Network, User Conferences, IT Toolbox, ASUG, there is a wealth of information to help you learn and grow in your career.


3. Adaptability - When I graduated from the Partner Academy all I knew was that I didn’t want to do SAP payroll as it seemed to difficult. Of course when I found out my first assignment was going to be a large Fortune 500 SAP payroll project I got a crash course in being adaptable. After doing many payroll implementations I had a chance to start working in other areas of HCM such as the Employee Interaction Center and Enterprise Compensation Management each of which had a steep learning curve but I wanted to continue to adapt and grow my SAP career. I believe it is very important to take advantage of the opportunities you are given in your SAP career as you never know where they are going to take you.


4. Networking - I read the other day that SCN has over 2 million members but make no mistake the SAP world can be very small. I have made a point to keep in touch with as many people in the industry as possible which takes effort and a time commitment. I have helped many people over the years by sharing knowledge, answering SAP questions or helping people find jobs and in return I have been helped when I needed it. A great example is Jon Reed who I met on Linkedin and Twitter who was kind enough to review this article. It is easy to network with your SAP peers on projects or via Linkedin, Twitter, Facebook etc and it is something that you should do from day 1 of your SAP career.


5. Knowledge Transfer - We all know individuals in the industry that try to hoard their knowledge thinking it will make them more valuable. There used to be a lot more of these folks before the SAP Community Network was formed and sharing became more fashionable. I still remember during my first month of consulting an individual who had 1 year of experience (that was lot in early 1998 for US Payroll) who would not explain or provide any help to either his fellow consultants or client resources. He confided in me one day at lunch that the client would never let him go because he had “all the knowledge”. The interesting thing is that he was the first one to roll off the implementation and yours truly stayed as although I had very little knowledge at the time I was more than willing to share it with everyone. I learned very early that the more I shared, and the more questions I got, the more I learned.  If you want to continually learn and become an expert in your area share all your knowledge as you will get way more back in return.


If you work towards those five key areas above it does not guarantee that you are going to be successful but it will put you on the right path.   
                                                                       By : Jarret Pazahanick

Wednesday, 23 May 2012

Logical Unit of Work


Logical Units of Work in ABAP, (LUWs in SAP)

LUWs are one of the least understood concept in ABAP, even by experienced ABAPers. More over it is one of the most important concept in ABAP.

Knowledge of SAP Transactions, SAP LUW and Database LUW is crucial in ensuring that your database updates does not result in inconsistent data.

Let us take an example: 
Consider a Transaction (ABAP program), where intention is to Debit Rs 50 from account A, and credit those Rs 50 into account B.
Say debit from account A is successful. But when there was a credit of Rs 50 to account B, an error happens hence crediting did not happen. Bust as you have noticed, debiting from account A is already odne, and now this Rs 50 is lost. ( Neither in Account A, nor in Account B )

Transaction: An application transaction, possibly containing multiple screens, where multiple tables need to be updated.


Database LUW: System's approach of updating database. Either an update happens completely or does not happen at all. System has fixed rules, based on which a DB LUW ends/starts.

SAP LUW: A series of logically related updates. Ideally an SAP LUW should contain only one DB LUW, to enure that data in consistent. If a SAP LUW is spread across several DB LUWs, it can result in inconsistent data.

Rules related to Database LUW
Current DB LUW ends, and new one starts: 
1. While moving form one screen to another screen (as soon a dialog step completes).
2. While calling a RFC
3. While exiting from and RFC
4. When encouters a WAIT statement
5. When any message is sent to dialogue. (Information, warning, error)
6. When COMMIT WORK statement is encountered
7. When function module DB_COMMIT is called.


Example of defective programming.
<-------------------------------SAP Transaction----------------------------------->
<---------------SAP LUW-------------><-------------SAP LUW----------------->
<--DB LUW--><--DB LUW--><--DB LUW--><--DB LUW--><--- DB LUW-->


Example of right programming technique.
<-------------------------------SAP Transaction----------------------------------->
<---------------SAP LUW-------------><-------------SAP LUW----------------->
<--------------DB LUW---------------><-----------------DB LUW--------------->

Why cant I use ROLLBACK statement? 
ROLLBACK statement scope in only within a DBLUW. I.e. only the changes done within the current DB LUW will be undone. Changes done in previous DB LUWs will not be undone.

How to ensure that an SAP LUW contains only one DB LUW?
There are two approaches
1. Using CALL FUNCTION  ............... IN UPDATE TASK statement.
2. Using PERFORM ....... ON COMMIT statement.

Other approach
This approach can be specially used/needed in HR Function modules.
Example: Creating a Org Unit and relationships. Requirement is that either Org Unit and all its relationships should get created, else nothing should get created.

In this approach we use FMs that provide option to handle buffers. These FMs have an import parameter VTASK, If VTASK is passed as 'B', update will happen only in buffer, not in DB. Once all update FMs are called with VTASK = B, call the FM RH_UPDATE_DATABASE to update the database.

Hacking SAP


Hacking SAP (Ethical :) )

YOU ARE RESPONSIBLE FOR ANY LOSSES ARISING OUT OF USING ANY OF THE BELOW CONTENT. USE IT IN YOUR OWN DISCRETION

In my understanding hacking is nothing but getting access which you are not supposed to get. Here I explain various ways of getting access to various things in SAP. This is also an education to SAP Security team, andd they can analyze these loopholes. That is why I call it ethical.

Ensure that you use these techniques only in your development or test systems. Never try in Production.

Execute a unauthorized Tcode ? Use SA38
What will you get?
To execute a Tcode for which you do not have access 

What do you need to have? 
Access to Tcode SA38,
This applies only to Report Tcodes, not to Module-pool Tcodes

How to do it? 
Login to any system where you have access to the target Tcode. (Example : AL08)
Go to System --> Status and find the name of the program which is triggered by your target Tcode.
Now go to SA38 and execute this program. In this case it is RSUSR000.This hack works because there is no authorization check inside the program. Rather the check is at Tcode level.



What is the trail?
Unless you are monitored using system trace, there is no trail you will leave behind.


Updating contents of a table (SE16 - Classic debugger)
What will you get?
- You can create/edit/delete table entries using SE16. This hack makes use of earlier ability available in SE16 to create/edit/delete entries. 

What do you need to have? 
- SE16 access
- Change access in debug mode

How to do it?
Go to SE16 -->Display and select the entry you want to delete/edit/copy -->switch on the debug mode -->Press F7 --> Switch to Classic debugger (from menu 'Debugger')-->In the classic debugger press F7 -->You see below screen.

Now change SHOW to EDIT and press F8. You are in the edit mode now. Similarly you can Edit/delete/create entries.


What is the trail?

Unfortunately this does not leave any trail. So impossible to detect, unless trace is set on the performing user.


Any authorization you want temporarily? table USRBF2
What will you get?
Any authorization you want. It will remain for around 2 to 3 hours.  


What do you need to have? 
Change access to table USRBF2

How to do it? 
Find out the authorization object required by you.
Create an entry in table USRBF2 using debugging access.

What is the trail?
Entry in this table will say that you have the access. But this entry will get deleted after 2-3 hours.
System trace will show that you get the access due to this table.

Want SAP* access? Table USREFUS
What will you get?
SAP* access, that is ALL the access is the system 


What do you need to have? 
- SE16 access
- Change access in debug mode

How to do it?
Create an entry like below using the debugging access in SE16


What is the trail?
- Entry in the table will mean that you have the access. The access will remain as long as the entry remains.

Sunday, 13 May 2012

Badi Notes

Business Add-Ins

Business add-ins are enhancements to the standard version of the system. They can be inserted into the SAP System to accommodate user requirements too specific to be included in the standard delivery. Since specific industries often require special functions, SAP allows you to predefine these points in your software.



As with customer exits, two different views are available:

· In the definition view, an application programmer defines exit points in a source that allow specific industry sectors, partners, and customers to attach additional coding to standard SAP source code without having to modify the original object.

· In the implementation view, the users of Business Add-Ins can customize the logic they need or use a standard solution if one is available.



Architecture of the Enhancement Technique

In order to enhance a program, you must first define a Business Add-In. The application developer creates an interface for the add-in. From this, enhancement management creates an adapter class that implements the interface and thus provides the interface for implementation by the customer, partner, and so on. The developer then creates an instance of the adapter class in the application program and calls the corresponding method at the appropriate time.



For each Business Add-In you have one interface and an adapter class that implements this. The interface is implemented by the user.
The generated class (Add-In adapter) has the following tasks:
· Control

The adapter class calls the active implementations.
1. · Filtering
If a Business Add-In is to be executed only under certain conditions, the adapter class ensures that only certain implementations will be executed.

This concept ensures mutlple use. Any Business Add-In that has been implemented once already can be implemented again by those groups listed to the right of the software chain shown in the above graphic.
Customers can find the enhancements in their system in the Implementation Guide (IMG) and in the component hierarchy. If a customer wishes to use a Business Add-In, he or she first creates an implementation. The customer must implement the methods and the enhancements, and afterwards activate the implementation of the enhancement. The enhancement's active components are then called at runtime. Normally, a Business Add-In contains an interface and other additional components such as function codes for menu enhancements. In some cases, Business Add-Ins also include enhancements for screens. The enhancement, interface, and generated classes are all located in the appropriate application development namespace. Business Add-In implementations are 
created in the respective implementation namespace.

A Comparison of Different Enhancement Techniques

Due to the necessity of adjusting R/3 to meet the specific needs of a variety of customers, several different enhancement techniques were developed in the past. A short description of each of the various enhancement techniques follows.

Business Transaction Events (Open FI)

The Open FI enhancement technique was developed in the Financial Accounting component. Open FI is based upon the following principles:

Application developers must define their interface in a function module, an assignment table is read in the accompanying (generated) code, and the customer modules assigned are called dynamically.
This technique differentiates between enhancements that are only allowed to have one implementation and enhancements that can call multiple implementations in any sequence desired. Both industry-specific and country-specific enhancements may be defined.
The concepts behind the Business Add-Ins enhancement technique and Open FI are basically the same. However, the two enhancement techniques do differ from each other in the following points:

1. · Open FI can only be used to make program enhancements, that is, you can only enhance source code using Open FI. You cannot enhance user interface elements with Open FI like you can with Business Add-Ins.
1. · Open FI assumes that enhancement will only take place on three levels (SAP - partners - customers), whereas with Business Add-Ins you can create and implement enhancements in as many software layers as you like.
2. · Open FI uses function modules for program enhancements. With Business Add-Ins, ABAP Objects is used to enhance programs.
Enhancements in Transactions SMOD/CMOD

Making enhancements using the transactions SMOD/CMOD has the following disadvantages:
1. · This enhancement technique assumes a two-tiered system infrastructure (SAP – customers).
2. · The naming conventions in effect do not tolerate name extension.

Conclusion:None of the techniques mentioned above can easily be extended to fulfill the requirements of a system infrastructure containing country versions, industry solutions, partners, and customers.Business Add-Ins should be considered generalized Business Transaction Events that can be used to bundle program, menu and screen enhancements into a single add-in. Business Add-Ins can be created and employed in each of the various software levels.

Defining a Business Add-In

Use
An application developer who wishes to have a Business Add-In in a particular program defines the interface for an enhancement in the Business Add-In Builder. In the following step, he or she programs the interface call in the application program at the appropriate place. Customers can then select the add-in and implement it according to their needs.

Procedure
1. ...
1. From the SAP menu, choose Tools ® ABAP Workbench ® Utilities ® Business Add-Ins (transaction SE18).

We would like to explain the procedures using an application program as an example. There is a string conversion in the program. You want the add-in users to determine themselves how their strings are to be converted. The application developer defines an enhancement. It consists of an interface with a method. A changing parameter is used to pass on the string.




Option: Within SAP



Meaning: If the customer selects this option for an Add-In, he or she has no option for creating his or her own implementations for this Business Add-In or for using them. In the input help, Business Add-Ins with this flag are not displayed. For more information on the checkbox Within SAP, refer to the section Definition of a Business Add-In in the Enterprise Core.




Option: Multiple Use



Meaning: The Business Add-In can be set for multiple use. For more information, refer to the section Multiple-Use Business Add-Ins.



Option: Filter-Dependent



Meaning : The implementation of a Business Add-In is dependent on a particular filter value.For more information, refer to the section Multiple-Use Business Add-Ins.
None of the above options is selected.







5. Choose the Interface tab. The interface name is generated automatically and can be changed here.

2. Enter a name with a maximum of 20 characters for the Business Add-In.









3. Choose Create.
4. On the following screen, enter a short text as the description for the Business Add-In.In this example, we are dealing with a simple enhancement.











Under the FCodes tab, you can create Menu Enhancements, and under the Subscreens tab you can create Screen Enhancements.
6. Double-click the interface name field. The system branches to the Class Builder.
7. Confirm that you want to save the entries you have made. Assign a package to the Business Add-In.


8. Use the Class Builder to assign a method to the interface.









9. Now define a parameter with the following attributes:






10. Save and activate your entries. Use the pushbutton Back to navigate back to the Business Add-In definition.

You can now continue with the definition of the Business Add-In by executing activation in the Class Builder.
A table control now appears on the definition screen for the Business Add-In. It displays the method you have created for the interface.
When you maintain the interface methods, the corresponding executing class is generated. The generated code cannot be altered in the initial expansion phase.
11. Save your entries and use the Documentation pushbutton to create a description for your new Business Add-In. Remember that this documentation is very important for users to be able to understand the purpose behind the Add-In. For more information, read the section Documentation of a Business Add-In.

Choose Goto ® Default Coding / Sample Coding if you wish to create default coding and/ or sample coding for the Business Add-In. The default implementation is executed only if no other active implementation is available. This applies also to filter-dependent Business Add-Ins.

When you create default or sample coding, do not forget to save your entries. In this way, the connection between the class and the implementation is set up.

Calling a Business Add-In in the Application Program

When you define a Business Add-In, enhancement management generates a class that implements your interface. The application developer uses a factory method to create an instance of this adapter class in the application program and calls the corresponding method, if necessary.
The adapter class method generated by add-in management decides whether one or several active implementations should be called. If necessary, these implementations are subsequently executed. The application program ensures only that the adapter class method is called. The application program does not know which implementations are called.

Example:

Having created a string conversion Business Add-In, you would program the call of the Business Add-In into your ABAP source code as follows:

1 Report businessaddin.
2 class cl_exithandler definition load. "Declaration
3 data exit type ref to if_ex_businessaddin. "Interface reference
4 data word(15) type c value 'Business Add-in'. "String to change

5 start-of-selection.
6 call method cl_exithandler=>get_instance "Factory method call
7 exporting "Method
exit name =’BUSINESSADDIN’
8 null instance accepted =’X’
9 changing instance = exit.
10 write:/'Please click here'.

11 at line-selection.
12 write:/ 'Original word: ',word.

13 if not exit is initial.
14 call method exit->method "Add-In call
15 changing parameter = word.
16 endif.
17 write:/ 'Original word: ',word.

In order to be able to call static methods, you must declare the corresponding class in ABAP Objects. This is why the class … definition load statement is necessary for the factory class.
A variable for object reference is also necessary when calling the method. Use data to create it and type it to the interface.

During initialization (line 6), the application developer creates an adapter class instance using the factory method. The instance methods are then called at the time specified.

To improve performance during creation of the instances, you should specify additional parameters for the call in the method GET_INSTANCE of the class CL_EXITHANDLER.
EXIT_NAME: The name of the BAdI definition is assigned to this parameter.

NULL_INSTANCE_ACCEPTED: Whenever the value X is assigned to this parameter, no instance is created if there are no active implementations for this BAdI definition. In this case, the INSTANCE parameter has the value NULL. Using this parameter implies that the method calls of this BAdI may only be called under the condition that this instance is not NULL. The query if not is initial. is necessary in this case.

Notes on UsageThe instance generated through the factory method should be declared as globally as possible or generally be passed as a parameter to ensure that the initialization process must be run as rarely as possible – just once would be best. In no case should you discard the instance as soon as it is generated or repeatedly run the initialization process in a loop.

Within the adapter class interface, required database accesses are buffered locally, so that each access is executed once only. However, repeated initialization makes the buffer useless and dramatically reduces performance.

Due to the local buffering, you can call Business-Add-In methods without having to expect considerable performance restrictions, even if no active implementations exist.

Also, if the definition of the Business-Add-In is filter-dependent, a single instance is sufficient.
However, you should not do without initialization altogether. Even if you could call static methods of the implementing class of the Business-Add-In implementation without an instance, you would lose the benefit of performance improvement through the Business-Add-Ins and the possibility of multiple use. If you switch the method type in the interface from the static method to the instance method at any time in the future, many code adjustments are required. In addition, you can no longer use default code that is provided

Implementing Methods Using the Formula Builder

Use 
You can use the Formula Builder to implement methods for Business Add-Ins without writing a single line of ABAP code. The methods are implemented by means of socalled formulas.

This type of implementation does not require you to have programming knowledge. However, the functions it offers are more restricted than if you implement a method by writing ABAP code. If the range of functions provided by the Formula Builder is not sufficient, you can change the implementation type of the method at any time.

Features
A formula can consist of the following steps:

· Condition
You define a Boolean formula expression whose result can be true or false. This formula expression is a logical condition based on the importing and changing parameters of the method. Depending on whether the condition is true or false, the system triggers different steps. If you do not specify a dependent step for one of these two possibilities, the system continues with the next superior step.

· Substitution
The system replaces the value of a specific parameter with another value which you define as a constant value or by means of a mathematic formula. Substitution is only possible if the method contains changing, exporting or returning parameters.

· Message
The system issues a message. All messages issued are collected in a log table. You define the message variables as constant values or by means of mathematic formulas. The system can only issue a message if you created a log table during method definition.

· ExceptionThe system exits the method. No further steps are executed, and the application program continues in accordance with the exception defined. You can additionally display a message whose variables you define as constant values or by means of mathematic formulas. An exception can only be triggered if the method contains exceptions.

A formula editor is available which you can use to enter formula expressions. After starting the formula editor, you can display information on how to use it by choosing the pushbutton next to the status display (traffic light).

Activities
You implement the method using the BAdI Builder. For information on this topic, see Implementing Business Add-Ins. To implement a method as a formula, choose the Formula implementation type on the Interface tab. Double-clicking the method name takes to to the Formula Builder: BadI Implementation screen.

You can change the implementation type of the method on the Interface tab. You can implement a method both using a formula and using ABAP code. At the runtime of the application program, the system executes the implementation type currently chosen.

You create the necessary steps in the left section of the screen. To do this, choose and then select the appropriate step type from the dropdown list. Using the other icons available or the context menu (which you can call by clicking the right mouse button), you then determine the arrangement and the descriptions of the steps. You can also copy steps to use them as templates for other steps, or you can delete individual steps.

To specify the parameters for the individual steps, double-click the corresponding entry in the left section of the screen. You then enter the data required in the right section of the screen.

Formulas are transported automatically.

Tuesday, 8 May 2012

How to attach PDF file into a Material(MM01)?



1.Go to MM02
2.Click on System
3.Service for object
4.click "attachment list".
5.Doble click in Title list.
6.The attached file will be display.
7. Save..
SAP ABAP INTERVIEW QUESTION PART-1


Enhancements:

Q1: What is the reason for using enhancements?
A1: Normal programs don’t give us all the functionalities we may need, so to fix this we can use the R/3 enhancements that will permit us to insert our particular functionality to any normal SAP program.

Q2: What is the meaning of customer development?
A2: Customer development generates objects particular to the customers in their name range.

Q3: What weaknesses do we find when using modification?
A3: One of the weaknesses is that we could have errors when standard code is modified. This automatically leads to a higher amount of work when software upgrades are made.

Q4: Why should we choose to make modifications?
A4: Customer exits don’t exist in every screen and program from R/3, and because they can be used just if they are already existing in SAP R/3, sometimes we must choose to make modifications.

Q5: What is the meaning of a screen exit?
A5: Screen exits means to add fields to R/3 screens, SAP generates screen exits by deploying particular sub screen areas in a normal R/3 screen and then invoking customer subscreens from the normal flow logic of dynpro.

Q6: What is the way in which exit organizing is made by SAP?
A6: An organizing exit package of SAP is also found under the name of SAP enhancements and every SAP enhancement can have several particular exits.

Q7: What is the meaning of user exits, how are they written and which measures do we have to take for prevention?
A7: In the default standards of SAP we can find the user defined functionalities, we can find a Sap program in which a customer personal program may be invoked. Unlike customer exits. user exits can permit the developers to enter and change the parts of the program and also the objects. When upgrade is made , every user exit has to be verified for conformation to the standard system. The user exits can use INCLUDES, case in which Customizing makes the management. We have to search for those customer enhancements from a specific development class.

Q8: Can we classify the enhancements by type?
A8: Yes they can be classified in: a) enhancements that use customer exits and b) enhancements of the elements in the ABAP/4 Dictionary.
a)      The standard software doesn’t incorporate all the requirements of the customer, but they can be contained as empty ‘shells’ that can be changed by the customers by inserting their personal codes. The enhancements can refer to menus, screens or programs, the compatibility being assured. This means that in SAP guarantees that the compatibility will be maintained even when passing from standard software to exit and the interface invoking the exit (they will be kept for future versions too).
b)      These are enhancements like table appends or text enhancements or field exits (supplementary coding for data elements).

Q9: What is the meaning of SSCR?
A9: The SAP Software Change Registration or SSCR is the operational that makes possible the registration of every manual change of the SAP source coding and objects of SAP Dictionary.

Q10: What are the strong features of enhancements?
A10: They don’t have an impact on the standard source code of SAP, they don’t have an impact on software upgrades.

Q11: Which are the main types of customer exits?
A11: The main types of customer exits are: the screen exits, the menu exits, the function module exits and the keyword exits.

Q12: What is the meaning of function module exit?
A12: The function module exit is meting supplementary functionality in R/3 programs having a big role in the menu exits and the screen exits.

Q13: What is the meaning of an add-on project?
A13: For using in the best way the exits we find in the standard R/3 programs we have to make an add-on project, that makes possible organizing the enhancement packs and the exits we desire to use. An add-on project makes possible to met add-on functionality on the texts from the SAP enhancements.

Q14: What is the meaning of a keyword exit?
A14: With a keyword exit we can give to the data elements of the keywords from the ABAP/4 dictionary some documentation. This documentation will be shown by the system every time users hit the F1 key for obtaining help online regarding a screen field.

Q15: What is the meaning of a menu exit?
A15: Menu exits mean when we add item on the pull down menus.

Q16: How can we separate enhancements from modifications?
A16: When we create modifications on the functionality of the SAP standard we say modifications. When we put supplementary functionality on the standard functionality of SAP we say enhancements.

Q17: What is the meaning of customizing?
A17: When we configure the system parameters through the SAP interface we mean customizing.

A18: How can we classify the methods in which we generate modifications in the standard software of SAP?
A18: We can make: enhancements to the standard of SAP, modifications to the standard of SAP, customizing and customer development.
Interview questions on enhancements in abap sap abap enhancements interview questions enhancements in sap abap interview questions abap enhancements interview questions
SAP Memory
SAP memory is the memory area where all main sessions with in the SAP GUI have the access. We can use SAP memory either

to pass data from one program to other within the session, or to pass data from one session to other.  Application programs that

use SAP memory must do so using SPA/GPA parameters (also known as SET/GET parameters). These parameters can be set

either for a particular user or for a particular program using the SET PARAMETER statement. Other ABAP programs can then retrieve

the set parameters using the GET PARAMETER statement. The most frequent use of SPA/GPA parameters is to fill input fields on

screens
ABAP/4 Memory
ABAP memory is the memory area that all ABAP programs within the same internal session can access using the EXPORT and

IMPORT statements. Data within this area remains intact during a whole sequence of program calls. To pass data
to a program which you are calling, the data needs to be placed in ABAP memory before the call is made. The internal session of

the called program then replaces that of the calling program. The program called can then read from the ABAP memory. If control is

then returned to the program which made the initial call, the same process operates in reverse.
SAP memory 
The SAP memory, otherwise known as the global memory, is available to a user during the entire duration of a terminal session. Its

contents are retained across transaction boundaries as well as external and internal sessions. The SET PARAMETER and GET

PARAMETER statements allow you to write to, or read from, the SAP memory.  
ABAP/4 memory 
The contents of the ABAP/4 memory are retained only during the lifetime of an external session (see also Organization of

Modularization Units). You can retain or pass data across internal sessions. The EXPORT TO MEMORY and IMPORT FROM

MEMORY statements allow you to write data to, or read data from, the ABAP memory.
Views
Data about an application object is often distributed on several tables. By defining a view, you can define an application-dependent view
that combines this data. The structure of such a view is defined by specifying the tables and fields used in the view. Fields that are not
required can be hidden, thereby minimizing interfaces. A view can be used in ABAP programs for data selection.
The data of a view is derived from one or more tables, but not stored physically. The simplest form of deriving data is to mask out one or
more fields from a base table (projection) or to include only certain entries of a base table in the view (selection). More complicated views
can comprise several base tables, the individual tables being linked with a relational join operation. See also Join, Projection and Selection.
The base tables of the view must be selected in the first step of a view definition. In the second step, these tables must be linked by
defining the join conditions. It is also possible to use the join condition from a foreign key defined between the tables (see  Foreign Key
Relationship and Join Condition). In the third step, you must select the fields of the base tables to be used in the view. Selection conditions
that restrict the records in the view can be formulated in the fourth step.
Four different view types are supported. These differ in the way in which the view is implemented and in the methods permitted for
accessing the view data.
Database views are implemented with an equivalent view on the database.
Projection views are used to hide fields of a table (only projection).
Help views can be used as selection method in  search helps.
Maintenance views permit you to maintain the data distributed on several tables for one application object at one time.
Database views implement an inner join. The other view types implement an outer join (see Inner and Outer Join).
The join conditions for database views can be formulated using equality relationships between any base fields. The join conditions for the
other view types must be obtained from existing foreign keys. Tables therefore can only be combined in a maintenance view or help view if
they are linked to one another with foreign keys.
The maintenance status defines whether you can only read data with the view or whether you can also insert and change data with it.
Creating a Database View
Procedure
Enter an explanatory short text in the field Short text.
You can for example find the view at a later time using this short text.
Define the tables to be included in the view in the Tables field of the Tables/Join conditions tab page.
Keep in mind that you can only include transparent tables in a database view.
Link the tables with join conditions.
If there are suitable foreign keys between the tables, you should copy the join conditions from these foreign keys (see  Foreign Key
Relationships and Join Conditions).
Place the cursor on a table name and choose Relationships. All foreign keys to other tables defined for this table are displayed. Select the
foreign keys and choose Copy. The join condition is now derived from the definitions in the foreign key.
If you only want to see the foreign key relationship existing between two tables, you must first select these two tables (click on the first
column of the input area Tables) and then choose Relationships.
On the View fields tab page, select the fields that you want to copy to the view.
Choose Table fields. All the tables contained in the view are displayed in a dialog box. Select a table. All the fields contained in this table are
displayed. You can copy fields by selecting them in the first column and choosing Copy.
You can also include an entire table in the view (see Includes in Database Views).
On the Selection conditions tab page, you can (optionally) formulate restrictions for the data records to be displayed with the view (see
Maintaining Selection Conditions for Views).
The selection conditions define the data records that can be selected with the view.
With Goto ® Technical settings, you can (optionally) maintain the technical settings of the database view.
You can define whether and how the database view should be buffered here. Proceed as for the technical settings of a table (see
Maintaining Technical Settings). Note that only the settings for buffering can be maintained for database views.
On the Maintenance status tab page, select the maintenance status of the database view.
If the view contains more than one table, the maintenance status read only cannot be altered.
Save your entries. You are asked to assign the view a development class.
You can change this development class later with Goto ® Object directory entry.
Choose.
Result
When a database view is activated, the corresponding view is also automatically created in the database if the base tables of the view
were already created there.
At activation, a log is written; it can be displayed with Utilities ® Activation log. If errors or warnings occurring when the view was activated,
they are displayed directly in the activation log.
If the base tables are not yet created in the database, this is recorded in the activation log. The view is nevertheless activated in the ABAP
Dictionary. In this case you can create the relevant view on the database later with the database utility.
Other Options
Create documentation: You can create information about using the view with Goto ® Documentation. This documentation is also output for
example when you print the view.
Change data element of a view field: Select the Mod (Modify) column in the View fields tab page. The Data element field is now ready for
input. You can enter a data element that refers to the same domain as the data element of the assigned table field here. Cancel the Mod
flag if you want to use the data element of the assigned table field again.
Display view data: With Utilities ® Contents you can determine which data can be selected with the view.
Display create statement: With Extras ® CREATE statement you can display how the view was created in the database. The statement that
was executed when the version of the view currently being edited was created in the database is displayed.
Check the definition of the view in the database: With Utilities ® Database object ® Check you can determine whether the definition of the
view in the database is consistent with the active version of the view. With Utilities ® Database object ® Display you can display the
definition of the view in the database.
Check the runtime object of the view: With Utilities ® Runtime object ® Check you can determine whether the definition of the view in the
ABAP Dictionary maintenance screen is identical to the specifications in the runtime object of the view. With Utilities ® Runtime object ®
Display you can display the runtime object of the view.
Creating Maintenance Views
Procedure
Enter an explanatory short text in the field Short text.
You can for example find the view at a later time using this short text.
Enter the primary table of the view under Tables in the Tables/Join conditions tab page.
Only those tables that are linked with the primary table (indirectly) with a foreign key can be included in the maintenance view.
If required, include more tables in the view. In a maintenance view you can only insert tables that are linked to one another with foreign
keys.
Place the cursor on the primary table and choose Relationships. All existing foreign key relationships of the primary table are displayed.
Select the required foreign key and choose Copy. The secondary table used in such a foreign key is included in the view. The join conditions
derived from the foreign keys (see Foreign Key Relationship and Join Condition) are displayed.
You can also insert tables that are linked by foreign key with one of the secondary tables that was already inserted. To do this, place the
cursor on the secondary table and choose Relationships. Then proceed as described above.
For maintenance and help views, there are certain restrictions on the foreign keys with which the tables can be included in the view (see
Restrictions for Maintenance and Help Views). The foreign keys violating these conditions are displayed at the end of the list under the
header Relationships with unsuitable cardinality.
On the View fields tab page, select the fields that you want to copy to the view.
Choose Table fields. All the tables contained in the view are displayed in a dialog box. Select a table. The fields of the table are now
displayed in a dialog box. You can copy fields by selecting them in the first column and choosing Copy.
All key fields of the primary table must be included in a maintenance view. In addition, all key fields of secondary tables that are not
involved in the foreign key (that is, which are not linked via a join condition to a key field already included in the view) must be included in
the view.
This ensures that the records inserted with a maintenance view can be written correctly in the tables contained in the view.
On the Selection conditions tab page, you can (optionally) formulate restrictions for the data records that can be displayed with the view
(see Maintaining Selection Conditions for Views).
The selection conditions define the data records that can be selected with the view.
In the Maintenance status tab page, define the maintenance status of the view.
The maintenance status defines how you can access the view data with the standard maintenance transaction (SM30).
Choose.
At activation, a log is written; it can be displayed with Utilities ® Activation log. If errors or warnings occurring when the view was activated,
the activation log is automatically displayed.
Go to Transaction SE54 with Environment ® Tab.maint.generator.
From the view definition you can generate maintenance modules and maintenance interfaces that distribute the data entered with the view
to the base tables of the view. You can find more information in Creating a Maintenance Dialog.
Other Options
Recording documentation: You can create information about using the view with Goto ® Documentation. This documentation is output for
example when you print the view.
Changing the data element of a view field: Select column Mod (modification) for the view field. The Data element field is now ready for input.
You can enter a data element that refers to the same domain as the data element of the assigned table field here. Cancel the Mod flag if
you want to use the data element of the assigned table field again.
Enter the delivery class of the view: In the Maintenance status tab page, select the delivery class of the maintenance view. If you assign
the delivery class G or E to the view, you must also maintain a customer namespace (key block) for the view entries. To navigate to the
appropriate maintenance transaction, choose Define Customer Namespace.
Entering the maintenance attributes of the view field: In the View fields tab page you can define the Maintenance Attributes of the view
field in column F.
Check functions: With Extras ® Runtime object ® Check you can determine whether the definition of the view in the ABAP Dictionary
maintenance screen is identical to the definitions in the runtime object of the view. With Extras ® Runtime object ® Display you can display
the runtime object of the view.
Deleting Views
Prerequisites
You should only delete a view if it is no longer used in programs.
Procedure
In the initial screen of the ABAP Dictionary, select object type View and enter the name of the view.
With , check if the view is still being used in programs.
Choose .
A dialog box appears in which you are asked to confirm the deletion request.
Confirm the deletion request.
Result
The view is deleted in the ABAP Dictionary and in the database.
defining selection conditions in sap views sap table view tutorial sap table view show hide .


bapi



2. Program a RFC enabled BAPI function module for each method
3. Create a Business object for the BAPI in the BOR
4. Documentation the BAPI
5. Generate ALE interface for aynchronous BAPIs
6. Generate and release
Tip: You can use the BAPi explorer to get a step by step 

instruction/checklist in how to create a BAPI. In the BAPI explorer 

select the Project tab.
Methods
If the BAPI to be implemented is a standardized BAPI, use the generic names, for example, Get List, Get Detail.
The method name must be in English (maximum 30 characters).
The individual components of a BAPI name are separated by the use of upper and lower case. Example: Get List
Underscores ("_") are not allowed in BAPI names.
Each BAPI has a return parameter that is either an export parameter or an export table.
So that customers can enhance BAPIs, each BAPI must have an ExtensionIn and an ExtensionOut parameter.
Parameters
If standardized parameters are used, you have to use the names specified for standardized parameters.
BAPI parameter names should be as meaningful as possible. Poorly chosen names include abbreviations and technical names (e.g. "flag", table 

names, etc.).
The parameter and field names must be in English with a maximum of 30 characters.
The components of a parameter name in the BOR are separated by upper and lower case letters to make them easier to read. Example: 

CompanyCodeDetail
Values that belong to each other semantically should be grouped together in one structured parameter, instead of using several scalar 

parameters.
For ISO-relevant fields (country, language, unit of measure, currency), additional fields for ISO codes are provided.
Unit of measure fields must accompany all quantity fields and currency identifiers must accompany currency amount fields.
Standardized BAPIs
Some BAPIs provide basic functions and can be used for most SAP business object types. These BAPIs should be implemented the same for all 

business object types. Standardized BAPIs are easier to use and prevent users having to deal with a number of different BAPIs. Whenever 

possible, a standardized BAPI must be used in preference to an individual BAPI.
The following standardized BAPIs are provided:
Reading instances of SAP business objects
GetList ( )
 With the BAPI GetList you can select a range of object key values, for example, company codes and material numbers.
The BAPI GetList() is a class method.
GetDetail() With the BAPI GetDetail() the details of an instance of a business object type are retrieved and returned to the calling program. The 

instance is identified via its key. The BAPI GetDetail() is an instance method.
BAPIs that can create, change or delete instances of a business object type
The following BAPIs of the same object type have to be programmed so that they can be called several times within one transaction. For example, 

if, after sales order 1 has been created, a second sales order 2 is created in the same transaction, the second BAPI call must not affect the 

consistency of the sales order 2. After completing the transaction with a COMMIT WORK, both the orders are saved consistently in the database.
Create( ) and
CreateFromData( ) The BAPIs Create() and CreateFromData() create an instance of an SAP business object type, for example, a purchase order. 

These BAPIs are class methods.
Change( ) The BAPI Change() changes an existing instance of an SAP business object type, for example, a purchase order. The BAPI Change () is 

an instance method.
Delete( ) and Undelete( ) The BAPI Delete() deletes an instance of an SAP business object type from the database or sets a deletion flag.
The BAPI Undelete() removes a deletion flag. These BAPIs are instance methods.
Cancel ( ) Unlike the BAPI Delete(), the BAPI Cancel() cancels an instance of a business object type. The instance to be cancelled remains in the 

database and an additional instance is created and this is the one that is actually canceled. The Cancel() BAPI is an instance method.
Add<subobject> ( ) and Remove<subobject> ( ) The BAPI Add<subobject> adds a subobject to an existing object instance and the BAPI and 

Remove<subobject> removes a subobject from an object instance. These BAPIs are instance methods.  
BAPIs for Mass Data Processing
The BAPIs listed above for creating and changing data can also be used for mass processing. For more information see BAPIs for Mass Data 

Transfer [Extern]
BAPIs for Replicating Business Object Instances
Replicate( ) and SaveReplica( ) The BAPIs Replicate() and SaveReplica() are implemented as methods of replicable business object types. They 

enable specific instances of an object type to be copied to one or more different systems. These BAPIs are used mainly to transfer data between 

distributed systems within the context of Application Link Enabling (ALE). These BAPIs are class methods.
Other Less Used Standardized BAPIs
Programming GetStatus() BAPIs [Extern]
Programming ExistenceCheck() BAPIs [Extern]
Standardized Parameters
There are some parameters that can be created for various BAPIs because they contain the same or the equivalent data in all BAPIs. They should 

be implemented the same in all BAPIs.
Address parameters Specific reference structures are defined for address parameters in BAPIs. You should copy these structures to use in your 

BAPI, especially if the underlying object type uses the central address management (CAM).
Change Parameters In BAPIs that cause database changes (for example, Change() and Create() BAPIs) you must be able to distinguish between 

parameter fields that contain modified values and parameter fields that have not been modified. This distinction is made through the use of 

standardized parameters.
Extension parameters The parameters ExtensionIn and ExtensionOut provides customers with a mechanism that enables BAPIs to be enhanced 

without modifications.
Return Parameters Each BAPI must have an export return parameter for returning messages to the calling application. To provide application 

programmers with a consistent error handling process for BAPI calls, all return parameters must be implemented in the same, standardized way.
Selection Parameters Standardized selection parameters are used in BAPIs that can be used to search for specific instances of a business object 

type (e.g. in GetList() ). These parameters enable the BAPI caller to specify the relevant selection criteria.
Test Run Parameters The parameter TestRun is used in write BAPIs (Create() and Change() ), to check the entries for the object instance in the 

database before actually creating the object instance. The creation of the object instance is only simulated and data is not updated.
Text Transfer Parameters To transfer BAPI documentation texts (e.g. the documentation of a business object type), you have to create 

standardized text transfer parameters.
Important things to remember..
It is important to follow the guidelines below when develop9ng BAPIs:
BAPIs must not contain CALL TRANSACTIO or SUBMIT REPORT
BAPIs must not invoke a COMMIT WORK. Instead use the BAPI Transaction Commit to execute the commit after the BAPI has executed.
BAPI structures must not use includes.
There should be no functional dependencies between two BAPIs
BAPIs must perform there own authorization check
BAPIs should not use dialogs
BAPIs must not cause the program to abort or terminate. Relevant messages must be communicated through the return parameter.
BAPI/ALE Integration
when you use the BAPIs for asynchronous messaging, the application in the sending system calls the generated ALE IDoc interface instead of the 

BAPI.
Asynchronous BAPIs use the ALE interface this way:
Creates an IDOC from the BAPI data
sends the IDOC to the target system
receives the IDOC in the target system, creates the BAPI data from the IDoc and calls the BAPI
An ALE interface for a BAPIs is created in transaction BDBG
sap BAPIs tutorial bapi tutorial pdf bapi material get detail with select-options bapi sap tutorial







STEP 1 – Define a structures for the BAPI
STEP 2 – Write Function Module
STEP 3 – Create the API Method Using the BAPI 5 WIZARD
STEP 4 – Final steps
About the Example
This BAPI reads system status for a production order from table JEST and system status 

text fro table TJ02T
Name                                                      ZGetOrderStatus
Function group                                      ZBAPISTATUS
Function module:                                   Z_BAPI_GET_ORDER_STATUS
Import parameters:                              ORDER_STATUS_IMPORT type 

ZBAPI_ORDER_STATUS_IMPORT:     AUFNR Order number (Keyfield)
                                     SPRAS Language ExcludeInactive – Checkbox –                                        

                                      Exclude  inactive status
Tables                     
T_BAPISTAT type ZBAPISTAT:
 OBJNR like JEST-OBJNR
  STAT like JEST-STAT
  INACT like JEST-INACT
  TXT04 like TJ02T-TXT04
  TXT30 likeTJ02T-TXT30
Export parameters
RETURN like BAPIRETURN
STEP 1 – Define a structures for the BAPI
In this step structures for the parameters and tables of the function module used for 

the BAPI are defined.
Use Data type -> Structure
Define the following structures:
ZBAPI_ORDER_STATUS_IMPORT which contains the following fields:
ORDERID Order number (Key field)
SPRAS Language
ExcludeInactive – Checkbox – Exclude inactive status
ZBAPISTAT:
OBJNR like JEST-OBJNR
STAT like JEST-STAT
INACT like JEST-INACT
TXT04 like TJ02T-TXT04
TXT30 likeTJ02T-TXT30
Important note:
You will have to define a structure for every parameter in the BAPI. You cannot use 

the same structures used in existing applications because BAPI structures are frozen 

when BAPIs are released and then there are restrictions on changing them.
ZBAPI_ORDER_STATUS_IMPORT

STEP 2 – Write Function Module
Important notes:
Each BAPI must have its own function group.
Under the attributes tab remember to select Processing Type Remote Enabled 

module, otherwise the function module cannot be invoked via RFC and used as a 

BAPI
Import/Export parameters can only be BY VALUE for an RFC enabled function 

module
We are only creating one BAPI in this example, but you can create related BAPIs 

in the same function pool, so they will be able to share global data.

Code
Notes:
The subroutine SET_RETURN_MESSAGE is a standard routine used for BAPIs that use the BAPIRETURN structure
in form Z_BAPI_GET_ORDER_SYSTEM_STATUS there is a test IF 1 = 2. If the test is true a message is displayed. The condition will obviously never be true, and we will never want to display a message in a BAPI. The reason why it 

is included is, that it create a reference for the message, so that the WHERE USED functionality can be used for the message. This is the SAP standard way to handle it, copied from the Company Code GetList BAPI.
INCLUDE LZBAPISTATUSUXX
*****************************************************************
*   THIS FILE IS GENERATED BY THE FUNCTION LIBRARY.             *
*   NEVER CHANGE IT MANUALLY, PLEASE!                           *
*****************************************************************
INCLUDE LZBAPISTATUSU02.
"Z_BAPI_GET_ORDER_SYSTEM_STATUS
INCLUDE LZBAPISTATUSTOP – Global data
FUNCTION-POOL ZBAPISTATUS.                  "MESSAGE-ID Z3
Types:
begin of Type_tj02t,
istat  like tj02t-istat,
txt04  like tj02t-txt04,
txt30  like tj02t-txt30,
end of type_tj02t.
DATA:
* Declarations for TABLE parameter
T_BAPISTAT like ZBAPISTAT occurs 0,
G_BAPISTAT like ZBAPISTAT,
* Table for object texts
t_tj02t    type type_tj02t occurs 0,
g_tj02t    type type_tj02t.
* Structure for return messages
DATA:
BEGIN OF MESSAGE,
MSGTY LIKE SY-MSGTY,
MSGID LIKE SY-MSGID,
MSGNO LIKE SY-MSGNO,
MSGV1 LIKE SY-MSGV1,
MSGV2 LIKE SY-MSGV2,
MSGV3 LIKE SY-MSGV3,
MSGV4 LIKE SY-MSGV4,
END OF MESSAGE.
INCLUDE LZBAPISTATUSF01 – Subroutines
***INCLUDE LZBAPISTATUSF01 .
*———————————————————————-*
*&———————————————————————*
*&      Form  SET_RETURN_MESSAGE
*&———————————————————————*
* This routine is used for setting the BAPI return message.
*
* The routine is a standard routine for BAPIs that handles the message
* structure for the BAPIRETURN structure. It has been copied from the
* BAPI Company Code Getlist
*———————————————————————-*
*      –>P_MESSAGE  text
*      <–P_RETURN  text
*———————————————————————-*
form SET_RETURN_MESSAGE USING    VALUE(P_MESSAGE)   LIKE MESSAGE
CHANGING P_RETURN  LIKE BAPIRETURN.
CHECK NOT MESSAGE IS INITIAL.
CALL FUNCTION 'BALW_BAPIRETURN_GET'
EXPORTING
TYPE       = P_MESSAGE-MSGTY
CL         = P_MESSAGE-MSGID
NUMBER     = P_MESSAGE-MSGNO
PAR1       = P_MESSAGE-MSGV1
PAR2       = P_MESSAGE-MSGV2
PAR3       = P_MESSAGE-MSGV3
PAR4       = P_MESSAGE-MSGV4
*          LOG_NO     = ' '
*          LOG_MSG_NO = ' '
IMPORTING
BAPIRETURN = P_RETURN
EXCEPTIONS
OTHERS     = 1.
endform.                    " SET_RETURN_MESSAGE
FUNCTION Z_BAPI_GET_ORDER_STATUS
FUNCTION z_bapi_get_order_system_status.
*"———————————————————————-
*"*"Local interface:
*"  IMPORTING
*"     VALUE(I_AUFNR) TYPE  AUFNR
*"     VALUE(I_SPRAS) TYPE  SPRAS DEFAULT SY-LANGU
*"     VALUE(I_EXCLUDEINACTIVE) TYPE  CHAR1 OPTIONAL
*"  EXPORTING
*"     VALUE(RETURN) TYPE  BAPIRETURN
*"  TABLES
*"      T_BAPISTAT STRUCTURE  ZBAPISTAT
*"———————————————————————-
**
*"Local interface:
*"  IMPORTING
*"     VALUE(I_AUFNR) TYPE  AUFNR
*"     VALUE(I_SPRAS) TYPE  SPRAS DEFAULT SY-LANGU
*"     VALUE(I_EXCLUDEINACTIVE) TYPE  CHAR1 OPTIONAL
*"  EXPORTING
*"     VALUE(RETURN) TYPE  BAPIRET2
*"  TABLES
*"      T_BAPISTAT STRUCTURE  ZBAPISTAT
*"———————————————————————-
DATA:
l_aufnr LIKE afko-aufnr,
l_objnr LIKE jest-objnr.
********************************************
* Check if order exists
********************************************
SELECT SINGLE aufnr
FROM afko
INTO  l_aufnr
WHERE aufnr = BAPI_ORDER_STATUS_IMPORT-orderid.
IF sy-subrc NE 0.
CLEAR message.
message-msgty = 'E'.
message-msgid = 'Z3'.
message-msgno = '000'.
message-msgv1 = BAPI_ORDER_STATUS_IMPORT-orderid.
PERFORM set_return_message USING    message
  CHANGING return.
IF 1 = 2.
*     The only reason to include this statement, that will obviously
*     never execute, is that it will create a referecence so that you
*     can find out where a particular message is being used. This
*     functionality is used by the BAPIs programmed by SAP
MESSAGE e000(z3).
ENDIF.
ENDIF.
CHECK return IS INITIAL.
********************************************
* Read order status
********************************************
CONCATENATE 'OR' BAPI_ORDER_STATUS_IMPORT-orderid INTO l_objnr.
IF BAPI_ORDER_STATUS_IMPORT-i_excludeinactive = 'X'.
SELECT objnr stat inact
FROM  jest
INTO  TABLE t_bapistat
WHERE objnr = l_objnr AND
inact <> 'X'.
ELSE.
SELECT objnr stat inact
FROM  jest
INTO  TABLE t_bapistat
WHERE objnr = l_objnr.
ENDIF.
IF sy-subrc <> 0.
*   No object status found
CLEAR message.
message-msgty = 'E'.
message-msgid = 'Z3'.
message-msgno = '001'.
message-msgv1 = BAPI_ORDER_STATUS_IMPORT-orderid.
PERFORM set_return_message USING    message
  CHANGING return.
IF 1 = 2.
MESSAGE e001(z3).
ENDIF.
ENDIF.
CHECK return IS INITIAL.
********************************************
* Read order status texts
********************************************
SELECT istat txt04 txt30
FROM tj02t
INTO TABLE t_tj02t
FOR ALL ENTRIES IN t_bapistat
WHERE istat = t_bapistat-stat AND
spras = BAPI_ORDER_STATUS_IMPORT-i_spras.
SORT t_tj02t BY istat.
LOOP AT t_bapistat INTO g_bapistat.
READ TABLE t_tj02t
WITH KEY istat = g_bapistat-stat BINARY SEARCH
INTO g_tj02t.
IF sy-subrc = 0.
MOVE:
g_tj02t-txt04 TO g_bapistat-txt04,
g_tj02t-txt30 TO g_bapistat-txt30.
MODIFY t_bapistat FROM g_bapistat TRANSPORTING txt04 txt30.
ENDIF.
ENDLOOP.
ENDFUNCTION.

TEP 3 – Create the API Method Using the BAPI WIZARD
The BAPI wizard is used toTo expose the remote function module as a BAPI. The wizard will generate some additional code, so the 

function module is a valid method of the BOR. This allows the BAPi to be called as a workflow method in addition to be called by an 

outside program.
Note: Each functionmodule corresponds to a method in the BOR
Go to the Busines Object Builder SWO1.
You can either create the new Object type as a subtype of an existing business object or create a new business object from scratch. In 

this example it would be obvious to create the Object type as a subtype of BUS2005 Production order. However, to illustrate how to 

create a new Object type from scratch, we will do this.
In the Object/Interface type field write the name of the new Business Object: ZORDERSTAT. Press enter and fill in the additional fields 

necessary to create the object type.
Supertype: Not relevant because we are creating our object from scratch
Program. This is the name of the program where the wizard generates code for the Object type, NOT the function module we craeted 

earlier. The program name must not be the name of an existinbg program.
Press enter and create the new business object. Note that when you create the business object a standard interface, an attribute ObjectType and the methods ExistenceCheck and Display are automatically generated. These cannot be changed !
The next step is to add the Z_BAPI_GET_ORDER_STATUS method to the business object. Select Utillities -> API methods -> Add method and write the name of the functionmodule in the dialogbox. Next the dialogbox show below will be shown. This is the start screen of the BAPI wizard. Proceed with wizard by pressing the  button.

After you have finished the wizard, tyou will notice that the ZGetOrderStatus has been added to 

the business object:
You can doubleclick on the method to see its properties. To use the business object you must change the Object type status to Implemented. Use menu Edit->Change releases 

status->Object type->To implemented. No you can test thge object (Press F8).
Note that the BAPI wizard has added a wrapper class for the function module so it can be sued as method in the business object. Choose menu Goto->Program to display the 

program:
*****           Implementation of object type ZORDERSTAT           *****
INCLUDE <OBJECT>.
BEGIN_DATA OBJECT. " Do not change.. DATA is generated
* only private members may be inserted into structure private
DATA:
" begin of private,
"   to declare private attributes remove comments and
"   insert private attributes here …
" end of private,
KEY LIKE SWOTOBJID-OBJKEY.
END_DATA OBJECT. " Do not change.. DATA is generated
BEGIN_METHOD ZGETORDERSTATUS CHANGING CONTAINER.
DATA:
BAPIORDERSTATUSIMPORT LIKE ZBAPI_ORDER_STATUS_IMPORT,
RETURN LIKE BAPIRETURN,
TBAPISTAT LIKE ZBAPISTAT OCCURS 0.
SWC_GET_ELEMENT CONTAINER 'BapiOrderStatusImport'
BAPIORDERSTATUSIMPORT.
SWC_GET_TABLE CONTAINER 'TBapistat' TBAPISTAT.
CALL FUNCTION 'Z_BAPI_GET_ORDER_STATUS'
EXPORTING
BAPI_ORDER_STATUS_IMPORT = BAPIORDERSTATUSIMPORT
IMPORTING
RETURN = RETURN
TABLES
T_BAPISTAT = TBAPISTAT
EXCEPTIONS
OTHERS = 01.
CASE SY-SUBRC.
WHEN 0.            " OK
WHEN OTHERS.       " to be implemented
ENDCASE.
SWC_SET_ELEMENT CONTAINER 'Return' RETURN.
SWC_SET_TABLE CONTAINER 'TBapistat' TBAPISTAT.
END_METHOD.

When the Business object has been checked and the documentation created, the follwing steps must be carried out:
Release the BAPI function module (in the Function Builder).
Release the business object type (in the BOR ObjectType -> Change release status to -> Implemented ).
Release the BAPI as a method in the BOR (Release the methods you has created – Set the cursor on the method then
Edit -> Change release status -> Object type component -> To released )
For potential write BAPIs: Release the IDoc and its segments
You can now display the BAPI in the BAPI Explorer:

bapi sd sap how to use two tables in sap table control wizard why we release object and method in bapi
……………………………………………………..


Lock and Unlock Purchase Documents ABAP

Lock Purchase document:
CALL FUNCTION 'ENQUEUE_EMEKKOE'
EXPORTING
ebeln = w_ebeln
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.

Unlock Purchase document:

CALL FUNCTION 'DEQUEUE_EMEKKOE'
EXPORTING
ebeln = w_ebeln.

Lock Purchase Document item:

CALL FUNCTION 'ENQUEUE_EMEKPOE'
    EXPORTING
      ebeln          = w_ebeln
      ebelp          = w_ebelp
    EXCEPTIONS
      foreign_lock   = 2
      system_failure = 3.
Unlock Purchase Document item:

CALL FUNCTION 'DEQUEUE_EMEKPOE'
EXPORTING

ebeln = w_ebeln
ebelp = w_ebelp.



Function Modules for Secondary Indexes in SAP ABAP

Indexes are using the increase the performance in retrival of data access from database. The primary key fields are key fields of the table and point to non key fields. The secondary indexes are non key fields in table.

DD_DROP_INDEX  - Deletes the index of the table 
DD_CREATE_INDEX  - Create primary and secondary index



Get date by using Week using FM WEEK_GET_FIRST_DAY in SAP ABAP

DATA: week(2) TYPE c,
            year(4) TYPE c,
            week_in TYPE SCAL-WEEK,
            date_out TYPE SCAL-DATE.

week = '42'.
year = sy-datum(4).

CONCATENATE year week INTO week_in.

CALL FUNCTION week_get_first_day
  EXPORTING
    WEEK         =   week_in
  IMPORTING
    DATE          =   date_out.

WRITE: date_out.



Date convert from internal yyyymmdd to External dd/mm/yyyy ABAP

Convert Date from YYYYMMDD to DD/MM/YYYY in SAP ABAP:

parameter : v1(10) type c.
data: : v2 type sy-datum.

v2 = sy-datum.

write v2 dd/mm/yyyy to v1.

write: v1.


Convert OTF data into PDF in SAP ABAP

Use the following Function Module for Converting OTF data into PDF:    

CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_PDF'
      EXPORTING
        FORMAT_SRC            = 'OTF'
        FORMAT_DST            = 'PDF'
        DEVTYPE                   = 'PRINTER'
      CHANGING
        TRANSFER_BIN          = ' '
        CONTENT_TXT           = t_otf                      " OTF Data
        CONTENT_BIN            = t_objhex                 " PDF content 
        OBJHEAD                   = t_objhead
        LEN                             = w_length

Naming Conventions in ABAP Objects

Global Class               -   CL_<class name>
Interface                     -   IF_<Interface Name>
Local Classes             -  LCL_<class name>
Local Interface            -  LIF_<Interface Name>
Method Name            -  <method Name>
Events                        -  <Event Name>
Local type in Class     -  TY_<type name>
Data Definitions          -  <Variable name>
Constants                   -   CO_<constant name>
Importing Parameters -  IM_<parameter name>
Exporting Parameters -  EX_<parameter name>
Changing parameters -  CH_<parameter name>
Result                       -  RE_<result>


Convert ALV Grid Output into PDF in SAP ABAP

The following code used for Converting ALV grid output into PDF document:
DATA:
i_T100 TYPE T100 OCCURS 0,
pdf LIKE tline OCCURS 0.
DATA:
g_spool TYPE tsp01-rqident,
g_program TYPE sy-repid VALUE sy-repid.
 
TYPE-POOLS:slis.
DATA: w_print TYPE slis_print_alv.
DATA: p_file TYPE string.
p_file = 'C:\itab_to_pdf1.pdf'.
"START-OF-SELECTION.
START-OF-SELECTION.
SELECT * FROM T100 INTO TABLE i_T100 UP TO 100 ROWS.
w_print-print = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_program
i_structure_name = 'T100'
is_print = w_print
TABLES
t_outtab = i_T100.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
g_spool = sy-spono.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = g_spool
TABLES
pdf = pdf.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = p_file
filetype = 'BIN'
TABLES
data_tab = pdf.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_program
i_structure_name = 'T100'
TABLES
t_outtab = i_T100. "is_print = w_print
ENDIF.
ENDIF.
ENDIF.