You are on page 1of 97

Ravi Anand VMS Techno Functional – anandravi75@gmail.

com

The Vehicle Management System (VMS) is an application for the Automotive industry. It
supports, in the area of Sales & Services, the business processes that you require as vehicle
importer when dealing with your original equipment manufacturers (OEMs) and your dealers
in new and used vehicle sales. VMS offers you complete integration of all the relevant
processes such as procurement, sales, rework, returns processing, trade-in and service
processing. It also supports the archiving of vehicle data. In other words, it allows you to react
flexibly to customers’ requirements in the area of production (using the “pull strategy”) and
fast delivery times with reduced warehouse stock and sales/distribution costs.

For the vehicle importer, VMS serves as a central tool for managing, procuring,
sales/distribution and tracking of vehicles. Your dealers use it as a workplace for
configuration, searching, purchasing and tracking of vehicles for your end customers. The
dealers can log in to your system remotely via Internet and access your data

The following graphic shows the use of VMS in vehicle procurement, vehicle sales and service.

VMS is completely integrated into the SAP application components MM, SD, CS and FI/CO.

You can call and execute actions for a vehicle easily and quickly from VMS. By an action we
mean a business function that affects the procurement of a vehicle at the manufacturer by
the importer or the sale of the vehicle to the dealer. Examples are: create or change vehicle,
create purchase order (at manufacturer), create sales order/delivery/outgoing invoice (for
dealer) and post goods receipt/goods issue.
A large part of the actions delivered by SAP are based on the SAP standard transactions: they
are delivered in a separate and easy-to-use interface but with the complete functionality. The
posting documents that are created by these actions are also SAP standard posting
documents that are stored in the application components MM, SD, CS or FI/CO in the SAP
system.
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

Apart from these general business actions, there are also Special VMS Actions, for example,
actions for making reservations, actions that hide or display vehicles for other dealers, actions
for changing vehicles, for setting a vehicle location or for assigning a sales campaign. You can
enhance the actions that are delivered to suit your own requirements or programme your
own actions. The action concept is on a modular basis and flexible so that you can adjust it at
any time to suit changes in your business processes.

The typical scenario when using VMS revolves around the procurement and sale of new
vehicles. As importer, you procure vehicles from one or more manufacturers and sell them to
your dealers or directly to large end customers, for example, rent-a-car companies. This
process is supported by VMS in both directions: ·
Pull strategy: the requirement/sale can trigger procurement (MTO = Make-to-Order, make-
to-order production) ·

Push strategy: procurement can come before sales (MTS = Make-to-Stock, make-to-stock
production).

The technical and business integration of all processes and business partners in VMS allows
you to shorten delivery times and – in the case of MTO – consider customer requirements
and therefore increase customer satisfaction.

Process Flow
1. The end customer would like to purchase a vehicle with specific features and approaches
one of your dealers.

2. The dealer searches your stock using the Internet to see if an appropriate vehicle exists.
3. If yes, the dealer enters additional characteristics for the vehicle, which are then installed
later in the course of local rework activities (for example, installing a radio, dog grate,
telephone, different tyres etc.). He/she then determines the price for the desired
configuration and creates a sales order in your system for this vehicle (scenario: make-to-
stock production). If no, the dealer also creates a sales order, but not for an existing vehicle.
He/she creates a sales order for the customer’s dream car. The importer then creates a
purchase order for this vehicle at the manufacturer’s and thus triggers production (scenario:
make-to-order production).
4. Status updates per EDI from the manufacturer give you and the dealer up-to-date
information on the status of the vehicle, in other words, information on the progress in
production or delivery. The dealers have access to this information via Internet and can
forward the information directly to the end customers.
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

5. VMS supports vehicle procurement and sales, including all the postings involved and
oversees the entire business process until the time when your dealer delivers the desired car
to the end customer. The following graphic displays which documents are exchanged via VMS
between OEM, dealer and importer during vehicle procurement, vehicle sales and service.

The dealer have access to SAP system via some URL, They can access data and create Sales
Order Etc.

OEM is original Manufacturer where vehicle manufactured. So the process for make to Stock
would be
1. Through ECC system Exa. US , one PO will be created for OEM for Exa. Japan.
2. OEM will confirm the order.
3. Status of the order get change.
4. They will deliver the Vehicle to ECC means US.
5. Good Receipt and Invoice will be processed.
6. At the Dealer level, They will create a Sales Order for Vehicle in US region.
7. Product will be deliver to End client, Than Good Issue , Invoice and Payment will take
place.

A vehicle is a business object (BUS1200) in the SAP system. A vehicle is the result of using
a create action in VMS to create a vehicle for a vehicle model. It is therefore, an instance
of a vehicle model, in other words, an individual object. A configuration is always created
for a vehicle; the characteristics in the configuration may have not yet had any values
assigned to them, partly have had values assigned or have had all values assigned. You
can identify the vehicle by its vehicle number and define it further using a batch, valuation
type and, where appropriate, an equipment number.
Ravi Anand VMS Techno Functional – anandravi75@gmail.com
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

When you create a vehicle it receives an internal vehicle number. This number is the also
the batch number and the valuation type number. Each vehicle, therefore, has its own
batch and valuation type. You can display valuated stock using transaction MMBE Stock
Overview .

GUID :Global Unique Identifier. A 22-character technical key assigned


by the system when the importer creates the vehicle. This key is unique and therefore
also differentiates between vehicles that have been created in different systems. The
GUID serves only internal technical control purposes and does not appear on the
interface.
Internal vehicle number :An identification number from an internal number range. It is
assigned by the system when the importer creates the vehicle. The vehicle number is
created independently of the vehicle identification number (VIN).

External vehicle number :Identification number assigned by the manufacturer (for


example, production number, vehicle number)

Vehicle identification number (VIN) : 17-character number that identifies a vehicle


and is created when the vehicle is assembled, for example, during the assembly process
in the manufacturer’s production system. The VIN is an international standard.

Vehicle Model : Basic type of a vehicle that can be varied. Vehicle models are
created as configurable materials in the SAP system. A vehicle model can be a general
vehicle type or a vehicle type for which specific characteristic values have been predefined
using object dependencies.

Configuration : Characteristics and assigned characteristic values (for


example: color: blue; special features: radio, air conditioning).

The vehicle data is the result of actions that have been performed for a vehicle. The data
is enhanced and updated continuously. Example: the following data is entered and
determined on creating a vehicle: internal vehicle number, plant, vehicle model,
configuration, primary action control, primary status, availability status, gross list price
and, where appropriate, production date and vendor. When the purchase order is
created, this data is completed with entries for the vendor and the location.
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

Every vehicle model that is managed with VMS is described by a configurable material and
the appropriate class. Before you can work with VMS, you must first maintain
characteristics, classes, variant conditions, object dependencies and material master
records.

The master data that you require belongs to the following SAP applications: ·
Material Master Record ·
Classification System ·
Variant Configuration ·
Pricing (SD and MM) ·
Business Partner Administration

Vehicle models are created in the SAP ECC system as configurable materials (material type
VEHI = configurable vehicle).
Classes with characteristics are assigned to the materials. A vehicle model can be a general
vehicle type or a vehicle type for which specific characteristic values have been predefined
using object dependencies.

Every vehicle model that is managed with VMS is described by a configurable material and
the appropriate class. Before you can work with VMS you must have created material
master records for the vehicle models.

One item category is basically used in the sales order. Item category determination is
controlled by the sales document type and the item category group. You can find the item
category group in the material master record for the view Sales and Distribution: Sales
Organization 2 .
Item category group VMS0 ( Vehicle VMS ) is delivered for VMS as standard, which links
to the special VMS item category VTAC that is also delivered as standard. Item category
VTAC differs from the standard item category TAC by billing relevance “B”. VTAC can be
billed related to the order, in other words, the billing document can be created as soon as
the sales order has been created.
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

Constructing a Vehicle Configuration


1. Transaction CT04, Define a Characteristics.

2. Create a class using transaction Cl04, and assign multiple Characteristics.


Ravi Anand VMS Techno Functional – anandravi75@gmail.com

3. Next assign this class to Vehicle Model under classification.

As a Result Vehicle Model get created.


Pricing of the Vehicle would be two type.

1. Gross listed price Action CREA-> Create Vehicle Without discount. Std Pricing
Procedure RVAA01.
2. ORD1->ME01(Create PO->MEK1) or CUOR->SD Price (Create Sales Order ->VK11).
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

Now you have defined the Material Basic price for MM and SD. Next go to CT04.

Create or Change multiple Char,


Next group them by creating a class using transaction CL04.

Got to CU01 and create dependency.


Ravi Anand VMS Techno Functional – anandravi75@gmail.com

Use Transaction CU42 and assigned class to material.


Ravi Anand VMS Techno Functional – anandravi75@gmail.com

Basic Price of the material will be for all the mentioned Char. -> Need to check.
Next Role and Authorization.

1. Use Transaction OVELO19 to define Role.

There are three types of Role.


1. Organisation Role : This is a role to which organizational data is assigne.
2. Vehicle Model Role: This role determines which vehicles the system displays to the
user in the vehicle model list.
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

3. Configuration Role : Depending on the vehicle model, status and so on, the
configuration role specifies which vehicle characteristics the system should make
visible for the user and which changes the user is allowed to make to the vehicle
characteristics

Activity
1. Assign vehicle models to the vehicle model roles (transaction VELORM).

2. Assign organizational data to the organizational roles (transaction VELORO).


Ravi Anand VMS Techno Functional – anandravi75@gmail.com

3. Optional: if desired, define configuration change profiles and, in the profile


determination, define which profile can be used for which configuration roles
(transaction VELOP).

4. Assign roles to the users (transaction VELORU).

Creating a Configuration Change Profile


A configuration change profile controls, depending on the status of the vehicle and the
configuration role that the VMS user has, which configuration characteristics can still be
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

