Vous êtes sur la page 1sur 27

I Want to GROW be STRONG and make my WORLD HAPPY

I WANT TO GROW BE STRONG AND MAKE MY WORLD HAPPY

I want to grow be strong and make my world happy

ATA : lo_trsmgr TYPE REF TO /bobf/if_tra_transaction_mgr,

lo_srvmgr TYPE REF TO /bobf/if_tra_service_manager,

lo_location TYPE REF TO /bobf/if_tra_service_manager,

lo_root TYPE REF TO /scmtms/s_trq_root_k,

lt_mod TYPE /bobf/t_frw_modification,

lo_item TYPE REF TO /scmtms/s_trq_item_k,

lo_party TYPE REF TO /scmtms/s_trq_party_k,

FIELD-SYMBOLS:<ls_mod> LIKE LINE OF lt_mod.

CREATE DATA lo_root.

lo_root->key = /bobf/cl_frw_factory=>get_new_key( ).

lo_root->trq_cat = '03'. " Category

lo_root->order_date = sy-datum. " Order Date

lo_root->transsrvlvl_code = '01'. " Service Level

lo_root->movem_type = '01'. " Movement Type


lo_root->shipping_type = '17'. " Shipping Type

lo_root->traffic_direct = '2'. " Traffic Direction

lo_root->pic_ear_req = lv_pick_date. " Pickup date

lo_root->del_lat_req = lv_dely_date. " Delivery Date

ls_location_id = lv_source. " Source Location

INSERT ls_location_id INTO TABLE lt_location_id.

ls_location_id = lv_dest. " Destination Location

INSERT ls_location_id INTO TABLE lt_location_id.

CLEAR : lo_location.

lo_location = /bobf/cl_tra_serv_mgr_factory=>get_service_manager(
/scmtms/if_location_c=>sc_bo_key ).

lo_location->convert_altern_key(

EXPORTING

iv_node_key = /scmtms/if_location_c=>sc_node-root

iv_altkey_key = /scmtms/if_location_c=>sc_alternative_key-root-location_id

it_key = lt_location_id

IMPORTING

et_result = lt_key_index " Key table with explicit index

et_key = lt_key ).

DELETE lt_key WHERE key IS INITIAL.

READ TABLE lt_key INDEX 1 INTO ls_key.

lo_root->src_loc_id = lv_source. " Source Location

lo_root->src_loc_key = ls_key-key.

READ TABLE lt_key INDEX 2 INTO ls_key.

lo_root->des_loc_id = lv_dest." Destination Location


lo_root->des_loc_key = ls_key-key.

CLEAR : lo_buspartner.

lo_buspartner = /bobf/cl_tra_serv_mgr_factory=>get_service_manager(
/bofu/if_bupa_constants=>sc_bo_key ).

ls_buspartner = ls_head-ord_p.

INSERT ls_buspartner INTO TABLE lt_buspartner.

ls_buspartner = ls_head-shipr.

INSERT ls_buspartner INTO TABLE lt_buspartner.

ls_buspartner = ls_head-consg.

INSERT ls_buspartner INTO TABLE lt_buspartner.

lo_buspartner->convert_altern_key(

EXPORTING

iv_node_key = /bofu/if_bupa_constants=>sc_node-root

iv_altkey_key = /bofu/if_bupa_constants=>sc_alternative_key-root-partner

it_key = lt_buspartner

IMPORTING

et_result = lt_key_bpdata

et_key = lt_key_bp ).

IF NOT ls_head-ord_p IS INITIAL.

READ TABLE lt_key_bp INDEX 1 INTO ls_key.

lo_root->order_party_key = ls_key-key.

lo_root->order_party_id = ls_head-ord_p.

ENDIF.

IF NOT ls_head-shipr IS INITIAL.

READ TABLE lt_key_bp INDEX 2 INTO ls_key.


lo_root->shipper_key = ls_key-key.

lo_root->shipper_id = ls_head-shipr.

ENDIF.

IF NOT ls_head-consg IS INITIAL.

READ TABLE lt_key_bp INDEX 3 INTO ls_key.

lo_root->consignee_key = ls_key-key.

lo_root->consignee_id = ls_head-consg.

ENDIF.

APPEND INITIAL LINE TO lt_mod ASSIGNING <ls_mod>.

<ls_mod>-node = /scmtms/if_trq_c=>sc_node-root.

<ls_mod>-change_mode = /bobf/if_frw_c=>sc_modify_create.

<ls_mod>-source_key = lo_root->key.

<ls_mod>-root_key = lo_root->key.

<ls_mod>-key = lo_root->key.

<ls_mod>-data = lo_root.

CLEAR lo_item.

CREATE DATA lo_item.

