Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
INVENTORY INTERFACE
Priya Kota
PMIS Code
PR15_003917
SDC Regional Delivery Head
Amarnath Jayaraman
SDC QA Lead
Sandeep Kehra
Michael Sturman
SAP Subsidiary
SAP NA
DATE
AUTHOR
REVIEWER/APPROVER
REMARKS
1.0
Final
Table of contents
1.
Program Summary...................................................................................................................3
2.
3.
Page 2 of 13
Page 3 of 13
1. Program Summary
OBJECT OVERVIEW
Business
Process
Object ID
PTM_IF_002
Object Title
Object Description
SAP Release
SAP Module
Cycle of Testing
C4
Required
Development
Completion Date
DDMONYY
Complexity of Object
Medium
Interface run
Interface Type
Inbound
Priority
BPCS Commercial
Non-SAP
System(s) and
corresponding
File Names
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
PROGRAM ATTRIBUTES
Program title
Program Name
Program Type
Package
Authorization Group
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
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
Page 5 of 13
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.
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.
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
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.
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
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
052
053
054
055
056
057
058
059
SELECTION TEXT
Description
Name
P_FILE
P_PLANT
File
Plant
TEXT ELEMENTS
Text Description
Name
001
002
A01
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
SUBROUTINES
Description
Name
OPEN_FILE_DIALOG
VALIDATE_FILE_ONLINE
VALIDATE_FILE_BACKGROUND
DISPLAY_RESULT
CALC_QUANS
VALIDATE_PLANT
10
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
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
11
Page 12 of 13
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
Scenario
#
1
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.
12
Page 13 of 13
N/A
3. Appendix
N/A
13