changed in the SAP Internet Pricing and Configurator (SAP IPC) and which cannot. For
example, when you create a sales order or change a purchase order etc., characteristics that
can no longer be changes can either be displayed or rendered invisible to the user.
Procedure :
1. In transaction VELOP, create a configuration change profile for every combination of
characteristics that can be changed and under Define Visibility of Characteristics ,
define which configuration characteristics you want to be visible but not changeable
and which you do not want to be visible. To do this, you must know the configuration
characteristics for the vehicle models for which you want to create the configuration
change profile.

Define when you want the profile to be used under Define Determination of Profile .
Determination can be dependent on the following parameters:
1. Configuration role
2. Vehicle model
3. Availability status
4. Primary action control
5. Primary status
6. Secondary action control
7. Secondary status

Calculation of Gross List Price Using Organizational Roles

When you create and configure a vehicle, VMS calculates the gross list price from the basic
price of the vehicle model and the prices for the individual characteristics. The system
automatically adjusts the gross list price when changes are made to the configuration. This
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

gross list price is independent of customers to which the vehicle is sold or has been sold and
does not contain any discounts. It is, therefore, not the price for which you sell the vehicle to
the dealer.

The system simulates a sales order when it calculates the gross list price and it therefore
requires all the data that you have to enter when you create a sales order. It writes the price
that it calculates to the vehicle data as the gross list price.

Action Control

You can represent your business processes in the system with action controls. You define
which actions can follow one after the other when handling vehicles and which changes to
the status of the vehicle are involved in this.

1. Define Action using transaction OVELO1.


Ravi Anand VMS Techno Functional – anandravi75@gmail.com

2. Define Vehicle Status Transaction OVELO12.

3. Define Availability using TCODE OVELO13.


Ravi Anand VMS Techno Functional – anandravi75@gmail.com

4. Vehicle location, Transaction OVELOL.

You can distinguish between primary and secondary action controls, depending on the
process that is being represents by the action control. The primary action control usually
represents the procurement process, in other words, ordering the vehicle from the
manufacturer and the secondary action control the sales process.

1. Define the action Control Transaction OVELO11.


Ravi Anand VMS Techno Functional – anandravi75@gmail.com

Define the action Matrix.


Ravi Anand VMS Techno Functional – anandravi75@gmail.com

Action control can be defined using Transaction code VELOS.


Ravi Anand VMS Techno Functional – anandravi75@gmail.com

Multiple combination can be defined, Its like access sequence in SD. Fields are Plant, Pur. Org
Vendor Etc.
You don not have to enter a value in all the key fields. A key field that is empty means that
the entry is valid for all values that are possible for this field.
Determination of the action control works as follows:
1. In Customizing, the system checks whether the action that you want to perform is a
primary action, a secondary action or both.

2. The system checks whether the appropriate action controls have already been assigned to
the vehicle. If yes, it uses these. The assignment of an action control to a vehicle cannot be
changed.
3. If no, the system triggers the action control and evaluates the entries in the table for
transaction VELOS. This takes place on the basis of the action data and the existing vehicle
data. The system makes checks in the following order:
a. Is there a fitting entry in the table for transaction VELOS? If yes, the system uses
this entry.
b. If no: is there a generic entry that fits, in other words, an entry for which fields are
empty and therefore all existing values can be taken? If yes, the system uses this entry.
If there is no generic entry or more than one suitable one and if the action controls in
the entries are not identical, the system displays an error message.

As soon as the system has found the correct action control, determination is ended.
The system performs the desired action and sets the status that is stored in the system
as new status for this action in the action control. If the system does not find a suitable
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

action control, it displays an error message and you have to correct the entries in
transaction VELOS appropriately.

Vehicle IDOC.
The vehicle IDoc VEHCLE01 is part of VMS. It serves to transfer vehicle data between
manufacturer and importer or between different sales organizations. It can be an
inbound or an outbound IDoc.

Transaction VELOM for Vehicle IDOC monitoring.


Ravi Anand VMS Techno Functional – anandravi75@gmail.com

The Vehicle Manager (transaction VELO) is the central transaction of the Vehicle
Management System and contains all the most important functions in a concise form.

Use program RVLCSACREG to run Action in background.


Ravi Anand VMS Techno Functional – anandravi75@gmail.com

Make to Stock Scenario.


As importer, you sit down with your manufacturer, analyze the sales figures for the
last business period and decide on quotas for the individual vehicle models for the
new business period. This decision made, you create the number of vehicles agreed
on as planned vehicles (no value assignment possible) in your system. You do not allow
values to be assigned until you actually order the vehicles from the manufacturer. As
soon as you receive a purchase order confirmation from the manufacturer via IDoc,
you make the vehicles visible, in other words, offer them for sale to your dealers. Your
dealers can now make reservations and requests for reservations or also create a sales
order directly. As soon as a dealer has created a sales order, he/she hides the vehicle
from display so that it can no longer be seen by other dealers. Goods movements and
invoices complete the process. The process is complete when your dealer delivers the
vehicle to the end customer and the sales registration note with the license number
has been returned to you.

Make to Order Scenario.


In contrast to the make-to-stock scenario, you do not create the vehicle as importer.
Your dealer does this with respect to a sales order. The vehicle created therefore has
the configuration desired by the dealer or the end customer. As importer, you order
the desired vehicle from the manufacturer. Larger dealers can, if required, create the
vehicle, purchase order and sales order at the same time in an inter-linking action. The
manufacturer confirms the purchase order and produces the desired vehicle. He/she
updates the vehicle status using IDocs and informs you of the progress being made in
production/delivery. Goods movements and invoices complete the process. The
process is complete when your dealer delivers the vehicle to the end customer and
the sales registration note with the license number has been returned to you.
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

Configuration Scenario.
Process Flow
Make-to-Stock-Scenario (MTS)
1. The vehicle configuration is at the beginning of the MTS scenario.
2. As soon as the purchase order is created at the manufacturer, the configuration for
the purchase order becomes the vehicle configuration.
3. As soon as a subcontracting purchase order is created for rework, the additional
rework characteristics are copied to the vehicle configuration. If no rework is required,
the purchase order configuration and the sales order configuration are the same.
4. At the end, the vehicle configuration shows what the vehicle really looks like.
Make-to-Order-Scenario (MTO)
1. The vehicle configuration is at the beginning of the MTO scenario.

2. As soon as the dealer creates the sales order, the configuration for the sales order
becomes the vehicle configuration.

3. As soon as the purchase order is created, its configuration is copied to the vehicle
configuration.

4. As soon as a subcontracting purchase order is created for rework, the additional


rework characteristics are copied to the vehicle configuration. After rework, the
vehicle configuration and the sales order configuration are the same.
5. At the end, the vehicle configuration shows what the vehicle really looks like.
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

Action can be executed in background using program RVLCSACREG.

Creating a Vehicle.

Important Actions : CREA / CMOD

Procurement : Create PO

Important Actions : ORD1( To create PO) / MORD to change a PO / DORD ( To delete


a PO ) ORD2 to create Vehicle and PO.

Incoming Invoice : Action : INIV to create Invoice, IIVR to cancel Invoice.


Ravi Anand VMS Techno Functional – anandravi75@gmail.com

VMS Actions in Sales Order

Now assignment of Vehicle to Sales Documents

Important Actions :
1. LORS create loose link between Sales Order and Vehicle ( Batch ).
a. VELO11_LORS_EXECUTE
2. DELR to delete loose link between Vehicle and Sales Order.
a. VELO11_DELR_EXECUTE
3. TIRS to create tight Link between Vehicle and Sales Order.
a. VELO11_TIRS_EXECUTE
4. DETR to delete tight link between Vehicle and sales order.
a. VELO11_DETR_EXECUTE
First LORS is perquisite for TIRS.

Action for Deliver are : DELI for Delivery and DEDE to delete a Delivery.
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

Goods Issue / GR

Now Rework with Goods movement. Subcontractor is responsible for Rework.


Ravi Anand VMS Techno Functional – anandravi75@gmail.com

VMS is a Tool to track status of Vehicle.

Material should be configurable.


Ravi Anand VMS Techno Functional – anandravi75@gmail.com

Class should be assigned, For variant.

Material should be batch managed


Ravi Anand VMS Techno Functional – anandravi75@gmail.com

Valuation Category should be X

Transaction VELOM
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

You can add your model , All the model should not be visible to every one so we have
created VMS Role here.
In VELO we can see only those model which is maintained in VOLM.

Transaction VELORU

User and Model Assignment.


When you are accessing via portal than you can see only those model which is assigned
to you.

Variant Configuration : The configuration will be copied to Vehicle.


Ravi Anand VMS Techno Functional – anandravi75@gmail.com

CU43.
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

Dependency

Copy and go to CU60.


Ravi Anand VMS Techno Functional – anandravi75@gmail.com

So this dependency we maintain table name and fields , all fields which we maintained
there will be copied from CU60 based on table name.
You can maintain data in CU60.

Based on the key fields which we defined in CU62 there will be multiple entries in
CU60 transaction.
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

How to create a vehicle in VELO. Select a Model and execute action.

On Next selection screen.


Ravi Anand VMS Techno Functional – anandravi75@gmail.com

Based on the production date it will pick the CU60 data which is close to production
date.

In MM03 Characteristic we see the possible value and in VELO configuration we see
value which is populated so actually in VELO its instance of Char. Which we defined in
MM03 using class type.

Here we defined Char. Which is possible and once we create a Vehicle we populate
values.
Class type 300 will be assigned to Material in MM03.

One base Engine can have multiple BOM. OCC Code first need to maintain in CU60.
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

Now only those OCC Code we can use. OCC code should be only one, in case of
multiple system will not pick anything.

Object Dependency in BOM’


Ravi Anand VMS Techno Functional – anandravi75@gmail.com

Based on dependency BOM is selected.


NO OCC Code No BOM assigned.
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

