Sistem / Kullanıcı Durumu , STATUS_READ Alternatif
Bir objenin (sipariş, ekipman, kontrol partisi, bildirim) kullanıcı ve sistem durumlarını bulmak için kullandığımız
STATUS_READ , STATUS_TEXT_EDIT fonksiyonları var, fakat tek tek çalıştırıyoruz.
Binlerce obje için fonksiyonu tek tek çalıştırmak çok zaman kaybettirici.
Toplu halde obje durumlarını alabilmek için bu iki fonksiyonu birleştirerek ZTR_READ_STATUS fonksiyonunu geliştirdik.
Kodlar dosyaları sırayla
* Import / Export Parametreleri
* LZQMIZ_TOOLTOP
* LZQMIZ_TOOLF01
* ZTR_READ_STATUS
* Örnek İmport / Export
Structure | Strucure Elemanı / Tablo Tipi | Data Element | Veri Tipi | ||
ZQMIZ_T_OBJNR | ZQMIZ_S_OBJNR | Tablo Tipi | |||
ZQMIZ_S_OBJNR | OBJNR | J_OBJNR | CHAR | 22 | Nesne numarası |
ZTR_T_STATUS_ALL | ZTR_S_STATUS_ALL | Tablo Tipi | |||
ZTR_S_STATUS_ALL | OBJNR | J_OBJNR | CHAR | 22 | Nesne numarası |
STAT | J_STATUS | CHAR | 5 | Nesne durumu | |
STTYPE | CHAR1 | CHAR | 1 | Tek basamaklı gösterge | |
OBTYP | J_OBTYP | CHAR | 3 | Nesne tipi | |
STSMA | J_STSMA | CHAR | 8 | Durum şeması | |
CHGKZ | J_CHGKZ | CHAR | 1 | Gösterge: Değişiklik belgeleri etkin | |
CHGNR_JSTO | J_CHGNR | NUMC | 3 | Değişiklik numarası | |
INACT | J_INACT | CHAR | 1 | Gösterge: Durum etkin değil | |
CHGNR_JEST | J_CHGNR | NUMC | 3 | Değişiklik numarası | |
TXT04 | J_TXT04 | CHAR | 4 | Nesnenin münferit durumu (kısa biçim) | |
TXT30 | J_TXT30 | CHAR | 30 | Nesne durumu | |
STONR | J_STONR | NUMC | 2 | Durum numarası | |
LINEP | J_LINEP | NUMC | 2 | Durumun durum göstergesindeki konumu | |
STATP | J_STATP | NUMC | 2 | Belirli bir konumda durum görüntü önceliği | |
ZTR_T_STATUS_OBJ | ZTR_S_STATUS_OBJ | Tablo Tipi | |||
ZTR_S_STATUS_OBJ | OBJNR | J_OBJNR | CHAR | 22 | Nesne numarası |
STSMA | J_STSMA | CHAR | 8 | Durum şeması | |
SYSTSTAT_ALL | J_STEXT | CHAR | 40 | Sistem durumu satırı | |
USERSTAT_ALL | J_STEXT | CHAR | 40 | Sistem durumu satırı | |
SYSTTXT04_ALL | J_STEXT | CHAR | 40 | Sistem durumu satırı | |
USERTXT04_ALL | J_STEXT | CHAR | 40 | Sistem durumu satırı | |
SYSTSTAT | J_ISTAT | CHAR | 5 | Sistem durumu | |
USERSTAT | J_ESTAT | CHAR | 5 | Kullanıcı durumu | |
SYSTTXT04 | J_TXT04 | CHAR | 4 | Nesnenin münferit durumu (kısa biçim) | |
USERTXT04 | J_TXT04 | CHAR | 4 | Nesnenin münferit durumu (kısa biçim) | |
SYSTTXT30 | J_TXT30 | CHAR | 30 | Nesne durumu | |
USERTXT30 | J_TXT30 | CHAR | 30 | Nesne durumu | |
ZTR_E_ACTIVE | XFELD | CHAR | 1 | Aktif | |
ZTR_E_INACTIVE | XFELD | CHAR | 1 | İnaktif | |
ZTR_E_USERSTAT_X | XFELD | CHAR | 1 | Kullanıcı Durumu | |
ZTR_E_SYSTEMSTAT_X | XFELD | CHAR | 1 | Sistem Durumu |
"LZQMIZ_TOOLTOP global
constants:
intern value `I`, "Interner Status
extern value `E`. "Externer Status
types: begin of ty_mixj ,
objnr type j_objnr,
stat type j_status,
sttype type c, "intern `I` , extern `E`
obtyp type j_obtyp,
stsma type j_stsma,
chgkz type j_chgkz,
chgnr_jsto type j_chgnr,
inact type j_inact,
chgnr_jest type j_chgnr,
txt04 type j_txt04,
txt30 type j_txt30,
STONR TYPE J_STONR,
LINEP Type J_LINEP,
STATP Type J_STATP,
end of ty_mixj.
types: tty_mixj type sorted table of ty_mixj with unique key objnr stat.
types: begin of ty_userstat, "TJ30 - TJ30T
stsma type j_stsma,
estat type j_estat,
inist type j_inist,
stonr type j_stonr,
hsonr type j_hsonr,
nsonr type j_nsonr,
linep type j_linep,
statp type j_statp,
bersl type j_bersl,
crm_vrgng type j_crmvrg,
txt04 type j_txt04,
txt30 type j_txt30,
end of ty_userstat.
types: tty_userstat type SORTED TABLE OF ty_userstat WITH UNIQUE key stsma estat.
types: begin of ty_systemstat, "TJ30 - TJ30T
ISTAT type J_ISTAT,
NODIS type J_NODIS,
SETONLY type J_SETONLY,
txt04 type j_txt04,
txt30 type j_txt30,
end of ty_systemstat.
types: tty_systemstat type SORTED TABLE OF ty_systemstat WITH UNIQUE key ISTAT .
types: ty_matrix type ztr_s_status_obj .
types: tty_matrix type SORTED TABLE OF ty_matrix WITH UNIQUE key OBJNR STSMA.
"""LZQMIZ_TOOLF01 foRMLAR
*&---------------------------------------------------------------------*
*& Form f_matrix
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->LT_OBJECT text
* -->LT_JSTO_JEST_EXT text
* <--ET_STATUS_OBJECT text
*----------------------------------------------------------------------*
form f_matrix using prm_stat_type type c
prt_mix type tty_mixj
changing cht_matrix type tty_matrix.
data: ls_mix like line of prt_mix.
data: ls_matrix like line of cht_matrix.
data: lv_xndx type int4.
data: lv_first type c.
data: lt_lokalmix type standard table of ty_mixj .
data: last_linep type j_linep.
loop at cht_matrix into ls_matrix.
lv_xndx = sy-tabix.
refresh lt_lokalmix.
loop at prt_mix into ls_mix where objnr = ls_matrix-objnr
and sttype = prm_stat_type
and inact = space.
append ls_mix to lt_lokalmix.
endloop.
case prm_stat_type.
when intern.
sort lt_lokalmix by linep statp txt04..
lv_first = space.
clear last_linep.
loop at lt_lokalmix into ls_mix.
if ls_mix-stonr is initial.
if last_linep = ls_mix-linep.
continue.
else.
last_linep = ls_mix-linep.
endif.
endif.
ls_matrix-syststat = ls_mix-stat.
ls_matrix-systtxt04 = ls_mix-txt04.
ls_matrix-systtxt30 = ls_mix-txt30.
if lv_first = space.
ls_matrix-syststat_all = ls_mix-stat . .
ls_matrix-systtxt04_all = ls_mix-txt04.
else.
concatenate ls_matrix-syststat_all ls_mix-stat into ls_matrix-syststat_all separated by space.
concatenate ls_matrix-systtxt04_all ls_mix-txt04 into ls_matrix-systtxt04_all separated by space.
endif.
lv_first = `X`.
endloop.
when extern.
sort lt_lokalmix by stonr descending linep statp txt04.
lv_first = space.
loop at lt_lokalmix into ls_mix.
ls_matrix-userstat = ls_mix-stat.
ls_matrix-usertxt04 = ls_mix-txt04.
ls_matrix-usertxt30 = ls_mix-txt30.
if lv_first = space.
ls_matrix-userstat_all = ls_mix-stat . .
ls_matrix-usertxt04_all = ls_mix-txt04.
else.
concatenate ls_matrix-userstat_all ls_mix-stat space into ls_matrix-userstat_all separated by space.
concatenate ls_matrix-usertxt04_all ls_mix-txt04 space into ls_matrix-usertxt04_all separated by space.
endif.
endloop.
endcase.
modify cht_matrix from ls_matrix index lv_xndx.
endloop.
endform. "f_matrix
*&---------------------------------------------------------------------*
*& Form f_export_mix
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PRT_MIX text
* <--CHT_ALL text
*----------------------------------------------------------------------*
form f_export_mix using prt_mix type tty_mixj
changing cht_all type ztr_t_status_all.
data: ls_mix like line of prt_mix.
data: ls_all like line of cht_all.
loop at prt_mix into ls_mix.
clear ls_all.
move-corresponding ls_mix to ls_all.
append ls_all to cht_all.
endloop.
endform. "f_export_mix
*&---------------------------------------------------------------------*
*& Form f_get_userstat_desc
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PRM_LANGU text
* <--CHT_MIX text
*----------------------------------------------------------------------*
form f_get_userstat_desc using prm_langu type sylangu
changing cht_mix type tty_mixj.
data: ls_mix like line of cht_mix.
data: lt_find type tty_userstat.
data: lt_search type tty_userstat.
data: ls_userstat type ty_userstat.
data: lv_xndx type int4.
loop at cht_mix into ls_mix.
clear ls_userstat.
ls_userstat-stsma = ls_mix-stsma.
ls_userstat-estat = ls_mix-stat.
insert ls_userstat into table lt_search.
endloop.
check lt_search[] is not initial.
select tj30~stsma
tj30~estat
tj30~inist
tj30~stonr
tj30~hsonr
tj30~nsonr
tj30~linep
tj30~statp
tj30~bersl
tj30~crm_vrgng
tj30t~txt04
tj30t~txt30
into table lt_find
from tj30
left join tj30t on tj30t~stsma = tj30~stsma
and tj30t~estat = tj30~estat
and tj30t~spras = prm_langu
for all entries in lt_search
where tj30~stsma = lt_search-stsma
and tj30~estat = lt_search-estat.
loop at cht_mix into ls_mix.
lv_xndx = sy-tabix.
clear ls_userstat.
read table lt_find into ls_userstat with table key stsma = ls_mix-stsma
estat = ls_mix-stat.
if sy-subrc eq 0.
ls_mix-txt04 = ls_userstat-txt04 .
ls_mix-txt30 = ls_userstat-txt30 .
ls_mix-stonr = ls_userstat-stonr .
ls_mix-linep = ls_userstat-linep .
ls_mix-statp = ls_userstat-statp .
endif.
modify cht_mix from ls_mix index lv_xndx transporting txt04 txt30 stonr linep statp.
endloop.
endform. "f_get_userstat_desc
*&---------------------------------------------------------------------*
*& Form f_get_systemstat_desc
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PRM_LANGU text
* <--CHT_MIX text
*----------------------------------------------------------------------*
form f_get_systemstat_desc using prm_langu type sylangu
changing cht_mix type tty_mixj.
data: ls_mix like line of cht_mix.
data: lt_find type tty_systemstat.
data: lt_search type tty_systemstat.
data: ls_sysstat type ty_systemstat.
data: lv_xndx type int4.
data: lt_tj04_search type sorted table of tj04 with unique key obtyp istat.
data: lt_tj04_find type sorted table of tj04 with unique key obtyp istat.
data: ls_tj04 type tj04 .
loop at cht_mix into ls_mix.
clear ls_sysstat.
ls_sysstat-istat = ls_mix-stat.
insert ls_sysstat into table lt_search.
clear ls_tj04 .
ls_tj04-obtyp = ls_mix-obtyp.
ls_tj04-istat = ls_mix-stat.
insert ls_tj04 into table lt_tj04_search.
endloop.
check lt_search[] is not initial.
select tj02~istat
tj02~nodis
tj02~setonly
tj02t~txt04
tj02t~txt30
into table lt_find
from tj02
left join tj02t on tj02t~istat = tj02~istat
and tj02t~spras = prm_langu
for all entries in lt_search
where tj02~istat = lt_search-istat.
if lt_tj04_search[] is not initial.
select *
into table lt_tj04_find
from tj04
for all entries in lt_tj04_search
where tj04~obtyp = lt_tj04_search-obtyp
and tj04~istat = lt_tj04_search-istat.
endif.
loop at cht_mix into ls_mix.
lv_xndx = sy-tabix.
clear ls_sysstat.
read table lt_find into ls_sysstat with table key istat = ls_mix-stat.
if sy-subrc eq 0.
ls_mix-txt04 = ls_sysstat-txt04 .
ls_mix-txt30 = ls_sysstat-txt30 .
endif.
clear ls_tj04.
read table lt_tj04_find into ls_tj04 with table key obtyp = ls_mix-obtyp
istat = ls_mix-stat.
if sy-subrc eq 0.
ls_mix-LINEP = ls_tj04-LINEP .
ls_mix-STATP = ls_tj04-STATP .
endif.
modify cht_mix from ls_mix index lv_xndx transporting txt04 txt30 LINEP STATP.
endloop.
endform. "f_get_systemstat_desc
function ztr_read_status.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(I_OBJNR) TYPE J_OBJNR OPTIONAL
*" VALUE(IT_OBJNR) TYPE ZQMIZ_T_OBJNR OPTIONAL
*" VALUE(I_ACTIVE) TYPE ZTR_E_ACTIVE DEFAULT `X`
*" VALUE(I_INACTIVE) TYPE ZTR_E_INACTIVE DEFAULT SPACE
*" VALUE(I_LANGU) TYPE SY-LANGU DEFAULT SY-LANGU
*" VALUE(I_USERSTAT) TYPE ZTR_E_USERSTAT_X DEFAULT `X`
*" VALUE(I_SYSTEMSTAT) TYPE ZTR_E_SYSTEMSTAT_X DEFAULT `X`
*" VALUE(I_MATRIX) TYPE C DEFAULT `X`
*" EXPORTING
*" VALUE(ET_STATUS_ALL) TYPE ZTR_T_STATUS_ALL
*" VALUE(ET_STATUS_OBJECT) TYPE ZTR_T_STATUS_OBJ
*"----------------------------------------------------------------------
data : lt_object type zqmiz_t_objnr.
data : ls_object type zqmiz_s_objnr.
data : lt_jsto type sorted table of jsto with unique key objnr.
data : lt_jest type sorted table of jest with unique key objnr stat.
data : ls_jsto type jsto .
data : ls_jest type jest .
data: lt_jsto_jest_ext type tty_mixj.
data: lt_jsto_jest_int type tty_mixj.
data: ls_jsto_jest type ty_mixj.
data: ls_matrix type ty_matrix.
data: lt_matrix type tty_matrix.
refresh et_status_all.
refresh et_status_object.
ranges: lr_inact for jest-inact.
lt_object[] = it_objnr[].
if i_objnr is not initial.
ls_object-objnr = i_objnr .
insert ls_object into table lt_object.
endif.
delete adjacent duplicates from lt_object comparing all fields.
check lt_object[] is not initial.
check i_active = `X` or i_inactive = `X`.
if i_active = `X`.
lr_inact-sign = `I`. lr_inact-option = `EQ`. lr_inact-low = space. append lr_inact.
endif.
if i_inactive = `X`.
lr_inact-sign = `I`. lr_inact-option = `EQ`. lr_inact-low = `X`. append lr_inact.
endif.
if i_active = `X` and i_inactive = `X`.
refresh lr_inact.
endif.
select * into table lt_jsto from jsto
for all entries in lt_object
where objnr = lt_object-objnr.
check lt_jsto[] is not initial.
select * into table lt_jest from jest
for all entries in lt_object
where objnr = lt_object-objnr
and inact in lr_inact.
loop at lt_jsto into ls_jsto.
clear ls_jsto_jest.
ls_jsto_jest-objnr = ls_jsto-objnr.
ls_jsto_jest-obtyp = ls_jsto-obtyp.
ls_jsto_jest-stsma = ls_jsto-stsma.
ls_jsto_jest-chgkz = ls_jsto-chgkz.
ls_jsto_jest-chgnr_jsto = ls_jsto-chgnr.
loop at lt_jest into ls_jest where objnr = ls_jsto-objnr.
ls_jsto_jest-stat = ls_jest-stat.
ls_jsto_jest-inact = ls_jest-inact.
ls_jsto_jest-chgnr_jest = ls_jest-chgnr.
ls_jsto_jest-sttype = ls_jest-stat.
case ls_jsto_jest-sttype.
when intern.
check i_systemstat = `X`.
insert ls_jsto_jest into table lt_jsto_jest_int.
when extern.
check i_userstat = `X`.
insert ls_jsto_jest into table lt_jsto_jest_ext.
endcase.
ls_matrix-objnr = ls_jsto_jest-objnr .
ls_matrix-stsma = ls_jsto_jest-stsma .
insert ls_matrix into table lt_matrix.
endloop.
endloop.
if lt_jsto_jest_ext[] is not initial.
perform f_get_userstat_desc using i_langu
changing lt_jsto_jest_ext .
endif.
if lt_jsto_jest_int[] is not initial.
perform f_get_systemstat_desc using i_langu
changing lt_jsto_jest_int .
endif.
perform f_export_mix using lt_jsto_jest_ext changing et_status_all .
perform f_export_mix using lt_jsto_jest_int changing et_status_all .
if i_matrix = `X`.
perform f_matrix using intern
lt_jsto_jest_int
changing lt_matrix .
perform f_matrix using extern
lt_jsto_jest_ext
changing lt_matrix .
et_status_object[] = lt_matrix[].
endif.
endfunction.
Örnek Çıktı: