Material characteristics can be obtained with the CLAF_CLASSIFICATION_OF_OBJECTS function.
Material Class:
Material characteristic value:
Selection-Screen:
Result:
■T-Code often be used:
CT04
CL02
OMS2
■Table often be used:
INOB
AUSP
CAWN
TCLA
Table Field OBJEK of AUSP = MATNR field of MARA Table
Sometimes the field OBJEK of INOB Table = MATNR field of MARA Table.
*&---------------------------------------------------------------------*
*& Report ZMaterialCharacteristic
*&
*&---------------------------------------------------------------------*
*& Note for Turkish speakers:
*& You can visit the link below to access my ABAP
*& and other courses at a discount.
*& https://saitorhan.com/udemy-kurslarim/
*&---------------------------------------------------------------------*
REPORT ZMaterialCharacteristic.
TYPE-POOLS: SLIS.
TABLES: MARA, MAKT, CABNT, CABN, T006A, AUSP.
DATA: BEGIN OF GT_METADATAS OCCURS 0,
MATNR LIKE MARA-MATNR, " material no.
MAKTX LIKE MAKT-MAKTX, " Material description
atinn LIKE AUSP-ATINN, " characteristic
ATBEZ LIKE CABNT-ATBEZ, " Characteristic description
MSEHI LIKE CABN-MSEHI, " Measurement unit
ATWRT LIKE AUSP-ATWRT, " Character characteristic value
ATFLV LIKE AUSP-ATFLV, " Numeric Lower value
ATFLB LIKE AUSP-ATFLB, " numeric upper value
MSEH6 LIKE T006A-MSEH6, " Unit of measure technical definition
SPRAS LIKE T006A-SPRAS, " language
ATFOR LIKE CABN-ATFOR, " data type
ANZST LIKE CABN-ANZST, " character length
ANZDZ LIKE CABN-ANZDZ, " number of decimal characters
VAL1 TYPE C LENGTH 10, " numeric value sub
VAL2 TYPE C LENGTH 10, " numerical value upper
END OF GT_METADATAS.
DATA: FCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA: LAYOUT TYPE SLIS_LAYOUT_ALV.
DATA: VARYANT TYPE DISVARIANT.
VARYANT-REPORT = SY-REPID.
VARYANT-USERNAME = SY-UNAME.
SELECTION-SCREEN BEGIN OF BLOCK PARAMETERS WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS:
P_MATNR FOR MARA-MATNR,
P_MATKL FOR MARA-MATKL.
SELECTION-SCREEN END OF BLOCK PARAMETERS.
START-OF-SELECTION.
IF P_MATNR[] IS INITIAL AND P_MATKL[] IS INITIAL.
MESSAGE 'Material number or one of the Goods Group must be entered'
TYPE 'S' DISPLAY LIKE 'E'.
CHECK 1 EQ 2.
ENDIF.
PERFORM GETDATA.
PERFORM SHOWDATA.
*&---------------------------------------------------------------------*
*& Form GETDATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM GETDATA .
SELECT
MR~MATNR
MT~MAKTX
AP~ATWRT
AP~ATFLV
AP~ATFLB
AP~ATINN
CN~ATFOR
CN~ANZST
CN~ANZDZ
CN~MSEHI
CT~ATBEZ
TA~MSEH6
TA~SPRAS
FROM MARA AS MR
JOIN MAKT AS MT ON MR~MATNR EQ MT~MATNR
JOIN AUSP AS AP ON MR~MATNR EQ AP~OBJEK
JOIN CABN AS CN ON AP~ATINN EQ CN~ATINN
JOIN CABNT AS CT ON CN~ATINN EQ CT~ATINN
LEFT JOIN T006A AS TA ON CN~MSEHI EQ TA~MSEHI
INTO CORRESPONDING FIELDS OF TABLE GT_METADATAS
WHERE AP~OBJEK IN P_MATNR
AND MR~MATKL IN P_MATKL.
DELETE GT_METADATAS WHERE SPRAS IS NOT INITIAL AND SPRAS NE SY-LANGU.
LOOP AT GT_METADATAS WHERE ATFOR EQ 'NUM'.
CALL FUNCTION 'FLTP_CHAR_CONVERSION'
EXPORTING
DECIM = GT_METADATAS-ANZDZ
EXPON = 0
INPUT = GT_METADATAS-ATFLV
IVALU = 'X'
* MASKN = ' '
IMPORTING
FLSTR = GT_METADATAS-VAL1.
" Assigned to see values in a single column
GT_METADATAS-ATWRT = GT_METADATAS-VAL1.
CALL FUNCTION 'FLTP_CHAR_CONVERSION'
EXPORTING
DECIM = GT_METADATAS-ANZDZ
EXPON = 0
INPUT = GT_METADATAS-ATFLB
IVALU = 'X'
* MASKN = ' '
IMPORTING
FLSTR = GT_METADATAS-VAL2.
MODIFY GT_METADATAS.
ENDLOOP.
ENDFORM. " GETDATA
*&---------------------------------------------------------------------*
*& Form SHOWDATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM SHOWDATA .
DATA: I_SORT TYPE SLIS_SORTINFO_ALV,
IT_SORT TYPE SLIS_T_SORTINFO_ALV.
I_SORT-SPOS = 1.
I_SORT-FIELDNAME = 'MATNR'.
APPEND I_SORT TO IT_SORT.
I_SORT-SPOS = 2.
I_SORT-FIELDNAME = 'MAKTX'.
APPEND I_SORT TO IT_SORT.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = SY-REPID
I_INTERNAL_TABNAME = 'GT_METADATAS'
I_INCLNAME = SY-REPID
CHANGING
CT_FIELDCAT = FCAT[].
PERFORM SET_FCAT.
LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IS_LAYOUT = LAYOUT
IT_FIELDCAT = FCAT[]
I_SAVE = 'A'
IS_VARIANT = VARYANT
IT_SORT = IT_SORT
TABLES
T_OUTTAB = GT_METADATAS.
ENDFORM. " SHOWDATA
*&---------------------------------------------------------------------*
*& Form SET_FCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM SET_FCAT .
DATA: FCATROW LIKE LINE OF FCAT.
LOOP AT FCAT INTO FCATROW.
CASE FCATROW-FIELDNAME.
WHEN 'MSEHI'.
FCATROW-TECH = 'X'.
WHEN 'SPRAS'.
FCATROW-TECH = 'X'.
WHEN 'ATFOR'.
FCATROW-TECH = 'X'.
WHEN 'ANZST'.
FCATROW-TECH = 'X'.
WHEN 'ANZDZ'.
FCATROW-TECH = 'X'.
WHEN 'ATFLB'.
FCATROW-TECH = 'X'.
WHEN 'ATFLV'.
FCATROW-TECH = 'X'.
WHEN 'VAL1'.
FCATROW-SELTEXT_S = 'Lower Value'.
FCATROW-SELTEXT_M = 'Lower Value'.
FCATROW-SELTEXT_L = 'Lower Value'.
FCATROW-REPTEXT_DDIC = 'Lower Value'.
FCATROW-TECH = 'X'.
WHEN 'VAL2'.
FCATROW-SELTEXT_S = 'Upper Value'.
FCATROW-SELTEXT_M = 'Upper Value'.
FCATROW-SELTEXT_L = 'Upper Value'.
FCATROW-REPTEXT_DDIC = 'Upper Value'.
FCATROW-TECH = 'X'.
ENDCASE.
MODIFY FCAT FROM FCATROW.
ENDLOOP.
ENDFORM. " SET_FCAT
没有评论:
发表评论