Primary and Secondary Status.

Availability

Configuration of Action
SPRO->
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

Define Actions
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

Interlinking means : You are performing some action and in the back end you are
performing some other action.
Internal Action : Not called through VELO action. You can call it in BADI Etc.
Primary Action :
Secondary Action :

Primary Status :
Secondary Status :

Status Table

There is single table for both Primary and Secondary status, Its Free text without any
validation.
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

Action Matrix
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

Once we perform action CREA than primary status would be P002.

Based on Old status and action New status get updated.


Availability

Based on action Availability get


changed. Availability is just for information to see the status of vehicle.
Ravi Anand VMS Techno Functional – anandravi75@gmail.com
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

Under details Tab if we click on Action we will get all the action and when we click on
Action tab than it will show us only those action , possible for this Vehicle.

ASN : Advance Shipping notification.


1. PO for OEM. ( Make to Stock ). Example 2 quantity.
2. OEM send as ASN. When we can receive Vehicle.
3. In ECC We will create Inbound delivery based on PO.
4. In ECC we will create SO and perform loose link action. Based on Quantity SO split
the line items into multiple Line item ( Later on we will put batch number in each
line item during Tight Link ).
During Action LORS means loose link Table VLCRESERVATION get updated.

When we execute Tight Link, Batch number will be updated in sales order. And entry
from Reservation get deleted. VLCRESERVATION is only to show that Vehicle is loose
linked.

Also there will be change in Configuration.


Ravi Anand VMS Techno Functional – anandravi75@gmail.com

Next step would be


Outbound deliver / Good Issue / Outgoing invoice…..FI activity start than.

Secondary Action means another set of action which we can perform parallel.

To understand net requirement.


Ravi Anand VMS Techno Functional – anandravi75@gmail.com

VMS Technical
Ravi Anand VMS Techno Functional – anandravi75@gmail.com
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

BADI :

METHOD IF_EX_VLC_EXECUTE_ACTION~EXECUTE_FURTHER_ACTIONS.
break ranand.

CASE INCOMING_ACTION_IS-AKTION.
WHEN 'ZSP1'.
CALL FUNCTION 'ZVELO10_UORD_EXECUTE1'
* EXPORTING
* ABA_UORD_IV = ABA_UORD_GC
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

* ABA_UTPO_IV = ABA_UTPO_GC
TABLES

VLCDIAVEHI_CT = VLCDIAVEHI_CT
VLCH_MSSG_CT = VLCH_MSSG_CT
VLCBAPICU_IT = VLCBAPICU1_IT
CHANGING
VLCACTDATA_CS = VLCACTDATA_CS
EXCEPTIONS
NO_LGORT =1
REWORK_BACKUP_CFG_ERROR =2
ORD1_ERROR =3
GMVT_HEADER_ERROR =4
GMVT_ITEM_ERROR =5
GMVT_UNKNOWN_ERROR =6
GMVT_POST_ERROR =7
GMVT_NOT_PERFORMED =8
VLCGMOVEM_NOT_UPDATED =9
OPEN_DELIVERY_FOUND = 10
OTHERS = 11
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here

ENDIF.
WHEN 'ZSP2' .
CALL FUNCTION 'ZVELO17_UGRE_EXECUTE1'
EXPORTING
ABA_UORD_IV = 'UORD'
ABA_UGRE_IV = 'UGRE'
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

TABLES
VLCDIAVEHI_CT = VLCDIAVEHI_CT

VLCH_MSSG_CT = VLCH_MSSG_CT
CHANGING
VLCACTDATA_CS = VLCACTDATA_CS
EXCEPTIONS
PREPARE_ERROR =1
PORDERS_NOT_FOUND =2
BAPI_HEADER_ERROR =3
BAPI_ITEM_ERROR =4
UGRE_NOT_PERFORMED =5
BAPI_POST_ERROR =6
VLCGRECEIPT_NOT_UPDATED = 7
NO_COMPONENTS_FOUND =8
OTHERS = 9.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
RAISE ACTION_NOT_PERFORMED .
ENDIF.
WHEN 'ZSP3' .
CALL FUNCTION 'ZVELO11_LORS_EXECUTE1'
TABLES
VLCDIAVEHI_CT = VLCDIAVEHI_CT
VLCH_MSSG_CT = VLCH_MSSG_CT
CHANGING
VLCACTDATA_CS = VLCACTDATA_CS
EXCEPTIONS
ACTION_NOT_PERFORMED = 1
UPDATE_NOT_PERFORMED = 2
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

OTHERS = 3.
IF SY-SUBRC <> 0.

* Implement suitable error handling here


RAISE ACTION_NOT_PERFORMED .
ENDIF.
WHEN 'ZSP4' .
CALL FUNCTION 'ZUPDATE_PO_COMPONENTS'
EXPORTING
* ADDR_IS =
* ABA_POEU_IV = ABA_POEU_GC
ABA_UORD_IV = 'UORD'"ABA_UORD_GC
* ABA_ORD1_IV = ABA_ORD1_GC
TABLES
VLCDIAVEHI_CT = VLCDIAVEHI_CT
VLCH_MSSG_CT = VLCH_MSSG_CT
VLCBAPICU_IT = VLCBAPICU1_IT
* VLCPORDER_ET =
CHANGING
VLCACTDATA_CS = VLCACTDATA_CS
EXCEPTIONS
PO_ERROR =1
PO_SET_CFG_ERROR = 2
SET_VHCLE_CFG_ERROR = 3
SUPPLIER_DIFFERENT = 4
PO_CFG_TO_DB_ERROR = 5
PO_VLCPORDER_ERROR = 6
OTHERS = 7.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

RAISE ACTION_NOT_PERFORMED .
ENDIF.

WHEN 'ZSP5'.

CALL FUNCTION 'ZVMS_ZSP5_PO_CREATE'


* EXPORTING
* ABA_UORD_IV = ABA_UORD_GC
* ABA_UTPO_IV = ABA_UTPO_GC
TABLES
VLCH_MSSG_CT = VLCH_MSSG_CT
VLCDIAVEHI_CT = VLCDIAVEHI_CT
VLCBAPICU_IT = VLCBAPICU1_IT
CHANGING
VLCACTDATA_CS = VLCACTDATA_CS
EXCEPTIONS
PO_ERROR =1
OTHERS = 2.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
*Start of change by rdubey ISI-14680*

when 'ZWGR'.

CALL FUNCTION 'ZVMS_ZWGR_INV_CREATE'


* EXPORTING
* ABA_UORD_IV = ABA_UORD_GC
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

* ABA_UTPO_IV = ABA_UTPO_GC
TABLES

VLCDIAVEHI_CT = VLCDIAVEHI_CT
VLCBAPICU_IT = VLCBAPICU1_IT
VLCH_MSSG_CT = VLCH_MSSG_CT
CHANGING
VLCACTDATA_CS = VLCACTDATA_CS
EXCEPTIONS
BAPI_HEADER_ERROR =1
PREPARE_ERROR =2
OTHERS =3
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

WHEN 'ZMOR' .
CALL FUNCTION 'ZVELO10_MORD_EXECUTE'
* EXPORTING
* ABA_ORD1_IV = ABA_ORD1_GC
TABLES
vlcdiavehi_ct = vlcdiavehi_ct
vlch_mssg_ct = vlch_mssg_ct
vlcbapicu_it = vlcbapicu1_it
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

CHANGING
vlcactdata_cs = vlcactdata_cs

EXCEPTIONS
PREPARE_ERROR =1
PO_SET_CFG_ERROR =2
SET_TARGET_CFG_ERROR =3
ERROR_UPDATE_VLCPORDER =4
PUR_DOCU_CHANGE_NOT_PERFORMED =5
PO_CFG_TO_DB_ERROR =6
OTHERS =7
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
WHEN 'ZMSO' .
CALL FUNCTION 'ZVELO10_MORD_EXECUTE'
* EXPORTING
* ABA_ORD1_IV = ABA_ORD1_GC
TABLES
vlcdiavehi_ct = vlcdiavehi_ct
vlch_mssg_ct = vlch_mssg_ct
vlcbapicu_it = vlcbapicu1_it
CHANGING
vlcactdata_cs = vlcactdata_cs
EXCEPTIONS
PREPARE_ERROR =1
PO_SET_CFG_ERROR =2
SET_TARGET_CFG_ERROR =3
ERROR_UPDATE_VLCPORDER =4
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

PUR_DOCU_CHANGE_NOT_PERFORMED =5
PO_CFG_TO_DB_ERROR =6

OTHERS =7
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

*End of change by rdubey ISI-14680*


ENDCASE .
ENDMETHOD.

*--- Top Declaration

FUNCTION-POOL ZVMS_ACTION_ZSP5 MESSAGE-ID VELO.


tables : ekko, T161, T001L.
TYPE-POOLS : VLCH,
IBXX.

INCLUDE lvelo02con.

*--- Below Screen contain all the variables


INCLUDE LVELO15ACT.

*--- PBO Action Screen General


INCLUDE LVELO15O01.
INCLUDE LVELO15F01.
INCLUDE LVELO15O02.
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

INCLUDE LVELO15F02.
INCLUDE LVELO15O03.

INCLUDE LVELO15F03.

INCLUDE LVELO15I01.
INCLUDE LVELO15F04.
INCLUDE LVELO15I02.
INCLUDE LVELO15F05.
INCLUDE LVELO15I03.
INCLUDE LVELO15F06.
INCLUDE LVELO15O04.
INCLUDE LVELO15F07.
INCLUDE LVELO15I04.
INCLUDE LVELO15F08.

INCLUDE lvelo15f21.

TYPES : BEGIN OF TY_ITEM,


MATNR TYPE MATNR,
MENGE TYPE MENGE_D,
IND(1),
END OF TY_ITEM.

TYPES : BEGIN OF TY_HEADER,


