SlideShare a Scribd company logo
1 of 146
Using Serializable Objects in ABAP
For a project I was working on I had to build generic logging functionality in ABAP. There were two important
requirements:
 No noticeable effect on performance
 Re-usable in different scenarios.
With the first requirement in mind I decided to build an RFC enabled function module that I could approach
via an asynchronous RFC call. That seemed a fine idea at the time, but not when you consider that no generic
types are allowed in RFC modules and you can’t use object references in the interface parameters. These
limitations seriously compromised my possibility to meet requirement number two as re -usability often goes
hand in hand with the passing of generic data types.
I complained about these restrictions by one of my esteemed colleagues and he asked me, why don’t you use
serialized objects to pass data to your function module. As I hardly knew what he was talking about I decided
to dive deeper in to this subject, ultimately leading to a satisfactory solution and to this blog.
Serialization
Before I continue I would like to explain how you can serialize (and de-serialize) objects in ABAP.
I will first hit you with the definition of serialization, which hopefully will make a bit of sense in combination
with the requirements above.
“Serialization is the process of translating data structures or object states into a format that can be stored or
transmitted and reconstructed later when the resulting series of bits is reread according to the serialization
format, it can be used to create a semantically identical clone of the original object”.
That is interesting stuff and just what I needed, a way to transmit an object instance and once transmitted a
way to reconstruct it again and by doing so overcoming the limitations of my RFC function module.
How does it work in ABAP
Actually the possibility of object serialization has been available in ABAP for a long time but somehow it never
crossed my path. Although there are already some blogs available on the subject I was missing an overview
of all its possibilities (and limitations). So let’s start with the basics.
Object serialization can be accessed with the CALL TRANSFORMATION statement in roughly the same way as
you do a transformation of an internal table. To be able to serialize an object using this statement, its class
must implement the interface IF_SERIALIZABLE_OBJECT. The result of this transformation is an XML (but
JSON is possible as well) string or xstring. In ABAP it will look something like this.
First we define a simple class which implements the interface IF_SERIALIZABLE_OBJECT and has one private
attribute and a setter- and a getter-method.
We can serialize an instance of this class into an XML-(x)string in the following way:
The result (LV_SERIALIZED_OBJECT) is of type XSTRING and it describes the instance in an XML format. You
can do everything with it what you also can do with any other variable. Like passing it as a parameter to a
function module or for example store it in the database. ( If you plan to do the latter it might be a good idea
to compress the data first before storing it, as more complex objects tend to take up a lot of storage.) If we
check the LV_SERIALIZED_OBJECT in the debugger it looks like this:
If you want the serialized object in JSON format then some additional coding has to be done as shown here.
But let’s stick with the XML version for now. We have seen that serialization can be done, but it’s pretty
useless if we cannot de-serialize it back to an object instance again. But have no fear this can be easily done
by calling the transformation again in reversed order.
It should not come as a surprise that the our object instance is working again as it should. And our private
attribute with value ‘Will_I_surivive_serialization’ was shown on screen. So that is pretty cool! But let’s dive a
bit deeper into the subject.
A further look into serializable objects
Object References
In our simple example we have seen that our attribute ‘survives’ the serialization process. But what happens
if our attribute is not a string variable but also an object instance. To test this I made a small adjustment to
our class definition and defined ‘MYPRIVATEATTRIBUTE’ into TYPE REF TO Object.
In my test I set an instance of class CL_CRM_ORGMAN_SERVICE as my attribute value and execute the
serialization and deserialization. When I check the value of ‘MYPRIVATEATTRIBUTE’ in the debugger after the
deserialization step I see it has the value {O:INITIAL}.
So what’s happening here. This means that it didn’t survive serialization and the reason behind it is that class
CL_CRM_ORGMAN_SERVICES self is not implementing the interface IF_SERIALIZABLE_OBJECT. So that is an
important limitation you have to take into account when you decide to use serialization. If you have other
reference variables inside your class make sure that they implement the interface IF_SERIALIZABLE_OBJECT
as well because otherwise they will not be serialized.
Data References
But what about data references? Are they serializable? Let’s find out and put it to the test. I changed the
definition of ‘MYPRIVATEATTRIBUTE’ into TYPE REF TO DATA and ran a simple test. Unfortunately the
‘MYPRIVATEATTRIBUTE’ didn’t survive the serialization process and after de-serialization it has the value
{O:INITIAL} again. How could this be as I was told, and had read online, that it was possible. After some
further investigation I found out that you have to supply the specific option data_refs = ‘heap_or_create’ to
your transformation so that it will support data references. If you are interested there are actually a lot of
options you can use for your transformations and an overview can be found here. But for now it suffices to
say that data reference can be serialized but you have to tell your transformation to take them into account.
See the example below for a working example.
Clone vs. Clone?
As stated above serialization can be used to create a semantically identical clone of the original object. But
SAP also provides another method of object cloning you can use by calling the following statement SYSTEM-
CALL OBJMGR CLONE <object> TO <cloned_object>. Let’s compare both and see what the difference is. To
do so I made some changes to our class definition and it now implements the CLONE method from the
interface IF_OS_CLONE.
In my next example program I pass an new instance of myself (as it implements the
IF_SERIALIZABLE_OBJECT interface) to the MYOBJECT attribute and after that I go through the serialization
process and subsequently also make a clone of object LO_SERIALIZABLE_OBJECT. See code below:
If we now compare all three objects we can see that cloning via the serialization is actually not delivering
exactly the same result in relation to the cloning done via the system call. As can be seen in the diagram
below.
The difference between the deserialized object and the cloned object is that the latter is also a new instance of
the same class but the attribute MYOBJECT is still referring to the same instance as the original
LO_SERIALIZABLE_OBJECT. The deserialized object generates a new instance for the attribute MYOBJECT
which actually makes sense as it goes through the same serialization process. This same principle will also
apply if you use data references.
Modified Serialization and Deserialization
All the instance attributes for an object part are serialized as standard regardless of their visibility. To change
this behavior, you can declare and implement the instance methods SERIALIZE_HELPER and
DESERIALIZE_HELPER in the relevant class for each object part. In SAP there is a demo program called
DEMO_SERIALIZABLE_OBJECT where this principle is demonstrated. As this blog is already getting quite large
I will not go into much detail here. But for those who are interested in the topic please check here.
Conclusion
Serialization of object references and data references can be quite a useful tool in some specific cases. It has
some limitations but I hope this blog made you aware of them. Serialization can for example be used for
passing generic data to RFC function modules, but also for storing object states in the database. You will
probably not use it every day but know that it is around and in some cases might help you out.
How to Create a Custom Business Object
Vishnu Vardhan
April 12, 2016
Modules, Tips / How To
It is often necessary to create a business object to create/post IDocs of specific objects like
SALES Contracts. Most of SAP data migration projects uses LSMW as a tool for data
load. Almost all master and transactional data can be loaded with LSMW BAPI/Idoc Option.
But, for the business object like sales contracts (BUS2034) cannot be loaded with LSMW BAPI
option because of missing BUS object BUS2034 in the bus iness object list.
Step by step procedures for creating a custom business object:
1. Go to T-code LSMW. And check for the availability of Business object “BUS2034” in the BAPI
method by creating any LSMW( For test)
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d679120c647767aea99
ef/1479398725345/Create+a+Custom+Business+Object+in+SAP" alt="Create a Custom Business Object
in SAP" />
Once if the system shows the error message” Enter a Valid Value”, we are required to create a
Z-Business object for the Object “BUS2034”.
2. For this Process, go to the T-Code “BAPI”. Select the “Business Object Builder” from the
Environment.
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d67ca01dbaea7589211
ed/1479398736298/SAP+Tips%3A+Create+a+Custom+Business+Object" alt="SAP Tips: Create a Custom
Business Object" />
3. Provide the details of fields as shown in Screen shot.
Object Type: ZBUS2034, Click on create button.
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d67f086db433231038a
0a/1479398751149/SAP+Tip%3A+Create+a+Custom+Business+Object" alt="SAP Tip: Create a Custom
Business Object" />
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d68011bbee0c64b398c
a2/1479398761174/SAP+Help%3A+Create+a+Custom+Business+Object" alt="SAP Help: Create a
Custom Business Object" />
4. Save the same in a Package.
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d68294d088ed2c69c82
ff/1479398769964/SAP+Tips%3A+Create+a+Custom+Business+Object" alt="SAP Tips: Create a Custom
Business Object" />
5. Create a transport request and use the same in the Business object creation.
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d685101dbaea758921
7f3/1479398778878/SAP+Business+Object+Tips" alt="SAP Business Object Tips" />
6. All the functions modules described in the Business Object BUS2034 will appear as shown.
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d687427d4bd5b2809e
d40/1479398788019/SAP+Business+Object+Tip" alt="SAP Business Object Tip" />
7. Select the method “CreateFromData” and release the status to “To Modified” as shown for
the object type.
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d68942fe13185ab98aa
50/1479398796860/SAP+Tips+and+Tricks" alt="SAP Tips and Tricks" />
8. Select the method “CreateFromData” and release the status to “To Implemented” as shown
for the object type.
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d68b301dbaea758921c
97/1479398806536/SAP+Screenshots" alt="SAP Screenshot s" />
9. Select the method “CreateFromData” and release the status to “To Released” as shown for
the object type.
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d68c801dbaea758921f
e3/1479398814202/SAP+Custom+Business" alt="SAP Custom Business" />
10. Select the method “CreateFromData” and release the object type component status to “To
Modified” as shown for the object type.
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d68e601dbaea758922
241/1479398846316/Create+a+Custom+Business+Object+in+SAP" alt="Create a Custom Business
Object in SAP" />
11. Select the method “CreateFromData” and release the status to “To Implemented” as shown
for the object type.
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d68fe01dbaea7589223
6b/1479399060287/Create+a+Custom+Business+Object+in+SAP" alt="Create a Custom Business Object
in SAP" />
12. Select the method “CreateFromData” and release the status to “To Released” as shown for
the object type.
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d6c36b654f9de9d8976
0b/1479399092824/SAP+Custom+Business+Objects" alt="SAP Custom Business Objects" />
13. Finally, Come back to the main screen and Change the release status to “Released”.
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d6946746fb9385743bf
3e/1479398868475/Business+Object+SAP" alt="Business Object SAP" />
14. Select the “Generate ALE Interface” from the Environment option of Menu in the
Transaction “BAPI”.
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d6960746fb9385743c0
2c/1479398889562/Business+Object+SAP" alt="Business Object SAP" />
15. Provide the Business Object name “ZVBUS2034” and select the method as
“CREATEFORMDATA.”
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d6c611bbee0c64b39b8
49/1460497513623/" />
16. Click on Create Option.
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d6997746fb9385743c2
2f/1479398931600/SAP+Business+Object" alt="SAP Business Object" />
17. Provide the Message Type as “ZZBAPI_CONTRACT_CREATEFROMDATA”
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d69c2746fb9385743c3
75/1479398945633/SAP+Business+Objects" alt="SAP Business Objects" />
18. Create a package “ZOTC”, Function Group “ZBUS2034” and fill the details for the fields as
shown.
IDOC Type: ZZBAPI_CONTRACT_CREATEFROMDA01
Function Module for ALE Outbound Processing: ZZZALE_CONTRACT_CREATEFROMDATA
Function Module for ALE Inbound Processing: ZIDOC_INPUT_ZZBAPI_CONTRACT_CR
Function Group: ZBUS2034
Package: ZOTC
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d69da1bbee0c64b399e
d2/1479398955770/Creating+Business+Objects+in+SAP" alt="Creating Business Objects in SAP" />
19. Below screen will appears once we are done with the step #17.
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d6a2686db43323103a
0f5/1479398968429/Creating+Business+Object+in+SAP" alt="Creating Business Object in SAP" />
20. Click on the IDoc Type “ZZBAPI_CONTRACT_CREATEFROMDA01” in the above screen and we
will be navigated to the below screen. Go to Edit in the Menu, Click on “Setrelease”.
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d6a43e707ebd28d321
0ca/1479398977847/Creating+Business+Object+SAP" alt="Creating Business Object SAP" />
21. Click on Back button. We will be navigated to the below screen.
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d6a61e707ebd28d321
237/1479398986775/How+To+Create+a+Custom+Business+Object+in+SAP" alt="How To Create a
Custom Business Object in SAP" />
22. Check the existence of business object “ZBUS2034” In the LSMW after the business object
creation and providing the ALE interface.
How to Create a Custom Business Object
Vishnu Vardhan
April 12, 2016
Modules, Tips / How To
It is often necessary to create a business object to create/post IDocs of specific objects like
SALES Contracts. Most of SAP data migration projects uses LSMW as a tool for data
load. Almost all master and transactional data can be loaded with LSMW BAPI/Idoc Option.
But, for the business object like sales contracts (BUS2034) cannot be loaded with LSMW BAPI
option because of missing BUS object BUS2034 in the business object list.
Step by step procedures for creating a custom business object:
1. Go to T-code LSMW. And check for the availability of Business object “BUS2034” in the BAPI
method by creating any LSMW( For test)
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d679120c647767aea99
ef/1479398725345/Create+a+Custom+Business+Object+in+SAP" alt="Create a Custom Business Object
in SAP" />
Once if the system shows the error message” Enter a Valid Value”, we are required to create a
Z-Business object for the Object “BUS2034”.
2. For this Process, go to the T-Code “BAPI”. Select the “Business Object Builder” from the
Environment.
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d67ca01dbaea7589211
ed/1479398736298/SAP+Tips%3A+Create+a+Custom+Business+Object" alt="SAP Tips: Create a Custom
Business Object" />
3. Provide the details of fields as shown in Screen shot.
Object Type: ZBUS2034, Click on create button.
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d67f086db433231038a
0a/1479398751149/SAP+Tip%3A+Create+a+Custom+Business+Object" alt="SAP Tip: Create a Custom
Business Object" />
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d68011bbee0c64b398c
a2/1479398761174/SAP+Help%3A+Create+a+Custom+Business+Object" alt="SAP Help: Crea te a
Custom Business Object" />
4. Save the same in a Package.
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d68294d088ed2c69c82
ff/1479398769964/SAP+Tips%3A+Create+a+Custom+Business+Object" alt="SAP Tips: Create a Custom
Business Object" />
5. Create a transport request and use the same in the Business object creation.
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d685101dbaea758921
7f3/1479398778878/SAP+Business+Object+Tips" alt="SAP Business Object Tips" />
6. All the functions modules described in the Business Object BUS2034 will appear as shown.
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d687427d4bd5b2809e
d40/1479398788019/SAP+Business+Object+Tip" alt="SAP Business Object Tip" />
7. Select the method “CreateFromData” and release the status to “To Modified” as shown for
the object type.
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d68942fe13185ab98aa
50/1479398796860/SAP+Tips+and+Tricks" alt="SAP Tips and Tricks" />
8. Select the method “CreateFromData” and release the status to “To Implemented” as shown
for the object type.
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d68b301dbaea758921c
97/1479398806536/SAP+Screenshots" alt="SAP Screenshots" />
9. Select the method “CreateFromData” and release the status to “To Released” as shown for
the object type.
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d68c801dbaea758921f
e3/1479398814202/SAP+Custom+Business" alt="SAP Custom Business" />
10. Select the method “CreateFromData” and release the object type component status to “To
Modified” as shown for the object type.
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d68e601dbaea758922
241/1479398846316/Create+a+Custom+Business+Object+in+SAP" alt="Create a Custom Business
Object in SAP" />
11. Select the method “CreateFromData” and release the status to “To Implemented” as shown
for the object type.
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d68fe01dbaea7589223
6b/1479399060287/Create+a+Custom+Business+Object+in+SAP" alt="Create a Custom Business Object
in SAP" />
12. Select the method “CreateFromData” and release the status to “To Released” as shown for
the object type.
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d6c36b654f9de9d897 6
0b/1479399092824/SAP+Custom+Business+Objects" alt="SAP Custom Business Objects" />
13. Finally, Come back to the main screen and Change the release status to “Released”.
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d6946746fb9385743bf
3e/1479398868475/Business+Object+SAP" alt="Business Object SAP" />
14. Select the “Generate ALE Interface” from the Environment option of Menu in the
Transaction “BAPI”.
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d6960746fb9385743c0
2c/1479398889562/Business+Object+SAP" alt="Business Object SAP" />
15. Provide the Business Object name “ZVBUS2034” and select the method as
“CREATEFORMDATA.”
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d6c611bbee0c64b39b8
49/1460497513623/" />
16. Click on Create Option.
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d6997746fb9385743c2
2f/1479398931600/SAP+Business+Object" alt="SAP Business Object" />
17. Provide the Message Type as “ZZBAPI_CONTRACT_CREATEFROMDATA”
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d69c2746fb9385743c3
75/1479398945633/SAP+Business+Objects" alt="SAP Business Objects" />
18. Create a package “ZOTC”, Function Group “ZBUS2034” and fill the details for the fields as
shown.
IDOC Type: ZZBAPI_CONTRACT_CREATEFROMDA01
Function Module for ALE Outbound Processing: ZZZALE_CONTRACT_CREATEFROMDATA
Function Module for ALE Inbound Processing: ZIDOC_INPUT_ZZBAPI_CONTRACT_CR
Function Group: ZBUS2034
Package: ZOTC
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d69da1bbee0c64b399e
d2/1479398955770/Creating+Business+Objects+in+SAP" alt="Creating Business Objects in SAP" />
19. Below screen will appears once we are done with the step #17.
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d6a2686db43323103a
0f5/1479398968429/Creating+Business+Object+in+SAP" alt="Creating Business Object in SAP" />
20. Click on the IDoc Type “ZZBAPI_CONTRACT_CREATEFROMDA01” in the above screen and we
will be navigated to the below screen. Go to Edit in the Menu, Click on “Setrelease”.
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d6a43e 707ebd28d321
0ca/1479398977847/Creating+Business+Object+SAP" alt="Creating Business Object SAP" />
21. Click on Back button. We will be navigated to the below screen.
<img
src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d6a61e70 7ebd28d321
237/1479398986775/How+To+Create+a+Custom+Business+Object+in+SAP" alt="How To Create a
Custom Business Object in SAP" />
22. Check the existence of business object “ZBUS2034” In the LSMW after the business object
creation and providing the ALE interface.
Business Object Delegation
Skip to end of metadata
 Created by Guest, lastmodified by Former Member on Nov 02, 2011
Go to startof metadata
Business Object Delegation
Applies To: Learners in w orkflow s, Business Object.
Summary
This document w illhelp people to understand business object delegation w hich can be further used in w orkflow s
It w ill give a brief idea of w hat is Business Object, its components, properties.
And how to delegate a business object and w hat is delegation and w hy w e delegate a std. business object.
Author : Mamta Verma, Softw are Engineer, ES-SAP.
Company: Infosys Technologies Ltd
Created on: 6th DEC, 2008
Table of contents
1. Business Object Type - An Introduction.3
2. Role of Business Object types3
3. Business Object Properties3
4. Components of a Business Object4
5. Business Object Statutes5
6. Delegating a Business Object6
7. References13
1. Business Object Type - An Introduction
Business Object Repository is an object oriented approach used to model Business Objects and processes.
It is a collection of Business Object types and Interface types and also their components like attributes, methods and events .
Business Object type is a representation of any business entity in an SAP system. Example of entity could be an employee, purchase
order, etc.
A BO type includes both the data of the entity and the functions it performs. Data is stored in form of BO attributes and functions in
form of BO methods. Thus w e can understand BO as an object oriented approach to model business entities and processes.
2. Role of Business Object types
Business Object has the follow ing functions:
a. BO reduces the complexity of the SAP system by dividing it into smaller units.
b. At BO level, non-SAP systems can communicate w ith SAP system. This can be done using BAPIs.
c. BO enables various business components to communicate w ith each other.
d. BO types acts as entry points to data and functions for an SAP System.
e. BO's can be used in business w orkflow s, ALE and RFC.
3. Business Object Properties
Each business object has the follow ing properties:
a. Object Type ID - It is used for internal identification of the business object.
b. Object Name - It is used for external identification of the business object. Using this property external system can interact w ith
SAP system.
c. Super Type - It is the parent object from w hich all the components of the BO are inherited.
d. Name - It is a descriptive name of the BO.
e. Description - It is a brief description of the business object type.
f. Application - The application component to w hich the BO belongs to.
g. Program - Program that w ill contain the ABAP code of the BO.
4. Components of a Business Object
There are 5 components of a business object:
a. Key Fields
Ø Can be a combination of one or more fields
Ø Is a specification of unique object key - to access a specific instance of a BO
Ø Is a reference to underlying application table
Ø Must be character based
Ø Value set w hen creating a BO instance or by a method
Ø Can be read from outside. Cannot be changed from outside
Ø Maximum length of concatenated key field can be 70 characters
b. Attributes
Ø Properties and characteristics of a BO
Ø Can be read from outside. Cannot be changed from outside
Ø Can be single-line or multi-line
Ø Can be instance independent (static) or instance dependent
Types of attributes:
• Virtual - Set by a method/BO program w hen accessed
• DB field - Loaded from the database w hen accessed, based on the key fields
c. Events
Ø Indicates the occurrence of a status change of a BO
Ø Can have parameters and exceptions like methods
Ø Have listeners outside the BO. E.g. Workflow
d. Methods
Ø These are functions that encapsulates the functionalities of a BO
Ø Can be synchronous or asynchronous
Ø Can be instance independent or instance dependent
Ø Can have parameters (mandatory/optional, single/multi-line, import/export/both) and exceptions
Ø The ABAP implementation can be:
• A function module
• A BAPI
• A transaction
• A dialog module (Obsolete)
• A report
• Other ABAP forms (Direct implementation, ABAP class methods, system program etc.)
Types of methods:
• Synchronous - Result is returned directly to the calling program.
• Asynchronous - Result can be returned to the calling program only through an event.
e. Interface Types
Ø Like models for BO Types
Ø Do not have any key fields
Ø Cannot be instantiated
Ø Do not have development statuses
Ø Can be inherited - substitute for multiple inheritance
Ø Can have implementation
Ø A BO Type can inherit one or more interfaces
Ø Methods defined in an interface can be redefined in a BO Type
Ø The interface IFSAP and its methods ExistenceCheck and Display are inherited by all BO Types by default
5. Business Object Statutes
The follow ing are the different development statuses of a BO/BO Component:
a. Modeled - Only defined (the method and its signature)
b. Implemented - ABAP implementation is done, can be used for testing or internal use
c. Released - Method ready to be used
d. Obsolete - Attribute / Method / Event not to be used anymore
6. Delegating a Business Object
Here w e w ill Discuss how to delegate a Business Object and w hat is Delegation and w hy w e use it?
Q1>What is Delegation ?
Ans1>Delegation, as the name implies, is a technique of replacing an original object type by its subtype to w hich additional
events/methods may be added.
Q2> Why we use Delegation?
Ans2> If the standard SAP events don't fulfill your purpose, new events/methods may be added to the given object type. SAP doesn't
allow changes to its original object types. It permits changes by using the concept of delegation.
Q3>What are the uses of Delegating a BO?
Ans3>By delegating a BO,
àCustomers use their ow n object extensions w ith the tasks , events , etc. supplied by SAP.
àWithout having to redefine existing tasks , w e can use standard objects w ith customer extensions.
Transaction to be used-------SWO1 (Business Object Builder)
1)Create a business Object using transaction SWO1.
2)Now take super-type as BUS2012 w hich you w ant to delegate.
3)Save it in a 'Z' Package.
4)Click on Object type and go to EDIT. There change the release status of Object type to implement.
5) Again click on Object type and go to EDIT. Now change the release status of Object type to Release.
6)Now click on Methods and press create button. One Pop-up w ill come and here click on 'No'.
Give the method name and description.
8) After this click on method that you have created. Go to EDIT-Change Release Status.
Here first implement the object type component and then release it.
Here you can notice both tick mark is coming in front of business object and method w e have created.
It means method is created successfully.
10) Now in this method , w e can w rite our ow n code according to our requirement.
In my w orkflow Ihave created one method just to add US w ith DEVHYD.
For this I have created tw o parameter---ID , USID (under Parameter Tab)
11) Now click On Program tab for w riting code in our method.
Here I have w ritten Code for adding US w ith DEVHYD.
12)Now save and come back. w e w illcome on SWO1 initial screen.
Here under Setting tab click on Delegate.
13) Choose object type as Bus 2012 and click on Details Tab.
14) In Delegation type , w rite your 'z' object name and then save it.
15) Now w e can use it in any TASK. For this go to transaction PFTC.
Write Business object in object type category. Press F4, the method w e have created w ill come.
Now choose that. It means that in BO bus2012 delegation is done.
ABAP 740 – LOOP AT with GROUP BY
By Naimesh Patel | October 27, 2015 | Concepts | 36,384 | 8
The great new addition to old and gold LOOP AT is a GROUP BY in ABAP 740. This is an
amazing addition to LOOP AT. Lets check it out!
Introduction
LOOP AT must be one of most commonly used syntax. You must be using that often as well. In
ABAP 740, this new great addition GROUP BY has amazing capabilities.
Syntax
This is highlevel syntax using the GROUP BY
LOOP AT t_customres INTO DATA(ls_cust1)
GROUP BY ( route = ls_cust1-route
SIZE = GROUP SIZE
INDEX = GROUP INDEX )
ASCENDING
REFERENCE INTO DATA(route_group).
LOOP AT with GROUP BY
As the name suggests, GROUP BY addition groups the rows of the ITAB and the executes the
LOOP across the groups. The loop gets executed in two phases:
 Group – A loop would be executed on the Group which would be created by GROUP
condition
 Group Loop – A loop would be on each group to access the rows of the group. This are
