Friday, February 24, 2017

SAP LUW (Logics Unit of Work) / Bundling Updates


LUW is a logical unit of work and is the span of time during which any transaction is updated completely and commited or thrown away(Roll Back). An Luw is nothing but a database LUW in database is updated from one screen to another screen within a transaction.

The Open SQL statements INSERTUPDATEMODIFY, and DELETE allow you to program database changes that extend over several dialog steps. Even if you have not explicitly programmed a database commit, the implicit database commit that occurs after a screen has been processed concludes the database LUW. The following diagram shows the individual database LUWs in a typical screen sequence:
This graphic is explained in the accompanying text
Under this procedure, you cannot roll back the database changes from previous dialog steps.
However, the database changes in individual dialog steps normally depend on those in other dialog steps, and must therefore all be executed or rolled back together. These dependent database changes form logical units, and can be grouped into a single database LUW using the bundling techniques listed below.
A logical unit consisting of dialog steps, whose changes are written to the database in a single database LUW is called an SAP LUW. Unlike a database LUW, an SAP LUW can span several dialog steps, and be executed using a series of different work processes. If an SAP LUW contains database changes, you should either write all of them or none at all to the database. To ensure that this happens, you must include a database commit when your transaction has ended successfully, and a database rollback in case the program detects an error. However, since database changes from a database LUW cannot be reversed in a subsequent database LUW, you must make all of the database changes for the SAP LUW in a single database LUW. To maintain data integrity, you must bundle all of you database changes in the final database LUW of the SAP LUW. The following diagram illustrates this principle:

This graphic is explained in the accompanying text
The bundling technique for database changes within an SAP LUW ensures that you can still reverse them. It also means that you can distribute a transaction across more than one work process, and even across more than one SAP system. The possibilities for bundling database changes within an SAP LUW are listed below:
The simplest form of bundling is to process a whole application within a single dialog step. Here, the system checks the user’s input and updates the database without a database commit occurring within the dialog step itself. Of course, this is not suitable for complex business processes. Instead, the SAP system contains the following bundling techniques.
Bundling using Function Modules for Updates
If you call a function module using the statement CALL FUNCTION ... IN UPDATE TASK, the function module is flagged for execution using a special update work process. This means that you can write the Open SQL statements for the database changes in the function module instead of in your program, and call the function module at the point in the program where you would otherwise have included the statements. When you call a function module using the IN UPDATE TASK addition, it and its interface parameters are stored as a log entry in a special database table called VBLOG.
The function module is executed using an update work process when the program reaches the COMMIT WORKstatement. After the COMMIT WORK statement, the dialog work process is free to receive further user input. The update work process is responsible for the update part of the SAP LUW. The statement COMMIT WORKcloses the SAP LUW for the dialog part of the program and starts the update. The SAP LUW is complete once the update process has committed or rolled back all of the database changes. Bundling using function modules is called Update.
For further information about how to create function modules for use in update, refer to Creating Function Modules for Database Updates
During the update, errors only occur in exceptional casses, since the system checks for all logical errors, such as incorrect entries, in the dialog phase of the SAP LUW. If a logical error occurs, the program can terminate the update using the ROLLBACK WORKstatement. Then, the function modules are not called, and the log entry is deleted from table VBLOG. Errors during the update itself are usually technical, for example, memory shortage. If a technical error occurs, the update work process triggers a database rollback, and places the log entry back into VBLOG. It then sends a mail to the user whose dialog originally generated the VBLOG entry with details of the termination. These errors must be corrected by the system administrator. After this, the returned VBLOG entries can be processed again. 
For further information about update administration, see Update Administration
This technique of bundling database changes in the last database LUW of the SAP LUW allows you to update the database asynchronously. This decreases the response times in the dialog process. You can, for example, decouple the update entirely from the dialog work process and use a central update work process on a remote database server.
Bundling Using Subroutines
The statement PERFORM ON COMMIT calls a subroutine in the dialog work process. However, it is not executed until the system reaches the next COMMIT WORK statement. Here, as well, the ABAP statement COMMIT WORK defines the end of the SAP LUW,  since all statements in a subroutine called with PERFORM ON COMMIT that make database changes are executed in the database LUW of the corresponding dialog step.
This graphic is explained in the accompanying text
The advantage of this bundling technique against CALL FUNCTION ... IN UPDATE TASK is better performance, since the update data does not have to be written into an extra table, therefore reducing the database accesses.. The disadvantage, however, is that you cannot pass parameters in a PERFORM ... ON COMMIT statement. Data is passed using global variables and ABAP memory. There is a considerable danger of data inconsistency when you use this method to pass data.
Bundling Using Function Modules in Other SAP Systems
Function modules that you call using CALL FUNCTION ... IN BACKGROUND TASK DESTINATION are registered for background execution in another SAP System when the program reaches the next COMMIT WORK statement (using Remote Function Call). After the COMMIT WORK, the dialog process does not wait for these function modules to be executed (asynchronous update). All of the function modules that you register in this way are executed together in a single database LUW. These updates are useful, for example, when you need to maintain identical data in more than one database.
For further details, refer to the keyword documentation.
For more details of RFC processing, refer to the Remote Communications section of the Basis Servicesdocumentation.