BSART TYPE EKKO-BSART,
EKORG TYPE EKKO-EKORG,
EKGRP TYPE EKKO-EKGRP,
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

LIFNR TYPE LFA1-LIFNR,


DEL_DATE TYPE SY-DATUM,

KBETR type KBETR, " COndition Price


BUKRS type EKKO-BUKRS,
werks type ekPo-werks,
END OF TY_HEADER.

DATA : GT_ITEM TYPE STANDARD TABLE OF TY_ITEM,


GX_ITEM TYPE TY_ITEM,
GX_HEADER TYPE TY_HEADER.

CONTROLS : TAB_CTR TYPE TABLEVIEW USING SCREEN 9000.

* INCLUDE LZVMS_ACTION_ZSP5D... " Local class definition

ISOLATION Code

METHOD IF_EX_VLC_EXECUTE_ACTION~VEHICLE_ISOLATION.
BREAK RANAND.
FIELD-SYMBOLS: <FS_OK> TYPE VLCDIAVEHI.

DATA: LT_VEHI_OK TYPE TABLE OF VLCDIAVEHI,


LT_MSSG TYPE VLCH_MSSG_PT,
LT_VLCVEHICLE TYPE TABLE OF VLCVEHICLE,
LT_HISTORY TYPE TABLE OF VLCHISTORY,
LS_HISTORY TYPE VLCHISTORY,
LT_CONFIG TYPE VLCBAPICU_T,
LS_VEHI_OK_TEMP TYPE VLCDIAVEHI,
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

LS_VLCDIAVEHI_CT LIKE LINE OF VLCDIAVEHI_CT,


LS_VLCDIAVEHI_OK_CT LIKE LINE OF VLCDIAVEHI_OK_CT.

CONSTANTS: LC_1_GREEN TYPE CHAR1 VALUE '1'.

IF ( ELEMENTARY_ACTION_IS-AKTION EQ 'ZSP5'
or ELEMENTARY_ACTION_IS-AKTION EQ 'ZWGR' ).

LOOP AT VLCDIAVEHI_OK_CT ASSIGNING <FS_OK>.


REFRESH: LT_VEHI_OK,
LT_MSSG.
APPEND <FS_OK> TO LT_VEHI_OK.
LT_CONFIG = VLCBAPICU_IT.

CALL FUNCTION 'VELO09_SET_SINGLE_ACTION'


EXPORTING
INCOMING_ACTION_IS = INCOMING_ACTION_IS
ELEMENTARY_ACTION_IS = ELEMENTARY_ACTION_IS
DIALOGUE_ALLOWED_IV = DIALOGUE_ALLOWED_IV
TABLES
VLCDIAVEHI_CT = LT_VEHI_OK "vlcdiavehi_ok_ct
VLCSTATUS_IT = VLCSTATUS_IT
VLCH_MSSG_CT = VLCH_MSSG_CT
VLCBAPICU_IT = LT_CONFIG
CHANGING
VLCACTDATA_CS = VLCACTDATA_CS
EXCEPTIONS
ACTION_NOT_PERFORMED = 1
OTHERS = 2.
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

IF SY-SUBRC = 0.

* Implement suitable error handling here


* commit work and wait.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
*--> Set the success flag and update export tables

CALL FUNCTION 'VELO09_SET_SUCCESS_MESSAGE'


EXPORTING
INCOMING_ACTION_IS = INCOMING_ACTION_IS
ELEMENTARY_ACTION_IS = ELEMENTARY_ACTION_IS
TABLES
VLCDIAVEHI_OK_IT = LT_VEHI_OK
VLCH_MSSG_CT = LT_MSSG.

APPEND LINES OF LT_MSSG TO VLCH_MSSG_CT.


*--> Set the success green flag
*Refreshing Action screen on the Velo Transcation
CLEAR LS_VEHI_OK_TEMP.
READ TABLE LT_VEHI_OK INTO LS_VEHI_OK_TEMP INDEX 1.
IF SY-SUBRC EQ 0.
LS_VEHI_OK_TEMP-XERROR = LC_1_GREEN.

READ TABLE VLCDIAVEHI_CT INTO LS_VLCDIAVEHI_CT WITH KEY VGUID =


LS_VEHI_OK_TEMP-VGUID.
IF SY-SUBRC EQ 0.
MODIFY VLCDIAVEHI_CT INDEX SY-TABIX FROM LS_VEHI_OK_TEMP .
ENDIF.
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

ENDIF.

REFRESH: LT_VLCVEHICLE,
LT_HISTORY.

CALL FUNCTION 'VELO04_UPDATE_VEHICLES'


TABLES
VLCVEHICLE_IT = LT_VLCVEHICLE
EXCEPTIONS
NOT_PERFORMED = 1
OTHERS = 2.

IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

REFRESH LT_VLCVEHICLE.
CLEAR LS_VEHI_OK_TEMP.
READ TABLE LT_VEHI_OK INTO LS_VEHI_OK_TEMP INDEX 1.
IF SY-SUBRC EQ 0.
READ TABLE VLCDIAVEHI_OK_CT INTO LS_VLCDIAVEHI_OK_CT WITH KEY VGUID
= LS_VEHI_OK_TEMP-VGUID.
IF SY-SUBRC EQ 0.

MODIFY VLCDIAVEHI_OK_CT INDEX SY-TABIX FROM LS_VEHI_OK_TEMP .


ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
ENDMETHOD.
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

Screen level

*&SPWIZARD: DECLARATION OF TABLECONTROL 'TAB_CTR1' ITSELF


CONTROLS: TAB_CTR1 TYPE TABLEVIEW USING SCREEN 9000.

*&SPWIZARD: LINES OF TABLECONTROL 'TAB_CTR1'


DATA: G_TAB_CTR1_LINES LIKE SY-LOOPC.

DATA: OK_CODE LIKE SY-UCOMM.

*&SPWIZARD: OUTPUT MODULE FOR TC 'TAB_CTR1'. DO NOT CHANGE THIS LINE!


*&SPWIZARD: UPDATE LINES FOR EQUIVALENT SCROLLBAR
MODULE TAB_CTR1_CHANGE_TC_ATTR OUTPUT.
EKKO-BSTYP = 'F'.
DESCRIBE TABLE GT_ITEM LINES TAB_CTR1-LINES.
ENDMODULE. "TAB_CTR1_CHANGE_TC_ATTR OUTPUT

*&SPWIZARD: OUTPUT MODULE FOR TC 'TAB_CTR1'. DO NOT CHANGE THIS LINE!


*&SPWIZARD: GET LINES OF TABLECONTROL
MODULE TAB_CTR1_GET_LINES OUTPUT.
G_TAB_CTR1_LINES = SY-LOOPC.
ENDMODULE. "TAB_CTR1_GET_LINES OUTPUT

*&SPWIZARD: INPUT MODULE FOR TC 'TAB_CTR1'. DO NOT CHANGE THIS LINE!


*&SPWIZARD: MODIFY TABLE
MODULE TAB_CTR1_MODIFY INPUT.

IF GX_ITEM-MATNR NE ' '.


MODIFY GT_ITEM
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

FROM GX_ITEM
INDEX TAB_CTR1-CURRENT_LINE.

IF SY-SUBRC NE 0.
APPEND GX_ITEM TO GT_ITEM.
ENDIF.
ENDIF.
ENDMODULE. "TAB_CTR1_MODIFY INPUT

*&SPWIZARD: INPUT MODULE FOR TC 'TAB_CTR1'. DO NOT CHANGE THIS LINE!


*&SPWIZARD: PROCESS USER COMMAND
MODULE TAB_CTR1_USER_COMMAND INPUT.

OK_CODE = SY-UCOMM.
PERFORM USER_OK_TC USING 'TAB_CTR1'
'GT_ITEM'
''
CHANGING OK_CODE.
SY-UCOMM = OK_CODE.

CASE SY-UCOMM.
WHEN 'INSERT'.
CLEAR : SY-UCOMM.
"insert row
PERFORM FCODE_INSERT_ROW USING 'TAB_CTR1'
'GT_ITEM'.
WHEN 'APPEND'.
CLEAR : SY-UCOMM.
TAB_CTR1-LINES = TAB_CTR1-LINES + 1.
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

CLEAR : GX_ITEM.
APPEND GX_ITEM TO GT_ITEM.

ENDCASE.

ENDMODULE. "TAB_CTR1_USER_COMMAND INPUT

*----------------------------------------------------------------------*
* INCLUDE TABLECONTROL_FORMS *
*----------------------------------------------------------------------*

*&---------------------------------------------------------------------*
*& Form USER_OK_TC *
*&---------------------------------------------------------------------*
FORM USER_OK_TC USING P_TC_NAME TYPE DYNFNAM
P_TABLE_NAME
P_MARK_NAME
CHANGING P_OK LIKE SY-UCOMM.

*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------*


DATA: L_OK TYPE SY-UCOMM,
L_OFFSET TYPE I.
*&SPWIZARD: END OF LOCAL DATA------------------------------------------*

*&SPWIZARD: Table control specific operations *


*&SPWIZARD: evaluate TC name and operations *
SEARCH P_OK FOR P_TC_NAME.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

L_OFFSET = STRLEN( P_TC_NAME ) + 1.


L_OK = P_OK+L_OFFSET.

*&SPWIZARD: execute general and TC specific operations *


CASE L_OK.

WHEN 'APPEND'.

"insert row
PERFORM FCODE_INSERT_ROW USING P_TC_NAME
P_TABLE_NAME.
CLEAR P_OK.

WHEN 'DELE'. "delete row


PERFORM FCODE_DELETE_ROW USING P_TC_NAME
P_TABLE_NAME
P_MARK_NAME.
CLEAR P_OK.

WHEN 'P--' OR "top of list


'P-' OR "previous page
'P+' OR "next page
'P++'. "bottom of list
PERFORM COMPUTE_SCROLLING_IN_TC USING P_TC_NAME
L_OK.
CLEAR P_OK.
* WHEN 'L--'. "total left
* PERFORM FCODE_TOTAL_LEFT USING P_TC_NAME.
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