members.
Sounds amazing, huh?
Things to Remember
Few points to remember whenever you need to use this GROUP BY:
 Group Key – You can specify any fields from the ITAB as part of the key.
 Sorting order – default sorting order of the field is ASCENDING. But you can also specify
ASCENDING or DESCENDING explicitly
 Group members – If don’t need to access the members, you can use the WITHOUT
MEMBERS
Lets dip dive in the Examples and learn more.
Example 1 – Get Unique values using the GROUP BY
I’m using the same customer/route test data which I have used in other ABAP 740 examples. In
this example 1, we’ll list down the unique Routes by creating the group based on the field ROUTE.
The output would be also captured in the result variable created automatically.
Also notice the use of the WITHOUT MEMBERS as members were not accessed at all.
TYPES:
BEGIN OF ty_customer,
customer TYPE char10,
NAME TYPE char30,
city TYPE char30,
route TYPE char10,
END OF ty_customer.
TYPES: tt_customers TYPE SORTED TABLE OF ty_customer
WITH UNIQUE KEY customer.
TYPES: tt_citys TYPE STANDARD TABLE OF char30 WITH EMPTY KEY.
DATA(t_customres) =
VALUE tt_customers(
( customer = 'C0001' NAME = 'Test Customer 1' city = 'NY' route = 'R0001'
)
( customer = 'C0002' NAME = 'Customer 2' city = 'LA' route = 'R0003'
)
( customer = 'C0003' NAME = 'Good Customer 3' city = 'DFW' route = 'R0001'
)
( customer = 'C0004' NAME = 'Best Customer 4' city = 'CH' route = 'R0003'
)
( customer = 'C0005' NAME = 'So So Customer 5' city = 'NY' route = 'R0001'
)
).
* Simply get the unique Routes, use WITHOUT MEMBERS
LOOP AT t_customres INTO DATA(ls_cust_2)
GROUP BY ( route = ls_cust_2-route )
ASCENDING
WITHOUT MEMBERS
REFERENCE INTO DATA(route_group_2).
WRITE: / route_group_2->route.
ENDLOOP.
The output would be like:
Example 2 – Usage of MEMBERS, SIZE and INDEX
The 2nd phase of the GROUP BY is the access the members of the LOOP. To get the members of
the group, we need to LOOP AT GROUP within the main LOOP. This inner LOOP needs to use
the group result to get the members. The new BASE addition of VALUE will provide all the field
values for non group fields. More on BASE in upcoming articles.
There are two inbuilt additions for the GROUP BY key.
SIZE – This would have the number of rows in that group
INDEX – Would be index number of the group, starting with 1.
When the single field is used to make the key, the result would be created as the single field as
shown in earlier example. When there are more than one field, the automatic variable would
contain all those fields, as in this example.
* Creates a group of Route
* with members as all fields which matches the group
LOOP AT t_customres INTO DATA(ls_cust1)
GROUP BY ( route = ls_cust1-route
SIZE = GROUP SIZE
INDEX = GROUP INDEX )
ASCENDING
REFERENCE INTO DATA(route_group).
WRITE: / 'Group', route_group->index.
WRITE: / route_group->route.
DATA(members) = VALUE tt_customers( ).
LOOP AT GROUP route_group ASSIGNING FIELD-SYMBOL(<route>).
members = VALUE #( BASE members ( <route> ) ).
ENDLOOP.
LOOP AT members INTO DATA(ls_member).
WRITE: /(5)", ls_member-customer, ls_member-name, ls_member-city.
ENDLOOP.
WRITE: /(5)", 'Group size ', route_group->size.
SKIP 2.
ENDLOOP.
The output of this example is like this:
In Debugging, you can see the created structure which is automatically created.
Example 3 – Group By without explicit Result variable
You can also choose not to specify the result variable at all. If you do so, the workarea used for the
LOOP AT would be used for the putting the group data as well. But it would be the entire first
matching record with group key.
* Creates a group of Route and City
* but without using the Group result
LOOP AT t_customres INTO DATA(ls_cust)
GROUP BY ( route = ls_cust-route
city = ls_cust-city )
ASCENDING.
WRITE: / ls_cust.
DATA(members) = VALUE tt_customers( ).
LOOP AT GROUP ls_cust ASSIGNING FIELD-SYMBOL(<route>).
members = VALUE #( BASE members ( <route> ) ).
ENDLOOP.
LOOP AT members INTO DATA(ls_member).
WRITE: /(5)", ls_member-customer, ls_member-name.
ENDLOOP.
SKIP 2.
ENDLOOP.
Output this example 3. As you can see here the entire first row of the group is being set in the
LOOP.
Move Cursor to next Row by Pressing
Enter in OO ALV
By Naimesh Patel | September 8, 2008 | OO ALV, Uncategorized | 10,295 | 4
I was wondering if it is possible to have the same functionality of the Excel: Press Enter and cursor
will move to next row.
As OO ABAP using the class CL_GUI_ALV_GRID provides so many methods for the processing
at the Cell Levels. After looking to all the methods of the CL_GUI_ALV_GRID, I found there are so
many methods which can do the processing at the Cell level. I have started to give the try. After
certain tries, I was able to achieve what I was looking for.
Code Snippet for the Class handler for ALV Grid Call
*&---------------------------------------------------------------------*
*& This codesnippetsets thehandlerof the evnets for the OO ALV
*&---------------------------------------------------------------------*
* DataDeclaration
DATA: g_grid type ref to cl_gui_alv_grid,
g_event_receiver type ref to lcl_event_receiver.
*
* Registering theEditevent
CALL METHODg_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
*
* EventHandler
create object g_event_receiver.
*
* Eventlistnermethod for EditEvent
SET HANDLERg_event_receiver->handle_data_changed FOR g_grid.
*
* callingthe instance of theALV
call method g_grid->set_table_for_first_display
changing it_fieldcatalog = gt_fieldcat
it_outtab = gt_outtab[].
Code Snippet for the Class handler definition and Implementation
*&---------------------------------------------------------------------*
*& This codesnippetshows theEventHandlerClass's Definition
*& andimplementation
*&---------------------------------------------------------------------*
* Definition
class lcl_event_receiver definition.
public section.
methods:
handle_data_changed FOR EVENTdata_changed
OF cl_gui_alv_grid
IMPORTINGer_data_changed.
endclass.
* Class Implementation
class lcl_event_receiver implementation.
method handle_data_changed.
*
* Localdata
data: LE_ROW TYPE I,
LE_VALUE TYPE C,
LE_COL TYPE I,
LES_ROW_ID TYPE LVC_S_ROW,
LES_COL_ID TYPE LVC_S_COL,
LES_ROW_NO TYPE LVC_S_ROID.
*
* GettingCurrent Cell
CALL METHODG_GRID->GET_CURRENT_CELL
IMPORTING
E_ROW = le_row
E_VALUE = le_value
E_COL = le_col
ES_ROW_ID = les_row_id
ES_COL_ID = les_col_id
ES_ROW_NO = les_row_no.
*
* Totalnumberof tables
describe table gt_outtab lines sy-index.
*
* Gettingnextrow
les_row_id-INDEX = les_row_id-INDEX + 1.
les_row_no-ROW_ID = les_row_no-ROW_ID + 1.
*
* Set the Nextrow
if les_row_id-index le sy-index.
CALL METHODG_GRID->SET_CURRENT_CELL_VIA_ID
EXPORTING
IS_ROW_ID = les_row_id
IS_COLUMN_ID = LES_COL_ID
IS_ROW_NO = les_row_no.
endif.
endmethod.
endclass.
Hi,
I use and it works! Try flush.
call method grid->set_current_cell_via_id
exporting
is_row_no = ls_row_no "row number
is_column_id = ls_col_id. "column number
Requêtes SQL pour trouver les doublons
La présence de doublons dans une base de données est néfaste pour les performances et l’intégrité des
données. Cela augmente artificielle la taille d’une base de données tandis que les données sont
potentiellement compromise.
Table d’utilisateurs avec des enregistrements dupliqués
Type de doublons
Il y a trois type de doublons couramment sur les bases de données:
 Doublon absolu : représente des “tuples” exactement identique. Plusieurs lignes qui ont les
mêmes valeurs pour chaque colonne.
 Doublon relatif : représente les “tuples” qui ont les mêmes valeurs sauf pour la clé. Le cas le
plus typique ce sont les lignes identiques sauf pour la colonne “id”.
 Quasi doublon : concerne les lignes qui sont presque identiques. La différence entre les lignes
peut être une simple faute de frappe (double espace au lieu d’un seul) ou des différences entre
majuscule et minuscule.
Requête pour trouver les doublons absolus
Il y a une solution simple pour trouver les doublons absolus. Il faut sélectionner les champs d’une table
en les groupant par les colonnes souhaitées. La sélection des champs doit inclure un comptage du
nombre de résultat. Puis il suffit de filtrer les résultats pour ne garder que ceux qui ont plus d’une
ligne (donc au moins un doublons):
SELECT COUNT(*) AS nbr_doublon, champ1, champ2, champ3
FROM table
GROUP BY champ1, champ2, champ3
HAVING COUNT(*) > 1
Requête pour trouver les doublons relatifs
Si une table possède des doublons sur toute les colonnes sauf sur la clé, par exemple pour une colonne
ID, il est possible de les trouver à l’aide de la requête suivante:
SELECT DISTINCT *
FROM table t1
WHERE EXISTS (
SELECT *
FROM table t2
WHERE t1.ID <> t2.ID
AND t1.champ1 = t2.champ1
AND t1.champ2 = t2.champ2
AND t1.champ3 = t2.champ3 )
A savoir : dans la sous-requête il utiliser la commande WHERE sur chacun des champs où l’ont veut
une égalité.
Requête pour trouver les doublons sur une colonne
seulement
La requête est presque similaire à celle pour chercher les doublons absolus. Cette fois-ci nous allons
prendre un exemple concret. Imaginons qu’on souhaite lister les utilisateurs ayant la même adresse
email:
SELECT COUNT(email) AS nbr_doublon, email
FROM utilisateur
GROUP BY email
HAVING COUNT(email) > 1
Articles similaires :

Méthode pour supprimer les doublons dans une base de données SQL
How to debug an IDOC
Skip to end of metadata
 Created by Cora Phelan,lastmodified on Apr 05, 2013
Go to startof metadata
Purpose
This w iki provides a demonstration of how to debug an IDOC.
Overview
The IDOC given in this example is based on invoice in materials management on a test system.
Step 1 - Display IDOC with error in transaction WE02
Double click on the Control Record.
View information on tab Typinfo:
Select tab Partner. For inbound processing check the Sender information.
.
Step 2 - View Partner profiles in transaction WE20
Using the information from step 1:
Partner type LI, Partner Number CP-CP01, Message type INVOIC, Message Variant MM
In transaction WE20 Open folder for Partner Type LI
Double click on partner number CP-CP01
In the inbound parameters, double click on Message type INVOIC (Message variant MM)
Double click on Process code
Here you find the function code identification, in this instance IDOC_INPUT_INVOIC_MRM
Step 3 - Set breakpoint on IDOC_INPUT_INVOIC_MRM and other relevant
function modules for issue concerned via SE37
Step 4 - Use transaction BD87 to debug IDOC concerned.
In transaction BD87 enter concerned IDOC and execute.
Select Button Process (F8). You then come to the first breakpoint set i.e. in this example on function module
IDOC_INPUT_INVOIC_MRM
Use F8 to go to the other relevant Breakpoints you have set.
add lines( itab ) to total_linecount.
SORT itab
Quick Reference
Syntax
SORT itab [STABLE]
{ { [ASCENDING|DESCENDING]
[AS TEXT]
[BY { comp1 [ASCENDING|DESCENDING] [AS TEXT]}
{ comp2 [ASCENDING|DESCENDING] [AS TEXT]}
... ] }
| { [BY (otab)] }
| { [BY expr] } }.
Extras:
1. ... STABLE
2. ... ASCENDING|DESCENDING
3. ... AS TEXT
4. ... BY compi [ASCENDING|DESCENDING] [AS TEXT]
5. ... BY (otab)
6. ... BY expr
Effect
This statement sorts an internal table itab by the size of its components. Here, default sizes are compared using the
general comparison rules, that is:
 Numeric and byte-like components are sorted by their values.
 Character-like components are sorted by default by their binary representation (code page). Textual sorting of
character-like components can be performed using the addition AS TEXT.
 The sizes of other component types are compared using the corresponding rules for reference variables,
structures, and internal tables.
If no explicit sort key is entered using the addition BY, the internal table itab is sorted by the primary table key. The
priority of the sort is based on the order in which the key fields are specified in the table definition. In standard keys, the
sort is prioritized according to the order of the key fields in the row type of the table. If the primary table key of a
standard table is empty, no sort takes place. If this is known statically, the syntax check produces a warning.
Sorting is unstable by default, which means that the relative order of rows that do not have different sort keys is not
preserved when they are sorted. The order can be different depending on the platform or when sorted multiple times.
The addition STABLE can be used for stable sorting.
itab expects a standard table or a hashed table.
 In standard tables, the primary table index is applied in accordance with the sort order
 In hashed tables, the internal order is modified. This internal order was defined either by inserting rows in the
internal table or by a previous sort using the statement SORT.
In both table categories, SORT specifies the order in which a subsequent LOOP runs without the addition USING KEY.
Sorted tables cannot be sorted using SORT and applying the statement SORT to sorted tables is prohibited by the
syntax. If the system only detects that a sorted table is to be sorted at runtime, a non-handleable exception is raised if
this action could modify the existing sorting. The latter occurs in the following cases:
 if the addition BY is used to specify a different sort key as the initial part of the table key.
 if the addition DESCENDING is used.
 if the addition AS TEXT is used.
 if an attribute of an object is specified as a component in the addition BY.
Otherwise, the statement SORT is ignored for sorted tables.
Notes
 It is best to specify an explicit sort key behind BY, if possible. An implicit sort behind the primary table key
(which can itself, in standard tables, be defined implicitly as a standard key) makes a program difficult to
understand and possibly unpredictable.
 When using the primary table key, note that this key can be the standard key, which can also have unexpected
consequences:
 If the row type is structured, the table is sorted by all character-like and byte-like components.
 The standard key of a standard table can be empty.
 Secondary table keys cannot be specified as sort keys.
 SORTs are ignored by the assignment of rows to a secondary table index.
 The addition GROUP BY of the statement LOOP AT itab or of a FOR expression also has the additions
ASCENDING and DESCENDING for sorting groups. These can be used to expand the statement SORT if its sort
criteria are not sufficient (see the executable example).
 It is possible to sort columns with reference types but doing this is questionable. Here it is important to note
that no comparison rule is defined for non-initial invalid references. An internal table can only be sorted by valid
or initial references. A non-initial, invalid reference leads to a runtime error if it is involved in sorting.
 System class CL_ABAP_ITAB_UTILITIES contains method VIRTUAL_SORT, which can be used to virtually
sort a set of internal tables. See also the executable examples listed below.
Example
Simplest form of statement SORT for internal tables. The hash table carriers is sorted by its primary key (in other
words, sorted by column carrid).
DATA carriers TYPE HASHED TABLE OF scarr
WITH UNIQUE KEY carrid.
SELECT *
FROM scarr
INTO TABLE @carriers.
SORT carriers.
Executable Examples
 Sorting Internal Tables
 Sorting Internal Tables with Secondary Keys
Addition 1
... STABLE
Effect
STABLE is used to perform stable sorts, which means that the relative order of rows (an order that does not change in
the sort key) remains unchanged in the sort. If the STABLE addition is not specified, the order is not stable:
 The order can depend on the platform.
 Multiple sorting of a table using the same sort key can produce a different order each time the table is sorted.
Example
Stabile sorting of internal table flights by columns cityfrom cityto, whereby the order within this sorting with
regards to carrid and connid remains the same.
SELECT carrid, connid, cityfrom, cityto
FROM spfli
ORDER BY carrid, connid
INTO TABLE @DATA(flights).
SORT flights STABLE BY cityfrom cityto.
Addition 2
... ASCENDING|DESCENDING
Effect
The addition ASCENDING or DESCENDING can be used to specify the sort direction explicitly as ascending or
descending. If neither of the additions is specified, the table is sorted in ascending order. This sort direction can be
overwritten after the addition BY for components specified individually here.
Example
The internal table itab is sorted by its primary key (in other words, by its rows). Next, LOOP AT GROUP BY can be
used for grouping and determine the number of rows per group.
DATA itab TYPE TABLE OF i WITH NON-UNIQUE KEY table_line.
DATA(rnd) = cl_abap_random_int=>create( seed = + sy-uzeit
min = 1
max = 10 ).
itab = VALUE #( FOR i = 1 UNTIL i > 100 ( rnd->get_next( ) ) ).
SORT itab DESCENDING.
LOOP AT itab ASSIGNING FIELD-SYMBOL(<fs>)
GROUP BY ( key = <fs> size = GROUP SIZE )
ASSIGNING FIELD-SYMBOL(<key>).
cl_demo_output=>write( |{ <key>-key WIDTH = 4
}{ <key>-size }| ).
ENDLOOP.
cl_demo_output=>display( ).
Addition 3
... AS TEXT
Effect
The addition AS TEXT specifies that text-like components are sorted in accordance with the locale of the current text
environment. If AS TEXT is not specified, text-like components are sorted according to the encoding in the code page
of the current text environment. This can be overwritten after the addition BY for the components specified individually
here. The text environment is set when an internal session is opened or by using the statement SET LOCALE.
Notes
 The result of sorting without the addition AS TEXT depends on the operating system of the application server.
Although the sequence of individual letters that belong to the activated language remains the same across
different operating systems, there are differences in terms of the characters that do not belong to the alphabet
of the activated language. Even if only the letters from the alphabet of the activated language are used, some
slight differences occur when sorting complete words. Furthermore, the order of uppercase and lowercase
letters is specific to the operating system.
 The use of the addition AS TEXT usually renders the statement CONVERT TEXT superfluous in the context of
internal tables.
 A sort without the addition AS TEXT is considerably faster than a sort that does use this addition. If it is certain
that both sorts produce the same order, the addition AS TEXT is not necessary. This can be the case if, for
example, text-like components contain characters from the ASCII character set only and only lowercase or
uppercase letters.
Example
Sorting a hashed table text_tab by the order in the code page and in accordance with the locale of the current text
environment. If a western European text environment is configured, the sorts produce the orders Miller, Moller, Muller,
Möller and Miller, Moller, Möller, Muller respectively (also see the executable example for SET LOCALE).
CLASS demo DEFINITION.
PUBLIC SECTION.
CLASS-METHODS main.
PRIVATE SECTION.
CLASS-DATA text_tab TYPE HASHED TABLE OF string
WITH UNIQUE KEY table_line.
ENDCLASS.
CLASS demo IMPLEMENTATION.
METHOD main.
text_tab = VALUE #(
( `Muller` )
( `Möller` )
( `Moller` )
( `Miller` ) ).
SORT text_tab.
cl_demo_output=>write_data( text_tab ).
SORT text_tab AS TEXT.
cl_demo_output=>display_data( text_tab ).
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
demo=>main( ).
Executable Example
Sorting Internal Tables Alphabetically
Addition 4
... BY compi [ASCENDING|DESCENDING] [AS TEXT]
Effect
The addition BY compi does not sort the table by the primary table key, but by the components comp1 comp2...
specified after it instead. The components are specified as described under Specifying Components. If all components
are specified using name variables and these variables contain only blanks, no sort takes place. The priority of the sort
depends on the order in which the components comp1 comp2 ... are specified from left to right. The specified
components can also be duplicated or can overlap. The specified components can have any data type. The relevant
comparison rules apply to the evaluation.
If neither of the additions ASCENDING or DESCENDING are specified after compi, the sort direction specified by addition
2 is used. If one of the additions ASCENDING or DESCENDING is specified, it overwrites the default for this component.
If the addition AS TEXT is not specified after a text-like component compi, the instructions defined by addition 3 are
used. If the addition AS TEXT is specified after a text-like component, it overwrites the default for this component. In
non-text-like components, AS TEXT cannot be specified, unless a structured component is specified. In structured
components, AS TEXT only affects text-like components.
Notes
 If the row type of the internal table is not known statically, the components can only be specified dynamically
and not directly.
 Instead of individual dynamic components, an internal table can be specified directly as otab or as the result
of an expression expr as a dynamic sort key (see additions 5 and 6). Using a table like this has the advantage
that any exceptions are handleable. When specifying the table, the number of components of the sort key is
also dynamic. In contrast, when individual dynamic components are used, a character-like data object must be
specified for any required component, which is ignored if it only contains blank characters.
 An obsolete variant allows field symbols to also be specified for the components outside of classes, for
standard tables.
Example
Sorting in ascending order of internal table itab by column col1 and sorting in descending order by column col2.
TYPES:
BEGIN OF line,
col1 TYPE c LENGTH 1,
col2 TYPE i,
END OF line.
DATA itab TYPE STANDARD TABLE OF line WITH EMPTY KEY.
itab = VALUE #( ( col1 = 'A' col2 = 6 )
( col1 = 'B' col2 = 4 )
( col1 = 'B' col2 = 7 )
( col1 = 'C' col2 = 1 )
( col1 = 'C' col2 = 3 )
( col1 = 'B' col2 = 9 )
( col1 = 'A' col2 = 2 )
( col1 = 'A' col2 = 5 )
( col1 = 'C' col2 = 8 ) ).
SORT itab BY col1 ASCENDING col2 DESCENDING.
cl_demo_output=>display( itab ).
Addition 5
... BY (otab)
Effect
The addition BY (otab) does not sort the table by the primary table key, but by the component specified dynamically
in the internal table otab instead. Each row of the table otab defines a component of the sort key. The priority of the
sort is based on the order of the rows in otab. If the table otab is initial, the table is not sorted.
For otab, a standard table of the table type ABAP_SORTORDER_TAB from ABAP Dictionary must be specified. The
row type of this table is the dictionary structure ABAP_SORTORDER with the following components:
 NAME of type SSTRING
for specifying a component of the sort key. The component is specified in the form
"comp_name[+off(len)]", where "comp_name" must be the name of a component in itab (uppercase
characters). The component name may contain offsets and lengths, structure component selectors, and
component selectors for assigning structured data objects and attributes in classes or objects.
 DESCENDING of the type CHAR of a length 1
for specifying the sort direction for the current component. If DESCENDING is initial, the sort is performed in
ascending order. If DESCENDING has the value "X", the table is sorted in descending order.
 ASTEXT of type CHAR with length 1
for the text sorting of the current component. If ASTEXT has the value "X", the sort is performed as with the
addition AS TEXT. This is only possible for character-like components. If ASTEXT is initial, character-like
components are sorted in accordance with their binary representation.
If a column of otab has invalid content (that is, if NAME contains the name of a component that does not exist or an
incorrect offset/length or if DESCENDING and ASTEXT do not contain "X" or the initial value), this raises a handleable
exception of the class CX_SY_DYN_TABLE_ILL_COMP_VAL.
Notes
 The addition BY (otab) cannot be combined with BY compi.
 When using the addition BY (otab), it is not possible to use DESCENDING or AS TEXT to specify a
descending sort direction or textual sorting for all components.
 If a single parenthesized data object (dobj) is specified after the BY addition, its data type decides whether its
content is used to specify a single dynamic component or multiple components. In either case, no sort takes
place if dobj is initial.
Example
Dynamic import of a database table into a dynamic internal table and dynamic sorting of its content. The name of the
database table and the names of the columns (which the table is to be sorted by) can be entered.
DATA dbtab TYPE c LENGTH 30 VALUE 'spfli'.
cl_demo_input=>add_field( CHANGING field = dbtab ).
DATA columns TYPE string VALUE `cityfrom, cityto`.
cl_demo_input=>request( CHANGING field = columns ).
dbtab = condense( to_upper( dbtab ) ).
DATA dref TYPE REF TO data.
FIELD-SYMBOLS <itab> TYPE STANDARD TABLE.
TRY.
CREATE DATA dref TYPE STANDARD TABLE OF (dbtab).
ASSIGN dref->* TO <itab>.
CATCH cx_sy_create_data_error.
cl_demo_output=>display( 'Wrong data type!' ).
LEAVE PROGRAM.
ENDTRY.
TRY.
SELECT *
FROM (dbtab)
INTO TABLE @<itab>.
CATCH cx_sy_dynamic_osql_semantics.
cl_demo_output=>display( 'Wrong database table!' ).
LEAVE PROGRAM.
ENDTRY.
SPLIT columns AT `,` INTO TABLE DATA(column_tab).
DATA(order) = VALUE abap_sortorder_tab(
FOR wa IN column_tab
( name = condense( to_upper( wa ) ) ) ).
TRY.
SORT <itab> BY (order).
CATCH cx_sy_dyn_table_ill_comp_val.
cl_demo_output=>display( 'Wrong column name!' ).
LEAVE PROGRAM.
ENDTRY.
cl_demo_output=>display( <itab> ).
Addition 6
... BY expr
Effect
The addition BY expr can be used to specify an expression or a functional method call expr whose result is an
internal table with the same type and content as in the preceding addition BY (otab). expr is a general expression
position. The behavior is the same as when specifying a parenthesized internal table directly.
Note
Parentheses cannot be placed around expr.
Example
The above example for specifying BY (otab) can be written in a shorter form as shown below. Instead of specifying
the unnecessary internal table order, you can specify the tabular value (constructed using value operator VALUE) of
the required content.
...
SPLIT columns AT `,` INTO TABLE DATA(column_tab).
TRY.
SORT <itab> BY VALUE #( FOR wa IN column_tab
( name = condense( to_upper( wa ) ) ) ).
CATCH cx_sy_dyn_table_ill_comp_val.
cl_demo_output=>display( 'Wrong column name!' ).
LEAVE PROGRAM.
ENDTRY.
...
Executable Example
Sorting Internal Tables Dynamically.
Exceptions
Non-Handleable Exceptions
CX_SY_DYN_TABLE_ILL_LINE_TYPE
 Cause: The table otab has a prohibited line type.
