You are on page 1of 13

TECHNICAL SPECIFICATION PTM_IF_002_TS - TOLUCA

INVENTORY INTERFACE

PROJECT IDENTIFICATION DETAILS


Project Name

JAFRA ACE PROJECT


Project End Date

29th Jan 2016


SDC QC Member

Priya Kota

PMIS Code

Project Start Date

10th May 2015

PR15_003917
SDC Regional Delivery Head

Amarnath Jayaraman
SDC QA Lead

Sandeep Kehra

SDC Project Manager

Michael Sturman
SAP Subsidiary

SAP NA

DOCUMENT REVISION, REVIEW, & APPROVAL HISTORY


VER

DATE

AUTHOR

REVIEWER/APPROVER

REMARKS

1.0

Aug 18, 2015

Srinivas Rao Aare

Priya Kota and or Ashish


Saxena

Final

Table of contents
1.

Program Summary...................................................................................................................3

PTM_IF_002_TS_Toluca Inventory Interface

2.
3.

Page 2 of 13

Detailed Technical Design......................................................................................................5


Appendix.................................................................................................................................13

Copyright 2011 SAP AG. All rights reserved

PTM_IF_002_TS_Toluca Inventory Interface

Page 3 of 13

1. Program Summary

OBJECT OVERVIEW

Business
Process

Object ID

PTM_IF_002

Object Title

Visibility of Toluca Inventory in SAP

Object Description

Interface of Toluca Inventory to SAP

SAP Release

Material Requirements Planning / Inventory

SAP Module

Production Planning (PP)

Cycle of Testing

C4

Required
Development
Completion Date

DDMONYY

Complexity of Object

Medium

Interface run

Batch / Real-time / Both

Interface Type

Inbound

Priority

Low / Medium / High

BPCS Commercial

Non-SAP
System(s) and
corresponding
File Names

TS Author and Phone


Number

Srinivas Rao Aare

Jafra Process
Owner and
Phone Number

Solis, Sergio

TS Approved By

Priya Kota/Ashish
Saxena

TS Approval date

DDMONYY

Non-SAP System(s)
and Descriptions
TS CONTROL

Other Contact
and Phone
Number

Other Contact and


Phone Number

PROGRAM ATTRIBUTES

Program title
Program Name
Program Type
Package
Authorization Group

Visibility of Toluca Inventory in SAP


ZPI_TOLUCA_INV
Executable
ZPP_MP
N/A

Copyright 2011 SAP AG. All rights reserved

PTM_IF_002_TS_Toluca Inventory Interface

Transaction Code
Include Programs

Function Modules
Message Class
Classes

Page 4 of 13

ZTOLUCAINV
ZPI_TOLUCA_INV_TOP for declerations
ZPI_TOLUCA_INV_SCR for selectio screen
ZPI_TOLUCA_INV_FRM for routines
N/A
ZACE_MSG_PP
N/A

SELECTION SCREEN

Selection Screen Block Name / Description Parameter


/ Select
Options
P_Plant

Type / Field
Name

Mandatory

Default
Value

WERKS

Yes

5565

Param
ID

Search
Help

Selection Screen
Text

Note: Currently an option to provide presentation file and also choose glocal file option. However this is
Provided temporarily to help with initial testing by FA.
VALIDATION OF SELECTION CRITERIA

N/A
AUTHORIZATION REQUIREMENTS

N/A
TECHNICAL FLOW DIAGRAM

Toluca Interface
Flow Diagram.xlsx

Copyright 2011 SAP AG. All rights reserved

PTM_IF_002_TS_Toluca Inventory Interface

Page 5 of 13

2. Detailed Technical Design


TABLE REQUIREMENTS

Table name: ZPINTRANSIT.


Delivery Class: A
Data Browser/Table View Maint.: Display/Maintenance Not Allowed.
Data Class: APPL0
Size: 0
Buffering: Not allowed
Enhancement Category: Cannot be enhanced.
Table Maintenance Generator: N/A but provided temporarily for helping with testing.
Function Group: N/A but currently ZPINTRANSIT
Structure
Key

Field

Data Element

Yes
Yes
No

MANDT
MATNR
MENGE

MANDT
MATNR
MENGE_D

No

AEDAT

AEDAT

Currency/Qua
n
None
None
MSEGMEINS
None

Type and
Length
CLNT 3
CHAR 18
QUAN 13
DATS 8

PROCESSING LOGIC