lo_item->key = /bobf/cl_frw_factory=>get_new_key( ).

lo_item->prd_key = /bobf/cl_frw_factory=>get_new_key( ).

lo_item->item_id = lv_item_id.

lo_item->item_type = lc_it_typ.

lo_item->item_cat = lc_it_cat.

lo_item->qua_pcs_val = ls_item-qty.
lo_item->qua_pcs_uni = ls_item-qty_uom.

lo_item->gro_wei_val = ls_item-gro_wt.

lo_item->gro_wei_uni = ls_item-gro_wt_uom.

lo_item->product_id = ls_item-pro_id.

lo_item->del_sel_time = lv_dely_date.

lo_item->del_lat_req = lv_dely_date.

APPEND INITIAL LINE TO lt_mod ASSIGNING <ls_mod>.

<ls_mod>-node = /scmtms/if_trq_c=>sc_node-item.

<ls_mod>-change_mode = /bobf/if_frw_c=>sc_modify_create.

<ls_mod>-source_node = /scmtms/if_trq_c=>sc_node-root.

<ls_mod>-source_key = lo_root->key.

<ls_mod>-root_key = lo_root->key.

<ls_mod>-key = lo_item->key.

<ls_mod>-data = lo_item.

<ls_mod>-association = /scmtms/if_trq_c=>sc_association-root-item.

* Create the Forwarding Order record:

CALL METHOD lo_srvmgr->modify

EXPORTING

it_modification = lt_mod

IMPORTING

eo_change = lo_change

CALL METHOD lo_trsmgr->save.

eo_message = lo_message.
There are some technologies like HANA, Fiori, SAPUI5, OData, SAP Netweaver
Gateway etc which every ABAPer wants to learn and utilize. But in all those
hypes, another framework called BOPF is being neglected. In this article and in
the future series, I would like to touch base upon BOPF and how we can use it
in real project scenarios. Although most of the concepts would be for beginners,
I am confident, even the seasoned BOPF consultants would get few cents to
take home for this BOPF series.

For your information, SAP Transportation Managment is mostly built on


BOPF framework. Applications developed using BOPF are generic and have
uniform architecture and the custom developments are stable and can be
developed faster.

Introduction:
BOPF (Business Object Processing Framework) is a framework for working with
the BO (Business Objects). This framework provides tools and services for
entire BO life cycle. BO is a representation of a type of uniquely identifiable
business entities described by a structural model, an internal process model,
and one or more service interfaces.

Important Transaction Codes:

 BOBF(Business Object Building framework) it’s not BOPF unlike the


name of the framework
 BOB (Business Object Builder)
 BOBT (BO Test)
 BOBX(Business Object Enhancement Workbench)

Do you remember “BOB the Builder” cartoon show?


BOPF has a step by step procedure. So we need to go and directly jump into a
class or a function module creation. Just like what we do in normal ABAP
programs or OO ABAP. We know everything is made up of programs, even the
screens are done by module pool programming where we have a screen painter
to design the screen and we have a backend report which executes the code
and then we see the output.

Architecture:

The upper layer is the UI layer where it can be FPM (BOPF is tightly integrated
with FPM) or Fiori to display the data. And then comes the Transaction
layer which gets instantiated automatically whenever we interact with the
BO, low-level transaction handling like lock objects are handled by the
transaction layer. So, whenever we call any BO internally it may call many
BO’s, all these are taken care by the BOPF framework. The next layer that is
the BOPF Object layer which doesn’t get instantiated automatically when we
are out of the framework like when we write the report we need to explicitly
instantiate it but when we are inside the framework we need not to instantiate
it, the framework takes care of it. Database layer consists of the data.
The BOPF framework consists of all BO (Business Object) like for example Sales
order, Outbound delivery, Inbound delivery (EWM Space) as an entity and that
is modeled as a business object. It will have a Structural model which consists
of the header structure, item structure, etc. When we go inside BOBF t-code we
see standard BO delivered by SAP. Open the demo sales order BO.

As we see the BO Demo Sales Order has Root node as ROOT (we can change
the name if we want when we build our own custom BO) and sub-node as ITEM,
ROOT_LONG_TEXT, ROOT_TEXT, CUSTOMER_BO. Under the Root node, we see
there are different sub-nodes with grey, green and green with a star each
with a different meaning. Whenever we create any custom node we get three
option to select the type of the Node as shown below.

And you see they are Standard, Delegated and Business Object
Representation Node. The grey one is nothing but the Standard
node, Green one are Delegated node and green with a star are the Business
Object Representation Node or the Cross BO node.