Runtime error: DYN_TABLE_ILL_LINE_TYPE
CX_SY_DYN_TABLE_ILL_COMP_VAL
 Cause: A column of the table otab contains a prohibited value.
Runtime error: DYN_TABLE_ILL_COMP_VAL
Non-Handleable Exceptions
 Cause: A sort criterion dynamically specified in the form (name) with the explicit addition AS TEXT is not text-
like.
Runtime error: SORT_AS_TEXT_BAD_DYN_TYPE
 Cause: A field symbol used as a dynamic sort criterion with an explicit addition AS TEXT is not text-like.
Runtime error: SORT_AS_TEXT_BAD_FS_TYPE
 Cause: A field symbol used as a dynamic sort criterion does not point to the header row of the internal table to
be sorted.
Runtime error: SORT_ITAB_FIELD_INVALID
 Cause: For a table of the type SORTED TABLE, the sort key does not match a beginning piece of the table key.
Runtime error: SORT_SORT_ILL_KEY_ORDER
 Cause: The additions DESCENDING and AS TEXT are not allowed for tables of the type SORTED TABLE.
Runtime error: SORT_SORT_ILLEGAL
 Cause: More than 250 sort criteria.
Runtime error: SORT_TOO_MANY_FIELDS
 Cause: Sort mode neither 'E'(xternal) nor 'I'(nternal)
Runtime error: SORT_ILLEGAL_MODE
ABAP 740 – LINE_EXISTS to check
record in ITAB
By Naimesh Patel | March 9, 2015 | Concepts | 38,001 | 4
As name suggests, this new predictive function checks if the Line is available in the internal table
or not.
Introduction
LINE_EXISTS can be used instead of the Table Expressions.
Here are the few things to consider:
 LINE_EXISTS is same as READ TABLE … TRANSPORTING NO FIELDS .. followed by
SY-SUBRC CHECK.
 The call doesn’t return any value. It only checks if the line is there in the table with specified
key or not
 This Function doesn’t set the system field SY-TABIX. So, this can’t be used if you want to
use the Parallel Cursor. So, I think you would need use still use the old READ TABLE
statement.
 From SAP Help, This function should be used carefully – you should not use this function to
first check if the line is there in the table and than use the table expression to read the table.
Instead of that, only the table expression assigning to Field Symbol followed by catching the
exception as you did in the article ABAP 740 – Table Expressions to Read & Modify ITAB
line, example 5
When to use LINE_EXISTS
As mentioned earlier, it can only replace few instanced of the READ TABLE… TRANSPORTING
NO FIELDS which are not using the result value. If you want the result value, use the Table
expression instead. If you want to use the SY-TABIX, you would need to use the old READ TABLE
statement. I got excite to replace my parallel cursor algorithms but I think I would need to halt on
that
Lets see few example.
Example – Simple Usage with SY fields behavior
Check if the line exist with the value which exists in the table, followed by the entry which doesn’t
exist with equivalent old code.
DATA: t_data TYPE STANDARD TABLE OF i.
DATA(lv_value) = 9.
DO 10 TIMES.
APPEND sy-INDEX TO t_data.
ENDDO.
*
WRITE: / '>>>> New', lv_value.
IF line_exists( t_data[ TABLE_LINE = lv_value ] ).
WRITE: /(20) 'Found', lv_value.
ELSE.
WRITE: /(20) 'Not Found', lv_value.
ENDIF.
WRITE: /(20) 'SUBRC', sy-subrc,
/(20) 'TABIX', sy-tabix,
/(20) 'INDEX', sy-INDEX.
*
lv_value = 15.
WRITE: / '>>> New', lv_value.
IF line_exists( t_data[ TABLE_LINE = lv_value ] ).
WRITE: /(20) 'Found', lv_value.
ELSE.
WRITE: /(20) 'Not Found', lv_value.
ENDIF.
WRITE: /(20) 'SUBRC', sy-subrc,
/(20) 'TABIX', sy-tabix,
/(20) 'INDEX', sy-INDEX.
* old
WRITE: /'<<<< OLD', lv_value.
READ TABLE t_data TRANSPORTING NO FIELDS WITH KEY TABLE_LINE = lv_value.
IF sy-subrc EQ 0.
WRITE: /(20) 'Found', lv_value.
ELSE.
WRITE: /(20) 'Not Found', lv_value.
ENDIF.
WRITE: /(20) 'SUBRC', sy-subrc,
/(20) 'TABIX', sy-tabix,
/(20) 'INDEX', sy-INDEX.
&#91;/abap_code&#93;
AS you can notice FROM the OUTPUT; SY-TABIX,SY-INDEX,SY-SUBRC doesn't reset from the
LINE_EXISTS call.
<div class="post-image"><img src="http://zevolving.com/wp-
content/uploads/2015/03/ABAP_740_Line_Exists_Example_1.png" alt="ABAP_740_Line_Exists_Example_1"
width="410" height="382" class="alignnone size-full wp-image-2846" /></div>
<h3>Example - Simple Negative Usage with SY fields behavior</h3>
Negative check using NOT and NE ..
[abap_code slider="X" title=""]
*
lv_value = 15.
WRITE: / '>>> New',lv_value.
IF NOT line_exists( t_data[ table_line = lv_value ] ).
WRITE: /(20) 'NOT Found', lv_value.
ELSE.
WRITE: /(20) 'Found', lv_value.
ENDIF.
* old
WRITE: /'<<<< OLD',lv_value.
READ TABLE t_data TRANSPORTINGNO FIELDS WITH KEY table_line = lv_value.
IF sy-subrc NE 0.
WRITE: /(20) 'NOT Found', lv_value.
ELSE.
WRITE: /(20) 'Found', lv_value.
ENDIF.
&#91;/abap_code&#93;
<div class="post-image"><img src="http://zevolving.com/wp-
content/uploads/2015/03/ABAP_740_Line_Exists_Example_2.png" alt="ABAP_740_Line_Exists_Example_2"
width="413" height="203" class="alignnone size-full wp-image-2847" /></div>
<h3>Example - Compare with Table Expression and LINE_EXISTS and READ</h3>
[abap_code slider="X" title=""]
* New function
lv_value = 15.
WRITE: / '>>> New',lv_value.
IF NOT line_exists( t_data[ table_line = lv_value ] ).
WRITE: /(20) 'NOT Found', lv_value.
ELSE.
WRITE: /(20) 'Found', lv_value.
ENDIF.
* New Way
TRY .
lv_value = 7.
WRITE: / '>>> New WITH TABLE Expression', lv_value.
DATA(lv_num) = t_data[ table_line = lv_value ].
WRITE: /(20) 'SUBRC',sy-subrc,
/(20) 'TABIX',sy-tabix,
/(20) 'INDEX',sy-index.
CATCH cx_sy_itab_line_not_found.
WRITE: / 'NOT found'.
ENDTRY.
* old
WRITE: /'<<<< OLD',lv_value.
READ TABLE t_data TRANSPORTINGNO FIELDS WITH KEY table_line = lv_value.
IF sy-subrc NE 0.
WRITE: /(20) 'NOT Found', lv_value.
ELSE.
WRITE: /(20) 'Found', lv_value.
ENDIF.
&#91;/abap_code&#93;
Even table expression don't RESET the SY-TABIX FIELD ...
<div CLASS="post-image"><img src="http://zevolving.com/wp-
content/uploads/2015/03/ABAP_740_Line_Exists_Example_3.png"
alt="ABAP_740_Line_Exists_Example_3" width="403" height="285"
class="alignnone size-full wp-image-2848" /></div>
<h3>Example - Multiple Component check</h3>
LINE_EXISTS works WITH SIMPLE multiple component CHECK AS well.
[abap_code slider="X" title=""]
* Multiple Components
TYPES:
BEGIN OF ty_data,
kunnr TYPE kunnr,
name1 TYPE name1,
ort01 TYPE ort01,
land1 TYPE land1,
END OF ty_data.
TYPES: tt_data TYPE STANDARD TABLE OF ty_data
WITH DEFAULT KEY.
*
DATA(itab_multi_comp) =
VALUE tt_data( ( kunnr = '123' name1 = 'ABCD' ort01 = 'LV' land1 = 'NV' )
( kunnr = '456' name1 = 'XYZ' ort01 = 'LA' land1 = 'CA' )
).
WRITE: / 'NEW'.
IF line_exists( itab_multi_comp[ kunnr = '456' ] ).
WRITE: / ' Customer found'.
ELSE.
WRITE: / ' Customer Not found'.
ENDIF.
* old
WRITE: / 'OLD'.
READ TABLE itab_multi_comp
TRANSPORTING NO FIELDS
WITH KEY kunnr = '456'.
IF sy-subrc EQ 0.
WRITE: / ' Customer found'.
ELSE.
WRITE: / ' Customer Not found'.
ENDIF.
Output
Example – Chaining of Table Expression within LINE_EXISTS now allowed
* Itab Deep
TYPES:
BEGIN OF ty_alv_data,
kunnr TYPE kunnr,
name1 TYPE name1,
ort01 TYPE ort01,
land1 TYPE land1,
t_color TYPE lvc_t_scol,
END OF ty_alv_data.
TYPES: tt_alv_data TYPE STANDARD TABLE OF ty_alv_data
WITH DEFAULT KEY.
DATA(itab_alv) =
VALUE tt_alv_data(
"First Row
( kunnr = '123' name1 = 'ABCD'
ort01 = 'LV' land1 = 'NV'
" color table
t_color = VALUE #(
" Color table - First Row
( fname = 'KUNNR'
color-col = COL_NEGATIVE
color-int = 0
color-inv = 0
)
" Color Table - 2nd Row
( fname = 'ORT01'
color-col = COL_TOTAL
color-int = 1
color-inv = 1
)
)
)
"Second row
( kunnr = '456' name1 = 'XYZ'
ort01 = 'LA' land1 = 'CA'
)
).
IF line_exists( itab_alv[ kunnr = '123' ]-t_color[ fname = 'ORT01' ]-color-
col = COL_BACKGROUND ).
ENDIF.
This produces the syntax error that it doesn’t like it ..
What do you think?
I think I would more use the READ TABLE as generally need to get the access to SY-TABIX for
parallel cursor.
Table of Content – ABAP 740 Concepts
 ABAP 740 – NEW Operator to instantiate the objects
 ABAP 740 – NEW Operator to create ITAB entries
 ABAP 740 – VALUE Operator to create ITAB entries
 ABAP 740 – Table Expressions to Read & Modify ITAB line
 ABAP 740 – LINE_EXISTS to check record in ITAB
 ABAP 740 – Meshes – A new complex type of Structures
 ABAP 740 – Mesh Path – Forward and Inverse Association
 ABAP 740 – FOR Iteration Expression
 ABAP 740 SWITCH – Conditional Operator
 ABAP 740 – LOOP AT with GROUP BY
 ABAP 740 – Is CONSTANT not a Static Attribute anymore?
 SALV IDA (Integrated Data Access) – Introduction
 SALV IDA – Selection Conditions
 SALV IDA – New Calculated Fields
 SALV IDA – Column Settings
 SALV IDA – Add and Handle Hotspot (Hyperlink)
Tags
ABAP 740 Concepts ITAB Processing Table Expressions
Like It? Share!!
inShare
Don't miss an Update
fb/zevolving@zevolving+zevolving
Get notified of the new post, right into your inbox
Subscribe
Naimesh Patel{273articles}
I'm SAP ABAP Consultant for more than a decade. I like to experiment with ABAP especially OO. I
have been SDN Top Contributor.
Follow :
Explore all of his 273 articles.
 Related Post
ABAP 740 – Table Expressions to Read & Modify ITAB line
Read and Modify the ITAB records without using the temporary work area or variables. It is
possible with using the ABAP Table Expressions. Lets see more about them. Preface Let
me start with begging your apologies for not publishing any article in long time. I had to take
a pause . I would try to…
Read Post »
 Related Post
ABAP 740 – NEW Operator to create ITAB entries
Similar to the NEW operator to instantiate the object, you can use the NEW as well with
internal table processing to append rows within it. Preface In ABAP 740, we have new NEW
operator to create the table entries. This NEW works similarly like . Lets take a look at what
how NEW can be…
Read Post »
4 Comments

Martin Pacovsky
# March 10th, 2015 at 2:34 am
Hi, is it possible to use this together with other key than whole TABLE LINE? Otherwise I see no
sense to remember it, because TRANSPORTING NO FIELDS, as you mentioned, has much
bigger area of use, and yes, no SY-TABIX is also awkward.

Naimesh Patel
# March 10th, 2015 at 10:06 am
Hello Martin,
Yes, it does work with the Multiple components. I have added the example in the article for that
now. I was more focused on the SY fields so didn’t focus on all other cases.
Also added chaining of the table expression example which is not yet allowed using LINE_EXISTS.
May be in next release
Thanks,
Naimesh Patel