*
* WHEN 'L-'. "column left

* PERFORM FCODE_COLUMN_LEFT USING P_TC_NAME.


*
* WHEN 'R+'. "column right
* PERFORM FCODE_COLUMN_RIGHT USING P_TC_NAME.
*
* WHEN 'R++'. "total right
* PERFORM FCODE_TOTAL_RIGHT USING P_TC_NAME.
*
WHEN 'MARK'. "mark all filled lines
PERFORM FCODE_TC_MARK_LINES USING P_TC_NAME
P_TABLE_NAME
P_MARK_NAME .
CLEAR P_OK.

WHEN 'DMRK'. "demark all filled lines


PERFORM FCODE_TC_DEMARK_LINES USING P_TC_NAME
P_TABLE_NAME
P_MARK_NAME .
CLEAR P_OK.

* WHEN 'SASCEND' OR
* 'SDESCEND'. "sort column
* PERFORM FCODE_SORT_TC USING P_TC_NAME
* l_ok.

ENDCASE.
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

ENDFORM. " USER_OK_TC

*&---------------------------------------------------------------------*
*& Form FCODE_INSERT_ROW *
*&---------------------------------------------------------------------*
FORM FCODE_INSERT_ROW
USING P_TC_NAME TYPE DYNFNAM
P_TABLE_NAME .

*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------*


DATA L_LINES_NAME LIKE FELD-NAME.
DATA L_SELLINE LIKE SY-STEPL.
DATA L_LASTLINE TYPE I.
DATA L_LINE TYPE I.
DATA L_TABLE_NAME LIKE FELD-NAME.
FIELD-SYMBOLS <TC> TYPE CXTAB_CONTROL.
FIELD-SYMBOLS <TABLE> TYPE STANDARD TABLE.
FIELD-SYMBOLS <LINES> TYPE I.
*&SPWIZARD: END OF LOCAL DATA------------------------------------------*

ASSIGN (P_TC_NAME) TO <TC>.

*&SPWIZARD: get the table, which belongs to the tc *


CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body
ASSIGN (L_TABLE_NAME) TO <TABLE>. "not headerline

*&SPWIZARD: get looplines of TableControl *


CONCATENATE 'G_' P_TC_NAME '_LINES' INTO L_LINES_NAME.
ASSIGN (L_LINES_NAME) TO <LINES>.
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

*&SPWIZARD: get current line *

GET CURSOR LINE L_SELLINE.


IF SY-SUBRC <> 0. " append line to table
L_SELLINE = <TC>-LINES + 1.
*&SPWIZARD: set top line *
IF L_SELLINE > <LINES>.
<TC>-TOP_LINE = L_SELLINE - <LINES> + 1 .
ELSE.
<TC>-TOP_LINE = 1.
ENDIF.
ELSE. " insert line into table
L_SELLINE = <TC>-TOP_LINE + L_SELLINE - 1.
L_LASTLINE = <TC>-TOP_LINE + <LINES> - 1.
ENDIF.
*&SPWIZARD: set new cursor line *
L_LINE = L_SELLINE - <TC>-TOP_LINE + 1.

*&SPWIZARD: insert initial line *


INSERT INITIAL LINE INTO <TABLE> INDEX L_SELLINE.
<TC>-LINES = <TC>-LINES + 1.
*&SPWIZARD: set cursor *
SET CURSOR LINE L_LINE.

ENDFORM. " FCODE_INSERT_ROW

*&---------------------------------------------------------------------*
*& Form FCODE_DELETE_ROW *
*&---------------------------------------------------------------------*
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

FORM FCODE_DELETE_ROW
USING P_TC_NAME TYPE DYNFNAM

P_TABLE_NAME
P_MARK_NAME .

*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------*


DATA L_TABLE_NAME LIKE FELD-NAME.

FIELD-SYMBOLS <TC> TYPE CXTAB_CONTROL.


FIELD-SYMBOLS <TABLE> TYPE STANDARD TABLE.
FIELD-SYMBOLS <WA>.
FIELD-SYMBOLS <MARK_FIELD>.
*&SPWIZARD: END OF LOCAL DATA------------------------------------------*

ASSIGN (P_TC_NAME) TO <TC>.

*&SPWIZARD: get the table, which belongs to the tc *


CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body
ASSIGN (L_TABLE_NAME) TO <TABLE>. "not headerline

*&SPWIZARD: delete marked lines *


DESCRIBE TABLE <TABLE> LINES <TC>-LINES.

LOOP AT <TABLE> ASSIGNING <WA>.

*&SPWIZARD: access to the component 'FLAG' of the table header *


ASSIGN COMPONENT P_MARK_NAME OF STRUCTURE <WA> TO <MARK_FIELD>.

IF <MARK_FIELD> = 'X'.
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

DELETE <TABLE> INDEX SYST-TABIX.


IF SY-SUBRC = 0.

<TC>-LINES = <TC>-LINES - 1.
ENDIF.
ENDIF.
ENDLOOP.

ENDFORM. " FCODE_DELETE_ROW

*&---------------------------------------------------------------------*
*& Form COMPUTE_SCROLLING_IN_TC
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_TC_NAME name of tablecontrol
* -->P_OK ok code
*----------------------------------------------------------------------*
FORM COMPUTE_SCROLLING_IN_TC USING P_TC_NAME
P_OK.
*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------*
DATA L_TC_NEW_TOP_LINE TYPE I.
DATA L_TC_NAME LIKE FELD-NAME.
DATA L_TC_LINES_NAME LIKE FELD-NAME.
DATA L_TC_FIELD_NAME LIKE FELD-NAME.

FIELD-SYMBOLS <TC> TYPE CXTAB_CONTROL.


FIELD-SYMBOLS <LINES> TYPE I.
*&SPWIZARD: END OF LOCAL DATA------------------------------------------*
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

ASSIGN (P_TC_NAME) TO <TC>.


*&SPWIZARD: get looplines of TableControl *

CONCATENATE 'G_' P_TC_NAME '_LINES' INTO L_TC_LINES_NAME.


ASSIGN (L_TC_LINES_NAME) TO <LINES>.

*&SPWIZARD: is no line filled? *


IF <TC>-LINES = 0.
*&SPWIZARD: yes, ... *
L_TC_NEW_TOP_LINE = 1.
ELSE.
*&SPWIZARD: no, ... *
CALL FUNCTION 'SCROLLING_IN_TABLE'
EXPORTING
ENTRY_ACT = <TC>-TOP_LINE
ENTRY_FROM =1
ENTRY_TO = <TC>-LINES
LAST_PAGE_FULL = 'X'
LOOPS = <LINES>
OK_CODE = P_OK
OVERLAPPING = 'X'
IMPORTING
ENTRY_NEW = L_TC_NEW_TOP_LINE
EXCEPTIONS
* NO_ENTRY_OR_PAGE_ACT = 01
* NO_ENTRY_TO = 02
* NO_OK_CODE_OR_PAGE_GO = 03
OTHERS = 0.
ENDIF.
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

*&SPWIZARD: get actual tc and column *

GET CURSOR FIELD L_TC_FIELD_NAME


AREA L_TC_NAME.

IF SYST-SUBRC = 0.
IF L_TC_NAME = P_TC_NAME.
*&SPWIZARD: et actual column *
SET CURSOR FIELD L_TC_FIELD_NAME LINE 1.
ENDIF.
ENDIF.

*&SPWIZARD: set the new top line *


<TC>-TOP_LINE = L_TC_NEW_TOP_LINE.

ENDFORM. " COMPUTE_SCROLLING_IN_TC

*&---------------------------------------------------------------------*
*& Form FCODE_TC_MARK_LINES
*&---------------------------------------------------------------------*
* marks all TableControl lines
*----------------------------------------------------------------------*
* -->P_TC_NAME name of tablecontrol
*----------------------------------------------------------------------*
FORM FCODE_TC_MARK_LINES USING P_TC_NAME
P_TABLE_NAME
P_MARK_NAME.
*&SPWIZARD: EGIN OF LOCAL DATA-----------------------------------------*
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

DATA L_TABLE_NAME LIKE FELD-NAME.

FIELD-SYMBOLS <TC> TYPE CXTAB_CONTROL.


FIELD-SYMBOLS <TABLE> TYPE STANDARD TABLE.
FIELD-SYMBOLS <WA>.
FIELD-SYMBOLS <MARK_FIELD>.
*&SPWIZARD: END OF LOCAL DATA------------------------------------------*

ASSIGN (P_TC_NAME) TO <TC>.

*&SPWIZARD: get the table, which belongs to the tc *


CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body
ASSIGN (L_TABLE_NAME) TO <TABLE>. "not headerline

*&SPWIZARD: mark all filled lines *


LOOP AT <TABLE> ASSIGNING <WA>.

*&SPWIZARD: access to the component 'FLAG' of the table header *


ASSIGN COMPONENT P_MARK_NAME OF STRUCTURE <WA> TO <MARK_FIELD>.

<MARK_FIELD> = 'X'.
ENDLOOP.
ENDFORM. "fcode_tc_mark_lines

*&---------------------------------------------------------------------*
*& Form FCODE_TC_DEMARK_LINES
*&---------------------------------------------------------------------*
* demarks all TableControl lines
*----------------------------------------------------------------------*
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

* -->P_TC_NAME name of tablecontrol


*----------------------------------------------------------------------*

FORM FCODE_TC_DEMARK_LINES USING P_TC_NAME


P_TABLE_NAME
P_MARK_NAME .
*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------*
DATA L_TABLE_NAME LIKE FELD-NAME.

FIELD-SYMBOLS <TC> TYPE CXTAB_CONTROL.