1. Validate plant against T001W table. If Invalid rasie an error message E057(ZACE_MSG_PP).
2. Retrieve the logical file path using class method ZCL_ACE_GEN_UTILITY=>
GET_LOGIFILE_WITH_PATH_FILE. Then extract only directory and collect files using class method
ZCL_ACE_GEN_UTILITY=>GET_FILES_IN_DIRECTORIES.
ZCL_ACE_GEN_UTILITY=> GET_LOGIFILE_WITH_PATH_FILE.
EXPORTING
IMPORTING
IV_LOGICAL_PATH
= EV_FILENAME = LV_FILENAME
Z_ACE_PTM002_IN
ET_RETURN = LT_RETURN.
IV_FILENAME = DUMMY.TXT
Then from LV_FILENAME, remove DUMMY.TXT to keep only directory.
Use below to get all files from the directory.
ZCL_ACE_GEN_UTILITY=>GET_FILES_IN_DIRECTORIES
EXPORTING
IMPORTING
IV_DIRPATH = LV_DIRNAME
ET_FILES = LT_FILELIST
ET_RETURN = LT_RETURN.

Copyright 2011 SAP AG. All rights reserved

PTM_IF_002_TS_Toluca Inventory Interface

Page 6 of 13

Validate file by using OPEN DATASET LV_FILENAME and if any message generated or any exception,
raise an error message.
3. SPLIT the file reord with HORIZONTAL TAB and prepare final data table.
4. Get data
Get MATNR for each material in file from MARA for validating material
Get RSNUM MATNR CHARG from RESB table for each material in file, WERKS = P_PLANT, XLOEK =
SPACE, CHARG IN DV-SERVIDA, LM-SERVIDA, VN-SERVIDA, TR-SERVIDA and BWART = 501.
Get MATNR WERKS CHARG from MCHA table for each file material, WERKS = P_PLANT and CHARGE
IN DV-SERVIDA, LM-SERVIDA, VN-SERVIDA, TR-SERVIDA.
Join MKPF and MSEG and get MBLNR, MJAHR, ZEILE, BWART,MATNR, MENGE where MKPF-CPUDT
= Yesterday (SY-DATUM-1), WERKS = P_PLANT and BWART IN (901, 902).
Select * from ZPINTRANSIT for each material in file.
Claculate Accumulated QTY as for each material add MSEG-MENGE with 901 movement type and
subtract MSEG-MENGE with 902 movement type
Update ZPINTRANSIT-MENGE = Accumulated QTY + ZPINTRANSIT-MENGE only when the
ZPINTRANSIT-AEDAT not equals to SY-DATUM.
5. BATCH CREATE
Check for duplicate entries with combination of Material and Batch Code. If duplicate exist, then mark that
material as invalid and to avoid further processing.
Loop the final table
Check if FILE-MATNR eixts in MARA. If not, mark the material as invalid and avoid further
processing for this material.
Check if Batch code is in following list DV, LM, VN, TR. If not, mark this material as invalid and
avoid further processing..
READ MCHA with Material, Plant and Batch. If the entry already exists, then update as Already
exists, Use BAPI_BATCH_CREATE to create batch by passing Material, Plant and Batch
number. Update as CREATED for successful execution of BAPI and ERROR for failure. If for a
material, some batches fail and some succeed, then for CREATED, update as NOT
CREATED.
EXPORTING
MATERIAL
=
FINALTABLE_MATNR
BATCH
=
FINALTABLECHARG
PLANT = P_PLANT

IMPORTING
BATCH = LV_BATCH

TABLES
RETURN = LT_RETURN

AT END OF MATERIAL.
Use BAPI_TRANSACTION COMMIT or ROLLBACK if all the batches for
material created or has no errors.
For error cases, update the final table so that these are not required to process
further.
Build a log table GT_BATCHLOG for any errors in reservation delete process.

Copyright 2011 SAP AG. All rights reserved

PTM_IF_002_TS_Toluca Inventory Interface

Page 7 of 13

6. RESERVATION DELETE
LOOP RESB table
DELETE each reservation in RESB using BAPI_RESERVATION_DELETE.
EXPORTING
TABLES
RESERVATION
=
RESB- RETURN = LT_RETURN
RSNUM

Use BAPI_COMMIT/ROLLBACK at the end of each material.


For each material if there is any error while deleting a material, mark that material as having
error so that this is not used in further processing. If all reservations are deleted, then
ALLRESDEL = YES or else NO if there is any error.
For each material, build a value by concatenating list of all RESB-RSNUMs exist and also build
a value of reservations that deleted for a material. These fields can be used in final log table .
Build a log table GT_RESBLOG for any errors in reservation delete process.

