Ansicht
Dokumentation

/SAPAPO/TR_PROD_GET - Read Routine for Product Procurement (incl. Shipment, Quota Arrangement)

/SAPAPO/TR_PROD_GET - Read Routine for Product Procurement (incl. Shipment, Quota Arrangement)

ABAP Short Reference   ROGBILLS - Synchronize billing plans  
This documentation is copyright by SAP AG.
SAP E-Book

Functionality

Reads the procurement, the shipment, and the quota arrangements for products.

This function module reads product procurements (sources of supply) and if transportation lane entries exist it returns the dependent entries in exploded form. The corresponding quota arrangements can also be returned optionally. This function module is the central read module for planning applications and basically does the following:

Reads all permitted procurement options (sources of supply/TRPROD)

For procurement using a transportation lane: Assigns the product procurement entries (TRPROD) to the permitted means of transport entries (TRM) and the product-specific shipment entries (TRPRODM) as well as exploding the product-independent product procurement entries. It also assigns the global transportation resource from TRTYPE to TRM entries

Assigns the valid quota arrangement entries (from product-specific/product-nonspecific and version-dependent/version-independent entries), if required.

Call parameters:

The function module call can be made generically using the relevant selection criteria. The principle selection criteria are:

MODEL, VALFR, VALTO, MINLS, MAXLS, BESKZ, SUBCO, CONSI, SPRKZ, QTDIR, and internal tables for TRPID, LOCFR, LOCTO, MATID, BZQID, TTYPE

Return parameters:

Returns are made in the table e_prod_tab. This table has the structure /SAPAPO/S_TR_PROD. This structure encompasses the fields of the source of supply table and the dependent transportation lane tables, as well as quota arrangements; that is, the fields of tables TRPROD, TRM, TRPRODM, TRQTAH, and TRQTAP.

The read procedure is as follows:

Read the product procurements (assigned to models); that is, TRPROD + TRPMOD:

First, the source of supply table TRPROD is read (if necessary, using the read buffer). Here, the read buffer is defined as the key LOCTO + MATID. Then, if they are provided at the call, PPMs can be selected using task list usage, and transportation lane product procurements using the planner of the transportation lane and using the specified transportation lane; that is, start/destination location combinations (import table i_tr_tab). If necessary: Collect locfr, locto.

Read from TRM:

The TRM is read according to the selection criteria entered (if necessary, using the relevant read buffer). The read buffer reads using the LOCTO key.

Read from table TRTYPE:

This table is read to get the bucket transportation resource of the means of transport. If a bucket transportation resource (field RESUID) is not specified for a TRM entry, the bucket transportation resource of the corresponding means of transport is taken from the means of transport table TRTYPE for this TRM entry (see also the description of the data model).

Read from TRPRODM: This is done using the DB view /SAPAPO/V_TRPDM, which contains all fields from TRPRODM and the fields of the referenced entries from TRPROD and TRM. The read buffer is again defined here using the key LOCTO + MATID.

Assignment of entries from TRPROD, TRM, and TRPRODM for transportation lane procurement entries:

If the procurement entry is a transportation lane (gc_trprodtype_fb), the corresponding TRM and TRPRODM entries are assigned to this as follows:

If the PTFLG indicator ("valid for all products") is set in the TRM entry, all TRPROD entries are assigned to this entry. If a corresponding TRPRODM entry exists for both TRM and TRPROD entries, the attributes are also adopted.

If the PTFLG indicator ("valid for all products") is not set in the TRM entry, the entry is only assigned those TRPROD entries for which a corresponding TRPRODM entry exists.

When the TRPROD and TRM entries are assigned, the chronological overlap is determined from the time validities of the two entries. The validity of the combined entry results from the maximum of the start times and the minimum of end times.

For the variable transportation costs that can be entered in both the TRPRODM table and the TRM entry, the value from TRPRODM is taken first, otherwise the value from TRM is used. The variable transportation costs and unit of measure entered there are converted into the base unit of measure for the assigned product.

Then, the explicitly forbidden product/means of transport assignments (field NOTALLOWFLG) are filtered out.

Read TRM and TRPRODM entries on the basis of a selected TRPROD entry (with mixture of TRM and TRPRODM):

Trigger product-nonspecific product procurement entries (TRPROD entries)

For this, the location products are read that are found at both locations of the transportation lane read in the model, and the product-nonspecific entries are instanced for these products. Database table /sapapo/matmod is read for the specified products and locations in the internal table l_matmod_tab. An index is created for this table to speed up the filtering of products at both locations of a transportation lane. This index describes the positions of the entries for a certain location.