FIELD-SYMBOLS <TABLE> TYPE STANDARD TABLE.
FIELD-SYMBOLS <WA>.
FIELD-SYMBOLS <MARK_FIELD>.
*&SPWIZARD: END OF LOCAL DATA------------------------------------------*

ASSIGN (P_TC_NAME) TO <TC>.

*&SPWIZARD: get the table, which belongs to the tc *


CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body
ASSIGN (L_TABLE_NAME) TO <TABLE>. "not headerline

*&SPWIZARD: demark all filled lines *


LOOP AT <TABLE> ASSIGNING <WA>.

*&SPWIZARD: access to the component 'FLAG' of the table header *


ASSIGN COMPONENT P_MARK_NAME OF STRUCTURE <WA> TO <MARK_FIELD>.

<MARK_FIELD> = SPACE.
ENDLOOP.
ENDFORM. "fcode_tc_mark_lines
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

*&---------------------------------------------------------------------*
*& Module CHECK_MATNR INPUT

*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE CHECK_MATNR INPUT.
DATA : LV_MATNR TYPE MATNR.
DATA : LX_ITEM TYPE TY_ITEM.

SELECT SINGLE MATNR


INTO LV_MATNR
FROM MARA
WHERE MATNR = GX_ITEM-MATNR.

IF SY-SUBRC NE 0.
MESSAGE 'Invalid Material.....' TYPE 'E'.
ENDIF.

* READ TABLE GT_ITEM INTO LX_ITEM WITH KEY MATNR = GX_ITEM-MATNR.


* IF SY-SUBRC = 0 and sy-ucomm ne 'APPEND'.
* MESSAGE 'Material already added.....' TYPE 'E'.
* ENDIF.

ENDMODULE. " CHECK_MATNR INPUT

*&---------------------------------------------------------------------*
*& Module MOVE_DATA_GLOBAL INPUT
*&---------------------------------------------------------------------*
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

* text
*----------------------------------------------------------------------*

MODULE MOVE_DATA_GLOBAL INPUT.


PERFORM FORM_MOVE_DATA_GLOBAL.
ENDMODULE. " MOVE_DATA_GLOBAL INPUT
*&---------------------------------------------------------------------*
*& Form FORM_MOVE_DATA_GLOBAL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FORM_MOVE_DATA_GLOBAL .

* VLCACTDATA_ITEM_GT
VLCACTDATA_HEAD_S-DOC_DATE = SY-DATUM.
VLCACTDATA_HEAD_S-BSART = EKKO-BSART.
VLCACTDATA_HEAD_S-EKORG = EKKO-EKORG.
VLCACTDATA_HEAD_S-EKGRP = EKKO-EKGRP.
VLCACTDATA_HEAD_S-LIFNR = EKKO-LIFNR.
VLCACTDATA_HEAD_S-EINDT = EKKO-AEDAT.
ENDFORM. " FORM_MOVE_DATA_GLOBAL
*&---------------------------------------------------------------------*
*& Module MOVE_DATA_GLOBAL OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE MOVE_DATA_GLOBAL OUTPUT.
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

PERFORM FORM_MOVE_DATA_GLOBAL.
ENDMODULE. " MOVE_DATA_GLOBAL OUTPUT

*&---------------------------------------------------------------------*
*& Module M_CLEAR_DATA OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE M_CLEAR_DATA OUTPUT.
PERFORM FORM_CLEAR_DATA.
ENDMODULE. " M_CLEAR_DATA OUTPUT
*&---------------------------------------------------------------------*
*& Form FORM_CLEAR_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FORM_CLEAR_DATA .

DATA: BEFORE_AFTER_LV TYPE I.


*----------------------------------------------------------------------

* Find out, if there's a before or a after the action situation


CALL FUNCTION 'VELO09_GET_BEFORE_AFTER'
IMPORTING
BEFORE_AFTER_EV = BEFORE_AFTER_LV.

* Data of VLCACTDATA should only be transferred to subscreen fields


Ravi Anand VMS Techno Functional – anandravi75@gmail.com

* before the action and after the action in order to display data
IF BEFORE_AFTER_LV IS INITIAL OR BEFORE_AFTER_LV = AFTER_ACT_GC.

*--- clear data


CLEAR : GT_ITEM, GX_ITEM,
EKKO-BSART,
EKKO-EKORG,
EKKO-EKGRP,
EKKO-LIFNR,
EKKO-AEDAT,
GX_HEADER-KBETR,
GX_ITEM-MATNR,
GX_ITEM-MENGE,
GX_ITEM-IND.
REFRESH : GT_ITEM.

ENDIF.

ENDFORM. " FORM_CLEAR_DATA


*&---------------------------------------------------------------------*
*& Module FILL_PLANT INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE FILL_PLANT INPUT.
PERFORM FORM_FILL_PLANT.
ENDMODULE. " FILL_PLANT INPUT
*&---------------------------------------------------------------------*
*& Form FORM_FILL_PLANT
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

*&---------------------------------------------------------------------*
* text

*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FORM_FILL_PLANT .
BREAK RANAND.
VLCACTDATA_HEAD_S-LGORT = T001L-LGORT.
ENDFORM. " FORM_FILL_PLANT
*&---------------------------------------------------------------------*
*& Module M_DEFAULT_VALUE OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE M_DEFAULT_VALUE OUTPUT.
PERFORM FORM_DEFAULT_VALUE.
ENDMODULE. " M_DEFAULT_VALUE OUTPUT
*&---------------------------------------------------------------------*
*& Form FORM_DEFAULT_VALUE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FORM_DEFAULT_VALUE .

IF VLCACTDATA_HEAD_S-BLDAT IS INITIAL.
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

VLCACTDATA_HEAD_S-BLDAT = SY-DATUM.
ENDIF.

IF VLCACTDATA_HEAD_S-BUDAT IS INITIAL.
VLCACTDATA_HEAD_S-BUDAT = SY-DATUM.
ENDIF.

ENDFORM. " FORM_DEFAULT_VALUE

FM

*****************************************************************
* THIS FILE IS GENERATED BY THE FUNCTION LIBRARY. *
* NEVER CHANGE IT MANUALLY, PLEASE! *
*****************************************************************
"ZVMS_ACTION_ZSP5
INCLUDE LZVMS_ACTION_ZSP5U02.
"ZVMS_ZSP5_PO_CREATE
INCLUDE LZVMS_ACTION_ZSP5U01.
"ZVMS_ZSP5_RESB_UPDATE
INCLUDE LZVMS_ACTION_ZSP5U03.
"ZVMS_ZWGR_INV_CREATE

FM ZVMS_ZSP5_PO_CREATE.

FUNCTION ZVMS_ZSP5_PO_CREATE.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

*" REFERENCE(ABA_UORD_IV) TYPE VLC_ACTDOCTYPE DEFAULT ABA_UORD_GC


*" REFERENCE(ABA_UTPO_IV) TYPE VLC_ACTDOCTYPE DEFAULT ABA_UTPO_GC

*" TABLES
*" VLCDIAVEHI_CT STRUCTURE VLCDIAVEHI
*" VLCBAPICU_IT TYPE VLCBAPICU_T
*" VLCH_MSSG_CT TYPE VLCH_MSSG_PT
*" CHANGING
*" REFERENCE(VLCACTDATA_CS) TYPE VLCACTDATA
*" EXCEPTIONS
*" PO_ERROR
*"----------------------------------------------------------------------
*--- Get the Plant from VLCVEHICLE table based on VGUID
*--- coming from VELO Variables
DATA : LV_EBELP TYPE EBELP.
DATA : LX_VLCVEHICLE TYPE VLCVEHICLE.
DATA : LV_HEADER TYPE BAPIMEPOHEADER.
DATA : LV_HEADERX TYPE BAPIMEPOHEADERX.
DATA : LT_RETURN TYPE STANDARD TABLE OF BAPIRET2.
DATA : LX_RETURN TYPE BAPIRET2.
DATA : LT_ITEM TYPE STANDARD TABLE OF BAPIMEPOITEM.
DATA : LX_ITEM TYPE BAPIMEPOITEM.

DATA : LT_ITEMX TYPE STANDARD TABLE OF BAPIMEPOITEMX.


DATA : LX_ITEMX TYPE BAPIMEPOITEMX.

DATA : LT_POCOND TYPE STANDARD TABLE OF BAPIMEPOCOND.


DATA : LX_POCOND TYPE BAPIMEPOCOND.

DATA : LT_POCONDX TYPE STANDARD TABLE OF BAPIMEPOCONDX.


Ravi Anand VMS Techno Functional – anandravi75@gmail.com

DATA : LX_POCONDX TYPE BAPIMEPOCONDX.

DATA : LV_PO_NUMBER(10).
DATA : LV_RSNUM TYPE RESB-RSNUM.
DATA : LT_RESB TYPE STANDARD TABLE OF RESB.
DATA : LX_RESB TYPE RESB.
DATA : LX_RESB_HEADER TYPE RESB.
DATA : LV_MODEL TYPE MATNR.

DATA : LT_SCHEDULE TYPE STANDARD TABLE OF BAPIMEPOSCHEDULE.


DATA : LX_SCHEDULE TYPE BAPIMEPOSCHEDULE.

DATA : LT_SCHEDULEX TYPE STANDARD TABLE OF BAPIMEPOSCHEDULX.


DATA : LX_SCHEDULEX TYPE BAPIMEPOSCHEDULX.
*--- to store curenrt line item details
DATA : LT_VLCACTDATA_ITEM_LT TYPE VLCACTDATA_ITEM_T.
DATA : VLCDIAVEHI_LS TYPE VLCDIAVEHI.
DATA : LOOP_INDEX_LV LIKE SY-TABIX.
DATA : VGUID_LS TYPE VLCGUID.
DATA : VGUID_LT TYPE TABLE OF VLCGUID.
DATA : VLCGUIDCUOBJ_RW_LS TYPE VLCGUIDCUOBJ.
DATA : VLCBAPICU_RW_LT TYPE VLCBAPICU_T.
DATA : MSGID_LV LIKE SY-MSGID,
MSGTY_LV LIKE SY-MSGTY,
MSGNO_LV LIKE SY-MSGNO,
MSGV1_LV LIKE SY-MSGV1,
MSGV2_LV LIKE SY-MSGV2,
MSGV3_LV LIKE SY-MSGV3,
MSGV4_LV LIKE SY-MSGV4,
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