7. RESERVATION CREATE
For error materials, use GT_BATCHLOG, GT_RESBLOG to populate final GT_LOG table.
LOOP FINAL TABLE
For each material call BAPI_RESERVATION_CREATE1 as below.
EXPORTING
IMPORTING
TABLES
RESERVATIONHEADER
= RESERVATION
= RESERVATIONITEMS
=
LS_RESHEAD
LV_RSNUM
LT_RESITEMS
CALCHECK = LS_CALCHECK
PROFITABILITYSEGMENT
= LT_PROFIT
RETURN = LT_RETURN
Below is the mapping for BAPI call.
BAPI
PROGRAM VALUE
RESERVATIONHEADER
(Structure)
CREATEDBY
SY-UNAME
RES_DATE
SY-DATUM
MOVE_TYPE
501
MOVE_PLANT
P_PLANT
RESERVATIONHEADER
(Table)
MATERIAL
GT_FINAL-MATERIAL
PLANT
P_PLANT
BATCH
GT_FINAL-CHARG
ENTRY_QNT
For
TR
batch,
(ZPINTRANSIT-MENGE
+
MSEG-MENGE of 901, 902) GT_FINAL-MENGE
For other batches simly pass
GT_FINAL-MENGE.

Copyright 2011 SAP AG. All rights reserved

PTM_IF_002_TS_Toluca Inventory Interface

Page 8 of 13

For each successful call, check if the same material has some quantity to be updated in table
ZPINTRANSIT. If it is, then update using MODIFY statement and if no issues, then call
BAPI_TRANSACTION_COMMIT else BAPI_TRANSACTION_ROLLBACK.
With RETURN table, fill log table GT_LOG.

8. ARCHIVE FILE
Use method ZCL_ACE_GEN_UTILITY=>GET_LOGIFILE_WITH_PATH_FILE to get the folder for
archiving the executed file.
EXPORTING
IMPORTING
IV_LOGICAL_PATH
= EV_FILENAME
=
Z_ACE_PTM002_IN_ARCHIVE LV_TARGETFILE
IV_FILENAME = LV_FILE
ET_RETURN = LT_RETURN.
Use method ZCL_ACE_GEN_UTILITY=>ARCHIVE_FILE for archiving file to target path.
This method deletes the file in original folder and places it in target folder.
9. REPORTING for GT_LOG table.
Use method CL_SALV_TABLE=>FACTORY and CL_SALV_TABLE=>DISPLAY for table GT_LOG to
display final report.
REUSABLE CODE

N/A
FILE ATTRIBUTES

File Type
Delimited / Fixedwidth
Header Record?
Footer Record?
Number of File
Layouts and
Description
File Layout(s)

TXT
Tab
N/A
N/A
1

File_data.xlsx

Note: Header is provided in attachment just for understanding the column


File Layout.xls
name.

Copyright 2011 SAP AG. All rights reserved

PTM_IF_002_TS_Toluca Inventory Interface

Page 9 of 13

INTERNAL TABLES

Name
GT_FILE_DATA
GT_MCHA
GT_MARA
GT_RESB
GT_MSEG
GT_DETAILDUP
GT_INTRANSITVAL
GT_RESBLOG
GT_BATCHLOG
GT_DETAIL
GT_LOG

Description
File data read
Batch data for material and plant
Material Master Details
Resveration Details
Material Document Details
Check duplicates in file data
In-transit Quantities
Reservation execution log
Batch Creation Log
Uploaded file data
Execution log details

MESSAGES

Message Class

Message
ID

Message Text

ZACE_MSG_F
I

051

Invalid batch status & for material & in file!

052
053
054
055
056
057
058
059

Invalid file format! Please use the correct file!


Invalid Material &!
Reservation & Created Successfully!
Invalid file selected!
No information to display! Please check the file!
Invalid Plant &!
Duplicate entry with material & and batch & combination!
Reservation(s) deleted successfully!

SELECTION TEXT

Description
Name
P_FILE
P_PLANT

File
Plant

TEXT ELEMENTS

Text Description
Name
001
002
A01

File selection (TEMPORARY)


Selection Details for Toluca Interface
Online

Copyright 2011 SAP AG. All rights reserved

PTM_IF_002_TS_Toluca Inventory Interface

A02
A10
A11
A12
A13
A14
A15
A17
A21
A22
A23
A24
A25
A26
A27
A28
A29
A30
A31
A32
A33
A34
A35
A36
A37
A38
A39
A51
A53
A54
A55
A56
A57