l_matmod_tab,,l_locidx_tab

locid,,matid,,locid,,from,,to

X,,A,,X,,1,,2,,

X,,B,,Y,,2,,2

Y,,A

This allows access to l_matmod_tab using the index.

Quantity conversion of variable transportation costs fields TCOST and TUNIT of the TRM entries)

The variable transportation costs of the associated TRM entries are converted to the base unit or measure for the product. If the entry parameter i_noconvflg_flg is set when the function module is called, conversion does not take place. This may be necessary to avoid rounding errors (currently used by SNP optimizer). If an error occurs in conversion, the original values TCOST and TUNIT are returned and the error message is written to the table e_msg_tab if the i_msgtab_flg indicator is set when the function module is called. Otherwise, the function module terminates with an error.

Entries for which product-specific entries already exist are then filtered out.

For this, the entries are sorted in such a way that the product-specific entries and the product-unspecific entries that were instanced for the same product lie next to each other. The corresponding entries for all product-specific entries that originated from the product-unspecific entries are now deleted.

Filtering out of the explicitly forbidden product/transportation lane assignments:

The product/transportation lane assignments that are explicitly forbidden by a prohibition indicator at the product-specific entry (NOTALLOWFLG at TRPRODM) are filtered out.

Selection using selection validity period

The entries are now selected using the optionally provided validity times (i_valfr_fld and i_valto_fld). This selection can only take place after the reconcile of product-specific and product-unspecific entries. This is because the existence of a product-specific entry for this product does not apply outside of its validity and is also not covered by a product-unspecific entry ("All Products"). For example: Product A is valid from 01.01.-30.06.2002 and a general entry ("All Products") is valid from 01.01.-31.12.2002. This means, for example, that product A is not valid at point in time 01.10.2002. Since a product-specific entry exists for product A, the product-unspecific entry no longer applies to this product.

Filtering out locked orders

This selection can only take place now, as with the selection using validity period.

Optional: Assignment of quota arrangement entries

First, the product-specific, version-specific, and quotation entries are assigned to the product procurement entries.

Calling this function module can activate a read buffer. This read buffers can only be used if the import tables i_locto_tab and i_matid_tab are filled. This covers requirement explosions and therefore most application cases. An extension of the read buffer is conceivable but would require a great deal of effort.

Buffering

The function module is generally called by SCM source determination and determines all external and in-house procurement options. The following objects are selected and returned in the output table e_prod_tab:

Product procurement (/sapapo/trprod)

Means of transport (/sapapo/trm)

Product-specific means of transport (/sapapo/trprodm)

Quota arrangement header (/sapapo/trqtah) - switchable

Quota arrangement item (/sapapo/trqtap) - switchable

The function module has several buffer options that are explained below. The i_buffer_flg parameter is the central control instrument for the buffer. This can be used to control whether the function module should use the original or enhanced selection or buffer. Both selections have their uses and will continue to be supported and developed further.

The original selection encompasses all input tables and parameters (except the tables i_matlocfr_tab, i_matlocto_tab, and i_matlocft_tab) of the function module. These can be used in the same way as before if the i_buffer_flg parameter is filled with ' '. There should not be a decrease in performance caused by the recently implemented buffer options. A restricted buffer using matid and locto is possible if the i_buffer_flg parameter is filled with 'X'.

More information on the values mentioned for parameter i_buffer_flg:

  • Value ' '--> Selection using all input tables or parameters (except i_matlocfr_tab, i_matlocto_tab, and i_matlocft_tab) directly from the databse. The buffer is not filled in this case.
  • Value 'X' --> Selection is restricted to the input tables for product GUID / destination location GUID i_matid_tab / i_locto_tab and all input parameters. In this case, the input parameter for model i_model_fld has to be filled. The buffer can either be created using a preselection with the function module /sapapo/tr_prod_prefetch or continuously over several calls.

The original selection options are very flexible and extensive. Buffering that uses the total combinational analysis of the call options is not possible, so you have to make certain restrictions in buffer extension. It may be that you do not want to use the extended buffer but that you want to make restrictions using the original selection options. You can use the values 'Y'and 'Z' to use the original selection options and fill the extended buffer. For example, this option can be used to make a restricted preselection that will enable you to later use new calls of this function module with restricted selection options to access these entries using extended buffering.

