*& Report ZVVF_MMRO_RM07MLBD *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT ZVVF_MMRO_RM07MLBD NO STANDARD PAGE HEADING MESSAGE-ID M7
LINE-SIZE 95.
************************************************************************
* REPORT RM07MLBD (Transaktionscode MB5B) *
************************************************************************
* ABAP-Preprocessor removed "n599218 A
* - this version is for release 4.6C and higher "n599218 A
* - process database table OBEW always "n599218 A
* - IS-OIL specific functions : "n599218 A
* - define IS-OIL workings fields "n599218 A
* - transport and process these fields only when "n599218 A
* structure MSEG comprise these fields "n599218 A
* Improvements : Dec. 2003 MM "n599218
* - print the page numbers "n599218
* "n599218
* - send warnings and error messages only when report is "n599218
* launched / advoid warnings when user changes entries on "n599218
* the selection screen "n599218
* - send warning M7 689 when user does not restrict the "n599218
* database in dialog or print mode "n599218
* - send warning M7 393 when user deletes the initial "n599218
* display variant "n599218
* "n599218
* - allow to process the fields MAT_KDAUF, MAT_KDPOS, and "n599218
* MAT_PSPNR from release 4.5B and higher "n599218
* "n599218
* - show the current activity and the progress "n599218
* "n599218
* - error message 'programmfehler' improved "n599218
* "n599218
* - new categories for scope of list "n599218
* "n599218
* - use function module for database commit for the update "n599218
* of the parameters in table ESDUS. This allows to record "n599218
* this transaction for a batch input session using "n599218
* transaction SHDB "n599218
* "n599218
* - reset the entries for plant when valuation level is "n599218
* is company code and mode is valuated stock "n599218
* "n599218
* - enable this report to run in the webreporting mode "n599218
* Dec. 2002 MM "n571473
* the definition of the selection screen moved from include "n571473
* RM07MLBP into this report "n571473
* Sept 2002 MM "n555246
* log function tax auditor "n555246
* note 547170 : August 2002 MM "n547170
* - representation of tied empties improved "n547170
* active this function automatically in retail systems "n547170
* - FORM routines without preprocessor commands and without "n547170
* text elements moved to the new include reports "n547170
* RM07MLBD_FORM_01and RM07MLBD_FORM_02 "n547170
* - the function module FI_CHECK_DATE of note 486477 will "n547170
* be processed when it exists "n547170
* - function and documentation of parameter XONUL improved "n547170
* - display MM documents with MIGO or MB03 depending from "n547170
* the release "n547170
* - get and save the parameters per user in dialog mode "n547170
* only in release >= 4.6 "n547170
* the following items were improved with note 497992 "n497992
*
* - wrong results when remaining BSIM entries contain "n497992
* an other quantity unit as material master MEINS "n497992
* - improve check FI summarization "n497992
* - the messages M7 390, M7 391, and M7 392 "n497992
* - definition of field g_f_repid for all releases "n497992
*
* - incomplete key for access of internal table IT134M "n497992
* causes wrong plant selection "n497992
* - the function "no reversal movement" did not surpress "n497992
* the original movements; fields "SJAHR" was moved from "n497992
* from report RM07MLBD_CUST_FIELDS to RM07MLBD "n497992
* - process valuated subcontractor stock from database "n497992
* table OBEW if it exists "n497992
* - if FI summarization is active process warning M7 390 "n497992
* for stock type = valuated stock "n497992
* - the user wants to restrict the movement type : process "n497992
* warning M7 391 "n497992
* - the user wants to surpress the reversal movements : "n497992
* process warning M7 392 "n497992
* - consider special gain/loss-handling of IS-OIL "n497992
* - automatic insert of field WAERS currency key into the "n497992
* field catalogue : "n497992
* - at least one ref. field is active -> WAERS active "n497992
* - all reference fields are hidden -> WAERS hidden "n497992
* - the length of sum fields for values was increased "n497992
* - customizing for the selection of remaining BSIM entries "n497992
* - customizing for the processing of tied empties "n497992
* separate time depending authorization for tax auditor "n486477
* additional fields are displayed in wrong format "n480130
* report RM07MLBD and its includes improved Nov 2001 "n451923
* - merging FI doc number into table G_T_MSEG_LEAN improved "n451923
* - handling of the short texts improved "n451923
* - some types and data definitions -> include RM07MLDD "n451923
*----------------------------------------------------------------------*
* error for split valuation and valuated special stock "n450764
*----------------------------------------------------------------------*
* process 'goods receipt/issue slip' as hidden field "n450596
*----------------------------------------------------------------------*
* error at start date : material without stock has value "n443935
*----------------------------------------------------------------------*
* wrong results for docs with customer consignment "W" "n435403
*----------------------------------------------------------------------*
* error during data selection for plants "n433765
*----------------------------------------------------------------------*
* report RM07MLBD and its includes improved May 10th, 2001 "n400992
*----------------------------------------------------------------------*
* !!! IMPORTANT : DO NOT CHANGE OR DELETE THE COMMENT LINES !!! *
*----------------------------------------------------------------------*
*
* - consider the material number during looking for FI documents
*
* - field "g_cust_color" in include report "RM07MLBD_CUST_FIELDS"
* allows the customer to activate or inactivate the colors in the
* lines with the documents.
*
* - error during calcuation of start stock for special stock "M"
*
* - valuted stocks required : no documents found ? continue and
* process empty document table
*
* - the length of sum fields for quantities has been increased
* to advoid decimal overflow
*
* - table ORGAN is replaced by G_T_ORGAN
* - it is filled by the following ways :
* - at process time at selection screen if the
* user wants the selection via cc or plant
* - otherwise after the database selection of the stock
* tables
* - it contains less data fields
* - it contains all entries twice, for binary search
* with plant or valuation area
*
* - selection of databases MKPF and MSEG in one SELECT
* command with an inner JOIN
*
* - authority checks after the database selections
*
* - result of database selection from the both database tables
* MSEG and MKPF in working table G_F_MSEG_LEAN instead of
* the tables IMSEG and IMKPF
*
* - the number of processed data fields was reduced
* - the user has the possibility to increase the number of
* the processed fields deleting the '*' in the types-command
* in include report RM07MLBD_CUST_FIELDS
*
* - the creation of the field catalog for the ALV considers
* only the fields of structure G_S_MSEG_LEAN
*
* - the new table G_T_BELEG contains the results for the ALV.
* the number of fields of table G_T_BELEG corresponds with
* the number of fields of table G_T_MSEG_LEAN.
*
* - the functions "define breakdown" and "choose" are inactivated
* in the menue, because they are are not carried out correctly
* in all blocks of the list
*
************************************************************************
* *# APP_CALL_DECLARE TEST
*----------------------------------------------------------------------*
* this definitions depend on the release
*----------------------------------------------------------------------*
TYPE-POOLS: IMREP, " Typen Bestandsführungsreporting
SLIS. " Typen Listviewer
* for the selection of the reversal movements only in release >=45B
DATA: BEGIN OF STORNO OCCURS 0,
MBLNR LIKE MSEG-MBLNR,
MJAHR LIKE MSEG-MJAHR,
ZEILE LIKE MSEG-ZEILE,
SMBLN LIKE MSEG-SMBLN,
SJAHR LIKE MSEG-SJAHR,
SMBLP LIKE MSEG-SMBLP,
END OF STORNO.
INCLUDE: ZVVF_MMRO_RM07MLDD,
*include: rm07mldd, " reportspezifische Datendefinitionen
rm07grid. " Gitternetz, Formatierung, Farbgebung
* INCLUDE RM07APP1. "ABAP-PREPROCESSOR "TEST
*-----------------------------------------------------------"n571473
* define the selection screen here "n571473
*-----------------------------------------------------------"n571473
SELECTION-SCREEN BEGIN OF BLOCK Database-selection
WITH FRAME TITLE TEXT-001.
* Text-001: Datenbankabgrenzungen
SELECT-OPTIONS: MATNR FOR MARD-MATNR MEMORY ID MAT
MATCHCODE OBJECT MAT1,
BUKRS FOR T001-BUKRS MEMORY ID BUK,
WERKS FOR T001W-WERKS MEMORY ID WRK,
LGORT FOR T001L-LGORT,
CHARG FOR MCHB-CHARG,
BWTAR FOR MBEW-BWTAR,
BWART FOR MSEG-BWART.
PARAMETERS SOBKZ LIKE MSEG-SOBKZ.
SELECTION-SCREEN SKIP.
SELECT-OPTIONS: DATUM FOR MKPF-BUDAT NO-EXTENSION.
* Datumsintervall für Selektion
SELECTION-SCREEN END OF BLOCK Database-selection.
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK BESTANDSART
WITH FRAME TITLE TEXT-002.
* Text-002: Bestandsart
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS LGBST LIKE AM07M-LGBST RADIOBUTTON GROUP BART DEFAULT 'X'.
SELECTION-SCREEN COMMENT 4(50) TEXT-010 FOR FIELD LGBST.
* Text-010: Lagerort-/Chargenbestand
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS BWBST LIKE AM07M-BWBST RADIOBUTTON GROUP BART.
SELECTION-SCREEN COMMENT 4(50) TEXT-011 FOR FIELD BWBST.
* Text-011: bewerteter Bestand
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS SBBST LIKE AM07M-SBBST RADIOBUTTON GROUP BART.
SELECTION-SCREEN COMMENT 4(50) TEXT-012 FOR FIELD SBBST.
* Text-012: Sonderbestand
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK BESTANDSART.
*----------------------------------------------------------------------*
* improved definition of parameters for scope of list "n599218
SELECTION-SCREEN BEGIN OF BLOCK listumfang
with frame title text-003. "Listumfang
* the following 3 parameters became obsolete do not use "n599218
* anymor. They are still here to inform the user about "n599218
* that he is using old variants or SUBMIT commands "n599218
PARAMETERS : "n599218
XONUL LIKE AM07M-XONUL no-display, "n599218
XVBST LIKE AM07M-XVBST no-display, "n599218
XNVBST LIKE AM07M-XNVBS no-display. "n599218
* 7 new categories for the scope of list "n599218
* "n599218
* cat. I docs I stock on I I stock on I Parameter "n599218
* I I start date I I end date I "n599218
* -----+------+------------+----+----------+---------- "n599218
* 1 I yes I = zero I = I = zero I pa_wdzer "n599218
* 2 I yes I = zero I <> I <> zero I pa_wdzew "n599218
* 3 I yes I <> zero I <> I = zero I pa_wdwiz "n599218
* 4 I yes I <> zero I <> I <> zero I pa_wdwuw "n599218
* 5 I yes I <> zero I = I <> zero I pa_wdwew "n599218
* I I I I I "n599218
* 6 I no I = zero I = I = zero I pa_ndzer "n599218
* 7 I no I <> zero I = I <> zero I pa_ndsto "n599218
* "n599218
* definition of the pushbutton : show or hide the following "n599218
* parameters for the scope of list "n599218
SELECTION-SCREEN PUSHBUTTON /1(20) PB_LIU "n599218
USER-COMMAND LIU. "n599218
"n599218
* text line : materials with movements "n599218
SELECTION-SCREEN BEGIN OF LINE. "n599218
SELECTION-SCREEN COMMENT 1(55) TEXT-072 "n599218
modif id liu. "n599218
SELECTION-SCREEN END OF LINE. "n599218
"n599218
* with movements / start = zero = end = zero "n599218
* 1 I yes I = zero I = I = zero I pa_wdzer "n599218
SELECTION-SCREEN BEGIN OF LINE. "n599218
SELECTION-SCREEN POSITION 2. "n599218
PARAMETERS : pa_wdzer LIKE AM07M-MB5B_XONUL "n599218
modif id liu. "n599218
* text-083 : no opening stock ; no closing stock "n599218
SELECTION-SCREEN COMMENT 5(70) text-083 "n599218
FOR FIELD pa_wdzer "n599218
modif id liu. "n599218
SELECTION-SCREEN END OF LINE. "n599218
"n599218
* with movements / start = zero = end <> zero "n599218
* 2 I yes I = zero I <> I <> zero I pa_wdzew "n599218
SELECTION-SCREEN BEGIN OF LINE. "n599218
SELECTION-SCREEN POSITION 2. "n599218
PARAMETERS : pa_wdzew LIKE AM07M-MB5B_XONUL "n599218
modif id liu. "n599218
* text-084 : no opening stock ; with closing stock "n599218
SELECTION-SCREEN COMMENT 5(70) text-084 "n599218
FOR FIELD pa_wdzew "n599218
modif id liu. "n599218
SELECTION-SCREEN END OF LINE. "n599218
"n599218
* with movements / start stock <> 0 / end stock = 0 "n599218
* 3 I yes I <> zero I <> I = zero I pa_wdwiz "n599218
SELECTION-SCREEN BEGIN OF LINE. "n599218
SELECTION-SCREEN POSITION 2. "n599218
PARAMETERS : pa_wdwiz LIKE AM07M-MB5B_XONUL "n599218
modif id liu. "n599218
* text-085 : with opening stock ; no closing stock "n599218
SELECTION-SCREEN COMMENT 5(70) text-085 "n599218
FOR FIELD pa_wdwiz "n599218
modif id liu. "n599218
SELECTION-SCREEN END OF LINE. "n599218
"n599218
* with movements / with start and end stocks / different "n599218
* 4 I yes I <> zero I <> I <> zero I pa_wdwuw "n599218
SELECTION-SCREEN BEGIN OF LINE. "n599218
SELECTION-SCREEN POSITION 2. "n599218
PARAMETERS : pa_wdwuw LIKE AM07M-MB5B_XONUL "n599218
modif id liu. "n599218
* with opening stock ; with closing stock ; changed "n599218
SELECTION-SCREEN COMMENT 5(70) text-086 "n599218
FOR FIELD pa_wdwuw "n599218
modif id liu. "n599218
SELECTION-SCREEN END OF LINE. "n599218
"n599218
* with movements / with start and end stock / equal "n599218
* 5 I yes I <> zero I = I <> zero I pa_wdwew "n599218
SELECTION-SCREEN BEGIN OF LINE. "n599218
SELECTION-SCREEN POSITION 2. "n599218
PARAMETERS : pa_wdwew LIKE AM07M-MB5B_XONUL "n599218
modif id liu. "n599218
* with opening stock ; with closing stock ; non-changed "n599218
SELECTION-SCREEN COMMENT 5(70) text-087 "n599218
FOR FIELD pa_wdwew "n599218
modif id liu. "n599218
SELECTION-SCREEN END OF LINE. "n599218
"n599218
* text line : materials without movements "n599218
SELECTION-SCREEN BEGIN OF LINE. "n599218
SELECTION-SCREEN COMMENT 1(55) TEXT-073 "n599218
modif id liu. "n599218
SELECTION-SCREEN END OF LINE. "n599218
"n599218
* materials without movements / stocks = zero "n599218
* 6 I no I = zero I = I = zero I pa_ndzer "n599218
SELECTION-SCREEN BEGIN OF LINE. "n599218
SELECTION-SCREEN POSITION 2. "n599218
PARAMETERS : pa_ndzer LIKE AM07M-MB5B_XONUL "n599218
modif id liu. "n599218
* text-083 : no opening stock ; no closing stock "n599218
SELECTION-SCREEN COMMENT 5(70) text-083 "n599218
FOR FIELD pa_ndzer "n599218
modif id liu. "n599218
SELECTION-SCREEN END OF LINE. "n599218
"n599218
* materials without movements / with start or end stock "n599218
* 7 I no I <> zero I = I <> zero I pa_ndsto "n599218
SELECTION-SCREEN BEGIN OF LINE. "n599218
SELECTION-SCREEN POSITION 2. "n599218
PARAMETERS : pa_ndsto LIKE AM07M-MB5B_XONUL "n599218
modif id liu. "n599218
* with opening stock ; with closing stock ; non-changed "n599218
SELECTION-SCREEN COMMENT 5(70) text-087 "n599218
FOR FIELD pa_ndsto "n599218
modif id liu. "n599218
SELECTION-SCREEN END OF LINE. "n599218
"n599218
SELECTION-SCREEN END OF BLOCK listumfang.
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK EINSTELLUNGEN
WITH FRAME TITLE TEXT-068. "Settings
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 1.
PARAMETERS XSUM LIKE AM07M-XSUM.
SELECTION-SCREEN COMMENT 4(50) TEXT-019 FOR FIELD XSUM.
* Text-019: nur Summen
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 1.
PARAMETERS XCHAR LIKE AM07M-XCHRG.
SELECTION-SCREEN COMMENT 4(50) TEXT-015 FOR FIELD XCHAR.
* Text-015: nur chargenpflichtige Materialien
* Das Kennzeichen 'xchar' bestimmt die Art der Listausgabe entweder
* auf Material- oder Chargenebene.
SELECTION-SCREEN END OF LINE.
* the function "No reversal movements" is only "n571473
* available from relaese 4.5B and higher "n571473
* ( TEXT-026 : No reversal movements ) "n571473
SELECTION-SCREEN BEGIN OF LINE. "n571473
SELECTION-SCREEN POSITION 1. "n571473
PARAMETERS NOSTO LIKE AM07M-NOSTO. "n571473
SELECTION-SCREEN COMMENT 4(50) TEXT-026 "n571473
FOR FIELD NOSTO. "n571473
SELECTION-SCREEN END OF LINE. "n571473
SELECTION-SCREEN END OF BLOCK EINSTELLUNGEN.
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK LISTE WITH FRAME TITLE TEXT-040.
PARAMETERS: P_VARI LIKE DISVARIANT-VARIANT.
SELECTION-SCREEN END OF BLOCK LISTE.
*----------------------------------------------------------------------*
*eject
*----------------------------------------------------------------------*
* new data definitions
*----------------------------------------------------------------------*
* working fields for reading structures from DDIC "n599218 A
* and check whether IS-OIL is active "n599218 A
types : stab_x031l type standard table of x031l "n599218 A
with default key. "n599218 A
"n599218 A
data : g_s_x031l type x031l, "n599218 A
g_t_x031l type stab_x031l. "n599218 A
"n599218 A
data : g_f_dcobjdef-name like dcobjdef-name, "n599218 A
g_flag_is_oil_active(01) type c, "n599218 A
g_cnt_is_oil type i. "n599218 A
* contains the a structure with the max. number of fields of
* the database table MSEG, but those lines are comment lines
* with a '*'. The customer can achtivate those lines.
* The activated fields will be selected from the database table
* and are hidden in the list. With the settings in the display
* variant the can be shown.
INCLUDE RM07MLBD_CUST_FIELDS.
* common types structure for working tables
* a) g_t_mseg_lean results form database selection
* b) g_t_beleg data table for ALV
TYPES : BEGIN OF STYPE_MSEG_LEAN,
MBLNR LIKE MKPF-MBLNR,
MJAHR LIKE MKPF-MJAHR,
VGART LIKE MKPF-VGART,
BLART LIKE MKPF-BLART,
BUDAT LIKE MKPF-BUDAT,
CPUDT LIKE MKPF-CPUDT,
CPUTM LIKE MKPF-CPUTM,
USNAM LIKE MKPF-USNAM,
* process 'goods receipt/issue slip' as hidden field "n450596
XABLN LIKE MKPF-XABLN, "n450596
LBBSA LIKE T156M-LBBSA,
BWAGR LIKE T156S-BWAGR,
BUKRS LIKE T001-BUKRS,
BELNR LIKE BKPF-BELNR,
GJAHR LIKE BKPF-GJAHR,
WAERS LIKE MSEG-WAERS,
ZEILE LIKE MSEG-ZEILE,
BWART LIKE MSEG-BWART,
MATNR LIKE MSEG-MATNR,
WERKS LIKE MSEG-WERKS,
LGORT LIKE MSEG-LGORT,
CHARG LIKE MSEG-CHARG,
BWTAR LIKE MSEG-BWTAR,
KZVBR LIKE MSEG-KZVBR,
KZBEW LIKE MSEG-KZBEW,
SOBKZ LIKE MSEG-SOBKZ,
KZZUG LIKE MSEG-KZZUG,
BUSTM LIKE MSEG-BUSTM,
BUSTW LIKE MSEG-BUSTW,
MENGU LIKE MSEG-MENGU,
WERTU LIKE MSEG-WERTU,
SHKZG LIKE MSEG-SHKZG,
MENGE LIKE MSEG-MENGE,
MEINS LIKE MSEG-MEINS,
DMBTR LIKE MSEG-DMBTR,
DMBUM LIKE MSEG-DMBUM,
XAUTO LIKE MSEG-XAUTO,
KZBWS LIKE MSEG-KZBWS,
* special flag for retail "n497992
retail(01) type c, "n497992
* define the fields for the IO-OIL specific functions "n599218 A
* mseg-oiglcalc CHAR 1 "n599218 A
* mseg-oiglsku QUAN 13 "n599218 A
oiglcalc(01) type c, "n599218 A
oiglsku(07) type p decimals 3, "n599218 A
insmk like mseg-insmk, "n599218 A
* the following fields are used for the selection of
* the reversal movements
SMBLN LIKE MSEG-SMBLN, " No. doc
SJAHR LIKE MSEG-SJAHR, " Year "n497992
SMBLP LIKE MSEG-SMBLP. " Item in doc
* additional fields : the user has the possibility to activate
* these fields in the following include report
INCLUDE TYPE STYPE_MB5B_ADD.
TYPES : END OF STYPE_MSEG_LEAN.
TYPES: STAB_MSEG_LEAN TYPE STANDARD TABLE OF STYPE_MSEG_LEAN
WITH KEY MBLNR MJAHR.
* data tables with the results for the ALV
TYPES : BEGIN OF STYPE_BELEGE.
INCLUDE TYPE STYPE_MSEG_LEAN.
TYPES : FARBE TYPE SLIS_T_SPECIALCOL_ALV.
TYPES : END OF STYPE_BELEGE.
TYPES : STAB_BELEGE TYPE STANDARD TABLE OF STYPE_BELEGE
WITH KEY BUDAT MBLNR ZEILE.
DATA : G_T_BELEGE TYPE STAB_BELEGE WITH HEADER LINE,
G_T_BELEGE1 TYPE STAB_BELEGE WITH HEADER LINE.
* global working areas data from MSEG and MKPF
FIELD-SYMBOLS :
DATA : G_S_MSEG_LEAN TYPE STYPE_MSEG_LEAN,
G_S_MSEG_UPDATE TYPE STYPE_MSEG_LEAN, "n443935
G_T_MSEG_LEAN TYPE STAB_MSEG_LEAN.
* working table for the control break "n451923
types : begin of stype_mseg_work. "n451923
include type stype_mseg_lean. "n451923
types : tabix like sy-tabix, "n451923
end of stype_mseg_work, "n451923
"n451923
stab_mseg_work type standard table of "n451923
stype_mseg_work "n451923
with default key. "n451923
"n451923
data : g_t_mseg_work type stab_mseg_work, "n443935
g_s_mseg_work type stype_mseg_work. "n443935
* working table for the requested field name from MSEG and MKPF
TYPES: BEGIN OF STYPE_FIELDS,
FIELDNAME TYPE NAME_FELD,
END OF STYPE_FIELDS.
TYPES: STAB_FIELDS TYPE STANDARD TABLE OF STYPE_FIELDS
WITH KEY FIELDNAME.
DATA: G_T_MSEG_FIELDS TYPE STAB_FIELDS,
G_S_MSEG_FIELDS TYPE STYPE_FIELDS.
* working table for the requested numeric fields of MSEG
types : begin of stype_color_fields,
FIELDNAME TYPE NAME_FELD,
type(01) type c,
end of stype_color_fields,
stab_color_fields type standard table of
stype_color_fields
with default key.
data: g_t_color_fields type stab_color_fields
with header line.
DATA: BEGIN OF IMSWEG OCCURS 1000,
MBLNR LIKE MSEG-MBLNR,
MJAHR LIKE MSEG-MJAHR,
ZEILE LIKE MSEG-ZEILE,
MATNR LIKE MSEG-MATNR,
CHARG LIKE MSEG-CHARG,
BWTAR LIKE MSEG-BWTAR,
WERKS LIKE MSEG-WERKS,
LGORT LIKE MSEG-LGORT,
SOBKZ LIKE MSEG-SOBKZ,
BWART LIKE MSEG-BWART,
SHKZG LIKE MSEG-SHKZG,
XAUTO LIKE MSEG-XAUTO,
MENGE LIKE MSEG-MENGE,
MEINS LIKE MSEG-MEINS,
DMBTR LIKE MSEG-DMBTR,
DMBUM LIKE MSEG-DMBUM,
BUSTM LIKE MSEG-BUSTM,
BUSTW LIKE MSEG-BUSTW, "147374
* define the fields for the IO-OIL specific functions "n599218 A
* mseg-oiglcalc CHAR 1 "n599218 A
* mseg-oiglsku QUAN 13 "n599218 A
oiglcalc(01) type c, "n599218 A
oiglsku(07) type p decimals 3, "n599218 A
insmk like mseg-insmk, "n599218 A
END OF IMSWEG.
* User settings for the checkboxes "n547170
DATA: oref_settings TYPE REF TO cl_mmim_userdefaults. "n547170
*----------------------------------------------------------------------*
*eject
************************ HAUPTPROGRAMM *********************************
*---------------- F4-Hilfe für Reportvariante -------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.
PERFORM f4_for_variant.
*-----------------------------------------------------------"n599218
* INITIALIZATION "n599218
*-----------------------------------------------------------"n599218
"n599218
* pay attentions : this process time will not be processed "n599218
* in the webreporting mode "n599218
INITIALIZATION.
* PERFORM APP_PROCESS USING 'ME'. "TEST
PERFORM initialisierung.
* get the parameters from the last run "n547170
perform esdus_get_parameters. "n547170
* set flag when INITILIZATION is processed
move 'X' to g_flag_initialization.
*-----------------------------------------------------------"n599218
* AT SELECTION-SCREEN "n599218
*-----------------------------------------------------------"n599218
*----------- Prüfung der eingegebenen Selektionsparameter, ------------*
*---------------------- Berechtigungsprüfung --------------------------*
AT SELECTION-SCREEN.
* the following 3 parameters XONUL, XVBST, and XNVBST "n599218
* became obsolete; send error when they should be filled. "n599218
* This could be possible if the user works with old "n599218
* selection variants or this report is launched by a "n599218
* SUBMIT command "n599218
if XONUL is initial and "n599218
XVBST is initial and "n599218
XNVBST is initial. "n599218
* ok, the old parameters are empty "n599218
else. "n599218
* text-088 : note 599218 : obsolete parameter used "n599218
MESSAGE E895 with text-088. "n599218
endif.
* did the user hit the pushbutton "Category" ? "n599218
case SSCRFIELDS-UCOMM. "n599218
when 'LIU '. "n599218
* yes, the pushbutton "Category" was hit "n599218
IF g_flag_status_liu = C_HIDE. "n599218
* show the 7 parameters on the selection srceen "n599218
MOVE C_SHOW TO g_flag_status_liu. "n599218
ELSE. "n599218
* hide the 7 paramaters "n599218
MOVE C_HIDE TO g_flag_status_liu. "n599218
ENDIF. "n599218
ENDcase. "n599218
"n599218
* go on only if the user wants to launch this report "n599218
check : sy-ucomm = 'ONLI' or "n599218
sy-ucomm = 'PRIN' or "n599218
sy-ucomm = 'SJOB'. "n599218
PERFORM eingaben_pruefen.
* check whether FI summarization is active and other "n547170
* restrictions could deliver wrong results "n547170
perform f0800_check_restrictions. "n547170
* - the user wants to surpress the reversal movements : "n497992
* process warning M7 392 "n497992
IF NOT NOSTO IS INITIAL. "n497992
* emerge warning ? "n497992
CALL FUNCTION 'ME_CHECK_T160M' "n497992
EXPORTING "n497992
I_ARBGB = 'M7' "n497992
I_MSGNR = '392' "n497992
EXCEPTIONS "n497992
NOTHING = 0 "n497992
OTHERS = 1. "n497992
"n497992
IF SY-SUBRC <> 0. "n497992
set cursor field 'NOSTO'. "n497992
* to surpress the reversal movements could cause ... "n497992
message w392. "n497992
endif. "n497992
ENDIF. "n497992
* carry out special authotity check for the tax auditor "n547170
perform tpc_check_tax_auditor. "n547170
* does the user wants a selection via company code or a plant ?
* fill range table g_ra_werks
REFRESH : G_RA_BWKEY, G_RA_WERKS, G_T_ORGAN.
CLEAR : G_RA_BWKEY, G_RA_WERKS, G_T_ORGAN, G_S_ORGAN.
REFRESH : G_0000_RA_BWKEY, G_0000_RA_WERKS, G_0000_RA_BUKRS.
CLEAR : G_0000_RA_BWKEY, G_0000_RA_WERKS, G_0000_RA_BUKRS.
DESCRIBE TABLE BUKRS LINES G_F_CNT_LINES_BUKRS.
DESCRIBE TABLE WERKS LINES G_F_CNT_LINES_WERKS.
IF G_F_CNT_LINES_BUKRS > 0 OR
G_F_CNT_LINES_WERKS > 0.
* fill range tables for the CREATION OF TABLE G_T_ORGAN
MOVE : WERKS[] TO G_0000_RA_WERKS[],
BUKRS[] TO G_0000_RA_BUKRS[].
PERFORM F0000_CREATE_TABLE_G_T_ORGAN
USING C_ERROR.
ENDIF.
* save the parameters of this run "n547170
perform esdus_save_parameters. "n547170
*-----------------------------------------------------------"n599218
* AT SELECTION-SCREEN OUTPUT "n599218
*-----------------------------------------------------------"n599218
"n599218
AT SELECTION-SCREEN OUTPUT. "n599218
"n599218
if g_flag_initialization is initial. "n599218
* the process time INITIALIZATION was not done, so "n599218
* carry out the functions here "n599218
move 'X' to g_flag_initialization. "n599218
"n599218
PERFORM initialisierung. "n599218
"n599218
* get the parameters from the last run "n599218
perform esdus_get_parameters. "n599218
endif. "n599218
"n599218
* how to handle the 7 paramaters for the scope of list ? "n599218
LOOP AT SCREEN. "n599218
* modify the selection screen "n599218
case SCREEN-GROUP1. "n599218
when 'LIU'. "n599218
IF g_flag_status_liu = C_SHOW. "n599218
SCREEN-ACTIVE = '1'. "show parameters "n599218
ELSE. "n599218
SCREEN-ACTIVE = '0'. "Hide parameters "n599218
ENDIF. "n599218
"n599218
MODIFY SCREEN. "n599218
endcase. "n599218
ENDLOOP. "n599218
"n599218
* adapt the icon on the pushbutton depending on the status "n599218
CASE g_flag_status_liu. "n599218
WHEN C_HIDE. "n599218
MOVE TEXT-081 TO pb_liu. "@0E\Q@ Scope ... "n599218
WHEN C_SHOW. "n599218
MOVE TEXT-082 TO pb_liu. "@0H\Q@ Scope ... "n599218
WHEN OTHERS. "n599218
ENDCASE. "n599218
"n599218
*-----------------------------------------------------------"n599218
*----------------------------------------------------------------------*
*eject
*------------------------- Datenselektion -----------------------------*
START-OF-SELECTION.
* for the representation of tied empties "n547170
perform f0700_prepare_tied_empties. "n547170
* create table g_t_mseg_fields with the names of all
* wanted fields from MSEG and MKPF
PERFORM F0300_GET_FIELDS.
* set a break-point : is IS-OIL active ? "n599218 A
"n599218 A
* check whether this is a IS-OIL system "n599218 A
perform check_is_oil_system. "n599218 A
"n599218 A
if g_flag_is_oil_active = 'X'. "IS-OIL ? "n599218 A
* the 2 IS-OIL specific data fields will be inserted into "n599218 A
* working table G_T_MSEG_FIELDS. Then these fields will "n599218 A
* transported from database table MSEG, too "n599218 A
append 'MSEG~OIGLCALC' TO G_T_MSEG_FIELDS. "n599218 A
append 'MSEG~OIGLSKU' TO G_T_MSEG_FIELDS. "n599218 A
endif. "n599218 A
* create the ALV fieldcatalog
IF xsum IS INITIAL.
* only if the user wants the whole list with the ALV
MOVE 'G_F_BELEGE' TO G_F_TABNAME.
PERFORM F0400_CREATE_FIELDCAT.
* do not print the ALV-statistics and selection criteria
CLEAR G_S_PRINT.
G_S_PRINT-NO_PRINT_SELINFOS = 'X'.
G_S_PRINT-NO_PRINT_LISTINFOS = 'X'."
ENDIF.
* create the range table for the storage location
PERFORM F0600_CREATE_RANGE_LGORT.
* - show the current activity and the progress "n599218
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR' "n599218
EXPORTING "n599218
TEXT = text-063. "Reading current stocks "n599218
* get the stock tables
PERFORM AKTUELLE_BESTAENDE.
PERFORM tabellen_lesen.
* - show the current activity and the progress "n599218
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR' "n599218
EXPORTING "n599218
TEXT = text-064. "Reading MM documents "n599218
PERFORM F1000_SELECT_MSEG_MKPF.
PERFORM BELEGSELEKTION.
*----------------------------------------------------------------------*
*eject
*-------------------------- Datenausgabe-------------------------------*
END-OF-SELECTION.
* results of all the autority checks
PERFORM F9100_AUTH_PLANT_RESULT.
* - show the current activity and the progress "n599218
IF bwbst = 'X'. "n599218
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR' "n599218
EXPORTING "n599218
TEXT = text-066. "Calculating Stocks and Values "n599218
else. "n599218
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR' "n599218
EXPORTING "n599218
TEXT = text-067. "Calculating Stocks "n599218
endif. "n599218
PERFORM summen_bilden.
PERFORM bestaende_berechnen.
PERFORM listumfang.
* - show the current activity and the progress "n599218
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR' "n599218
EXPORTING "n599218
TEXT = text-065. "Preparing list output "n599218
* stop if table bestand is empty
DESCRIBE TABLE BESTAND LINES G_F_CNT_LINES.
IF G_F_CNT_LINES IS INITIAL.
* Keinen Eintrag zu den Suchbegriffen gefunden/selektiert
MESSAGE S083.
* perform anforderungsbild.
ELSE.
* process log function if the use is a tax auditor "n555246
* and the database selection was successful "n555246
if g_flag_tpcuser = '1'. "n555246
perform tpc_write_log. "n555246
endif. "n555246
PERFORM FELDGRUPPEN_AUFBAUEN.
PERFORM BESTAENDE_AUSGEBEN.
ENDIF.
CLEAR: G_T_MSEG_LEAN, g_t_BSIM_lean, BESTAND. "n443935
*-----------------------------------------------------------"n599218
* top-of-page "n599218
*-----------------------------------------------------------"n599218
"n599218
top-of-page. "n599218
"n599218
* print the page number here when the user wants the "n599218
* totals only ( list without ALV ) only in print mode "n599218
IF not xsum IS INITIAL and "n599218
not sy-prdsn is initial. "n599218
perform print_headline. "n599218
endif. "n599218
"n599218
*-----------------------------------------------------------"n599218
* Aus dieser Unterroutine heraus werden implizit, d.h. in der Schleife
* über alle selektierten Bestände, die zugehörigen Materialbelege
* aufgerufen.
* Die Bestände werden zum Anfangs- und Enddatum als Summen zu
* folgendem Schlüssel, der im Listkopf geführt wird, ausgegeben:
* Buchungskreis bzw. Werk, Material, Charge. Nicht-chargenpflichtige
* Materialien werden auf Materialebene angezeigt.
* Es folgt jeweils eine Liste mit den einzelnen Belegpositionen.
*********************** Ende HAUPTPROGRAMM *****************************
*eject
************************* FORMROUTINEN *********************************
*&---------------------------------------------------------------------*
* & Form EINGABEN_PRUEFEN
*&---------------------------------------------------------------------*
* Prüfung der Eingaben auf dem Selektionsbild *
*----------------------------------------------------------------------*
FORM eingaben_pruefen.
* check the entries only in releases >= 46B
CALL FUNCTION 'MMIM_ENTRYCHECK_MAIN'
TABLES
IT_MATNR = MATNR
IT_WERKS = WERKS
IT_LGORT = LGORT
IT_BWART = BWART
IT_BUKRS = BUKRS.
* Die Selektionseingaben Buchungskreis und Werk werden hierarchisch
* verstanden, d.h. es werden nur Werke innerhalb der angegebenen
* Buchungskreise selektiert.
* Lagerort-/Chargenbestand: Da die Werksbezeichnung eindeutig ist,
* finden alle Selektionen auf Werksebene bzw. - falls mindestens ein
* Lagerort eingegeben wurde - auf der Ebene der eingegebenen Lagerorte
* statt. Die Ausgabe erfolgt auf Werksebene des Materials / der Charge.
* Bewerteter Bestand: Die Ausgabe erfolgt auf Bewertungskreisebene,
* d.h. je nach Einstellung in der Tabelle TCURM auf Werks- oder
* Buchungskreisebene.
* Feststellen, ob der Bewertungskreis auf Buchungskreis- oder
* Werksebene liegt:
* tcurm-bwkrs_cus = 1 => Bewertungskreis auf Werksebene,
* tcurm-bwkrs_cus = 3 => Bewertungskreis auf Buchungskreisebene.
SELECT bwkrs_cus FROM tcurm INTO curm. ENDSELECT.
IF xchar = ' ' AND NOT charg-low IS INITIAL.
xchar = 'X'.
ENDIF.
IF sbbst = 'X' AND sobkz IS INITIAL.
MESSAGE e286.
* Bitte ein Sonderbestandskennzeichen eingeben.
ELSEIF sbbst = ' ' AND NOT sobkz IS INITIAL.
CLEAR sobkz.
MESSAGE w287.
* Sonderbestandskennzeichen wird zurückgesetzt.
ENDIF.
* reset the entries for plant when valuation area is "n599218
* company code and mode is valuated stock "n599218
if curm = '3' and "n599218
bwbst = 'X'. "n599218
if not werks[] is initial. "n599218
* reset the restricts for plants "n599218
clear werks. "n599218
refresh werks. "n599218
* text-074 : valuation area = company code "n599218
* text-075 : entries for plant will be reset "n599218
message w010(ad) with text-074 text-075 space space. "n599218
endif. "n599218
endif. "n599218
IF bwbst = 'X' AND NOT charg IS INITIAL
OR bwbst = 'X' AND NOT xchar IS INITIAL.
CLEAR charg. REFRESH charg.
MESSAGE w285.
* Charge wird zurückgesetzt.
ENDIF.
IF bwbst = 'X' AND NOT lgort IS INITIAL.
CLEAR lgort. REFRESH lgort.
MESSAGE w284.
* Lagerort wird zurückgesetzt.
ENDIF.
* consider and prepare select-options depending on the required
* special stock indicator
REFRESH G_RA_SOBKZ.
CLEAR G_RA_SOBKZ.
IF LGBST = 'X'. "only Storage loc./batch stock
* create ranges table : select only sobkz = space
PERFORM F0500_APPEND_RA_SOBKZ USING C_SPACE.
ELSEIF BWBST = 'X'. "only valuated stocks
* take all special stock indicators / the record selection
* will be done after the database selection
ELSEIF SBBST = 'X'. "only special stocks
PERFORM F0500_APPEND_RA_SOBKZ USING SOBKZ.
IF SOBKZ = 'O' OR
SOBKZ = 'V' OR
SOBKZ = 'W' OR
SOBKZ = 'E' OR
SOBKZ = 'K' OR
SOBKZ = 'M' OR
SOBKZ = 'Q'.
* ok; no aktion taken
ELSE.
SET CURSOR FIELD 'SOBKZ'.
* Sonderbestandskennzeichen nicht vorhanden
MESSAGE E221.
ENDIF.
ENDIF.
IF bwbst = 'X' AND NOT bwart IS INITIAL.
CLEAR bwart. REFRESH bwart.
MESSAGE w298.
* Bewegungsart wird zurückgesetzt
ENDIF.
IF bwbst = ' ' AND NOT bwtar IS INITIAL.
CLEAR bwtar. REFRESH bwtar.
MESSAGE w288.
* Bewertungsart wird zurückgesetzt.
ENDIF.
* The function "no cancellations" is not possible
* for valuated stock
* for the selection of the reversal movements only in release >=45B
IF NOSTO = 'X' AND BWBST = 'X'. "204463
MESSAGE E151(E1) WITH 'VALUATED_STOCK' "204463
'NO_CANCELLATIONS'. "204463
ENDIF. "204463
IF NOT p_vari IS INITIAL.
MOVE variante TO def_variante.
MOVE p_vari TO def_variante-variant.
CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
EXPORTING
i_save = variant_save
CHANGING
cs_variant = def_variante.
variante = def_variante.
ELSE.
* the user wants no initial display variant "n599218
if not alv_default_variant is initial. "n599218
* but the SAP-LIST-VIEWER will apply the existing "n599218
* initial display variant / emerge warning 393 ? "n599218
CALL FUNCTION 'ME_CHECK_T160M' "n599218
EXPORTING "n599218
I_ARBGB = 'M7' "n599218
I_MSGNR = '393' "n599218
EXCEPTIONS "n599218
NOTHING = 0 "n599218
OTHERS = 1. "n599218
"n599218
IF SY-SUBRC <> 0. "n599218
* list will be created using the initial layout & "n599218
message w393(M7) with alv_default_variant. "n599218
endif. "n599218
endif. "n599218
CLEAR variante.
variante-report = repid.
ENDIF.
ENDFORM. " EINGABEN_PRÜFEN
*&---------------------------------------------------------------------*
*eject
*eject
*---------------------- bewerteter Bestand ----------------------------*
FORM AKTUELLE_BST_BWBST.
* define local working areas / for the result of the "n450764
* database selections and the control break "n450764
DATA : L_T_MBEW TYPE STAB_MBEW, "n450764
L_S_MBEW TYPE STYPE_MBEW, "n450764
"n450764
L_S_MBEW_SPLIT TYPE STYPE_MBEW, "n450764
L_S_MBEW_NORMAL TYPE STYPE_MBEW, "n450764
L_FLAG_SPLIT(01) TYPE C. "n450764
"n450764
* read the matching valuation entries "n450764
SELECT MATNR BWKEY BWTAR LBKUM SALK3 FROM MBEW "n450764
INTO CORRESPONDING FIELDS OF TABLE L_T_MBEW "n450764
WHERE MATNR IN MATNR "n450764
AND BWKEY IN G_RA_BWKEY "n450764
AND BWTAR IN BWTAR. "n450764
"n450764
IF SY-SUBRC NE 0. "n450764
MESSAGE S289. "n450764
* Kein Material in Selektion vorhanden. "n450764
PERFORM ANFORDERUNGSBILD. "n450764
ENDIF. "n450764
"n450764
* read the matching valuation records of the valuated "n450764
* special stock sales order "n450764
SELECT MATNR BWKEY BWTAR "n450764
SUM( LBKUM ) AS LBKUM "n450764
SUM( SALK3 ) AS SALK3 FROM EBEW "n450764
APPENDING CORRESPONDING FIELDS OF TABLE L_T_MBEW "n450764
WHERE MATNR IN MATNR "n450764
AND BWKEY IN G_RA_BWKEY "n450764
AND BWTAR IN BWTAR "n450764
GROUP BY MATNR BWKEY BWTAR. "n450764
"n450764
* read the matching valuation records of the valuated "n450764
* special stock projects "n450764
SELECT MATNR BWKEY BWTAR "n450764
SUM( LBKUM ) AS LBKUM "n450764
SUM( SALK3 ) AS SALK3 FROM QBEW "n450764
APPENDING CORRESPONDING FIELDS OF TABLE L_T_MBEW "n450764
WHERE MATNR IN MATNR "n450764
AND BWKEY IN G_RA_BWKEY "n450764
AND BWTAR IN BWTAR "n450764
GROUP BY MATNR BWKEY BWTAR. "n450764
* read the matching valuation records of the valuated "n497992
* special subcontractor stock OBEW "n497992
SELECT MATNR BWKEY BWTAR "n497992
SUM( LBKUM ) AS LBKUM "n497992
SUM( SALK3 ) AS SALK3 FROM OBEW "n497992
APPENDING CORRESPONDING FIELDS OF TABLE L_T_MBEW "n497992
WHERE MATNR IN MATNR "n497992
AND BWKEY IN G_RA_BWKEY "n497992
AND BWTAR IN BWTAR "n497992
GROUP BY MATNR BWKEY BWTAR. "n497992
* create table g_t_organ if it is still empty
IF G_T_ORGAN[] IS INITIAL. "n433765
* create working table G_0000_RA_BWKEY with the valuation areas
LOOP AT L_T_MBEW INTO L_S_MBEW. "n450764
ON CHANGE OF L_S_MBEW-BWKEY. "n450764
MOVE : L_S_MBEW-BWKEY "n450764
TO G_0000_RA_BWKEY-LOW, "n450764
'I' TO G_0000_RA_BWKEY-SIGN, "n450764
'EQ' TO G_0000_RA_BWKEY-OPTION. "n450764
COLLECT G_0000_RA_BWKEY. "n450764
ENDON. "n450764
ENDLOOP.
PERFORM F0000_CREATE_TABLE_G_T_ORGAN
USING C_NO_ERROR.
ENDIF.
SORT L_T_MBEW BY MATNR BWKEY. "n450764
"n450764
LOOP AT L_T_MBEW INTO L_S_MBEW. "n450764
* process a single entry / add the stock and value "n450764
IF L_S_MBEW-BWTAR IS INITIAL. "n450764
MOVE : L_S_MBEW-MATNR TO L_S_MBEW_NORMAL-MATNR, "n450764
L_S_MBEW-BWKEY TO L_S_MBEW_NORMAL-BWKEY. "n450764
ADD : L_S_MBEW-LBKUM TO L_S_MBEW_NORMAL-LBKUM, "n450764
L_S_MBEW-SALK3 TO L_S_MBEW_NORMAL-SALK3. "n450764
ELSE. "n450764
* material has split valuation "n450764
MOVE : 'X' TO L_FLAG_SPLIT, "n450764
L_S_MBEW-MATNR TO L_S_MBEW_SPLIT-MATNR, "n450764
L_S_MBEW-BWKEY TO L_S_MBEW_SPLIT-BWKEY. "n450764
ADD : L_S_MBEW-LBKUM TO L_S_MBEW_SPLIT-LBKUM, "n450764
L_S_MBEW-SALK3 TO L_S_MBEW_SPLIT-SALK3. "n450764
ENDIF. "n450764
"n450764
* control break after material and valuation area "n450764
AT END OF BWKEY. "n450764
* create a entry for the next working table "n450764
IF L_FLAG_SPLIT = 'X'. "n450764
* if the material has split valuation, take only "n450764
* the sums from the entries with valuation type "n450764
MOVE-CORRESPONDING L_S_MBEW_SPLIT TO G_S_MBEW. "n450764
ELSE. "n450764
MOVE-CORRESPONDING L_S_MBEW_NORMAL TO G_S_MBEW. "n450764
ENDIF. "n450764
"n450764
* check the authority "n450764
PERFORM F9300_READ_ORGAN "n450764
USING C_BWKEY G_S_MBEW-BWKEY. "n450764
"n450764
IF SY-SUBRC IS INITIAL. "n450764
* enrich the entries with the field currency key "n450764
MOVE G_S_ORGAN-WAERS TO G_S_MBEW-WAERS. "n450764
APPEND G_S_MBEW TO G_T_MBEW. "n450764
"n450764
* create the key table for the material texts "n450764
PERFORM F9400_MATERIAL_KEY "n450764
USING G_S_MBEW-MATNR. "n450764
ENDIF. "n450764
"n450764
* clear the working areas for the next group "n450764
CLEAR : L_FLAG_SPLIT, L_S_MBEW_NORMAL, L_S_MBEW_SPLIT."n450764
ENDAT. "n450764
ENDLOOP. "n450764
* no entries left in table g_t_mbew ?
IF G_T_MBEW[] IS INITIAL. "n450764
MESSAGE S289.
* Kein Material in Selektion vorhanden.
PERFORM ANFORDERUNGSBILD.
ENDIF.
ENDFORM. "aktuelle_bst_bwbst
*&---------------------------------------------------------------------*
*eject
*&---------------------------------------------------------------------*
* & Form BEWEGUNGSARTEN_LESEN
*&---------------------------------------------------------------------*
* Lesen der Tabellen zur Bewegungsart *
*----------------------------------------------------------------------*
FORM BEWEGUNGSARTEN_LESEN.
DATA: BEGIN OF K2 OCCURS 0,
BWART LIKE T156S-BWART,
END OF K2.
REFRESH K2.
* select the movement types from the selected documents
LOOP AT G_T_MSEG_LEAN INTO G_S_MSEG_LEAN.
MOVE G_S_MSEG_LEAN-BWART TO K2-BWART.
COLLECT K2.
ENDLOOP.
* Read data for movement type from new tables
* T156SY/C/Q with function module from release >=46B
DATA: T_ST156S LIKE ST156S OCCURS 0
WITH HEADER LINE.
REFRESH IT156.
LOOP AT K2.
REFRESH T_ST156S.
CALL FUNCTION 'MB_CONTROL_MOVETYPE_GET'
EXPORTING
I_BWART = K2-BWART
TABLES
TE_ST156S_TAB = T_ST156S
EXCEPTIONS
INCONSISTENT_ENTRIES = 1
NO_ENTRIES_FOUND = 2
OTHERS = 3.
IF SY-SUBRC = 0. "311588
LOOP AT T_ST156S.
MOVE-CORRESPONDING T_ST156S TO IT156.
APPEND IT156.
ENDLOOP.
ENDIF.
ENDLOOP.
SORT IT156 BY BWART WERTU MENGU SOBKZ KZBEW KZZUG KZVBR.
SELECT * FROM T156M INTO CORRESPONDING FIELDS OF TABLE IT156X
FOR ALL ENTRIES IN IT156 WHERE BUSTM EQ IT156-BUSTM.
LOOP AT IT156.
CLEAR IT156-LBBSA.
READ TABLE IT156X WITH KEY BUSTM = IT156-BUSTM.
IT156-LBBSA = IT156X-LBBSA.
MODIFY IT156.
ENDLOOP.
data: rc type i. "147374
LOOP AT G_T_MSEG_LEAN INTO G_S_MSEG_LEAN.
* find and delete reversal movements / only in releases >= 45B
IF NOT NOSTO IS INITIAL AND
NOT ( G_S_MSEG_LEAN-SMBLN IS INITIAL OR
G_S_MSEG_LEAN-SMBLP IS INITIAL ).
MOVE-CORRESPONDING G_S_MSEG_LEAN
TO STORNO.
APPEND STORNO.
DELETE G_T_MSEG_LEAN.
CONTINUE.
ENDIF.
READ TABLE IT156 WITH KEY BWART = G_S_MSEG_LEAN-BWART
WERTU = G_S_MSEG_LEAN-WERTU
MENGU = G_S_MSEG_LEAN-MENGU
SOBKZ = G_S_MSEG_LEAN-SOBKZ
KZBEW = G_S_MSEG_LEAN-KZBEW
KZZUG = G_S_MSEG_LEAN-KZZUG
KZVBR = G_S_MSEG_LEAN-KZVBR
BINARY SEARCH.
RC = SY-SUBRC. "147374
IF G_S_MSEG_LEAN-BUSTM = SPACE AND
G_S_MSEG_LEAN-BUSTW = SPACE AND
RC = 0. "147374
MOVE : IT156-BUSTM TO G_S_MSEG_LEAN-BUSTM, "147374
IT156-BUSTW TO G_S_MSEG_LEAN-BUSTW. "147374
ENDIF.
if rc = 0. "147374
MOVE : IT156-LBBSA TO G_S_MSEG_LEAN-LBBSA.
IF NOT IT156-BWAGR IS INITIAL.
MOVE : IT156-BWAGR TO G_S_MSEG_LEAN-BWAGR.
ELSE.
MOVE : 'REST' TO G_S_MSEG_LEAN-BWAGR.
ENDIF.
ELSE.
MOVE : 'REST' TO G_S_MSEG_LEAN-BWAGR.
ENDIF. "147374
MODIFY G_T_MSEG_LEAN FROM G_S_MSEG_LEAN.
ENDLOOP.
endform. " BEWEGUNGSARTEN_LESEN
*&---------------------------------------------------------------------*
*eject
*&---------------------------------------------------------------------*
*& Form SUMMEN_BILDEN
*&---------------------------------------------------------------------*
* Bestandssummen zur Berechnung der Bestände *
* zu 'datum-low' und 'datum-high' *
*----------------------------------------------------------------------*
FORM summen_bilden.
* Some explanatory words on the strategy of material
* counting/valuation:
* ======================================================
* 1) Stock overview (no valuation):
* The material document is accepted, if is has not been created
* automatically or if it is not related to movements out of
* the stock. For example, if a stock transfer is posted, the
* system creates a material document with two lines: Out of
* the old stock (accepted) and into the transfer stock (rejected,
* because the material is not yet visible in the target location).
* When the movement into the stock is posted, this is accepted.
* 2) Valuated stock:
* a) Movements within a single plant (MA05, MA06 =
* movement types 313-316) are ignored.
* b) The moving of material out of a plant (303/304)
* is counted and valuated in the emitting plant and
* the target plant. The moving in
* (305/306) is ignored, because
* the valuated stock appears in the target at the
* very moment of leaving the emitter.
* c) Material documents without valuation string are ignored.
*------------- Summen von 'datum-high' bis Gegenwart ------------------*
IF NOT index_2 IS INITIAL.
IF bwbst = ' '.
IF xchar = ' '.
SORT imsweg BY werks matnr shkzg. "auf Materialebene
LOOP AT imsweg.
IF ( imsweg-xauto IS INITIAL ) OR
( imsweg-bustm <> 'MA02' AND imsweg-bustm <> 'MA05' ).
MOVE-CORRESPONDING imsweg TO weg_mat.
COLLECT weg_mat.
ELSE.
DELETE imsweg.
ENDIF.
ENDLOOP.
ELSEIF xchar = 'X'.
SORT imsweg BY werks matnr charg shkzg. "auf Chargenebene
LOOP AT imsweg.
IF ( imsweg-xauto IS INITIAL ) OR
( imsweg-bustm <> 'MA02' AND imsweg-bustm <> 'MA05' ).
MOVE-CORRESPONDING imsweg TO weg_char.
COLLECT weg_char.
ELSE.
DELETE imsweg.
ENDIF.
ENDLOOP.
ENDIF.
ELSEIF bwbst = 'X'.
SORT imsweg BY werks matnr shkzg.
LOOP AT imsweg.
* consider special gain/loss-handling of IS-OIL "n497992
**# IF EXIST OI001
**" IF ( imsweg-bustm <> 'MEU1' ) OR "n497992
**" ( imsweg-bustm = 'MEU1' "n497992
**" AND not imsweg-OIGLCALC IS INITIAL "n497992
**" AND not imsweg-OIGLSKU IS INITIAL ). "n497992
**" MOVE-CORRESPONDING imsweg TO mat_weg. "n497992
**" COLLECT mat_weg. "n497992
**" ELSE. "n497992
**" DELETE imsweg. "n497992
**" ENDIF . "n497992
**# ELSE
* MOVE-CORRESPONDING imsweg TO mat_weg. "n497992
* COLLECT mat_weg. "n497992
**# ENDIF
* IS-OIL specific functions without ABAP preprocessor "n599218 A
if g_flag_is_oil_active = 'X'. "IS-OIL ? "n599218 A
IF ( imsweg-bustm <> 'MEU1' ) OR "n599218 A
( imsweg-bustm = 'MEU1' "n599218 A
AND not imsweg-OIGLCALC IS INITIAL "n599218 A
AND not imsweg-OIGLSKU IS INITIAL ). "n599218 A
MOVE-CORRESPONDING imsweg TO mat_weg. "n599218 A
COLLECT mat_weg. "n599218 A
ELSE. "n599218 A
DELETE imsweg. "n599218 A
ENDIF. "n599218 A
ELSE. "n599218 A
MOVE-CORRESPONDING imsweg TO mat_weg. "n599218 A
COLLECT mat_weg. "n599218 A
ENDIF. "n599218 A
ENDLOOP.
LOOP AT mat_weg.
IF curm = '1'.
mat_weg-bwkey = mat_weg-werks.
ELSEIF curm = '3'.
*
* look for the corresponding valuation area
* READ TABLE organ WITH KEY werks = mat_weg-werks.
* mat_weg-bwkey = organ-bwkey.
PERFORM F9300_READ_ORGAN
USING C_WERKS MAT_WEG-WERKS.
MOVE : G_S_ORGAN-BWKEY TO MAT_WEG-BWKEY.
ENDIF.
MODIFY mat_weg.
ENDLOOP.
IF curm = '3'.
SORT mat_weg BY bwkey matnr shkzg.
LOOP AT mat_weg.
MOVE-CORRESPONDING mat_weg TO mat_weg_buk.
COLLECT mat_weg_buk.
ENDLOOP.
ENDIF.
ENDIF.
ENDIF.
*------------- Summen von 'datum-low' bis 'datum-high' ----------------*
IF bwbst = ' '.
IF xchar = ' '. "auf Materialebene
SORT G_T_MSEG_LEAN BY WERKS MATNR SHKZG DESCENDING.
LOOP AT G_T_MSEG_LEAN INTO G_S_MSEG_LEAN.
IF ( G_S_MSEG_LEAN-XAUTO IS INITIAL ) OR
( G_S_MSEG_LEAN-BUSTM <> 'MA02' AND
G_S_MSEG_LEAN-BUSTM <> 'MA05' ).
MOVE-CORRESPONDING G_S_MSEG_LEAN TO SUM_MAT.
COLLECT SUM_MAT.
ELSE.
DELETE G_T_MSEG_LEAN.
ENDIF.
ENDLOOP.
ELSEIF xchar = 'X'. "auf Chargenebene
SORT G_T_MSEG_LEAN BY WERKS MATNR CHARG SHKZG DESCENDING.
LOOP AT G_T_MSEG_LEAN INTO G_S_MSEG_LEAN.
IF ( G_S_MSEG_LEAN-XAUTO IS INITIAL ) OR
( G_S_MSEG_LEAN-BUSTM <> 'MA02' AND
G_S_MSEG_LEAN-BUSTM <> 'MA05' ).
MOVE-CORRESPONDING G_S_MSEG_LEAN
TO SUM_CHAR.
COLLECT SUM_CHAR.
ELSE.
DELETE G_T_MSEG_LEAN.
ENDIF.
ENDLOOP.
ENDIF.
ELSEIF bwbst = 'X'.
SORT G_T_MSEG_LEAN BY WERKS MATNR SHKZG DESCENDING.
LOOP AT G_T_MSEG_LEAN INTO G_S_MSEG_LEAN.
* consider special gain/loss-handling of IS-OIL "n497992
**# IF EXIST OI001
**" IF ( G_S_MSEG_LEAN-bustm <> 'MEU1' ) OR "n497992
**" ( G_S_MSEG_LEAN-bustm = 'MEU1' "n497992
**" AND not G_S_MSEG_LEAN-OIGLCALC IS INITIAL "n497992
**" AND not G_S_MSEG_LEAN-OIGLSKU IS INITIAL ). "n497992
**# ENDIF
* MOVE-CORRESPONDING G_S_MSEG_LEAN
* TO MAT_SUM.
* COLLECT MAT_SUM.
**# IF EXIST OI001
**" ELSE. "n497992
**" DELETE G_T_MSEG_LEAN. "n497992
**" ENDIF. "n497992
**# ENDIF
* IS-OIL specific functions without ABAP preprocessor "n599218 A
if g_flag_is_oil_active = 'X'. "IS-OIL ? "n599218 A
IF ( G_S_MSEG_LEAN-bustm <> 'MEU1' ) OR "n599218 A
( G_S_MSEG_LEAN-bustm = 'MEU1' "n599218 A
AND not G_S_MSEG_LEAN-OIGLCALC IS INITIAL "n599218 A
AND not G_S_MSEG_LEAN-OIGLSKU IS INITIAL ). "n599218 A
MOVE-CORRESPONDING G_S_MSEG_LEAN "n599218 A
TO MAT_SUM. "n599218 A
COLLECT MAT_SUM. "n599218 A
ELSE. "n599218 A
DELETE G_T_MSEG_LEAN. "n599218 A
ENDIF. "n599218 A
else. "n599218 A
MOVE-CORRESPONDING G_S_MSEG_LEAN "n599218 A
TO MAT_SUM. "n599218 A
COLLECT MAT_SUM. "n599218 A
endif. "n599218 A
ENDLOOP.
LOOP AT mat_sum.
IF curm = '1'.
mat_sum-bwkey = mat_sum-werks.
ELSEIF curm = '3'.
PERFORM F9300_READ_ORGAN
USING C_WERKS MAT_SUM-WERKS.
MOVE : G_S_ORGAN-BWKEY TO MAT_SUM-BWKEY.
ENDIF.
MODIFY mat_sum.
ENDLOOP.
IF curm = '3'. "Materialbelege auf Buchungskreisebene
SORT mat_sum BY bwkey matnr shkzg DESCENDING.
LOOP AT mat_sum.
MOVE-CORRESPONDING mat_sum TO mat_sum_buk.
COLLECT mat_sum_buk.
ENDLOOP.
ENDIF.
ENDIF.
ENDFORM. " SUMMEN_BILDEN
*eject
*&---------------------------------------------------------------------*
*& Form BELEGSELEKTION
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM belegselektion.
* create the title line
* If no date is given at all, the range is set to the maximum
* extend (1.1.0000 - 31.12.9999).
* If only datum-low is set, it is interpreted as the day for
* which the analysis is wanted --> datum-high is filled up.
IF datum-low IS INITIAL.
datum-low = '00000101'.
IF datum-high IS INITIAL.
datum-high = '99991231'.
ENDIF.
ELSE.
IF datum-high IS INITIAL.
datum-high = datum-low.
ENDIF.
ENDIF.
MOVE: datum-low(4) TO jahrlow,
datum-low+4(2) TO monatlow,
datum-low+6(2) TO taglow,
datum-high(4) TO jahrhigh,
datum-high+4(2) TO monathigh,
datum-high+6(2) TO taghigh.
SET TITLEBAR 'MAN'
WITH taglow monatlow jahrlow taghigh monathigh jahrhigh.
* create the headlines using the titelbar "n599218
perform create_headline. "n599218
* does the user wants the valuated stocks ?
IF bwbst = 'X'.
* delete the MM-documents without values
PERFORM unbewertet_weg.
IF G_T_MBEW[] IS INITIAL. "n450764
MESSAGE s289.
* Kein Material in Selektion vorhanden.
PERFORM anforderungsbild.
ENDIF.
* select the corresponding FI-documents
PERFORM FI_BELEGE_LESEN.
ENDIF.
IF SBBST IS INITIAL.
PERFORM KONTIERT_AUSSORTIEREN.
ENDIF.
PERFORM BEWEGUNGSARTEN_LESEN.
* does the user want no reversal movements ? only in releases >=45B
IF NOT NOSTO IS INITIAL.
PERFORM STORNO.
ENDIF.
* does the user wants the valuated stocks ?
IF BWBST = 'X'.
PERFORM BELEGE_ERGAENZEN.
ENDIF.
PERFORM BELEGE_SORTIEREN.
ENDFORM. "BELEGSELEKTION
*&---------------------------------------------------------------------*
*eject
*&--------------------------------------------------------------------*
*& FELDGRUPPEN_AUFBAUEN
*&--------------------------------------------------------------------*
*& create table GRUPPEN with the parameter for special groups *
*&--------------------------------------------------------------------*
FORM FELDGRUPPEN_AUFBAUEN.
* Gruppendefinitionen Positionsfelder
gruppen-sp_group = 'M'.
gruppen-text = text-050.
APPEND gruppen.
gruppen-sp_group = 'B'.
gruppen-text = text-051.
APPEND gruppen.
gruppen-sp_group = 'D'.
gruppen-text = text-052.
APPEND gruppen.
gruppen-sp_group = 'O'.
gruppen-text = text-053.
APPEND gruppen.
gruppen-sp_group = 'K'.
gruppen-text = text-054.
APPEND gruppen.
gruppen-sp_group = 'E'.
gruppen-text = text-055.
APPEND gruppen.
gruppen-sp_group = 'V'.
gruppen-text = text-056.
APPEND gruppen.
gruppen-sp_group = 'F'.
gruppen-text = text-057.
APPEND gruppen.
gruppen-sp_group = 'S'.
gruppen-text = text-058.
APPEND gruppen.
layout-group_buttons = ' '.
ENDFORM. " FELDGRUPPEN_AUFBAUEN.
*&---------------------------------------------------------------------*
*eject
*&---------------------------------------------------------------------*
*& Form UEBERSCHRIFT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM ueberschrift.
IF xsum IS INITIAL. "n599218
* print the page number, etc.. here when the user wants "n599218
* the full list using ALV "n599218
if not sy-prdsn is initial. "n599218
* only in case the list is not displayed on screen "n599218
perform print_headline. "n599218
endif. "n599218
else. "n599218
* the user wants only the sums without ALV "n599218
reserve 9 lines. "n599218
endif. "n599218
IF bwbst = ' '.
move bestand-werks to g_f_werks_retail. "n497992
PERFORM open_grid USING 78 0 'X'.
WRITE 2 text-020.
PERFORM set_format USING 0 space space.
WRITE 16 bestand-werks.
PERFORM F2200_READ_T001 USING BESTAND-WERKS.
WRITE 24 T001W-NAME1.
PERFORM next_row USING 0 'X'.
WRITE 2 text-021.
PERFORM set_format USING 0 space space.
WRITE 16 bestand-matnr.
PERFORM next_row USING 0 'X'.
WRITE 2 text-022.
PERFORM F2100_MAT_TEXT USING BESTAND-MATNR.
PERFORM set_format USING 0 space space.
WRITE 16 G_S_MAKT-MAKTX. "n451923
IF xchar = 'X'.
PERFORM next_row USING 0 'X'.
WRITE 2 text-023.
PERFORM set_format USING 0 space space.
WRITE 16 bestand-charg.
ENDIF.
ELSEIF bwbst = 'X'.
move bestand-bwkey to g_f_werks_retail. "n497992
PERFORM open_grid USING 92 0 'X'.
WRITE 2 text-025.
PERFORM set_format USING 0 space space.
WRITE 19 bestand-bwkey.
PERFORM next_row USING 0 'X'.
WRITE 2 text-021.
PERFORM set_format USING 0 space space.
WRITE 19 bestand-matnr.
HIDE: bestand-matnr, bestand-bwkey.
PERFORM next_row USING 0 'X'.
WRITE 2 text-022.
PERFORM F2100_MAT_TEXT USING BESTAND-MATNR.
PERFORM set_format USING 0 space space.
WRITE 19 G_S_MAKT-MAKTX. "n451923
ENDIF.
* special processing of tied emptied active ? "n497992
if not G_cust_tied_empties is initial. "n497992
perform f9600_tied_empties "n497992
using bestand-matnr "n497992
g_f_werks_retail. "n497992
endif. "n497992
PERFORM close_grid.
PERFORM summensegment.
IF xsum IS INITIAL.
* only if the user wants the whole list with the ALV
PERFORM CLOSE_GRID.
ENDIF.
ENDFORM. " UEBERSCHRIFT
*&---------------------------------------------------------------------*
*eject
*&---------------------------------------------------------------------*
*& Form UEBERSCHRIFT1
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM ueberschrift1.
IF xsum IS INITIAL. "n599218
* print the page number, etc.. here when the user wants "n599218
* the full list using ALV "n599218
if not sy-prdsn is initial. "n599218
* only in case the list is not displayed on screen "n599218
perform print_headline. "n599218
endif. "n599218
else. "n599218
* the user wants only the sums without ALV "n599218
reserve 9 lines. "n599218
endif. "n599218
IF bwbst = ' '.
move bestand1-werks to g_f_werks_retail. "n497992
PERFORM open_grid USING 78 0 'X'.
WRITE 2 text-020.
PERFORM set_format USING 0 space space.
WRITE 16 bestand1-werks.
PERFORM F2200_READ_T001 USING BESTAND1-WERKS. "note423456
WRITE 24 T001W-NAME1.
PERFORM next_row USING 0 'X'.
WRITE 2 text-021.
PERFORM set_format USING 0 space space.
WRITE 16 bestand1-matnr.
PERFORM next_row USING 0 'X'.
WRITE 2 text-022.
PERFORM F2100_MAT_TEXT USING BESTAND1-MATNR.
PERFORM set_format USING 0 space space.
WRITE 16 G_S_MAKT-MAKTX. "n451923
IF xchar = 'X'.
PERFORM next_row USING 0 'X'.
WRITE 2 text-023.
PERFORM set_format USING 0 space space.
WRITE 16 bestand1-charg.
ENDIF.
ELSEIF bwbst = 'X'.
move bestand1-bwkey to g_f_werks_retail. "n497992
PERFORM open_grid USING 92 0 'X'.
WRITE 2 text-025.
PERFORM set_format USING 0 space space.
WRITE 19 bestand1-bwkey.
PERFORM next_row USING 0 'X'.
WRITE 2 text-021.
PERFORM set_format USING 0 space space.
WRITE 19 bestand1-matnr.
HIDE: bestand1-matnr, bestand1-bwkey.
PERFORM next_row USING 0 'X'.
WRITE 2 text-022.
PERFORM F2100_MAT_TEXT USING BESTAND1-MATNR.
PERFORM set_format USING 0 space space.
WRITE 16 G_S_MAKT-MAKTX. "n451923
ENDIF.
* special processing of tied emptied active ? "n497992
if not G_cust_tied_empties is initial. "n497992
perform f9600_tied_empties "n497992
using bestand1-matnr "n497992
g_f_werks_retail. "n497992
endif. "n497992
PERFORM close_grid.
PERFORM summensegment1.
IF xsum IS INITIAL.
* only if the user wants the whole list with the ALV
PERFORM CLOSE_GRID.
ENDIF.
ENDFORM. " UEBERSCHRIFT1
*&---------------------------------------------------------------------*
*eject
*&---------------------------------------------------------------------*
*& Form SUMMENSEGMENT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM summensegment.
IF bwbst IS INITIAL.
PERFORM next_row USING 3 ' '.
WRITE: 2 text-007, 26 datum-low, "Bestand zum
50 BESTAND-ANFMENGE " Anfangsbestand
UNIT bestand-meins,
74 bestand-meins. " Mengeneinheit
PERFORM next_row USING 3 ' '.
WRITE: 6 TEXT-005, 34 BESTAND-SOLL "Summe der Zugänge
UNIT bestand-meins,
57 bestand-meins.
PERFORM next_row USING 3 ' '.
WRITE: 6 TEXT-006, 34 BESTAND-HABEN "Summe der Abgänge
UNIT bestand-meins,
57 bestand-meins.
PERFORM next_row USING 3 ' '.
WRITE: 2 text-007, 26 datum-high, "Bestand zum
50 BESTAND-ENDMENGE " Endbestand
UNIT bestand-meins,
74 bestand-meins.
ELSEIF NOT bwbst IS INITIAL.
PERFORM next_row USING 3 ' '.
WRITE: 2 text-008, 22 datum-low, "Bestand/Wert zum ...
36 BESTAND-ANFMENGE "Anfangsbestand
UNIT bestand-meins,
60 bestand-meins, "Mengeneinheit
68 bestand-anfwert "Anfangswert
CURRENCY bestand-waers,
87 bestand-waers.
PERFORM next_row USING 3 ' '.
WRITE: 6 TEXT-030, 33 BESTAND-SOLL "Summe/Wert der Zugänge
UNIT bestand-meins,
56 bestand-meins,
63 bestand-sollwert
CURRENCY bestand-waers,
82 bestand-waers.
PERFORM next_row USING 3 ' '.
WRITE: 6 TEXT-031, 33 BESTAND-HABEN "Summe/Wert der Abgänge
UNIT bestand-meins,
56 bestand-meins,
63 bestand-habenwert
CURRENCY bestand-waers,
82 bestand-waers.
PERFORM next_row USING 3 ' '.
WRITE: 2 text-008, 22 datum-high,
36 BESTAND-ENDMENGE "Endbestand
UNIT bestand-meins,
60 bestand-meins,
68 bestand-endwert "Endwert
CURRENCY bestand-waers,
87 bestand-waers.
ENDIF.
ENDFORM. " SUMMENSEGMENT
*&---------------------------------------------------------------------*
*eject
*&---------------------------------------------------------------------*
*& Form SUMMENSEGMENT1
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM summensegment1.
IF bwbst IS INITIAL.
PERFORM next_row USING 3 ' '.
WRITE: 2 text-007, 26 datum-low, "Bestand zum
50 BESTAND1-ANFMENGE " Anfangsbestand
UNIT bestand1-meins,
74 bestand1-meins. " Mengeneinheit
PERFORM next_row USING 3 ' '.
WRITE: 6 TEXT-005, 34 BESTAND1-SOLL "Summe der Zugänge
UNIT bestand1-meins,
57 bestand1-meins.
PERFORM next_row USING 3 ' '.
WRITE: 6 TEXT-006, 34 BESTAND1-HABEN "Summe der Abgänge
UNIT bestand1-meins,
57 bestand1-meins.
PERFORM next_row USING 3 ' '.
WRITE: 2 text-007, 26 datum-high, "Bestand zum
50 BESTAND1-ENDMENGE " Endbestand
UNIT bestand1-meins,
74 bestand1-meins.
ELSEIF NOT bwbst IS INITIAL.
PERFORM next_row USING 3 ' '.
WRITE: 2 text-008, 22 datum-low, "Bestand/Wert zum ...
36 BESTAND1-ANFMENGE "Anfangsbestand
UNIT bestand1-meins,
60 bestand1-meins, "Mengeneinheit
68 bestand1-anfwert "Anfangswert
CURRENCY bestand1-waers,
87 bestand1-waers.
PERFORM next_row USING 3 ' '.
WRITE: 6 TEXT-030, 33 BESTAND1-SOLL "Summe/Wert der Zugänge
UNIT bestand1-meins,
56 bestand1-meins,
63 bestand1-sollwert
CURRENCY bestand1-waers,
82 bestand1-waers.
PERFORM next_row USING 3 ' '.
WRITE: 6 TEXT-031, 33 BESTAND1-HABEN "Summe/Wert der Abgänge
UNIT bestand1-meins,
56 bestand1-meins,
63 bestand1-habenwert
CURRENCY bestand1-waers,
82 bestand1-waers.
PERFORM next_row USING 3 ' '.
WRITE: 2 text-008, 22 datum-high,
36 BESTAND1-ENDMENGE "Endbestand
UNIT bestand1-meins,
60 bestand1-meins,
68 bestand1-endwert "Endwert
CURRENCY bestand1-waers,
87 bestand1-waers.
ENDIF.
ENDFORM. " SUMMENSEGMENT1
*&---------------------------------------------------------------------*
*eject
*&---------------------------------------------------------------------*
*& Form STORNO
*&---------------------------------------------------------------------*
* Stornobewegungen vernachlässigen
*----------------------------------------------------------------------*
* delete the reversal movements from the working
* table with the documents / only in releases >=45B
FORM STORNO.
LOOP AT STORNO.
DELETE G_T_MSEG_LEAN
WHERE MBLNR = STORNO-SMBLN "204463
AND MJAHR = STORNO-SJAHR "204463
AND ZEILE = STORNO-SMBLP. "204463
ENDLOOP.
ENDFORM. " STORNO
*----------------------------------------------------------------------*
*eject
*----------------------------------------------------------------------*
*
* create field catalog for the ALV
* take only the field of structure MSEG_LEAN who are in working
* table g_f_mseg_fields
* --> input name of ALV input data table
* <-- output table wilh the field catalog
*
*----------------------------------------------------------------------*
FORM F0400_CREATE_FIELDCAT.
CLEAR G_S_FIELDCAT.
* lagerort storage location
* the following special stocks O, V, W need no storage location
IF SOBKZ = 'O' OR
SOBKZ = 'V' OR
SOBKZ = 'W'.
ELSE.
G_S_FIELDCAT-FIELDNAME = 'LGORT'.
G_S_FIELDCAT-REF_TABNAME = 'MSEG'.
G_S_FIELDCAT-SP_GROUP = 'O'.
PERFORM F0410_FIELDCAT USING C_TAKE C_OUT.
ENDIF.
* Bewegungsart movement type
G_S_FIELDCAT-FIELDNAME = 'BWART'.
G_S_FIELDCAT-REF_TABNAME = 'MSEG'.
G_S_FIELDCAT-SP_GROUP = 'M'.
PERFORM F0410_FIELDCAT USING C_TAKE C_OUT.
* Sonderbestandskennzeichen Special stock indicator
G_S_FIELDCAT-FIELDNAME = 'SOBKZ'.
G_S_FIELDCAT-REF_TABNAME = 'MSEG'.
G_S_FIELDCAT-SP_GROUP = 'B'.
PERFORM F0410_FIELDCAT USING C_TAKE C_OUT.
* Nummer des Materialbelegs Number of material document
G_S_FIELDCAT-FIELDNAME = 'MBLNR'.
G_S_FIELDCAT-REF_TABNAME = 'MKPF'.
G_S_FIELDCAT-SP_GROUP = 'O'.
PERFORM F0410_FIELDCAT USING C_TAKE C_OUT.
* Position im Materialbeleg Item in material document
G_S_FIELDCAT-FIELDNAME = 'ZEILE'.
G_S_FIELDCAT-REF_TABNAME = 'MSEG'.
G_S_FIELDCAT-SP_GROUP = 'O'.
PERFORM F0410_FIELDCAT USING C_TAKE C_OUT.
IF BWBST = 'X'.
* Nummer Buchhaltungsbeleg Accounting document number
G_S_FIELDCAT-FIELDNAME = 'BELNR'.
G_S_FIELDCAT-REF_TABNAME = 'BSIM'.
G_S_FIELDCAT-SP_GROUP = 'O'.
PERFORM F0410_FIELDCAT USING C_TAKE C_OUT.
ENDIF.
* Buchungsdatum im Beleg Posting date in the document
G_S_FIELDCAT-FIELDNAME = 'BUDAT'.
G_S_FIELDCAT-REF_TABNAME = 'MKPF'.
G_S_FIELDCAT-SP_GROUP = 'D'.
PERFORM F0410_FIELDCAT USING C_TAKE C_OUT.
G_S_FIELDCAT-FIELDNAME = 'MENGE'. " Menge
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. " Quantity
G_S_FIELDCAT-QFIELDNAME = 'MEINS'.
G_S_FIELDCAT-SP_GROUP = 'M'.
PERFORM F0410_FIELDCAT USING C_TAKE C_OUT.
G_S_FIELDCAT-FIELDNAME = 'MEINS'. " Basismengeneinheit
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. " Base unit of measure
G_S_FIELDCAT-SP_GROUP = 'M'.
PERFORM F0410_FIELDCAT USING C_TAKE C_OUT.
IF NOT BWBST IS INITIAL. "mit bewertetem Bestand
* Betrag in Hauswaehrung Amount in local currency
G_S_FIELDCAT-FIELDNAME = 'DMBTR'.
G_S_FIELDCAT-REF_TABNAME = 'BSIM'.
G_S_FIELDCAT-CFIELDNAME = 'WAERS'.
G_S_FIELDCAT-SP_GROUP = 'M'.
PERFORM F0410_FIELDCAT USING C_TAKE C_OUT.
ENDIF. "note 201670
* g_s_fieldcat-fieldname = 'WAERS'. " Waehrungs-schluessel
* g_s_fieldcat-ref_tabname = 'T001'. " Currency Key
* g_s_fieldcat-sp_group = 'M'.
* perform f0410_fieldcat using c_take c_out.
* the following fields are always in g_s_mseg_lean, but they are
* hidden in the list
G_S_FIELDCAT-FIELDNAME = 'MJAHR'. " Materialbelegjahr
G_S_FIELDCAT-REF_TABNAME = 'MKPF'. " Material doc. year
G_S_FIELDCAT-SP_GROUP = 'D'.
PERFORM F0410_FIELDCAT USING C_TAKE C_NO_OUT.
G_S_FIELDCAT-FIELDNAME = 'GJAHR'. " Geschäftsjahr
G_S_FIELDCAT-REF_TABNAME = 'BKPF'. " Fiscal Year
G_S_FIELDCAT-SP_GROUP = 'D'.
PERFORM F0410_FIELDCAT USING C_TAKE C_NO_OUT.
G_S_FIELDCAT-FIELDNAME = 'VGART'. " Vorgangsart
G_S_FIELDCAT-REF_TABNAME = 'MKPF'. " Transaction/event type
G_S_FIELDCAT-SP_GROUP = 'M'.
PERFORM F0410_FIELDCAT USING C_TAKE C_NO_OUT.
G_S_FIELDCAT-FIELDNAME = 'USNAM'. " Name des Benutzers
G_S_FIELDCAT-REF_TABNAME = 'MKPF'. " User name
G_S_FIELDCAT-SP_GROUP = 'O'.
PERFORM F0410_FIELDCAT USING C_TAKE C_NO_OUT.
G_S_FIELDCAT-FIELDNAME = 'CPUDT'. " Tag der Erfassung
G_S_FIELDCAT-REF_TABNAME = 'MKPF'. " Acc. doc. entry date
G_S_FIELDCAT-SP_GROUP = 'D'.
PERFORM F0410_FIELDCAT USING C_TAKE C_NO_OUT.
G_S_FIELDCAT-FIELDNAME = 'CPUTM'. " Uhrzeit der Erfassung
G_S_FIELDCAT-REF_TABNAME = 'MKPF'. " Time of entry
G_S_FIELDCAT-SP_GROUP = 'D'.
PERFORM F0410_FIELDCAT USING C_TAKE C_NO_OUT.
G_S_FIELDCAT-FIELDNAME = 'SHKZG'. " Soll-/Haben-Kennzeichen
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. " Debit/credit indicator
G_S_FIELDCAT-SP_GROUP = 'M'.
PERFORM F0410_FIELDCAT USING C_TAKE C_NO_OUT.
G_S_FIELDCAT-FIELDNAME = 'BWTAR'. " Bewertungsart
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. " Valuation type
G_S_FIELDCAT-SP_GROUP = 'B'.
PERFORM F0410_FIELDCAT USING C_TAKE C_NO_OUT.
* Kennzeichen Bewertung Sonderbestand
* Indicator: valuation of special stock
G_S_FIELDCAT-FIELDNAME = 'KZBWS'.
G_S_FIELDCAT-REF_TABNAME = 'MSEG'.
G_S_FIELDCAT-SP_GROUP = 'B'.
PERFORM F0410_FIELDCAT USING C_TAKE C_NO_OUT.
G_S_FIELDCAT-FIELDNAME = 'CHARG'. " Chargennummer
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. " Batch number
G_S_FIELDCAT-SP_GROUP = 'B'.
PERFORM F0410_FIELDCAT USING C_TAKE C_NO_OUT.
G_S_FIELDCAT-FIELDNAME = 'BUKRS'. " Buchungskreis
G_S_FIELDCAT-REF_TABNAME = 'T001'. " Company code
G_S_FIELDCAT-SP_GROUP = 'O'.
PERFORM F0410_FIELDCAT USING C_TAKE C_NO_OUT.
G_S_FIELDCAT-FIELDNAME = 'KZBEW'. " Bewegungskennzeichen
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. " Movement indicator
G_S_FIELDCAT-SP_GROUP = 'M'.
PERFORM F0410_FIELDCAT USING C_TAKE C_NO_OUT.
G_S_FIELDCAT-FIELDNAME = 'KZVBR'. " Kennz. Verbrauchsbuchung
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. " Consumption posting
G_S_FIELDCAT-SP_GROUP = 'M'.
PERFORM F0410_FIELDCAT USING C_TAKE C_NO_OUT.
G_S_FIELDCAT-FIELDNAME = 'KZZUG'. " Zugangskennzeichen
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. " Receipt indicator
G_S_FIELDCAT-SP_GROUP = 'M'.
PERFORM F0410_FIELDCAT USING C_TAKE C_NO_OUT.
G_S_FIELDCAT-FIELDNAME = 'BUSTM'. " Buchungsstring für Mengen
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. " Posting string for quantities
G_S_FIELDCAT-SP_GROUP = 'B'.
PERFORM F0410_FIELDCAT USING C_TAKE C_NO_OUT.
G_S_FIELDCAT-FIELDNAME = 'BUSTW'. " Buchungsstring für Werte
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. " Posting string for values
G_S_FIELDCAT-SP_GROUP = 'B'.
PERFORM F0410_FIELDCAT USING C_TAKE C_NO_OUT.
* Kennzeichen: Mengenfortschreibung im Materialstammsatz
* Quantity Updating in Material Master Record
G_S_FIELDCAT-FIELDNAME = 'MENGU'.
G_S_FIELDCAT-REF_TABNAME = 'MSEG'.
G_S_FIELDCAT-SP_GROUP = 'B'.
PERFORM F0410_FIELDCAT USING C_TAKE C_NO_OUT.
* Kennzeichen: Wertfortschreibung im Materialstammsatz
* Value Updating in Material Master Record
G_S_FIELDCAT-FIELDNAME = 'WERTU'.
G_S_FIELDCAT-REF_TABNAME = 'MSEG'.
G_S_FIELDCAT-SP_GROUP = 'B'.
PERFORM F0410_FIELDCAT USING C_TAKE C_NO_OUT.
* Bewegungsartengruppe zur Bestandsauswertung
* Movement type group for stock analysis
G_S_FIELDCAT-FIELDNAME = 'BWAGR'.
* the reference table changed in release 46B
g_s_fieldcat-ref_tabname = 'T156Q'.
G_S_FIELDCAT-SP_GROUP = 'M'.
G_S_FIELDCAT-NO_OUT = 'X'. "+SR21092004
PERFORM F0410_FIELDCAT USING C_TAKE C_NO_OUT.
* process 'goods receipt/issue slip' as hidden field "n450596
G_S_FIELDCAT-FIELDNAME = 'XABLN'. "n450596
G_S_FIELDCAT-REF_TABNAME = 'MKPF'. "n450596
G_S_FIELDCAT-SP_GROUP = 'S'. "n450596
PERFORM F0410_FIELDCAT USING C_TAKE C_NO_OUT. "n450596
* the following fields will be processed if they are in working table
* g_t_mseg_fields Customer Exit :
* these fields can be activated in include RM07MLBD_CUST_FIELDS
G_S_FIELDCAT-FIELDNAME = 'INSMK'. " Bestandsart
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. " stock type
G_S_FIELDCAT-SP_GROUP = 'B'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
G_S_FIELDCAT-FIELDNAME = 'LIFNR'. " Kontonummer Lieferant
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. " vendor's account number
G_S_FIELDCAT-SP_GROUP = 'E'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
G_S_FIELDCAT-FIELDNAME = 'KUNNR'. " Kontonummer des Kunden
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. " account number of customer
G_S_FIELDCAT-SP_GROUP = 'V'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
* process the sales order number and sales order item "n599218
* depending on the release "n599218
* release field "n599218
* 4.5B and higher MAT_KDAUF, MAT_KDPOS "n599218
* 4.0B KDAUF, KDPOS "n599218
* "n599218
G_S_FIELDCAT-FIELDNAME = 'MAT_KDAUF'. "n599218
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. "n599218
G_S_FIELDCAT-SP_GROUP = 'V'. "n599218
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT. "n599218
"n599218
G_S_FIELDCAT-FIELDNAME = 'MAT_KDPOS'. "n599218
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. "n599218
G_S_FIELDCAT-SP_GROUP = 'V'. "n599218
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT. "n599218
G_S_FIELDCAT-FIELDNAME = 'KDAUF'. " Kundenauftragsnummer
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. " Sales Order Number
G_S_FIELDCAT-SP_GROUP = 'V'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
G_S_FIELDCAT-FIELDNAME = 'KDPOS'. " Positionsnummer
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. " Item number in Sales Order
G_S_FIELDCAT-SP_GROUP = 'V'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
* Einteilung Kundenauftrag Delivery schedule for sales order
G_S_FIELDCAT-FIELDNAME = 'KDEIN'.
G_S_FIELDCAT-REF_TABNAME = 'MSEG'.
G_S_FIELDCAT-SP_GROUP = 'F'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
* Menge in Erfassungsmengeneinheit Quantity in unit of entry
G_S_FIELDCAT-FIELDNAME = 'ERFMG'.
G_S_FIELDCAT-REF_TABNAME = 'MSEG'.
G_S_FIELDCAT-QFIELDNAME = 'ERFME'.
G_S_FIELDCAT-SP_GROUP = 'M'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
G_S_FIELDCAT-FIELDNAME = 'ERFME'. " Erfassungsmengeneinheit
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. " Unit of entry
G_S_FIELDCAT-SP_GROUP = 'M'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
* Menge in Bestellpreismengeneinheit
* Quantity in purchase order price unit
G_S_FIELDCAT-FIELDNAME = 'BPMNG'.
G_S_FIELDCAT-REF_TABNAME = 'MSEG'.
G_S_FIELDCAT-QFIELDNAME = 'BPRME'.
G_S_FIELDCAT-SP_GROUP = 'E'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
G_S_FIELDCAT-FIELDNAME = 'BPRME'. " Bestellpreismengeneinheit
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. " Order price unit
G_S_FIELDCAT-SP_GROUP = 'E'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
G_S_FIELDCAT-FIELDNAME = 'EBELN'. " Bestellnummer
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. " Purchase order number
G_S_FIELDCAT-SP_GROUP = 'E'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
* Positionsnummer des Einkaufsbelegs
* Item Number of Purchasing Document
G_S_FIELDCAT-FIELDNAME = 'EBELP'.
G_S_FIELDCAT-REF_TABNAME = 'MSEG'.
G_S_FIELDCAT-SP_GROUP = 'E'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
G_S_FIELDCAT-FIELDNAME = 'SJAHR'. " Materialbelegjahr
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. " Material doc. year
G_S_FIELDCAT-SP_GROUP = 'D'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
G_S_FIELDCAT-FIELDNAME = 'SMBLN'. " Nummer des Materialbelegs
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. " Number of material doc.
G_S_FIELDCAT-SP_GROUP = 'O'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
G_S_FIELDCAT-FIELDNAME = 'SMBLP'. " Position im Materialbeleg
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. " Item in material document
G_S_FIELDCAT-SP_GROUP = 'O'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
G_S_FIELDCAT-FIELDNAME = 'ELIKZ'. " Endlieferungskennzeichen
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. "Delivery completed" indicator
G_S_FIELDCAT-SP_GROUP = 'E'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
G_S_FIELDCAT-FIELDNAME = 'SGTXT'. " Positionstext
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. " Item Text
G_S_FIELDCAT-SP_GROUP = 'E'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
G_S_FIELDCAT-FIELDNAME = 'WEMPF'. " Warenempfänger
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. " Goods recipient
G_S_FIELDCAT-SP_GROUP = 'V'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
G_S_FIELDCAT-FIELDNAME = 'ABLAD'. " Abladestelle
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. " Unloading point
G_S_FIELDCAT-SP_GROUP = 'V'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
G_S_FIELDCAT-FIELDNAME = 'GSBER'. " Geschäftsbereich
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. " Business Area
G_S_FIELDCAT-SP_GROUP = 'O'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
* Geschäftsbereich des Geschäftspartners
* Trading partner's business area
G_S_FIELDCAT-FIELDNAME = 'PARGB'.
G_S_FIELDCAT-REF_TABNAME = 'MSEG'.
G_S_FIELDCAT-SP_GROUP = 'O'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
G_S_FIELDCAT-FIELDNAME = 'PARBU'. " Verrechnender Buchungskreis
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. " Clearing company code
G_S_FIELDCAT-SP_GROUP = 'O'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
G_S_FIELDCAT-FIELDNAME = 'KOSTL'. " Kostenstelle
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. " Cost Center
G_S_FIELDCAT-SP_GROUP = 'K'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
G_S_FIELDCAT-FIELDNAME = 'AUFNR'. " Auftragsnummer
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. " Order Number
G_S_FIELDCAT-SP_GROUP = 'K'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
G_S_FIELDCAT-FIELDNAME = 'ANLN1'. " Anlagen-Hauptnummer
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. " Main asset number
G_S_FIELDCAT-SP_GROUP = 'K'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
* Nummer der Reservierung / des Sekundärbedarfs
* Number of reservation/dependent requirements
G_S_FIELDCAT-FIELDNAME = 'RSNUM'.
G_S_FIELDCAT-REF_TABNAME = 'MSEG'.
G_S_FIELDCAT-SP_GROUP = 'B'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
* Positionsnummer der Reservierung / des Sekundärbedarfs
* Item number of reservation/dependent requirements
G_S_FIELDCAT-FIELDNAME = 'RSPOS'.
G_S_FIELDCAT-REF_TABNAME = 'MSEG'.
G_S_FIELDCAT-SP_GROUP = 'B'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
* Final issue for this reservation
G_S_FIELDCAT-FIELDNAME = 'KZEAR'. " Kennzeichen: Endausfassung
G_S_FIELDCAT-REF_TABNAME = 'MSEG'.
G_S_FIELDCAT-SP_GROUP = 'B'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
* empfangendes/abgebendes Material
* Receiving/issuing material
G_S_FIELDCAT-FIELDNAME = 'UMMAT'.
G_S_FIELDCAT-REF_TABNAME = 'MSEG'.
G_S_FIELDCAT-SP_GROUP = 'M'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
* Empfangendes/Abgebendes Werk
* Receiving plant/issuing plant
G_S_FIELDCAT-FIELDNAME = 'UMWRK'.
G_S_FIELDCAT-REF_TABNAME = 'MSEG'.
G_S_FIELDCAT-SP_GROUP = 'M'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
* Empfangender/Abgebender Lagerort
* Receiving/issuing storage location
G_S_FIELDCAT-FIELDNAME = 'UMLGO'.
G_S_FIELDCAT-REF_TABNAME = 'MSEG'.
G_S_FIELDCAT-SP_GROUP = 'M'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
G_S_FIELDCAT-FIELDNAME = 'UMCHA'. " Empfangende/Abgebende Charge
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. " Receiving/issuing batch
G_S_FIELDCAT-SP_GROUP = 'M'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
* Empfangende/Abgebende Bwertungsart
* Valuation type of transfer batch
G_S_FIELDCAT-FIELDNAME = 'UMBAR'.
G_S_FIELDCAT-REF_TABNAME = 'MSEG'.
G_S_FIELDCAT-SP_GROUP = 'M'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
* Sonderbestandskennzeichen der Umlagerung
* Special stock indicator for physical stock transfer
G_S_FIELDCAT-FIELDNAME = 'UMSOK'.
G_S_FIELDCAT-REF_TABNAME = 'MSEG'.
G_S_FIELDCAT-SP_GROUP = 'M'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
* Kennzeichen Wareneingang unbewertet
* Goods receipt, non-valuated
G_S_FIELDCAT-FIELDNAME = 'WEUNB'.
G_S_FIELDCAT-REF_TABNAME = 'MSEG'.
G_S_FIELDCAT-SP_GROUP = 'B'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
* Kennzeichen: Grund der Bewegung
* Reason for movement
G_S_FIELDCAT-FIELDNAME = 'GRUND'.
G_S_FIELDCAT-REF_TABNAME = 'MSEG'.
G_S_FIELDCAT-SP_GROUP = 'M'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
G_S_FIELDCAT-FIELDNAME = 'KSTRG'. " Kostenträger
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. " Cost Object
G_S_FIELDCAT-SP_GROUP = 'K'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
* Nummer für Ergebnisobjekte (CO-PA)
* Profitability segment number (CO-PA)
G_S_FIELDCAT-FIELDNAME = 'PAOBJNR'.
G_S_FIELDCAT-REF_TABNAME = 'MSEG'.
G_S_FIELDCAT-SP_GROUP = 'K'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
G_S_FIELDCAT-FIELDNAME = 'PRCTR'. " Profit Center
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. " Profit Center
G_S_FIELDCAT-SP_GROUP = 'O'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
* Projektstrukturplanelement (PSP-Element)
* Work breakdown structure element (WBS element)
* process the WBS element depends on the release "n599218
* release field "n599218
* 4.5B and higher MAT_PSPNR "n599218
* 4.0B PS_PSP_PNR "n599218
* "n599218
G_S_FIELDCAT-FIELDNAME = 'MAT_PSPNR'. "n599218
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. "n599218
G_S_FIELDCAT-SP_GROUP = 'K'. "n599218
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT. "n599218
G_S_FIELDCAT-FIELDNAME = 'PS_PSP_PNR'.
G_S_FIELDCAT-REF_TABNAME = 'MSEG'.
G_S_FIELDCAT-SP_GROUP = 'K'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
* Netzplannummer für Kontierung
* Network Number for Account Assignment
G_S_FIELDCAT-FIELDNAME = 'NPLNR'.
G_S_FIELDCAT-REF_TABNAME = 'MSEG'.
G_S_FIELDCAT-SP_GROUP = 'K'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
* Plannummer zu Vorgängen im Auftrag
* Routing number for operations in the order
G_S_FIELDCAT-FIELDNAME = 'AUFPL'.
G_S_FIELDCAT-REF_TABNAME = 'MSEG'.
G_S_FIELDCAT-SP_GROUP = 'K'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
G_S_FIELDCAT-FIELDNAME = 'AUFPS'. " Nummer der Auftragsposition
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. " Order item number
G_S_FIELDCAT-SP_GROUP = 'K'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
* Wareneingangsmenge in Bestellmengeneinheit
* Goods receipt quantity in order unit
G_S_FIELDCAT-FIELDNAME = 'BSTMG'.
G_S_FIELDCAT-QFIELDNAME = 'BSTME'.
G_S_FIELDCAT-REF_TABNAME = 'MSEG'.
G_S_FIELDCAT-SP_GROUP = 'E'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
G_S_FIELDCAT-FIELDNAME = 'BSTME'. " Bestellmengeneinheit
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. " Order unit
G_S_FIELDCAT-SP_GROUP = 'E'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
* Extern eingegebener Buchungsbetrag in Hauswährung
* Externally entered posting amount in local currency
G_S_FIELDCAT-FIELDNAME = 'EXBWR'.
G_S_FIELDCAT-REF_TABNAME = 'MSEG'.
G_S_FIELDCAT-CFIELDNAME = 'WAERS'.
G_S_FIELDCAT-SP_GROUP = 'S'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
* Wert zu Verkaufspreisen mit Mehrwertsteuer
* Value at sales prices including value-added tax
G_S_FIELDCAT-FIELDNAME = 'VKWRT'.
G_S_FIELDCAT-REF_TABNAME = 'MSEG'.
G_S_FIELDCAT-CFIELDNAME = 'WAERS'.
G_S_FIELDCAT-SP_GROUP = 'V'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
* Verfallsdatum oder Mindesthaltbarkeitsdatum
* Shelf Life Expiration Date
G_S_FIELDCAT-FIELDNAME = 'VFDAT'.
G_S_FIELDCAT-REF_TABNAME = 'MSEG'.
G_S_FIELDCAT-SP_GROUP = 'B'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
* Extern eingegebener Verkaufswert in Hauswährung
* Externally entered sales value in local currency
G_S_FIELDCAT-FIELDNAME = 'EXVKW'.
G_S_FIELDCAT-REF_TABNAME = 'MSEG'.
G_S_FIELDCAT-CFIELDNAME = 'WAERS'.
G_S_FIELDCAT-SP_GROUP = 'S'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
G_S_FIELDCAT-FIELDNAME = 'PPRCTR'. " Partner-Profit Center
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. " Partner-Profit Center
G_S_FIELDCAT-SP_GROUP = 'O'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
* Material, auf dem der Bestand geführt wird
* Material on which stock is managed
G_S_FIELDCAT-FIELDNAME = 'MATBF'.
G_S_FIELDCAT-REF_TABNAME = 'MSEG'.
G_S_FIELDCAT-SP_GROUP = 'B'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
* Empfangendes/Abgebendes Material
* Receiving/issuing material
G_S_FIELDCAT-FIELDNAME = 'UMMAB'.
G_S_FIELDCAT-REF_TABNAME = 'MSEG'.
G_S_FIELDCAT-SP_GROUP = 'B'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
* Gesamter bewerteter Bestand
* Total valuated stock before the posting
G_S_FIELDCAT-FIELDNAME = 'LBKUM'.
G_S_FIELDCAT-QFIELDNAME = 'MEINS'. "note 201670
G_S_FIELDCAT-REF_TABNAME = 'MSEG'.
G_S_FIELDCAT-SP_GROUP = 'B'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
* Wert des gesamten bewerteten Bestandes
* Value of total valuated stock before the posting
G_S_FIELDCAT-FIELDNAME = 'SALK3'.
G_S_FIELDCAT-CFIELDNAME = 'WAERS'. "note 201670
G_S_FIELDCAT-REF_TABNAME = 'MSEG'.
G_S_FIELDCAT-SP_GROUP = 'B'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
G_S_FIELDCAT-FIELDNAME = 'VPRSV'. " Preissteuerungskennzeichen
G_S_FIELDCAT-REF_TABNAME = 'MSEG'. " Price control indicator
G_S_FIELDCAT-SP_GROUP = 'S'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
* Wert zu Verkaufspreisen ohne Mehrwertsteuer
* Value at sales prices excluding value-added tax
G_S_FIELDCAT-FIELDNAME = 'VKWRA'.
G_S_FIELDCAT-CFIELDNAME = 'WAERS'. "note 201670
G_S_FIELDCAT-REF_TABNAME = 'MSEG'.
G_S_FIELDCAT-SP_GROUP = 'S'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
* Ursprungszeile im Materialbeleg
* Original line in material document
G_S_FIELDCAT-FIELDNAME = 'URZEI'.
G_S_FIELDCAT-REF_TABNAME = 'MSEG'.
G_S_FIELDCAT-SP_GROUP = 'S'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
* Menge in Mengeneinheit aus Lieferschein
* Quantity in unit of measure from delivery note
G_S_FIELDCAT-FIELDNAME = 'LSMNG'.
G_S_FIELDCAT-QFIELDNAME = 'LSMEH'. "note 201670
G_S_FIELDCAT-REF_TABNAME = 'MSEG'.
G_S_FIELDCAT-SP_GROUP = 'M'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
* Mengeneinheit aus Lieferschein
* Unit of measure from delivery note
G_S_FIELDCAT-FIELDNAME = 'LSMEH'.
G_S_FIELDCAT-REF_TABNAME = 'MSEG'.
G_S_FIELDCAT-SP_GROUP = 'M'.
PERFORM F0410_FIELDCAT USING C_CHECK C_NO_OUT.
****
* if the field catalog contains a field with values in currency,
* add the currency to to field-catalogue
data : l_cnt_waers_active type i, "n497992
l_cnt_waers_total type i. "n497992
"n497992
LOOP AT FIELDCAT INTO G_S_FIELDCAT. "n497992
CHECK : G_S_FIELDCAT-CFIELDNAME = 'WAERS'. "n497992
* this field has a reference to the currency key "n497992
add 1 to l_cnt_waers_total. "n497992
"n497992
check : g_s_fieldcat-no_out is initial. "n497992
* this field is active "n497992
add 1 to l_cnt_waers_active. "n497992
endloop. "n497992
"n497992
if l_cnt_waers_active > 0. "n497992
* there is at least one active reference field "n497992
* declare currency key WAERS active, too "n497992
G_S_FIELDCAT-FIELDNAME = 'WAERS'. "Currency Key "n497992
G_S_FIELDCAT-REF_TABNAME = 'T001'. "n497992
G_S_FIELDCAT-SP_GROUP = 'M'. "n497992
PERFORM F0410_FIELDCAT USING C_TAKE C_OUT. "n497992
"n497992
elseif l_cnt_waers_total > 0. "n497992
* there are only hidden reference fields "n497992
* declare currency key WAERS hidden, too "n497992
G_S_FIELDCAT-FIELDNAME = 'WAERS'. "Currency Key "n497992
G_S_FIELDCAT-REF_TABNAME = 'T001'. "n497992
G_S_FIELDCAT-SP_GROUP = 'M'. "n497992
PERFORM F0410_FIELDCAT USING C_TAKE C_no_OUT. "n497992
endif. "n497992
ENDFORM. "f0400_create_fieldcat
*----------------------------------------------------------------------*
*eject
*----------------------------------------------------------------------*
FORM F0410_FIELDCAT
USING L_F_CHECK
L_F_NO_OUT TYPE SLIS_FIELDCAT_MAIN-NO_OUT.
DATA : L_F_CONTINUE(01) TYPE C,
l_f_type(01) type c,
L_F_FIELDNAME TYPE STYPE_FIELDS.
field-symbols :
IF L_F_CHECK = C_TAKE.
* take this entry without check
MOVE 'X' TO L_F_CONTINUE.
ELSE.
* create key and look for fieldname
CONCATENATE G_S_FIELDCAT-REF_TABNAME
'~'
G_S_FIELDCAT-FIELDNAME
INTO L_F_FIELDNAME.
READ TABLE G_T_MSEG_FIELDS INTO G_S_MSEG_FIELDS
WITH KEY
FIELDNAME = L_F_FIELDNAME
BINARY SEARCH.
IF SY-SUBRC IS INITIAL.
MOVE 'X' TO L_F_CONTINUE.
ELSE.
* additional fields are displayed in wrong format : "n480130
* clear the working area for the field catalog when "n480130
* the current field should not be processed "n480130
CLEAR G_S_FIELDCAT. "n480130
CLEAR L_F_CONTINUE.
ENDIF.
ENDIF.
* append entry to field catalog if field is in structure
CHECK : L_F_CONTINUE = 'X'.
IF NOT L_F_NO_OUT IS INITIAL.
MOVE L_F_NO_OUT TO G_S_FIELDCAT-NO_OUT.
ENDIF.
ADD : 1 TO G_F_COL_POS.
MOVE : G_F_COL_POS TO G_S_FIELDCAT-COL_POS,
G_F_TABNAME TO G_S_FIELDCAT-TABNAME.
APPEND G_S_FIELDCAT TO FIELDCAT.
* create the table with the fields who will be enriched with colors
* and sign
if G_S_FIELDCAT-FIELDNAME = 'MENGE' or
G_S_FIELDCAT-FIELDNAME = 'MEINS' or
G_S_FIELDCAT-FIELDNAME = 'DMBTR' or
G_S_FIELDCAT-FIELDNAME = 'WAERS' or
G_S_FIELDCAT-FIELDNAME = 'ERFMG' or
G_S_FIELDCAT-FIELDNAME = 'ERFME' or
G_S_FIELDCAT-FIELDNAME = 'BPMNG' or
G_S_FIELDCAT-FIELDNAME = 'BPRME' or
G_S_FIELDCAT-FIELDNAME = 'BSTMG' or
G_S_FIELDCAT-FIELDNAME = 'BSTME' or
G_S_FIELDCAT-FIELDNAME = 'EXBWR' or
G_S_FIELDCAT-FIELDNAME = 'VKWRT' or
G_S_FIELDCAT-FIELDNAME = 'EXVKW' or
G_S_FIELDCAT-FIELDNAME = 'VKWRA' or
G_S_FIELDCAT-FIELDNAME = 'LSMNG' or
G_S_FIELDCAT-FIELDNAME = 'LSMEH' or
G_S_FIELDCAT-FIELDNAME = 'SHKZG'.
* look for the type of this field
CONCATENATE G_S_FIELDCAT-REF_TABNAME
'-'
G_S_FIELDCAT-FIELDNAME
INTO L_F_FIELDNAME.
ASSIGN (L_F_FIELDNAME) TO
if sy-subrc is initial.
DESCRIBE FIELD
move : G_S_FIELDCAT-FIELDNAME
to g_t_color_fields-fieldname,
l_f_type to g_t_color_fields-type.
append g_t_color_fields.
endif.
endif.
CLEAR G_S_FIELDCAT.
ENDFORM. "F0410_FIELDCAT
*-----------------------------------------------------------"n497992
"n497992
form f9600_tied_empties "n497992
using l_9000_matnr like marc-matnr "n497992
l_9000_werks like marc-werks. "n497992
"n497992
* find out whether this material is a tied empty, if true "n497992
* print a line with an info "n497992
"n497992
* define local working areas "n497992
data : l_wmakg like t134-wmakg, "n497992
l_glgmg like marc-glgmg. "n497992
"n497992
* get the material type "n497992
SELECT single wmakg INTO l_wmakg "n497992
FROM mara AS mara JOIN t134 AS t134 "n497992
ON mara~MANDT = t134~MANDT AND "n497992
mara~mtart = t134~mtart "n497992
WHERE Mara~MATNR = l_9000_matnr. "n497992
"n497992
* entries in MARA and T134 found ? "n497992
check sy-subrc is initial. "n497992
"n497992
* go on if indicator wmakg is '2' "n497992
check l_wmakg = '2'. "n497992
"n497992
* look for the stock of tied empties "n497992
select single glgmg from marc "n497992
into l_glgmg "n497992
where matnr = l_9000_matnr and "n497992
werks = l_9000_werks. "n497992
"n497992
* entry MARC found ? "n497992
check sy-subrc is initial. "n497992
"n497992
* print line "n497992
PERFORM next_row USING 0 'X'. "n497992
"n497992
* caution : material is tied empty "n497992
write : 3 text-060. "n497992
"n497992
endform. "f9600_tied_empties "n497992
"n497992
*-----------------------------------------------------------"n497992
*----------------------------------------------------------------------*
*eject "n443935
*&----------------------------------------------------------"n443935
"n443935
form belege_ergaenzen_2. "n443935
"n443935
* control break : process the entries from a group "n443935
"n443935
* look for the matching FI documents with set and get "n443935
move : g_s_mseg_old-mblnr to matkey-mblnr, "n443935
g_s_mseg_old-mjahr to matkey-mjahr. "n443935
"n443935
read table g_t_bsim_lean into g_s_bsim_lean "n443935
with key Bukrs = g_s_mseg_old-bukrs "n443935
BWKEY = g_s_mseg_old-bwkey "n443935
MATNR = g_s_mseg_old-matnr "n443935
BWTAR = g_s_mseg_old-bwtar "n443935
SHKZG = g_s_mseg_old-shkzg "n443935
MEINS = g_s_mseg_old-meins "n443935
BUDAT = G_S_MSEG_old-BUDAT "n443935
BLART = G_S_MSEG_old-BLART "n443935
AWKEY = MATKEY "n443935
binary search. "n443935
"n443935
if sy-subrc is initial. "n443935
move sy-tabix to g_f_tabix_start. "n443935
"n443935
* continue with sequential read of working table "n443935
loop at g_t_bsim_lean into g_s_bsim_lean "n443935
from g_f_tabix_start. "n443935
"n443935
if g_s_bsim_lean-bukrs = g_s_mseg_old-bukrs and "n443935
g_s_bsim_lean-BWKEY = g_s_mseg_old-bwkey and "n443935
g_s_bsim_lean-MATNR = g_s_mseg_old-matnr and "n443935
g_s_bsim_lean-BWTAR = g_s_mseg_old-bwtar and "n443935
g_s_bsim_lean-SHKZG = g_s_mseg_old-shkzg and "n443935
g_s_bsim_lean-MEINS = g_s_mseg_old-meins and "n443935
g_s_bsim_lean-BUDAT = G_S_MSEG_old-BUDAT and "n443935
g_s_bsim_lean-BLART = G_S_MSEG_old-BLART and "n443935
g_s_bsim_lean-AWKEY = MATKEY. "n443935
* select all matching entries "n443935
add 1 to g_cnt_bsim_entries. "n443935
move-corresponding g_s_bsim_lean "n443935
to g_s_bsim_work. "n443935
move sy-tabix to g_s_bsim_work-tabix. "n443935
append g_s_bsim_work to g_t_bsim_work. "n443935
else. "n443935
exit. "n443935
endif. "n443935
endloop. "n443935
endif. "n443935
"n443935
* set a break-point : results in contol break "n443935
* how many matching entries from BSIM found ? "n443935
if g_cnt_bsim_entries is initial. "n443935
* no BSIM entries found -> no action. "n443935
"n443935
elseif g_cnt_bsim_entries = 1 and "n443935
g_cnt_mseg_entries = 1. "n443935
* the ideal case 1 MM and 1 FI document; "n443935
* mark this FI doc for deletion "n443935
loop at g_t_bsim_work into g_s_bsim_work. "n443935
read table g_t_bsim_lean into g_s_bsim_lean "n443935
index g_s_bsim_work-tabix. "n443935
"n443935
check : sy-subrc is initial. "n443935
move : 'D' to g_s_bsim_lean-accessed. "n443935
modify g_t_bsim_lean from g_s_bsim_lean "n443935
INDEX G_S_BSIM_WORK-TABIX "n443935
TRANSPORTING ACCESSED. "n451923
"n443935
* set the FI doc number into the entry of the MM doc "n443935
read table g_t_mseg_work into g_s_mseg_work "n443935
index 1. "n443935
check : sy-subrc is initial. "n443935
"n443935
MOVE : g_S_BSIM_work-BELNR "n443935
TO G_S_MSEG_work-BELNR, "n443935
g_S_BSIM_work-GJAHR "n443935
TO G_S_MSEG_work-GJAHR. "n443935
* consider special gain/loss-handling of IS-OIL "n497992
**# IF EXIST OI001
**" if g_s_mseg_work-oiglcalc = 'L' and "n497992
**" g_s_mseg_work-shkzg = 'H' and "n497992
**" g_s_mseg_work-dmbtr = 0. "n497992
**" move g_s_bsim_work-dmbtr "n497992
**" to g_s_mseg_work-dmbtr. "n497992
**" endif. "n497992
**" "n497992
**" MODIFY G_T_MSEG_work "n497992
**" FROM G_S_MSEG_work "n497992
**" INDEX 1 "n497992
**" TRANSPORTING BELNR GJAHR dmbtr. "n497992
**# ELSE
* MODIFY G_T_MSEG_work FROM G_S_MSEG_work "n443935
* INDEX 1 "n443935
* TRANSPORTING BELNR GJAHR. "n443935
**# ENDIF
* IS-OIL specific functions without ABAP preprocessor "n599218 A
if g_flag_is_oil_active = 'X'. "IS-OIL ? "n599218 A
if g_s_mseg_work-oiglcalc = 'L' and "n599218 A
g_s_mseg_work-shkzg = 'H' and "n599218 A
g_s_mseg_work-dmbtr = 0. "n599218 A
move g_s_bsim_work-dmbtr "n599218 A
to g_s_mseg_work-dmbtr. "n599218 A
endif. "n599218 A
"n599218 A
MODIFY G_T_MSEG_work "n599218 A
FROM G_S_MSEG_work "n599218 A
INDEX 1 "n599218 A
TRANSPORTING BELNR GJAHR dmbtr. "n599218 A
ELSE. "n599218 A
MODIFY G_T_MSEG_work FROM G_S_MSEG_work "n599218 A
INDEX 1 "n599218 A
TRANSPORTING BELNR GJAHR. "n599218 A
ENDIF. "n599218 A
endloop. "n443935
"n443935
else. "n443935
* there are a lot of MM docs "n443935
perform belege_ergaenzen_several_docs. "n443935
"n443935
endif. "n443935
"n443935
* copy the number and fiscal year into the matching "n451923
* entry of the main table G_T_MSEG_LEAN "n451923
loop at g_t_mseg_work into g_s_mseg_work. "n451923
* only with useful FI doc data "n451923
check : not g_s_mseg_work-belnr is initial. "n451923
"n443935
* read the original entry and change it "n451923
read table g_t_mseg_lean into g_s_mseg_update "n451923
index g_s_mseg_work-tabix. "n451923
"n443935
check : sy-subrc is initial. "entry found ? "n451923
move : g_s_mseg_work-belnr "n451923
to g_s_mseg_update-belnr, "n451923
g_s_mseg_work-gjahr "n451923
to g_s_mseg_update-gjahr. "n451923
* consider special gain/loss-handling of IS-OIL "n497992
**# IF EXIST OI001
**" move g_s_mseg_work-dmbtr "n497992
**" to g_s_mseg_update-dmbtr. "n497992
**" "n497992
**" MODIFY G_T_MSEG_lean "n497992
**" FROM G_S_MSEG_update "n497992
**" index g_s_mseg_work-tabix "n497992
**" TRANSPORTING BELNR GJAHR dmbtr. "n497992
**# ELSE
* modify g_t_mseg_lean from g_s_mseg_update "n451923
* index g_s_mseg_work-tabix "n451923
* transporting belnr gjahr. "n451923
**# ENDIF
* IS-OIL specific functions without ABAP preprocessor "n599218 A
if g_flag_is_oil_active = 'X'. "IS-OIL ? "n599218 A
move g_s_mseg_work-dmbtr "n599218 A
to g_s_mseg_update-dmbtr. "n599218 A
"n599218 A
MODIFY G_T_MSEG_lean "n599218 A
FROM G_S_MSEG_update "n599218 A
index g_s_mseg_work-tabix "n599218 A
TRANSPORTING BELNR GJAHR dmbtr. "n599218 A
ELSE. "n599218 A
modify g_t_mseg_lean from g_s_mseg_update "n599218 A
index g_s_mseg_work-tabix "n599218 A
transporting belnr gjahr. "n599218 A
ENDIF. "n599218 A
endloop. "n451923
perform belege_ergaenzen_clear. "n443935
"n443935
endform. "belege_ergaenzen_2 "n443935
"n443935
*&----------------------------------------------------------"n443935
*eject "n443935
*&----------------------------------------------------------"n443935
"n443935
form belege_ergaenzen_clear. "n443935
"n443935
* clear working areas for the next group "n443935
refresh : g_t_bsim_work, g_t_mseg_work. "n443935
clear : g_cnt_mseg_entries, g_cnt_mseg_done, "n443935
g_cnt_bsim_entries. "n443935
"n443935
endform. "belege_ergaenzen_clear. "n443935
"n443935
*&----------------------------------------------------------"n443935
"n443935
form belege_ergaenzen_several_docs. "n443935
"n443935
* first step : the entries must hit quantity and value "n443935
loop at g_t_mseg_work into g_s_mseg_work. "n443935
"n443935
* look for a matching FI doc "n443935
loop at g_t_bsim_work into g_s_bsim_work. "n443935
* ingnore the entries for deletion "n443935
check : g_s_bsim_work-accessed ne 'D'. "n443935
"n443935
if g_s_bsim_work-menge = g_s_mseg_work-menge and "n443935
g_s_bsim_work-dmbtr = g_s_mseg_work-dmbtr. "n443935
* mark the entries "n443935
ADD 1 TO G_CNT_MSEG_DONE. "n443935
MOVE : g_S_BSIM_work-BELNR "n443935
TO G_S_MSEG_work-BELNR, "n443935
g_S_BSIM_work-GJAHR "n443935
TO G_S_MSEG_work-GJAHR. "n443935
MODIFY G_T_MSEG_WORK FROM G_S_MSEG_WORK "n443935
TRANSPORTING BELNR GJAHR. "n451923
"n443935
* mark the entries for deletion "n443935
MOVE 'D' TO G_S_BSIM_WORK-ACCESSED. "n443935
MODIFY G_T_BSIM_WORK FROM G_S_BSIM_WORK "n443935
TRANSPORTING ACCESSED. "n451923
exit. "Stop at the firts hit "n443935
endif. "n443935
endloop. "n443935
endloop. "n443935
"n443935
* set a break-point : in control break after the 1st step "n443935
if g_cnt_mseg_entries ne g_cnt_mseg_done. "n443935
* there are MM docs without FI doc left "n443935
"n443935
* subtract the quantity and value from MM doc from "n443935
* the fields of the FI doc "n443935
loop at g_t_mseg_work into g_s_mseg_work. "n443935
"n443935
* take only the entries without FI doc number "n443935
check : G_S_MSEG_work-BELNR is initial. "n443935
"n443935
loop at g_t_bsim_work into g_s_bsim_work. "n443935
* ingnore the entries for deletion "n443935
check : g_s_bsim_work-accessed ne 'D'. "n443935
"n443935
if g_s_bsim_work-menge ge g_s_mseg_work-menge and "n443935
g_s_bsim_work-dmbtr ge g_s_mseg_work-dmbtr. "n443935
"n443935
subtract : "n443935
G_S_MSEG_work-MENGE FROM G_S_BSIM_work-MENGE, "n443935
G_S_MSEG_work-DMBTR FROM g_S_BSIM_work-DMBTR. "n443935
"n443935
if g_s_bsim_work-menge is initial and "n443935
g_s_bsim_work-dmbtr is initial. "n443935
* mark the entry for deletion "n443935
MOVE 'D' TO g_S_BSIM_work-ACCESSED. "n443935
else. "n443935
* set the flag for check the merge process "n443935
MOVE 'X' TO g_S_BSIM_work-ACCESSED. "n443935
endif. "n443935
"n443935
MODIFY G_T_BSIM_WORK FROM G_S_BSIM_WORK "n443935
TRANSPORTING ACCESSED. "n451923
"n443935
* mark the entries "n443935
add 1 to g_cnt_mseg_done. "n443935
MOVE : g_S_BSIM_work-BELNR "n443935
TO G_S_MSEG_work-BELNR, "n443935
g_S_BSIM_work-GJAHR "n443935
TO G_S_MSEG_work-GJAHR. "n443935
MODIFY G_T_MSEG_WORK FROM G_S_MSEG_WORK "n443935
TRANSPORTING BELNR GJAHR. "n451923
exit. "Stop at the first hit "n443935
endif. "n443935
endloop. "n443935
endloop. "n443935
endif. "n443935
"n443935
* mark the processed FI docs for deletion "n443935
loop at g_t_bsim_work into g_s_bsim_work. "n443935
check g_s_bsim_work-accessed = 'D'. "n443935
"n443935
read table g_t_bsim_lean into g_s_bsim_lean "n443935
index g_s_bsim_work-tabix. "n443935
"n443935
check : sy-subrc is initial. "n443935
move : 'D' to g_s_bsim_lean-accessed. "n443935
modify g_t_bsim_lean from g_s_bsim_lean "n443935
INDEX G_S_BSIM_WORK-TABIX "n443935
TRANSPORTING ACCESSED. "n451923
endloop. "n443935
"n443935
endform. "belege_ergaenzen_several_docs "n443935
"n443935
*&----------------------------------------------------------"n443935
*eject
*&---------------------------------------------------------------------*
*& Form USER_COMMAND *
*&---------------------------------------------------------------------*
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
TYPES: BEGIN OF ty_s_sel,
MBLNR LIKE MSEG-MBLNR,
MJAHR LIKE MSEG-MJAHR,
ZEILE LIKE MSEG-ZEILE,
BUKRS LIKE MSEG-BUKRS,
BELNR LIKE MSEG-BELNR,
GJAHR LIKE MSEG-GJAHR,
END OF ty_s_sel,
ty_t_sel TYPE ty_s_sel OCCURS 0.
DATA: l_value(10) TYPE n,
ls_sel TYPE ty_s_sel,
lt_sel TYPE ty_t_sel,
l_lines LIKE sy-tabix,
ls_fc TYPE slis_fieldcat_alv,
lt_fc TYPE slis_t_fieldcat_alv,
ls_selfield TYPE slis_selfield,
l_fi_doc.
* Unfortunately the output list of this report consists
* of several ALVs, one started at the end-event of the other.
* This abstrucse programming style was chosen to create a list
* layout similar to the one in release 3.1. Now this causes a severe
* problem: When selecting a line, we do not know which ALV (and there-
* for which line in table IMSEG) has been selected. We can only use
* the value of the selected field to access the data-table.
* In case of ambiguities, a popup has to be transmitted where the
* user has to reselect the document he wants to see. This is
* difficult to understand, if you do not know the problems of
* programming ABAP.
* This is a nice example of unnecessarily copying old crap.
CASE r_ucomm.
WHEN '9PBP'.
* Get line of IMSEG which "look" like the one selected
l_value = rs_selfield-value.
CHECK NOT l_value IS INITIAL. "204872
IF RS_SELFIELD-SEL_TAB_FIELD = 'G_T_BELEGE-MBLNR' OR
RS_SELFIELD-SEL_TAB_FIELD = 'G_T_BELEGE1-MBLNR'.
LOOP AT G_T_MSEG_LEAN INTO G_S_MSEG_LEAN
WHERE MBLNR = L_VALUE.
LS_SEL-MBLNR = G_S_MSEG_LEAN-MBLNR.
LS_SEL-MJAHR = G_S_MSEG_LEAN-MJAHR.
LS_SEL-ZEILE = G_S_MSEG_LEAN-ZEILE.
COLLECT ls_sel INTO lt_sel.
ENDLOOP.
ELSEIF RS_SELFIELD-SEL_TAB_FIELD = 'G_T_BELEGE-BELNR' OR
RS_SELFIELD-SEL_TAB_FIELD = 'G_T_BELEGE1-BELNR'.
l_fi_doc = 'X'.
LOOP AT G_T_MSEG_LEAN INTO G_S_MSEG_LEAN
WHERE BELNR = L_VALUE.
LS_SEL-BELNR = G_S_MSEG_LEAN-BELNR.
LS_SEL-GJAHR = G_S_MSEG_LEAN-GJAHR.
LS_SEL-BUKRS = G_S_MSEG_LEAN-BUKRS.
COLLECT ls_sel INTO lt_sel.
ENDLOOP.
ENDIF.
SORT lt_sel BY mjahr mblnr zeile bukrs belnr gjahr.
* Read first line. If L_LINES = 1, LS_SEL is filled properly.
READ TABLE lt_sel INTO ls_sel INDEX 1.
DESCRIBE TABLE lt_sel LINES l_lines.
* If no line found, the cursor was not on a useful value.
IF l_lines = 0.
MESSAGE s270.
EXIT.
ENDIF.
* If more than one line found, it gets difficult. We send a popup
* where the user may select a single line.
IF l_lines > 1.
* Create fieldcatalog
DEFINE fc_add.
ls_fc-fieldname = &1.
ls_fc-ref_tabname = &2.
ls_fc-ref_fieldname = &3.
append ls_fc to lt_fc.
END-OF-DEFINITION.
CLEAR ls_sel.
IF l_fi_doc IS INITIAL.
fc_add 'MBLNR' 'MKPF' 'MBLNR'.
fc_add 'MJAHR' 'MKPF' 'MJAHR'.
fc_add 'ZEILE' 'MSEG' 'ZEILE'.
ELSE.
fc_add 'BUKRS' 'BKPF' 'BUKRS'.
fc_add 'BELNR' 'BKPF' 'BELNR'.
fc_add 'GJAHR' 'BKPF' 'GJAHR'.
ENDIF.
CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
EXPORTING
i_zebra = 'X'
i_tabname = 'LT_SEL'
it_fieldcat = lt_fc
IMPORTING
es_selfield = ls_selfield
TABLES
t_outtab = lt_sel.
* Read table with the unique index.
READ TABLE lt_sel INTO ls_sel INDEX ls_selfield-tabindex.
IF sy-subrc <> 0.
EXIT.
ENDIF.
ENDIF.
* Now call the corresponding application. LS_SEL is always filled
* correctly.
IF l_fi_doc IS INITIAL.
* call the display transcation MIGO for the MM document "TEST
CALL FUNCTION 'MIGO_DIALOG' "n547170
EXPORTING "n547170
i_action = 'A04' "n547170
i_refdoc = 'R02' "n547170
i_notree = 'X' "n547170
i_no_auth_check = ' ' "n547170
i_deadend = 'X' "n547170
i_skip_first_screen = 'X' "n547170
i_okcode = 'OK_GO' "n547170
i_mblnr = ls_sel-mblnr "n547170
i_mjahr = ls_sel-mjahr "n547170
i_zeile = ls_sel-zeile. "n547170
ELSE.
SET PARAMETER ID 'BLN' FIELD ls_sel-belnr.
SET PARAMETER ID 'BUK' FIELD ls_sel-bukrs.
SET PARAMETER ID 'GJR' FIELD ls_sel-gjahr.
CALL TRANSACTION 'FB03' AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
ENDFORM. " USER_COMMAND
*&---------------------------------------------------------------------*
*eject
*-----------------------------------------------------------"n547170
* esdus_get_parameters "n547170
*-----------------------------------------------------------"n547170
form esdus_get_parameters. "n547170
*-----------------------------------------------------------"n547170
* Initialization of the user defaults for the checkboxes
* read the settings from table ESDUS
*-----------------------------------------------------------
* only in dialog mode
check : sy-batch is initial.
data : l_cnt_radiobutton type i.
* get the parameters from the last run from table ESDUS as
* default values in release 4.6 and higher
IF oref_settings IS INITIAL.
CREATE OBJECT oref_settings
EXPORTING i_action = 'RM07MLBD'.
ENDIF.
** get the parameters from the last run
LGBST = oref_settings->get( 'LGBST' ).
BWBST = oref_settings->get( 'BWBST' ).
SBBST = oref_settings->get( 'SBBST' ).
XCHAR = oref_settings->get( 'XCHAR' ).
XSUM = oref_settings->get( 'XSUM' ).
NOSTO = oref_settings->get( 'NOSTO' ).
** get the parameters for the list categories "n599218
pa_wdzer = oref_settings->get( 'PA_WDZER' ). "n599218
pa_wdzew = oref_settings->get( 'PA_WDZEW' ). "n599218
pa_wdWIZ = oref_settings->get( 'PA_WDWIZ' ). "n599218
pa_wdwuw = oref_settings->get( 'PA_WDWUW' ). "n599218
pa_wdwew = oref_settings->get( 'PA_WDWEW' ). "n599218
pa_ndsto = oref_settings->get( 'PA_NDSTO' ). "n599218
pa_ndzer = oref_settings->get( 'PA_NDZER' ). "n599218
** check radiobutton rules
if not LGBST is initial.
add 1 to l_cnt_radiobutton.
endif.
if not BWBST is initial.
add 1 to l_cnt_radiobutton.
endif.
if not SBBST is initial.
add 1 to l_cnt_radiobutton.
endif.
if l_cnt_radiobutton ne 1.
** offend against radiobutton rules ?
** yes -> set the first and delete the rest
move : 'X' to LGBST.
clear : BWBST, SBBST.
endif.
* at the first time ( or in a lower release ) all seven "n599218
* list categories will be initial --> activate them all "n599218
perform f0850_empty_parameters. "n599218
"n599218
if g_cnt_empty_parameter = 7. "n599218
move : 'X' to PA_wdzer, "n599218
'X' to pa_wdzew, "n599218
'X' to pa_wdwiz, "n599218
'X' to pa_wdwuw, "n599218
'X' to pa_wdwew, "n599218
'X' to pa_ndsto, "n599218
'X' to pa_ndzer. "n599218
endif. "n599218
endform. "esdus_get_parameters "n547170
*-----------------------------------------------------------"n547170
* esdus_save_parameters "n547170
*-----------------------------------------------------------"n547170
form esdus_save_parameters. "n547170
"n547170
* only in dialog mode
check : sy-batch is initial.
* Save the settings in release 4.6 and higher
CALL METHOD oref_settings->set( i_element = 'LGBST'
i_active = LGBST ).
CALL METHOD oref_settings->set( i_element = 'BWBST'
i_active = BWBST ).
CALL METHOD oref_settings->set( i_element = 'SBBST'
i_active = SBBST ).
CALL METHOD oref_settings->set( i_element = 'XCHAR'
i_active = XCHAR ).
* CALL METHOD oref_settings->set( i_element = 'XONUL'
* i_active = xonul ).
*
* CALL METHOD oref_settings->set( i_element = 'XVBST'
* i_active = XVBST ).
* CALL METHOD oref_settings->set( i_element = 'XNVBST'
* i_active = xnvbst ).
* save the list categories "n599218
CALL METHOD oref_settings->set( i_element = 'PA_WDZER' "n599218
i_active = pa_wdzer )."n599218
CALL METHOD oref_settings->set( i_element = 'PA_WDZEW' "n599218
i_active = pa_wdzew )."n599218
CALL METHOD oref_settings->set( i_element = 'PA_WDWIZ' "n599218
i_active = pa_wdwiz )."n599218
CALL METHOD oref_settings->set( i_element = 'PA_WDWUW' "n599218
i_active = pa_wdwuw )."n599218
CALL METHOD oref_settings->set( i_element = 'PA_WDWEW' "n599218
i_active = pa_wdwew )."n599218
CALL METHOD oref_settings->set( i_element = 'PA_NDSTO' "n599218
i_active = pa_ndsto )."n599218
CALL METHOD oref_settings->set( i_element = 'PA_NDZER' "n599218
i_active = pa_ndzer )."n599218
CALL METHOD oref_settings->set( i_element = 'XSUM'
i_active = XSUM ).
CALL METHOD oref_settings->set( i_element = 'NOSTO'
i_active = nosto ).
CALL METHOD oref_settings->flush.
* carry out the database updates only; the normal commit "n599218
* command does not allow to record this transaction for "n599218
* a batch input session using transaction SHDB "n599218
CALL FUNCTION 'DB_COMMIT'. "n599218
endform. "esdus_save_parameters "n547170
*-----------------------------------------------------------"n547170
"n599218 A
form check_is_oil_system. "n599218 A
"n599218 A
move 'OI001' to g_f_dcobjdef-name. "n599218 A
clear : g_flag_is_oil_active, g_cnt_is_oil. "n599218 A
"n599218 A
* does database OI001 exist in this system ? "n599218 A
call function 'DDIF_NAMETAB_GET' "n599218 A
exporting "n599218 A
tabname = g_f_dcobjdef-name "n599218 A
tables "n599218 A
x031l_tab = g_t_x031l "n599218 A
exceptions "n599218 A
others = 1. "n599218 A
"n599218 A
check sy-subrc is initial. "OI001 is available ? "n599218 A
"n599218 A
* check definition of MM document item MSEG "n599218 A
move 'MSEG' to g_f_dcobjdef-name. "n599218 A
"n599218 A
call function 'DDIF_NAMETAB_GET' "n599218 A
exporting "n599218 A
tabname = g_f_dcobjdef-name "n599218 A
tables "n599218 A
x031l_tab = g_t_x031l "n599218 A
exceptions "n599218 A
others = 1. "n599218 A
"n599218 A
check sy-subrc is initial. "structure MSEG found "n599218 A
"n599218 A
* check whether the IS-OIL specific fields are available "n599218 A
loop at g_t_x031l into g_s_x031l. "n599218 A
case g_s_x031l-fieldname. "n599218 A
when 'OIGLCALC'. "n599218 A
add 1 to g_cnt_is_oil. "n599218 A
"n599218 A
when 'OIGLSKU'. "n599218 A
add 2 to g_cnt_is_oil. "n599218 A
endcase. "n599218 A
endloop. "n599218 A
"n599218 A
* in the case structure MSEG comprises both fields "n599218 A
* -> activate the IS-OIL function "n599218 A
if g_cnt_is_oil = 3. "n599218 A
move 'X' to g_flag_is_oil_active. "n599218 A
endif. "n599218 A
"n599218 A
endform. "check_is_oil_system. "n599218 A
"n599218 A
*----------------------------------------------------------------------*
* contains FORM routines without preprocessor commands and "n547170
* no text elements "n547170
include ZVVF_M07MLBD_FORM_01. "n547170
*eject
include RM07MLBD_FORM_02. "n547170
No comments:
Post a Comment