Page 10 of 13

Background Logical File


DATA.VALID
BATCH.CREATE
RES.DELETE
RES.CREATE
NOT_IN_FILE_RES.DEL
Toluca Interface
Data Could Not be Read From File.
STATUS
STAGE
DV-SERVIDA
LM-SERVIDA
VN-SERVIDA
TR-SERVIDA
Existing Reservations
Existing RES
Existg.RES
Deleted Reservations
DEL.RESERVATIONS
DEL.RESERV
All Resrv. Deleted?
Resrv.Deleted?
Resrv.Del?
Reservation Created
Resrv.Created
Resrv.CRTD
Message
CREATED
ALREADY EXISTS
NO
N/A
Yes
NOT CREATED

SUBROUTINES

Description
Name
OPEN_FILE_DIALOG
VALIDATE_FILE_ONLINE
VALIDATE_FILE_BACKGROUND
DISPLAY_RESULT
CALC_QUANS
VALIDATE_PLANT

Opens a dialog for file browsing


Validates presentation server file entered
Validates application server file entered
Display log report
Calculate In-transit quantity details
Validates Plant

Copyright 2011 SAP AG. All rights reserved

10

PTM_IF_002_TS_Toluca Inventory Interface

ARCHIVE_FILE
POPULATE_RESERVATION_LO
G
POPULATE_FINAL_ERROR
LOG_VALID_BATCH_ERROR
LOG_RESDEL_ERROR
GET_DATA_AND_VALIDATE
RESERVATION_CREATE
RESERVATION_DELETION
BATCH_CREATE
SPLIT_INPUT_FILE
GET_FILE_DATA

Page 11 of 13

Deletes file from IN folder and places in ARCHIVE folder


Fill resveration execution log
Fill final error details
Fill batch error details to log
Fill reservation delete errors to log
Get data for validation and execution
Creates reservations
Deletes reservations
Creates batches
Split data to individual fields
Get data from file to Internal table

INTERFACE LIST OUTPUT

At the end of the interface run, please describe the details for the output list.
Output Method
ALV Report. Can be downloaded to excel
Main Heading
Toluca Interface

LAYOUT

TOTALING
N/A
SORTING
MATERIAL
PAGE BREAK
N/A
ERROR HANDLING
1) Error in file format: Display error message and go back to selection screen
2) Error in data: Display them in ALV with traffic lights and do not proceed with further steps
3) Error ducring process execution: Display them in ALV with traffic light

Copyright 2011 SAP AG. All rights reserved

11

PTM_IF_002_TS_Toluca Inventory Interface

Page 12 of 13

INTERFACE LIST HEADER / FOOTER

N/A
ASSUMPTIONS IN TECHNICAL DESIGN

1. While calculating for ZPINTRANSIT-MENGE, unit of measure need not be taken into account.
2. The table ZINTRANSIT will have quantity more than the material quantity provided in file.
3. There will always be one file in the designated folder for Toluca Interface or IT team will make sure of it.
4. AEDAT field is needed in ZPINTRANSIT table to make sure that the Accumulated quantity is updated only once.
OPEN ISSUES IN TECHNICAL DESIGN

N/A

UNIT TEST PLAN

Scenario
#
1

Input Selection Criteria


Test with an input file that contains
all valid materials that exist in SAP
with combination of materials with
status (DV Only, LM Only, both DV
and LM).
Test with an input file that contains
three or four materials that do not
exist in SAP.

Expected Result
Validate that Material Reservations are generated
accordingly for materials for DV Only, LM Only,
and both DV and LM.
Validate the Process Log and that there are no
exceptions (no errors)
Validate that Material Reservations are loaded for
valid materials.
Validate that the invalid materials error out and are
captured on the processing log according to the
messages in the Error Handling Section.

Test with an input file that contains


Valid SAP Materials and with Status
Types DV, LM, VC and RC.

Validate the Processing Log Summary captures


correctly the number of records processed
correctly and incorrectly according to the Error
Handling section.
Validate that four types of Material reservations
are properly created for Available, Quarantine,
Sales, and In-transit.
Validate proper MRP netting with Planned
Independent Requirements present.

Copyright 2011 SAP AG. All rights reserved

12

PTM_IF_002_TS_Toluca Inventory Interface

Page 13 of 13

RELATED DOCUMENTATION (ATTACH OSS NOTES, EMAILS, DOWNLOAD OF EXISTING


REPORT, ETC)

N/A

3. Appendix
N/A

Copyright 2011 SAP AG. All rights reserved

13