More information on the values mentioned for parameter i_buffer_flg:

  • Value 'Y' --> see value ' ' plus filling of extended buffer
  • Value 'Z' --> see value 'X' plus filling of extended buffer

To use extended buffering (values '1'and '2'), you have to restrict yourself to the following selection tables. It is also not possible to use several of the input tables together; for example, to create an additional restriction.

  • Product procurement GUID ,,,,,,--> Input table i_trpid_tab
  • Model, start and destination location ,,,,,,--> Input table i_tr_tab
  • Purchase contract GUID ,,,,,,,,--> Input table i_bzqid_tab
  • Sales contract GUID ,,,,,,,,--> Input table i_scoid_tab
  • Product GUID/start location GUID ,,,,--> Input table i_matlocfr_tab
  • Product GUID/destination location GUID ,,,,--> Input table i_matlocto_tab
  • Product GUID/start/destination location GUID ,,--> Input table i_matlocft_tab
  • Means of tranport GUID ,,,,,,,,--> Input table i_trmid_tab

A model always has to be used for the read, which means that parameter i_model_fld always has to be valuated.

A restriction can be made using all input parameters and the input tables i_ttype_tab, i_planid_tab, and i_planner_rtab. However, this restriction will only be taken into account after data selection.

You can use value '0' together with the restricted selection options mentioned above to access the database directly.

More information on the values mentioned for parameter i_buffer_flg:

  • Value '0' --> You can access the database directly using the restricted selection options mentioned above and the input parameters and tables that are also mentioned. The buffer is not filled in this case.
  • Value '1'--> You can access the previously selected entries exclusively in the buffer using the restricted selection options mentioned above and the input parameters and tables that are also mentioned.
  • Value '2'--> You can access the buffer or database using the restricted selection options mentioned above and the input parameters and tables that are also mentioned. For example, this option can be used to fill the buffer continuously over multiple calls.

Additional restrictions:

The context-specific tables or parameters (such as i_planid_tab or i_ttype_tab) can only be used if the procurement parameter i_beskz_fld is filled accordingly. For example, it is not useful to make a restriction using plan GUIDs if the procurement parameter theoretically also allows external procurements.

If a combination of selection tables and parameters was used that is not permitted, the WRONG_SELECTION exception is activated.

Example

Notes

Further information





Parameters

E_MSG_TAB
E_PROD_NOQUOTA_TAB
E_PROD_TAB
E_PROD_VALIDITIES
E_TRPID_USAGE
I_ACCID_FLD
I_AGGTPL_FLG
I_APPLI_FLG
I_APRD_LOCPROD_FLG
I_BESKZ_FLD
I_BUFFER_FLG
I_BZQID_TAB
I_BZQ_INT_FLD
I_CONSI_FLD
I_DTLTPL_FLG
I_IH_HLEVEL
I_IH_RELID
I_LOCFRNO_RTAB
I_LOCFR_TAB
I_LOCPROD_FLG
I_LOCTONO_RTAB
I_LOCTO_TAB
I_MATID_TAB
I_MATLOCFR_TAB
I_MATLOCFT_TAB
I_MATLOCTO_TAB
I_MATNR_RTAB
I_MAXLS_FLD
I_MINLS_FLD
I_MODEL_FLD
I_MODE_FLD
I_MSGTAB_FLG
I_NAME_RTAB
I_NOUNITCONV_FLG
I_NO_ACCID_FILTER
I_ONLY_MOST_REL_MOT_FLG
I_PLANID_TAB
I_PLANNER_RTAB
I_PLUSAGE_FLD
I_PREFETCH_FLG
I_PRODNOTRSP_FLG
I_PRODSPRKZ_FLG
I_PR_HLEVEL
I_PR_RELID
I_QTDIR_FLD
I_SCOID_TAB
I_SELPIOL_FLG
I_SOS_AND_QUOTA
I_SPRKZ_FLD
I_SUBCO_FLD
I_TRMID_TAB
I_TRPID_TAB
I_TRPTYPE_FLD
I_TR_TAB
I_TTYPE_TAB
I_VALFR_FLD
I_VALTO_FLD
I_VDREL_LOCFR
I_VERSID_FLD

Exceptions

INTERNAL_ERROR
MATERIAL_NOT_FOUND
UNIT_CONVERSION_FAILED
WRONG_SELECTION

Function Group

APO/SAPLOO_TR_READ

BAL_S_LOG - Application Log: Log header data   General Material Data  
This documentation is copyright by SAP AG.

Length: 16150 Date: 20240419 Time: 205837     sap01-206 ( 281 ms )