* Error handling (needed to avoid type confilcts)


XERROR_LV TYPE C. " Flag: error

DATA : ADDCFG_RW_EXIST_LS TYPE VLCADDCFG.


DATA : ADDCFG_RW_TODB_LS TYPE VLCADDCFG.
DATA : VLCBAPICU_RW_LS TYPE VLCBAPICU.
DATA : ADDCFG_RW_EXIST_LT TYPE TABLE OF VLCADDCFG,
VLCACTDATA_ITEM_LS TYPE VLCACTDATA_ITEM_S,
VLCACTDATA_ITEM_LT TYPE VLCACTDATA_ITEM_T,
* Structure of header data
VLCACTDATA_HEAD_LS TYPE VLCACTDATA_HEAD_S,
ADDCFG_RW_TODB_LT TYPE TABLE OF VLCADDCFG,
ADDCFG_RW_NEW_LT TYPE TABLE OF VLCADDCFG,
ADDCFG_RW_NEW_LS TYPE VLCADDCFG,
VLCPORDER_LS TYPE VLCPORDER,
VLCPORDER_LT TYPE TABLE OF VLCPORDER.
DATA : GT_ZSP5_ITEM TYPE STANDARD TABLE OF ZSP5_ITEM .
DATA : GX_ZSP5_ITEM TYPE ZSP5_ITEM.

*--- Macro for error processing


DEFINE FILL_VLCH_MSSG_CT.

MSGID_LV = &1.
MSGTY_LV = &2.
MSGNO_LV = &3.
MSGV1_LV = &4.
MSGV2_LV = &5.
MSGV3_LV = &6.
MSGV4_LV = &7.
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

CALL FUNCTION 'VELO03_FILL_ERROR_TABLE'


EXPORTING

MSGID_IV = MSGID_LV
MSGTY_IV = MSGTY_LV
MSGNO_IV = MSGNO_LV
MSGV1_IV = MSGV1_LV
MSGV2_IV = MSGV2_LV
MSGV3_IV = MSGV3_LV
MSGV4_IV = MSGV4_LV
TABLES
VLCH_MSSG_CT = VLCH_MSSG_CT.

END-OF-DEFINITION.

BREAK RANAND.
LOOP AT VLCDIAVEHI_CT INTO VLCDIAVEHI_LS.

CLEAR : LOOP_INDEX_LV.
LOOP_INDEX_LV = SY-TABIX.

*----------------

* Prepare a list of vehicle GUIDs


CLEAR VGUID_LS.
VGUID_LS-VGUID = VLCDIAVEHI_LS-VGUID.
APPEND VGUID_LS TO VGUID_LT.

*--- Set the document type of the action which changes the configuration
VLCDIAVEHI_LS-CUABA = ABA_UORD_IV.
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

*--- Set the document type of the action which changes the vehicle

VLCDIAVEHI_LS-ACTDOCTYPE = ABA_UORD_IV.

*--- Make sure that the action doc type is written into the vehicle table
MODIFY VLCDIAVEHI_CT FROM VLCDIAVEHI_LS
INDEX LOOP_INDEX_LV TRANSPORTING ACTDOCTYPE CUABA.

*--- Fill structure needed to read the current vehicle configuration


*--- from the database
VLCGUIDCUOBJ_RW_LS-VGUID = VLCDIAVEHI_LS-VGUID.
VLCGUIDCUOBJ_RW_LS-CUOBJ = VLCDIAVEHI_LS-CUOBJ.

*--- Read the current vehicle configuration from the database


CALL FUNCTION 'VELO03_GET_CONFIG_FOR_VEHICLE'
EXPORTING
GUID_CUOBJ_MAPPING_IS = VLCGUIDCUOBJ_RW_LS
TABLES
VLCBAPICU_CT = VLCBAPICU_RW_LT
EXCEPTIONS
CONFIG_NOT_FOUND =1
OTHERS = 2.

IF SY-SUBRC <> 0.
*--- Macro for error handling
FILL_VLCH_MSSG_CT
SY-MSGID SY-MSGTY SY-MSGNO SY-MSGV1
SY-MSGV2 SY-MSGV3 SY-MSGV4.
RAISE REWORK_BACKUP_CFG_ERROR.
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

ENDIF.

CLEAR: ADDCFG_RW_EXIST_LS,
ADDCFG_RW_TODB_LS, " 441657
VLCBAPICU_RW_LS.
REFRESH: ADDCFG_RW_EXIST_LT. " 441657

*--- Find the configuration data of the vehicle


READ TABLE VLCBAPICU_RW_LT INTO VLCBAPICU_RW_LS
WITH KEY VGUID = VLCDIAVEHI_LS-VGUID.

*--- Find out if a configuration of type CFGTY_RW_GC does already exist


*--- for this vehicle. This is only the case if that's not the first
*--- subcontract order for the vehicle.
CALL FUNCTION 'VELO14_VLCADDCFG_READ_SINGLE'
EXPORTING
CFGTY_IV = CFGTY_RW_GC
VGUID_IV = VLCBAPICU_RW_LS-VGUID
TABLES
ADDCFG_ET = ADDCFG_RW_EXIST_LT
EXCEPTIONS
VLCADDCFG_READ_ERROR = 1
OTHERS = 2.

IF SY-SUBRC <> 0.

IF SY-SUBRC = 1.
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

*--- No existing configuration of type CFGTY_RW_GC. Thats not an error.


*--- A new configuration has to be created

ENDIF.

IF SY-SUBRC = 2.
*--- Unknown error
*--- Macro for error handling
FILL_VLCH_MSSG_CT
'VELO' 'E' '016' 'VELO10_UORD_EXECUTE' '' '' ''.
RAISE REWORK_BACKUP_CFG_ERROR.
ENDIF.

ENDIF.

*--- When the vehicle has already a configuration of type CFGTY_RW_GC,


*--- the existing CUOBJ is used here again.
IF NOT ADDCFG_RW_EXIST_LT[] IS INITIAL.

CLEAR ADDCFG_RW_EXIST_LS.
READ TABLE ADDCFG_RW_EXIST_LT INTO ADDCFG_RW_EXIST_LS
WITH KEY VGUID = VLCDIAVEHI_LS-VGUID.

ENDIF. " IF NOT ADDCFG_RW_EXIST_LT[] IS INITIAL.

*--- Write the new subcontract backup configuration (If


*--- ADDCFG_RW_LS-CUOBJ is not initial, an existing one is changed)
CALL FUNCTION 'VELO03_SET_SINGLE_CONFIG'
EXPORTING
VLCDIAVEHI_IS = VLCDIAVEHI_LS
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

VLCACTDATA_HEAD_IS = VLCACTDATA_HEAD_LS
VLCACTDATA_ITEM_IS = VLCACTDATA_ITEM_LS

VLCBAPICU_IS = VLCBAPICU_RW_LS
ACTDOCTYPE_IV = ABA_UORD_IV
CFGCALLID_IV = CFGCALLID_3_GC
CUOBJ_IV = ADDCFG_RW_EXIST_LS-CUOBJ
IMPORTING
CUOBJ_EV = ADDCFG_RW_TODB_LS-CUOBJ " 441657
EXCEPTIONS
NO_SET_CONFIG =1
OTHERS = 2.

IF SY-SUBRC <> 0.
*--- Macro for error handling
FILL_VLCH_MSSG_CT
SY-MSGID SY-MSGTY SY-MSGNO SY-MSGV1
SY-MSGV2 SY-MSGV3 SY-MSGV4.
RAISE REWORK_BACKUP_CFG_ERROR.
ENDIF. " IF SY-SUBRC <> 0.

*--- Add the new line to ADDCFG_RW_TODB_LT because it's needed for
*--- calling CUCB_CONFIGURATION_TO_TB
ADDCFG_RW_TODB_LS-VGUID = VLCDIAVEHI_LS-VGUID. " 441657
ADDCFG_RW_TODB_LS-CFGTY = CFGTY_RW_GC. " 441657
APPEND ADDCFG_RW_TODB_LS TO ADDCFG_RW_TODB_LT. " 441657

*--- Make a list of the new entries of VLCADDCFG. If there's no


*--- subcontract order existing for the vehicle, there's no fitting entry
*--- in table VLCADDCFG so that a new one has to be created for the
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

*--- vehicle
IF ADDCFG_RW_EXIST_LS-CUOBJ IS INITIAL.

*--- Add entry to table ADDCFG_RW_NEW_LT so that a new line is written


*--- into VLCADDCFG.
ADDCFG_RW_NEW_LS-VGUID = VLCDIAVEHI_LS-VGUID.
ADDCFG_RW_NEW_LS-CFGTY = CFGTY_RW_GC.
ADDCFG_RW_NEW_LS-CUOBJ = ADDCFG_RW_TODB_LS-CUOBJ. " 441657
APPEND ADDCFG_RW_NEW_LS TO ADDCFG_RW_NEW_LT.

ENDIF. " IF ADDCFG_RW_EXIST_LS-CUOBJ IS INITIAL.

ENDLOOP. " LOOP AT VLCDIAVEHI_CT INTO VLCDIAVEHI_LS.

BREAK RANAND.
LV_HEADER-DOC_DATE = SY-DATUM.
LV_HEADER-DOC_TYPE = VLCACTDATA_CS-BSART.
LV_HEADER-PURCH_ORG = VLCACTDATA_CS-EKORG.
LV_HEADER-PUR_GROUP = VLCACTDATA_CS-EKGRP.
LV_HEADER-VENDOR = VLCACTDATA_CS-LIFNR.

