1、在程序里包含SLIS
type-pools: slis.
2、声明主表和明细表
* Global structure of list
types: begin of t_table,
tabname like dd03l-tabname,
ddtext like dd02t-ddtext,
as4user like dd02l-as4user,
end of t_table.
types: begin of ud_struct,
position like dd03l-position,
tabname like dd03l-tabname,
fieldname like dd03l-fieldname,
ddtext like dd03t-ddtext,
keyflag like dd03l-keyflag,
rollname like dd03l-rollname,
domname like dd03l-domname,
datatype like dd03l-datatype,
ddleng like dd03l-leng,
checktable like dd03l-checktable,
decimals like dd03l-decimals,
eddtext like dd03t-ddtext,
dddtext like dd03t-ddtext,
end of ud_struct.
data: gt_outtabt type t_table occurs 0 with header line.
data: gt_outtabf type ud_struct occurs 0 with header line.
3、申明主表和明细表的名称变量
g_tabname_header type slis_tabname,
g_tabname_item type slis_tabname.
4、声明主表和明细表连接关键字变量
data: gs_keyinfo type slis_keyinfo_alv
5 、设置输出格式
6、具体完整样例
*&---------------------------------------------------------------------
*& Report ZGETTABLEFIELD *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
report zgettablefield .
* Data declaration
type-pools: slis.
* Global structure of list
types: begin of t_table,
tabname like dd03l-tabname,
ddtext like dd02t-ddtext,
as4user like dd02l-as4user,
end of t_table.
types: begin of ud_struct,
position like dd03l-position,
tabname like dd03l-tabname,
fieldname like dd03l-fieldname,
ddtext like dd03t-ddtext,
keyflag like dd03l-keyflag,
rollname like dd03l-rollname,
domname like dd03l-domname,
datatype like dd03l-datatype,
ddleng like dd03l-leng,
checktable like dd03l-checktable,
decimals like dd03l-decimals,
eddtext like dd03t-ddtext,
dddtext like dd03t-ddtext,
end of ud_struct.
tables: dd03l,dd02l.
data: gt_fieldcat type slis_t_fieldcat_alv.
data: gt_outtabt type t_table occurs 0 with header line.
data: gt_outtabf type ud_struct occurs 0 with header line.
data: gs_keyinfo type slis_keyinfo_alv,
g_tabname_header type slis_tabname,
g_tabname_item type slis_tabname.
data: g_repid like sy-repid.
data : begin of exclude occurs 5,
fcode like sy-ucomm,
end of exclude.
data p_ucomm like sy-ucomm.
select-options s_tname for dd02l-tabname default 'VBAK'.
*======================================================================*
* Initialization fieldcatalog
*======================================================================*
initialization.
g_repid = sy-repid.
g_tabname_header = 'GT_OUTTABT'.
g_tabname_item = 'GT_OUTTABF'.
* define keyinfo
clear gs_keyinfo.
gs_keyinfo-header01 = 'TABNAME'.
gs_keyinfo-item01 = 'TABNAME'.
gs_keyinfo-header02 = space.
gs_keyinfo-item02 = 'POSITION'.
*======================================================================*
* Ereignis : AT SELECTION-SCREEN OUTPUT (PBO-Zeitpunkt) *
*======================================================================*
at selection-screen output.
data exclude like rsexfcode occurs 0 with header line.
if sy-dynnr = 1000.
call function 'RS_SET_SELSCREEN_STATUS'
exporting
p_status = 'ZGETTBFD'
tables
p_exclude = exclude
exceptions
others = 1.
endif.
p_ucomm = space.
*======================================================================*
* Ereignis : AT SELECTION-SCREEN (PAI-Zeitpunkt) *
* letztes PAI-Ereignis *
*======================================================================*
at selection-screen.
p_ucomm = sy-ucomm.
case p_ucomm.
when 'STBL'.
set parameter id 'DTB' field s_tname.
* PERFORM AUTHORITY_CHECK USING 'SE11' .
call transaction 'SE11' and skip first screen.
endcase.
*======================================================================*
* Data selection
*======================================================================*
start-of-selection.
perform select_table tables gt_outtabt.
perform select_field tables gt_outtabf.
*======================================================================*
* Display list
*======================================================================*
end-of-selection.
perform fieldcat_init using gt_fieldcat[].
* CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
* EXPORTING
* i_callback_program = g_repid
* it_fieldcat = gt_fieldcat[]
* TABLES
* t_outtab = gt_outtabf.
call function 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
exporting
i_callback_program = g_repid
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* is_layout = gs_layout
it_fieldcat = gt_fieldcat[]
* IT_EXCLUDING =
* it_special_groups = gt_sp_group[]
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* i_default = g_default
* i_save = g_save
* is_variant = g_variant
* it_events = gt_events[]
* IT_EVENT_EXIT =
i_tabname_header = g_tabname_header
i_tabname_item = g_tabname_item
is_keyinfo = gs_keyinfo
* IS_PRINT =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
tables
t_outtab_header = gt_outtabt
t_outtab_item = gt_outtabf.
************************************************************************
* Form Name : fieldcat_init
* Created by : DEV01
* Created on :
* Form Description:
* Set field's output layout
*----------------------------------------------------------------------*
*parameter description
*----------------------------------------------------------------------*
* <--- rt_fieldcat: return field's information
*----------------------------------------------------------------------*
* Modification Log:
* Date Programmer Description
*----------------------------------------------------------------------*
************************************************************************
form fieldcat_init
using rt_fieldcat type slis_t_fieldcat_alv.
data: ls_fieldcat type slis_fieldcat_alv.
data: pos type i value 1.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'TABNAME'.
ls_fieldcat-tabname = g_tabname_header.
ls_fieldcat-ref_fieldname = 'TABNAME'.
ls_fieldcat-ref_tabname = 'DD03T'.
ls_fieldcat-key = 'X'.
append ls_fieldcat to rt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'DDTEXT'.
ls_fieldcat-tabname = g_tabname_header.
ls_fieldcat-ref_fieldname = 'DDTEXT'.
ls_fieldcat-ref_tabname = 'DD02T'.
ls_fieldcat-key = 'X'.
append ls_fieldcat to rt_fieldcat.
* ls_fieldcat-fieldname = 'TABNAME'.
* ls_fieldcat-tabname = g_tabname_item.
* ls_fieldcat-ref_fieldname = 'TABNAME'.
* ls_fieldcat-ref_tabname = 'DD03T'.
* LS_FIELDCAT-KEY = 'X'.
* APPEND ls_fieldcat TO rt_fieldcat.
* CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'POSITION'.
ls_fieldcat-tabname = g_tabname_item.
ls_fieldcat-ref_fieldname = 'POSITION'.
ls_fieldcat-ref_tabname = 'DD03L'.
ls_fieldcat-key = 'X'.
append ls_fieldcat to rt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'FIELDNAME'.
ls_fieldcat-tabname = g_tabname_item.
ls_fieldcat-ref_fieldname = 'FIELDNAME'.
ls_fieldcat-ref_tabname = 'DD03T'.
append ls_fieldcat to rt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'DDTEXT'.
ls_fieldcat-tabname = g_tabname_item.
ls_fieldcat-ref_fieldname = 'DDTEXT'.
ls_fieldcat-ref_tabname = 'DD03T'.
* LS_FIELDCAT-NO_OUT = 'X'.
append ls_fieldcat to rt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'KEYFLAG'.
ls_fieldcat-tabname = g_tabname_item.
ls_fieldcat-ref_fieldname = 'KEYFLAG'.
ls_fieldcat-ref_tabname = 'DD03L'.
* LS_FIELDCAT-NO_OUT = 'X'.
append ls_fieldcat to rt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'DATATYPE'.
ls_fieldcat-tabname = g_tabname_item.
ls_fieldcat-ref_fieldname = 'DATATYPE'.
ls_fieldcat-ref_tabname = 'DD03T'.
append ls_fieldcat to rt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'DDLENG'.
ls_fieldcat-tabname = g_tabname_item.
ls_fieldcat-ref_fieldname = 'LENG'.
ls_fieldcat-ref_tabname = 'DD03L'.
append ls_fieldcat to rt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'DECIMALS'.
ls_fieldcat-tabname = g_tabname_item.
ls_fieldcat-ref_fieldname = 'DECIMALS'.
ls_fieldcat-ref_tabname = 'DD03L'.
append ls_fieldcat to rt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'CHECKTABLE'.
ls_fieldcat-tabname = g_tabname_item.
ls_fieldcat-ref_fieldname = 'CHECKTABLE'.
ls_fieldcat-ref_tabname = 'DD03L'.
append ls_fieldcat to rt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'ROLLNAME'.
ls_fieldcat-tabname = g_tabname_item.
ls_fieldcat-ref_fieldname = 'ROLLNAME'.
ls_fieldcat-ref_tabname = 'DD03L'.
append ls_fieldcat to rt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'DOMNAME'.
ls_fieldcat-tabname = g_tabname_item.
ls_fieldcat-ref_fieldname = 'DOMNAME'.
ls_fieldcat-ref_tabname = 'DD03L'.
* LS_FIELDCAT-NO_OUT = 'X'.
append ls_fieldcat to rt_fieldcat.
endform. "fieldcat_init
************************************************************************
* Form Name : select_table
* Created by : DEV01
* Created on :
* Form Description:
* Get Table's information
*----------------------------------------------------------------------*
*parameter description
*----------------------------------------------------------------------*
* <---rt_outtab: return field's information
*----------------------------------------------------------------------*
* Modification Log:
* Date Programmer Description
*----------------------------------------------------------------------*
************************************************************************
form select_table tables rt_outtab like gt_outtabt[].
select dd02l~tabname dd02t~ddtext dd02l~as4user
into (rt_outtab-tabname,rt_outtab-ddtext,rt_outtab-as4user)
from dd02l left join dd02t
on dd02l~tabname = dd02t~tabname
and dd02l~as4local = dd02t~as4local
and dd02l~as4vers = dd02t~as4vers
and dd02t~ddlanguage = sy-langu
where dd02l~tabname in s_tname
and dd02l~as4local = 'A'
order by dd02l~tabname.
append rt_outtab.
endselect.
endform. "SELECT_DATA
************************************************************************
* Form Name : select_field
* Created by : DEV01
* Created on :
* Form Description:
* Get Table field's information
*----------------------------------------------------------------------*
*parameter description
*----------------------------------------------------------------------*
* <---rt_outtab: return field's information
*----------------------------------------------------------------------*
* Modification Log:
* Date Programmer Description
*----------------------------------------------------------------------*
************************************************************************
form select_field tables
rt_outtab like gt_outtabf[].
select dd03l~position dd03l~tabname
dd03l~fieldname
dd03t~ddtext
dd03l~keyflag
dd03l~rollname
dd03l~domname
dd03l~datatype
dd03l~leng
dd03l~checktable dd03l~decimals
dd04t~ddtext dd01t~ddtext
into (rt_outtab-position, rt_outtab-tabname,
rt_outtab-fieldname, rt_outtab-ddtext,
rt_outtab-keyflag,rt_outtab-rollname,
rt_outtab-domname,rt_outtab-datatype,
rt_outtab-ddleng,rt_outtab-checktable,
rt_outtab-decimals,
rt_outtab-eddtext,rt_outtab-dddtext)
from dd03l left join dd03t
on dd03l~tabname = dd03t~tabname
and dd03l~fieldname = dd03t~fieldname
and dd03t~ddlanguage = sy-langu
left join dd04t
on dd03l~rollname = dd04t~rollname
and dd04t~ddlanguage = sy-langu
left join dd01t
on dd03l~domname = dd01t~domname
and dd01t~ddlanguage = sy-langu
where dd03l~tabname in s_tname
order by dd03l~tabname dd03l~position.
if rt_outtab-ddtext = space.
if rt_outtab-eddtext = space.
rt_outtab-ddtext = rt_outtab-dddtext.
else.
rt_outtab-ddtext = rt_outtab-eddtext.
endif.
endif.
append rt_outtab.
endselect.
endform. "SELECT_DATA
*&---------------------------------------------------------------------*
*& Form FUNCTION_EXCLUDE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_EXCLUDE text *
*----------------------------------------------------------------------*
form function_exclude tables p_exclude structure exclude.
* data : rcode like sy-subrc.
* clear p_exclude.
* refresh p_exclude.
* exclude-fcode = 'EERW'.
* append exclude.
* exclude-fcode = 'EXIT'.
* append exclude.
endform. " FUNCTION_EXCLUDE
******************************************************************MI12
REPORT RM07IMAT MESSAGE-ID M7 NO STANDARD PAGE HEADING LINE-SIZE 132.
*-----------------------------------------------------------"n513843
* MI21 : wild card selection of WBS element possible "n513843
* error fixed reported by the extended progam check "n513843
*-----------------------------------------------------------"n400792
* selection of WBS element improved "n400792
*----------------------------------------------------------------------*
* selection for PI-documents of special stock improved "n0377071
*----------------------------------------------------------------------*
* For the selection of inventory documents who belong to "ALRK230033
* special stocks without storage location number the "ALRK230033
* select-option table IM_LGORT will be extended with an "ALRK230033
* entry comprising space "ALRK230033
*----------------------------------------------------------------------*
* Handhabung Selektionsbild verbessert 06.05.1999 XJD
* - Der ALV wird auch aufgerufen, wenn keine Daten vorliegen
* - die Routine
* - die Routine ANFORDERUNGSBILD wird nicht mehr aufgerufen
* - Fehlermeldungen nur in Zeitpunkt AT SELECTION-SCREEN
* - SELECT ... FOR ALL ENTRIES TTTT nur, wenn Daten in TTTT vorliegen
*----------------------------------------------------------------------*
* Buchungsperiode von MM.JJJJ nach JJJJ.MM ge鋘dert XJD 22.01.1999
*----------------------------------------------------------------------*
* - ohne log. Datenbank IM/M
* - neue Selektion nach Beleg- und Positions-Stati mit Pushbutton
* und versteckten Parametern
* - die Funktion "Aendern Inventurbeleg" enfaellt
*
* - Nur noch 2. Stati :
* STANDARD fuer die Hauptliste
* Wie wird der Report aufgerufen ? moegliche Funktionen
* direkt SUMM, AUSW, AUSR
* von anderen Programm SUMM, AUSW, AURS, UEBN
*
* SUMM fuer Verzeigungsliste
*
* - Umgestellt auf ALV :
* es gibt jetzt die beiden Listen :
* - Hierseq. Liste mit allen selektierten Materialien
* - Verzweigungsliste mit den Summen pro Material und Lagerorten
*
* - Gruppenwechsel Material wird jezt im ALV eingestellt,
* und zwar ueber die Buttons fuer Sortieren
* GW=* default Anzeige : ein Block pro Material
* Druck : eine Seite pro Material
* GW=UL alle Materialien in einem fortlaufenden Block
*----------------------------------------------------------------------*
*
*---- Datendefinition -------------------------------------------------*
*--- Externe Tabellen -------------------------------------------------*
TABLES: DM07I,
ISEG, "Inv.- Belegpositionen
prps, "WBS element in long format "n400792
RM07I,
VM07I,
TM07I,
T148T,
T159L,
T320,
T001L,
SSCRFIELDS. "fuer Pushbutton auf Selektionsbild
*--- Datenfelder fuer ALV ---------------------------------------------
TYPE-POOLS: SLIS.
DATA: GS_LAYOUT_1 TYPE SLIS_LAYOUT_ALV,
GS_LAYOUT_2 TYPE SLIS_LAYOUT_ALV,
GS_KEYINFO TYPE SLIS_KEYINFO_ALV,
G_EXIT_CAUSED_BY_CALLER,
GS_EXIT_CAUSED_BY_USER TYPE SLIS_EXIT_BY_USER,
G_REPID LIKE SY-REPID.
* INTERNE TABELLEN FUER FELDKATALOGE
DATA: FIELDCAT TYPE SLIS_FIELDCAT_ALV OCCURS 0 WITH HEADER LINE,
FIELDCAT_2 TYPE SLIS_FIELDCAT_ALV OCCURS 0 WITH HEADER LINE,
FIELDCAT_3 TYPE SLIS_FIELDCAT_ALV OCCURS 0 WITH HEADER LINE.
* TABELLEN FUER ZUORDNUNG EVENTS - FORM-ROUTINEN
DATA : T_EVENTS_1 TYPE SLIS_ALV_EVENT OCCURS 0 WITH HEADER LINE,
T_EVENTS_2 TYPE SLIS_ALV_EVENT OCCURS 0 WITH HEADER LINE.
* Tabellen fuer Sort
DATA : T_SORT_1 TYPE SLIS_SORTINFO_ALV OCCURS 0 WITH HEADER LINE,
T_SORT_2 TYPE SLIS_SORTINFO_ALV OCCURS 0 WITH HEADER LINE.
* Tabellen mit dem Listenkopftext
DATA : T_UEB_1 TYPE SLIS_LISTHEADER OCCURS 0 WITH HEADER LINE,
T_UEB_2 TYPE SLIS_LISTHEADER OCCURS 0 WITH HEADER LINE,
T_UEB_3 TYPE SLIS_LISTHEADER OCCURS 0 WITH HEADER LINE.
* DRUCKPARAMETER
DATA: IS_PRINT TYPE SLIS_PRINT_ALV.
* Anzeigevarianten
DATA: GX_VARIANT LIKE DISVARIANT,
G_VARIANT LIKE DISVARIANT,
G_EXIT(1) TYPE C,
G_SAVE(1) TYPE C,
G_DEFAULT(1) TYPE C.
* Tabellen fuer das Einlesen der Beleg-Koepfe
DATA: BEGIN OF XIKPF OCCURS 1.
INCLUDE STRUCTURE IKPF.
DATA: END OF XIKPF.
*--- Variablen --------------------------------------------------------
DATA: DIFMG LIKE VM07I-DIFMG,
DIFVW LIKE VM07I-DIFVW,
H_BWKEY LIKE T001W-BWKEY,
IBLNR LIKE ISEG-IBLNR,
INDEX_Z LIKE SY-TABIX,
XTABIX LIKE SY-TABIX,
XTAB LIKE SY-TABIX,
XKZWM LIKE DM07I-KZWMD, " Beleg aus LVS
MELDUNG LIKE AM07M-XSELK.
DATA: X_MATNR LIKE ISEG-MATNR,
Y_MATNR LIKE ISEG-MATNR,
X_KWART LIKE ISEG-KWART,
INVFLAG(1) TYPE C,
X_GJAHR LIKE ISEG-GJAHR,
Y_GJAHR LIKE ISEG-GJAHR,
X_COUNT LIKE ISEG-ZEILI,
X_IBLNR LIKE ISEG-IBLNR,
X_MEINS LIKE ISEG-MEINS,
X_PFKEY TYPE C,
ALT-WERKS LIKE ISEG-WERKS,
ALT-LGORT LIKE ISEG-LGORT,
ALT-SOBKZ LIKE ISEG-SOBKZ,
ALT-MATNR LIKE ISEG-MATNR,
OLD-MATNR LIKE ISEG-MATNR.
* Pfaffp: begin - Kein Abbruch bei gel鰏chtem Werk
DATA: DELORG(1) TYPE C,
DELWERK LIKE ISEG-WERKS.
* end
*--- Strukturen der Inventurbelegpositionen ---------------------------*
DATA: BEGIN OF PERBU,
GJAHR LIKE IKPF-GJAHR,
POINT TYPE C,
MONAT LIKE IKPF-MONAT,
END OF PERBU.
DATA: BEGIN OF IKPF_KEY,
MANDT LIKE SY-MANDT,
IBLNR LIKE IKPF-IBLNR,
GJAHR LIKE IKPF-GJAHR,
END OF IKPF_KEY.
DATA: BEGIN OF GRU_ALT_BELEG,
MANDT LIKE SY-MANDT,
IBLNR LIKE IKPF-IBLNR,
GJAHR LIKE IKPF-GJAHR,
END OF GRU_ALT_BELEG.
DATA: BEGIN OF MAKT_KEY,
MANDT LIKE SY-MANDT,
MATNR LIKE MAKT-MATNR,
END OF MAKT_KEY.
DATA: BEGIN OF BUPE1,
GJAHR LIKE IKPF-GJAHR,
MONAT LIKE IKPF-MONAT,
END OF BUPE1.
*--- Interne Tabelle f黵 Inventurpositionsdaten ----------------------*
DATA: BEGIN OF PRE_IKPF OCCURS 0, "Zum Nachlesen Beleg-Kopf-Segmente
MANDT LIKE SY-MANDT,
IBLNR LIKE IKPF-IBLNR,
GJAHR LIKE IKPF-GJAHR,
END OF PRE_IKPF.
DATA: BEGIN OF IISEG OCCURS 30.
INCLUDE STRUCTURE ISEG.
DATA: END OF IISEG.
DATA: BEGIN OF XISEG OCCURS 30.
INCLUDE STRUCTURE ISEG.
DATA: END OF XISEG.
DATA: BEGIN OF XISEG1 OCCURS 30.
INCLUDE STRUCTURE ISEG.
DATA: END OF XISEG1.
*--- Interne Tabelle f黵 Bereichssummen ----------------------*
DATA: BEGIN OF STAB OCCURS 10,
COUNT LIKE ISEG-ZEILI,
MATNR LIKE ISEG-MATNR,
WERKS LIKE ISEG-WERKS,
LGORT LIKE ISEG-LGORT,
GJAHR LIKE ISEG-GJAHR,
DMBTR LIKE ISEG-DMBTR,
VDMBT LIKE ISEG-DMBTR,
VDIFM LIKE VM07I-DIFMG,
DIFMG LIKE VM07I-DIFMG,
WAERS LIKE ISEG-WAERS,
MEINS LIKE ISEG-MEINS,
DIFVW LIKE VM07I-DIFVW,
VDIFV LIKE VM07I-DIFVW,
KWART LIKE ISEG-KWART,
SOBKZ LIKE ISEG-SOBKZ,
MESSAGE(03) TYPE C,
END OF STAB.
*--- Interne Tabelle f黵 Bereichssummen ----------------------*
DATA: BEGIN OF STAB1 OCCURS 10,
COUNT LIKE ISEG-ZEILI,
MATNR LIKE ISEG-MATNR,
WERKS LIKE ISEG-WERKS,
LGORT LIKE ISEG-LGORT,
GJAHR LIKE ISEG-GJAHR,
DMBTR LIKE ISEG-DMBTR,
DIFMG LIKE VM07I-DIFMG,
WAERS LIKE ISEG-WAERS,
MEINS LIKE ISEG-MEINS,
DIFVW LIKE VM07I-DIFVW,
KWART LIKE ISEG-KWART,
SOBKZ LIKE ISEG-SOBKZ,
MESSAGE(03) TYPE C,
END OF STAB1.
*--- Interne Tabelle f黵 Bereichssummen ----------------------*
DATA: BEGIN OF STAB2 OCCURS 10,
COUNT LIKE ISEG-ZEILI,
MATNR LIKE ISEG-MATNR,
WERKS LIKE ISEG-WERKS,
LGORT LIKE ISEG-LGORT,
GJAHR LIKE ISEG-GJAHR,
VDMBT LIKE ISEG-DMBTR,
VDIFM LIKE VM07I-DIFMG,
WAERS LIKE ISEG-WAERS,
MEINS LIKE ISEG-MEINS,
VDIFV LIKE VM07I-DIFVW,
KWART LIKE ISEG-KWART,
SOBKZ LIKE ISEG-SOBKZ,
MESSAGE(03) TYPE C,
END OF STAB2.
* diese Tabelle enthaelt die Daten zu einem Material. Sie wird dem
* ALV zum Drucken zugewiesen
* Achtung : der Aufbau weicht vom Aufbau STAB ab !
* Mengen und Werte des Vorjahres werden jeweils in einem Feld
* dargestellt. Duch das GJAHR wird die Sache eindeutig
DATA : BEGIN OF STAB3 OCCURS 10,
SOBKZ LIKE ISEG-SOBKZ,
SOTXT LIKE T148T-SOTXT,
MATNR LIKE ISEG-MATNR,
GJAHR LIKE ISEG-GJAHR,
WERKS LIKE ISEG-WERKS,
LGORT LIKE ISEG-LGORT,
WERT LIKE ISEG-DMBTR,
WAERS LIKE ISEG-WAERS,
MENGE LIKE VM07I-DIFMG,
MEINS LIKE ISEG-MEINS,
PREIS LIKE VM07I-DIFVW,
END OF STAB3.
DATA: BEGIN OF XMSEG OCCURS 1.
INCLUDE STRUCTURE MSEG.
DATA: END OF XMSEG.
*---- Include-Reports -------------------------------------------------*
INCLUDE: MM07MABC,
RM07GRID,
RM07MAUT,
RM07MSQL,
RM07MUSR,
RM07MEND.
* Diese Tabelle wird mit dem ALV gedruckt
DATA : BEGIN OF YISEG1 OCCURS 100.
INCLUDE STRUCTURE YISEG.
DATA : PERBU(07) TYPE C, "Buchungsperiode
DSTAT_TEXT(15) TYPE C, "Text zum Belegstatus
FARBE(03) TYPE C.
DATA : END OF YISEG1.
* Arbeitstabelle
DATA : BEGIN OF YISEG2 OCCURS 100.
INCLUDE STRUCTURE YISEG.
DATA : PERBU(07) TYPE C, "Buchungsperiode
DSTAT_TEXT(15) TYPE C, "Text zum Belegstatus
FARBE(03) TYPE C.
DATA : END OF YISEG2.
* fuer Gruppenwechsel zum Aufbau der Tabellen YISEG1 und T2
DATA : GRU_ALT_IBLNR LIKE ISEG-IBLNR,
BEGIN OF GRU_ALT_YISEG,
MATNR LIKE ISEG-MATNR,
MAKTX LIKE MAKT-MAKTX,
WERKS LIKE ISEG-WERKS,
LGORT LIKE ISEG-LGORT,
SOBKZ LIKE ISEG-SOBKZ,
END OF GRU_ALT_YISEG,
BEGIN OF GRU_NEU_YISEG,
MATNR LIKE ISEG-MATNR,
MAKTX LIKE MAKT-MAKTX,
WERKS LIKE ISEG-WERKS,
LGORT LIKE ISEG-LGORT,
SOBKZ LIKE ISEG-SOBKZ,
END OF GRU_NEU_YISEG.
* Diese Tabelle enthaelt die Kopf-Daten fuer die hierarch.-seq. Liste
DATA : BEGIN OF T2 OCCURS 100,
MATNR LIKE ISEG-MATNR,
WERKS LIKE ISEG-WERKS,
LGORT LIKE ISEG-LGORT,
SOBKZ LIKE ISEG-SOBKZ,
MAKTX LIKE MAKT-MAKTX,
SOTXT LIKE T148T-SOTXT,
END OF T2.
* Konstanten
CONSTANTS :
c_eq(02) type c value 'EQ', "n0377071
C_SHOW(01) TYPE C VALUE S,
C_HIDE(01) TYPE C VALUE H,
C_T2(06) TYPE C VALUE 'T2',
C_YISEG1(06) TYPE C VALUE 'YISEG1'.
DATA : FLAG_KWART(01) TYPE C,
FLAG_STAB(01) TYPE C,
FLAG_STATUS_OK(01) TYPE C,
BEGIN OF FLAG_STATI,
SELN1(01) TYPE C,
SELT1(01) TYPE C,
SELT2(01) TYPE C,
SELT3(01) TYPE C,
SELT4(01) TYPE C,
SELT5(01) TYPE C,
SELT6(01) TYPE C,
SELV2(01) TYPE C,
SELV3(01) TYPE C,
SELV4(01) TYPE C,
SELV5(01) TYPE C,
SELV6(01) TYPE C,
END OF FLAG_STATI,
flag_sel_sp_stock type c, "n0377071
flag_delete type c, "n0377071
zw_zustand_sob(01) type c value H, "n0377071
zw_DATUM LIKE Sy-DATum,
ZW_TABZEILE LIKE XISEG-ZEILI,
ZW_SEL_TAB_FIELD TYPE SLIS_SEL_TAB_FIELD,
ZW_ZUSTAND(01) TYPE C VALUE H, "HIDE fuer pushbutton
ZW_FARBE(03) TYPE C,
ZW_SAVE_IBLNR LIKE ISEG-IBLNR,
ZW_SAVE_GJAHR LIKE IKPF-GJAHR,
ZW_COUNT LIKE ISEG-ZEILI,
ZW_COUNT_MAX LIKE ISEG-ZEILI,
ZW_MATNR LIKE ISEG-MATNR,
ZW_MESSAGE LIKE T100-MSGNR,
ZW_EXTAB TYPE SLIS_EXTAB,
Z_YISEG TYPE P,
Z_COL_POS TYPE P,
Z_LINES TYPE P.
* ranges tables for the special stocks "n0377071
ranges : "n0377071
ra_sobkz for iseg-sobkz, "n0377071
ra_lifnr for iseg-lifnr, "n0377071
ra_kunnr for iseg-kunnr. "n0377071
* range table for internal format of WBS element "n513843
ranges : ra_pspnr_all for iseg-PS_PSP_PNR, "n513843
ra_pspnr_from_to for iseg-PS_PSP_PNR. "n513843
*EJECT
*---- Select-Options -------------------------------------------------*
* Hauptselektion fuer Material, Belegnummer, Jahr, etc..
SELECTION-SCREEN BEGIN OF BLOCK 1 WITH FRAME
TITLE TEXT-917. "Datenbankabgrenzungen
SELECT-OPTIONS :
IM_MATNR FOR ISEG-MATNR MATCHCODE OBJECT MAT1 MEMORY ID MAT,
IM_WERKS FOR MARC-WERKS MEMORY ID WRK,
IM_LGORT FOR IKPF-LGORT MEMORY ID LAG,
IM_CHARG FOR ISEG-CHARG MEMORY ID CHA,
IM_IBLNR FOR IKPF-IBLNR MEMORY ID IBN,
IM_INVNU FOR IKPF-INVNU MATCHCODE OBJECT INVN.
SELECTION-SCREEN END OF BLOCK 1.
*----------------------------------------------------------------------*
* selection of special stocks "n0377071
SELECTION-SCREEN begin of BLOCK so with frame
title text-918. "special stocks
SELECTION-SCREEN PUSHBUTTON /1(20) PB_SOB USER-COMMAND PSOB.
* user wants to select all existing special stocks ?
parameters : kzlso like rmmmb-kzlso default X
modif id sob.
SELECT-OPTIONS :
* sales order
SO_EEAUF FOR iseg-kdauf MATCHCODE OBJECT VMCF
modif id sob,
* vendor consignment
SO_KKLIF FOR iseg-LIFNR matchcode object kred
modif id sob,
* return transport pack.
SO_MMLIF FOR iseg-LIFNR matchcode object kred
modif id sob,
* stock provided to vendor
SO_OOLIF FOR iseg-LIFNR matchcode object kred
modif id sob,
* project stock ( input in readable from )
* use the long format for the WBS element "n400792
so_qqpnr for prps-posid "n400792
matchcode object prp
modif id sob,
* return pack customer
SO_VVKUN FOR iseg-KUNNR matchcode object debi
modif id sob,
* customer consignment
SO_WWKUN FOR iseg-KUNNR matchcode object debi
modif id sob.
SELECTION-SCREEN END OF BLOCK so.
*----------------------------------------------------------------------*
* 1. Pushbutton mit den Stati, wie einem Pop-Up,
* alle Parameterfelder und Texte werden der MODIF ID SAP zugeordnet
* fuer ein- und ausblenden auf Selektionsbild = aus; Pop-Up = ein
SELECTION-SCREEN BEGIN OF BLOCK 2 WITH FRAME TITLE TEXT-902.
SELECTION-SCREEN PUSHBUTTON /1(20) PARAM USER-COMMAND PARA.
* Unterblock : links -> Beleg : nocht nicht gezaehlt
* mitte -> Beleg : teilweise gezaehlt
* rechts -> Beleg : volstaendig gezaehlt
* Zeile 1 : nur Texte
SELECTION-SCREEN BEGIN OF LINE. "Beleg : teilweise gezaehlt
SELECTION-SCREEN COMMENT 1(24) TEXT-901 MODIF ID SAP.
SELECTION-SCREEN COMMENT 25(26) TEXT-903 MODIF ID SAP.
SELECTION-SCREEN COMMENT 53(27) TEXT-904 MODIF ID SAP.
SELECTION-SCREEN END OF LINE.
* Zeile 2 : links -> noch nicht gezaehlt
* Mitte -> noch nicht gezaehlt
* rechts -> frei
SELECTION-SCREEN BEGIN OF LINE. "Beleg : teilweise gezaehlt
SELECTION-SCREEN POSITION 1.
PARAMETERS :
PA_SELN1 LIKE AM07M-Xipos DEFAULT X MODIF ID SAP.
SELECTION-SCREEN
COMMENT 3(23) TEXT-911 FOR FIELD PA_SELN1 MODIF ID SAP.
SELECTION-SCREEN POSITION 27.
PARAMETERS :
PA_SELT1 LIKE AM07M-Xipos DEFAULT X MODIF ID SAP.
SELECTION-SCREEN
COMMENT 29(24) TEXT-911 FOR FIELD PA_SELT1 MODIF ID SAP.
SELECTION-SCREEN END OF LINE.
* Zeile 3 : links -> frei
* Mitte -> Position ist nur gezaehlt
* rechts -> Position ist nur gezaehlt
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 27.
PARAMETERS :
PA_SELT2 LIKE AM07M-XIPOS DEFAULT X MODIF ID SAP.
SELECTION-SCREEN
COMMENT 29(24) TEXT-912 FOR FIELD PA_SELT2 MODIF ID SAP.
SELECTION-SCREEN POSITION 54.
PARAMETERS :
PA_SELV2 LIKE AM07M-XIPOS DEFAULT X MODIF ID SAP.
SELECTION-SCREEN
COMMENT 56(23) TEXT-912 FOR FIELD PA_SELV2 MODIF ID SAP.
SELECTION-SCREEN END OF LINE.
* Zeile 4 : links -> frei
* Mitte -> Position ist ausgebucht
* rechts -> Position ist ausgebucht
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 27.
PARAMETERS :
PA_SELT3 LIKE AM07M-XIPOS DEFAULT X MODIF ID SAP.
SELECTION-SCREEN
COMMENT 29(24) TEXT-913 FOR FIELD PA_SELT3 MODIF ID SAP.
SELECTION-SCREEN POSITION 54.
PARAMETERS :
PA_SELV3 LIKE AM07M-XIPOS DEFAULT X MODIF ID SAP.
SELECTION-SCREEN
COMMENT 56(23) TEXT-913 FOR FIELD PA_SELV3 MODIF ID SAP.
SELECTION-SCREEN END OF LINE.
* Zeile 5 : links -> frei
* Mitte -> Position ist nachgezaehlt
* rechts -> Position ist nachgezaehlt
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 27.
PARAMETERS :
PA_SELT4 LIKE AM07M-XIPOS DEFAULT X MODIF ID SAP.
SELECTION-SCREEN
COMMENT 29(24) TEXT-914 FOR FIELD PA_SELT4 MODIF ID SAP.
SELECTION-SCREEN POSITION 54.
PARAMETERS :
PA_SELV4 LIKE AM07M-XIPOS DEFAULT X MODIF ID SAP.
SELECTION-SCREEN
COMMENT 56(23) TEXT-914 FOR FIELD PA_SELV4 MODIF ID SAP.
SELECTION-SCREEN END OF LINE.
* Zeile 6 : links -> frei H鋕chen !
* mitte -> Position ist gel鰏cht
* rechts -> Position ist gel鰏cht
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 27.
PARAMETERS :
PA_SELT5 LIKE AM07M-XIPOS DEFAULT X MODIF ID SAP.
SELECTION-SCREEN
COMMENT 29(24) TEXT-915 FOR FIELD PA_SELT5 MODIF ID SAP.
SELECTION-SCREEN POSITION 54.
PARAMETERS :
PA_SELV5 LIKE AM07M-XIPOS DEFAULT X MODIF ID SAP.
SELECTION-SCREEN
COMMENT 56(23) TEXT-915 FOR FIELD PA_SELV5 MODIF ID SAP.
SELECTION-SCREEN END OF LINE.
* Zeile 7 : links -> frei
* mitte -> Position ist gezaehlt und gel鰏cht
* rechts -> Position ist gezaehlt und gel鰏cht
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 27.
PARAMETERS :
PA_SELT6 LIKE AM07M-XIPOS DEFAULT X MODIF ID SAP.
SELECTION-SCREEN
COMMENT 29(24) TEXT-916 FOR FIELD PA_SELT6 MODIF ID SAP.
SELECTION-SCREEN POSITION 54.
PARAMETERS :
PA_SELV6 LIKE AM07M-XIPOS DEFAULT X MODIF ID SAP.
SELECTION-SCREEN
COMMENT 56(23) TEXT-916 FOR FIELD PA_SELV6 MODIF ID SAP.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK 2.
*----------------------------------------------------------------------*
* Selektion nach Datum
SELECTION-SCREEN BEGIN OF BLOCK 3 WITH FRAME TITLE TEXT-905.
SELECT-OPTIONS:
ZLDAT FOR ISEG-ZLDAT,
GIDAT FOR IKPF-GIDAT,
BUCHP FOR RM07I-BUPEV.
SELECTION-SCREEN END OF BLOCK 3.
* Variante
SELECTION-SCREEN BEGIN OF BLOCK 4 WITH FRAME TITLE TEXT-064.
PARAMETERS: PA_VARI LIKE DISVARIANT-VARIANT.
SELECTION-SCREEN END OF BLOCK 4.
*----------------------------------------------------------------------*
*EJECT
*---- Initialisierung -------------------------------------------------*
INITIALIZATION.
* Ermitteln ALV Einstiegs-Variante fuer Vorbesetzung Parameterfeld
* Das Kennzeichen "Einstiegsvariante" muss sitzen
CLEAR G_VARIANT.
MOVE SY-REPID TO G_VARIANT-REPORT.
GX_VARIANT = G_VARIANT.
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
I_SAVE = A
CHANGING
CS_VARIANT = GX_VARIANT
EXCEPTIONS
NOT_FOUND = 2.
IF SY-SUBRC = 0.
PA_VARI = GX_VARIANT-VARIANT.
ENDIF.
* Allow entering wildcards (*) in the field PRPS-POSID for "n513843
* WBS element. This call affects the conversion exit "n513843
* between external and internal representation of POSID "n513843
* (with/without edition mask). "n513843
perform set_wildc(saplcjpn) using 'X'. "n513843
*EJECT
*----------------------------------------------------------------------*
* AT SELECTION-SCREEN
*----------------------------------------------------------------------*
AT SELECTION-SCREEN OUTPUT. "vor den Senden Selektionsbild
* Sollen die Parameter fuer die Stati-Selektion gezeigt werden ?
LOOP AT SCREEN.
* modify the selection screen "n0377071
case SCREEN-GROUP1.
when 'SAP'.
* show or hide selection fields for doc. status
IF ZW_ZUSTAND = C_SHOW.
SCREEN-ACTIVE = EINS.
ELSE.
SCREEN-ACTIVE = NULL.
ENDIF.
MODIFY SCREEN.
when 'SOB'.
* show or hide selection fields for special stocks
IF ZW_ZUSTAND_sob = C_SHOW.
SCREEN-ACTIVE = EINS.
ELSE.
SCREEN-ACTIVE = NULL.
ENDIF.
MODIFY SCREEN.
endcase.
ENDLOOP.
CASE ZW_ZUSTAND. "Zeigen oder Verstecken ?
WHEN C_HIDE.
MOVE TEXT-066 TO PARAM. "@0E/Q@ Statusauswahl
WHEN C_SHOW.
MOVE TEXT-067 TO PARAM. "@0H/Q@ Statusauswahl
WHEN OTHERS.
ENDCASE.
* Pushbutton for special stock selection "n0377071
CASE ZW_ZUSTAND_sob. "show or hide ?
WHEN C_HIDE.
MOVE TEXT-076 TO PB_SOB. "@0E/Q@ Details
WHEN C_SHOW.
MOVE TEXT-077 TO PB_SOB. "@0H/Q@ Details
WHEN OTHERS.
ENDCASE.
*----------------------------------------------------------------------*
AT SELECTION-SCREEN.
* Wurde der Pushbutton betaetigt ? wenn ja, wird die Anzeige der
* Stati-Selektions-Parameter geaendert
* did the user hit one of the pushbuttons ? "n0377071
case SSCRFIELDS-UCOMM.
when 'PARA'.
* the pushbutton for the doc. status was hit
IF ZW_ZUSTAND = C_HIDE.
MOVE C_SHOW TO ZW_ZUSTAND.
ELSE.
MOVE C_HIDE TO ZW_ZUSTAND.
ENDIF.
when 'PSOB'.
* the pushbutton for the special stocks was hit
IF ZW_ZUSTAND_sob = C_HIDE.
MOVE C_SHOW TO ZW_ZUSTAND_sob.
ELSE.
MOVE C_HIDE TO ZW_ZUSTAND_sob.
ENDIF.
ENDcase.
* Warnung, falls keine Datenbankeingrenzung vorgenommen wurde,
* nur beim Anstarten
IF IM_MATNR IS INITIAL AND
IM_WERKS IS INITIAL AND
IM_LGORT IS INITIAL AND
IM_CHARG IS INITIAL AND
IM_IBLNR IS INITIAL AND
IM_INVNU IS INITIAL.
IF SY-UCOMM = 'ONLI' OR
SY-UCOMM = UCOM-PRIN.
MESSAGE W689. "Die Selektion wurde nicht eingeschr鋘kt
ENDIF.
ENDIF.
* Pruefen Selektion nach Beleg- und Positions-Stati
CLEAR FLAG_STATI.
MOVE : PA_SELN1 TO FLAG_STATI-SELN1,
PA_SELT1 TO FLAG_STATI-SELT1,
PA_SELT2 TO FLAG_STATI-SELT2,
PA_SELT3 TO FLAG_STATI-SELT3,
PA_SELT4 TO FLAG_STATI-SELT4,
PA_SELT5 TO FLAG_STATI-SELT5,
PA_SELT6 TO FLAG_STATI-SELT6,
PA_SELV2 TO FLAG_STATI-SELV2,
PA_SELV3 TO FLAG_STATI-SELV3,
PA_SELV4 TO FLAG_STATI-SELV4,
PA_SELV5 TO FLAG_STATI-SELV5,
PA_SELV6 TO FLAG_STATI-SELV6.
IF FLAG_STATI IS INITIAL.
SET CURSOR FIELD 'PA_SELN1'.
MESSAGE E015. "Bitte Eingabe pr黤en
ENDIF.
PERFORM S0200_PAI_OF_SELECTION_SCREEN.
* Pr黤en eingetippe Buchungsperioden
if not buchp is initial.
if not SY-UCOMM = '%067'. "Keine pr黤ung bei Korrektur
LOOP at buchp.
perfORM S9000_CHECK_PERIODE USING buchp-low.
PERFORM S9000_CHECK_PERIODE USING BUCHP-high.
endLOOP.
endif.
ENDIF.
*----------------------------------------------------------------------*
* Process on value request / F4 fuer Eingabehilfe
AT SELECTION-SCREEN ON VALUE-REQUEST FOR PA_VARI.
PERFORM S0000_F4_FOR_VARIANT.
*EJECT
*---- Beginn der Verarbeitung -----------------------------------------*
START-OF-SELECTION.
SET TITLEBAR '100'. "Inventurbelege zum Mateterial anzeigen
CLEAR NO_CHANCE.
* REFRESH IIKPF. "darf hier nicht gel鰏cht werden
* pfaffp: begin: Kein Abbruch bei gel鰏chtem Werk
CLEAR DELORG.
CLEAR DELWERK.
* end
* create ranges for the database selektion
perform s0100_create_ranges. "n0377071
* Mapping of external WBS-element into internal "n513843
* representation. See note 326100 for the possible "n513843
* consequences. "n513843
refresh : ra_pspnr_all, ra_pspnr_from_to. "n513843
"n513843
if not so_qqpnr[] is initial. "n513843
* the user wants to restrict docs using WBS elements "n513843
"n513843
select pspnr as low from prps "n513843
into corresponding fields of table ra_pspnr_all "n513843
where posid in so_qqpnr. "n513843
"n513843
if sy-subrc is initial. "n513843
* complete the range table "n513843
move : I to ra_pspnr_all-sign, "n513843
c_EQ to ra_pspnr_all-option. "n513843
"n513843
modify ra_pspnr_all transporting sign option "n513843
where not low is initial. "n513843
"n513843
* range table ra_pspnr_all could contain thousands of "n513843
* entries. So create a second range table for the rough "n513843
* selection of database ISEG with only one entry to "n513843
* avoid a database error and to restrict the number of "n513843
* matching ISEG entries. Get the first and last "n513843
* internal WBS element for the database selection "n513843
describe table ra_pspnr_all lines z_lines. "n513843
"n513843
if z_lines = 1. "n513843
move ra_pspnr_all[] to ra_pspnr_from_to[]. "n513843
else. "n513843
sort ra_pspnr_all by low. "n513843
read table ra_pspnr_all index 1. "n513843
"n513843
if sy-subrc is initial. "n513843
move ra_pspnr_all-low to ra_pspnr_from_to-low. "n513843
"n513843
read table ra_pspnr_all index z_lines. "n513843
"n513843
if sy-subrc is initial. "n513843
move : ra_pspnr_all-low "n513843
to ra_pspnr_from_to-high, "n513843
I to ra_pspnr_from_to-sign, "n513843
'BT' to ra_pspnr_from_to-option. "n513843
append ra_pspnr_from_to. "n513843
endif. "n513843
endif. "n513843
endif. "n513843
endif. "n513843
endif. "n513843
* Datenselektion : der Einstieg erfolgt je nach den
* Selektionskriterien analog log. DB IM/M
IF IM_MATNR IS INITIAL AND
IM_CHARG IS INITIAL.
PERFORM S6000_EINSTIEG_KOEPFE.
ELSE.
PERFORM S6100_EINSTIEG_POSITIONEN.
ENDIF.
* Die Daten sind gelesen und stehen in den Tabellen zur Verfuegung:
* XIKPF - Koepfe
* IISEG - Positionen
* die Tabelle mit allen Positionen IISEG wird verarbeitet :
* - Die Daten werden pro Belegnummer gesammelt
* - beim Wechsel der Belegnummer wird der Beleg-Kopf nachgelesen,
* - dann wird die Status-Pr黤ung durchgef黨rt
* check for correct selection of special stocks
if flag_sel_sp_stock = X. "n0377071
perform s0200_check_special_stocks.
endif.
LOOP AT IISEG.
* Sammeln Materialnummern fuer Nachlesen Kurztexte
MOVE IISEG-MATNR TO XMATN.
APPEND XMATN.
IF GRU_ALT_BELEG-IBLNR = IISEG-IBLNR AND
GRU_ALT_BELEG-GJAHR = IISEG-GJAHR.
ELSE.
PERFORM S6110_ENDE_BELEG.
ENDIF.
MOVE-CORRESPONDING : IISEG TO GRU_ALT_BELEG.
APPEND IISEG TO XISEG1.
ENDLOOP.
PERFORM S6110_ENDE_BELEG.
* die selektierten Daten stehen jetzt in den Tabellen :
* IIKPF - Koepfe und ISEG - Positionen
* wurde der Report von einem Programm aufgerufen ?
IMPORT INVFLAG FROM MEMORY ID 'INVKEY'.
*EJECT
*---- Ende der Positionsselektion -------------------------------------
END-OF-SELECTION.
* Nachlesen Materialkurztexte
SORT XMATN.
DELETE ADJACENT DUPLICATES FROM XMATN.
* Liegen Daten in Tabelle XMATN vor?
describe table xmatn lines z_lines.
if not z_lines is initial.
SELECT * FROM MAKT APPENDING TABLE IMAKT
FOR ALL ENTRIES IN XMATN
WHERE MATNR EQ XMATN-MATNR
AND SPRAS EQ SY-LANGU.
endif.
* Fuellen Arbeitstabelle YISEG
PERFORM YISEG_FUELLEN.
* Hinweis, falls Daten wegen fehlender Berechtigung ueberlesen wurden
IF NOT NO_CHANCE IS INITIAL.
* Wegen fehlender Berechtigung ist die Liste unvollst鋘dig
MESSAGE S124.
ENDIF.
* Drucken mit neuer AVL-Technik
* ( Der ALV wird immer angestartet, mit und ohne Daten )
PERFORM S1000_LISTE_ALV.
*EJECT
*----------------------------------------------------------------------*
*--- Formroutine, die: 1. den Inventurbelegkopf (IKPF) liest, ---------*
*--- 2. falls IKPF gel鰏cht, GIDAT zur點ksetzt, -----*
*--- 3. MARV liest, ---------*
*--- 4. BUPER ermittelt, ---------*
*--- 5. BSTAR, T064T, MBEW liest, ---------*
*--- 6. Differenzmenge ermittelt ---------*
*--- 7. Differenzwert ermittelt ---------*
*--- 8. pr黤t, ob das eingegebene geplante ------*
*--- Aufnahmedatum in IKPF ------*
*--- 9. gegebenenfalls die DEL f黮lt ---------*
*--- 10. pr黤t, ob die eingegebene Buchungsperiode ---*
*--- in IKPF ------*
*--- 11. ein Update auf die YISEG durchf黨rt ---------*
*----------------------------------------------------------------------*
FORM YISEG_FUELLEN.
SORT XISEG BY IBLNR ASCENDING.
SORT IIKPF BY MANDT IBLNR GJAHR ASCENDING.
SORT IMAKT BY MATNR ASCENDING.
LOOP AT XISEG.
ON CHANGE OF XISEG-LGORT.
CLEAR XKZWM.
SELECT SINGLE * FROM T320 WHERE WERKS = XISEG-WERKS AND
LGORT = XISEG-LGORT AND
OBEST = SPACE.
IF SY-SUBRC IS INITIAL.
MOVE X TO XKZWM.
ENDIF.
ENDON.
IKPF_KEY-MANDT = XISEG-MANDT.
IKPF_KEY-IBLNR = XISEG-IBLNR.
IKPF_KEY-GJAHR = XISEG-GJAHR.
CHECK XISEG-ZLDAT IN ZLDAT.
READ TABLE IIKPF WITH KEY IKPF_KEY BINARY SEARCH.
CHECK IIKPF-GIDAT IN GIDAT.
MOVE-CORRESPONDING IIKPF TO BUPE1.
YISEG-INVNU = IIKPF-INVNU.
CHECK BUPE1 IN BUCHP.
YISEG-BUPER = BUPE1.
YISEG-DSTAT = IIKPF-DSTAT.
YISEG-GIDAT = IIKPF-GIDAT.
MOVE-CORRESPONDING XISEG TO YISEG.
MAKT_KEY-MANDT = XISEG-MANDT.
MAKT_KEY-MATNR = XISEG-MATNR.
READ TABLE IMAKT WITH KEY MAKT_KEY BINARY SEARCH.
IF SY-SUBRC EQ 0.
YISEG-MAKTX = IMAKT-MAKTX.
ELSE.
CLEAR YISEG-MAKTX.
ENDIF.
ON CHANGE OF YISEG-WERKS.
* PFAFFP: begin - Bei gel鰏chtem werk keinen Abbruch
* PERFORM WERK_LESEN USING YISEG-WERKS.
CLEAR DELWERK.
PERFORM LESEN_WERK USING YISEG-WERKS.
IF NOT SY-SUBRC IS INITIAL.
IF DELORG IS INITIAL.
MESSAGE S239.
ENDIF.
DELORG = X.
MOVE YISEG-WERKS TO DELWERK.
CONTINUE.
ENDIF.
* end
CLEAR T159L.
SELECT SINGLE * FROM T159L WHERE WERKS = YISEG-WERKS.
* PFAFFP: begin - Bei gel鰏chtem werk keinen Abbruch
IF NOT SY-SUBRC IS INITIAL.
IF DELORG IS INITIAL.
MESSAGE S239.
ENDIF.
DELORG = X.
CONTINUE.
ENDIF.
* end
* Ermitteln aktuelles Gesch鋐tsjahr
CALL FUNCTION 'DETERMINE_PERIOD'
EXPORTING
VERSION = T001-PERIV
DATE = SY-DATLO
IMPORTING
YEAR = Y_GJAHR.
* PFAFFP: begin - Bei gel鰏chtem werk keinen Abbruch
ELSE.
IF DELWERK EQ YISEG-WERKS.
CONTINUE.
ENDIF.
* end
ENDON.
IF IIKPF-VGART = T159L-VGART.
XKZWM = X.
ENDIF.
YISEG-Y_GJAHR = Y_GJAHR.
IF NOT YISEG-ZLDAT IS INITIAL.
CALL FUNCTION 'DETERMINE_PERIOD'
EXPORTING
VERSION = T001-PERIV
DATE = YISEG-ZLDAT
IMPORTING
PERIOD = YISEG-MONAT
YEAR = YISEG-GJAHR.
ELSE.
CLEAR YISEG-BUPER.
ENDIF.
H_BWKEY = T001W-BWKEY.
MOVE H_BWKEY TO YISEG-BWKEY.
MOVE T001-WAERS TO YISEG-WAERS.
IF YISEG-KWART IS INITIAL.
PERFORM BSTAR_LESEN USING YISEG-BSTAR.
ELSE.
CLEAR T064B.
ENDIF.
PERFORM T064T_LESEN.
YISEG-STEXT = T064T-STEXT.
YISEG-VGARI = T159L-VGART.
YISEG-VGART = IIKPF-VGART.
YISEG-DIFMG = YISEG-MENGE - YISEG-BUCHM.
IF XKZWM = X AND
NOT XISEG-MBLNR IS INITIAL.
CALL FUNCTION 'MB_READ_MATERIAL_POSITION'
EXPORTING
MBLNR = XISEG-MBLNR
MJAHR = XISEG-MJAHR
TRTYP = TM07I-TRTYP
ZEILB = XISEG-ZEILE
ZEILE = XISEG-ZEILE
TABLES
SEQTAB = XMSEG
EXCEPTIONS
ERROR_MESSAGE = 1.
READ TABLE XMSEG INDEX 1.
IF SY-SUBRC EQ 0.
IF XMSEG-SHKZG = H AND
YISEG-DIFMG GT 0.
YISEG-DIFMG = 0 - YISEG-DIFMG.
ENDIF.
ELSE.
YISEG-LVSAM = X.
ENDIF.
ENDIF.
YISEG-DIFVW = YISEG-EXVKW - YISEG-BUCHW.
IF NOT SY-SUBRC IS INITIAL.
CLEAR T064T.
ENDIF.
YISEG-BTEXT = T064B-BTEXT.
APPEND YISEG.
ENDLOOP.
ENDFORM.
*eject
*----------------------------------------------------------------------*
* diese Zeitpunkte wird vom ALV nicht genutzt
*---- Seitenkopfverarbeitung ------------------------------------------*
*TOP-OF-PAGE.
*
*----- Seitenkopfverarbeitung w鋒rend Zeilenselektion -----------------*
*TOP-OF-PAGE DURING LINE-SELECTION.
*---- PF-Tastenbelegung ------------------------------------------*
*AT USER-COMMAND.
* Dieser Zeitpunkt wird nicht durchlaufen. Dafuer werden FORM-Routinen
* vom ALV aufgerufen, die in der EVENTS-Tabelle enthalten sind
*----------------------------------------------------------------------*
FORM S0000_F4_FOR_VARIANT.
* Suchen und Anzeigen aller vorhandenen fuer F4 Eingabehilfe
MOVE A TO G_SAVE.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
IS_VARIANT = G_VARIANT
I_SAVE = G_SAVE
IMPORTING
E_EXIT = G_EXIT
ES_VARIANT = GX_VARIANT
EXCEPTIONS
NOT_FOUND = 2.
IF SY-SUBRC = 2.
MESSAGE ID SY-MSGID TYPE S NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
IF G_EXIT = SPACE.
PA_VARI = GX_VARIANT-VARIANT.
ENDIF.
ENDIF.
ENDFORM.
*----------------------------------------------------------------------*
FORM S0200_PAI_OF_SELECTION_SCREEN.
* Pruefen, ob die eingetippte Anzeigevariante vorhanden ist
SET CURSOR FIELD 'PA_VARI'.
IF PA_VARI IS INITIAL.
* Uebergabebreich loeschen und mit Reportname versehen
CLEAR G_VARIANT.
MOVE SY-REPID TO G_VARIANT-REPORT.
ELSE.
MOVE G_VARIANT TO GX_VARIANT.
MOVE PA_VARI TO GX_VARIANT-VARIANT.
CLEAR GX_VARIANT-USERNAME.
CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
EXPORTING
I_SAVE = A
CHANGING
CS_VARIANT = GX_VARIANT.
G_VARIANT = GX_VARIANT.
ENDIF.
ENDFORM.
*EJECT
*----------------------------------------------------------------------*
FORM S0300_CHECK_STATUS.
* Die Positionen werden je nach Belegstatus gel鰏cht oder belassen
LOOP AT XISEG1.
CLEAR FLAG_STATUS_OK.
* welcher Status hat der Belegkopf ?
CASE XIKPF-ZSTAT.
WHEN SPACE. "Noch nicht gezaehlte Belege
PERFORM S0310_CHECK_NICHT_GEZAEHLTE.
WHEN A. "Teilweise gezaehlte Belege
PERFORM S0320_CHECK_TEILWEISE.
WHEN X. "Vollstaendig gezaehlte Belege
PERFORM S0330_CHECK_VOLLSTAENDIG.
ENDCASE.
* Nicht selektierte Positionen werden aus XISEG1 geloescht
IF FLAG_STATUS_OK IS INITIAL.
DELETE XISEG1.
ENDIF.
ENDLOOP.
ENDFORM.
*----------------------------------------------------------------------*
FORM S0310_CHECK_NICHT_GEZAEHLTE.
IF PA_SELN1 = X. "noch nicht gezaehlte Belege
MOVE X TO FLAG_STATUS_OK.
ENDIF.
ENDFORM.
*----------------------------------------------------------------------*
FORM S0320_CHECK_TEILWEISE.
IF PA_SELT1 = X. "Status IP noch nicht gezaehlt
IF XISEG1-XZAEL IS INITIAL AND
XISEG1-XDIFF IS INITIAL AND
XISEG1-XNZAE IS INITIAL AND
XISEG1-XLOEK IS INITIAL.
MOVE X TO FLAG_STATUS_OK.
ENDIF.
ENDIF.
IF PA_SELT2 = X. "Status IP nur gez鋒lt
IF XISEG1-XZAEL = X AND
XISEG1-XDIFF IS INITIAL AND
XISEG1-XNZAE IS INITIAL AND
XISEG1-XLOEK IS INITIAL.
MOVE X TO FLAG_STATUS_OK.
ENDIF.
ENDIF.
IF PA_SELT3 = X. "Status IP ausgebucht
IF XISEG1-XDIFF = X.
MOVE X TO FLAG_STATUS_OK.
ENDIF.
ENDIF.
IF PA_SELT4 = X. "Status IP nachgez鋒lt
IF XISEG1-XNZAE = X.
MOVE X TO FLAG_STATUS_OK.
ENDIF.
ENDIF.
IF PA_SELT5 = X. "Status IP gel鰏cht
IF XISEG1-XLOEK = X.
MOVE X TO FLAG_STATUS_OK.
ENDIF.
ENDIF.
IF PA_SELT6 = X. "Status IP gez鋒lt und gel鰏cht
IF XISEG1-XLOEK = X AND
XISEG1-XZAEL = X AND
XISEG1-XDIFF IS INITIAL.
MOVE X TO FLAG_STATUS_OK.
ENDIF.
ENDIF.
ENDFORM.
*----------------------------------------------------------------------*
FORM S0330_CHECK_VOLLSTAENDIG.
IF PA_SELV2 = X. "Status IP nur gez鋒lt
IF XISEG1-XZAEL = X AND
XISEG1-XDIFF IS INITIAL AND
XISEG1-XNZAE IS INITIAL AND
XISEG1-XLOEK IS INITIAL.
MOVE X TO FLAG_STATUS_OK.
ENDIF.
ENDIF.
IF PA_SELV3 = X. "Status IP ausgebucht
IF XISEG1-XDIFF = X.
MOVE X TO FLAG_STATUS_OK.
ENDIF.
ENDIF.
IF PA_SELV4 = X. "Status IP nachgez鋒lt
IF XISEG1-XNZAE = X.
MOVE X TO FLAG_STATUS_OK.
ENDIF.
ENDIF.
IF PA_SELV5 = X. "Status IP gel鰏cht
IF XISEG1-XLOEK = X.
MOVE X TO FLAG_STATUS_OK.
ENDIF.
ENDIF.
IF PA_SELV6 = X. "Status IP gez鋒lt und gel鰏cht
IF XISEG1-XLOEK = X AND
XISEG1-XZAEL = X AND
XISEG1-XDIFF IS INITIAL.
MOVE X TO FLAG_STATUS_OK.
ENDIF.
ENDIF.
ENDFORM.
*----------------------------------------------------------------------*
*eject
*----------------------------------------------------------------------*
* create ranges for the database selektion
form s0100_create_ranges. "n0377071
clear flag_sel_sp_stock.
* with selection for special stock customer order ?
if not SO_EEAUF is initial.
move : E to ra_sobkz-low,
I to ra_sobkz-sign,
C_eq to ra_sobkz-option.
append ra_sobkz.
endif.
* with selection for special stock vendor consignation
if not SO_KKLIF is initial.
move : K to ra_sobkz-low,
I to ra_sobkz-sign,
C_eq to ra_sobkz-option.
append ra_sobkz.
loop at so_KKLIF.
move-corresponding so_kklif
to ra_lifnr.
append ra_lifnr.
endloop.
endif.
* with selection for special stock retunable vendor packing
if not SO_MMLIF is initial.
move : M to ra_sobkz-low,
I to ra_sobkz-sign,
C_eq to ra_sobkz-option.
append ra_sobkz.
loop at so_MMLIF.
move-corresponding so_MMlif
to ra_lifnr.
append ra_lifnr.
endloop.
endif.
* with selection for special stock provided to the vendor
if not SO_ooLIF is initial.
move : o to ra_sobkz-low,
I to ra_sobkz-sign,
C_eq to ra_sobkz-option.
append ra_sobkz.
loop at so_ooLIF.
move-corresponding so_oolif
to ra_lifnr.
append ra_lifnr.
endloop.
endif.
* with selection for special stock projects
if not SO_qqpnr is initial.
move : q to ra_sobkz-low,
I to ra_sobkz-sign,
C_eq to ra_sobkz-option.
append ra_sobkz.
endif.
* with selection for special stock provided by the customer
if not SO_vvkun is initial.
move : v to ra_sobkz-low,
I to ra_sobkz-sign,
C_eq to ra_sobkz-option.
append ra_sobkz.
loop at so_vvkun.
move-corresponding so_vvkun
to ra_kunnr.
append ra_kunnr.
endloop.
endif.
* with selection special stock packing by the customer
if not SO_wwkun is initial.
move : w to ra_sobkz-low,
I to ra_sobkz-sign,
C_eq to ra_sobkz-option.
append ra_sobkz.
loop at so_wwkun.
move-corresponding so_wwkun
to ra_kunnr.
append ra_kunnr.
endloop.
endif.
if ra_sobkz is initial.
* the user does not want detailled selection
if kzlso = X.
* the user wants all existing special stocks
else.
* the user wants no special stocks
clear ra_sobkz.
move : I to ra_sobkz-sign,
C_eq to ra_sobkz-option.
append ra_sobkz.
endif.
else.
* the user wants a detailled special stock selection
move : X to flag_sel_sp_stock.
endif.
endform. "s0100_create_ranges "n0377071
*----------------------------------------------------------------------*
*eject
*----------------------------------------------------------------------*
form s0200_check_special_stocks. "n0377071
* check for correct selection of special stocks
* it could be the vendor with K delivered entries with o, too.
* if they are not required, the will be deleted
loop at iiseg.
move X to flag_delete.
* check the special stocks for vendors and customers
case iiseg-sobkz.
when k.
if iiseg-lifnr in so_kklif.
clear flag_delete.
endif.
when m.
if iiseg-lifnr in so_mmlif.
clear flag_delete.
endif.
when o.
if iiseg-lifnr in so_oolif.
clear flag_delete.
endif.
* check WBS element in special stock projects "n400792
when Q. "n400792
* check the WBS element in internal format "n513843
if iiseg-ps_psp_pnr in ra_pspnr_all. "n513843
* WBS element in selection -> keep it "n400792
clear flag_delete. "n400792
endif. "n400792
when v.
if iiseg-kunnr in so_vvkun.
clear flag_delete.
endif.
when w.
if iiseg-kunnr in so_wwkun.
clear flag_delete.
endif.
when others.
clear flag_delete.
endcase.
if flag_delete = X.
delete iiseg.
endif.
endloop.
* release this range table after use "n513843
free ra_pspnr_all. "n513843
endform. "s0200_check_special_stocks "n0377071
*----------------------------------------------------------------------*
*EJECT
*----------------------------------------------------------------------*
* Liste mit dem ABAP-List_Viewer aufbereiten und ausgeben
*----------------------------------------------------------------------*
FORM S1000_LISTE_ALV.
MOVE SY-REPID TO G_REPID.
IS_PRINT-NO_PRINT_SELINFOS = X. "Kein Druck der Selektionskriterien
IS_PRINT-NO_PRINT_LISTINFOS = X. "Kein Druck der Datenstatistik
PERFORM S1100_BUILD_KEYINFO.
PERFORM S1200_BUILD_FIELDCAT.
PERFORM S1300_ASSIGN_EVENT_FORMS.
PERFORM S1400_BUILD_LAYOUT.
PERFORM S1500_BUILD_SORTINFO.
PERFORM S2000_BUILD_TABLE_YISEG1.
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = G_REPID
I_TABNAME_HEADER = 'T2'
I_TABNAME_ITEM = 'YISEG1'
IT_EVENTS = T_EVENTS_1[]
IT_FIELDCAT = FIELDCAT[]
IS_KEYINFO = GS_KEYINFO
IS_LAYOUT = GS_LAYOUT_1
IT_SORT = T_SORT_1[]
IS_PRINT = IS_PRINT
I_SAVE = A
IS_VARIANT = G_VARIANT
IMPORTING
E_EXIT_CAUSED_BY_CALLER = G_EXIT_CAUSED_BY_CALLER
ES_EXIT_CAUSED_BY_USER = GS_EXIT_CAUSED_BY_USER
TABLES
T_OUTTAB_HEADER = T2
T_OUTTAB_ITEM = YISEG1
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF NOT SY-SUBRC IS INITIAL. "Fehler vom ALV ?
MESSAGE ID SY-MSGID TYPE S NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.
*EJECT
*----------------------------------------------------------------------*
FORM S1100_BUILD_KEYINFO.
* Define keyinfo as sort group definition
CLEAR GS_KEYINFO.
GS_KEYINFO-HEADER01 = 'MATNR'. "define corresponding
GS_KEYINFO-ITEM01 = 'MATNR'. "keyfields of header table
GS_KEYINFO-HEADER02 = 'WERKS'. "and item table;
GS_KEYINFO-ITEM02 = 'WERKS'.
GS_KEYINFO-HEADER03 = 'LGORT'. "set additional item keyfields
GS_KEYINFO-ITEM03 = 'LGORT'. "(corresponding HEADER0n = ' ')
GS_KEYINFO-HEADER04 = 'SOBKZ'.
GS_KEYINFO-ITEM04 = 'SOBKZ'.
GS_KEYINFO-HEADER05 = SPACE.
GS_KEYINFO-ITEM05 = 'IBLNR'. "additional item keyfields
ENDFORM.
*----------------------------------------------------------------------*
FORM S1200_BUILD_FIELDCAT.
* 1. Aufbauen Feldkatalog fuer die Hauptliste
* 1.1 Header
CLEAR : FIELDCAT, Z_COL_POS.
* Fieldname tabname ref_tabname
PERFORM S1210_FIELDCAT USING 'MATNR' C_T2 'MAKT'.
PERFORM S1210_FIELDCAT USING 'MAKTX' C_T2 'MAKT'.
PERFORM S1210_FIELDCAT USING 'WERKS' C_T2 'ISEG'.
PERFORM S1210_FIELDCAT USING 'LGORT' C_T2 'ISEG'.
PERFORM S1210_FIELDCAT USING 'SOBKZ' C_T2 'ISEG'.
PERFORM S1210_FIELDCAT USING 'SOTXT' C_T2 'T148T'.
* 1.2 Positionen
CLEAR Z_COL_POS.
* Fieldname tabname ref_tabname
PERFORM S1210_FIELDCAT USING 'IBLNR' 'YISEG1' 'ISEG'.
PERFORM S1210_FIELDCAT USING 'ZEILI' 'YISEG1' 'ISEG'.
PERFORM S1210_FIELDCAT USING 'CHARG' 'YISEG1' 'ISEG'.
MOVE : SIEBEN TO FIELDCAT-OUTPUTLEN,
'CHAR' TO FIELDCAT-DATATYPE,
TEXT-043 TO FIELDCAT-SELTEXT_L, "Periode
'BUPER' TO FIELDCAT-rollname. "Ref. Felddoku
PERFORM S1210_FIELDCAT USING 'PERBU' 'YISEG1' ' '.
* FIELDNAME TABNAME REF_TABNAME
PERFORM S1210_FIELDCAT USING 'GIDAT' 'YISEG1' 'IKPF'.
PERFORM S1210_FIELDCAT USING 'ZLDAT' 'YISEG1' 'IKPF'.
PERFORM S1210_FIELDCAT USING 'BSTAR' 'YISEG1' 'ISEG'.
PERFORM S1210_FIELDCAT USING 'INVNU' 'YISEG1' 'IKPF'.
MOVE : '15' TO FIELDCAT-OUTPUTLEN,
'CHAR' TO FIELDCAT-DATATYPE,
TEXT-068 TO FIELDCAT-SELTEXT_L. "Beleg Status
MOVE 'X' TO FIELDCAT-LOWERCASE. " 357338
PERFORM S1210_FIELDCAT USING 'DSTAT_TEXT' 'YISEG1' ' '.
* insert the key info of special stocks into the field "n0377071
* catalog as hidden fields
move : X to fieldcat-no_out.
PERFORM S1210_FIELDCAT USING 'LIFNR' 'YISEG1' 'ISEG'.
move : X to fieldcat-no_out.
PERFORM S1210_FIELDCAT USING 'KUNNR' 'YISEG1' 'ISEG'.
move : X to fieldcat-no_out.
PERFORM S1210_FIELDCAT USING 'PS_PSP_PNR' 'YISEG1' 'ISEG'.
move : X to fieldcat-no_out.
PERFORM S1210_FIELDCAT USING 'KDAUF' 'YISEG1' 'ISEG'.
move : X to fieldcat-no_out.
PERFORM S1210_FIELDCAT USING 'KDPOS' 'YISEG1' 'ISEG'.
*----------------------------------------------------------------------*
* 2. Aufbauen Feldkatalog fuer die Verzweigungsliste aus STAB3
* 2.1 fuer normale Materialien mit Wert und Menge
CLEAR Z_COL_POS.
* Fieldname tabname ref_tabname
PERFORM S1220_FIELDCAT_2 USING 'SOBKZ' 'STAB3' 'ISEG'.
PERFORM S1220_FIELDCAT_2 USING 'SOTXT' 'STAB3' 'T148T'.
PERFORM S1220_FIELDCAT_2 USING 'GJAHR' 'STAB3' 'ISEG'.
PERFORM S1220_FIELDCAT_2 USING 'WERKS' 'STAB3' 'ISEG'.
PERFORM S1220_FIELDCAT_2 USING 'LGORT' 'STAB3' 'ISEG'.
* Feld WERT als Summe der Felder DMBTR und VDMBT
MOVE : 'WAERS' TO FIELDCAT_2-CFIELDNAME,
X TO FIELDCAT_2-DO_SUM,
'DMBTR' TO FIELDCAT_2-REF_FIELDNAME,
TEXT-047 TO FIELDCAT_2-SELTEXT_L. "Differenzwert
PERFORM S1220_FIELDCAT_2 USING 'WERT' 'STAB3' 'ISEG'.
PERFORM S1220_FIELDCAT_2 USING 'WAERS' 'STAB3' 'ISEG'.
* Feld MENGE aus Summe der Felder DIFMG und VDIFM
MOVE : 'DIFMG' TO FIELDCAT_2-REF_FIELDNAME,
'MEINS' TO FIELDCAT_2-QFIELDNAME,
X TO FIELDCAT_2-DO_SUM,
TEXT-048 TO FIELDCAT_2-SELTEXT_L. "Differenzmenge
PERFORM S1220_FIELDCAT_2 USING 'MENGE' 'STAB3' 'VM07I'.
PERFORM S1220_FIELDCAT_2 USING 'MEINS' 'STAB3' 'ISEG'.
*-----------------------------------------------------------------------
* 2.2 fuer Wert-Materialien nur mit Wert
CLEAR Z_COL_POS.
* Fieldname tabname ref_tabname
PERFORM S1230_FIELDCAT_3 USING 'SOBKZ' 'STAB3' 'ISEG'.
PERFORM S1230_FIELDCAT_3 USING 'SOTXT' 'STAB3' 'T148T'.
PERFORM S1230_FIELDCAT_3 USING 'GJAHR' 'STAB3' 'ISEG'.
PERFORM S1230_FIELDCAT_3 USING 'WERKS' 'STAB3' 'ISEG'.
PERFORM S1230_FIELDCAT_3 USING 'LGORT' 'STAB3' 'ISEG'.
* Feld WERT als Summe der Felder DMBTR und VDMBT
MOVE : 'WAERS' TO FIELDCAT_3-CFIELDNAME,
X TO FIELDCAT_3-DO_SUM,
'DMBTR' TO FIELDCAT_3-REF_FIELDNAME,
TEXT-047 TO FIELDCAT_3-SELTEXT_L. "Differenzwert
PERFORM S1230_FIELDCAT_3 USING 'WERT' 'STAB3' 'ISEG'.
* Feld PREIS als Summe der Felder DIFVW und VDIFV
MOVE : 'WAERS' TO FIELDCAT_3-CFIELDNAME,
X TO FIELDCAT_3-DO_SUM,
'DIFVW' TO FIELDCAT_3-REF_FIELDNAME,
TEXT-069 TO FIELDCAT_3-SELTEXT_L. "Verkaufspreis
PERFORM S1230_FIELDCAT_3 USING 'PREIS' 'STAB3' 'VM07I'.
PERFORM S1230_FIELDCAT_3 USING 'WAERS' 'STAB3' 'ISEG'.
ENDFORM.
*----------------------------------------------------------------------*
FORM S1210_FIELDCAT USING X1210_FIELDNAME
X1210_TABNAME
X1210_REF_TABNAME.
ADD : 1 TO Z_COL_POS.
MOVE : Z_COL_POS TO FIELDCAT-COL_POS,
X1210_FIELDNAME TO FIELDCAT-FIELDNAME,
X1210_TABNAME TO FIELDCAT-TABNAME,
X1210_REF_TABNAME TO FIELDCAT-REF_TABNAME.
APPEND FIELDCAT.
CLEAR FIELDCAT.
ENDFORM.
*----------------------------------------------------------------------*
FORM S1220_FIELDCAT_2 USING X1220_FIELDNAME
X1220_TABNAME
X1220_REF_TABNAME.
ADD : 1 TO Z_COL_POS.
MOVE : Z_COL_POS TO FIELDCAT_2-COL_POS,
X1220_FIELDNAME TO FIELDCAT_2-FIELDNAME,
X1220_TABNAME TO FIELDCAT_2-TABNAME,
X1220_REF_TABNAME TO FIELDCAT_2-REF_TABNAME.
APPEND FIELDCAT_2.
CLEAR FIELDCAT_2.
ENDFORM.
*----------------------------------------------------------------------*
FORM S1230_FIELDCAT_3 USING X1230_FIELDNAME
X1230_TABNAME
X1230_REF_TABNAME.
ADD : 1 TO Z_COL_POS.
MOVE : Z_COL_POS TO FIELDCAT_3-COL_POS,
X1230_FIELDNAME TO FIELDCAT_3-FIELDNAME,
X1230_TABNAME TO FIELDCAT_3-TABNAME,
X1230_REF_TABNAME TO FIELDCAT_3-REF_TABNAME.
APPEND FIELDCAT_3.
CLEAR FIELDCAT_3.
ENDFORM.
*EJECT
*----------------------------------------------------------------------*
FORM S1300_ASSIGN_EVENT_FORMS.
* Aufbauen Tabelle mit den Zuordnungen EVENTS - FORM-Routinen
* 1. fuer Hauptliste
T_EVENTS_1-NAME = 'PF_STATUS_SET'.
T_EVENTS_1-FORM = 'S3000_PF_STATUS_SET'.
APPEND T_EVENTS_1.
T_EVENTS_1-NAME = 'USER_COMMAND'.
T_EVENTS_1-FORM = 'S3100_USER_COMMAND'.
APPEND T_EVENTS_1.
* 2. fuer die Verzweigungsliste
T_EVENTS_2-NAME = 'PF_STATUS_SET'.
T_EVENTS_2-FORM = 'S5000_PF_STATUS_SET'.
APPEND T_EVENTS_2.
T_EVENTS_2-NAME = 'USER_COMMAND'.
T_EVENTS_2-FORM = 'S5100_USER_COMMAND'.
APPEND T_EVENTS_2.
T_EVENTS_2-NAME = 'TOP_OF_LIST'.
T_EVENTS_2-FORM = 'S5200_TOP_OF_LIST'.
APPEND T_EVENTS_2.
ENDFORM.
*EJECT
*----------------------------------------------------------------------*
FORM S1400_BUILD_LAYOUT.
* 1. fuer die Hauptliste
GS_LAYOUT_1-DEFAULT_ITEM = X.
GS_LAYOUT_1-DETAIL_POPUP = X.
GS_LAYOUT_1-INFO_FIELDNAME = 'FARBE'.
GS_LAYOUT_1-NO_MIN_LINESIZE = X.
GS_LAYOUT_1-GROUP_BUTTONS = SPACE.
GS_LAYOUT_1-GROUP_CHANGE_EDIT = X.
* 2. fuer die Verzweigungsliste
GS_LAYOUT_2-NO_HOTSPOT = X.
GS_LAYOUT_2-NO_TOTALLINE = X. "keine Gesamtsumme
ENDFORM.
*----------------------------------------------------------------------*
FORM S1500_BUILD_SORTINFO.
CLEAR T_SORT_1.
REFRESH T_SORT_1.
* Vorschlagswert fuer Gruppenwechsel Material
MOVE : '1' TO T_SORT_1-SPOS,
'MATNR' TO T_SORT_1-FIELDNAME,
'T2' TO T_SORT_1-TABNAME,
'X' TO T_SORT_1-UP,
'X' TO T_SORT_1-SUBTOT,
'UL' TO T_SORT_1-GROUP.
APPEND T_SORT_1.
* Aufbauen Sortinfo-tabelle fuer die Verzweigungsliste
CLEAR T_SORT_2.
MOVE : EINS TO T_SORT_2-SPOS,
'SOBKZ' TO T_SORT_2-FIELDNAME,
'STAB3' TO T_SORT_2-TABNAME,
X TO T_SORT_2-UP,
STERN TO T_SORT_2-GROUP.
APPEND T_SORT_2.
CLEAR T_SORT_2.
MOVE : ZWEI TO T_SORT_2-SPOS,
'GJAHR' TO T_SORT_2-FIELDNAME,
'STAB3' TO T_SORT_2-TABNAME,
X TO T_SORT_2-UP,
X TO T_SORT_2-SUBTOT.
APPEND T_SORT_2.
CLEAR T_SORT_2.
MOVE : DREI TO T_SORT_2-SPOS,
'WERKS' TO T_SORT_2-FIELDNAME,
'STAB3' TO T_SORT_2-TABNAME,
X TO T_SORT_2-UP,
X TO T_SORT_2-SUBTOT.
APPEND T_SORT_2.
CLEAR T_SORT_2.
MOVE : VIER TO T_SORT_2-SPOS,
'LGORT' TO T_SORT_2-FIELDNAME,
'STAB3' TO T_SORT_2-TABNAME,
X TO T_SORT_2-UP.
APPEND T_SORT_2.
CLEAR T_SORT_2.
ENDFORM.
*EJECT
*----------------------------------------------------------------------*
* Die eigentliche Drucktabelle wird aufgebaut
FORM S2000_BUILD_TABLE_YISEG1.
* nur weiter, wenn Tabelle YISEG Daten enth鋖t
describe table yiseg lines Z_lines.
check : not z_lines is initial.
MOVE : 'C21' TO ZW_FARBE.
* Sortieren interne Tabellen YISEG
SORT YISEG BY MATNR MAKTX WERKS LGORT SOBKZ IBLNR ZEILI CHARG BUPER
GIDAT ZLDAT BSTAR.
LOOP AT YISEG.
MOVE-CORRESPONDING YISEG TO GRU_NEU_YISEG.
ADD 1 TO Z_YISEG.
IF Z_YISEG > 1.
IF GRU_NEU_YISEG = GRU_ALT_YISEG.
IF YISEG-IBLNR = GRU_ALT_IBLNR.
ELSE.
PERFORM S2300_ENDE_BELEG.
ENDIF.
ELSE.
PERFORM S2300_ENDE_BELEG.
PERFORM S2200_ENDE_GRUPPE.
ENDIF.
ENDIF.
MOVE : GRU_NEU_YISEG TO GRU_ALT_YISEG,
YISEG-IBLNR TO GRU_ALT_IBLNR.
PERFORM S2100_SATZVERARBEITUNG.
ENDLOOP.
* Verarbeiten Daten der letzten Gruppe
PERFORM S2300_ENDE_BELEG.
PERFORM S2200_ENDE_GRUPPE.
ENDFORM.
*----------------------------------------------------------------------*
FORM S2100_SATZVERARBEITUNG.
* der Eintrag YISEG wird ergaenzt und in Arbeitstabelle YISEG2
* eingestellt
MOVE-CORRESPONDING YISEG TO YISEG2.
PERBU-MONAT = YISEG-BUPER+4(2).
PERBU-POINT = PUNKT.
PERBU-GJAHR = YISEG-BUPER+0(4).
CONDENSE PERBU NO-GAPS.
MOVE PERBU TO YISEG2-PERBU.
IF YISEG-DSTAT = X.
CLEAR YISEG2-DSTAT_TEXT.
ELSE.
MOVE TEXT-007 TO YISEG2-DSTAT_TEXT.
ENDIF.
APPEND YISEG2.
ENDFORM.
*----------------------------------------------------------------------*
FORM S2200_ENDE_GRUPPE.
* AUfbauen Header-Tabelle T2
MOVE-CORRESPONDING GRU_ALT_YISEG TO T2.
SELECT SINGLE * FROM T148T WHERE SPRAS = SY-LANGU
AND SOBKZ = GRU_ALT_YISEG-SOBKZ.
IF SY-SUBRC = 0.
MOVE T148T-SOTXT TO T2-SOTXT.
ELSE.
CLEAR T2-SOTXT.
ENDIF.
APPEND T2.
MOVE 'C21' TO ZW_FARBE.
ENDFORM.
*----------------------------------------------------------------------*
FORM S2300_ENDE_BELEG.
* Farbe fuer die Gruppe festlegen
IF ZW_FARBE = 'C21'.
MOVE 'C20' TO ZW_FARBE.
ELSE.
MOVE 'C21' TO ZW_FARBE.
ENDIF.
* Alle Saetze eines Beleges mit der gleichen Farbe weitergeben
LOOP AT YISEG2.
MOVE-CORRESPONDING YISEG2 TO YISEG1.
MOVE : ZW_FARBE TO YISEG1-FARBE.
APPEND YISEG1.
ENDLOOP.
* Datenbereiche fuer neue Gruppe loeschen
CLEAR : YISEG2.
REFRESH YISEG2.
ENDFORM.
*----------------------------------------------------------------------*
FORM S3000_PF_STATUS_SET USING EXTAB TYPE SLIS_T_EXTAB.
* Setzen Menue-Status; ggf. Ausgeblenden Button fuer UEBN
IF INVFLAG IS INITIAL.
* Wird der Report direkt aufgerufen, so wird die Funktion UEBN
* Uebernahme Belegnummer ausgeblendet durch Aufnahme in die EXTAB
MOVE UCOM-UEBN TO ZW_EXTAB-FCODE.
APPEND ZW_EXTAB TO EXTAB.
ENDIF.
SET PF-STATUS 'STANDARD' EXCLUDING EXTAB.
ENDFORM.
*----------------------------------------------------------------------*
FORM S3100_USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
* Zeitpunkt USER_COMMAND in Hauptliste
CASE R_UCOMM. "Was steht im User-Command ?
WHEN '&IC1'. "Doppelklick auf Feld ?
* Doppelklick klappt nur bei Status = STANDARD
CASE RS_SELFIELD-SEL_TAB_FIELD.
WHEN 'T2-MATNR'.
PERFORM S4000_SUMMEN_MATERIAL
USING RS_SELFIELD-TABINDEX C_T2.
WHEN 'YISEG1-IBLNR'.
PERFORM S4100_BEARB_BELEG USING RS_SELFIELD-TABINDEX.
WHEN OTHERS.
* keine Meldeung, da gleiches Kommando auch beim markieren der
* 躡erschrift gesetzt wird
* MESSAGE I847 WITH TEXT-071. "Material- oder Belegnummer
ENDCASE.
WHEN UCOM-AUSW. "Anzeige Inventurbeleg
CASE RS_SELFIELD-SEL_TAB_FIELD.
WHEN 'YISEG1-IBLNR'.
PERFORM S4100_BEARB_BELEG USING RS_SELFIELD-TABINDEX.
WHEN OTHERS.
MESSAGE I847 WITH TEXT-070. "Belegnummer
ENDCASE.
WHEN UCOM-AUSR.
*** Positionieren auf Positionszeile
MOVE RS_SELFIELD-SEL_TAB_FIELD TO ZW_SEL_TAB_FIELD.
CASE ZW_SEL_TAB_FIELD(07).
WHEN 'YISEG1-'.
PERFORM S4300_HISTORIE USING RS_SELFIELD-TABINDEX.
WHEN OTHERS.
MESSAGE I847 WITH TEXT-070. "Belegnummer
ENDCASE.
WHEN UCOM-SUMM. "Summen angefordert
CASE RS_SELFIELD-SEL_TAB_FIELD.
WHEN 'T2-MATNR'.
PERFORM S4000_SUMMEN_MATERIAL
USING RS_SELFIELD-TABINDEX C_T2.
WHEN 'YISEG1-IBLNR'.
* auch wenn eine Zeile mit Beleg ausgewaehlt wurde, werden die
* Summen des zugehoerigen Materials dargestellt
PERFORM S4000_SUMMEN_MATERIAL
USING RS_SELFIELD-TABINDEX C_YISEG1.
WHEN OTHERS.
MESSAGE I847 WITH TEXT-072. "Materialnummer
ENDCASE.
WHEN UCOM-UEBN. "Ubernahme Belegnummer+Werk
CASE RS_SELFIELD-SEL_TAB_FIELD.
WHEN 'YISEG1-IBLNR'.
PERFORM S4200_UEBERNAHME USING RS_SELFIELD-TABINDEX.
WHEN OTHERS.
MESSAGE I847 WITH TEXT-070. "Belegnummer
ENDCASE.
ENDCASE.
ENDFORM.
*----------------------------------------------------------------------*
FORM S4000_SUMMEN_MATERIAL USING X4000_TABINDEX TYPE SYTABIX
X4000_TABLE.
* Achtung : dieses Feld -VALUE enthaelt die druckaufbereitet Material-
* nummer! Mit dieser kann nicht in internen Tabellen gesucht werden!
* MOVE RS_SELFIELD-VALUE TO ZW_MATNR.
* Nachlesen Tabelleneintrag zur ausgewaehlten Zeile
* In welcher Tabelle soll gesucht werden ?
CASE X4000_TABLE.
WHEN C_YISEG1.
READ TABLE YISEG1 INDEX X4000_TABINDEX.
MOVE YISEG1-MATNR TO ZW_MATNR.
WHEN C_T2.
READ TABLE T2 INDEX X4000_TABINDEX.
MOVE T2-MATNR TO ZW_MATNR.
WHEN OTHERS.
MOVE 4 TO SY-SUBRC.
ENDCASE.
CHECK : SY-SUBRC = 0. "Materialnummer gefunden ?
IF FLAG_STAB IS INITIAL.
* Die Tabelle STAB wird nur einmal aufgebaut
PERFORM S4010_STABX_FUELLEN.
MOVE : X TO FLAG_STAB,
X_COUNT TO ZW_COUNT_MAX.
ENDIF.
* das Anzeigen der Verzweigungsliste erfolgt jetzt in einer Schleife,
* und zwar so lange, bis der User BACK betaetigt hat
DO.
* Selektieren Summen zum Material aus Tabelle STAB --> STAB3
PERFORM S5400_FUELLEN_STAB3.
PERFORM S5300_DIPLAY_STAB3.
IF SY-UCOMM = 'RW' OR "Hat der User PF3 betaetigt ?
SY-UCOMM = '&F03' OR
SY-UCOMM = '&ONT' OR "ENTER
SY-UCOMM = '&AC1'. "das rote Abbruchkreuz
EXIT.
ENDIF.
ENDDO.
ENDFORM.
*----------------------------------------------------------------------*
FORM S4010_STABX_FUELLEN.
CLEAR X_COUNT.
LOOP AT YISEG.
Y_GJAHR = YISEG-Y_GJAHR.
X_GJAHR = Y_GJAHR - 1.
IF YISEG-XDIFF = X AND
( YISEG-GJAHR = Y_GJAHR OR YISEG-GJAHR = X_GJAHR ).
X_PFKEY = X.
ON CHANGE OF YISEG-MATNR.
X_COUNT = X_COUNT + 1.
ENDON.
ENDIF.
IF YISEG-XDIFF = X AND YISEG-GJAHR = Y_GJAHR.
* die Meldung wird weitergegeben
* IF YISEG-LVSAM = X AND MELDUNG IS INITIAL.
* MELDUNG = X.
* MESSAGE I699 WITH YISEG-MATNR.
* ENDIF.
IF YISEG-LVSAM = X.
MOVE '699' TO STAB1-MESSAGE.
ELSE.
CLEAR STAB1-MESSAGE.
ENDIF.
STAB1-SOBKZ = YISEG-SOBKZ.
STAB1-COUNT = YISEG-ZEILI.
STAB1-MATNR = YISEG-MATNR.
STAB1-WERKS = YISEG-WERKS.
STAB1-LGORT = YISEG-LGORT.
STAB1-GJAHR = YISEG-GJAHR.
STAB1-DMBTR = YISEG-DMBTR.
IF YISEG-DIFMG < 0. "note 71448
STAB1-DMBTR = STAB1-DMBTR * -1.
ENDIF.
STAB1-KWART = YISEG-KWART.
IF YISEG-KWART IS INITIAL.
CLEAR STAB1-DIFVW.
ELSE.
STAB1-DIFVW = YISEG-DIFVW.
ENDIF.
STAB1-DIFMG = YISEG-DIFMG.
STAB1-WAERS = YISEG-WAERS.
STAB1-MEINS = YISEG-MEINS.
STAB1-COUNT = X_COUNT.
APPEND STAB1.
ENDIF.
IF YISEG-XDIFF = X AND YISEG-GJAHR = X_GJAHR.
* die Meldung wird weitergegeben
* IF YISEG-LVSAM = X AND MELDUNG IS INITIAL.
* MELDUNG = X.
* MESSAGE I699 WITH YISEG-MATNR.
* ENDIF.
IF YISEG-LVSAM = X.
MOVE '699' TO STAB2-MESSAGE.
ELSE.
CLEAR STAB2-MESSAGE.
ENDIF.
STAB2-SOBKZ = YISEG-SOBKZ.
STAB2-GJAHR = YISEG-GJAHR.
STAB2-MATNR = YISEG-MATNR.
STAB2-WERKS = YISEG-WERKS.
STAB2-LGORT = YISEG-LGORT.
STAB2-WAERS = YISEG-WAERS.
STAB2-MEINS = YISEG-MEINS.
STAB2-VDMBT = YISEG-DMBTR.
STAB2-VDIFM = YISEG-DIFMG.
STAB2-KWART = YISEG-KWART.
IF YISEG-KWART IS INITIAL.
CLEAR STAB2-VDIFV.
IF STAB2-VDIFM < 0. "note 71448
STAB2-VDMBT = STAB2-VDMBT * -1.
ENDIF.
ELSE.
STAB2-VDIFV = YISEG-EXVKW - YISEG-BUCHW.
IF STAB2-VDIFV < 0. "note 71448
STAB2-VDMBT = STAB2-VDMBT * -1.
ENDIF.
ENDIF.
* IF STAB2-VDIFM < 0. "note 71448
* STAB2-VDMBT = STAB2-VDMBT * -1.
* ENDIF.
STAB2-COUNT = X_COUNT.
APPEND STAB2.
ENDIF.
ENDLOOP.
CLEAR MELDUNG.
X_GJAHR = Y_GJAHR - 1.
CLEAR OLD-MATNR.
CLEAR STAB.
LOOP AT STAB1.
MOVE-CORRESPONDING STAB1 TO STAB.
APPEND STAB.
ENDLOOP.
CLEAR STAB.
LOOP AT STAB2.
MOVE-CORRESPONDING STAB2 TO STAB.
APPEND STAB.
ENDLOOP.
ENDFORM.
*----------------------------------------------------------------------*
FORM S4100_BEARB_BELEG USING X4100_TABINDEX TYPE SYTABIX.
* Direktes Nachlesen EINTRAG IN TABELLE YISEG1
READ TABLE YISEG1 INDEX X4100_TABINDEX.
CHECK : SY-SUBRC = 0.
* sichern aktuelle Werte aus Parameterbereich
CLEAR : ZW_SAVE_IBLNR, ZW_SAVE_GJAHR.
GET PARAMETER ID 'IBN' FIELD ZW_SAVE_IBLNR.
GET PARAMETER ID 'GJR' FIELD ZW_SAVE_GJAHR.
* Setzen ausgewaehlte Belegnummer und Jahr in den Parameterbereich
SET PARAMETER ID 'IBN' FIELD YISEG1-IBLNR.
SET PARAMETER ID 'GJR' FIELD YISEG1-GJAHR.
CALL TRANSACTION 'MI03' AND SKIP FIRST SCREEN.
* gesicherte Werte wieder in den Parameterbereich einstellen
SET PARAMETER ID 'IBN' FIELD ZW_SAVE_IBLNR.
SET PARAMETER ID 'GJR' FIELD ZW_SAVE_GJAHR.
ENDFORM.
*----------------------------------------------------------------------*
FORM S4200_UEBERNAHME USING X4200_TABINDEX TYPE SYTABIX.
* Direktes Nachlesen EINTRAG IN TABELLE YISEG1 und setzen Belegnummer
* und GJAHR in den Parameterbereich
READ TABLE YISEG1 INDEX X4200_TABINDEX.
CHECK : SY-SUBRC = 0.
SET PARAMETER ID 'IBN' FIELD YISEG1-IBLNR.
SET PARAMETER ID 'GJR' FIELD YISEG1-GJAHR.
leave program.
ENDFORM.
*----------------------------------------------------------------------*
FORM S4300_HISTORIE USING X4300_TABINDEX TYPE SYTABIX.
* Direktes Nachlesen EINTRAG IN TABELLE YISEG1
READ TABLE YISEG1 INDEX X4300_TABINDEX.
CHECK : SY-SUBRC = 0.
REFRESH YDM07I.
XTAB = XTABIX.
XTAB = X4300_TABINDEX.
MOVE XTAB TO RM07I-ZEILI.
CLEAR TM07I.
SELECT SINGLE * FROM T001W WHERE WERKS = YISEG1-WERKS.
SELECT SINGLE * FROM T148T WHERE SPRAS = SY-LANGU
AND SOBKZ = YISEG1-SOBKZ.
SELECT SINGLE * FROM T001L WHERE WERKS = YISEG1-WERKS
AND LGORT = YISEG1-LGORT.
CLEAR XKZWM.
SELECT SINGLE * FROM T320 WHERE WERKS = YISEG1-WERKS AND
LGORT = YISEG1-LGORT AND
OBEST = SPACE.
IF SY-SUBRC IS INITIAL.
MOVE X TO XKZWM.
ENDIF.
MOVE-CORRESPONDING YISEG1 TO IKPF.
TM07I-VGART_MB = YISEG1-VGARI.
REFRESH XISEG.
IBLNR = YISEG1-IBLNR.
LOOP AT YISEG WHERE IBLNR = IBLNR.
* Material mu?gelesen werden, um Datum der letzen Inventur zu f黮len
PERFORM MATERIAL_LESEN .
PERFORM DATUM_LETZTE_INV.
YDM07I-IBLNA = YISEG-IBLNR.
YDM07I-AZEIL = YISEG-ZEILI.
YDM07I-MAKTX = YISEG-MAKTX.
YDM07I-BUCHH = YISEG-MEINS.
YDM07I-DIFMH = YISEG-MEINS.
IF XKZWM IS INITIAL.
YDM07I-KZWMD = SPACE.
ELSE.
YDM07I-KZWMD = X.
ENDIF.
APPEND YDM07I.
MOVE-CORRESPONDING YISEG TO XISEG.
APPEND XISEG.
ENDLOOP.
READ TABLE XISEG INDEX 1.
IF NOT SY-SUBRC IS INITIAL.
* error fixed reported by the extended progam check "n513843
MESSAGE E001 WITH 'XISEG' '1' space space. "n513843
ENDIF.
READ TABLE YISEG INDEX XTAB.
* remove the following sort as it is not useful for
* MB_DISPLAY_INVENTORY_HISTORY. The function assumes that YDM07I and
* XISEG is in the same order. This is true after the loop above, but
* will no longer be true after you have sorted only xiseg.
* (see note 0373689)
* SORT XISEG.
LOOP AT XISEG WHERE MANDT EQ YISEG-MANDT
AND IBLNR EQ YISEG-IBLNR
AND GJAHR EQ YISEG-GJAHR
AND ZEILI EQ YISEG-ZEILI.
MOVE SY-TABIX TO ZW_TABZEILE.
DIFMG = XISEG-MENGE - XISEG-BUCHM.
IF NOT XKZWM IS INITIAL AND NOT YISEG-MBLNR IS INITIAL.
CALL FUNCTION 'MB_READ_MATERIAL_POSITION'
EXPORTING
MBLNR = YISEG-MBLNR
MJAHR = YISEG-MJAHR
TRTYP = TM07I-TRTYP
ZEILB = YISEG-ZEILE
ZEILE = YISEG-ZEILE
TABLES
SEQTAB = XMSEG
EXCEPTIONS
ERROR_MESSAGE = 1.
READ TABLE XMSEG INDEX 1.
IF SY-SUBRC EQ 0.
IF XMSEG-SHKZG = H AND
DIFMG GT 0.
DIFMG = 0 - DIFMG.
ENDIF.
ELSE.
YISEG-LVSAM = X.
ENDIF.
ENDIF.
REFRESH DUMMY.
CALL FUNCTION 'MB_DISPLAY_INVENTORY_HISTORY'
EXPORTING
F_TM07I = TM07I
F_IKPF = IKPF
DIFMG = DIFMG
*(DEL) ZEILI = XISEG-ZEILI
ZEILI = ZW_TABZEILE
B_ZEILE = SPACE
F_FUSS = SPACE
F_FCAUSI = SPACE
SOTXT = T148T-SOTXT
LGOBE = T001L-LGOBE
NAME1 = T001W-NAME1
TABLES
YISEG = XISEG
YDM07I = YDM07I
FUSS = DUMMY.
ENDLOOP.
ENDFORM.
*----------------------------------------------------------------------*
FORM S5000_PF_STATUS_SET USING EXTAB TYPE SLIS_T_EXTAB.
SET TITLEBAR '200'. "Summen pro Material
SET PF-STATUS 'SUMM' EXCLUDING EXTAB.
ENDFORM.
*----------------------------------------------------------------------*
FORM S5100_USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
* Zeitpunkt USER_COMMAND in der Verzweigungsliste
* hier wird nur noch die gewuenschte Materialnummer ermittelt
* der ALV wird sofort verlassen
MOVE X TO RS_SELFIELD-EXIT.
CASE R_UCOMM.
WHEN 'EMAT'. "Anzeige des 1. Materials
MOVE : 1 TO ZW_COUNT.
PERFORM S5110_GET_NEXT_MATERIAL.
WHEN UCOM-NMAT. "Anzeige des naechsten Materials
* Gruppennummer erhoehen, falls der letzte noch nicht erreicht ist
IF ZW_COUNT < ZW_COUNT_MAX.
ADD 1 TO ZW_COUNT.
PERFORM S5110_GET_NEXT_MATERIAL.
ELSE.
MESSAGE W149(CK). "Letztes selektiertes Material wurde erreicht
ENDIF.
WHEN UCOM-VMAT. "Anzeige 1. Material zurueck
* Gruppennummer verkleinern, falls die 1. noch nicht erreicht ist
IF ZW_COUNT > 1.
SUBTRACT 1 FROM ZW_COUNT.
PERFORM S5110_GET_NEXT_MATERIAL.
ELSE.
MESSAGE W150(CK). "Erstes selektiertes Material wurde erreicht
ENDIF.
WHEN 'LMAT'. "Anzeige des letzten Materials
MOVE : ZW_COUNT_MAX TO ZW_COUNT.
PERFORM S5110_GET_NEXT_MATERIAL.
WHEN OTHERS.
ENDCASE.
ENDFORM.
*----------------------------------------------------------------------*
FORM S5110_GET_NEXT_MATERIAL.
LOOP AT STAB WHERE COUNT = ZW_COUNT.
MOVE STAB-MATNR TO ZW_MATNR.
EXIT.
ENDLOOP.
ENDFORM.
*----------------------------------------------------------------------*
FORM S5200_TOP_OF_LIST.
* Ueberschift fuer die 2. Liste
REFRESH T_UEB_3.
T_UEB_3-TYP = S. "Selektions-Zeile
T_UEB_3-KEY = TEXT-001. "Material "Key
* die Materialnummer wird hier zum Druck aufbereitet !!!
WRITE : ZW_MATNR TO T_UEB_3-INFO. "Info
APPEND T_UEB_3.
* Suchen Kurztext zum Material in Tabelle T2
CLEAR T_UEB_3-INFO.
LOOP AT T2 WHERE MATNR = ZW_MATNR.
MOVE T2-MAKTX TO T_UEB_3-INFO.
EXIT.
ENDLOOP.
T_UEB_3-KEY = TEXT-031. "Beschreibung
T_UEB_3-TYP = S.
APPEND T_UEB_3.
* Ausgabe eines Kommentarblocks zum Listk鰎per
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = T_UEB_3[].
ENDFORM.
*----------------------------------------------------------------------*
FORM S5300_DIPLAY_STAB3.
* Ausgeben Tabelle STAB3 als einfache Verzweigungsliste
* ALV auch mit leerer Tabelle aufrufen
IF ZW_MESSAGE = '699'. "Liegt eine Meldung vor ?
MESSAGE S699 WITH ZW_MATNR.
ENDIF.
IF FLAG_KWART = X. "Liegt ein Wertmaterial vor ?
* Ausgabe Wertmaterial ohne Mengen
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = G_REPID
IT_FIELDCAT = FIELDCAT_3[]
IT_EVENTS = T_EVENTS_2[]
IT_SORT = T_SORT_2[]
IS_LAYOUT = GS_LAYOUT_2
IMPORTING
E_EXIT_CAUSED_BY_CALLER = G_EXIT_CAUSED_BY_CALLER
ES_EXIT_CAUSED_BY_USER = GS_EXIT_CAUSED_BY_USER
TABLES
T_OUTTAB = STAB3
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
ELSE.
* Ausgabe Material mit Mengen
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = G_REPID
IT_FIELDCAT = FIELDCAT_2[]
IT_EVENTS = T_EVENTS_2[]
IT_SORT = T_SORT_2[]
IS_LAYOUT = GS_LAYOUT_2
IMPORTING
E_EXIT_CAUSED_BY_CALLER = G_EXIT_CAUSED_BY_CALLER
ES_EXIT_CAUSED_BY_USER = GS_EXIT_CAUSED_BY_USER
TABLES
T_OUTTAB = STAB3
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
ENDIF.
IF NOT SY-SUBRC IS INITIAL. "Fehler vom ALV ?
MOVE 'RW' TO SY-UCOMM. "Do-Schleife beenden
MESSAGE ID SY-MSGID TYPE S NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.
*----------------------------------------------------------------------*
FORM S5400_FUELLEN_STAB3.
* die n鋍hste Materialnummer ZW_MATNR ist gef黮lt
CLEAR : STAB3, FLAG_KWART, ZW_MESSAGE.
REFRESH : STAB3.
LOOP AT STAB WHERE MATNR = ZW_MATNR.
* Sichern laufende Nummer des Materials
MOVE STAB-COUNT TO ZW_COUNT.
* Nachlesen Text zum Sonderbestand
SELECT SINGLE * FROM T148T WHERE SPRAS = SY-LANGU
AND SOBKZ = STAB-SOBKZ.
IF SY-SUBRC = 0.
MOVE T148T-SOTXT TO STAB3-SOTXT.
ELSE.
CLEAR STAB3-SOTXT.
ENDIF.
MOVE-CORRESPONDING STAB TO STAB3.
COMPUTE : STAB3-WERT = STAB-DMBTR + STAB-VDMBT,
STAB3-MENGE = STAB-DIFMG + STAB-VDIFM,
STAB3-PREIS = STAB-DIFVW + STAB-VDIFV.
COLLECT STAB3.
IF NOT STAB-KWART IS INITIAL. "Liegt ein Wert-Material vor ?
MOVE X TO FLAG_KWART.
ENDIF.
IF NOT STAB-MESSAGE IS INITIAL. "Liegt eine Meldung vor ?
MOVE STAB-MESSAGE TO ZW_MESSAGE.
ENDIF.
ENDLOOP.
SORT STAB3.
ENDFORM.
*EJECT
*----------------------------------------------------------------------*
FORM S6000_EINSTIEG_KOEPFE. "Einstieg 黚er IKPF
SELECT * FROM IKPF INTO TABLE XIKPF WHERE IBLNR IN IM_IBLNR
AND WERKS IN IM_WERKS
AND LGORT IN IM_LGORT
AND INVNU IN IM_INVNU.
* nur weiter, wenn Daten selektiert wurden
check : SY-SUBRC IS INITIAL.
* Pruefen Berechtigung bei Wechsel von Werk
LOOP AT XIKPF.
ON CHANGE OF XIKPF-WERKS.
AUTHORITY-CHECK OBJECT 'M_ISEG_WIB'
ID 'ACTVT' FIELD ACTVT03
ID 'WERKS' FIELD xikpf-WERKS.
IF SY-SUBRC IS INITIAL.
clear auth03.
else.
auth03 = X.
NO_CHANCE = X.
ENDIF.
ENDON.
IF NOT AUTH03 IS INITIAL. "Berechtigung OK ?
DELETE XIKPF.
ENDIF.
ENDLOOP.
* sind noch Daten vorhanden ?
DESCRIBE TABLE XIKPF LINES Z_LINES.
check : not Z_LINES IS INITIAL.
SORT XIKPF BY MANDT IBLNR GJAHR ASCENDING.
* Nachlesen Inventurpositionen zu den Koepfen
SELECT * FROM ISEG "n0377071
INTO corresponding fields of TABLE IISEG
FOR ALL ENTRIES IN XIKPF
WHERE IBLNR = XIKPF-IBLNR
AND GJAHR = XIKPF-GJAHR
* selection for special stocks
and ps_psp_pnr in ra_pspnr_from_to "n513843
and sobkz in ra_sobkz
and kdauf in so_eeauf
and lifnr in ra_lifnr
and kunnr in ra_kunnr.
ENDFORM.
*----------------------------------------------------------------------*
*EJECT
FORM S6100_EINSTIEG_POSITIONEN.
* Lesen Inventur-Positionen
SELECT * FROM ISEG "n0377071
INTO corresponding fields of TABLE IISEG
WHERE IBLNR IN IM_IBLNR
AND MATNR IN IM_MATNR
AND WERKS IN IM_WERKS
AND LGORT IN IM_LGORT
AND CHARG IN IM_CHARG
* selection for special stocks
and ps_psp_pnr in ra_pspnr_from_to "n513843
and sobkz in ra_sobkz
and kdauf in so_eeauf
and lifnr in ra_lifnr
and kunnr in ra_kunnr.
* nur weiter, wenn Inventurbelege vorhanden sind
check : SY-SUBRC IS INITIAL.
* seq. Lesen Tabelle XISEG, loeschen Eintrage,
* - loeschen Eintrage, fuer die der User keine Berechtigung hat
* - Sammeln Belegnummern zum Nachlesen der IKPF
* - Sammeln Materialnummern zum Nachlesen der Kurztexte
REFRESH : PRE_IKPF.
LOOP AT IISEG.
* Pruefen Berechtigung bei Wechsel von Werk
ON CHANGE OF IISEG-WERKS.
AUTHORITY-CHECK OBJECT 'M_ISEG_WIB'
ID 'ACTVT' FIELD ACTVT03
ID 'WERKS' FIELD iiseg-WERKS.
IF SY-SUBRC IS INITIAL.
clear auth03.
else.
auth03 = X.
NO_CHANCE = X.
ENDIF.
ENDON.
IF AUTH03 IS INITIAL. "Berechtigung OK ?
* Belegnummer und Gesch鋐tsjahr sichern
MOVE-CORRESPONDING IISEG TO PRE_IKPF.
COLLECT PRE_IKPF.
ELSE.
* Eintrag loeschen
DELETE IISEG.
ENDIF.
ENDLOOP.
SORT : PRE_IKPF, IISEG.
SORT : XISEG ASCENDING BY MANDT IBLNR GJAHR.
* Nachlesen Belegkoepfe, nur wenn PRE_IKPF gefuellt
describe table pre_ikpf lines z_lines.
if not z_lines is initial.
SELECT * FROM IKPF INTO TABLE XIKPF
FOR ALL ENTRIES IN PRE_IKPF
WHERE IBLNR = PRE_IKPF-IBLNR
AND GJAHR = PRE_IKPF-GJAHR
ORDER BY PRIMARY KEY.
ENDIF.
ENDFORM.
*----------------------------------------------------------------------*
FORM S6110_ENDE_BELEG.
* nur weiter, wenn Tabelle XISEG1 gefuellt ist
DESCRIBE TABLE XISEG1 LINES Z_LINES.
CHECK : Z_LINES > 0.
* Nachlesen Belegkopf in Tabelle XIKPF
READ TABLE XIKPF WITH KEY GRU_ALT_BELEG BINARY SEARCH.
IF SY-SUBRC = 0.
PERFORM S0300_CHECK_STATUS.
* Gibt es noch Positionen zum Beleg ?
DESCRIBE TABLE XISEG1 LINES Z_LINES.
IF Z_LINES > 0.
* Kopf in Tabelle IIKPF aufnehmen
APPEND XIKPF TO IIKPF.
* Positionen in Tabelle XISEG aufnehmen
LOOP AT XISEG1.
APPEND XISEG1 TO XISEG.
ENDLOOP.
ENDIF.
ENDIF.
* Bereiche fuer neue Gruppe loeschen
REFRESH XISEG1.
ENDFORM.
*----------------------------------------------------------------------*
form s9000_check_periode using x9000_periode.
check : not x9000_periode IS INITIAL. "nur wenn was da ist
MOVE : x9000_periode TO ZW_DATUM+0(06),
'01' TO ZW_DATUM+6(02).
CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
EXPORTING DATE = ZW_DATUM
EXCEPTIONS PLAUSIBILITY_CHECK_FAILED = 1.
IF NOT SY-SUBRC IS INITIAL.
SET CURSOR FIELD 'BUCHP-LOW'.
MESSAGE E015.
ENDIF.
ENDFORM.
*----------------------------------------------------------------------*