Michal
# April 15th, 2015 at 6:13 pm
Hi Naimesh,
I think the reason why line_exists does not work is stated in the documentation:
The table expression is only used to check the existence of the specified row. No temporary result
is created.
To modify the deep component, the chaining table expressions can be used together with the
exception handling (catching the exception is the same as line_exists = false).
Check the snippet below:
PROGRAM zchain.
TYPES:
BEGIN OF struc_2,
b_2,
c_2,
END OF struc_2,
tt2 TYPE STANDARD TABLE OF struc_2 WITH DEFAULT KEY,
BEGIN OF struc_1,
a_1,
b_1 TYPE tt2,
END OF struc_1,
tt1 TYPE STANDARD TABLE OF struc_1 WITH DEFAULT KEY.
DATA(lt) = VALUE tt1(
( a_1 = 'A' b_1 = VALUE #( ( b_2 = 'B' ) ( b_2 = 'C' ) ) )
( a_1 = 'D' b_1 = VALUE #( ( b_2 = 'E' ) ( b_2 = 'F' ) ) )
).
TRY.
DATA(b_2_value) = 'D'. "change to 'C' to get positive result
lt[ a_1 = 'A' ]-b_1[ b_2 = b_2_value ]-c_2 = 'X'.
WRITE:/ 'OK:', lt[ a_1 = 'A' ]-b_1[ b_2 = b_2_value ]-c_2.
CATCH cx_sy_itab_line_not_found.
WRITE:/ 'The desired record not found in nested table'.
ENDTRY.
BR
Michal
Quelque informationpouvantutile:
Si smartformalimentationduprotocole :
DATA: lt_errortab TYPE tsferror.
DATA: lf_msgnr TYPE sy-msgno.
DATA: l_s_log TYPE bal_s_log,
p_loghandle TYPE balloghndl,
l_s_msg TYPE bal_s_msg.
FIELD-SYMBOLS: <fs_errortab> TYPE LINE OF tsferror.
* get smart form protocoll
CALL FUNCTION 'SSF_READ_ERRORS'
IMPORTING
errortab = lt_errortab.
SORT lt_errortab.
* delete adjacent duplicates from lt_errortab comparing errnumber.
* add smartform protocoll to nast protocoll
LOOP AT lt_errortab ASSIGNING <fs_errortab>.
CLEAR lf_msgnr.
lf_msgnr = <fs_errortab>-errnumber.
CALL FUNCTION 'NAST_PROTOCOL_UPDATE'
EXPORTING
msg_arbgb = <fs_errortab>-msgid
msg_nr = lf_msgnr
msg_ty = <fs_errortab>-msgty
msg_v1 = <fs_errortab>-msgv1
msg_v2 = <fs_errortab>-msgv2
msg_v3 = <fs_errortab>-msgv3
msg_v4 = <fs_errortab>-msgv4
EXCEPTIONS
OTHERS = 1.
ENDLOOP.
* open the application log
l_s_log-extnumber = sy-uname.
CALL FUNCTION 'BAL_LOG_CREATE'
EXPORTING
i_s_log = l_s_log
IMPORTING
e_log_handle = p_loghandle
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
ENDIF.
LOOP AT lt_errortab ASSIGNING <fs_errortab>.
MOVE-CORRESPONDING <fs_errortab> TO l_s_msg.
CALL FUNCTION 'BAL_LOG_MSG_ADD'
EXPORTING
i_log_handle = p_loghandle
i_s_msg = l_s_msg
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
ENDIF.
ENDLOOP.
** Function module to display error logs during
** smart form processing
** Notice , the function 'BAL_DSP_LOG_DISPLAY' can
** not be used when you using output dispatch time
** 4 (Send immediately), so the statement is comment
** out by default.
** You can enable the function call statement
** if your form can not be output and you want to
** see the error log. Set output dispatch time to 3
** before save your order, then print or preview the
** output.
DATA lv_debug.
IF NOT lv_debug IS INITIAL.
CALL FUNCTION 'BAL_DSP_LOG_DISPLAY'.
ENDIF.
Préparationdusmartforma l’envoiede mail
* Envoi par mail
ELSE.
* pas d'impression, on récupère juste le fichier OTF
ls_control_param-getotf = 'X'.
CALL FUNCTION lv_fm_name
EXPORTING
archive_index = toa_dara
archive_parameters = arc_params
control_parameters = ls_control_param
mail_recipient = ls_recipient
mail_sender = ls_sender
output_options = ls_composer_param
is_ekko = ls_doc-xekko
ls_job_out_info-otfdata contient les information
du smartform a envoyer
user_settings = 'X'
is_pekko = ls_doc-xpekko
is_nast = ls_nast
iv_from_mem = lv_from_memory
iv_druvo = iv_druvo
it_receiver = lt_receiver "M002(+)
IMPORTING
document_output_info = ls_doc_out_info
job_output_info = ls_job_out_info
job_output_options = ls_job_out_options
* ev_mail_dest = l_mail "M002(-)
TABLES
it_ekpo = ls_doc-xekpo[]
it_ekpa = ls_doc-xekpa[]
it_pekpo = ls_doc-xpekpo[]
it_eket = ls_doc-xeket[]
it_tkomv = ls_doc-xtkomv[]
it_ekkn = ls_doc-xekkn[]
it_ekek = ls_doc-xekek[]
it_komk = l_xkomk[]
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
DATA :
lt_pdf_lines TYPE TABLE OF tline,
lt_doctab_archive TYPE TABLE OF docs,
lt_contents_out TYPE TABLE OF solisti1,
lt_contents_hex TYPE TABLE OF solix,
lt_contents_txt TYPE TABLE OF solisti1,
ls_contents_txt TYPE solisti1,
lt_objpack TYPE TABLE OF sopcklsti1,
ls_objpack TYPE sopcklsti1,
lt_object_header TYPE TABLE OF solisti1,
* lt_receiver TYPE TABLE OF somlreci1, "M002(-)
* ls_receiver TYPE somlreci1, "M002(-)
ls_document_data TYPE sodocchgi1,
lv_nb_lines TYPE i,
l_mail TYPE ad_smtpadr,
lv_ebeln TYPE ebeln,
lv_commit TYPE xfeld.
* Conversion en PDF
CALL FUNCTION 'CONVERT_OTF_2_PDF'
TABLES
otf = put_otfdata
doctab_archive = lt_doctab_archive
lines = lt_pdf_lines
EXCEPTIONS
err_conv_not_possible = 1
err_otf_mc_noendmarker = 2
OTHERS = 3.
* On change la largeur de la ligne
CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
TABLES
content_in = lt_pdf_lines
content_out = lt_contents_out
EXCEPTIONS
err_line_width_src_too_long = 1
err_line_width_dst_too_long = 2
err_conv_failed = 3
OTHERS = 4.
TRY.
CALL METHOD cl_bcs_convert=>bin_to_solix
EXPORTING
it_soli = lt_contents_out
IMPORTING
et_solix = lt_contents_hex.
ENDTRY.
Corps du mail
ls_contents_txt-line = text-001.
APPEND ls_contents_txt TO lt_contents_txt.
* Définition des objets du mail : d'abord le corps du mail
CLEAR ls_objpack.
ls_objpack-transf_bin = ' '.
ls_objpack-head_start = 0.
ls_objpack-head_num = 0.
ls_objpack-body_start = 1.
DESCRIBE TABLE lt_contents_txt LINES lv_nb_lines.
ls_objpack-body_num = lv_nb_lines.
ls_objpack-doc_type = 'RAW'.
APPEND ls_objpack TO lt_objpack.
* Ensuite le formulaire commande d'achat en fichier joint
CLEAR ls_objpack.
ls_objpack-obj_descr = text-002.
ls_objpack-transf_bin = 'X'.
ls_objpack-head_start = 0.
ls_objpack-head_num = 0.
ls_objpack-body_start = 1.
ls_objpack-doc_type = 'PDF'.
DESCRIBE TABLE lt_contents_hex LINES lv_nb_lines.
ls_objpack-body_num = lv_nb_lines.
APPEND ls_objpack TO lt_objpack.
Searchhelpou aide a larecherche serveurrepertoirserveur
IF sy-batch EQ abap_false.
* GUI mode
CALL FUNCTION 'F4_DXFILENAME_TOPRECURSION'
EXPORTING
i_location_flag = lv_location " Flag: Application or presentation server
i_path = sv_last_path
filemask = lv_filemask
fileoperation = lv_file_operation
IMPORTING
o_location_flag = cv_location
o_path = cv_path
EXCEPTIONS
rfc_error = 1
error_with_gui = 2
OTHERS = 3.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF. "sy-batch EQ abap_false.
* Corps du mail
ls_contents_txt-line = text-001.
APPEND ls_contents_txt TO lt_contents_txt.
* Définition des objets du mail : d'abord le corps du mail
CLEAR ls_objpack.
ls_objpack-transf_bin = ' '.
ls_objpack-head_start = 0.
ls_objpack-head_num = 0.
ls_objpack-body_start = 1.
DESCRIBE TABLE lt_contents_txt LINES lv_nb_lines.
ls_objpack-body_num = lv_nb_lines.
ls_objpack-doc_type = 'RAW'.
APPEND ls_objpack TO lt_objpack.
* Ensuite le formulaire commande d'achat en fichier joint
CLEAR ls_objpack.
ls_objpack-obj_descr = text-002.
ls_objpack-transf_bin = 'X'.
ls_objpack-head_start = 0.
ls_objpack-head_num = 0.
ls_objpack-body_start = 1.
ls_objpack-doc_type = 'PDF'.
DESCRIBE TABLE lt_contents_hex LINES lv_nb_lines.
ls_objpack-body_num = lv_nb_lines.
APPEND ls_objpack TO lt_objpack.
Gestiondesimagespourl’envoie de mail
mail_add_access_map USING pus_doc TYPE meein_purchase_doc_print
CHANGING pct_content_hex TYPE INDEX TABLE
pct_objpack TYPE INDEX TABLE.
DATA : l_bytecount TYPE i,
l_tdbtype LIKE stxbitmaps-tdbtype,
l_content TYPE STANDARD TABLE OF bapiconten INITIAL SIZE 0,
l_graphic_size TYPE i,
ls_objpack TYPE sopcklsti1,
lv_size TYPE i,
lv_size_c TYPE char12,
lv_nb_lines TYPE i,
l_plan TYPE flag,
l_name TYPE ad_name1,
ls_ekpo TYPE ekpo,
l_post_code TYPE ad_pstcd1.
CALL FUNCTION 'SAPSCRIPT_GET_GRAPHIC_BDS'
EXPORTING
i_object = 'GRAPHICS'
i_name = 'PLAN_ACCES_0006'
i_id = 'BMAP'
i_btype = 'BCOL'
IMPORTING
e_bytecount = l_bytecount
TABLES
content = l_content
EXCEPTIONS
not_found = 1
bds_get_failed = 2
bds_no_content = 3
OTHERS = 4.
IF sy-subrc = 0.
CALL FUNCTION 'SAPSCRIPT_CONVERT_BITMAP'
EXPORTING
old_format = 'BDS'
new_format = 'BMP'
bitmap_file_bytecount_in = l_bytecount
IMPORTING
bitmap_file_bytecount = l_graphic_size
TABLES
bds_bitmap_file = l_content
bitmap_file = lt_graphic
EXCEPTIONS
OTHERS = 1.
IF sy-subrc = 0.
* On ajoute l'image en pièce jointe
CLEAR ls_objpack.
ls_objpack-obj_descr = text-004.
ls_objpack-obj_name = text-004.
ls_objpack-transf_bin = 'X'.
ls_objpack-head_start = 0.
ls_objpack-head_num = 0.
DESCRIBE TABLE pct_content_hex LINES lv_nb_lines.
ls_objpack-body_start = lv_nb_lines + 1.
ls_objpack-doc_type = 'BMP'.
APPEND LINES OF lt_graphic TO pct_content_hex.
DESCRIBE TABLE pct_content_hex LINES ls_objpack-body_num.
APPEND ls_objpack TO pct_objpack.
ENDIF.
Exemple de récupération de fichierdansle GOSpourenvoie de mail :
Sur commande d’achatetDA
FORM mail_add_attachment USING pus_doc TYPE meein_purchase_doc_print
CHANGING pct_content_hex TYPE INDEX TABLE
pct_objpack TYPE INDEX TABLE.
DATA : lt_srgbtbrel TYPE TABLE OF srgbtbrel,
ls_srgbtbrel TYPE srgbtbrel,
lt_signature TYPE TABLE OF bapisignat,
lt_components TYPE TABLE OF bapicompon,
ls_components TYPE bapicompon,
lt_content TYPE TABLE OF bapiconten,
lt_solix TYPE TABLE OF solix,
ls_solix TYPE solix,
ls_object_key TYPE bds_typeid,
ls_ekpo TYPE ekpo,
ls_document_data TYPE sofolenti1,
ls_objpack TYPE sopcklsti1,
lv_doc_id TYPE so_entryid,
lv_doc_id_otp TYPE so_entryid, "ACN(+) - 05022015
lv_size TYPE i,
lv_xstring TYPE xstring,
lv_extension TYPE char3,
lv_size_c TYPE char12,
lv_nb_lines TYPE i.
DATA : r_societe TYPE fip_t_bukrs_range.
DATA : flag_attach_doc_okay TYPE xfeld.
* Récupération des pièces jointes sur la commande
SELECT *
FROM srgbtbrel
INTO TABLE lt_srgbtbrel
WHERE instid_a = pus_doc-xekko-ebeln
AND typeid_a = 'BUS2012'
AND catid_a = 'BO'.
* Début de modification - ACN - 05022015
* Lecture de la 1ère pièce jointe
* READ TABLE lt_srgbtbrel INTO ls_srgbtbrel INDEX 1.
* IF sy-subrc = 0.
*
* lv_doc_id = ls_srgbtbrel-instid_b.
*
* ELSE.
* Boucle sur les documents joints
LOOP AT lt_srgbtbrel INTO ls_srgbtbrel.
*{+M007 Construction de la table permettant de savoir si l'envoie de document attac
hés
* a la commande d'achat sont autorisés.
AT FIRST.
PERFORM societe_autorisee CHANGING r_societe.
ENDAT.
*}+M007
" Récupération du titre du document et du contenu
CLEAR :
lt_solix[],
lv_doc_id_otp,
ls_document_data.
lv_doc_id_otp = ls_srgbtbrel-instid_b.
CALL FUNCTION 'SO_DOCUMENT_READ_API1'
EXPORTING
document_id = lv_doc_id_otp
IMPORTING
document_data = ls_document_data
TABLES
contents_hex = lt_solix
EXCEPTIONS
document_id_not_exist = 1
operation_no_authorization = 2
x_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
CONTINUE.
ENDIF.
*{+M007 Controle l'intitulé du document pour savoir si celui-
ci est eligible a l'envoie
* de mail.
IF pus_doc-xekko-bukrs IN r_societe.
PERFORM check_title_of_doc USING ls_document_data-obj_descr
CHANGING flag_attach_doc_okay.
ENDIF.
*}+M007
" Si le titre comprend OTP alors joindre la pièce au mail
IF ls_document_data-obj_descr(3) = 'OTP' OR ls_document_data-
obj_descr CS 'Adresse'
OR flag_attach_doc_okay IS NOT INITIAL. "M007
" Il faut joindre le fichier au mail
CLEAR :
lv_extension,
lv_size_c.
lv_extension = ls_document_data-obj_type.
lv_size_c = ls_document_data-doc_size.
DESCRIBE TABLE pct_content_hex LINES lv_nb_lines.
IF lt_solix[] IS NOT INITIAL.
" On ajoute la pièce jointe à la commande
APPEND LINES OF lt_solix TO pct_content_hex.
CLEAR ls_objpack.
ls_objpack-obj_descr = ls_document_data-obj_descr.
ls_objpack-obj_name = ls_document_data-obj_descr.
ls_objpack-transf_bin = 'X'.
ls_objpack-head_start = 0.
ls_objpack-head_num = 0.
ls_objpack-body_start = lv_nb_lines + 1.
ls_objpack-doc_type = lv_extension.
DESCRIBE TABLE lt_solix LINES ls_objpack-body_num.
ls_objpack-doc_size = lv_size_c.
APPEND ls_objpack TO pct_objpack.
CLEAR lt_solix[].
ENDIF.
ELSE.
IF lv_doc_id IS INITIAL.
" Nous gardons le premier doc ne provenant pas de l'OTP
lv_doc_id = ls_srgbtbrel-instid_b.
ENDIF.
ENDIF.
ENDLOOP.
IF NOT sy-subrc IS INITIAL.
* Fin de modification - ACN - 05022015
" On va voir s'il n'existe pas une pièce jointe sur la DA liée au 1er poste
READ TABLE pus_doc-xekpo INTO ls_ekpo INDEX 1.
IF ls_ekpo-banfn IS NOT INITIAL.
" Récupération des pièces jointes sur la DA
SELECT *
FROM srgbtbrel
INTO TABLE lt_srgbtbrel
WHERE instid_a = ls_ekpo-banfn
AND typeid_a = 'BUS2105'
AND catid_a = 'BO'.
" Lecture de la 1ère pièce jointe
READ TABLE lt_srgbtbrel INTO ls_srgbtbrel INDEX 1.
IF sy-subrc = 0.
lv_doc_id = ls_srgbtbrel-instid_b.
ELSE.
ls_object_key = ls_ekpo-banfn.
CALL FUNCTION 'BDS_BUSINESSDOCUMENT_GET_TAB'
EXPORTING
classname = 'BUS2105'
classtype = 'BO'
client = sy-mandt
object_key = ls_object_key
binary_flag = 'X'
text_as_stream = 'X'
TABLES
signature = lt_signature
components = lt_components
content = lt_content
EXCEPTIONS
nothing_found = 1
parameter_error = 2
not_allowed = 3
error_kpro = 4
internal_error = 5
not_authorized = 6
OTHERS = 7.
IF sy-subrc = 0.
" Taille de la pièce jointe
READ TABLE lt_components INTO ls_components INDEX 1.
MOVE ls_components-comp_size TO lv_size.
lv_size_c = ls_components-comp_size.
" Type de la pièce jointe (= extension)
CALL METHOD cl_bcs_utilities=>split_name
EXPORTING
iv_name = ls_components-comp_id
IMPORTING
ev_extension = lv_extension.
TRANSLATE lv_extension TO UPPER CASE.
" Conversion pour changer la taille des lignes
CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
EXPORTING
input_length = lv_size
IMPORTING
buffer = lv_xstring
TABLES
binary_tab = lt_content
EXCEPTIONS
failed = 1
OTHERS = 2.
WHILE lv_xstring IS NOT INITIAL.
CLEAR ls_solix.
ls_solix-line = lv_xstring.
APPEND ls_solix TO lt_solix.
SHIFT lv_xstring LEFT BY 255 PLACES IN BYTE MODE.
ENDWHILE.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
IF lv_doc_id IS NOT INITIAL.
* Récupération du contenu de la pièce jointe
CALL FUNCTION 'SO_DOCUMENT_READ_API1'
EXPORTING
document_id = lv_doc_id
IMPORTING
document_data = ls_document_data
TABLES
contents_hex = lt_solix
EXCEPTIONS
document_id_not_exist = 1
operation_no_authorization = 2
x_error = 3
OTHERS = 4.
lv_extension = ls_document_data-obj_type.
lv_size_c = ls_document_data-doc_size.
DESCRIBE TABLE pct_content_hex LINES lv_nb_lines.
ENDIF.
IF lt_solix[] IS NOT INITIAL.
" On ajoute la pièce jointe à la commande
APPEND LINES OF lt_solix TO pct_content_hex.
CLEAR ls_objpack.
ls_objpack-obj_descr = ls_document_data-obj_descr.
ls_objpack-obj_name = ls_document_data-obj_descr.
ls_objpack-transf_bin = 'X'.
ls_objpack-head_start = 0.
ls_objpack-head_num = 0.
ls_objpack-body_start = lv_nb_lines + 1.
ls_objpack-doc_type = lv_extension.
DESCRIBE TABLE lt_solix LINES ls_objpack-body_num.
ls_objpack-doc_size = lv_size_c.
APPEND ls_objpack TO pct_objpack.
ENDIF.
ENDFORM.
Autre variante de document attaché : doknr
ORM mail_add_file_dms USING pus_doc TYPE meein_purchase_doc_print
CHANGING pct_content_hex TYPE INDEX TABLE
pct_objpack TYPE INDEX TABLE.
DATA : ls_draw TYPE draw,
lt_drao TYPE TABLE OF drao,
ls_drao TYPE drao,
ls_cout_def TYPE dms_checkout_def,
ls_doc_file TYPE dms_doc_file,
l_offset TYPE i,
ls_solix TYPE solix,
lt_solix TYPE TABLE OF solix,
ls_objpack TYPE sopcklsti1,
lv_nb_lines TYPE i,
lr_adr TYPE RANGE OF adrnr,
ls_ekpo TYPE ekpo.
FIELD-SYMBOLS : <ls_adr> LIKE LINE OF lr_adr.
CHECK pus_doc-xekko-ekorg = 'A006' AND pus_doc-xekko-
bsart = 'ZANB'. "uniquement pour Castel Alu
* Uniquement pour les adresses de livraison particulières (atelier)
SELECT sign opti low high FROM tvarvc
INTO TABLE lr_adr
WHERE name = 'ZMM_ADR_PJ_CDE' AND
type = 'S'.
* Conversion des n° d'adresse au format interne
LOOP AT lr_adr ASSIGNING <ls_adr>.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = <ls_adr>-low
IMPORTING
output = <ls_adr>-low.
IF <ls_adr>-high IS NOT INITIAL.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = <ls_adr>-high
IMPORTING
output = <ls_adr>-high.
ENDIF.
ENDLOOP.
* On vérifie que l'adresse de livraison du 1er poste correspond au range
READ TABLE pus_doc-xekpo INDEX 1 INTO ls_ekpo.
CHECK sy-subrc = 0 AND lr_adr[] IS NOT INITIAL AND ls_ekpo-adrn2 IN lr_adr.
* Infos document DMS
SELECT SINGLE * FROM draw
INTO ls_draw
WHERE dokar = 'ZCA' AND
doknr = 'CA000000001' AND
dokvr = '00' AND
doktl = '000'.
ls_cout_def-action = 'V'.
ls_cout_def-comp_get = 'X'.
ls_cout_def-ftp_dest = 'SAPFTP'.
ls_doc_file-fileno = '1'.
ls_doc_file-dttrg = ls_draw-dttrg.
ls_doc_file-dappl = ls_draw-dappl.
* Récupération du contenu du fichier en binaire (à partir de la table DRAO)
CALL FUNCTION 'CV120_DOC_CHECKOUT'
EXPORTING
ps_cout_def = ls_cout_def
ps_draw = ls_draw
ps_doc_file = ls_doc_file
TABLES
ptx_drao = lt_drao
EXCEPTIONS
error = 1
OTHERS = 2.
IF sy-subrc <> 0.
EXIT.
ENDIF.
LOOP AT lt_drao INTO ls_drao.
* On split en "paquets" de 255 caractères pour avoir le bon format
DO 10 TIMES.
l_offset = 255 * ( sy-index - 1 ).
ls_solix-line = ls_drao-orblk+l_offset(255).
APPEND ls_solix TO lt_solix.
ENDDO.
ENDLOOP.
DESCRIBE TABLE pct_content_hex LINES lv_nb_lines.
* On ajoute la pièce jointe à la commande
IF lt_solix[] IS NOT INITIAL.
APPEND LINES OF lt_solix TO pct_content_hex.
CLEAR ls_objpack.
ls_objpack-obj_descr = text-005.
ls_objpack-obj_name = text-006.
ls_objpack-transf_bin = 'X'.
ls_objpack-head_start = 0.
ls_objpack-head_num = 0.
ls_objpack-body_start = lv_nb_lines + 1.
ls_objpack-doc_type = ls_doc_file-dappl. "PDF
DESCRIBE TABLE lt_solix LINES ls_objpack-body_num.
* ls_objpack-doc_size = lv_size_c.
APPEND ls_objpack TO pct_objpack.
ENDIF.
ENDFORM. " MAIL_ADD_FILE_DMS
Envoie effectif dumail :
ls_document_data-obj_descr = text-tit.
WRITE pus_doc-xekko-ebeln TO lv_ebeln.
CONDENSE lv_ebeln.
CONCATENATE ls_document_data-obj_descr lv_ebeln INTO ls_document_data-obj_descr.
CLEAR lv_commit.
IF nast-vsztp NE '4'.
lv_commit = 'X'.
ENDIF.
* Envoi du mail
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = ls_document_data
commit_work = lv_commit
TABLES
packing_list = lt_objpack
object_header = lt_object_header
contents_txt = lt_contents_txt
contents_hex = lt_contents_hex
* receivers = lt_receiver "M002(-)
receivers = put_receiver "M002(+)
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
Methodenchainmentd’ALV:
ALV – это не только простые таблицы
ivan 08.10.2010
Разрабатывая отчетики на базе ALV можно также обратить внимание на дополнительные
аспекты – не всегда простой таблицы бывает достаточно, а рисовать свои экраны не
сильно тянет.
Если покопаться в примерах, то можно найти несколько полезных вариантов.
Одна оговорка: в данном случае ALV представлено не своим красивым элементом
управления, а ABAP-списком. В стандарте очень много отчётов строятся похожим образом.
Иерархический просмотр master-detail
Пример можно найти в программе BALVHD01.
Этот отчёт строится на базе функционального модуля REUSE_ALV_HIERSEQ_LIST_DISPLAY.
Основная ALV функциональность присутствует: управление вариантами, сортировки,
суммы, группировки, фильтр и прочее.
Иерархичность тут не полная, а всего лишь отношение master-detail, чего в большинстве
случаев может и хватить, так как покрывает стандартные отношения типа “заголовок
документа – позиции документа”.
Ко всему прочему, такой вывод поддерживает многострочность одной строки (до трёх
строк), что позволяет упаковать больше данных по ширине экрана.
Несколько независимых таблиц
Пример можно обнаружить в программе BALVBT01.
Такой вариант реализуется на базе функциональных модулей REUSE_ALV_BLOCK_LIST_INIT,
REUSE_ALV_BLOCK_LIST_APPEND, REUSE_ALV_BLOCK_LIST_HS_APPEND,
REUSE_ALV_BLOCK_LIST_DISPLAY.
В программе требуется простая последовательность фрагментов: инициализация,
последовательное добавление таблиц, вызов показывалки.
Таким образом можно представить несколько независимых наборов данных, с
сохранением основной функциональности ALV в рамках отдельных таблиц.
MAINTAINING VARIABLE USING TCODE STVARV
February 21, 2017 · by abaplearner · in ABAP · Leavea comment
Untuk menghindari hardcode dalam suatu program, biasanyaabaper menggunakan constants untuk meminimalisir
hardcode atau agar lebihfleksibel, dibuattableZ yang digunakanuntuk me-maintainvariabel yang di-hardcode.
Penggunaan tcode STVARV dapat menjadi solusi bagi abaperuntuk menghindari penggunaan constantmaupun table z
untuk menghindari hardcode. Namun, namavariabel yang di-defineddalam tcode tetap harus di-hardcode di program.
Selainitu, tcodeSTVARV tidak hanya bisamemaintainsinglevariabledalam bentuk parameter, tetapi juga dalam bentuk
selectoption. Berikutadalah cara penggunaannya.
Requirement: hardcode GL Accountyang digunakan dalam suatu program, yaituget data GL Accountdengan
range 0011021910 ~ 0011021918.
 MaintainvariableGL Accountpada tcode STVARV pada tab selectionoption. LaluSave.
 Pada abap program, get variabel valuedari table TVARVCyangmenyimpanvariabletcodeSTVARV.
DATA: t_stdbsart TYPE STANDARD TABLE OF tvarvc WITH HEADER LINE,
t_ska1 TYPE STANDARD TABLE OF ska1 WITH HEADER LINE.
RANGES: r_hkont FOR ska1-saknr.
SELECT * INTO CORRESPONDING FIELDS OF TABLE t_stdbsart
FROM tvarvc WHERE name EQ 'GL_ACCOUNT'.
IF LINES( t_stdbsart ) > 0.
LOOP AT t_stdbsart.
MOVE-CORRESPONDING t_stdbsart TO r_hkont.
r_hkont-option = t_stdbsart-opti.
APPEND r_hkont.
ENDLOOP.
ENDIF.
IF r_hkont[] is NOT INITIAL.
SELECT * FROM ska1 INTO TABLE t_ska1
WHERE saknr in r_hkont.
ENDIF.
Variableyang di-create di tcode STVARV dapat ditransport dengan men-thick pilihan‘Includechangedentries intransport
request’ sebelum Save.
Displaying ALV in Splitter Container with heading using
ABAP OO
7 December2012 | AvinashPalavai | 6 Comments | SAP ABAP
Introduction:
Splitter Container can be used to display data either from two or more tables or from a single table based on
particular conditions in ALV format using a single container at a time.
The classes that are used for achieving this are as follows,
1. CL_GUI_CUSTOM_CONTAINER .
2. CL_GUI_SPLITTER_CONTAINER .
3. CL_GUI_CONTAINER .
4. CL_GUI_ALV_GRID .
5. CL_DD_DOCUMENT.
Procedure:
1. First we have to design a modulepool screen (Screen No.100 ) with two custom controls, each for ALV
and Heading as below,
1. Name the first control as "HEADING".
2. Name the second control as "MAIN_CONT".
3. Save and activate the screen.
4. Do the below coding in the report program.
5. Here i took a case of displaying the material details of a particular material type ‘ZSEM', in the parent split
alv list and the descriptions of those materials that are listed in parent split alv in child split alv.
6. The heading being maintained for this ALV is 'Material Master
Report'.*****************************Coding********************************
*REPORT ZOOALV_WITH_SPLITTER.
DATA : O_CC TYPE REF TO CL_GUI_CUSTOM_CONTAINER .
DATA : O_SC TYPE REF TO CL_GUI_SPLITTER_CONTAINER .
DATA : O_PART1 TYPE REF TO CL_GUI_CONTAINER .
DATA : O_PART2 TYPE REF TO CL_GUI_CONTAINER .
DATA : ALV_GRID1 TYPE REF TO CL_GUI_ALV_GRID .
DATA : ALV_GRID2 TYPE REF TO CL_GUI_ALV_GRID .
DATA : I_MARA TYPE TABLE OF MARA .
DATA : I_MAKT TYPE TABLE OF MAKT .
DATA : DD TYPE REF TO CL_DD_DOCUMENT.
START-OF-SELECTION .
call SCREEN 100.
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
* SET PF-STATUS 'xxxxxxxx'.
* SET TITLEBAR 'xxx'.
PERFORM create_objects.
PERFORM spli_main_cont .
PERFORM DISP_HEADING.
PERFORM disp_alv1 .
PERFORM disp_alv2 .
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Form CREATE_OBJECTS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* p1 text
* GET_CONTAINER
EXPORTING
ROW = 1
COLUMN = 1
RECEIVING
CONTAINER = O_PART1.
CALL METHOD O_SC->GET_CONTAINER
EXPORTING
ROW = 2
COLUMN = 1
RECEIVING
CONTAINER = O_PART2.
ENDFORM. " SPLI_MAIN_CONT
*&---------------------------------------------------------------------*
*& Form DISP_ALV1
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_STRUCTURE_NAME = 'MARA'
CHANGING
IT_OUTTAB = I_MARA.
ENDFORM . "DISP_ALV1
*&---------------------------------------------------------------------*
*& Form DISP_ALV2
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_STRUCTURE_NAME = 'MAKT'
CHANGING
IT_OUTTAB = I_MAKT.
ENDFORM. " DISP_ALV2
*&---------------------------------------------------------------------*
*& Form DISP_HEADING
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* HEADING .
CALL METHOD DD->ADD_TEXT
EXPORTING
TEXT = 'MATERIAL MASTER REPORT'
SAP_STYLE = HEAD .
CALL METHOD DD->DISPLAY_DOCUMENT
EXPORTING
CONTAINER = 'HEADING'.
ENDFORM. " DISP_LOGO
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP
How to Create a Custom Business Object in ABAP

More Related Content

What's hot

[2015/2016] Local data storage for web-based mobile apps
[2015/2016] Local data storage for web-based mobile apps[2015/2016] Local data storage for web-based mobile apps
[2015/2016] Local data storage for web-based mobile appsIvano Malavolta
 
Il n'y a pas que Polymer dans la vie… - RennesJS - 2017-06-27
Il n'y a pas que Polymer dans la vie… - RennesJS - 2017-06-27Il n'y a pas que Polymer dans la vie… - RennesJS - 2017-06-27
Il n'y a pas que Polymer dans la vie… - RennesJS - 2017-06-27Horacio Gonzalez
 
D2W Stateful Controllers
D2W Stateful ControllersD2W Stateful Controllers
D2W Stateful ControllersWO Community
 
Javascript Prototype Visualized
Javascript Prototype VisualizedJavascript Prototype Visualized
Javascript Prototype Visualized军 沈
 
Service Oriented Architecture -Unit II - Modeling databases in xml
Service Oriented Architecture -Unit II - Modeling databases in xml Service Oriented Architecture -Unit II - Modeling databases in xml
Service Oriented Architecture -Unit II - Modeling databases in xml Roselin Mary S
 
iOS UI Component API Design
iOS UI Component API DesigniOS UI Component API Design
iOS UI Component API DesignBrian Gesiak
 
C# Advanced L07-Design Patterns
C# Advanced L07-Design PatternsC# Advanced L07-Design Patterns
C# Advanced L07-Design PatternsMohammad Shaker
 
An Overview of the React Ecosystem
An Overview of the React EcosystemAn Overview of the React Ecosystem
An Overview of the React EcosystemFITC
 
Angular custom directives
Angular custom directivesAngular custom directives
Angular custom directivesAlexe Bogdan
 
JavaScript Workshop
JavaScript WorkshopJavaScript Workshop
JavaScript WorkshopPamela Fox
 
Apache Wicket Web Framework
Apache Wicket Web FrameworkApache Wicket Web Framework
Apache Wicket Web FrameworkLuther Baker
 
Zend Framework And Doctrine
Zend Framework And DoctrineZend Framework And Doctrine
Zend Framework And Doctrineisaaczfoster
 
JSP Standart Tag Lİbrary - JSTL
JSP Standart Tag Lİbrary - JSTLJSP Standart Tag Lİbrary - JSTL
JSP Standart Tag Lİbrary - JSTLseleciii44
 
Wicket Next (1.4/1.5)
Wicket Next (1.4/1.5)Wicket Next (1.4/1.5)
Wicket Next (1.4/1.5)jcompagner
 

What's hot (20)

Hibernate tutorial
Hibernate tutorialHibernate tutorial
Hibernate tutorial
 
Iq rails
Iq railsIq rails
Iq rails
 
[2015/2016] Local data storage for web-based mobile apps
[2015/2016] Local data storage for web-based mobile apps[2015/2016] Local data storage for web-based mobile apps
[2015/2016] Local data storage for web-based mobile apps
 
Il n'y a pas que Polymer dans la vie… - RennesJS - 2017-06-27
Il n'y a pas que Polymer dans la vie… - RennesJS - 2017-06-27Il n'y a pas que Polymer dans la vie… - RennesJS - 2017-06-27
Il n'y a pas que Polymer dans la vie… - RennesJS - 2017-06-27
 
D2W Stateful Controllers
D2W Stateful ControllersD2W Stateful Controllers
D2W Stateful Controllers
 
iOS API Design
iOS API DesigniOS API Design
iOS API Design
 
KAAccessControl
KAAccessControlKAAccessControl
KAAccessControl
 
Javascript Prototype Visualized
Javascript Prototype VisualizedJavascript Prototype Visualized
Javascript Prototype Visualized
 
Service Oriented Architecture -Unit II - Modeling databases in xml
Service Oriented Architecture -Unit II - Modeling databases in xml Service Oriented Architecture -Unit II - Modeling databases in xml
Service Oriented Architecture -Unit II - Modeling databases in xml
 
iOS UI Component API Design
iOS UI Component API DesigniOS UI Component API Design
iOS UI Component API Design
 
C# Advanced L07-Design Patterns
C# Advanced L07-Design PatternsC# Advanced L07-Design Patterns
C# Advanced L07-Design Patterns
 
An Overview of the React Ecosystem
An Overview of the React EcosystemAn Overview of the React Ecosystem
An Overview of the React Ecosystem
 
Angular custom directives
Angular custom directivesAngular custom directives
Angular custom directives
 
Real World MVC
Real World MVCReal World MVC
Real World MVC
 
JavaScript Workshop
JavaScript WorkshopJavaScript Workshop
JavaScript Workshop
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 
Apache Wicket Web Framework
Apache Wicket Web FrameworkApache Wicket Web Framework
Apache Wicket Web Framework
 
Zend Framework And Doctrine
Zend Framework And DoctrineZend Framework And Doctrine
Zend Framework And Doctrine
 
JSP Standart Tag Lİbrary - JSTL
JSP Standart Tag Lİbrary - JSTLJSP Standart Tag Lİbrary - JSTL
JSP Standart Tag Lİbrary - JSTL
 
Wicket Next (1.4/1.5)
Wicket Next (1.4/1.5)Wicket Next (1.4/1.5)
Wicket Next (1.4/1.5)
 

Similar to How to Create a Custom Business Object in ABAP

Javascript Objects Deep Dive
Javascript Objects Deep DiveJavascript Objects Deep Dive
Javascript Objects Deep DiveManish Jangir
 
Inverting Dependencies
Inverting DependenciesInverting Dependencies
Inverting DependenciesLuc Trudeau
 
Javascript Prototypal Inheritance - Big Picture
Javascript Prototypal Inheritance - Big PictureJavascript Prototypal Inheritance - Big Picture
Javascript Prototypal Inheritance - Big PictureManish Jangir
 
create-netflix-clone-02-server_transcript.pdf
create-netflix-clone-02-server_transcript.pdfcreate-netflix-clone-02-server_transcript.pdf
create-netflix-clone-02-server_transcript.pdfShaiAlmog1
 
I Heard React Was Good
I Heard React Was GoodI Heard React Was Good
I Heard React Was GoodFITC
 
Jump start to OOP, OOAD, and Design Pattern
Jump start to OOP, OOAD, and Design PatternJump start to OOP, OOAD, and Design Pattern
Jump start to OOP, OOAD, and Design PatternNishith Shukla
 
Jump Start To Ooad And Design Patterns
Jump Start To Ooad And Design PatternsJump Start To Ooad And Design Patterns
Jump Start To Ooad And Design PatternsLalit Kale
 
Getting Started with React, When You’re an Angular Developer
Getting Started with React, When You’re an Angular DeveloperGetting Started with React, When You’re an Angular Developer
Getting Started with React, When You’re an Angular DeveloperFabrit Global
 
SADI: A design-pattern for “native” Linked-Data Semantic Web Services
SADI: A design-pattern for “native” Linked-Data Semantic Web ServicesSADI: A design-pattern for “native” Linked-Data Semantic Web Services
SADI: A design-pattern for “native” Linked-Data Semantic Web ServicesLDBC council
 
Enterprise Level Application Architecture with Web APIs using Entity Framewor...
Enterprise Level Application Architecture with Web APIs using Entity Framewor...Enterprise Level Application Architecture with Web APIs using Entity Framewor...
Enterprise Level Application Architecture with Web APIs using Entity Framewor...Akhil Mittal
 
Hibernate Session 1
Hibernate Session 1Hibernate Session 1
Hibernate Session 1b_kathir
 
Java interview questions and answers
Java interview questions and answersJava interview questions and answers
Java interview questions and answersKrishnaov
 
Oracle Objects And Transactions
Oracle Objects And TransactionsOracle Objects And Transactions
Oracle Objects And Transactionstepsum
 
Mastering the Lightning Framework - Part 1
Mastering the Lightning Framework - Part 1Mastering the Lightning Framework - Part 1
Mastering the Lightning Framework - Part 1Salesforce Developers
 

Similar to How to Create a Custom Business Object in ABAP (20)

Javascript Objects Deep Dive
Javascript Objects Deep DiveJavascript Objects Deep Dive
Javascript Objects Deep Dive
 
01. design pattern
01. design pattern01. design pattern
01. design pattern
 
Graphql
GraphqlGraphql
Graphql
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 
Inverting Dependencies
Inverting DependenciesInverting Dependencies
Inverting Dependencies
 
Chapter 8 java
Chapter 8 javaChapter 8 java
Chapter 8 java
 
Javascript Prototypal Inheritance - Big Picture
Javascript Prototypal Inheritance - Big PictureJavascript Prototypal Inheritance - Big Picture
Javascript Prototypal Inheritance - Big Picture
 
create-netflix-clone-02-server_transcript.pdf
create-netflix-clone-02-server_transcript.pdfcreate-netflix-clone-02-server_transcript.pdf
create-netflix-clone-02-server_transcript.pdf
 
I Heard React Was Good
I Heard React Was GoodI Heard React Was Good
I Heard React Was Good
 
Jump start to OOP, OOAD, and Design Pattern
Jump start to OOP, OOAD, and Design PatternJump start to OOP, OOAD, and Design Pattern
Jump start to OOP, OOAD, and Design Pattern
 
Jump Start To Ooad And Design Patterns
Jump Start To Ooad And Design PatternsJump Start To Ooad And Design Patterns
Jump Start To Ooad And Design Patterns
 
Getting Started with React, When You’re an Angular Developer
Getting Started with React, When You’re an Angular DeveloperGetting Started with React, When You’re an Angular Developer
Getting Started with React, When You’re an Angular Developer
 
Entity Framework 4
Entity Framework 4Entity Framework 4
Entity Framework 4
 
SADI: A design-pattern for “native” Linked-Data Semantic Web Services
SADI: A design-pattern for “native” Linked-Data Semantic Web ServicesSADI: A design-pattern for “native” Linked-Data Semantic Web Services
SADI: A design-pattern for “native” Linked-Data Semantic Web Services
 
Fame
FameFame
Fame
 
Enterprise Level Application Architecture with Web APIs using Entity Framewor...
Enterprise Level Application Architecture with Web APIs using Entity Framewor...Enterprise Level Application Architecture with Web APIs using Entity Framewor...
Enterprise Level Application Architecture with Web APIs using Entity Framewor...
 
Hibernate Session 1
Hibernate Session 1Hibernate Session 1
Hibernate Session 1
 
Java interview questions and answers
Java interview questions and answersJava interview questions and answers
Java interview questions and answers
 
Oracle Objects And Transactions
Oracle Objects And TransactionsOracle Objects And Transactions
Oracle Objects And Transactions
 
Mastering the Lightning Framework - Part 1
Mastering the Lightning Framework - Part 1Mastering the Lightning Framework - Part 1
Mastering the Lightning Framework - Part 1
 

Recently uploaded

VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls KolkataVIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一
定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一
定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一3sw2qly1
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...SofiyaSharma5
 
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebGDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebJames Anderson
 
Networking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGNetworking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGAPNIC
 
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)Dana Luther
 
象限策略:Google Workspace 与 Microsoft 365 对业务的影响 .pdf
象限策略:Google Workspace 与 Microsoft 365 对业务的影响 .pdf象限策略:Google Workspace 与 Microsoft 365 对业务的影响 .pdf
象限策略:Google Workspace 与 Microsoft 365 对业务的影响 .pdfkeithzhangding
 
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一Fs
 
On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024APNIC
 
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls KolkataLow Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts servicevipmodelshub1
 
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130  Available With RoomVIP Kolkata Call Girl Alambazar 👉 8250192130  Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Roomdivyansh0kumar0
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Complet Documnetation for Smart Assistant Application for Disabled Person
Complet Documnetation   for Smart Assistant Application for Disabled PersonComplet Documnetation   for Smart Assistant Application for Disabled Person
Complet Documnetation for Smart Assistant Application for Disabled Personfurqan222004
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsThierry TROUIN ☁
 

Recently uploaded (20)

VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls KolkataVIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一
定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一
定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
 
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebGDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
 
Networking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGNetworking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOG
 
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
 
象限策略:Google Workspace 与 Microsoft 365 对业务的影响 .pdf
象限策略:Google Workspace 与 Microsoft 365 对业务的影响 .pdf象限策略:Google Workspace 与 Microsoft 365 对业务的影响 .pdf
象限策略:Google Workspace 与 Microsoft 365 对业务的影响 .pdf
 
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
 
On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024
 
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls KolkataLow Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
 
Vip Call Girls Aerocity ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Aerocity ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Aerocity ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Aerocity ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130  Available With RoomVIP Kolkata Call Girl Alambazar 👉 8250192130  Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
 
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
 
Model Call Girl in Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in  Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in  Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝
 
Complet Documnetation for Smart Assistant Application for Disabled Person
Complet Documnetation   for Smart Assistant Application for Disabled PersonComplet Documnetation   for Smart Assistant Application for Disabled Person
Complet Documnetation for Smart Assistant Application for Disabled Person
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with Flows
 

How to Create a Custom Business Object in ABAP

  • 1. Using Serializable Objects in ABAP For a project I was working on I had to build generic logging functionality in ABAP. There were two important requirements:  No noticeable effect on performance  Re-usable in different scenarios. With the first requirement in mind I decided to build an RFC enabled function module that I could approach via an asynchronous RFC call. That seemed a fine idea at the time, but not when you consider that no generic types are allowed in RFC modules and you can’t use object references in the interface parameters. These limitations seriously compromised my possibility to meet requirement number two as re -usability often goes hand in hand with the passing of generic data types. I complained about these restrictions by one of my esteemed colleagues and he asked me, why don’t you use serialized objects to pass data to your function module. As I hardly knew what he was talking about I decided to dive deeper in to this subject, ultimately leading to a satisfactory solution and to this blog. Serialization Before I continue I would like to explain how you can serialize (and de-serialize) objects in ABAP. I will first hit you with the definition of serialization, which hopefully will make a bit of sense in combination with the requirements above. “Serialization is the process of translating data structures or object states into a format that can be stored or transmitted and reconstructed later when the resulting series of bits is reread according to the serialization format, it can be used to create a semantically identical clone of the original object”. That is interesting stuff and just what I needed, a way to transmit an object instance and once transmitted a way to reconstruct it again and by doing so overcoming the limitations of my RFC function module. How does it work in ABAP Actually the possibility of object serialization has been available in ABAP for a long time but somehow it never crossed my path. Although there are already some blogs available on the subject I was missing an overview of all its possibilities (and limitations). So let’s start with the basics. Object serialization can be accessed with the CALL TRANSFORMATION statement in roughly the same way as you do a transformation of an internal table. To be able to serialize an object using this statement, its class must implement the interface IF_SERIALIZABLE_OBJECT. The result of this transformation is an XML (but JSON is possible as well) string or xstring. In ABAP it will look something like this. First we define a simple class which implements the interface IF_SERIALIZABLE_OBJECT and has one private attribute and a setter- and a getter-method.
  • 2. We can serialize an instance of this class into an XML-(x)string in the following way: The result (LV_SERIALIZED_OBJECT) is of type XSTRING and it describes the instance in an XML format. You can do everything with it what you also can do with any other variable. Like passing it as a parameter to a function module or for example store it in the database. ( If you plan to do the latter it might be a good idea to compress the data first before storing it, as more complex objects tend to take up a lot of storage.) If we check the LV_SERIALIZED_OBJECT in the debugger it looks like this: If you want the serialized object in JSON format then some additional coding has to be done as shown here. But let’s stick with the XML version for now. We have seen that serialization can be done, but it’s pretty useless if we cannot de-serialize it back to an object instance again. But have no fear this can be easily done by calling the transformation again in reversed order.
  • 3. It should not come as a surprise that the our object instance is working again as it should. And our private attribute with value ‘Will_I_surivive_serialization’ was shown on screen. So that is pretty cool! But let’s dive a bit deeper into the subject. A further look into serializable objects Object References In our simple example we have seen that our attribute ‘survives’ the serialization process. But what happens if our attribute is not a string variable but also an object instance. To test this I made a small adjustment to our class definition and defined ‘MYPRIVATEATTRIBUTE’ into TYPE REF TO Object. In my test I set an instance of class CL_CRM_ORGMAN_SERVICE as my attribute value and execute the serialization and deserialization. When I check the value of ‘MYPRIVATEATTRIBUTE’ in the debugger after the deserialization step I see it has the value {O:INITIAL}. So what’s happening here. This means that it didn’t survive serialization and the reason behind it is that class CL_CRM_ORGMAN_SERVICES self is not implementing the interface IF_SERIALIZABLE_OBJECT. So that is an important limitation you have to take into account when you decide to use serialization. If you have other reference variables inside your class make sure that they implement the interface IF_SERIALIZABLE_OBJECT as well because otherwise they will not be serialized. Data References But what about data references? Are they serializable? Let’s find out and put it to the test. I changed the definition of ‘MYPRIVATEATTRIBUTE’ into TYPE REF TO DATA and ran a simple test. Unfortunately the ‘MYPRIVATEATTRIBUTE’ didn’t survive the serialization process and after de-serialization it has the value {O:INITIAL} again. How could this be as I was told, and had read online, that it was possible. After some further investigation I found out that you have to supply the specific option data_refs = ‘heap_or_create’ to your transformation so that it will support data references. If you are interested there are actually a lot of options you can use for your transformations and an overview can be found here. But for now it suffices to say that data reference can be serialized but you have to tell your transformation to take them into account. See the example below for a working example.
  • 4. Clone vs. Clone? As stated above serialization can be used to create a semantically identical clone of the original object. But SAP also provides another method of object cloning you can use by calling the following statement SYSTEM- CALL OBJMGR CLONE <object> TO <cloned_object>. Let’s compare both and see what the difference is. To do so I made some changes to our class definition and it now implements the CLONE method from the interface IF_OS_CLONE. In my next example program I pass an new instance of myself (as it implements the IF_SERIALIZABLE_OBJECT interface) to the MYOBJECT attribute and after that I go through the serialization process and subsequently also make a clone of object LO_SERIALIZABLE_OBJECT. See code below: If we now compare all three objects we can see that cloning via the serialization is actually not delivering exactly the same result in relation to the cloning done via the system call. As can be seen in the diagram below. The difference between the deserialized object and the cloned object is that the latter is also a new instance of the same class but the attribute MYOBJECT is still referring to the same instance as the original
  • 5. LO_SERIALIZABLE_OBJECT. The deserialized object generates a new instance for the attribute MYOBJECT which actually makes sense as it goes through the same serialization process. This same principle will also apply if you use data references. Modified Serialization and Deserialization All the instance attributes for an object part are serialized as standard regardless of their visibility. To change this behavior, you can declare and implement the instance methods SERIALIZE_HELPER and DESERIALIZE_HELPER in the relevant class for each object part. In SAP there is a demo program called DEMO_SERIALIZABLE_OBJECT where this principle is demonstrated. As this blog is already getting quite large I will not go into much detail here. But for those who are interested in the topic please check here. Conclusion Serialization of object references and data references can be quite a useful tool in some specific cases. It has some limitations but I hope this blog made you aware of them. Serialization can for example be used for passing generic data to RFC function modules, but also for storing object states in the database. You will probably not use it every day but know that it is around and in some cases might help you out.
  • 6. How to Create a Custom Business Object Vishnu Vardhan April 12, 2016 Modules, Tips / How To It is often necessary to create a business object to create/post IDocs of specific objects like SALES Contracts. Most of SAP data migration projects uses LSMW as a tool for data load. Almost all master and transactional data can be loaded with LSMW BAPI/Idoc Option. But, for the business object like sales contracts (BUS2034) cannot be loaded with LSMW BAPI option because of missing BUS object BUS2034 in the bus iness object list. Step by step procedures for creating a custom business object: 1. Go to T-code LSMW. And check for the availability of Business object “BUS2034” in the BAPI method by creating any LSMW( For test) <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d679120c647767aea99 ef/1479398725345/Create+a+Custom+Business+Object+in+SAP" alt="Create a Custom Business Object in SAP" />
  • 7. Once if the system shows the error message” Enter a Valid Value”, we are required to create a Z-Business object for the Object “BUS2034”. 2. For this Process, go to the T-Code “BAPI”. Select the “Business Object Builder” from the Environment. <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d67ca01dbaea7589211 ed/1479398736298/SAP+Tips%3A+Create+a+Custom+Business+Object" alt="SAP Tips: Create a Custom Business Object" /> 3. Provide the details of fields as shown in Screen shot. Object Type: ZBUS2034, Click on create button. <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d67f086db433231038a
  • 8. 0a/1479398751149/SAP+Tip%3A+Create+a+Custom+Business+Object" alt="SAP Tip: Create a Custom Business Object" /> <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d68011bbee0c64b398c a2/1479398761174/SAP+Help%3A+Create+a+Custom+Business+Object" alt="SAP Help: Create a Custom Business Object" /> 4. Save the same in a Package. <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d68294d088ed2c69c82
  • 9. ff/1479398769964/SAP+Tips%3A+Create+a+Custom+Business+Object" alt="SAP Tips: Create a Custom Business Object" /> 5. Create a transport request and use the same in the Business object creation. <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d685101dbaea758921
  • 10. 7f3/1479398778878/SAP+Business+Object+Tips" alt="SAP Business Object Tips" /> 6. All the functions modules described in the Business Object BUS2034 will appear as shown. <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d687427d4bd5b2809e
  • 11. d40/1479398788019/SAP+Business+Object+Tip" alt="SAP Business Object Tip" /> 7. Select the method “CreateFromData” and release the status to “To Modified” as shown for the object type. <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d68942fe13185ab98aa 50/1479398796860/SAP+Tips+and+Tricks" alt="SAP Tips and Tricks" />
  • 12. 8. Select the method “CreateFromData” and release the status to “To Implemented” as shown for the object type. <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d68b301dbaea758921c 97/1479398806536/SAP+Screenshots" alt="SAP Screenshot s" /> 9. Select the method “CreateFromData” and release the status to “To Released” as shown for the object type. <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d68c801dbaea758921f e3/1479398814202/SAP+Custom+Business" alt="SAP Custom Business" />
  • 13. 10. Select the method “CreateFromData” and release the object type component status to “To Modified” as shown for the object type. <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d68e601dbaea758922 241/1479398846316/Create+a+Custom+Business+Object+in+SAP" alt="Create a Custom Business Object in SAP" /> 11. Select the method “CreateFromData” and release the status to “To Implemented” as shown for the object type. <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d68fe01dbaea7589223 6b/1479399060287/Create+a+Custom+Business+Object+in+SAP" alt="Create a Custom Business Object
  • 14. in SAP" /> 12. Select the method “CreateFromData” and release the status to “To Released” as shown for the object type. <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d6c36b654f9de9d8976 0b/1479399092824/SAP+Custom+Business+Objects" alt="SAP Custom Business Objects" /> 13. Finally, Come back to the main screen and Change the release status to “Released”. <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d6946746fb9385743bf
  • 15. 3e/1479398868475/Business+Object+SAP" alt="Business Object SAP" /> 14. Select the “Generate ALE Interface” from the Environment option of Menu in the Transaction “BAPI”. <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d6960746fb9385743c0 2c/1479398889562/Business+Object+SAP" alt="Business Object SAP" /> 15. Provide the Business Object name “ZVBUS2034” and select the method as “CREATEFORMDATA.” <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d6c611bbee0c64b39b8
  • 16. 49/1460497513623/" /> 16. Click on Create Option. <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d6997746fb9385743c2 2f/1479398931600/SAP+Business+Object" alt="SAP Business Object" />
  • 17. 17. Provide the Message Type as “ZZBAPI_CONTRACT_CREATEFROMDATA” <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d69c2746fb9385743c3 75/1479398945633/SAP+Business+Objects" alt="SAP Business Objects" /> 18. Create a package “ZOTC”, Function Group “ZBUS2034” and fill the details for the fields as shown. IDOC Type: ZZBAPI_CONTRACT_CREATEFROMDA01 Function Module for ALE Outbound Processing: ZZZALE_CONTRACT_CREATEFROMDATA Function Module for ALE Inbound Processing: ZIDOC_INPUT_ZZBAPI_CONTRACT_CR Function Group: ZBUS2034 Package: ZOTC <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d69da1bbee0c64b399e
  • 18. d2/1479398955770/Creating+Business+Objects+in+SAP" alt="Creating Business Objects in SAP" /> 19. Below screen will appears once we are done with the step #17. <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d6a2686db43323103a
  • 19. 0f5/1479398968429/Creating+Business+Object+in+SAP" alt="Creating Business Object in SAP" /> 20. Click on the IDoc Type “ZZBAPI_CONTRACT_CREATEFROMDA01” in the above screen and we will be navigated to the below screen. Go to Edit in the Menu, Click on “Setrelease”. <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d6a43e707ebd28d321 0ca/1479398977847/Creating+Business+Object+SAP" alt="Creating Business Object SAP" /> 21. Click on Back button. We will be navigated to the below screen.
  • 20. <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d6a61e707ebd28d321 237/1479398986775/How+To+Create+a+Custom+Business+Object+in+SAP" alt="How To Create a Custom Business Object in SAP" /> 22. Check the existence of business object “ZBUS2034” In the LSMW after the business object creation and providing the ALE interface. How to Create a Custom Business Object Vishnu Vardhan April 12, 2016 Modules, Tips / How To It is often necessary to create a business object to create/post IDocs of specific objects like SALES Contracts. Most of SAP data migration projects uses LSMW as a tool for data load. Almost all master and transactional data can be loaded with LSMW BAPI/Idoc Option. But, for the business object like sales contracts (BUS2034) cannot be loaded with LSMW BAPI option because of missing BUS object BUS2034 in the business object list. Step by step procedures for creating a custom business object: 1. Go to T-code LSMW. And check for the availability of Business object “BUS2034” in the BAPI method by creating any LSMW( For test)
  • 21. <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d679120c647767aea99 ef/1479398725345/Create+a+Custom+Business+Object+in+SAP" alt="Create a Custom Business Object in SAP" /> Once if the system shows the error message” Enter a Valid Value”, we are required to create a Z-Business object for the Object “BUS2034”. 2. For this Process, go to the T-Code “BAPI”. Select the “Business Object Builder” from the Environment. <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d67ca01dbaea7589211
  • 22. ed/1479398736298/SAP+Tips%3A+Create+a+Custom+Business+Object" alt="SAP Tips: Create a Custom Business Object" /> 3. Provide the details of fields as shown in Screen shot. Object Type: ZBUS2034, Click on create button. <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d67f086db433231038a 0a/1479398751149/SAP+Tip%3A+Create+a+Custom+Business+Object" alt="SAP Tip: Create a Custom Business Object" /> <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d68011bbee0c64b398c a2/1479398761174/SAP+Help%3A+Create+a+Custom+Business+Object" alt="SAP Help: Crea te a
  • 23. Custom Business Object" /> 4. Save the same in a Package. <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d68294d088ed2c69c82 ff/1479398769964/SAP+Tips%3A+Create+a+Custom+Business+Object" alt="SAP Tips: Create a Custom
  • 24. Business Object" /> 5. Create a transport request and use the same in the Business object creation. <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d685101dbaea758921
  • 25. 7f3/1479398778878/SAP+Business+Object+Tips" alt="SAP Business Object Tips" /> 6. All the functions modules described in the Business Object BUS2034 will appear as shown. <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d687427d4bd5b2809e
  • 26. d40/1479398788019/SAP+Business+Object+Tip" alt="SAP Business Object Tip" /> 7. Select the method “CreateFromData” and release the status to “To Modified” as shown for the object type. <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d68942fe13185ab98aa 50/1479398796860/SAP+Tips+and+Tricks" alt="SAP Tips and Tricks" />
  • 27. 8. Select the method “CreateFromData” and release the status to “To Implemented” as shown for the object type. <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d68b301dbaea758921c 97/1479398806536/SAP+Screenshots" alt="SAP Screenshots" /> 9. Select the method “CreateFromData” and release the status to “To Released” as shown for the object type. <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d68c801dbaea758921f e3/1479398814202/SAP+Custom+Business" alt="SAP Custom Business" />
  • 28. 10. Select the method “CreateFromData” and release the object type component status to “To Modified” as shown for the object type. <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d68e601dbaea758922 241/1479398846316/Create+a+Custom+Business+Object+in+SAP" alt="Create a Custom Business Object in SAP" /> 11. Select the method “CreateFromData” and release the status to “To Implemented” as shown for the object type. <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d68fe01dbaea7589223 6b/1479399060287/Create+a+Custom+Business+Object+in+SAP" alt="Create a Custom Business Object
  • 29. in SAP" /> 12. Select the method “CreateFromData” and release the status to “To Released” as shown for the object type. <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d6c36b654f9de9d897 6 0b/1479399092824/SAP+Custom+Business+Objects" alt="SAP Custom Business Objects" /> 13. Finally, Come back to the main screen and Change the release status to “Released”. <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d6946746fb9385743bf
  • 30. 3e/1479398868475/Business+Object+SAP" alt="Business Object SAP" /> 14. Select the “Generate ALE Interface” from the Environment option of Menu in the Transaction “BAPI”. <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d6960746fb9385743c0 2c/1479398889562/Business+Object+SAP" alt="Business Object SAP" /> 15. Provide the Business Object name “ZVBUS2034” and select the method as “CREATEFORMDATA.” <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d6c611bbee0c64b39b8
  • 31. 49/1460497513623/" /> 16. Click on Create Option. <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d6997746fb9385743c2 2f/1479398931600/SAP+Business+Object" alt="SAP Business Object" />
  • 32. 17. Provide the Message Type as “ZZBAPI_CONTRACT_CREATEFROMDATA” <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d69c2746fb9385743c3 75/1479398945633/SAP+Business+Objects" alt="SAP Business Objects" /> 18. Create a package “ZOTC”, Function Group “ZBUS2034” and fill the details for the fields as shown. IDOC Type: ZZBAPI_CONTRACT_CREATEFROMDA01 Function Module for ALE Outbound Processing: ZZZALE_CONTRACT_CREATEFROMDATA Function Module for ALE Inbound Processing: ZIDOC_INPUT_ZZBAPI_CONTRACT_CR Function Group: ZBUS2034 Package: ZOTC <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d69da1bbee0c64b399e
  • 33. d2/1479398955770/Creating+Business+Objects+in+SAP" alt="Creating Business Objects in SAP" /> 19. Below screen will appears once we are done with the step #17. <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d6a2686db43323103a
  • 34. 0f5/1479398968429/Creating+Business+Object+in+SAP" alt="Creating Business Object in SAP" /> 20. Click on the IDoc Type “ZZBAPI_CONTRACT_CREATEFROMDA01” in the above screen and we will be navigated to the below screen. Go to Edit in the Menu, Click on “Setrelease”. <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d6a43e 707ebd28d321 0ca/1479398977847/Creating+Business+Object+SAP" alt="Creating Business Object SAP" /> 21. Click on Back button. We will be navigated to the below screen.
  • 35. <img src="https://static1.squarespace.com/static/56a77c1b25981d11f5774bbe/t/570d6a61e70 7ebd28d321 237/1479398986775/How+To+Create+a+Custom+Business+Object+in+SAP" alt="How To Create a Custom Business Object in SAP" /> 22. Check the existence of business object “ZBUS2034” In the LSMW after the business object creation and providing the ALE interface.
  • 36.
  • 37. Business Object Delegation Skip to end of metadata  Created by Guest, lastmodified by Former Member on Nov 02, 2011 Go to startof metadata Business Object Delegation Applies To: Learners in w orkflow s, Business Object. Summary This document w illhelp people to understand business object delegation w hich can be further used in w orkflow s It w ill give a brief idea of w hat is Business Object, its components, properties. And how to delegate a business object and w hat is delegation and w hy w e delegate a std. business object. Author : Mamta Verma, Softw are Engineer, ES-SAP. Company: Infosys Technologies Ltd Created on: 6th DEC, 2008 Table of contents 1. Business Object Type - An Introduction.3 2. Role of Business Object types3 3. Business Object Properties3 4. Components of a Business Object4 5. Business Object Statutes5 6. Delegating a Business Object6 7. References13 1. Business Object Type - An Introduction Business Object Repository is an object oriented approach used to model Business Objects and processes. It is a collection of Business Object types and Interface types and also their components like attributes, methods and events . Business Object type is a representation of any business entity in an SAP system. Example of entity could be an employee, purchase order, etc. A BO type includes both the data of the entity and the functions it performs. Data is stored in form of BO attributes and functions in form of BO methods. Thus w e can understand BO as an object oriented approach to model business entities and processes. 2. Role of Business Object types Business Object has the follow ing functions: a. BO reduces the complexity of the SAP system by dividing it into smaller units. b. At BO level, non-SAP systems can communicate w ith SAP system. This can be done using BAPIs. c. BO enables various business components to communicate w ith each other. d. BO types acts as entry points to data and functions for an SAP System. e. BO's can be used in business w orkflow s, ALE and RFC. 3. Business Object Properties Each business object has the follow ing properties: a. Object Type ID - It is used for internal identification of the business object. b. Object Name - It is used for external identification of the business object. Using this property external system can interact w ith SAP system. c. Super Type - It is the parent object from w hich all the components of the BO are inherited. d. Name - It is a descriptive name of the BO. e. Description - It is a brief description of the business object type. f. Application - The application component to w hich the BO belongs to. g. Program - Program that w ill contain the ABAP code of the BO.
  • 38. 4. Components of a Business Object There are 5 components of a business object: a. Key Fields Ø Can be a combination of one or more fields Ø Is a specification of unique object key - to access a specific instance of a BO Ø Is a reference to underlying application table Ø Must be character based Ø Value set w hen creating a BO instance or by a method Ø Can be read from outside. Cannot be changed from outside Ø Maximum length of concatenated key field can be 70 characters b. Attributes Ø Properties and characteristics of a BO Ø Can be read from outside. Cannot be changed from outside Ø Can be single-line or multi-line Ø Can be instance independent (static) or instance dependent Types of attributes: • Virtual - Set by a method/BO program w hen accessed • DB field - Loaded from the database w hen accessed, based on the key fields c. Events Ø Indicates the occurrence of a status change of a BO Ø Can have parameters and exceptions like methods Ø Have listeners outside the BO. E.g. Workflow d. Methods Ø These are functions that encapsulates the functionalities of a BO Ø Can be synchronous or asynchronous Ø Can be instance independent or instance dependent Ø Can have parameters (mandatory/optional, single/multi-line, import/export/both) and exceptions Ø The ABAP implementation can be: • A function module • A BAPI • A transaction • A dialog module (Obsolete) • A report • Other ABAP forms (Direct implementation, ABAP class methods, system program etc.) Types of methods: • Synchronous - Result is returned directly to the calling program. • Asynchronous - Result can be returned to the calling program only through an event. e. Interface Types Ø Like models for BO Types Ø Do not have any key fields Ø Cannot be instantiated Ø Do not have development statuses Ø Can be inherited - substitute for multiple inheritance Ø Can have implementation Ø A BO Type can inherit one or more interfaces Ø Methods defined in an interface can be redefined in a BO Type Ø The interface IFSAP and its methods ExistenceCheck and Display are inherited by all BO Types by default 5. Business Object Statutes The follow ing are the different development statuses of a BO/BO Component: a. Modeled - Only defined (the method and its signature) b. Implemented - ABAP implementation is done, can be used for testing or internal use c. Released - Method ready to be used d. Obsolete - Attribute / Method / Event not to be used anymore 6. Delegating a Business Object Here w e w ill Discuss how to delegate a Business Object and w hat is Delegation and w hy w e use it? Q1>What is Delegation ?
  • 39. Ans1>Delegation, as the name implies, is a technique of replacing an original object type by its subtype to w hich additional events/methods may be added. Q2> Why we use Delegation? Ans2> If the standard SAP events don't fulfill your purpose, new events/methods may be added to the given object type. SAP doesn't allow changes to its original object types. It permits changes by using the concept of delegation. Q3>What are the uses of Delegating a BO? Ans3>By delegating a BO, àCustomers use their ow n object extensions w ith the tasks , events , etc. supplied by SAP. àWithout having to redefine existing tasks , w e can use standard objects w ith customer extensions. Transaction to be used-------SWO1 (Business Object Builder) 1)Create a business Object using transaction SWO1. 2)Now take super-type as BUS2012 w hich you w ant to delegate. 3)Save it in a 'Z' Package.
  • 40. 4)Click on Object type and go to EDIT. There change the release status of Object type to implement. 5) Again click on Object type and go to EDIT. Now change the release status of Object type to Release.
  • 41. 6)Now click on Methods and press create button. One Pop-up w ill come and here click on 'No'. Give the method name and description.
  • 42. 8) After this click on method that you have created. Go to EDIT-Change Release Status. Here first implement the object type component and then release it.
  • 43. Here you can notice both tick mark is coming in front of business object and method w e have created. It means method is created successfully. 10) Now in this method , w e can w rite our ow n code according to our requirement. In my w orkflow Ihave created one method just to add US w ith DEVHYD. For this I have created tw o parameter---ID , USID (under Parameter Tab)
  • 44.
  • 45. 11) Now click On Program tab for w riting code in our method. Here I have w ritten Code for adding US w ith DEVHYD. 12)Now save and come back. w e w illcome on SWO1 initial screen. Here under Setting tab click on Delegate.
  • 46. 13) Choose object type as Bus 2012 and click on Details Tab. 14) In Delegation type , w rite your 'z' object name and then save it.
  • 47. 15) Now w e can use it in any TASK. For this go to transaction PFTC. Write Business object in object type category. Press F4, the method w e have created w ill come. Now choose that. It means that in BO bus2012 delegation is done.
  • 48. ABAP 740 – LOOP AT with GROUP BY By Naimesh Patel | October 27, 2015 | Concepts | 36,384 | 8 The great new addition to old and gold LOOP AT is a GROUP BY in ABAP 740. This is an amazing addition to LOOP AT. Lets check it out! Introduction LOOP AT must be one of most commonly used syntax. You must be using that often as well. In ABAP 740, this new great addition GROUP BY has amazing capabilities. Syntax This is highlevel syntax using the GROUP BY LOOP AT t_customres INTO DATA(ls_cust1) GROUP BY ( route = ls_cust1-route SIZE = GROUP SIZE INDEX = GROUP INDEX ) ASCENDING REFERENCE INTO DATA(route_group). LOOP AT with GROUP BY As the name suggests, GROUP BY addition groups the rows of the ITAB and the executes the LOOP across the groups. The loop gets executed in two phases:  Group – A loop would be executed on the Group which would be created by GROUP condition  Group Loop – A loop would be on each group to access the rows of the group. This are members.
  • 49. Sounds amazing, huh? Things to Remember Few points to remember whenever you need to use this GROUP BY:  Group Key – You can specify any fields from the ITAB as part of the key.  Sorting order – default sorting order of the field is ASCENDING. But you can also specify ASCENDING or DESCENDING explicitly  Group members – If don’t need to access the members, you can use the WITHOUT MEMBERS Lets dip dive in the Examples and learn more. Example 1 – Get Unique values using the GROUP BY I’m using the same customer/route test data which I have used in other ABAP 740 examples. In this example 1, we’ll list down the unique Routes by creating the group based on the field ROUTE. The output would be also captured in the result variable created automatically. Also notice the use of the WITHOUT MEMBERS as members were not accessed at all. TYPES: BEGIN OF ty_customer, customer TYPE char10, NAME TYPE char30, city TYPE char30, route TYPE char10, END OF ty_customer. TYPES: tt_customers TYPE SORTED TABLE OF ty_customer WITH UNIQUE KEY customer. TYPES: tt_citys TYPE STANDARD TABLE OF char30 WITH EMPTY KEY. DATA(t_customres) = VALUE tt_customers( ( customer = 'C0001' NAME = 'Test Customer 1' city = 'NY' route = 'R0001' ) ( customer = 'C0002' NAME = 'Customer 2' city = 'LA' route = 'R0003' ) ( customer = 'C0003' NAME = 'Good Customer 3' city = 'DFW' route = 'R0001' ) ( customer = 'C0004' NAME = 'Best Customer 4' city = 'CH' route = 'R0003' ) ( customer = 'C0005' NAME = 'So So Customer 5' city = 'NY' route = 'R0001' ) ). * Simply get the unique Routes, use WITHOUT MEMBERS LOOP AT t_customres INTO DATA(ls_cust_2) GROUP BY ( route = ls_cust_2-route ) ASCENDING WITHOUT MEMBERS REFERENCE INTO DATA(route_group_2). WRITE: / route_group_2->route. ENDLOOP.
  • 50. The output would be like: Example 2 – Usage of MEMBERS, SIZE and INDEX The 2nd phase of the GROUP BY is the access the members of the LOOP. To get the members of the group, we need to LOOP AT GROUP within the main LOOP. This inner LOOP needs to use the group result to get the members. The new BASE addition of VALUE will provide all the field values for non group fields. More on BASE in upcoming articles. There are two inbuilt additions for the GROUP BY key. SIZE – This would have the number of rows in that group INDEX – Would be index number of the group, starting with 1. When the single field is used to make the key, the result would be created as the single field as shown in earlier example. When there are more than one field, the automatic variable would contain all those fields, as in this example. * Creates a group of Route * with members as all fields which matches the group LOOP AT t_customres INTO DATA(ls_cust1) GROUP BY ( route = ls_cust1-route SIZE = GROUP SIZE INDEX = GROUP INDEX ) ASCENDING REFERENCE INTO DATA(route_group). WRITE: / 'Group', route_group->index. WRITE: / route_group->route. DATA(members) = VALUE tt_customers( ). LOOP AT GROUP route_group ASSIGNING FIELD-SYMBOL(<route>). members = VALUE #( BASE members ( <route> ) ). ENDLOOP. LOOP AT members INTO DATA(ls_member). WRITE: /(5)", ls_member-customer, ls_member-name, ls_member-city. ENDLOOP. WRITE: /(5)", 'Group size ', route_group->size. SKIP 2. ENDLOOP. The output of this example is like this:
  • 51. In Debugging, you can see the created structure which is automatically created. Example 3 – Group By without explicit Result variable You can also choose not to specify the result variable at all. If you do so, the workarea used for the LOOP AT would be used for the putting the group data as well. But it would be the entire first matching record with group key. * Creates a group of Route and City * but without using the Group result LOOP AT t_customres INTO DATA(ls_cust)
  • 52. GROUP BY ( route = ls_cust-route city = ls_cust-city ) ASCENDING. WRITE: / ls_cust. DATA(members) = VALUE tt_customers( ). LOOP AT GROUP ls_cust ASSIGNING FIELD-SYMBOL(<route>). members = VALUE #( BASE members ( <route> ) ). ENDLOOP. LOOP AT members INTO DATA(ls_member). WRITE: /(5)", ls_member-customer, ls_member-name. ENDLOOP. SKIP 2. ENDLOOP. Output this example 3. As you can see here the entire first row of the group is being set in the LOOP.
  • 53. Move Cursor to next Row by Pressing Enter in OO ALV By Naimesh Patel | September 8, 2008 | OO ALV, Uncategorized | 10,295 | 4 I was wondering if it is possible to have the same functionality of the Excel: Press Enter and cursor will move to next row. As OO ABAP using the class CL_GUI_ALV_GRID provides so many methods for the processing at the Cell Levels. After looking to all the methods of the CL_GUI_ALV_GRID, I found there are so many methods which can do the processing at the Cell level. I have started to give the try. After certain tries, I was able to achieve what I was looking for. Code Snippet for the Class handler for ALV Grid Call *&---------------------------------------------------------------------* *& This codesnippetsets thehandlerof the evnets for the OO ALV *&---------------------------------------------------------------------* * DataDeclaration DATA: g_grid type ref to cl_gui_alv_grid, g_event_receiver type ref to lcl_event_receiver. * * Registering theEditevent CALL METHODg_grid->register_edit_event EXPORTING i_event_id = cl_gui_alv_grid=>mc_evt_enter. * * EventHandler create object g_event_receiver. * * Eventlistnermethod for EditEvent SET HANDLERg_event_receiver->handle_data_changed FOR g_grid. * * callingthe instance of theALV call method g_grid->set_table_for_first_display changing it_fieldcatalog = gt_fieldcat it_outtab = gt_outtab[].
  • 54. Code Snippet for the Class handler definition and Implementation *&---------------------------------------------------------------------* *& This codesnippetshows theEventHandlerClass's Definition *& andimplementation *&---------------------------------------------------------------------* * Definition class lcl_event_receiver definition. public section. methods: handle_data_changed FOR EVENTdata_changed OF cl_gui_alv_grid IMPORTINGer_data_changed. endclass. * Class Implementation class lcl_event_receiver implementation. method handle_data_changed. * * Localdata data: LE_ROW TYPE I, LE_VALUE TYPE C, LE_COL TYPE I, LES_ROW_ID TYPE LVC_S_ROW, LES_COL_ID TYPE LVC_S_COL, LES_ROW_NO TYPE LVC_S_ROID. * * GettingCurrent Cell CALL METHODG_GRID->GET_CURRENT_CELL IMPORTING E_ROW = le_row E_VALUE = le_value E_COL = le_col ES_ROW_ID = les_row_id ES_COL_ID = les_col_id ES_ROW_NO = les_row_no. * * Totalnumberof tables describe table gt_outtab lines sy-index. * * Gettingnextrow les_row_id-INDEX = les_row_id-INDEX + 1. les_row_no-ROW_ID = les_row_no-ROW_ID + 1. * * Set the Nextrow if les_row_id-index le sy-index. CALL METHODG_GRID->SET_CURRENT_CELL_VIA_ID EXPORTING IS_ROW_ID = les_row_id IS_COLUMN_ID = LES_COL_ID IS_ROW_NO = les_row_no. endif. endmethod. endclass.
  • 55. Hi, I use and it works! Try flush. call method grid->set_current_cell_via_id exporting is_row_no = ls_row_no "row number is_column_id = ls_col_id. "column number
  • 56. Requêtes SQL pour trouver les doublons La présence de doublons dans une base de données est néfaste pour les performances et l’intégrité des données. Cela augmente artificielle la taille d’une base de données tandis que les données sont potentiellement compromise. Table d’utilisateurs avec des enregistrements dupliqués Type de doublons Il y a trois type de doublons couramment sur les bases de données:  Doublon absolu : représente des “tuples” exactement identique. Plusieurs lignes qui ont les mêmes valeurs pour chaque colonne.  Doublon relatif : représente les “tuples” qui ont les mêmes valeurs sauf pour la clé. Le cas le plus typique ce sont les lignes identiques sauf pour la colonne “id”.  Quasi doublon : concerne les lignes qui sont presque identiques. La différence entre les lignes peut être une simple faute de frappe (double espace au lieu d’un seul) ou des différences entre majuscule et minuscule. Requête pour trouver les doublons absolus Il y a une solution simple pour trouver les doublons absolus. Il faut sélectionner les champs d’une table en les groupant par les colonnes souhaitées. La sélection des champs doit inclure un comptage du nombre de résultat. Puis il suffit de filtrer les résultats pour ne garder que ceux qui ont plus d’une ligne (donc au moins un doublons): SELECT COUNT(*) AS nbr_doublon, champ1, champ2, champ3 FROM table GROUP BY champ1, champ2, champ3 HAVING COUNT(*) > 1 Requête pour trouver les doublons relatifs
  • 57. Si une table possède des doublons sur toute les colonnes sauf sur la clé, par exemple pour une colonne ID, il est possible de les trouver à l’aide de la requête suivante: SELECT DISTINCT * FROM table t1 WHERE EXISTS ( SELECT * FROM table t2 WHERE t1.ID <> t2.ID AND t1.champ1 = t2.champ1 AND t1.champ2 = t2.champ2 AND t1.champ3 = t2.champ3 ) A savoir : dans la sous-requête il utiliser la commande WHERE sur chacun des champs où l’ont veut une égalité. Requête pour trouver les doublons sur une colonne seulement La requête est presque similaire à celle pour chercher les doublons absolus. Cette fois-ci nous allons prendre un exemple concret. Imaginons qu’on souhaite lister les utilisateurs ayant la même adresse email: SELECT COUNT(email) AS nbr_doublon, email FROM utilisateur GROUP BY email HAVING COUNT(email) > 1 Articles similaires :  Méthode pour supprimer les doublons dans une base de données SQL
  • 58. How to debug an IDOC Skip to end of metadata  Created by Cora Phelan,lastmodified on Apr 05, 2013 Go to startof metadata Purpose This w iki provides a demonstration of how to debug an IDOC. Overview The IDOC given in this example is based on invoice in materials management on a test system. Step 1 - Display IDOC with error in transaction WE02 Double click on the Control Record. View information on tab Typinfo:
  • 59. Select tab Partner. For inbound processing check the Sender information.
  • 60. . Step 2 - View Partner profiles in transaction WE20 Using the information from step 1: Partner type LI, Partner Number CP-CP01, Message type INVOIC, Message Variant MM In transaction WE20 Open folder for Partner Type LI
  • 61. Double click on partner number CP-CP01
  • 62. In the inbound parameters, double click on Message type INVOIC (Message variant MM)
  • 63. Double click on Process code
  • 64. Here you find the function code identification, in this instance IDOC_INPUT_INVOIC_MRM Step 3 - Set breakpoint on IDOC_INPUT_INVOIC_MRM and other relevant function modules for issue concerned via SE37
  • 65. Step 4 - Use transaction BD87 to debug IDOC concerned. In transaction BD87 enter concerned IDOC and execute.
  • 66. Select Button Process (F8). You then come to the first breakpoint set i.e. in this example on function module IDOC_INPUT_INVOIC_MRM
  • 67. Use F8 to go to the other relevant Breakpoints you have set. add lines( itab ) to total_linecount.
  • 68. SORT itab Quick Reference Syntax SORT itab [STABLE] { { [ASCENDING|DESCENDING] [AS TEXT] [BY { comp1 [ASCENDING|DESCENDING] [AS TEXT]} { comp2 [ASCENDING|DESCENDING] [AS TEXT]} ... ] } | { [BY (otab)] } | { [BY expr] } }. Extras: 1. ... STABLE 2. ... ASCENDING|DESCENDING 3. ... AS TEXT 4. ... BY compi [ASCENDING|DESCENDING] [AS TEXT] 5. ... BY (otab) 6. ... BY expr Effect This statement sorts an internal table itab by the size of its components. Here, default sizes are compared using the general comparison rules, that is:  Numeric and byte-like components are sorted by their values.  Character-like components are sorted by default by their binary representation (code page). Textual sorting of character-like components can be performed using the addition AS TEXT.  The sizes of other component types are compared using the corresponding rules for reference variables, structures, and internal tables. If no explicit sort key is entered using the addition BY, the internal table itab is sorted by the primary table key. The priority of the sort is based on the order in which the key fields are specified in the table definition. In standard keys, the sort is prioritized according to the order of the key fields in the row type of the table. If the primary table key of a standard table is empty, no sort takes place. If this is known statically, the syntax check produces a warning. Sorting is unstable by default, which means that the relative order of rows that do not have different sort keys is not preserved when they are sorted. The order can be different depending on the platform or when sorted multiple times. The addition STABLE can be used for stable sorting. itab expects a standard table or a hashed table.  In standard tables, the primary table index is applied in accordance with the sort order  In hashed tables, the internal order is modified. This internal order was defined either by inserting rows in the internal table or by a previous sort using the statement SORT. In both table categories, SORT specifies the order in which a subsequent LOOP runs without the addition USING KEY.
  • 69. Sorted tables cannot be sorted using SORT and applying the statement SORT to sorted tables is prohibited by the syntax. If the system only detects that a sorted table is to be sorted at runtime, a non-handleable exception is raised if this action could modify the existing sorting. The latter occurs in the following cases:  if the addition BY is used to specify a different sort key as the initial part of the table key.  if the addition DESCENDING is used.  if the addition AS TEXT is used.  if an attribute of an object is specified as a component in the addition BY. Otherwise, the statement SORT is ignored for sorted tables. Notes  It is best to specify an explicit sort key behind BY, if possible. An implicit sort behind the primary table key (which can itself, in standard tables, be defined implicitly as a standard key) makes a program difficult to understand and possibly unpredictable.  When using the primary table key, note that this key can be the standard key, which can also have unexpected consequences:  If the row type is structured, the table is sorted by all character-like and byte-like components.  The standard key of a standard table can be empty.  Secondary table keys cannot be specified as sort keys.  SORTs are ignored by the assignment of rows to a secondary table index.  The addition GROUP BY of the statement LOOP AT itab or of a FOR expression also has the additions ASCENDING and DESCENDING for sorting groups. These can be used to expand the statement SORT if its sort criteria are not sufficient (see the executable example).  It is possible to sort columns with reference types but doing this is questionable. Here it is important to note that no comparison rule is defined for non-initial invalid references. An internal table can only be sorted by valid or initial references. A non-initial, invalid reference leads to a runtime error if it is involved in sorting.  System class CL_ABAP_ITAB_UTILITIES contains method VIRTUAL_SORT, which can be used to virtually sort a set of internal tables. See also the executable examples listed below. Example Simplest form of statement SORT for internal tables. The hash table carriers is sorted by its primary key (in other words, sorted by column carrid). DATA carriers TYPE HASHED TABLE OF scarr WITH UNIQUE KEY carrid. SELECT * FROM scarr INTO TABLE @carriers. SORT carriers. Executable Examples  Sorting Internal Tables  Sorting Internal Tables with Secondary Keys Addition 1
  • 70. ... STABLE Effect STABLE is used to perform stable sorts, which means that the relative order of rows (an order that does not change in the sort key) remains unchanged in the sort. If the STABLE addition is not specified, the order is not stable:  The order can depend on the platform.  Multiple sorting of a table using the same sort key can produce a different order each time the table is sorted. Example Stabile sorting of internal table flights by columns cityfrom cityto, whereby the order within this sorting with regards to carrid and connid remains the same. SELECT carrid, connid, cityfrom, cityto FROM spfli ORDER BY carrid, connid INTO TABLE @DATA(flights). SORT flights STABLE BY cityfrom cityto. Addition 2 ... ASCENDING|DESCENDING Effect The addition ASCENDING or DESCENDING can be used to specify the sort direction explicitly as ascending or descending. If neither of the additions is specified, the table is sorted in ascending order. This sort direction can be overwritten after the addition BY for components specified individually here. Example The internal table itab is sorted by its primary key (in other words, by its rows). Next, LOOP AT GROUP BY can be used for grouping and determine the number of rows per group. DATA itab TYPE TABLE OF i WITH NON-UNIQUE KEY table_line. DATA(rnd) = cl_abap_random_int=>create( seed = + sy-uzeit min = 1 max = 10 ). itab = VALUE #( FOR i = 1 UNTIL i > 100 ( rnd->get_next( ) ) ). SORT itab DESCENDING. LOOP AT itab ASSIGNING FIELD-SYMBOL(<fs>) GROUP BY ( key = <fs> size = GROUP SIZE ) ASSIGNING FIELD-SYMBOL(<key>). cl_demo_output=>write( |{ <key>-key WIDTH = 4 }{ <key>-size }| ). ENDLOOP. cl_demo_output=>display( ). Addition 3 ... AS TEXT Effect
  • 71. The addition AS TEXT specifies that text-like components are sorted in accordance with the locale of the current text environment. If AS TEXT is not specified, text-like components are sorted according to the encoding in the code page of the current text environment. This can be overwritten after the addition BY for the components specified individually here. The text environment is set when an internal session is opened or by using the statement SET LOCALE. Notes  The result of sorting without the addition AS TEXT depends on the operating system of the application server. Although the sequence of individual letters that belong to the activated language remains the same across different operating systems, there are differences in terms of the characters that do not belong to the alphabet of the activated language. Even if only the letters from the alphabet of the activated language are used, some slight differences occur when sorting complete words. Furthermore, the order of uppercase and lowercase letters is specific to the operating system.  The use of the addition AS TEXT usually renders the statement CONVERT TEXT superfluous in the context of internal tables.  A sort without the addition AS TEXT is considerably faster than a sort that does use this addition. If it is certain that both sorts produce the same order, the addition AS TEXT is not necessary. This can be the case if, for example, text-like components contain characters from the ASCII character set only and only lowercase or uppercase letters. Example Sorting a hashed table text_tab by the order in the code page and in accordance with the locale of the current text environment. If a western European text environment is configured, the sorts produce the orders Miller, Moller, Muller, Möller and Miller, Moller, Möller, Muller respectively (also see the executable example for SET LOCALE). CLASS demo DEFINITION. PUBLIC SECTION. CLASS-METHODS main. PRIVATE SECTION. CLASS-DATA text_tab TYPE HASHED TABLE OF string WITH UNIQUE KEY table_line. ENDCLASS. CLASS demo IMPLEMENTATION. METHOD main. text_tab = VALUE #( ( `Muller` ) ( `Möller` ) ( `Moller` ) ( `Miller` ) ). SORT text_tab. cl_demo_output=>write_data( text_tab ). SORT text_tab AS TEXT. cl_demo_output=>display_data( text_tab ). ENDMETHOD. ENDCLASS. START-OF-SELECTION. demo=>main( ). Executable Example Sorting Internal Tables Alphabetically Addition 4 ... BY compi [ASCENDING|DESCENDING] [AS TEXT] Effect The addition BY compi does not sort the table by the primary table key, but by the components comp1 comp2... specified after it instead. The components are specified as described under Specifying Components. If all components are specified using name variables and these variables contain only blanks, no sort takes place. The priority of the sort
  • 72. depends on the order in which the components comp1 comp2 ... are specified from left to right. The specified components can also be duplicated or can overlap. The specified components can have any data type. The relevant comparison rules apply to the evaluation. If neither of the additions ASCENDING or DESCENDING are specified after compi, the sort direction specified by addition 2 is used. If one of the additions ASCENDING or DESCENDING is specified, it overwrites the default for this component. If the addition AS TEXT is not specified after a text-like component compi, the instructions defined by addition 3 are used. If the addition AS TEXT is specified after a text-like component, it overwrites the default for this component. In non-text-like components, AS TEXT cannot be specified, unless a structured component is specified. In structured components, AS TEXT only affects text-like components. Notes  If the row type of the internal table is not known statically, the components can only be specified dynamically and not directly.  Instead of individual dynamic components, an internal table can be specified directly as otab or as the result of an expression expr as a dynamic sort key (see additions 5 and 6). Using a table like this has the advantage that any exceptions are handleable. When specifying the table, the number of components of the sort key is also dynamic. In contrast, when individual dynamic components are used, a character-like data object must be specified for any required component, which is ignored if it only contains blank characters.  An obsolete variant allows field symbols to also be specified for the components outside of classes, for standard tables. Example Sorting in ascending order of internal table itab by column col1 and sorting in descending order by column col2. TYPES: BEGIN OF line, col1 TYPE c LENGTH 1, col2 TYPE i, END OF line. DATA itab TYPE STANDARD TABLE OF line WITH EMPTY KEY. itab = VALUE #( ( col1 = 'A' col2 = 6 ) ( col1 = 'B' col2 = 4 ) ( col1 = 'B' col2 = 7 ) ( col1 = 'C' col2 = 1 ) ( col1 = 'C' col2 = 3 ) ( col1 = 'B' col2 = 9 ) ( col1 = 'A' col2 = 2 ) ( col1 = 'A' col2 = 5 ) ( col1 = 'C' col2 = 8 ) ). SORT itab BY col1 ASCENDING col2 DESCENDING. cl_demo_output=>display( itab ). Addition 5 ... BY (otab) Effect The addition BY (otab) does not sort the table by the primary table key, but by the component specified dynamically in the internal table otab instead. Each row of the table otab defines a component of the sort key. The priority of the sort is based on the order of the rows in otab. If the table otab is initial, the table is not sorted. For otab, a standard table of the table type ABAP_SORTORDER_TAB from ABAP Dictionary must be specified. The row type of this table is the dictionary structure ABAP_SORTORDER with the following components:
  • 73.  NAME of type SSTRING for specifying a component of the sort key. The component is specified in the form "comp_name[+off(len)]", where "comp_name" must be the name of a component in itab (uppercase characters). The component name may contain offsets and lengths, structure component selectors, and component selectors for assigning structured data objects and attributes in classes or objects.  DESCENDING of the type CHAR of a length 1 for specifying the sort direction for the current component. If DESCENDING is initial, the sort is performed in ascending order. If DESCENDING has the value "X", the table is sorted in descending order.  ASTEXT of type CHAR with length 1 for the text sorting of the current component. If ASTEXT has the value "X", the sort is performed as with the addition AS TEXT. This is only possible for character-like components. If ASTEXT is initial, character-like components are sorted in accordance with their binary representation. If a column of otab has invalid content (that is, if NAME contains the name of a component that does not exist or an incorrect offset/length or if DESCENDING and ASTEXT do not contain "X" or the initial value), this raises a handleable exception of the class CX_SY_DYN_TABLE_ILL_COMP_VAL. Notes  The addition BY (otab) cannot be combined with BY compi.  When using the addition BY (otab), it is not possible to use DESCENDING or AS TEXT to specify a descending sort direction or textual sorting for all components.  If a single parenthesized data object (dobj) is specified after the BY addition, its data type decides whether its content is used to specify a single dynamic component or multiple components. In either case, no sort takes place if dobj is initial. Example Dynamic import of a database table into a dynamic internal table and dynamic sorting of its content. The name of the database table and the names of the columns (which the table is to be sorted by) can be entered. DATA dbtab TYPE c LENGTH 30 VALUE 'spfli'. cl_demo_input=>add_field( CHANGING field = dbtab ). DATA columns TYPE string VALUE `cityfrom, cityto`. cl_demo_input=>request( CHANGING field = columns ). dbtab = condense( to_upper( dbtab ) ). DATA dref TYPE REF TO data. FIELD-SYMBOLS <itab> TYPE STANDARD TABLE. TRY. CREATE DATA dref TYPE STANDARD TABLE OF (dbtab). ASSIGN dref->* TO <itab>. CATCH cx_sy_create_data_error. cl_demo_output=>display( 'Wrong data type!' ). LEAVE PROGRAM. ENDTRY. TRY. SELECT * FROM (dbtab) INTO TABLE @<itab>. CATCH cx_sy_dynamic_osql_semantics. cl_demo_output=>display( 'Wrong database table!' ). LEAVE PROGRAM. ENDTRY. SPLIT columns AT `,` INTO TABLE DATA(column_tab). DATA(order) = VALUE abap_sortorder_tab( FOR wa IN column_tab ( name = condense( to_upper( wa ) ) ) ).
  • 74. TRY. SORT <itab> BY (order). CATCH cx_sy_dyn_table_ill_comp_val. cl_demo_output=>display( 'Wrong column name!' ). LEAVE PROGRAM. ENDTRY. cl_demo_output=>display( <itab> ). Addition 6 ... BY expr Effect The addition BY expr can be used to specify an expression or a functional method call expr whose result is an internal table with the same type and content as in the preceding addition BY (otab). expr is a general expression position. The behavior is the same as when specifying a parenthesized internal table directly. Note Parentheses cannot be placed around expr. Example The above example for specifying BY (otab) can be written in a shorter form as shown below. Instead of specifying the unnecessary internal table order, you can specify the tabular value (constructed using value operator VALUE) of the required content. ... SPLIT columns AT `,` INTO TABLE DATA(column_tab). TRY. SORT <itab> BY VALUE #( FOR wa IN column_tab ( name = condense( to_upper( wa ) ) ) ). CATCH cx_sy_dyn_table_ill_comp_val. cl_demo_output=>display( 'Wrong column name!' ). LEAVE PROGRAM. ENDTRY. ... Executable Example Sorting Internal Tables Dynamically. Exceptions Non-Handleable Exceptions CX_SY_DYN_TABLE_ILL_LINE_TYPE  Cause: The table otab has a prohibited line type. Runtime error: DYN_TABLE_ILL_LINE_TYPE CX_SY_DYN_TABLE_ILL_COMP_VAL  Cause: A column of the table otab contains a prohibited value. Runtime error: DYN_TABLE_ILL_COMP_VAL Non-Handleable Exceptions  Cause: A sort criterion dynamically specified in the form (name) with the explicit addition AS TEXT is not text- like. Runtime error: SORT_AS_TEXT_BAD_DYN_TYPE
  • 75.  Cause: A field symbol used as a dynamic sort criterion with an explicit addition AS TEXT is not text-like. Runtime error: SORT_AS_TEXT_BAD_FS_TYPE  Cause: A field symbol used as a dynamic sort criterion does not point to the header row of the internal table to be sorted. Runtime error: SORT_ITAB_FIELD_INVALID  Cause: For a table of the type SORTED TABLE, the sort key does not match a beginning piece of the table key. Runtime error: SORT_SORT_ILL_KEY_ORDER  Cause: The additions DESCENDING and AS TEXT are not allowed for tables of the type SORTED TABLE. Runtime error: SORT_SORT_ILLEGAL  Cause: More than 250 sort criteria. Runtime error: SORT_TOO_MANY_FIELDS  Cause: Sort mode neither 'E'(xternal) nor 'I'(nternal) Runtime error: SORT_ILLEGAL_MODE
  • 76. ABAP 740 – LINE_EXISTS to check record in ITAB By Naimesh Patel | March 9, 2015 | Concepts | 38,001 | 4 As name suggests, this new predictive function checks if the Line is available in the internal table or not. Introduction LINE_EXISTS can be used instead of the Table Expressions. Here are the few things to consider:  LINE_EXISTS is same as READ TABLE … TRANSPORTING NO FIELDS .. followed by SY-SUBRC CHECK.  The call doesn’t return any value. It only checks if the line is there in the table with specified key or not  This Function doesn’t set the system field SY-TABIX. So, this can’t be used if you want to use the Parallel Cursor. So, I think you would need use still use the old READ TABLE statement.  From SAP Help, This function should be used carefully – you should not use this function to first check if the line is there in the table and than use the table expression to read the table. Instead of that, only the table expression assigning to Field Symbol followed by catching the exception as you did in the article ABAP 740 – Table Expressions to Read & Modify ITAB line, example 5 When to use LINE_EXISTS As mentioned earlier, it can only replace few instanced of the READ TABLE… TRANSPORTING NO FIELDS which are not using the result value. If you want the result value, use the Table expression instead. If you want to use the SY-TABIX, you would need to use the old READ TABLE statement. I got excite to replace my parallel cursor algorithms but I think I would need to halt on that Lets see few example. Example – Simple Usage with SY fields behavior Check if the line exist with the value which exists in the table, followed by the entry which doesn’t exist with equivalent old code. DATA: t_data TYPE STANDARD TABLE OF i.
  • 77. DATA(lv_value) = 9. DO 10 TIMES. APPEND sy-INDEX TO t_data. ENDDO. * WRITE: / '>>>> New', lv_value. IF line_exists( t_data[ TABLE_LINE = lv_value ] ). WRITE: /(20) 'Found', lv_value. ELSE. WRITE: /(20) 'Not Found', lv_value. ENDIF. WRITE: /(20) 'SUBRC', sy-subrc, /(20) 'TABIX', sy-tabix, /(20) 'INDEX', sy-INDEX. * lv_value = 15. WRITE: / '>>> New', lv_value. IF line_exists( t_data[ TABLE_LINE = lv_value ] ). WRITE: /(20) 'Found', lv_value. ELSE. WRITE: /(20) 'Not Found', lv_value. ENDIF. WRITE: /(20) 'SUBRC', sy-subrc, /(20) 'TABIX', sy-tabix, /(20) 'INDEX', sy-INDEX. * old WRITE: /'<<<< OLD', lv_value. READ TABLE t_data TRANSPORTING NO FIELDS WITH KEY TABLE_LINE = lv_value. IF sy-subrc EQ 0. WRITE: /(20) 'Found', lv_value. ELSE. WRITE: /(20) 'Not Found', lv_value. ENDIF. WRITE: /(20) 'SUBRC', sy-subrc, /(20) 'TABIX', sy-tabix, /(20) 'INDEX', sy-INDEX. &#91;/abap_code&#93; AS you can notice FROM the OUTPUT; SY-TABIX,SY-INDEX,SY-SUBRC doesn't reset from the LINE_EXISTS call. <div class="post-image"><img src="http://zevolving.com/wp- content/uploads/2015/03/ABAP_740_Line_Exists_Example_1.png" alt="ABAP_740_Line_Exists_Example_1" width="410" height="382" class="alignnone size-full wp-image-2846" /></div> <h3>Example - Simple Negative Usage with SY fields behavior</h3> Negative check using NOT and NE .. [abap_code slider="X" title=""] * lv_value = 15. WRITE: / '>>> New',lv_value. IF NOT line_exists( t_data[ table_line = lv_value ] ). WRITE: /(20) 'NOT Found', lv_value. ELSE. WRITE: /(20) 'Found', lv_value. ENDIF. * old WRITE: /'<<<< OLD',lv_value.
  • 78. READ TABLE t_data TRANSPORTINGNO FIELDS WITH KEY table_line = lv_value. IF sy-subrc NE 0. WRITE: /(20) 'NOT Found', lv_value. ELSE. WRITE: /(20) 'Found', lv_value. ENDIF. &#91;/abap_code&#93; <div class="post-image"><img src="http://zevolving.com/wp- content/uploads/2015/03/ABAP_740_Line_Exists_Example_2.png" alt="ABAP_740_Line_Exists_Example_2" width="413" height="203" class="alignnone size-full wp-image-2847" /></div> <h3>Example - Compare with Table Expression and LINE_EXISTS and READ</h3> [abap_code slider="X" title=""] * New function lv_value = 15. WRITE: / '>>> New',lv_value. IF NOT line_exists( t_data[ table_line = lv_value ] ). WRITE: /(20) 'NOT Found', lv_value. ELSE. WRITE: /(20) 'Found', lv_value. ENDIF. * New Way TRY . lv_value = 7. WRITE: / '>>> New WITH TABLE Expression', lv_value. DATA(lv_num) = t_data[ table_line = lv_value ]. WRITE: /(20) 'SUBRC',sy-subrc, /(20) 'TABIX',sy-tabix, /(20) 'INDEX',sy-index. CATCH cx_sy_itab_line_not_found. WRITE: / 'NOT found'. ENDTRY. * old WRITE: /'<<<< OLD',lv_value. READ TABLE t_data TRANSPORTINGNO FIELDS WITH KEY table_line = lv_value. IF sy-subrc NE 0. WRITE: /(20) 'NOT Found', lv_value. ELSE. WRITE: /(20) 'Found', lv_value. ENDIF. &#91;/abap_code&#93; Even table expression don't RESET the SY-TABIX FIELD ... <div CLASS="post-image"><img src="http://zevolving.com/wp- content/uploads/2015/03/ABAP_740_Line_Exists_Example_3.png" alt="ABAP_740_Line_Exists_Example_3" width="403" height="285" class="alignnone size-full wp-image-2848" /></div> <h3>Example - Multiple Component check</h3> LINE_EXISTS works WITH SIMPLE multiple component CHECK AS well. [abap_code slider="X" title=""] * Multiple Components TYPES: BEGIN OF ty_data, kunnr TYPE kunnr, name1 TYPE name1, ort01 TYPE ort01, land1 TYPE land1, END OF ty_data.
  • 79. TYPES: tt_data TYPE STANDARD TABLE OF ty_data WITH DEFAULT KEY. * DATA(itab_multi_comp) = VALUE tt_data( ( kunnr = '123' name1 = 'ABCD' ort01 = 'LV' land1 = 'NV' ) ( kunnr = '456' name1 = 'XYZ' ort01 = 'LA' land1 = 'CA' ) ). WRITE: / 'NEW'. IF line_exists( itab_multi_comp[ kunnr = '456' ] ). WRITE: / ' Customer found'. ELSE. WRITE: / ' Customer Not found'. ENDIF. * old WRITE: / 'OLD'. READ TABLE itab_multi_comp TRANSPORTING NO FIELDS WITH KEY kunnr = '456'. IF sy-subrc EQ 0. WRITE: / ' Customer found'. ELSE. WRITE: / ' Customer Not found'. ENDIF. Output Example – Chaining of Table Expression within LINE_EXISTS now allowed * Itab Deep TYPES: BEGIN OF ty_alv_data, kunnr TYPE kunnr, name1 TYPE name1, ort01 TYPE ort01, land1 TYPE land1, t_color TYPE lvc_t_scol, END OF ty_alv_data. TYPES: tt_alv_data TYPE STANDARD TABLE OF ty_alv_data WITH DEFAULT KEY. DATA(itab_alv) = VALUE tt_alv_data( "First Row ( kunnr = '123' name1 = 'ABCD' ort01 = 'LV' land1 = 'NV' " color table
  • 80. t_color = VALUE #( " Color table - First Row ( fname = 'KUNNR' color-col = COL_NEGATIVE color-int = 0 color-inv = 0 ) " Color Table - 2nd Row ( fname = 'ORT01' color-col = COL_TOTAL color-int = 1 color-inv = 1 ) ) ) "Second row ( kunnr = '456' name1 = 'XYZ' ort01 = 'LA' land1 = 'CA' ) ). IF line_exists( itab_alv[ kunnr = '123' ]-t_color[ fname = 'ORT01' ]-color- col = COL_BACKGROUND ). ENDIF. This produces the syntax error that it doesn’t like it .. What do you think? I think I would more use the READ TABLE as generally need to get the access to SY-TABIX for parallel cursor. Table of Content – ABAP 740 Concepts  ABAP 740 – NEW Operator to instantiate the objects  ABAP 740 – NEW Operator to create ITAB entries  ABAP 740 – VALUE Operator to create ITAB entries  ABAP 740 – Table Expressions to Read & Modify ITAB line  ABAP 740 – LINE_EXISTS to check record in ITAB  ABAP 740 – Meshes – A new complex type of Structures
  • 81.  ABAP 740 – Mesh Path – Forward and Inverse Association  ABAP 740 – FOR Iteration Expression  ABAP 740 SWITCH – Conditional Operator  ABAP 740 – LOOP AT with GROUP BY  ABAP 740 – Is CONSTANT not a Static Attribute anymore?  SALV IDA (Integrated Data Access) – Introduction  SALV IDA – Selection Conditions  SALV IDA – New Calculated Fields  SALV IDA – Column Settings  SALV IDA – Add and Handle Hotspot (Hyperlink) Tags ABAP 740 Concepts ITAB Processing Table Expressions Like It? Share!! inShare Don't miss an Update fb/zevolving@zevolving+zevolving Get notified of the new post, right into your inbox Subscribe Naimesh Patel{273articles} I'm SAP ABAP Consultant for more than a decade. I like to experiment with ABAP especially OO. I have been SDN Top Contributor. Follow : Explore all of his 273 articles.  Related Post ABAP 740 – Table Expressions to Read & Modify ITAB line Read and Modify the ITAB records without using the temporary work area or variables. It is possible with using the ABAP Table Expressions. Lets see more about them. Preface Let me start with begging your apologies for not publishing any article in long time. I had to take a pause . I would try to… Read Post »  Related Post ABAP 740 – NEW Operator to create ITAB entries
  • 82. Similar to the NEW operator to instantiate the object, you can use the NEW as well with internal table processing to append rows within it. Preface In ABAP 740, we have new NEW operator to create the table entries. This NEW works similarly like . Lets take a look at what how NEW can be… Read Post » 4 Comments  Martin Pacovsky # March 10th, 2015 at 2:34 am Hi, is it possible to use this together with other key than whole TABLE LINE? Otherwise I see no sense to remember it, because TRANSPORTING NO FIELDS, as you mentioned, has much bigger area of use, and yes, no SY-TABIX is also awkward.  Naimesh Patel # March 10th, 2015 at 10:06 am Hello Martin, Yes, it does work with the Multiple components. I have added the example in the article for that now. I was more focused on the SY fields so didn’t focus on all other cases. Also added chaining of the table expression example which is not yet allowed using LINE_EXISTS. May be in next release Thanks, Naimesh Patel  Michal # April 15th, 2015 at 6:13 pm
  • 83. Hi Naimesh, I think the reason why line_exists does not work is stated in the documentation: The table expression is only used to check the existence of the specified row. No temporary result is created. To modify the deep component, the chaining table expressions can be used together with the exception handling (catching the exception is the same as line_exists = false). Check the snippet below: PROGRAM zchain. TYPES: BEGIN OF struc_2, b_2, c_2, END OF struc_2, tt2 TYPE STANDARD TABLE OF struc_2 WITH DEFAULT KEY, BEGIN OF struc_1, a_1, b_1 TYPE tt2, END OF struc_1, tt1 TYPE STANDARD TABLE OF struc_1 WITH DEFAULT KEY. DATA(lt) = VALUE tt1( ( a_1 = 'A' b_1 = VALUE #( ( b_2 = 'B' ) ( b_2 = 'C' ) ) ) ( a_1 = 'D' b_1 = VALUE #( ( b_2 = 'E' ) ( b_2 = 'F' ) ) ) ). TRY. DATA(b_2_value) = 'D'. "change to 'C' to get positive result lt[ a_1 = 'A' ]-b_1[ b_2 = b_2_value ]-c_2 = 'X'. WRITE:/ 'OK:', lt[ a_1 = 'A' ]-b_1[ b_2 = b_2_value ]-c_2. CATCH cx_sy_itab_line_not_found. WRITE:/ 'The desired record not found in nested table'. ENDTRY. BR Michal
  • 84.
  • 85. Quelque informationpouvantutile: Si smartformalimentationduprotocole : DATA: lt_errortab TYPE tsferror. DATA: lf_msgnr TYPE sy-msgno. DATA: l_s_log TYPE bal_s_log, p_loghandle TYPE balloghndl, l_s_msg TYPE bal_s_msg. FIELD-SYMBOLS: <fs_errortab> TYPE LINE OF tsferror. * get smart form protocoll CALL FUNCTION 'SSF_READ_ERRORS' IMPORTING errortab = lt_errortab. SORT lt_errortab. * delete adjacent duplicates from lt_errortab comparing errnumber. * add smartform protocoll to nast protocoll LOOP AT lt_errortab ASSIGNING <fs_errortab>. CLEAR lf_msgnr. lf_msgnr = <fs_errortab>-errnumber. CALL FUNCTION 'NAST_PROTOCOL_UPDATE' EXPORTING msg_arbgb = <fs_errortab>-msgid msg_nr = lf_msgnr msg_ty = <fs_errortab>-msgty msg_v1 = <fs_errortab>-msgv1 msg_v2 = <fs_errortab>-msgv2 msg_v3 = <fs_errortab>-msgv3
  • 86. msg_v4 = <fs_errortab>-msgv4 EXCEPTIONS OTHERS = 1. ENDLOOP. * open the application log l_s_log-extnumber = sy-uname. CALL FUNCTION 'BAL_LOG_CREATE' EXPORTING i_s_log = l_s_log IMPORTING e_log_handle = p_loghandle EXCEPTIONS OTHERS = 1. IF sy-subrc <> 0. ENDIF. LOOP AT lt_errortab ASSIGNING <fs_errortab>. MOVE-CORRESPONDING <fs_errortab> TO l_s_msg. CALL FUNCTION 'BAL_LOG_MSG_ADD' EXPORTING i_log_handle = p_loghandle i_s_msg = l_s_msg EXCEPTIONS OTHERS = 1. IF sy-subrc <> 0. ENDIF. ENDLOOP. ** Function module to display error logs during ** smart form processing ** Notice , the function 'BAL_DSP_LOG_DISPLAY' can ** not be used when you using output dispatch time ** 4 (Send immediately), so the statement is comment ** out by default. ** You can enable the function call statement ** if your form can not be output and you want to ** see the error log. Set output dispatch time to 3 ** before save your order, then print or preview the ** output. DATA lv_debug. IF NOT lv_debug IS INITIAL. CALL FUNCTION 'BAL_DSP_LOG_DISPLAY'. ENDIF. Préparationdusmartforma l’envoiede mail * Envoi par mail ELSE. * pas d'impression, on récupère juste le fichier OTF ls_control_param-getotf = 'X'. CALL FUNCTION lv_fm_name EXPORTING archive_index = toa_dara archive_parameters = arc_params control_parameters = ls_control_param mail_recipient = ls_recipient mail_sender = ls_sender output_options = ls_composer_param is_ekko = ls_doc-xekko ls_job_out_info-otfdata contient les information du smartform a envoyer
  • 87. user_settings = 'X' is_pekko = ls_doc-xpekko is_nast = ls_nast iv_from_mem = lv_from_memory iv_druvo = iv_druvo it_receiver = lt_receiver "M002(+) IMPORTING document_output_info = ls_doc_out_info job_output_info = ls_job_out_info job_output_options = ls_job_out_options * ev_mail_dest = l_mail "M002(-) TABLES it_ekpo = ls_doc-xekpo[] it_ekpa = ls_doc-xekpa[] it_pekpo = ls_doc-xpekpo[] it_eket = ls_doc-xeket[] it_tkomv = ls_doc-xtkomv[] it_ekkn = ls_doc-xekkn[] it_ekek = ls_doc-xekek[] it_komk = l_xkomk[] EXCEPTIONS formatting_error = 1 internal_error = 2 send_error = 3 user_canceled = 4 OTHERS = 5. DATA : lt_pdf_lines TYPE TABLE OF tline, lt_doctab_archive TYPE TABLE OF docs, lt_contents_out TYPE TABLE OF solisti1, lt_contents_hex TYPE TABLE OF solix, lt_contents_txt TYPE TABLE OF solisti1, ls_contents_txt TYPE solisti1, lt_objpack TYPE TABLE OF sopcklsti1, ls_objpack TYPE sopcklsti1, lt_object_header TYPE TABLE OF solisti1, * lt_receiver TYPE TABLE OF somlreci1, "M002(-) * ls_receiver TYPE somlreci1, "M002(-) ls_document_data TYPE sodocchgi1, lv_nb_lines TYPE i, l_mail TYPE ad_smtpadr, lv_ebeln TYPE ebeln, lv_commit TYPE xfeld. * Conversion en PDF CALL FUNCTION 'CONVERT_OTF_2_PDF' TABLES otf = put_otfdata doctab_archive = lt_doctab_archive lines = lt_pdf_lines EXCEPTIONS err_conv_not_possible = 1 err_otf_mc_noendmarker = 2 OTHERS = 3. * On change la largeur de la ligne CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE' TABLES content_in = lt_pdf_lines content_out = lt_contents_out EXCEPTIONS
  • 88. err_line_width_src_too_long = 1 err_line_width_dst_too_long = 2 err_conv_failed = 3 OTHERS = 4. TRY. CALL METHOD cl_bcs_convert=>bin_to_solix EXPORTING it_soli = lt_contents_out IMPORTING et_solix = lt_contents_hex. ENDTRY. Corps du mail ls_contents_txt-line = text-001. APPEND ls_contents_txt TO lt_contents_txt. * Définition des objets du mail : d'abord le corps du mail CLEAR ls_objpack. ls_objpack-transf_bin = ' '. ls_objpack-head_start = 0. ls_objpack-head_num = 0. ls_objpack-body_start = 1. DESCRIBE TABLE lt_contents_txt LINES lv_nb_lines. ls_objpack-body_num = lv_nb_lines. ls_objpack-doc_type = 'RAW'. APPEND ls_objpack TO lt_objpack. * Ensuite le formulaire commande d'achat en fichier joint CLEAR ls_objpack. ls_objpack-obj_descr = text-002. ls_objpack-transf_bin = 'X'. ls_objpack-head_start = 0. ls_objpack-head_num = 0. ls_objpack-body_start = 1. ls_objpack-doc_type = 'PDF'. DESCRIBE TABLE lt_contents_hex LINES lv_nb_lines. ls_objpack-body_num = lv_nb_lines. APPEND ls_objpack TO lt_objpack. Searchhelpou aide a larecherche serveurrepertoirserveur IF sy-batch EQ abap_false. * GUI mode CALL FUNCTION 'F4_DXFILENAME_TOPRECURSION' EXPORTING i_location_flag = lv_location " Flag: Application or presentation server i_path = sv_last_path filemask = lv_filemask fileoperation = lv_file_operation IMPORTING o_location_flag = cv_location o_path = cv_path EXCEPTIONS rfc_error = 1 error_with_gui = 2
  • 89. OTHERS = 3. IF sy-subrc NE 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. ENDIF. "sy-batch EQ abap_false. * Corps du mail ls_contents_txt-line = text-001. APPEND ls_contents_txt TO lt_contents_txt. * Définition des objets du mail : d'abord le corps du mail CLEAR ls_objpack. ls_objpack-transf_bin = ' '. ls_objpack-head_start = 0. ls_objpack-head_num = 0. ls_objpack-body_start = 1. DESCRIBE TABLE lt_contents_txt LINES lv_nb_lines. ls_objpack-body_num = lv_nb_lines. ls_objpack-doc_type = 'RAW'. APPEND ls_objpack TO lt_objpack. * Ensuite le formulaire commande d'achat en fichier joint CLEAR ls_objpack. ls_objpack-obj_descr = text-002. ls_objpack-transf_bin = 'X'. ls_objpack-head_start = 0. ls_objpack-head_num = 0. ls_objpack-body_start = 1. ls_objpack-doc_type = 'PDF'. DESCRIBE TABLE lt_contents_hex LINES lv_nb_lines. ls_objpack-body_num = lv_nb_lines. APPEND ls_objpack TO lt_objpack. Gestiondesimagespourl’envoie de mail mail_add_access_map USING pus_doc TYPE meein_purchase_doc_print CHANGING pct_content_hex TYPE INDEX TABLE pct_objpack TYPE INDEX TABLE. DATA : l_bytecount TYPE i, l_tdbtype LIKE stxbitmaps-tdbtype, l_content TYPE STANDARD TABLE OF bapiconten INITIAL SIZE 0, l_graphic_size TYPE i, ls_objpack TYPE sopcklsti1, lv_size TYPE i, lv_size_c TYPE char12, lv_nb_lines TYPE i, l_plan TYPE flag, l_name TYPE ad_name1, ls_ekpo TYPE ekpo, l_post_code TYPE ad_pstcd1. CALL FUNCTION 'SAPSCRIPT_GET_GRAPHIC_BDS' EXPORTING i_object = 'GRAPHICS' i_name = 'PLAN_ACCES_0006' i_id = 'BMAP' i_btype = 'BCOL' IMPORTING e_bytecount = l_bytecount TABLES
  • 90. content = l_content EXCEPTIONS not_found = 1 bds_get_failed = 2 bds_no_content = 3 OTHERS = 4. IF sy-subrc = 0. CALL FUNCTION 'SAPSCRIPT_CONVERT_BITMAP' EXPORTING old_format = 'BDS' new_format = 'BMP' bitmap_file_bytecount_in = l_bytecount IMPORTING bitmap_file_bytecount = l_graphic_size TABLES bds_bitmap_file = l_content bitmap_file = lt_graphic EXCEPTIONS OTHERS = 1. IF sy-subrc = 0. * On ajoute l'image en pièce jointe CLEAR ls_objpack. ls_objpack-obj_descr = text-004. ls_objpack-obj_name = text-004. ls_objpack-transf_bin = 'X'. ls_objpack-head_start = 0. ls_objpack-head_num = 0. DESCRIBE TABLE pct_content_hex LINES lv_nb_lines. ls_objpack-body_start = lv_nb_lines + 1. ls_objpack-doc_type = 'BMP'. APPEND LINES OF lt_graphic TO pct_content_hex. DESCRIBE TABLE pct_content_hex LINES ls_objpack-body_num. APPEND ls_objpack TO pct_objpack. ENDIF. Exemple de récupération de fichierdansle GOSpourenvoie de mail : Sur commande d’achatetDA FORM mail_add_attachment USING pus_doc TYPE meein_purchase_doc_print CHANGING pct_content_hex TYPE INDEX TABLE pct_objpack TYPE INDEX TABLE. DATA : lt_srgbtbrel TYPE TABLE OF srgbtbrel, ls_srgbtbrel TYPE srgbtbrel, lt_signature TYPE TABLE OF bapisignat, lt_components TYPE TABLE OF bapicompon, ls_components TYPE bapicompon, lt_content TYPE TABLE OF bapiconten, lt_solix TYPE TABLE OF solix, ls_solix TYPE solix, ls_object_key TYPE bds_typeid, ls_ekpo TYPE ekpo, ls_document_data TYPE sofolenti1, ls_objpack TYPE sopcklsti1,
  • 91. lv_doc_id TYPE so_entryid, lv_doc_id_otp TYPE so_entryid, "ACN(+) - 05022015 lv_size TYPE i, lv_xstring TYPE xstring, lv_extension TYPE char3, lv_size_c TYPE char12, lv_nb_lines TYPE i. DATA : r_societe TYPE fip_t_bukrs_range. DATA : flag_attach_doc_okay TYPE xfeld. * Récupération des pièces jointes sur la commande SELECT * FROM srgbtbrel INTO TABLE lt_srgbtbrel WHERE instid_a = pus_doc-xekko-ebeln AND typeid_a = 'BUS2012' AND catid_a = 'BO'. * Début de modification - ACN - 05022015 * Lecture de la 1ère pièce jointe * READ TABLE lt_srgbtbrel INTO ls_srgbtbrel INDEX 1. * IF sy-subrc = 0. * * lv_doc_id = ls_srgbtbrel-instid_b. * * ELSE. * Boucle sur les documents joints LOOP AT lt_srgbtbrel INTO ls_srgbtbrel. *{+M007 Construction de la table permettant de savoir si l'envoie de document attac hés * a la commande d'achat sont autorisés. AT FIRST. PERFORM societe_autorisee CHANGING r_societe. ENDAT. *}+M007 " Récupération du titre du document et du contenu CLEAR : lt_solix[], lv_doc_id_otp, ls_document_data. lv_doc_id_otp = ls_srgbtbrel-instid_b. CALL FUNCTION 'SO_DOCUMENT_READ_API1' EXPORTING document_id = lv_doc_id_otp IMPORTING document_data = ls_document_data TABLES contents_hex = lt_solix EXCEPTIONS document_id_not_exist = 1 operation_no_authorization = 2 x_error = 3 OTHERS = 4. IF sy-subrc <> 0. CONTINUE. ENDIF. *{+M007 Controle l'intitulé du document pour savoir si celui- ci est eligible a l'envoie * de mail. IF pus_doc-xekko-bukrs IN r_societe. PERFORM check_title_of_doc USING ls_document_data-obj_descr
  • 92. CHANGING flag_attach_doc_okay. ENDIF. *}+M007 " Si le titre comprend OTP alors joindre la pièce au mail IF ls_document_data-obj_descr(3) = 'OTP' OR ls_document_data- obj_descr CS 'Adresse' OR flag_attach_doc_okay IS NOT INITIAL. "M007 " Il faut joindre le fichier au mail CLEAR : lv_extension, lv_size_c. lv_extension = ls_document_data-obj_type. lv_size_c = ls_document_data-doc_size. DESCRIBE TABLE pct_content_hex LINES lv_nb_lines. IF lt_solix[] IS NOT INITIAL. " On ajoute la pièce jointe à la commande APPEND LINES OF lt_solix TO pct_content_hex. CLEAR ls_objpack. ls_objpack-obj_descr = ls_document_data-obj_descr. ls_objpack-obj_name = ls_document_data-obj_descr. ls_objpack-transf_bin = 'X'. ls_objpack-head_start = 0. ls_objpack-head_num = 0. ls_objpack-body_start = lv_nb_lines + 1. ls_objpack-doc_type = lv_extension. DESCRIBE TABLE lt_solix LINES ls_objpack-body_num. ls_objpack-doc_size = lv_size_c. APPEND ls_objpack TO pct_objpack. CLEAR lt_solix[]. ENDIF. ELSE. IF lv_doc_id IS INITIAL. " Nous gardons le premier doc ne provenant pas de l'OTP lv_doc_id = ls_srgbtbrel-instid_b. ENDIF. ENDIF. ENDLOOP. IF NOT sy-subrc IS INITIAL. * Fin de modification - ACN - 05022015 " On va voir s'il n'existe pas une pièce jointe sur la DA liée au 1er poste READ TABLE pus_doc-xekpo INTO ls_ekpo INDEX 1. IF ls_ekpo-banfn IS NOT INITIAL. " Récupération des pièces jointes sur la DA SELECT * FROM srgbtbrel INTO TABLE lt_srgbtbrel WHERE instid_a = ls_ekpo-banfn AND typeid_a = 'BUS2105' AND catid_a = 'BO'. " Lecture de la 1ère pièce jointe READ TABLE lt_srgbtbrel INTO ls_srgbtbrel INDEX 1. IF sy-subrc = 0. lv_doc_id = ls_srgbtbrel-instid_b. ELSE.
  • 93. ls_object_key = ls_ekpo-banfn. CALL FUNCTION 'BDS_BUSINESSDOCUMENT_GET_TAB' EXPORTING classname = 'BUS2105' classtype = 'BO' client = sy-mandt object_key = ls_object_key binary_flag = 'X' text_as_stream = 'X' TABLES signature = lt_signature components = lt_components content = lt_content EXCEPTIONS nothing_found = 1 parameter_error = 2 not_allowed = 3 error_kpro = 4 internal_error = 5 not_authorized = 6 OTHERS = 7. IF sy-subrc = 0. " Taille de la pièce jointe READ TABLE lt_components INTO ls_components INDEX 1. MOVE ls_components-comp_size TO lv_size. lv_size_c = ls_components-comp_size. " Type de la pièce jointe (= extension) CALL METHOD cl_bcs_utilities=>split_name EXPORTING iv_name = ls_components-comp_id IMPORTING ev_extension = lv_extension. TRANSLATE lv_extension TO UPPER CASE. " Conversion pour changer la taille des lignes CALL FUNCTION 'SCMS_BINARY_TO_XSTRING' EXPORTING input_length = lv_size IMPORTING buffer = lv_xstring TABLES binary_tab = lt_content EXCEPTIONS failed = 1 OTHERS = 2. WHILE lv_xstring IS NOT INITIAL. CLEAR ls_solix. ls_solix-line = lv_xstring. APPEND ls_solix TO lt_solix. SHIFT lv_xstring LEFT BY 255 PLACES IN BYTE MODE. ENDWHILE. ENDIF. ENDIF. ENDIF. ENDIF.
  • 94. IF lv_doc_id IS NOT INITIAL. * Récupération du contenu de la pièce jointe CALL FUNCTION 'SO_DOCUMENT_READ_API1' EXPORTING document_id = lv_doc_id IMPORTING document_data = ls_document_data TABLES contents_hex = lt_solix EXCEPTIONS document_id_not_exist = 1 operation_no_authorization = 2 x_error = 3 OTHERS = 4. lv_extension = ls_document_data-obj_type. lv_size_c = ls_document_data-doc_size. DESCRIBE TABLE pct_content_hex LINES lv_nb_lines. ENDIF. IF lt_solix[] IS NOT INITIAL. " On ajoute la pièce jointe à la commande APPEND LINES OF lt_solix TO pct_content_hex. CLEAR ls_objpack. ls_objpack-obj_descr = ls_document_data-obj_descr. ls_objpack-obj_name = ls_document_data-obj_descr. ls_objpack-transf_bin = 'X'. ls_objpack-head_start = 0. ls_objpack-head_num = 0. ls_objpack-body_start = lv_nb_lines + 1. ls_objpack-doc_type = lv_extension. DESCRIBE TABLE lt_solix LINES ls_objpack-body_num. ls_objpack-doc_size = lv_size_c. APPEND ls_objpack TO pct_objpack. ENDIF. ENDFORM. Autre variante de document attaché : doknr ORM mail_add_file_dms USING pus_doc TYPE meein_purchase_doc_print CHANGING pct_content_hex TYPE INDEX TABLE pct_objpack TYPE INDEX TABLE. DATA : ls_draw TYPE draw, lt_drao TYPE TABLE OF drao, ls_drao TYPE drao, ls_cout_def TYPE dms_checkout_def, ls_doc_file TYPE dms_doc_file, l_offset TYPE i, ls_solix TYPE solix, lt_solix TYPE TABLE OF solix, ls_objpack TYPE sopcklsti1, lv_nb_lines TYPE i, lr_adr TYPE RANGE OF adrnr, ls_ekpo TYPE ekpo. FIELD-SYMBOLS : <ls_adr> LIKE LINE OF lr_adr.
  • 95. CHECK pus_doc-xekko-ekorg = 'A006' AND pus_doc-xekko- bsart = 'ZANB'. "uniquement pour Castel Alu * Uniquement pour les adresses de livraison particulières (atelier) SELECT sign opti low high FROM tvarvc INTO TABLE lr_adr WHERE name = 'ZMM_ADR_PJ_CDE' AND type = 'S'. * Conversion des n° d'adresse au format interne LOOP AT lr_adr ASSIGNING <ls_adr>. CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' EXPORTING input = <ls_adr>-low IMPORTING output = <ls_adr>-low. IF <ls_adr>-high IS NOT INITIAL. CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' EXPORTING input = <ls_adr>-high IMPORTING output = <ls_adr>-high. ENDIF. ENDLOOP. * On vérifie que l'adresse de livraison du 1er poste correspond au range READ TABLE pus_doc-xekpo INDEX 1 INTO ls_ekpo. CHECK sy-subrc = 0 AND lr_adr[] IS NOT INITIAL AND ls_ekpo-adrn2 IN lr_adr. * Infos document DMS SELECT SINGLE * FROM draw INTO ls_draw WHERE dokar = 'ZCA' AND doknr = 'CA000000001' AND dokvr = '00' AND doktl = '000'. ls_cout_def-action = 'V'. ls_cout_def-comp_get = 'X'. ls_cout_def-ftp_dest = 'SAPFTP'. ls_doc_file-fileno = '1'. ls_doc_file-dttrg = ls_draw-dttrg. ls_doc_file-dappl = ls_draw-dappl. * Récupération du contenu du fichier en binaire (à partir de la table DRAO) CALL FUNCTION 'CV120_DOC_CHECKOUT' EXPORTING ps_cout_def = ls_cout_def ps_draw = ls_draw ps_doc_file = ls_doc_file TABLES ptx_drao = lt_drao EXCEPTIONS error = 1 OTHERS = 2. IF sy-subrc <> 0. EXIT.
  • 96. ENDIF. LOOP AT lt_drao INTO ls_drao. * On split en "paquets" de 255 caractères pour avoir le bon format DO 10 TIMES. l_offset = 255 * ( sy-index - 1 ). ls_solix-line = ls_drao-orblk+l_offset(255). APPEND ls_solix TO lt_solix. ENDDO. ENDLOOP. DESCRIBE TABLE pct_content_hex LINES lv_nb_lines. * On ajoute la pièce jointe à la commande IF lt_solix[] IS NOT INITIAL. APPEND LINES OF lt_solix TO pct_content_hex. CLEAR ls_objpack. ls_objpack-obj_descr = text-005. ls_objpack-obj_name = text-006. ls_objpack-transf_bin = 'X'. ls_objpack-head_start = 0. ls_objpack-head_num = 0. ls_objpack-body_start = lv_nb_lines + 1. ls_objpack-doc_type = ls_doc_file-dappl. "PDF DESCRIBE TABLE lt_solix LINES ls_objpack-body_num. * ls_objpack-doc_size = lv_size_c. APPEND ls_objpack TO pct_objpack. ENDIF. ENDFORM. " MAIL_ADD_FILE_DMS Envoie effectif dumail : ls_document_data-obj_descr = text-tit. WRITE pus_doc-xekko-ebeln TO lv_ebeln. CONDENSE lv_ebeln. CONCATENATE ls_document_data-obj_descr lv_ebeln INTO ls_document_data-obj_descr. CLEAR lv_commit. IF nast-vsztp NE '4'. lv_commit = 'X'. ENDIF. * Envoi du mail CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1' EXPORTING document_data = ls_document_data commit_work = lv_commit TABLES packing_list = lt_objpack object_header = lt_object_header contents_txt = lt_contents_txt contents_hex = lt_contents_hex * receivers = lt_receiver "M002(-) receivers = put_receiver "M002(+) EXCEPTIONS
  • 97. too_many_receivers = 1 document_not_sent = 2 document_type_not_exist = 3 operation_no_authorization = 4 parameter_error = 5 x_error = 6 enqueue_error = 7 OTHERS = 8.
  • 98. Methodenchainmentd’ALV: ALV – это не только простые таблицы ivan 08.10.2010 Разрабатывая отчетики на базе ALV можно также обратить внимание на дополнительные аспекты – не всегда простой таблицы бывает достаточно, а рисовать свои экраны не сильно тянет. Если покопаться в примерах, то можно найти несколько полезных вариантов. Одна оговорка: в данном случае ALV представлено не своим красивым элементом управления, а ABAP-списком. В стандарте очень много отчётов строятся похожим образом. Иерархический просмотр master-detail Пример можно найти в программе BALVHD01. Этот отчёт строится на базе функционального модуля REUSE_ALV_HIERSEQ_LIST_DISPLAY. Основная ALV функциональность присутствует: управление вариантами, сортировки, суммы, группировки, фильтр и прочее. Иерархичность тут не полная, а всего лишь отношение master-detail, чего в большинстве случаев может и хватить, так как покрывает стандартные отношения типа “заголовок документа – позиции документа”.
  • 99. Ко всему прочему, такой вывод поддерживает многострочность одной строки (до трёх строк), что позволяет упаковать больше данных по ширине экрана. Несколько независимых таблиц Пример можно обнаружить в программе BALVBT01. Такой вариант реализуется на базе функциональных модулей REUSE_ALV_BLOCK_LIST_INIT, REUSE_ALV_BLOCK_LIST_APPEND, REUSE_ALV_BLOCK_LIST_HS_APPEND, REUSE_ALV_BLOCK_LIST_DISPLAY. В программе требуется простая последовательность фрагментов: инициализация, последовательное добавление таблиц, вызов показывалки. Таким образом можно представить несколько независимых наборов данных, с сохранением основной функциональности ALV в рамках отдельных таблиц. MAINTAINING VARIABLE USING TCODE STVARV February 21, 2017 · by abaplearner · in ABAP · Leavea comment Untuk menghindari hardcode dalam suatu program, biasanyaabaper menggunakan constants untuk meminimalisir hardcode atau agar lebihfleksibel, dibuattableZ yang digunakanuntuk me-maintainvariabel yang di-hardcode. Penggunaan tcode STVARV dapat menjadi solusi bagi abaperuntuk menghindari penggunaan constantmaupun table z untuk menghindari hardcode. Namun, namavariabel yang di-defineddalam tcode tetap harus di-hardcode di program.
  • 100. Selainitu, tcodeSTVARV tidak hanya bisamemaintainsinglevariabledalam bentuk parameter, tetapi juga dalam bentuk selectoption. Berikutadalah cara penggunaannya. Requirement: hardcode GL Accountyang digunakan dalam suatu program, yaituget data GL Accountdengan range 0011021910 ~ 0011021918.  MaintainvariableGL Accountpada tcode STVARV pada tab selectionoption. LaluSave.  Pada abap program, get variabel valuedari table TVARVCyangmenyimpanvariabletcodeSTVARV. DATA: t_stdbsart TYPE STANDARD TABLE OF tvarvc WITH HEADER LINE, t_ska1 TYPE STANDARD TABLE OF ska1 WITH HEADER LINE. RANGES: r_hkont FOR ska1-saknr. SELECT * INTO CORRESPONDING FIELDS OF TABLE t_stdbsart FROM tvarvc WHERE name EQ 'GL_ACCOUNT'. IF LINES( t_stdbsart ) > 0. LOOP AT t_stdbsart. MOVE-CORRESPONDING t_stdbsart TO r_hkont. r_hkont-option = t_stdbsart-opti. APPEND r_hkont. ENDLOOP. ENDIF.
  • 101. IF r_hkont[] is NOT INITIAL. SELECT * FROM ska1 INTO TABLE t_ska1 WHERE saknr in r_hkont. ENDIF. Variableyang di-create di tcode STVARV dapat ditransport dengan men-thick pilihan‘Includechangedentries intransport request’ sebelum Save. Displaying ALV in Splitter Container with heading using ABAP OO 7 December2012 | AvinashPalavai | 6 Comments | SAP ABAP Introduction: Splitter Container can be used to display data either from two or more tables or from a single table based on particular conditions in ALV format using a single container at a time. The classes that are used for achieving this are as follows, 1. CL_GUI_CUSTOM_CONTAINER . 2. CL_GUI_SPLITTER_CONTAINER . 3. CL_GUI_CONTAINER . 4. CL_GUI_ALV_GRID . 5. CL_DD_DOCUMENT. Procedure: 1. First we have to design a modulepool screen (Screen No.100 ) with two custom controls, each for ALV and Heading as below,
  • 102. 1. Name the first control as "HEADING".
  • 103. 2. Name the second control as "MAIN_CONT". 3. Save and activate the screen. 4. Do the below coding in the report program. 5. Here i took a case of displaying the material details of a particular material type ‘ZSEM', in the parent split alv list and the descriptions of those materials that are listed in parent split alv in child split alv. 6. The heading being maintained for this ALV is 'Material Master Report'.*****************************Coding******************************** *REPORT ZOOALV_WITH_SPLITTER. DATA : O_CC TYPE REF TO CL_GUI_CUSTOM_CONTAINER . DATA : O_SC TYPE REF TO CL_GUI_SPLITTER_CONTAINER . DATA : O_PART1 TYPE REF TO CL_GUI_CONTAINER . DATA : O_PART2 TYPE REF TO CL_GUI_CONTAINER . DATA : ALV_GRID1 TYPE REF TO CL_GUI_ALV_GRID . DATA : ALV_GRID2 TYPE REF TO CL_GUI_ALV_GRID . DATA : I_MARA TYPE TABLE OF MARA . DATA : I_MAKT TYPE TABLE OF MAKT . DATA : DD TYPE REF TO CL_DD_DOCUMENT. START-OF-SELECTION . call SCREEN 100. *&---------------------------------------------------------------------* *& Module STATUS_0100 OUTPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE STATUS_0100 OUTPUT. * SET PF-STATUS 'xxxxxxxx'. * SET TITLEBAR 'xxx'. PERFORM create_objects. PERFORM spli_main_cont . PERFORM DISP_HEADING. PERFORM disp_alv1 . PERFORM disp_alv2 . ENDMODULE. " STATUS_0100 OUTPUT *&---------------------------------------------------------------------* *& Form CREATE_OBJECTS *&---------------------------------------------------------------------*
  • 104. * text *----------------------------------------------------------------------* * --> p1 text * p1 text * GET_CONTAINER EXPORTING ROW = 1 COLUMN = 1 RECEIVING CONTAINER = O_PART1. CALL METHOD O_SC->GET_CONTAINER EXPORTING ROW = 2 COLUMN = 1 RECEIVING CONTAINER = O_PART2. ENDFORM. " SPLI_MAIN_CONT *&---------------------------------------------------------------------* *& Form DISP_ALV1 *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * SET_TABLE_FOR_FIRST_DISPLAY EXPORTING I_STRUCTURE_NAME = 'MARA' CHANGING IT_OUTTAB = I_MARA. ENDFORM . "DISP_ALV1 *&---------------------------------------------------------------------* *& Form DISP_ALV2 *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * SET_TABLE_FOR_FIRST_DISPLAY EXPORTING I_STRUCTURE_NAME = 'MAKT' CHANGING IT_OUTTAB = I_MAKT. ENDFORM. " DISP_ALV2 *&---------------------------------------------------------------------* *& Form DISP_HEADING *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * HEADING . CALL METHOD DD->ADD_TEXT EXPORTING TEXT = 'MATERIAL MASTER REPORT' SAP_STYLE = HEAD . CALL METHOD DD->DISPLAY_DOCUMENT EXPORTING CONTAINER = 'HEADING'. ENDFORM. " DISP_LOGO