LV_HEADERX-DOC_DATE = 'X'.
LV_HEADERX-DOC_TYPE = 'X'.
LV_HEADERX-PURCH_ORG = 'X'.
LV_HEADERX-PUR_GROUP = 'X'.
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

LV_HEADERX-VENDOR = 'X'.
LV_HEADERX-COMP_CODE = 'X'. " Need

SELECT SINGLE *
INTO LX_VLCVEHICLE
FROM VLCVEHICLE
WHERE VGUID = VLCACTDATA_ITEM_S-VGUID.

LV_MODEL = LX_VLCVEHICLE-MATNR.

CLEAR : LV_EBELP.

LV_EBELP = LV_EBELP + 10.


LX_ITEM-MATERIAL = LX_VLCVEHICLE-MATNR.
LX_ITEM-QUANTITY = '1'.
LX_ITEM-PO_ITEM = LV_EBELP.
LX_ITEM-PLANT = LX_VLCVEHICLE-WERKS. " Need
LX_ITEM-ITEM_CAT = 'L'.
LX_ITEM-BATCH = LX_VLCVEHICLE-CHARG.
LX_ITEM-INT_OBJ_NO = ADDCFG_RW_TODB_LS-CUOBJ.
APPEND LX_ITEM TO LT_ITEM.

LX_ITEMX-MATERIAL = 'X'.
LX_ITEMX-QUANTITY = 'X'.
LX_ITEMX-PO_ITEM = LV_EBELP.
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

LX_ITEMX-PLANT = 'X'.
LX_ITEMX-ITEM_CAT = 'X'.

LX_ITEMX-BATCH = 'X'.
LX_ITEMX-INT_OBJ_NO = 'X'.
APPEND LX_ITEMX TO LT_ITEMX.

*--- for free material do not pass Price

LX_POCOND-ITM_NUMBER = LV_EBELP.
LX_POCOND-COND_TYPE = 'ZLBR'.
LX_POCOND-COND_VALUE = GX_HEADER-KBETR.
LX_POCOND-CURRENCY = 'USD'.
LX_POCOND-CHANGE_ID = 'I'.
APPEND LX_POCOND TO LT_POCOND.

LX_POCONDX-ITM_NUMBER = LV_EBELP.
LX_POCONDX-COND_TYPE = 'X'.
LX_POCONDX-COND_VALUE = 'X'.
LX_POCONDX-CURRENCY = 'X'.
LX_POCONDX-CHANGE_ID = 'I'.
APPEND LX_POCONDX TO LT_POCONDX.

LX_SCHEDULE-DELIVERY_DATE = GX_HEADER-DEL_DATE.
LX_SCHEDULE-PO_ITEM = LV_EBELP.
APPEND LX_SCHEDULE TO LT_SCHEDULE.

LX_SCHEDULEX-DELIVERY_DATE = 'X'.
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

LX_SCHEDULEX-PO_ITEM = LV_EBELP.
APPEND LX_SCHEDULEX TO LT_SCHEDULEX.

CLEAR : GX_ZSP5_ITEM, GT_ZSP5_ITEM.


LOOP AT GT_ITEM INTO GX_ITEM.
GX_ZSP5_ITEM-MATNR = GX_ITEM-MATNR.
GX_ZSP5_ITEM-MENGE = GX_ITEM-MENGE.
GX_ZSP5_ITEM-IND = GX_ITEM-IND.
APPEND GX_ZSP5_ITEM TO GT_ZSP5_ITEM.

ENDLOOP.
*--- Pass tye Model number as main material with Batch number and Item catagory as
L.

LOOP AT GT_ITEM INTO GX_ITEM WHERE IND = 'X'.

CLEAR : LX_ITEM, LX_ITEMX,LX_POCOND, LX_POCONDX.

LV_EBELP = LV_EBELP + 10.


LX_ITEM-MATERIAL = GX_ITEM-MATNR.
LX_ITEM-QUANTITY = GX_ITEM-MENGE.
LX_ITEM-PO_ITEM = LV_EBELP.
LX_ITEM-PLANT = LX_VLCVEHICLE-WERKS. " Need
LX_ITEM-FREE_ITEM = GX_ITEM-IND.

IF GX_ITEM-IND = 'X'.
LX_ITEM-IR_IND = ' '.
ENDIF.

APPEND LX_ITEM TO LT_ITEM.


Ravi Anand VMS Techno Functional – anandravi75@gmail.com

LX_ITEMX-MATERIAL = 'X'.

LX_ITEMX-QUANTITY = 'X'.
LX_ITEMX-PO_ITEM = LV_EBELP.
LX_ITEMX-PLANT = 'X'.
LX_ITEMX-ITEM_CAT = 'X'.

IF GX_ITEM-IND = 'X'.
LX_ITEMX-IR_IND = 'X'.
ENDIF.

LX_ITEM-FREE_ITEM = 'X'.
APPEND LX_ITEMX TO LT_ITEMX.
*--- for free material do not pass Price
IF GX_ITEM-IND = ' '.
LX_POCOND-ITM_NUMBER = LV_EBELP.
LX_POCOND-COND_TYPE = 'ZLBR'.
LX_POCOND-COND_VALUE = GX_HEADER-KBETR.
LX_POCOND-CURRENCY = 'USD'.
LX_POCOND-CHANGE_ID = 'I'.
APPEND LX_POCOND TO LT_POCOND.

LX_POCONDX-ITM_NUMBER = LV_EBELP.
LX_POCONDX-COND_TYPE = 'X'.
LX_POCONDX-COND_VALUE = 'X'.
LX_POCONDX-CURRENCY = 'X'.
LX_POCONDX-CHANGE_ID = 'I'.
APPEND LX_POCONDX TO LT_POCONDX.
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

ENDIF.

LX_SCHEDULE-DELIVERY_DATE = GX_HEADER-DEL_DATE.
LX_SCHEDULE-PO_ITEM = LV_EBELP.
APPEND LX_SCHEDULE TO LT_SCHEDULE.

LX_SCHEDULEX-DELIVERY_DATE = 'X'.
LX_SCHEDULEX-PO_ITEM = LV_EBELP.
APPEND LX_SCHEDULEX TO LT_SCHEDULEX.

ENDLOOP.

BREAK RANAND.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
POHEADER = LV_HEADER
POHEADERX = LV_HEADERX
IMPORTING
EXPPURCHASEORDER = LV_PO_NUMBER
TABLES
RETURN = LT_RETURN
POITEM = LT_ITEM
POITEMX = LT_ITEMX
POCOND = LT_POCOND
POCONDX = LT_POCONDX
POSCHEDULE = LT_SCHEDULE
POSCHEDULEX = LT_SCHEDULEX.
BREAK RANAND.
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

*--- Fill the messages


LOOP AT LT_RETURN INTO LX_RETURN.

IF ( LX_RETURN-TYPE = 'W' OR LX_RETURN-TYPE = 'I' ).


CONTINUE.
ENDIF.

CALL FUNCTION 'VELO03_FILL_ERROR_TABLE'


EXPORTING
MSGID_IV = LX_RETURN-ID
MSGTY_IV = LX_RETURN-TYPE
MSGNO_IV = LX_RETURN-NUMBER
MSGV1_IV = LX_RETURN-MESSAGE_V1
MSGV2_IV = LX_RETURN-MESSAGE_V2
MSGV3_IV = LX_RETURN-MESSAGE_V3
MSGV4_IV = LX_RETURN-MESSAGE_V4
TABLES
VLCH_MSSG_CT = VLCH_MSSG_CT.

ENDLOOP.

READ TABLE LT_RETURN INTO LX_RETURN WITH KEY TYPE = 'E'.


IF SY-SUBRC = 0.
MESSAGE 'PO creation error....' TYPE 'E'.
RAISE : PO_ERROR.
ENDIF.

break ranand.

READ TABLE VLCDIAVEHI_CT INTO VLCDIAVEHI_LS INDEX 1.


Ravi Anand VMS Techno Functional – anandravi75@gmail.com

READ TABLE LT_ITEM INTO LX_ITEM INDEX 1.

*--- Populate thabe, it will help us to display thye document


VLCPORDER_LS-VGUID = VLCDIAVEHI_LS-VGUID.
VLCPORDER_LS-TSTMP = VLCDIAVEHI_LS-NEWTSP.
VLCPORDER_LS-ACTDOCTYPE = VLCDIAVEHI_LS-ACTDOCTYPE.
VLCPORDER_LS-EBELP = LX_ITEM-PO_ITEM.
VLCPORDER_LS-EBELN = LV_PO_NUMBER.
VLCPORDER_LS-CUOBJ = ADDCFG_RW_TODB_LS-CUOBJ.
VLCPORDER_LS-ERNAM = VLCDIAVEHI_LS-ACTERNAM.
APPEND VLCPORDER_LS TO VLCPORDER_LT.

CALL FUNCTION 'VELO14_VLCPORDER_INSERT' IN UPDATE TASK


TABLES
VLCPORDER_IT = VLCPORDER_LT
EXCEPTIONS
NO_DATA_RECEIVED = 1
NO_INSERT_PERFORMED = 2
OTHERS = 3.

*--- Update RESB with new entry


*--- RESB Entry will depends on Table control entry, Only \
*--- Item with space will be part of RESB
CALL FUNCTION 'ZVMS_ZSP5_RESB_UPDATE' IN UPDATE TASK
EXPORTING
LV_PO_NUMBER = LV_PO_NUMBER.
Ravi Anand VMS Techno Functional – anandravi75@gmail.com

CALL FUNCTION 'ZVMS_ZSP5_RESB_UPDATE' IN UPDATE TASK


EXPORTING

LV_PO_NUMBER = LV_PO_NUMBER
TABLES
GT_ZSP5_ITEM = GT_ZSP5_ITEM.

ENDFUNCTION.

You might also like