Database Logical Unit of Work (LUW) 

From the point of view of database programming, a database LUW is an inseparable sequence of database operations that ends with a database commit. The database LUW is either fully executed by the database system or not at all. Once a database LUW has been successfully executed, the database will be in a consistent state. If an error occurs within a database LUW, all of the database changes since the beginning of the database LUW are reversed. This leaves the database in the state it was in before the transaction started.
This graphic is explained in the accompanying text
The database changes that occur within a database LUW are not actually written to the database until after the database commit. Until this happens, you can use a database rollback to reverse the changes. In the SAP System, database commits and rollbacks can be triggered either implicitly or using explicit commands.
Implicit Database Commits
A work process can only execute a single database LUW. The consequence of this is that a work process must always end a database LUW when it finishes its work for a user or an external call. Work processes trigger an implicit database commit in the following situations:
·  When a dialog step is completed
Control changes from the work process back to the SAP GUI.
·  When a function module is called in another work process (RFC).
Control passes to the other work process.
·  When the called function module (RFC) in the other work process ends.
Control returns to the calling work process.
·  When a WAIT statement interrupts the work process.
Control passes to another work process.
·  Error dialogs (information, warning, or error messages) in dialog steps.
Control passes from the work process to the SAP GUI.
Explicit Database Commits
There are two ways to trigger an explicit database commit in your application programs:
·  Call the function module DB_COMMIT
The sole task of this function module is to start a database commit.
·  Use the ABAP statement COMMIT WORK
This statement starts a database commit, but also performs other tasks (refer to the keyword documentation for COMMIT WORK).
Implicit Database Rollbacks
The following cases lead to an implicit database rollback:
·  Runtime error in an application program
This occurs whenever an application program has to terminate because of an unforeseen situation (for example, trying to divide by zero).
·  Termination message
Termination messages are generated using the ABAP statement MESSAGE with the message type A or X. In certain cases (updates), they are also generated with message types I, W, and E. These messages end the current application program.
Explicit Database Rollbacks
You can trigger a database rollback explicitly using the ABAP statement ROLLBACK WORK. This statement starts a database rollback, but also performs other tasks (refer to the keyword documentation for ROLLBACK WORK).
From the above, we can draw up the following list of points at which database LUWs begin and end.
A Database LUW Begins
·  Each time a dialog step starts (when the dialog step is sent to the work process).
·  Whenever the previous database LUW ends in a database commit.
·  Whenever the previous database LUW ends in a database rollback.
A Database LUW Ends
·  Each time a database commit occurs. This writes all of the changes to the database.
·  Each time a database rollback occurs. This reverses all of the changes made during the LUW.
Database LUWs and Database Locks

As well as the database changes made within it, a database LUW also consists of database locks. The database system uses locks to ensure that two or more users cannot change the same data simultaneously, since this could lead to inconsistent data being written to the database. A database lock can only be active for the duration of a database LUW. They are automatically released when the database LUW ends. In order to program SAP LUWs, we need a lock mechanism within the R/3 System that allows us to create locks with a longer lifetime (refer to The SAP Locking Concept).



Saturday, February 18, 2017

Hiding a Field Using Javascript in Adobe Form based on the condition

Hiding a Field Using Javascript in Adobe Form based on the condition


By Kalyan Balabhadrapatruni, YASH Technologies

Go to Transaction SFP->  
Select Interface Radio Button & Enter the name to create New Interface.
(Eg:- zhide_field).  
Click on Create & Enter the Description and Press Save:  
Press Save Button.
 
Creating a import parameter
Go to Form Interface->import ->Parameters name -> Enter the import parameter (ie:- pernr)
Creating the Global Delivery which will passed filled in the form interface and passed to the Layout of adobe form.
Go to Global Definitions->Global Data -> enter the below variables.
Go to Global Definitions->Create types.
Go to Initialization->code Initialization.
Enter the below code.
Save
Check
Activate the Interface.

Once the interface is activated.
Go back to transaction SFP.
Select Form Radio Button & Enter the name to create New Form.
(Eg:- zhide_field).  
Enter the Description & Interface name which we have created and press save button.
Press save.
 
Form Context is displayed as below.
Drag & drop the Global data form Interface to Context Level & Save the form.  
Click on the Layout to design the layout.  
Form layout is displayed.
Click on the data view to View the fields that are add to the context in the context tab.

Now drag and drop the fields from the Data view to the form.  
Select object name ->go to Palettes->Click on Script Editor.
This script will hide the field in runtime if it is initial.
Enter the below JavaScript in the editor & Select the language as JavaScript.  
if(this.rawValue == null) // if you use double quotes instead, it will not take effect
{
 this.presence = "hidden"; // in lowercase
}  
Save and activate the form.  
Execute the form to see the below screen.  
Here for output we will have two scenarios.   
SCENARIO 1: Position Title is not initial  
SCENARIO 2: Position Title is initial  
SCENARIO 2:

SAP giới thiệu mã hỗ trợ AI trong ngôn ngữ ABAP riêng của mình

SAP đã ra mắt một loạt tính năng mã hỗ trợ AI trong môi trường phát triển ứng dụng dựa trên đám mây của mình, đồng thời tham gia vào danh sá...