I have used FM ‘BAPI_OBJCL_GETDETAIL’ in one of my enhancements where the possibility of records are very huge. When code moved to Quality it has caused serious troubles and I have been forced to change the source code.
So, I started to alternative solutions. I haven’t found any read made solution like any existing BAPI or FM or CDS View. I came across a solution posted in below link Alternate of SAP BAPI BAPI_OBJCL_GETDETAIL
It was very informative but looks like long procedure to me, so I have started search in SAP SCN for tables involved to get material characteristics. I couldn’t get (maybe I missed) in my search.
Tables involved:
Intially I have used Ranges in Select query as in opeartion. It may cause dump if reocrds in range cross more than Number of DBSL marker
So I have used For all entries instead of ranges and I ovecame the dump.
Okumaya devam et...
So, I started to alternative solutions. I haven’t found any read made solution like any existing BAPI or FM or CDS View. I came across a solution posted in below link Alternate of SAP BAPI BAPI_OBJCL_GETDETAIL
It was very informative but looks like long procedure to me, so I have started search in SAP SCN for tables involved to get material characteristics. I couldn’t get (maybe I missed) in my search.
Tables involved:
CABN | To get Internal Characteristic Number by passing Characteristic Name assigned to Material Characteristic Class |
CAWN | To get pre-defined Characteristic values based on Internal Characteristic Number |
CAWNT | To get pre-defined Characteristic values Texts based on Internal Characteristic Number |
INOB | To get Characteristic Object for a Class and Class object [ In Our case – Material ] |
AUSP | To get Characteristic Values for Object [ In Our case – Material] |
Kod:
TYPES: BEGIN OF lty_inob,
cuobj TYPE cuobj,
objek TYPE cuobn,
cuobj_ausp TYPE cuobn,
END OF lty_inob.
TYPES: BEGIN OF lty_ausp,
objek TYPE cuobn,
atinn TYPE atinn,
atzhl TYPE wzaehl,
mafid TYPE klmaf,
klart TYPE klassenart,
adzhl TYPE adzhl,
atwrt TYPE atwrt,
END OF lty_ausp.
DATA: lt_inob TYPE STANDARD TABLE OF lty_inob,
lt_ausp TYPE STANDARD TABLE OF lty_ausp
WITH NON-UNIQUE SORTED KEY s1 COMPONENTS objek.
DATA: lr_plnum TYPE RANGE OF plnum,
lr_aufnr TYPE RANGE OF aufnr,
lr_matnr_cuobn TYPE RANGE OF cuobn,
lr_atnam TYPE RANGE OF atnam,
lv_matnr_inob TYPE cuobn,
lv_matnr TYPE matnr.
lr_atnam = VALUE #( BASE lr_atnam
( sign = 'I' option = 'EQ' low = 'Z_GAB' )
( sign = 'I' option = 'EQ' low = 'Z_OAB' )
( sign = 'I' option = 'EQ' low = 'Z_CAB' )
( sign = 'I' option = 'EQ' low = 'Z_AAB' )
( sign = 'I' option = 'EQ' low = 'Z_BAB' ) ).
*lr_atnam range object of Material Characterstics
SELECT atinn,
adzhl,
atnam
FROM cabn
INTO TABLE @DATA(lt_cabn)
FOR ALL ENTRIES IN @lr_atnam
WHERE atnam = @lr_atnam-low
ORDER BY PRIMARY KEY.
IF sy-subrc = 0.
SELECT atinn,
atzhl,
adzhl,
atwrt
FROM cawn
INTO TABLE @DATA(lt_cawn)
FOR ALL ENTRIES IN @lt_cabn
WHERE atinn = @lt_cabn-atinn
AND adzhl = @lt_cabn-adzhl.
IF sy-subrc = 0.
SORT lt_cawn BY atinn adzhl atwrt.
ENDIF.
SELECT atinn,
atzhl,
spras,
adzhl,
atwtb
FROM cawnt
INTO TABLE @DATA(lt_cawnt)
FOR ALL ENTRIES IN @lt_cabn
WHERE atinn = @lt_cabn-atinn
AND spras = @sy-langu
AND adzhl = @lt_cabn-adzhl
ORDER BY PRIMARY KEY.
ENDIF. "Select from CABN
lr_atnam = VALUE #( BASE lr_atnam
( sign = 'I' option = 'EQ' low = 'Z_GAB' )
( sign = 'I' option = 'EQ' low = 'Z_OAB' )
( sign = 'I' option = 'EQ' low = 'Z_CAB' )
( sign = 'I' option = 'EQ' low = 'Z_AAB' )
( sign = 'I' option = 'EQ' low = 'Z_BAB' ) ).
*@lr_matnr_cuobn range object of Material
SELECT cuobj,
objek
FROM inob
INTO TABLE @lt_inob
FOR ALL ENTRIES IN @lr_matnr_cuobn
WHERE klart = '001'
AND obtab = 'MARA'
AND objek = @lr_matnr_cuobn-low
ORDER BY PRIMARY KEY.
IF sy-subrc = 0.
LOOP AT lt_inob ASSIGNING FIELD-SYMBOL(<lfs_inob>).
<lfs_inob>-cuobj_ausp = <lfs_inob>-cuobj.
ENDLOOP. "LOOP AT lt_inob ASSIGNING FIELD-SYMBOL(<lfs_inob>).
SELECT objek,
atinn,
atzhl,
mafid,
klart,
adzhl,
atwrt
FROM ausp
INTO TABLE @lt_ausp
FOR ALL ENTRIES IN @lt_inob
WHERE objek = @lt_inob-cuobj_ausp
ORDER BY PRIMARY KEY.
ENDIF. "Select from INOB
ENDIF. "IF NOT lr_matnr IS INITIAL.
Intially I have used Ranges in Select query as in opeartion. It may cause dump if reocrds in range cross more than Number of DBSL marker
Kod:
Select aa,
bb
from xx
into table @data(lt_tab)
where aa in @lr_aa.
So I have used For all entries instead of ranges and I ovecame the dump.
Kod:
CLEAR: lv_matnr_inob.
lv_matnr_inob = lv_matnr.
READ TABLE lt_inob ASSIGNING <lfs_inob> WITH KEY objek = lv_matnr_inob BINARY SEARCH.
IF sy-subrc = 0.
*Using Sorted key gives better results
LOOP AT lt_ausp ASSIGNING FIELD-SYMBOL(<lfs_ausp>) USING KEY s1 WHERE objek = <lfs_inob>-cuobj_ausp.
READ TABLE lt_cabn ASSIGNING FIELD-SYMBOL(<lfs_cabn>)
WITH KEY atinn = <lfs_ausp>-atinn
adzhl = <lfs_ausp>-adzhl BINARY SEARCH.
IF sy-subrc = 0.
CASE <lfs_cabn>-atnam.
WHEN 'Z_GAB' OR
'Z_OAB' OR
'Z_CAB' OR
'Z_AAB'
READ TABLE lt_cawn ASSIGNING FIELD-SYMBOL(<lfs_cawn>)
WITH KEY atinn = <lfs_ausp>-atinn
adzhl = <lfs_ausp>-adzhl
atwrt = <lfs_ausp>-atwrt BINARY SEARCH.
IF sy-subrc = 0.
READ TABLE lt_cawnt ASSIGNING FIELD-SYMBOL(<lfs_cawnt>)
WITH KEY atinn = <lfs_ausp>-atinn
atzhl = <lfs_cawn>-atzhl
adzhl = <lfs_cawn>-adzhl BINARY SEARCH.
IF sy-subrc = 0.
CASE <lfs_cabn>-atnam.
WHEN 'Z_GAB'.
<lfs_receipts>-zzgab = |{ <lfs_ausp>-atwrt } - { <lfs_cawnt>-atwtb }|.
WHEN 'Z_OAB'.
<lfs_receipts>-zzoab = |{ <lfs_ausp>-atwrt } - { <lfs_cawnt>-atwtb }|.
WHEN 'Z_CAB'.
<lfs_receipts>-zzcab = |{ <lfs_ausp>-atwrt } - { <lfs_cawnt>-atwtb }|.
WHEN 'Z_AAB'.
<lfs_receipts>-zzaab = |{ <lfs_ausp>-atwrt } - { <lfs_cawnt>-atwtb }|.
ENDCASE.
ENDIF. "READ TABLE lt_cawnt ASSIGNING FIELD-SYMBOL(<lfs_cawnt>)
ENDIF. "READ TABLE lt_cawn ASSIGNING FIELD-SYMBOL(<lfs_cawn>)
WHEN 'Z_BAB'. "Characterstic Without Pre-defined Values
<lfs_receipts>-zzbab = |{ <lfs_ausp>-atwrt }|.
ENDCASE.
ENDIF. "READ TABLE lt_cabn ASSIGNING FIELD-SYMBOL(<lfs_cabn>)
ENDLOOP. "LOOP AT lt_ausp ASSIGNING FIELD-SYMBOL(<lfs_ausp>) WHERE objek = <lfs_inob>-cuobj_ausp.
ENDIF. "READ TABLE lt_inob ASSIGNING <lfs_inob> WITH KEY objek = lv_matnr_inob BINARY SEARCH.
Okumaya devam et...