1. Standard node is the node which we create for Item detail under
header as seen above.
2. Delegated node is the dependent node which we can use as per our
requirement, things like Attachment folder, Text collection can be used
in any particular node as and when required.
3. Business Object Representation Node or Cross BO node are nodes
of other BO as the name says “CROSS”. The framework is well
designed to integrate these functionalities. All we need to know is the
particular constant interface of the BO and we are well to go which we
will come to know as we work with BOPF.
We see under node elements the procedural elements (Node Elements) of the
root node which contains the business logic. The procedural models are
Determinations, Actions, Validations, etc. Clear separation between changing
and checking business logic. Changing logic is nothing but
the determinations if something has happened to my application, I need to
react to it so there is something called an action and to validate the data
whether it is correct or not we have validations which are nothing but checking
business logic. So there is no mixing of both, all are separate. We have a
separate section for everything.

Also Read – SAP Hybris Overview

Step by Step Creation of a Custom BO

Go to Transaction BOB:

We see here three BO Categories viz. Custom Business Object, SAP


Business Object and Business Object enhancements which are self-
explanatory.
Click on Create Custom Business Object:

A wizard guides us to create a custom business object.

The next steps are simple for the creation of the BO, just provide the necessary
names and you are ready to go.

Provide the prefix, ignore the namespace (namespace is like you are working for
a client and you need your entire BO namespace to have the same name
instead to be in Z namespace then we buy the namespace from SAP).
Click continue
You find the Constant Interface name is already proposed, that’s the beauty
of BOPF. You can also change the name if you wish to do so. And then click
continue.
By default, the name of the root node is Root (you can change if you wish).
Provide the description and the name of
the Persistent and Transient structure (you can also click on the Propose
Name button and the framework gives you the name). Moreover,
the Transient structure is optional, you may leave it blank if you wish so but
the Persistent structure is mandatory to give.

As the name says the Transient structure is transient in nature i.e. it gets called
at the runtime.

Note – You need to have zpersistent and ztranscient structure (not table) in the
database. Else you would get an error like below.

Also Check – How to identify S/4HANA System from ABAP on HANA System?
Click continue…

The BOPF framework automatically proposes the Combined Structure, Table


Type, and Database Table name, however, you can change the name as per
your choice in Z namespace.

Click continue…
And finally, click Complete and your BO is created. As said earlier BOPF is more
of modeling and less of coding.
Click on the BO and you find all the details of your Business Object viz the
structural model, procedural model (Node Elements), constant interface,
etc. We haven’t done any coding yet and our BO got created with the database
table unlike in traditional process we have to do these manually.
When we open the DB table we find it has the key field generated
automatically.
In BOPF we don’t create the key field. The framework itself created the key and
the key is a long 32 digit hexadecimal number. It is very difficult to remember
but there is a way to handle it. We have something called as alternative
keys which we will look in our later tutorials.

In the next part, as per requirement, we can create our node structure i.e. we
can add sub-node of any of the three types specified above. Also, implement
the Logic in the node elements section. We will check how there is a clear
separation of Business model and Logic.

Also Read – An ABAPer’s first SAPUI5 App

All the above steps are good case scenario. What if you face some issues in
the Custom BO Creation process? Check the below section which one of our
team members faced while doing the step by step tutorial above. You might find
solutions in case you have similar problems.
1. If you get “Business Object could not be created” message, do
not worry.

Go to t-code BOBF and you would find your Business Object was created.
2. Display<>Change icon is disabled.

Look for Home Business Objects section (in above image). Double click on your
Object. You would find that the change icon is disabled.
HOW TO ENABLE THE
MAINTAIN/CHANGE OF BUSINESS
OBJECT?
Type “debug” at the command section and hit enter.

Hit Yes on the Pop-Up.


Magic!! The Display<>Change Icon is enabled.

3. Data Dictionary Structures/Tables are not Activated or are in


NEW status.
Go to change mode. From Extras Menu -> Generate Repository Objects -
> Generate Dictionary Elements.

Hit the green tick mark.


The Data Dictionary Objects would be generated and activated.
Go to SE11 and check them. They are activated. If you happen to check them
before Generating the Repository Objects from the Extras Menu, then those
SE11 objects would be in NEW status, not Active.

Let us stop here today. Hope I was able to give you a fair introduction. BOPF is
no Rocket Science and it is not that complex as some say. We just need to
understand some fundamentals, then you would start loving the framework and
appreciate it better.

As already revealed above, the next article would be more interesting with real
project case. We would create our Node Structure. Add Sub Nodes of types
(Standard Node, Delegated Node, and Business Object Representation Node).
We would implement the logic in the elements of the nodes and we would see
how we can separate the business model and logic. So, please stay tuned.

If you are already working in BOPF, please share your project use case. Let us
know what issue you faced and how you resolved.

WE WANT TO HEAR FROM YOU. PLEA


s

Vous aimerez peut-être aussi