Even after 5 years of tampering with ABAP, I still have problems getting used to the way SAP name their production tables. All those four letter German abbreviated names are explanatory enough to scare away any newcomer. Even the English descriptive texts that SAP provides along with each object are so Spartan, that I very seldom can make any good use out of them.
Luckily enough, I have just the right person available who seems to know all the four -- or five -- letter permutations that yield SAP table and field identifiers. (Thanks again Marilena), so today I am going to steal a few of her knowledge and give us code fragments that show how to get descriptive texts for various material and production related key's like material names, groups, blocking statuses, MRP controllers, etc.
We will start with the names of storage locations. The field and the data type for those are named
lgode. The table that stores related info is
DATA : storage_location TYPE lgort_d, storage_location_name TYPE lgobe. " storage_location = '...'. SELECT SINGLE lgobe INTO storage_location_name FROM t001l WHERE lgort = storage_location.
The next one is easy. Even I know by heart how to get the material description given the material number, but I will put it down anyway. The thing to mention however, is that most SAP text tables are language dependent, so to get the text for the key, you also need to specify the language
DATA : material TYPE matnr, material_descr TYPE maktx. " material = '...'. SELECT SINGLE maktx INTO material_descr FROM makt WHERE matnr = material AND spras = sy-langu.
Material types are stored in table
t134t which is also language dependent.
DATA : material_type TYPE mtart, material_type_descr TYPE mtbez. " material_type = '...'. SELECT SINGLE mtbez INTO material_type_descr FROM t134t WHERE mtart = material_type AND spras = sy-langu.
Our next table is
t141t, that stores the various texts for the material blocking statuses.
DATA : mat_blocking_status TYPE mstae, mat_blocking_status_descr TYPE mstb. " Material blocking status descriptions SELECT SINGLE mtstb INTO mat_blocking_status_descr FROM t141t WHERE mmsta = mat_blocking_status AND spras = sy-langu.
We wil now move to the inspiringly named
t023t table, that provides access to the short and long names of material groups.
DATA : material_group TYPE matkl, mat_group_short_descr type wgbez, mat_group_long_descr TYPE wgbez60. " material_group = "...". SELECT SINGLE wgbez wgbez60 INTO (mat_group_short_descr, mat_group_long_descr) FROM t023t WHERE matkl = material_group AND spras = sy-langu.
Product hierarchy descriptions are found in in
DATA : mat_hierarchy TYPE prodh_d, mat_hierarchy_descr TYPE vtext. " mat_hierarchy = '...'. SELECT SINGLE vtext INTO mat_hierarchy_descr FROM t179t WHERE prodh = mat_hierarchy AND spras = sy-langu.
t438t stores MRP type descriptions.
DATA : mrp_type TYPE dismm, mrp_type_descr TYPE disbez. SELECT SINGLE dibez INTO mrp_type_descr FROM t438t WHERE dismm = mrp_type AND spras = sy-langu.
Last table for today's post will be
t024d. this one contains MRP Controller descriptions and is not language but plant organized.
DATA : plant TYPE werks_d, mrp_controller type idspo, mrp_controller_descr TYPE disnam. SELECT SINGLE dsnam FROM t024d INTO mrp_controller_descr WHERE dispo = mrp_controller AND werks = plant.
... and that is enough for one day.