Sei sulla pagina 1di 94

REPORT DATA : DATA : DATA :

zmb5bn_mat NO STANDARD PAGE HEADING MESSAGE-ID m7 LINE-SIZE 255. cl_stock(9) TYPE p DECIMALS 2. pdays LIKE t009b-butag. par_month LIKE t009b-bumon. " TYPEN BESTANDSF HRUNGSREPORTING " TYPEN LISTVIEWER "N890109 "N890109

TYPE-POOLS: vrm. TYPE-POOLS: imrep, slis.

* ALLOW THE INTERACTIONS 'SPECIFY DRILL-DOWN' ETC.. TYPE-POOLS : kkblo. "KORREKTUR ALV INCLUDE zrm07mlddn_mat. *INCLUDE: ZRM07MLDDN.

" REPORTSPEZIFISCHE DATENDEFINITIONEN NITIN

* CONTROLS THE "EXPENSIVE" CHECKS LIKE AUTHORIZATION, ETC. "N878753 DATA : g_flag_launched(01) TYPE c. "N878753 * WORKING FIELDS FOR THE PERFORMANCE IMPROVEMENTS DATA : g_flag_db_parameters(01) TYPE c, g_f_database(03) TYPE c, g_cnt_radio g_cnt_error_dba DATA : g_tabix_set g_flag_sorted TYPE i, TYPE i. TYPE sy-tabix, TYPE c. STOPS AT DYNAMIC VALUE VALUE VALUE VALUE VALUE VALUE VALUE VALUE 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165

* THESE FLAGS ALLOW TO IGNORE MULTIPLE * BREAK-POINTS IN LOOPS DATA : BEGIN OF g_flag_break, b1(01) TYPE c b2(01) TYPE c b3(01) TYPE c b4(01) TYPE c b5(01) TYPE c b6(01) TYPE c b7(01) TYPE c b8(01) TYPE c END OF g_flag_break.

*-----------------------------------------------------------"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 NO-DISPLAY. *ENHANCEMENT-POINT RM07MLBD_01 SPOTS ES_RM07MLBD STATIC. SELECT-OPTIONS: bukrs FOR t001-bukrs MEMORY ID buk NO-DISPLAY, werks FOR t001w-werks MEMORY ID wrk NO INTERVALS NO-EXTENSION, datum FOR mkpf-budat NO-EXTENSION, lgort FOR t001l-lgort NO-DISPLAY, charg FOR mchb-charg NO-DISPLAY, bwtar FOR mbew-bwtar NO-DISPLAY, bwart FOR mseg-bwart NO-DISPLAY, *--INSERTED BY TULASI 30.01

mtart FOR mara-mtart NO INTERVALS NO-DISPLAY, matkl FOR mara-matkl NO INTERVALS NO-DISPLAY. PARAMETERS sobkz LIKE mseg-sobkz NO-DISPLAY. *SELECTION-SCREEN SKIP. *PARAMETERS: months(09) AS LISTBOX VISIBLE LENGTH 15 NO-DISPLAY. *PARAMETERS: gjahr LIKE mseg-gjahr DEFAULT '2010' NO-DISPLAY. *SELECT-OPTIONS: datum FOR mkpf-budat NO-EXTENSION. * DATUMSINTERVALL F R SELEKTION SELECTION-SCREEN END OF BLOCK database-selection. *----------------------------------------------------------------------* DATA: lgbst TYPE c VALUE 'X', bwbst TYPE c , sbbst TYPE c. 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 SELECTION-SCREEN BEGIN OF BLOCK listumfang WITH FRAME TITLE text-003. "LISTUMFANG PARAMETERS : xonul LIKE am07m-xonul xvbst LIKE am07m-xvbst xnvbst LIKE am07m-xnvbs * * * * * * NO-DISPLAY, NO-DISPLAY, NO-DISPLAY. "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218

7 NEW CATEGORIES FOR THE SCOPE OF LIST CAT. I DOCS I STOCK ON I I STOCK ON I PARAMETER I I START DATE I I END DATE I -----+------+------------+----+----------+---------1 I YES I = ZERO I = I = ZERO I PA_WDZER

* 2 I YES I = ZERO I <> I <> ZERO I PA_WDZEW * 3 I YES I <> ZERO I <> I = ZERO I PA_WDWIZ * 4 I YES I <> ZERO I <> I <> ZERO I PA_WDWUW * 5 I YES I <> ZERO I = I <> ZERO I PA_WDWEW * I I I I I * 6 I NO I = ZERO I = I = ZERO I PA_NDZER * 7 I NO I <> ZERO I = I <> ZERO I PA_NDSTO * * DEFINITION OF THE PUSHBUTTON : SHOW OR HIDE THE FOLLOWING * PARAMETERS FOR THE SCOPE OF LIST *SELECTION-SCREEN PUSHBUTTON /1(20) pb_liu * USER-COMMAND liu. * TEXT LINE : MATERIALS WITH MOVEMENTS SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN COMMENT 1(55) text-072 MODIF ID liu. SELECTION-SCREEN END OF LINE. * WITH MOVEMENTS / START = ZERO = END = ZERO * 1 I YES I = ZERO I = I = ZERO I PA_WDZER SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN POSITION 2. PARAMETERS : pa_wdzer LIKE am07m-mb5b_xonul MODIF ID liu. * TEXT-083 : NO OPENING STOCK ; NO CLOSING STOCK SELECTION-SCREEN COMMENT 5(70) text-083 FOR FIELD pa_wdzer MODIF ID liu. SELECTION-SCREEN END OF LINE. * WITH MOVEMENTS / START = ZERO = END <> ZERO * 2 I YES I = ZERO I <> I <> ZERO I PA_WDZEW SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN POSITION 2. PARAMETERS : pa_wdzew LIKE am07m-mb5b_xonul MODIF ID liu. * TEXT-084 : NO OPENING STOCK ; WITH CLOSING STOCK SELECTION-SCREEN COMMENT 5(70) text-084 FOR FIELD pa_wdzew MODIF ID liu. SELECTION-SCREEN END OF LINE. * WITH MOVEMENTS / START STOCK <> 0 / END STOCK = 0 * 3 I YES I <> ZERO I <> I = ZERO I PA_WDWIZ SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN POSITION 2. PARAMETERS : pa_wdwiz LIKE am07m-mb5b_xonul MODIF ID liu. * TEXT-085 : WITH OPENING STOCK ; NO CLOSING STOCK SELECTION-SCREEN COMMENT 5(70) text-085 FOR FIELD pa_wdwiz MODIF ID liu. SELECTION-SCREEN END OF LINE. * WITH MOVEMENTS / WITH START AND END STOCKS / DIFFERENT * 4 I YES I <> ZERO I <> I <> ZERO I PA_WDWUW SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN POSITION 2. PARAMETERS : pa_wdwuw LIKE am07m-mb5b_xonul

"N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218

MODIF ID liu. * WITH OPENING STOCK ; WITH CLOSING STOCK ; CHANGED SELECTION-SCREEN COMMENT 5(70) text-086 FOR FIELD pa_wdwuw MODIF ID liu. SELECTION-SCREEN END OF LINE. * WITH MOVEMENTS / WITH START AND END STOCK / EQUAL * 5 I YES I <> ZERO I = I <> ZERO I PA_WDWEW SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN POSITION 2. PARAMETERS : pa_wdwew LIKE am07m-mb5b_xonul MODIF ID liu. * WITH OPENING STOCK ; WITH CLOSING STOCK ; NON-CHANGED SELECTION-SCREEN COMMENT 5(70) text-087 FOR FIELD pa_wdwew MODIF ID liu. SELECTION-SCREEN END OF LINE. * TEXT LINE : MATERIALS WITHOUT MOVEMENTS SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN COMMENT 1(55) text-073 MODIF ID liu. SELECTION-SCREEN END OF LINE. * MATERIALS WITHOUT MOVEMENTS / STOCKS = ZERO * 6 I NO I = ZERO I = I = ZERO I PA_NDZER SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN POSITION 2. PARAMETERS : pa_ndzer LIKE am07m-mb5b_xonul MODIF ID liu. * TEXT-083 : NO OPENING STOCK ; NO CLOSING STOCK SELECTION-SCREEN COMMENT 5(70) text-083 FOR FIELD pa_ndzer MODIF ID liu. SELECTION-SCREEN END OF LINE. * MATERIALS WITHOUT MOVEMENTS / WITH START OR END STOCK * 7 I NO I <> ZERO I = I <> ZERO I PA_NDSTO SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN POSITION 2. PARAMETERS : pa_ndsto LIKE am07m-mb5b_xonul MODIF ID liu. * WITH OPENING STOCK ; WITH CLOSING STOCK ; NON-CHANGED SELECTION-SCREEN COMMENT 5(70) text-087 FOR FIELD pa_ndsto MODIF ID liu. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN END OF BLOCK listumfang.

"N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218

*----------------------------------------------------------------------* DATA: xsum TYPE c, pa_sumfl TYPE c VALUE 'X', xchar TYPE c, xnomchb TYPE c, nosto TYPE am07m-nosto.

SELECTION-SCREEN BEGIN OF BLOCK einstellungen WITH FRAME TITLE text-068. "SETTINGS * PARAMETER FOR TOTALS ONLY - HIERSEQ. LIST * CORRESPONDING DISPLAY VARIANT SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN POSITION 1. *PARAMETERS xsum LIKE am07m-xsum. *SELECTION-SCREEN COMMENT 4(60) text-090 FOR FIELD xsum. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN BEGIN OF LINE. *SELECTION-SCREEN COMMENT 5(30) text-091 FOR FIELD pa_suvar. SELECTION-SCREEN POSITION 40. PARAMETERS: pa_suvar LIKE disvariant-variant NO-DISPLAY. SELECTION-SCREEN END OF LINE. * PARAMETER FOR TOTALS ONLY - FLAT LIST + CORRESPONDING DISPLAY VARIANT SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN POSITION 1. *PARAMETERS pa_sumfl LIKE am07m-xsum. *SELECTION-SCREEN COMMENT 4(60) text-092 FOR FIELD pa_sumfl. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN BEGIN OF LINE. *SELECTION-SCREEN COMMENT 5(30) text-091 FOR FIELD pa_sflva. SELECTION-SCREEN POSITION 40. PARAMETERS: pa_sflva LIKE disvariant-variant NO-DISPLAY. 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. SELECTION-SCREEN BEGIN OF LINE. "838360_V SELECTION-SCREEN POSITION 4. *PARAMETERS xnomchb LIKE am07m-mb5b_xnomchb. *SELECTION-SCREEN COMMENT 6(50) text-089 FOR FIELD xnomchb. * TEXT-089: AUCH CHARGEN OHNE BESTANDSSEGMENT SELECTION-SCREEN END OF LINE. "838360_^ * THE FUNCTION "NO REVERSAL MOVEMENTS" IS ONLY * AVAILABLE FROM RELAESE 4.5B AND HIGHER * ( TEXT-026 : NO REVERSAL MOVEMENTS ) SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN POSITION 1. *PARAMETERS nosto LIKE am07m-nosto. *SELECTION-SCREEN COMMENT 4(50) text-026 * FOR FIELD nosto. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN END OF BLOCK einstellungen. *----------------------------------------------------------------------* "N571473 "N571473 "N571473 "N571473 "N571473 "N571473 "N571473 "N571473 "N571473

SELECTION-SCREEN BEGIN OF BLOCK liste WITH FRAME TITLE text-040. PARAMETERS: p_vari LIKE disvariant-variant NO-DISPLAY. SELECTION-SCREEN END OF BLOCK liste. *----------------------------------------------------------------------* * * * * WITH THESE NEW PARAMETERS ALLOW THE USER TO DETERMINE THE BEST DATABASE ACCESS; THESE PARAMETERS WILL APPEAR ONLY WHEN THE INSTALLED DATABASE SYSTEM IS : DB6, INFORMIX, OR MAXDB "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165

* DEFINE DATABASE ACCESS FOR BEST RUNTIME SELECTION-SCREEN BEGIN OF BLOCK db WITH FRAME TITLE text-111. * DATABASE DETERMINES BEST ACCESS SELECTION-SCREEN : BEGIN OF LINE. PARAMETERS : pa_dbstd LIKE am07m-xselk MODIF ID dba DEFAULT 'X' RADIOBUTTON GROUP db. SELECTION-SCREEN : COMMENT 3(70) text-112 FOR FIELD pa_dbstd MODIF ID dba. SELECTION-SCREEN : END OF LINE. * ACCESS VIA MATERIAL NUMBER SELECTION-SCREEN : BEGIN OF LINE. PARAMETERS : pa_dbmat LIKE am07m-xselk MODIF ID dba RADIOBUTTON GROUP db. SELECTION-SCREEN : COMMENT 3(70) text-113 FOR FIELD pa_dbmat MODIF ID dba. SELECTION-SCREEN : END OF LINE. * ACCESS VIA POSTING DATE SELECTION-SCREEN : BEGIN OF LINE. PARAMETERS : pa_dbdat LIKE am07m-xselk MODIF ID dba RADIOBUTTON GROUP db. SELECTION-SCREEN : COMMENT 3(70) text-114 FOR FIELD pa_dbdat MODIF ID dba. SELECTION-SCREEN : END OF LINE. SELECTION-SCREEN END OF BLOCK db.

*------------------------------------------------------------------------------* *------------------------------------------------------------------------------* DATA: r1 TYPE c VALUE 'X', r2 TYPE c. *------------------------------------------------------------------------------* **--INSERTED BY TULASI FOR OUTPUT DISPLAY SELECTION

*SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-200. *PARAMETERS : r1 RADIOBUTTON GROUP g DEFAULT 'X', * r2 RADIOBUTTON GROUP g. *SELECTION-SCREEN : END OF BLOCK b1. ************************ HAUPTPROGRAMM ********************************* *---------------- F4-HILFE F R REPORTVARIANTE *-------------------------* *AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari. * PERFORM f4_for_variant. *----------------------------------------------------------------------* *AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_sflva. * PERFORM variant_value_request_f4 * USING pa_sflva g_s_vari_sumfl. *----------------------------------------------------------------------* *AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_suvar. * PERFORM variant_value_request_f4 * USING pa_suvar g_s_vari_sumhq. *-----------------------------------------------------------"N599218 * INITIALIZATION "N599218 *-----------------------------------------------------------"N599218 "N599218 * PAY ATTENTIONS : THIS PROCESS TIME WILL NOT BE PROCESSED "N599218 * IN THE WEBREPORTING MODE "N599218 INITIALIZATION. CLEAR : g_s_vari_sumhq, g_s_vari_sumfl. repid = sy-repid. variant_save = 'A'. *ENHANCEMENT-POINT RM07MLBD_03 SPOTS ES_RM07MLBD. * PREPRAE THE WORKING AREAS FOR THE VARIANTS MOVE : repid TO g_s_vari_sumhq-report, 'SUHQ' TO g_s_vari_sumhq-handle, repid TO g_s_vari_sumfl-report, 'SUFL' TO g_s_vari_sumfl-handle. MOVE-CORRESPONDING : g_s_vari_sumhq TO g_s_vari_sumhq_def, g_s_vari_sumfl TO g_s_vari_sumfl_def. PERFORM get_the_default_variant USING pa_sflva g_s_vari_sumfl g_s_vari_sumfl_def. PERFORM get_the_default_variant USING pa_suvar g_s_vari_sumhq g_s_vari_sumhq_def. PERFORM initialisierung.

* GET THE PARAMETERS FROM THE LAST RUN PERFORM esdus_get_parameters. * SET FLAG WHEN INITILIZATION IS PROCESSED MOVE 'X' TO g_flag_initialization.

"N547170 "N547170

*-----------------------------------------------------------"N599218 * AT SELECTION-SCREEN "N599218 *-----------------------------------------------------------"N599218 *----------- PR FUNG DER EINGEGEBENEN SELEKTIONSPARAMETER, *------------* *---------------------- BERECHTIGUNGSPR FUNG *--------------------------* AT SELECTION-SCREEN. * THE USER WILL GET THE INFO ABOUT THE OLD VARIANT ONLY * ONCE IF g_cnt_error_dba = 1. IF NOT sy-slset IS INITIAL. * VARIANT & OF PROGRAM & IS NOT THE CURRENT VERSION MESSAGE i634(db) WITH sy-slset sy-repid. ENDIF. ENDIF. * * "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 IF THE INSTALLED DATABASE SYSTEM IS NOT DB6, INFORMIX OR "N921165 MAXDB THE PARAMETER PA_DBSTD MUST BE SET "N921165 IF g_flag_db_parameters IS INITIAL. "N921165 IF pa_dbstd = 'X' AND "N921165 pa_dbmat IS INITIAL AND "N921165 pa_dbdat IS INITIAL. "N921165 OK "N921165 ELSE. "N921165 SEND WARNING WHEN THE USER APPLIED AN OLD VARIANT "N921165 IF NOT sy-slset IS INITIAL. "N921165 ADD 1 TO g_cnt_error_dba. "N921165 VARIANT & OF PROGRAM & IS NOT THE CURRENT VERSION "N921165 MESSAGE i634(db) WITH sy-slset sy-repid. "N921165 ENDIF. "N921165 ENDIF. "N921165 ENDIF. "N921165 "N921165 CHECK CHOOSEN DATABASE ACCESS AGAIST RESTRICTIONS "N921165 TEXT-095 : MISMATCH DATABASE ACCESS - RESTRICTION "N921165 IF g_flag_db_parameters = 'X'. "N921165 "N921165 IF pa_dbmat = 'X'. "N921165 ACCESS VIA MATERIAL NUMBER : MATERIAL ENTERED ? "N921165 IF matnr[] IS INITIAL. "N921165 SET CURSOR FIELD pa_dbmat. "N921165 MESSAGE w895 WITH text-115. "N921165 ENDIF. "N921165 "N921165 ELSEIF pa_dbdat = 'X'. "N921165 ACCESS VIA POSTING DATA : POSTING DATE ENTERED ? "N921165 IF datum-low IS INITIAL AND "N921165 datum-high IS INITIAL. "N921165 SET CURSOR FIELD pa_dbdat. "N921165 MESSAGE w895 WITH text-115. "N921165

* * *

* *

ENDIF. ENDIF. ENDIF. * * * * * THE FOLLOWING 3 PARAMETERS XONUL, XVBST, AND XNVBST BECAME OBSOLETE; SEND ERROR WHEN THEY SHOULD BE FILLED. THIS COULD BE POSSIBLE IF THE USER WORKS WITH OLD SELECTION VARIANTS OR THIS REPORT IS LAUNCHED BY A SUBMIT COMMAND IF xonul IS INITIAL AND xvbst IS INITIAL AND xnvbst IS INITIAL. * OK, THE OLD PARAMETERS ARE EMPTY ELSE. * TEXT-088 : NOTE 599218 : OBSOLETE PARAMETER USED MESSAGE e895 WITH text-088. ENDIF. * DID THE USER HIT THE PUSHBUTTON "CATEGORY" ? CASE sscrfields-ucomm. WHEN 'LIU '. * YES, THE PUSHBUTTON "CATEGORY" WAS HIT IF g_flag_status_liu = c_hide. * SHOW THE 7 PARAMETERS ON THE SELECTION SRCEEN MOVE c_show TO g_flag_status_liu. ELSE. * HIDE THE 7 PARAMATERS MOVE c_hide TO g_flag_status_liu. ENDIF. ENDCASE. * * * * * * * CARRY OUT THE "EXPENSIVE" CHECKS, LIKE AUTHORIZATION, ONLY AFTER THE USER WANTS TO LAUNCH THIS REPORT. IN THE CASE AN ERROR MESSAGE WAS SENT THE USER CAN CORRECT THE ENTRIES AND GO ON WITH "ENTER". THAT MEANS THE SYSTEM FIELD SY-UCOMM IS INITIAL. THIS CORRECTION SHOULD MAKE SURE THAT ALL CHECKS ARE DONE WHEN THIS REPORT IS LAUNCHED. IF sy-ucomm = 'ONLI' OR sy-ucomm = 'PRIN' OR sy-ucomm = 'SJOB'. MOVE 'X' TO g_flag_launched. ENDIF. CHECK : g_flag_launched = 'X'. * ONLY ONE SUM FUNCTION CAN BE PROCESSED IF xsum = 'X' AND pa_sumfl = 'X'. SET CURSOR FIELD 'XSUM'. * SELECT ONE SUM LIST ONLY MESSAGE e895 WITH text-093. ENDIF. PERFORM eingaben_pruefen. SET CURSOR FIELD 'PA_SFLVA'. PERFORM variant_check_existence USING pa_sflva

"N921165 "N921165 "N921165 "N921165 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N878753 "N878753 "N878753 "N878753 "N878753 "N878753 "N878753 "N878753 "N878753 "N878753 "N878753 "N878753 "N878753 "N878753

g_s_vari_sumfl g_s_vari_sumfl_def. SET CURSOR FIELD 'PA_SUVAR'. PERFORM variant_check_existence USING pa_suvar g_s_vari_sumhq g_s_vari_sumhq_def. * CHECK WHETHER FI SUMMARIZATION IS ACTIVE AND OTHER * RESTRICTIONS COULD DELIVER WRONG RESULTS PERFORM f0800_check_restrictions. * - THE USER WANTS TO SURPRESS THE REVERSAL MOVEMENTS : * PROCESS WARNING M7 392 IF NOT nosto IS INITIAL. * EMERGE WARNING ? CALL FUNCTION 'ME_CHECK_T160M' EXPORTING i_arbgb = 'M7' i_msgnr = '392' EXCEPTIONS nothing = 0 OTHERS = 1. "N547170 "N547170 "N547170

"N497992 "N497992 "N497992 "N497992 "N497992 "N497992 "N497992 "N497992 "N497992 "N497992 "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 PERFORM tpc_check_tax_auditor. "N547170 "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 DESCRIBE TABLE werks LINES g_f_cnt_lines_bukrs. 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 PERFORM esdus_save_parameters. "N547170 "N547170

*-----------------------------------------------------------"N599218 * AT SELECTION-SCREEN OUTPUT "N599218

*-----------------------------------------------------------"N599218 "N599218 AT SELECTION-SCREEN OUTPUT. ******* START OF NITIN 06/09/2010 PERFORM build_user_drop_down_list. * * * * CHECK WHETHER THE DATABASE ACCESS PARAMETERS FULFIL THE RADIOBUTTON RULES / IN THE CASE THIS REPORT WAS LAUNCHED WITH A SELECTION VARIANT, THE SETTINGS OF THIS VARIANT HAVE BEEN SET ALREADY IF g_flag_db_parameters = 'X'. CLEAR g_cnt_radio. IF pa_dbstd = 'X'. ADD 1 TO g_cnt_radio. ENDIF. IF pa_dbmat = 'X'. ADD 1 TO g_cnt_radio. ENDIF. IF pa_dbdat = 'X'. ADD 1 TO g_cnt_radio. ENDIF. "N599218

IF g_cnt_radio = 1. OK ELSE. * OFFENDED AGAINST RADIOBUTTON RULES : SET DEFAULT ADD 1 TO g_cnt_error_dba. MOVE : 'X' TO pa_dbstd. CLEAR : pa_dbmat, pa_dbdat. ENDIF. ENDIF. * * * IF g_flag_initialization IS INITIAL. THE PROCESS TIME INITIALIZATION WAS NOT DONE, SO CARRY OUT THE FUNCTIONS HERE MOVE 'X' TO g_flag_initialization. PERFORM * initialisierung.

"N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165

GET THE PARAMETERS FROM THE LAST RUN PERFORM esdus_get_parameters. ENDIF.

* HOW TO HANDLE THE 7 PARAMATERS FOR THE SCOPE OF LIST ? LOOP AT SCREEN. * MODIFY THE SELECTION SCREEN CASE screen-group1. WHEN 'LIU'. IF g_flag_status_liu = c_show. screen-active = '1'. "SHOW PARAMETERS ELSE. screen-active = '0'. "HIDE PARAMETERS ENDIF. MODIFY SCREEN. * WHEN 'DBA'. SHOW OR HIDE THE PARAMETES FOR THE DATABASE ACCESS IF g_flag_db_parameters = 'X'. screen-active = '1'. "SHOW PARAMETERS ELSE. screen-active = '0'. "HIDE PARAMETERS ENDIF.

MODIFY SCREEN. ENDCASE. ENDLOOP.

"N921165

"N599218 "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 *----------------------------------------------------------------------* * START-OF-SELECTION *----------------------------------------------------------------------* START-OF-SELECTION. * IT MAKES NO SENCE TO CARRY OUT THIS REPORT WITH AN OLD * AND INCORRECT SELECTION VARIANT IF g_cnt_error_dba > 0. IF NOT sy-slset IS INITIAL. * VARIANT & OF PROGRAM & IS NOT THE CURRENT VERSION MESSAGE e634(db) WITH sy-slset sy-repid. ENDIF. ENDIF. * 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. BREAK HNBIR. "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165 "N921165

* par_month = months. ********** * CALL FUNCTION '/SDF/RBE_GET_DAYS_PER_MONTH' * EXPORTING * par_month = par_month * par_year = gjahr * IMPORTING * par_days = pdays. * * CONCATENATE gjahr months '01' INTO datum-low. * CONCATENATE gjahr months pdays INTO datum-high. *********** 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 PERFORM create_headline. * CALCULATE THE OFFSETS FOR THE LIST HEADER PERFORM calculate_offsets. * FOR THE REPRESENTATION OF TIED EMPTIES PERFORM f0700_prepare_tied_empties. * CREATE TABLE G_T_MSEG_FIELDS WITH THE NAMES OF ALL * WANTED FIELDS FROM MSEG AND MKPF PERFORM f0300_get_fields. BREAK-POINT ID mmim_rep_mb5b. * DYNAMIC BREAK-POINT : IS IS-OIL ACTIVE ? * "N921164 "N921164 "N599218 CHECK WHETHER THIS IS A IS-OIL SYSTEM "N599218 PERFORM check_is_oil_system. "N599218 "N599218 IF g_flag_is_oil_active = 'X'. "IS-OIL ? "N599218 THE 2 IS-OIL SPECIFIC DATA FIELDS WILL BE INSERTED INTO "N599218 WORKING TABLE G_T_MSEG_FIELDS. THEN THESE FIELDS WILL "N599218 TRANSPORTED FROM DATABASE TABLE MSEG, TOO "N599218 APPEND 'MSEG~OIGLCALC' TO g_t_mseg_fields. "N599218 APPEND 'MSEG~OIGLSKU' TO g_t_mseg_fields. "N599218 ENDIF. "N599218 "N547170 "N547170 "N599218 "N599218

* * *

A A A A A A A A A A A

* CREATE THE ALV FIELDCATALOG FOR THE MAIN LIST ALWAYS MOVE 'G_T_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'." * CREATE THE RANGE TABLE FOR THE STORAGE LOCATION PERFORM f0600_create_range_lgort. * - SHOW THE CURRENT ACTIVITY AND THE PROGRESS CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR' EXPORTING text = text-063. "READING CURRENT STOCKS * GET THE STOCK TABLES "N599218 "N599218 "N599218 "N599218

PERFORM PERFORM tabellen_lesen.

aktuelle_bestaende.

* - SHOW THE CURRENT ACTIVITY AND THE PROGRESS CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR' EXPORTING text = text-064. "READING MM DOCUMENTS PERFORM PERFORM f1000_select_mseg_mkpf. belegselektion.

"N599218 "N599218 "N599218 "N599218

*----------------------------------------------------------------------* * END-OF-SELECTION *----------------------------------------------------------------------* 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 CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR' EXPORTING text = text-065. "PREPARING LIST OUTPUT * 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 * AND THE DATABASE SELECTION WAS SUCCESSFUL IF g_flag_tpcuser = '1'. PERFORM tpc_write_log. ENDIF. * "N599218 "N599218 "N599218 "N599218

"N555246 "N555246 "N555246 "N555246 "N555246

PERFORM feldgruppen_aufbauen. * SORT TABLE WITH HEADER DATA PER MATERIAL IF bwbst IS INITIAL. SORT bestand BY matnr werks charg. ELSE. SORT bestand BY matnr bwkey. ENDIF. WHICH FUNCTION DOES THE USER WANT ? IF xsum = 'X'. HIERSEQ. ALV WITH SUMS PERFORM create_table_totals_hq. PERFORM PERFORM * create_fieldcat_totals_hq. alv_hierseq_list_totals.

* *

ELSEIF pa_sumfl = 'X'. SHOW THE SUMS ONLY IN A FLAT ALV PERFORM create_table_totals_flat. PERFORM PERFORM create_fieldcat_totals_flat. alv_flat_list_sums_only.

ELSE. DISPLAY THE FULL LIST USING THE APPEND ALV PERFORM bestaende_ausgeben. ENDIF. ENDIF. CLEAR: g_t_mseg_lean, g_t_bsim_lean, bestand. "N443935

*&---------------------------------------------------------------------* *& PF_STATUS_SET_TOTALS *&---------------------------------------------------------------------* FORM pf_status_set_totals USING SET PF-STATUS 'STANDARD' ENDFORM. "#EC CALLED extab TYPE slis_t_extab. EXCLUDING extab. "PF_STATUS_SET_TOTALS

*----------------------------------------------------------------------* * USER_PARAMETERS_SAVE *----------------------------------------------------------------------* FORM user_parameters_save. GET GET GET GET GET GET GET PARAMETER PARAMETER PARAMETER PARAMETER PARAMETER PARAMETER PARAMETER ID ID ID ID ID ID ID 'BUK' 'WRK' 'MAT' 'CHA' 'BLN' 'BUK' 'GJR' FIELD FIELD FIELD FIELD FIELD FIELD FIELD g_save_params-bukrs. g_save_params-werks. g_save_params-matnr. g_save_params-charg. g_save_params-belnr. g_save_params-bukrs. g_save_params-gjahr.

ENDFORM.

"USER_PARAMETERS_SAVE

*----------------------------------------------------------------------* * USER_PARAMETERS_RESTORE *----------------------------------------------------------------------* FORM user_parameters_restore. SET SET SET SET GET GET GET PARAMETER PARAMETER PARAMETER PARAMETER PARAMETER PARAMETER PARAMETER ID ID ID ID ID ID ID 'BUK' 'WRK' 'MAT' 'CHA' 'BLN' 'BUK' 'GJR' FIELD FIELD FIELD FIELD FIELD FIELD FIELD g_save_params-bukrs. g_save_params-werks. g_save_params-matnr. g_save_params-charg. g_save_params-belnr. g_save_params-bukrs. g_save_params-gjahr.

ENDFORM.

"USER_PARAMETERS_RESTORE

*&---------------------------------------------------------------------* *& USER_COMMAND_TOTALS *&---------------------------------------------------------------------* FORM user_command_totals USING CLEAR IF * "#EC CALLED r_ucomm LIKE sy-ucomm rs_selfield TYPE slis_selfield. g_s_bestand_key.

rs_selfield-tabname = 'G_T_TOTALS_HEADER'. GET THE SELECTED ENTRY FROM TABLE G_T_TOTALS READ TABLE g_t_totals_header INTO g_s_totals_header INDEX rs_selfield-tabindex. IF sy-subrc IS INITIAL. MOVE-CORRESPONDING g_s_totals_header TO g_s_bestand_key. ENDIF.

ELSEIF rs_selfield-tabname = 'G_T_TOTALS_ITEM'. GET THE SELECTED ENTRY FROM TABLE G_T_TOTALS READ TABLE g_t_totals_item INTO g_s_totals_item INDEX rs_selfield-tabindex. IF sy-subrc IS INITIAL. MOVE-CORRESPONDING g_s_totals_item TO g_s_bestand_key. ENDIF.

ELSEIF rs_selfield-tabname = 'G_T_TOTALS_FLAT'. GET THE SELECTED ENTRY FROM TABLE G_T_TOTALS READ TABLE g_t_totals_flat INTO g_s_totals_flat INDEX rs_selfield-tabindex. IF sy-subrc IS INITIAL. MOVE-CORRESPONDING g_s_totals_flat TO g_s_bestand_key. ENDIF. ENDIF.

IF g_s_bestand_key IS INITIAL. "NOTINH FOUND ? PLACE THE CURSOR ON A TABLE LINE MESSAGE s322. EXIT. ENDIF.

* GET THE LINE FROM THE MAIN TABLE BESTAND DEPENDING ON THE MODE IF bwbst IS INITIAL. * SORT SEQUENCE = MATNR WERKS CHARG READ TABLE bestand WITH KEY matnr = g_s_bestand_key-matnr werks = g_s_bestand_key-werks charg = g_s_bestand_key-charg BINARY SEARCH. * ELSE. SORT SEQUENCE = MATNR BWKEY READ TABLE bestand WITH KEY matnr = g_s_bestand_key-matnr bwkey = g_s_bestand_key-bwkey BINARY SEARCH. ENDIF. IF sy-subrc IS INITIAL. MOVE-CORRESPONDING bestand APPEND g_s_bestand_detail PERFORM PERFORM ENDIF. ENDFORM. TO g_s_bestand_detail. TO g_t_bestand_detail.

create_table_for_detail. list_output_detail. " USER_COMMAND_TOTALS

*&---------------------------------------------------------------------* * LIST_OUTPUT_DETAIL *&---------------------------------------------------------------------* FORM list_output_detail. * BUILD THE AUXILIARY INTERFACE TABLES FOR THE ALV IF g_cust_color = 'X'. "COLORIZE NUMERIC FIELDS ? layout-coltab_fieldname = 'FARBE_PRO_FELD'. ELSE. layout-info_fieldname = 'FARBE_PRO_ZEILE'. ENDIF. layout-f2code = '9PBP'. IF NOT bwbst IS INITIAL. layout-min_linesize = '92'. ENDIF. events-name = 'TOP_OF_PAGE'. events-form = 'UEBERSCHRIFT_DETAIL'. APPEND events. IF g_flag_break-b3 = 'X'. "N921164

BREAK-POINT ID mmim_rep_mb5b. "N921164 DYNAMIC BREAK-POINT : CHECK INPUT DATA FOR LIST VIEWER "N921164 ENDIF. "N921164 CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY' EXPORTING i_interface_check = g_flag_i_check i_callback_program = repid i_callback_pf_status_set = 'STATUS' i_callback_user_command = 'USER_COMMAND' is_layout = layout it_fieldcat = fieldcat[] it_special_groups = gruppen[] it_sort = sorttab[] i_default = 'X' i_save = 'A' is_variant = variante it_events = events[] is_print = g_s_print TABLES t_outtab = g_t_belege1 EXCEPTIONS OTHERS = 2.

"N599218

* DOES THE ALV RETURN WITH AN ERROR ? IF NOT sy-subrc IS INITIAL. "FEHLER VOM ALV ? MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. ENDFORM. " LIST_OUTPUT_DETAIL

*&---------------------------------------------------------------------* *& TOP_OF_PAGE_TOTALS *&---------------------------------------------------------------------* FORM top_of_page_totals. * GO ON WHEN THE REPORT RUNS IN PRINT MODE -> LAST LINE CHECK NOT sy-prdsn IS INITIAL. DATA: lr_content TYPE REF TO cl_salv_form_element. *... (1) CREATE THE INFORMATION TO BE DISPLAYED BY USING * THE ALV FORM ELEMENTS PERFORM top_of_page_totals_render CHANGING lr_content. *... (2) SENDING THE INFORMATION TO THE ALV * ONCE THE INFORATION TO BE DISPLAYED HAS BEEN * CREATED THE INFORMATION HAS TO BE SENT TO THE ALV * THIS IS DONE BY CALLING THE STATIC METHOD * CL_SALV_FORM_CONTENT=>SET( <CONTENT> ) WITH THE CONTENT * WHICH IS TO BE DISPLAYED. * ALTERNATIVLY THE FUNCTION MODULE REUSE_ALV_COMMENTARY_WRITE * CAN STILL BE USED. cl_salv_form_content=>set( lr_content ). ENDFORM. "TOP_OF_PAGE_TOTALS "#EC CALLED

*&---------------------------------------------------------------------*

*& TOP_OF_PAGE_TOTALS_RENDER *&---------------------------------------------------------------------* FORM top_of_page_totals_render CHANGING cr_content TYPE REF TO cl_salv_form_element. DATA: lr_grid lr_flow l_text(500) l_char(500) TYPE TYPE TYPE TYPE REF TO cl_salv_form_layout_grid, REF TO cl_salv_form_layout_flow, c, c.

*... CREATE A GRID CREATE OBJECT lr_grid. lr_flow = lr_grid->create_flow( row = 1 column = 1 ). IF bwbst IS INITIAL. STOCKS ONLY WRITE : sy-pagno NO-SIGN MOVE : g_s_header_77 ELSE. * STOCKS AND VALUES WRITE : sy-pagno NO-SIGN MOVE : g_s_header_91 ENDIF. * "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218

TO g_s_header_77-page. TO l_text. TO g_s_header_91-page. TO l_text.

* ADD LINE TO OBJECT lr_flow->create_text( text = l_text ). * COPY WHOLE HEADER OBJECT cr_content = lr_grid. ENDFORM. " TOP_OF_PAGE_TOTALS_RENDER

*----------------------------------------------------------------------* * TOP_OF_PAGE_RENDER. *----------------------------------------------------------------------* FORM top_of_page_render. * INTERFACE STRUCTUREBEGIN OF G_S_BESTAND. DATA: lr_content TYPE REF TO cl_salv_form_element. *... (1) CREATE THE INFORMATION TO BE DISPLAYED BY USING * THE ALV FORM ELEMENTS PERFORM create_alv_form_content_top CHANGING lr_content. *... (2) SENDING THE INFORMATION TO THE ALV * ONCE THE INFORATION TO BE DISPLAYED HAS BEEN * CREATED THE INFORMATION HAS TO BE SENT TO THE ALV * THIS IS DONE BY CALLING THE STATIC METHOD * CL_SALV_FORM_CONTENT=>SET( <CONTENT> ) WITH THE CONTENT * WHICH IS TO BE DISPLAYED. * ALTERNATIVLY THE FUNCTION MODULE REUSE_ALV_COMMENTARY_WRITE * CAN STILL BE USED. cl_salv_form_content=>set( lr_content ). ENDFORM. " TOP_OF_PAGE_RENDER

*----------------------------------------------------------------------* * CREATE_ALV_FORM_CONTENT_TOP *----------------------------------------------------------------------* * BAUSTELLE FORM create_alv_form_content_top CHANGING cr_content TYPE REF TO cl_salv_form_element. DATA: lr_grid lr_flow l_text(500) l_char(500) TYPE TYPE TYPE TYPE REF TO cl_salv_form_layout_grid, REF TO cl_salv_form_layout_flow, c, c.

DATA: l_row TYPE i, l_figure(24) TYPE c, l_flag_tied_empties(01) DATA: l_f_text(60)

TYPE c. "N999530

TYPE c.

*----------------------------------------------------------------------* *... CREATE A GRID CREATE OBJECT lr_grid. * THE CURRENT DATA ARE IN INTERFACE STRUCTURE G_S_BESTAND. * IN THE CASE THE REPORT RUN IN PRINT OR BACKGROUND MODE * --> PRINT THE OLD HEADLINES IF NOT sy-prdsn IS INITIAL. ADD 1 TO l_row. lr_flow = lr_grid->create_flow( row = l_row column = 1 ). * IF bwbst IS INITIAL. STOCKS ONLY WRITE : sy-pagno NO-SIGN MOVE : g_s_header_77 ELSE. STOCKS AND VALUES WRITE : sy-pagno NO-SIGN MOVE : g_s_header_91 ENDIF.

TO g_s_header_77-page. TO l_text. TO g_s_header_91-page. TO l_text.

ADD LINE TO OBJECT lr_flow->create_text( text = l_text ). ADD 1 ENDIF. TO l_row.

* FIRST LINE : PLANT OR VALUATION AREA --------------------------------ADD 1 TO l_row. lr_flow = lr_grid->create_flow( row = l_row column = 1 ). IF bwbst IS INITIAL. PERFORM f2200_read_t001 USING g_s_bestand-werks. WRITE g_s_bestand-werks TO l_f_text. CONDENSE l_f_text. CONCATENATE l_f_text t001w-name1 "N999530 "N999530 "N999530 "N999530

INTO l_f_text SEPARATED BY space. MOVE : text-020 l_f_text ELSE. * SHOW VALUATION AREA MOVE : text-025 g_s_bestand-bwkey ENDIF. TO l_text, TO l_text+g_offset_header. TO l_text, TO l_text+g_offset_header.

"N999530 "N999530 "N999530

* ADD LINE TO OBJECT lr_flow->create_text( text = l_text ). * SECOND LINE : MATERIAL NUMBER ---------------------------------------ADD 1 TO l_row. lr_flow = lr_grid->create_flow( row = l_row column = 1 ). MOVE : text-021 TO l_text. WRITE : g_s_bestand-matnr TO l_text+g_offset_header. * ADD LINE TO OBJECT lr_flow->create_text( text = l_text ). * THIRD LINE : MATERIAL SHORT TEXT ------------------------------------ADD 1 TO l_row. lr_flow = lr_grid->create_flow( row = l_row column = 1 ). PERFORM f2100_mat_text MOVE : text-022 g_s_makt-maktx USING g_s_bestand-matnr. TO l_text, TO l_text+g_offset_header.

* ADD LINE TO OBJECT lr_flow->create_text( text = l_text ). * FOURTH LINE : BATCH IF REQUIRED -------------------------------------IF xchar = 'X'. ADD 1 TO l_row. lr_flow = lr_grid->create_flow( row = l_row column = 1 ). MOVE : text-023 TO l_text, g_s_bestand-charg TO l_text+g_offset_header. * ADD LINE TO OBJECT lr_flow->create_text( text = l_text ). ENDIF.

* LINE : STOCK AND VALUE ON START DATE -----------------------------* WITH ONE EMPTY LINE ADD 2 TO l_row. lr_flow = lr_grid->create_flow( row = l_row column = 1 ). * CONVERT UNIT OF MEASUREMENT FROM INTERNAL TO EXTERNAL FORMAT "N1018717 WRITE : g_s_bestand-meins TO l_f_meins_external. "N1018717 CLEAR IF bwbst IS INITIAL. * STOCK ON START DATE MOVE : g_date_line_from l_text. TO l_text.

WRITE g_s_bestand-anfmenge * MOVE l_figure MOVE G_S_BESTAND-MEINS MOVE l_f_meins_external

TO l_figure UNIT g_s_bestand-meins. TO l_text+g_offset_qty(24). TO L_TEXT+G_OFFSET_UNIT. "N1018717 TO l_text+g_offset_unit. "N1018717

ELSE. * STOCKS AND VALUES ON START DATE MOVE : g_date_line_from TO l_text. WRITE g_s_bestand-anfmenge TO l_figure UNIT g_s_bestand-meins. MOVE l_figure TO l_text+g_offset_qty(24). * MOVE G_S_BESTAND-MEINS TO L_TEXT+G_OFFSET_UNIT. "N1018717 MOVE l_f_meins_external TO l_text+g_offset_unit. "N1018717 WRITE g_s_bestand-anfwert MOVE l_figure MOVE g_s_bestand-waers ENDIF. * TO l_figure CURRENCY g_s_bestand-waers. TO l_text+g_offset_value(24). TO l_text+g_offset_curr.

ADD LINE TO OBJECT lr_flow->create_text( text = l_text ).

* LINE : TOTAL QUANTITY AND VALUE OF GOODS RECEIPTS -------------------ADD 1 TO l_row. lr_flow = lr_grid->create_flow( row = l_row column = 1 ). CLEAR * l_text.

IF bwbst IS INITIAL. TOTAL QUANTITIES OF GOODS RECEIPTS MOVE : text-005 TO l_text+2. WRITE g_s_bestand-soll TO l_figure UNIT g_s_bestand-meins. MOVE l_figure TO l_text+g_offset_qty(24). * MOVE G_S_BESTAND-MEINS TO L_TEXT+G_OFFSET_UNIT. "N1018717 MOVE l_f_meins_external TO l_text+g_offset_unit. "N1018717 ELSE. * TOTAL QUANTITIES AND VALUES OF GOODS RECEIPTS MOVE : text-030 TO l_text+2. WRITE g_s_bestand-soll TO l_figure UNIT g_s_bestand-meins. MOVE l_figure TO l_text+g_offset_qty(24). * MOVE G_S_BESTAND-MEINS TO L_TEXT+G_OFFSET_UNIT. "N1018717 MOVE l_f_meins_external TO l_text+g_offset_unit. "N1018717 WRITE g_s_bestand-sollwert MOVE l_figure MOVE g_s_bestand-waers ENDIF. TO l_figure CURRENCY g_s_bestand-waers. TO l_text+g_offset_value(24). TO l_text+g_offset_curr.

* ADD LINE TO OBJECT lr_flow->create_text( text = l_text ). * LINE : TOTAL QUANTITY AND VALUE OF GOODS ISSUES ---------------------ADD 1 TO l_row. lr_flow = lr_grid->create_flow( row = l_row column = 1 ).

CLEAR *

l_text.

IF bwbst IS INITIAL. TOTAL QUANTITIES OF GOODS ISSUES MOVE : text-006 TO l_text+2. COMPUTE g_s_bestand-haben = g_s_bestand-haben * -1. WRITE g_s_bestand-haben TO l_figure UNIT g_s_bestand-meins. MOVE l_figure TO l_text+g_offset_qty(24). * MOVE G_S_BESTAND-MEINS TO L_TEXT+G_OFFSET_UNIT. "N1018717 MOVE l_f_meins_external TO l_text+g_offset_unit. "N1018717 ELSE. * TOTAL QUANTITIES OF GOODS ISSUES MOVE : text-031 TO l_text+2. COMPUTE g_s_bestand-haben = g_s_bestand-haben * -1. WRITE g_s_bestand-haben TO l_figure UNIT g_s_bestand-meins. MOVE l_figure TO l_text+g_offset_qty(24). * MOVE G_S_BESTAND-MEINS TO L_TEXT+G_OFFSET_UNIT. "N1018717 MOVE l_f_meins_external TO l_text+g_offset_unit. "N1018717 COMPUTE g_s_bestand-habenwert = g_s_bestand-habenwert * -1. WRITE g_s_bestand-habenwert TO l_figure CURRENCY g_s_bestand-waers. MOVE l_figure TO l_text+g_offset_value(24). MOVE g_s_bestand-waers TO l_text+g_offset_curr. ENDIF. * ADD LINE TO OBJECT lr_flow->create_text( text = l_text ). * LINE : STOCK AND VALUE ON END DATE -----------------------------ADD 1 TO l_row. lr_flow = lr_grid->create_flow( row = l_row column = 1 ). CLEAR * IF bwbst IS INITIAL. STOCK ON END DATE MOVE : g_date_line_to WRITE g_s_bestand-endmenge l_text.

MOVE l_figure MOVE G_S_BESTAND-MEINS MOVE l_f_meins_external ELSE. * STOCKS AND VALUES ON END DATE MOVE : g_date_line_to WRITE g_s_bestand-endmenge * * MOVE l_figure MOVE G_S_BESTAND-MEINS MOVE l_f_meins_external WRITE g_s_bestand-endwert MOVE l_figure MOVE g_s_bestand-waers ENDIF.

TO l_text. TO l_figure UNIT g_s_bestand-meins. TO l_text+g_offset_qty(24). TO L_TEXT+G_OFFSET_UNIT. "N1018717 TO l_text+g_offset_unit. "N1018717 TO l_text. TO l_figure UNIT g_s_bestand-meins. TO l_text+g_offset_qty(24). TO L_TEXT+G_OFFSET_UNIT. "N1018717 TO l_text+g_offset_unit. "N1018717 TO l_figure CURRENCY g_s_bestand-waers. TO l_text+g_offset_value(24). TO l_text+g_offset_curr.

* ADD LINE TO OBJECT lr_flow->create_text( text = l_text ). * COPY WHOLE HEADER OBJECT cr_content = lr_grid. ENDFORM. " CREATE_ALV_FORM_CONTENT_TOP

*----------------------------------------------------------------------* * CREATE_TABLE_TOTALS_HQ *----------------------------------------------------------------------* FORM create_table_totals_hq. * CREATE OUTPUT TABLE LOOP AT bestand. * PART 1 : CREATE HEADER TABLE G_T_TOTALS_HEADER MOVE-CORRESPONDING bestand TO g_s_totals_header. MOVE sobkz TO g_s_totals_header-sobkz. PERFORM f2100_mat_text USING bestand-matnr. MOVE g_s_makt-maktx TO g_s_totals_header-maktx. * IF bwbst IS INITIAL. MODE : STOCKS OR SPECIAL STOCKS PERFORM f2200_read_t001 USING bestand-werks. MOVE t001w-name1 TO g_s_totals_header-name1. ELSE. MODE : VALUATED STOCKS IF curm = '3'. VALUATION LEVEL IS COMPANY CODE SELECT SINGLE butxt FROM t001 INTO g_f_butxt WHERE bukrs = bestand-bwkey. IF sy-subrc IS INITIAL. MOVE g_f_butxt TO g_s_totals_header-name1. ELSE. CLEAR g_s_totals_header-name1. ENDIF. ELSE. VALUATION LEVEL IS PLANT -> TAKE THE NAME OF THE PLANT PERFORM f2200_read_t001 USING bestand-werks. MOVE t001w-name1 ENDIF. ENDIF. APPEND g_s_totals_header * TO g_s_totals_header-name1.

* *

TO g_t_totals_header.

PART 2 : CREATE 4 LINES IN ITEM TABLE G_T_TOTALS_ITEM CLEAR g_s_totals_item. MOVE : bestand-bwkey TO g_s_totals_item-bwkey, bestand-werks TO g_s_totals_item-werks, bestand-matnr TO g_s_totals_item-matnr, bestand-charg TO g_s_totals_item-charg, bestand-meins TO g_s_totals_item-meins, bestand-waers TO g_s_totals_item-waers.

LINE WITH THE STOCK ON START MOVE : g_date_line_from bestand-anfmenge bestand-anfwert PERFORM

DATE TO g_s_totals_item-stock_type, TO g_s_totals_item-menge, TO g_s_totals_item-wert. create_table_totals_hq_1.

LINE WITH THE GOOD RECEIPTS IF bwbst = 'X'. MOVE : text-030 bestand-soll bestand-sollwert ELSE. MOVE : text-005 bestand-soll ENDIF. PERFORM

TO g_s_totals_item-stock_type+2, TO g_s_totals_item-menge, TO g_s_totals_item-wert. TO g_s_totals_item-stock_type+2, TO g_s_totals_item-menge. create_table_totals_hq_1.

LINE WITH THE GOOD ISSUES IF bwbst = 'X'. MOVE : text-031 g_s_totals_item-menge g_s_totals_item-wert ELSE. MOVE : text-006 g_s_totals_item-menge ENDIF. PERFORM

TO g_s_totals_item-stock_type+2. = bestand-haben * -1. = bestand-habenwert * -1. TO g_s_totals_item-stock_type+2. = bestand-haben * -1. create_table_totals_hq_1.

LINE WITH THE TOCK ON END DATE MOVE : g_date_line_to TO g_s_totals_item-stock_type, bestand-endmenge TO g_s_totals_item-menge, bestand-endwert TO g_s_totals_item-wert. PERFORM ENDLOOP. create_table_totals_hq_1. " CREATE_TABLE_TOTALS_HQ

ENDFORM.

*----------------------------------------------------------------------* * CREATE_TABLE_TOTALS_HQ_1. *----------------------------------------------------------------------* * COLORIZE THE NUMERIC FIELDS DEPENDING ON THE SIGN AND APPEND THE * ENTRIES INTO TABLE G_T_TOTALS_ITEM FORM create_table_totals_hq_1. REFRESH CLEAR g_t_color. g_s_color. > 0. g_s_color-fieldname, g_s_color-color-col, g_s_color-color-int. "GREEN

* COLORIZE THE QUNTITIES ALWAYS IF g_s_totals_item-menge * POSITIVE VALUE -> GREEN MOVE : 'MENGE' TO '5' TO '0' TO

APPEND g_s_color MOVE : 'MEINS' '5' '0' APPEND g_s_color *

TO g_t_color. TO TO TO TO g_s_color-fieldname, g_s_color-color-col, g_s_color-color-int. g_t_color. < 0. g_s_color-fieldname, g_s_color-color-col, g_s_color-color-int. g_t_color. g_s_color-fieldname, g_s_color-color-col, g_s_color-color-int. g_t_color. "RED "GREEN

ELSEIF g_s_totals_item-menge NEGATIVE VALUE -> RED MOVE : 'MENGE' TO '6' TO '0' TO APPEND g_s_color TO MOVE : 'MEINS' '6' '0' APPEND g_s_color ENDIF. TO TO TO TO

"RED

IF bwbst = 'X'. * COLORIZE THE VALUES ONLY IN MODE VALUATED STOCK IF g_s_totals_item-wert > 0. * POSITIVE VALUE -> GREEN MOVE : 'WERT' TO g_s_color-fieldname, '5' TO g_s_color-color-col, '0' TO g_s_color-color-int. APPEND g_s_color TO g_t_color. MOVE : 'WAERS' '5' '0' APPEND g_s_color * TO TO TO TO g_s_color-fieldname, g_s_color-color-col, g_s_color-color-int. g_t_color. < 0. g_s_color-fieldname, g_s_color-color-col, g_s_color-color-int. g_t_color. g_s_color-fieldname, g_s_color-color-col, g_s_color-color-int. g_t_color.

"GREEN

"GREEN

ELSEIF g_s_totals_item-wert NEGATIVE VALUE -> RED MOVE : 'WERT' TO '6' TO '0' TO APPEND g_s_color TO MOVE : 'WAERS' '6' '0' APPEND g_s_color ENDIF. ENDIF. TO TO TO TO

"RED

"RED

IF g_t_color[] IS INITIAL. CLEAR : g_s_totals_item-color. ELSE. * CUSTOMIZING : SET THE COLOR INFORMATION IF g_cust_color = 'X'. MOVE g_t_color[] TO g_s_totals_item-color. ENDIF. ENDIF. ADD 1 APPEND g_s_totals_item CLEAR : TO g_s_totals_item-counter. TO g_t_totals_item. g_s_totals_item-stock_type.

ENDFORM.

" CREATE_TABLE_TOTALS_HQ_1.

*----------------------------------------------------------------------* * CREATE_TABLE_FOR_DETAIL *----------------------------------------------------------------------* FORM create_table_for_detail. STATICS : l_flag_sorted(01) DATA : l_tabix TYPE c. LIKE sy-tabix.

* SORT TABLE WITH THE DOCUMENTS IF l_flag_sorted IS INITIAL. SORT g_t_mseg_lean BY matnr werks charg budat mblnr zeile belnr. MOVE 'X' TO l_flag_sorted. ENDIF. REFRESH g_t_belege1.

* FIND THE FIRST ENTRY WITH THIS MATERIAL NUMBER READ TABLE g_t_mseg_lean INTO g_s_mseg_lean WITH KEY matnr = g_s_bestand_detail-matnr BINARY SEARCH. IF sy-subrc IS INITIAL. MOVE sy-tabix LOOP AT g_t_mseg_lean * TO l_tabix. INTO g_s_mseg_lean FROM l_tabix.

LEAVE THIS LOOP WHEN THE MATERIAL NUMBER CHANGES IF g_s_mseg_lean-matnr NE g_s_bestand_detail-matnr. EXIT. ENDIF. IF bwbst IS INITIAL. CHECK : xchar IS INITIAL OR g_s_mseg_lean-charg = bestand-charg. MOVE-CORRESPONDING g_s_mseg_lean TO g_t_belege1.

ENRICH SOME FIELDS WITH COLOR AND NUMERIC FIELDS WITH SIGN PERFORM f9500_set_color_and_sign USING g_t_belege1 'G_T_BELEGE1'. APPEND g_t_belege1. ELSE. GET THE VALUATION AREA FOR THIS PLANT PERFORM f9300_read_organ USING c_werks g_s_mseg_lean-werks. CHECK : g_s_organ-bwkey = bestand-bwkey. MOVE-CORRESPONDING g_s_mseg_lean TO g_t_belege1. "184465

ENRICH SOME FIELDS WITH COLOR AND NUMERIC FIELDS WITH SIGN PERFORM f9500_set_color_and_sign USING g_t_belege1 'G_T_BELEGE1'.

APPEND ENDIF. ENDLOOP. ENDIF. ENDFORM.

g_t_belege1.

" CREATE_TABLE_FOR_DETAIL

*----------------------------------------------------------------------* * CREATE_TABLE_TOTALS_FLAT *----------------------------------------------------------------------* FORM create_table_totals_flat. ****ADDED BY SONATA PERFORM get_order. WAIT UP TO 1 SECONDS. SORT bestand[] BY matnr charg. SORT it_sh BY matnr charg. SORT SORT SORT SORT lt_mseg BY matnr charg. lt_mseg1 BY matnr charg. lt_mseg2 BY matnr charg. lt_mseg3 BY matnr charg.

lt_m_101 = lt_mseg. lt_m1_101 = lt_mseg1. lt_m2_101 = lt_mseg2. lt_m3_101 = lt_mseg3. DELETE DELETE DELETE DELETE DELETE DELETE DELETE DELETE lt_mseg WHERE bwart = '101'. lt_mseg1 WHERE bwart = '101'. lt_mseg2 WHERE bwart = '101'. lt_mseg3 WHERE bwart = '101'. lt_m_101 WHERE lt_m1_101 WHERE lt_m2_101 WHERE lt_m3_101 WHERE ( ( ( ( bwart bwart bwart bwart = = = = '261' '261' '261' '261' OR OR OR OR bwart bwart bwart bwart = = = = '262' '262' '262' '262' ). ). ). ).

*****END OF CODE * CREATE OUTPUT TABLE G-T-TOTALS_FLAT LOOP AT bestand. * REFRESH g_t_color. MOVE-CORRESPONDING bestand MOVE sobkz TO g_s_totals_flat. TO g_s_totals_flat-sobkz.

PERFORM f2100_mat_text USING bestand-matnr. * SHOW THE GI WITH NEGATIVE SIGN g_s_totals_flat-haben = g_s_totals_flat-haben * -1.

*BREAK HNBIR. MOVE : g_s_makt-maktx TO g_s_totals_flat-maktx, datum-low TO g_s_totals_flat-start_date, datum-high TO g_s_totals_flat-end_date. * *==========================================================NILKANTH 17.01.2011 13:03:41

IF bestand-endwert = '0.00' OR bestand-endmenge = '0.000'. g_s_totals_flat-cl_rate = '0.00'. ELSE. g_s_totals_flat-cl_rate = ( bestand-endwert * 1000 ) / bestand-endmenge. cl_stock = bestand-endwert / bestand-endmenge. ENDIF. IF bestand-anfwert = '0.00' OR bestand-anfmenge = '0.00'. g_s_totals_flat-op_rate = '0.00'. ELSE. g_s_totals_flat-op_rate = ( bestand-anfwert * 1000 ) / bestand-anfmenge. ENDIF. * ==========================================================NILKANTH 17.01.2011 13:03:41 READ TABLE imara WITH KEY matnr = bestand-matnr. MOVE imara-mtart MOVE imara-matkl TO g_s_totals_flat-mtart. TO g_s_totals_flat-matkl.

READ TABLE it023t WITH KEY matkl = g_s_totals_flat-matkl. IF sy-subrc = 0. MOVE it023t-wgbez TO g_s_totals_flat-wgbez. ENDIF. * GET THE NAME OF THIS PLANT "N999530 PERFORM f2200_read_t001 USING g_s_totals_flat-werks. "N999530 MOVE t001w-name1 TO g_s_totals_flat-name1. "N999530

****CODE ADDED BY SONATA DATA: lv_ind TYPE sy-index. DATA: lv_in TYPE sy-index. DATA: ls LIKE LINE OF g_t_totals_flat. DATA: lw_matnr TYPE matnr. READ TABLE it_sh WITH KEY matnr = bestand-matnr TRANSPORTING NO FIELDS. IF sy-subrc = 0. lv_ind = sy-tabix. LOOP AT it_sh INTO wa_sh FROM lv_ind. CLEAR:g_t_color. IF wa_sh-matnr = bestand-matnr. g_s_totals_flat-mat_ty = wa_sh-mat_ty. g_s_totals_flat-mat_gp = wa_sh-mat_gp. g_s_totals_flat-matnr1 = wa_sh-matnr1. g_s_totals_flat-mat_txt = wa_sh-mat_txt. g_s_totals_flat-charg = wa_sh-charg. g_s_totals_flat-cons = wa_sh-cons + wa_sh-cons1. g_s_totals_flat-st_tran = wa_sh-st_tran + wa_sh-st_tran1. g_s_totals_flat-mm_tran = wa_sh-mm_tran + wa_sh-mm_tran1. g_s_totals_flat-sale = wa_sh-sale + wa_sh-sale1. PERFORM colorize_totals_flat USING 'ANFMENGE'. PERFORM colorize_totals_flat USING 'SOLL'. PERFORM colorize_totals_flat USING 'HABEN'. PERFORM colorize_totals_flat USING 'ENDMENGE'. PERFORM colorize_totals_flat USING 'CONS'. PERFORM colorize_totals_flat USING 'ST_TRAN'. PERFORM colorize_totals_flat USING 'MM_TRAN'.

PERFORM colorize_totals_flat USING 'SALE'. IF g_t_color[] IS INITIAL. CLEAR g_s_totals_flat-color. ELSE. MOVE g_t_color[] TO g_s_totals_flat-color. ENDIF. APPEND g_s_totals_flat TO g_t_totals_flat. CLEAR:g_s_totals_flat-anfmenge,g_s_totals_flat-endmenge, g_s_totals_flat-haben,g_s_totals_flat-soll. CLEAR: g_s_totals_flat-mat_ty, g_s_totals_flat-mat_gp,g_s_totals_flatmatnr1, g_s_totals_flat-mat_txt,g_s_totals_flat-charg,g_s_totals_flat-co ns, g_s_totals_flat-st_tran,g_s_totals_flat-mm_tran,g_s_totals_flatsale. DATA: lv_rat TYPE menge_d, lv_rat1 TYPE menge_d, lv_rat2 TYPE menge_d, lv_rat3 TYPE menge_d, lv_tab LIKE sy-tabix, lv_charg TYPE charg_d, lv_charg1 TYPE charg_d, lv_charg2 TYPE charg_d, lv_charg3 TYPE charg_d. ********FOR HALB MATERIALS LEVEL 1 IF wa_sh-mat_ty = 'HALB'. lw_matnr = wa_sh-matnr1. lv_rat = wa_sh-cons + wa_sh-cons1. lv_charg = wa_sh-charg. CLEAR: wa_sh. * LOOP AT it_fert INTO wa_sh WHERE matnr = lw_matnr. READ TABLE lt_mseg WITH KEY matnr = lw_matnr charg = lv_charg flag = '' TRANSPORTING NO FIELDS. IF sy-subrc = 0. lv_in = sy-tabix. LOOP AT lt_mseg INTO lw_mseg FROM lv_in . IF lw_mseg-matnr = lw_matnr AND lw_mseg-charg = lv_charg. "and l w_mseg-flag <> 'X' AND wa_sh-matnr = lw_matnr. * g_s_totals_flat-charg = lw_mseg-charg. READ TABLE lt_ord INTO wa_ord WITH KEY aufnr = lw_mseg-aufnr. IF sy-subrc = 0. READ TABLE lt_matnr INTO wa_mat WITH KEY matnr = wa_ord-matn r. IF sy-subrc = 0. g_s_totals_flat-mat_ty = wa_mat-mtart. g_s_totals_flat-mat_gp = wa_mat-matkl. g_s_totals_flat-matnr1 = wa_mat-matnr. g_s_totals_flat-mat_txt = wa_mat-maktx. g_s_totals_flat-charg = wa_ord-charg. ENDIF. ENDIF. IF lw_mseg-bwart = '261'. IF wa_mat-mtart = 'FERT'. READ TABLE lt_fert1 INTO lw_fert WITH KEY aufnr = wa_ord-a

ufnr matnr = wa_ord-m atnr charg = wa_ord-c harg flag = ''. IF sy-subrc = 0. lv_tab = sy-tabix. DATA: lv_dec TYPE menge_d. READ TABLE lt_m_101 INTO lw_mseg1 WITH KEY bwart = '101' matnr = lw_mat nr charg = lv_cha rg. IF sy-subrc = 0. CLEAR: lv_dec. CALL FUNCTION 'ZRMC_DIV' EXPORTING a_menge = lv_rat b_menge = lw_mseg1-menge c_mul = lw_fert-menge CHANGING gv_result = lv_dec. g_s_totals_flat-cons = lv_dec. ELSE. g_s_totals_flat-cons = lw_fert-menge. ENDIF. * * lw_fert-flag = 'X'. MODIFY lt_fert1 FROM lw_fert INDEX lv_tab TRANSPORTING flag . ELSE. g_s_totals_flat-cons = lw_mseg-menge. ENDIF. ELSE. g_s_totals_flat-cons = lw_mseg-menge. ENDIF. PERFORM colorize_totals_flat USING 'ANFMENGE'. PERFORM colorize_totals_flat USING 'SOLL'. PERFORM colorize_totals_flat USING 'HABEN'. PERFORM colorize_totals_flat USING 'ENDMENGE'. PERFORM colorize_totals_flat USING 'CONS'. PERFORM colorize_totals_flat USING 'ST_TRAN'. PERFORM colorize_totals_flat USING 'MM_TRAN'. PERFORM colorize_totals_flat USING 'SALE'. IF g_t_color[] IS INITIAL. CLEAR g_s_totals_flat-color. ELSE. MOVE g_t_color[] TO g_s_totals_flat-color. ENDIF. APPEND g_s_totals_flat TO g_t_totals_flat. IF sy-subrc = 0. lw_mseg-flag = 'X'. MODIFY lt_mseg FROM lw_mseg TRANSPORTING flag WHERE matnr = lw_matnr AND aufnr = lw_mseg-aufnr AND charg = lv_charg. ENDIF.

* * * *

"TO CALCULATE THE RATIO CLEAR: lv_rat1, lv_charg1. lv_rat1 = g_s_totals_flat-cons. lv_charg1 = g_s_totals_flat-charg. ********************************************************** CLEAR:g_s_totals_flat-anfmenge,g_s_totals_flat-endmenge, g_s_totals_flat-haben,g_s_totals_flat-soll. CLEAR: g_s_totals_flat-mat_ty, g_s_totals_flat-mat_gp,g_s_to tals_flat-matnr1, g_s_totals_flat-mat_txt,g_s_totals_flat-charg,g_s_tota ls_flat-cons, g_s_totals_flat-st_tran,g_s_totals_flat-mm_tran,g_s_to tals_flat-sale. ********FOR HALB MATERIALS LEVEL 2 IF wa_mat-mtart = 'HALB'. lw_matnr = wa_mat-matnr. CLEAR: wa_ord, wa_mat. READ TABLE lt_mseg1 WITH KEY matnr = lw_matnr charg = lv_c harg1 flag = '' TRANSPORTING NO FIELDS. IF sy-subrc = 0. lv_in = sy-tabix. LOOP AT lt_mseg1 INTO lw_mseg FROM lv_in . IF lw_mseg-matnr = lw_matnr AND lw_mseg-charg = lv_cha rg1 ."AND "lw_mseg-flag <> 'X' AND * flag <> 'X'. seg-aufnr. IF sy-subrc = 0. READ TABLE lt_matnr1 INTO wa_mat WITH KEY matnr = wa_ord-matnr. IF sy-subrc = 0. g_s_totals_flat-mat_ty = wa_mat-mtart. g_s_totals_flat-mat_gp = wa_mat-matkl. g_s_totals_flat-matnr1 = wa_mat-matnr. g_s_totals_flat-mat_txt = wa_mat-maktx. g_s_totals_flat-charg = wa_ord-charg. ENDIF. ENDIF. IF lw_mseg-bwart = '261'. IF wa_mat-mtart = 'FERT'. READ TABLE lt_fert2 INTO lw_fert WITH KEY aufnr = wa_ord-aufnr matnr = wa_ord -matnr charg = wa_ordcharg flag = ''. IF sy-subrc = 0. lv_tab = sy-tabix. ******TO CALCULATE THE RATIO READ TABLE lt_m1_101 INTO lw_mseg1 WITH KEY bw art = '101' matnr = lw_matn r charg = wa_ordLOOP AT lt_mseg1 INTO lw_mseg WHERE matnr = lw_matnr AND wa_sh-matnr = lw_matnr. READ TABLE lt_ord1 INTO wa_ord WITH KEY aufnr = lw_m

charg. IF sy-subrc = 0. CLEAR: lv_dec. CALL FUNCTION 'ZRMC_DIV' EXPORTING a_menge = lv_rat b_menge = lw_mseg1-menge c_mul = lw_fert-menge CHANGING gv_result = lv_dec. g_s_totals_flat-cons = lv_dec. ELSE. g_s_totals_flat-cons = lw_fert-menge. ENDIF. lw_fert-flag = 'X'. MODIFY lt_fert2 FROM lw_fert INDEX lv_tab TRANSPORTING flag . ELSE. g_s_totals_flat-cons = lw_mseg-menge. ENDIF. ELSE. g_s_totals_flat-cons = lw_mseg-menge. ENDIF. PERFORM colorize_totals_flat USING 'ANFMENGE'. PERFORM colorize_totals_flat USING 'SOLL'. PERFORM colorize_totals_flat USING 'HABEN'. PERFORM colorize_totals_flat USING 'ENDMENGE'. PERFORM colorize_totals_flat USING 'CONS'. PERFORM colorize_totals_flat USING 'ST_TRAN'. PERFORM colorize_totals_flat USING 'MM_TRAN'. PERFORM colorize_totals_flat USING 'SALE'. IF g_t_color[] IS INITIAL. CLEAR g_s_totals_flat-color. ELSE. MOVE g_t_color[] TO g_s_totals_flat-color . ENDIF. APPEND g_s_totals_flat TO g_t_totals_flat. IF sy-subrc = 0. lw_mseg-flag = 'X'. MODIFY lt_mseg1 FROM lw_mseg TRANSPORTING flag WHERE matnr = lw_ma AND aufnr = lw_ms AND charg = lv_ch ENDIF. "TO CALCULATE THE RATIO CLEAR: lv_rat2,lv_charg2. lv_rat2 = g_s_totals_flat-cons. lv_charg2 = g_s_totals_flat-charg. ********************************************************** CLEAR:g_s_totals_flat-anfmenge,g_s_totals_flat-end menge,

* *

* * tnr * eg-aufnr * arg1.

g_s_totals_flat-haben,g_s_totals_flat-soll. CLEAR: g_s_totals_flat-mat_ty, g_s_totals_flat-mat _gp,g_s_totals_flat-matnr1, g_s_totals_flat-mat_txt,g_s_totals_flat-char g,g_s_totals_flat-cons, g_s_totals_flat-st_tran,g_s_totals_flat-mm_t ran,g_s_totals_flat-sale. *******************FOR HALB MATERIALS LEVEL 3 IF wa_mat-mtart = 'HALB'. " LEVEL 3 lw_matnr = wa_mat-matnr. CLEAR: wa_ord, wa_mat. READ TABLE lt_mseg2 WITH KEY matnr = lw_matnr ch arg = lv_charg2 flag = '' TRANSPORTING NO FIELDS. IF sy-subrc = 0. lv_in = sy-tabix. LOOP AT lt_mseg2 INTO lw_mseg FROM lv_in . IF lw_mseg-matnr = lw_matnr AND lw_mseg-char g = lv_charg2 ."AND "lw_mseg-flag <> 'X' AND * LOOP AT lt_mseg1 INTO lw_mseg WHERE matnr = lw_matnr AND flag <> 'X'. wa_sh-matnr = lw_matnr. READ TABLE lt_ord2 INTO wa_ord WITH KEY au fnr = lw_mseg-aufnr. IF sy-subrc = 0. READ TABLE lt_matnr2 INTO wa_mat WITH KE Y matnr = wa_ord-matnr. IF sy-subrc = 0. g_s_totals_flat-mat_ty = wa_mat-mtart. g_s_totals_flat-mat_gp = wa_mat-matkl. g_s_totals_flat-matnr1 = wa_mat-matnr. g_s_totals_flat-mat_txt = wa_mat-maktx . g_s_totals_flat-charg = wa_ord-charg . ENDIF. ENDIF. IF lw_mseg-bwart = '261'. IF wa_mat-mtart = 'FERT'. READ TABLE lt_fert3 INTO lw_fert WITH KEY aufnr = wa_ord-aufnr matnr = wa_ord-m atnr charg = wa_ord -charg flag = ''. IF sy-subrc = 0. lv_tab = sy-tabix. ***TO CALCULATE RATIO READ TABLE lt_m2_101 INTO lw_mseg1 W ITH KEY bwart = '101' matnr = lw_matn r charg = wa_ordcharg. IF sy-subrc = 0. CLEAR: lv_dec. CALL FUNCTION 'ZRMC_DIV' EXPORTING

a_menge b_menge c_mul CHANGING gv_result

= lv_rat = lw_mseg1-menge = lw_fert-menge = lv_dec.

g_s_totals_flat-cons = lv_dec. ELSE. g_s_totals_flat-cons = lw_fert-men ge. * lv_tab * . ENDIF. ELSE. g_s_totals_flat-cons = lw_mseg-menge. ENDIF. PERFORM colorize_totals_flat USING 'A NFMENGE'. PERFORM colorize_totals_flat OLL'. PERFORM colorize_totals_flat ABEN'. PERFORM colorize_totals_flat NDMENGE'. PERFORM colorize_totals_flat ONS'. PERFORM colorize_totals_flat T_TRAN'. PERFORM colorize_totals_flat M_TRAN'. PERFORM colorize_totals_flat ALE'. IF g_t_color[] IS INITIAL. CLEAR g_s_totals_flat -color. ELSE. MOVE g_t_color[] flat-color. ENDIF. APPEND g_s_totals_flat TO g_t_totals_ flat. * TING * nr = * nr = * rg = IF sy-subrc = 0. lw_mseg-flag = 'X'. MODIFY lt_mseg2 FROM lw_mseg TRANSPOR flag WHERE mat lw_matnr AND auf lw_mseg-aufnr AND cha lv_charg2. ENDIF. TO g_s_totals_ USING 'S USING 'M USING 'S USING 'C USING 'E USING 'H USING 'S ENDIF. lw_fert-flag = 'X'. MODIFY lt_fert3 FROM lw_fert INDEX TRANSPORTING flag . ELSE. g_s_totals_flat-cons = lw_mseg-menge

"TO CALCULATE THE RATIO CLEAR: lv_rat3,lv_charg3. lv_rat3 = g_s_totals_flat-cons. lv_charg3 = g_s_totals_flat-charg. ********************************************************** CLEAR:g_s_totals_flat-anfmenge,g_s_total s_flat-endmenge, g_s_totals_flat-haben,g_s_totals_ flat-soll. CLEAR: g_s_totals_flat-mat_ty, g_s_total s_flat-mat_gp,g_s_totals_flat-matnr1, g_s_totals_flat-mat_txt,g_s_totals _flat-charg,g_s_totals_flat-cons, g_s_totals_flat-st_tran,g_s_totals _flat-mm_tran,g_s_totals_flat-sale. *******************FOR HALB MATERIALS LEVEL 4 IF wa_mat-mtart = 'HALB'. " LEVEL 3 lw_matnr = wa_mat-matnr. CLEAR: wa_ord, wa_mat. READ TABLE lt_mseg3 WITH KEY matnr = l w_matnr charg = lv_charg3 flag = '' TRANSPORTING NO FIELDS. IF sy-subrc = 0. lv_in = sy-tabix. LOOP AT lt_mseg3 INTO lw_mseg FROM l v_in . IF lw_mseg-matnr = lw_matnr AND lw _mseg-charg = lv_charg3." AND "lw_mseg-flag <> 'X' AND wa_sh-matnr = lw_matnr. READ TABLE lt_ord3 INTO wa_ord W ITH KEY aufnr = lw_mseg-aufnr. IF sy-subrc = 0. READ TABLE lt_matnr3 INTO wa_m at WITH KEY matnr = wa_ord-matnr. IF sy-subrc = 0. g_s_totals_flat-mat_ty = wa_ mat-mtart. g_s_totals_flat-mat_gp = wa_ mat-matkl. g_s_totals_flat-matnr1 = wa_ mat-matnr. g_s_totals_flat-mat_txt = wa _mat-maktx. g_s_totals_flat-charg = wa _ord-charg. ENDIF. ENDIF. IF lw_mseg-bwart = '261'. IF wa_mat-mtart = 'FERT'. READ TABLE lt_fert4 INTO lw_ fert WITH KEY aufnr = wa_ord-aufnr matnr = wa_ord-m atnr charg = wa_ordcharg flag = ''. IF sy-subrc = 0. lv_tab = sy-tabix. ***** TO CALCULATE RATIO

READ TABLE lt_m3_101 INTO lw_mseg1 WITH KEY bwart = '101' matnr = lw_matnr charg = wa_ord-cha rg. IF sy-subrc = 0. CLEAR: lv_dec. CALL FUNCTION 'ZRMC_DIV' EXPORTING a_menge = lv_rat b_menge = lw_mseg1 -menge c_mul menge CHANGING gv_result = lv_dec. g_s_totals_flat-cons = l v_dec. ELSE. g_s_totals_flat-cons = l w_fert-menge. * ert INDEX lv_tab * . mseg-menge. ENDIF. ELSE. g_s_totals_flat-cons = lw_ms eg-menge. ENDIF. PERFORM colorize_totals_flat USING 'ANFMENGE'. PERFORM colorize_totals_flat USING 'SOLL'. PERFORM colorize_totals_flat USING 'HABEN'. PERFORM colorize_totals_flat USING 'ENDMENGE'. PERFORM colorize_totals_flat USING 'CONS'. PERFORM colorize_totals_flat USING 'ST_TRAN'. PERFORM colorize_totals_flat USING 'MM_TRAN'. PERFORM colorize_totals_flat USING 'SALE'. IF g_t_color[] IS INITIAL. CLEAR g_s_t otals_flat-color. ELSE. MOVE g_t_color[] _s_totals_flat-color. ENDIF. APPEND g_s_totals_flat TO g TO g ENDIF. lw_fert-flag = 'X'. MODIFY lt_fert4 FROM lw_f TRANSPORTING flag ELSE. g_s_totals_flat-cons = lw_ = lw_fert-

_t_totals_flat. * g TRANSPORTING * WHERE matnr = * AND aufnr = * AND charg = IF sy-subrc = 0. lw_mseg-flag = 'X'. MODIFY lt_mseg3 FROM lw_mse flag lw_matnr lw_mseg-aufnr lv_charg3. ENDIF. CLEAR:g_s_totals_flat-anfmenge ,g_s_totals_flat-endmenge, g_s_totals_flat-haben,g _s_totals_flat-soll. CLEAR: g_s_totals_flat-mat_ty, g_s_totals_flat-mat_gp,g_s_totals_flat-matnr1, g_s_totals_flat-mat_txt, g_s_totals_flat-charg,g_s_totals_flat-cons, g_s_totals_flat-st_tran, g_s_totals_flat-mm_tran,g_s_totals_flat-sale. ELSE. "LEVEL 3 READ TABLE g_t_totals_flat INT O ls WITH KEY charg = lw_mseg-charg matnr1 = g_s_totals_flat-matnr1 matnr = g_s_totals_flat-matnr. IF sy-subrc = 0. READ TABLE lt_m3_101 INTO lw _mseg1 WITH KEY bwart = '101' matnr = lw_matn r charg = wa_ordcharg. IF sy-subrc = 0. CLEAR: lv_dec. CALL FUNCTION 'ZRMC_DIV' EXPORTING a_menge = lv_rat b_menge = lw_mseg1-m enge c_mul nge CHANGING gv_result = lv_dec. g_s_totals_flat-cons = lscons - lv_dec. * g_s_totals_flat-cons = ls -cons - ( lw_mseg-menge * ( lv_rat3 / lw_mseg1-menge ) ). ELSE. g_s_totals_flat-cons = lscons - lw_mseg-menge. ENDIF. * g_s_totals_flat-cons = ls-c = lw_mseg-me

ons - lw_mseg-menge. PERFORM colorize_totals_fla t t t t t t t t USING 'ANFMENGE'. PERFORM colorize_totals_fla USING 'SOLL'. PERFORM colorize_totals_fla USING 'HABEN'. PERFORM colorize_totals_fla USING 'ENDMENGE'. PERFORM colorize_totals_fla USING 'CONS'. PERFORM colorize_totals_fla USING 'ST_TRAN'. PERFORM colorize_totals_fla USING 'MM_TRAN'. PERFORM colorize_totals_fla USING 'SALE'. IF g_t_color[] IS INITIAL. CLEAR g_s _totals_flat-color. ELSE. MOVE g_t_color[] g_s_totals_flat-color. ENDIF. MODIFY g_t_totals_flat FROM g_s_totals_flat TRANSPORTING cons color WHERE charg = lw_mseg-charg AND matnr1 = g_s_totals_flat-matnr1 AND matnr = g_s_totals_flat-matnr. ENDIF. ENDIF. ELSE. EXIT. ENDIF. ENDLOOP. ENDIF. ENDIF. " LEVEL 4 ELSE. "LEVEL 3 READ TABLE g_t_totals_flat INTO ls WITH KEY charg = lw_mseg-charg matnr1 = g_s_totals_flat-matnr1 matnr = g_s_totals_flat-matnr. IF sy-subrc = 0. READ TABLE lt_m2_101 INTO lw_mseg1 WIT H KEY bwart = '101' matnr = lw_matn r charg = wa_ordcharg. IF sy-subrc = 0. CLEAR: lv_dec. CALL FUNCTION 'ZRMC_DIV' EXPORTING a_menge = lv_rat TO

b_menge = lw_mseg1-menge c_mul = lw_mseg-menge CHANGING gv_result = lv_dec. g_s_totals_flat-cons = ls-cons - lv_ dec. * g_s_totals_flat-cons = ls-cons - ( lw_mseg-menge * ( lv_rat2 / lw_mseg1-menge ) ). ELSE. g_s_totals_flat-cons = ls-cons - lw_ mseg-menge. ENDIF. * seg-menge. 'ANFMENGE'. PERFORM colorize_totals_flat 'SOLL'. PERFORM colorize_totals_flat 'HABEN'. PERFORM colorize_totals_flat 'ENDMENGE'. PERFORM colorize_totals_flat 'CONS'. PERFORM colorize_totals_flat 'ST_TRAN'. PERFORM colorize_totals_flat 'MM_TRAN'. PERFORM colorize_totals_flat 'SALE'. IF g_t_color[] IS INITIAL. CLEAR g_s_totals_fl at-color. ELSE. MOVE g_t_color[] s_flat-color. ENDIF. MODIFY g_t_totals_flat FROM g_s_totals _flat TRANSPORTING cons color WHERE charg = lw _mseg-charg AND matnr1 = g _s_totals_flat-matnr1 AND matnr = g_s_totals_flat-matnr. ENDIF. ENDIF. ELSE. EXIT. ENDIF. ENDLOOP. ENDIF. ENDIF. TO g_s_total USING USING USING USING USING USING USING g_s_totals_flat-cons = ls-cons - lw_m PERFORM colorize_totals_flat USING

" LEVEL 3

ELSE. "LEVEL 2 READ TABLE g_t_totals_flat INTO ls WITH KEY charg

= lw_mseg-charg matnr1 = g_s_totals_flat-matnr1 matnr = g_s_totals_flat-matnr. IF sy-subrc = 0. READ TABLE lt_m1_101 INTO lw_mseg1 WITH KEY bwar t = '101' matnr = lw_matn r charg = wa_ordcharg. IF sy-subrc = 0. CLEAR: lv_dec. CALL FUNCTION 'ZRMC_DIV' EXPORTING a_menge = lv_rat b_menge = lw_mseg1-menge c_mul = lw_mseg-menge CHANGING gv_result = lv_dec. g_s_totals_flat-cons = ls-cons - lv_dec. * g_s_totals_flat-cons = ls-cons - ( lw_mseg-me nge * ( lv_rat1 / lw_mseg1-menge ) ). ELSE. g_s_totals_flat-cons = ls-cons - lw_mseg-menge . ENDIF. * . PERFORM colorize_totals_flat PERFORM colorize_totals_flat PERFORM colorize_totals_flat . PERFORM colorize_totals_flat USING 'CONS'. PERFORM colorize_totals_flat USING 'ST_TRAN'. PERFORM colorize_totals_flat USING 'MM_TRAN'. PERFORM colorize_totals_flat USING 'SALE'. IF g_t_color[] IS INITIAL. CLEAR g_s_totals_flat-color. ELSE. MOVE g_t_color[] TO g_s_totals_flat-col or. ENDIF. MODIFY g_t_totals_flat FROM g_s_totals_flat TRAN SPORTING cons color WHERE charg = lw_mseg-char g AND matnr1 = g_s_totals_ flat-matnr1 AND matnr = g_s_totals _flat-matnr. ENDIF. ENDIF. USING 'SOLL'. USING 'HABEN'. USING 'ENDMENGE' g_s_totals_flat-cons = ls-cons - lw_mseg-menge. PERFORM colorize_totals_flat USING 'ANFMENGE'

ELSE. EXIT. ENDIF. ENDLOOP. ENDIF. ENDIF. ELSE. * charg

"LEVEL 2 "LEVEL 1

READ TABLE g_t_totals_flat INTO ls WITH KEY charg = lw_msegmatnr1 = g_s_tot als_flat-matnr1 matnr = g_s_tot als_flat-matnr. IF sy-subrc = 0. READ TABLE lt_m_101 INTO lw_mseg1 WITH KEY bwart = '101' matnr = lw_matn r charg = wa_ordcharg. IF sy-subrc = 0. CLEAR: lv_dec. CALL FUNCTION 'ZRMC_DIV' EXPORTING a_menge = lv_rat b_menge = lw_mseg1-menge c_mul = lw_mseg-menge CHANGING gv_result = lv_dec. g_s_totals_flat-cons = ls-cons - lv_dec. ELSE. g_s_totals_flat-cons = ls-cons - lw_mseg-menge. ENDIF. PERFORM colorize_totals_flat USING 'ANFMENGE'. PERFORM colorize_totals_flat USING 'SOLL'. PERFORM colorize_totals_flat USING 'HABEN'. PERFORM colorize_totals_flat USING 'ENDMENGE'. PERFORM colorize_totals_flat USING 'CONS'. PERFORM colorize_totals_flat USING 'ST_TRAN'. PERFORM colorize_totals_flat USING 'MM_TRAN'. PERFORM colorize_totals_flat USING 'SALE'. IF g_t_color[] IS INITIAL. CLEAR g_s_totals_flat-color. ELSE. MOVE g_t_color[] TO g_s_totals_flat-color. ENDIF. APPEND g_s_totals_flat TO g_t_totals_flat. MODIFY g_t_totals_flat FROM g_s_totals_flat TRANSPORTING c WHERE charg = lw_mseg-charg AND matnr1 = g_s_totals_flat-matnr 1 AND matnr = g_s_totals_flat-matn r. ENDIF. ENDIF.

* ons color

ELSE. EXIT. ENDIF. ENDLOOP. ENDIF. ENDIF.

"LEVEL1

CLEAR:g_s_totals_flat-anfmenge,g_s_totals_flat-endmenge, g_s_totals_flat-haben,g_s_totals_flat-soll. CLEAR: g_s_totals_flat-mat_ty, g_s_totals_flat-mat_gp,g_s_totals_flatmatnr1, g_s_totals_flat-mat_txt,g_s_totals_flat-charg,g_s_totals_flat-co ns, g_s_totals_flat-st_tran,g_s_totals_flat-mm_tran,g_s_totals_flatsale. ELSE. EXIT. ENDIF. ENDLOOP. ELSE. PERFORM colorize_totals_flat USING 'ANFMENGE'. PERFORM colorize_totals_flat USING 'SOLL'. PERFORM colorize_totals_flat USING 'HABEN'. PERFORM colorize_totals_flat USING 'ENDMENGE'. IF g_t_color[] IS INITIAL. CLEAR g_s_totals_flat-color. ELSE. MOVE g_t_color[] TO g_s_totals_flat-color. ENDIF. CLEAR: g_t_color. APPEND g_s_totals_flat TO g_t_totals_flat. ENDIF. *****END OF CODE ENDLOOP.

ENDFORM.

" CREATE_TABLE_TOTALS_FLAT

*----------------------------------------------------------------------* * COLORIZE_TOTALS_FLAT *----------------------------------------------------------------------* FORM colorize_totals_flat USING l_fieldname TYPE any.

DATA : l_f_fieldname(30) TYPE c. FIELD-SYMBOLS : <l_fs_field>. * CUSTOMIZING : SET THE COLOR INFORMATION CHECK : g_cust_color = 'X'. CONCATENATE 'G_S_TOTALS_FLAT-' l_fieldname INTO l_f_fieldname. ASSIGN (l_f_fieldname) TO <l_fs_field>. CHECK sy-subrc IS INITIAL. IF <l_fs_field> > 0. MOVE : l_fieldname TO g_s_color-fieldname,

'5' '0' APPEND g_s_color

TO g_s_color-color-col, TO g_s_color-color-int. TO g_t_color.

"GREEN

ELSEIF <l_fs_field> < 0. MOVE : l_fieldname TO g_s_color-fieldname, '6' TO g_s_color-color-col, "RED '0' TO g_s_color-color-int. APPEND g_s_color TO g_t_color. ENDIF. ENDFORM. " COLORIZE_TOTALS_FLAT

*----------------------------------------------------------------------* * CREATE_FIELDCAT_TOTALS_FLAT *----------------------------------------------------------------------* FORM create_fieldcat_totals_flat. CLEAR : g_s_fieldcat, g_f_col_pos.

MOVE : text-116 TO g_s_fieldcat-seltext_l, "Material Type 'L' TO g_s_fieldcat-ddictxt, 10 TO g_s_fieldcat-outputlen. PERFORM fc_s_flat USING 'MTART' 'MARA' 'MTART'. MOVE : text-117 TO g_s_fieldcat-seltext_l, "Material Group 'L' TO g_s_fieldcat-ddictxt, 10 TO g_s_fieldcat-outputlen. PERFORM fc_s_flat USING 'MATKL' 'MARA' 'MATKL'. PERFORM fc_s_flat USING 'WGBEZ' 'T023T' 'WGBEZ'. PERFORM fc_s_flat USING 'MATNR' 'MARA' 'MATNR'.

MOVE : text-118 TO g_s_fieldcat-seltext_l, "Material Desc 'L' TO g_s_fieldcat-ddictxt, 13 TO g_s_fieldcat-outputlen. * MOVE 'X' TO g_s_fieldcat-no_out. PERFORM fc_s_flat USING 'MAKTX' 'MAKT' 'MAKTX'. PERFORM fc_s_flat USING 'MEINS' 'MARA' 'MEINS'. IF sobkz IS INITIAL. MOVE 'X' ENDIF.

TO g_s_fieldcat-no_out.

PERFORM fc_s_flat USING 'SOBKZ' 'MSLB' 'SOBKZ'. MOVE : text-094 'L' 15 TO g_s_fieldcat-seltext_l, "FROM DATE TO g_s_fieldcat-ddictxt, TO g_s_fieldcat-outputlen.

PERFORM fc_s_flat USING 'START_DATE' 'MKPF' 'BUDAT'.

MOVE : text-095 TO g_s_fieldcat-seltext_l, "TO DATE 'L' TO g_s_fieldcat-ddictxt, 15 TO g_s_fieldcat-outputlen. PERFORM fc_s_flat USING 'END_DATE' 'MKPF' 'BUDAT'. MOVE : text-096 TO g_s_fieldcat-seltext_l, "OPENING STOCK 'L' TO g_s_fieldcat-ddictxt, 13 TO g_s_fieldcat-outputlen, 'MEINS' TO g_s_fieldcat-qfieldname. PERFORM fc_s_flat USING 'ANFMENGE' 'MARD' 'LABST'. MOVE : text-097 TO 'L' TO 23 TO 'MEINS' TO PERFORM fc_s_flat USING 'SOLL' g_s_fieldcat-seltext_l, "SUM RECEIPTS g_s_fieldcat-ddictxt, g_s_fieldcat-outputlen, g_s_fieldcat-qfieldname. 'MSEG' 'MENGE'.

MOVE : text-098 TO g_s_fieldcat-seltext_l, "SUM ISSUES 'L' TO g_s_fieldcat-ddictxt, 13 TO g_s_fieldcat-outputlen, 'MEINS' TO g_s_fieldcat-qfieldname. PERFORM fc_s_flat USING 'HABEN' 'MSEG' 'MENGE'. MOVE : text-099 TO g_s_fieldcat-seltext_l, "END STOCK 'L' TO g_s_fieldcat-ddictxt, 13 TO g_s_fieldcat-outputlen, 'MEINS' TO g_s_fieldcat-qfieldname. PERFORM fc_s_flat USING 'ENDMENGE' 'MARD' 'LABST'. MOVE : text-116 TO g_s_fieldcat-seltext_l, "Material Type 'L' TO g_s_fieldcat-ddictxt, 13 TO g_s_fieldcat-outputlen. PERFORM fc_s_flat USING 'MAT_TY' 'MARA' 'MTART'. MOVE : text-117 TO g_s_fieldcat-seltext_l, "Material Type 'L' TO g_s_fieldcat-ddictxt, 14 TO g_s_fieldcat-outputlen. PERFORM fc_s_flat USING 'MAT_GP' 'MARA' 'MATKL'. MOVE : text-021 TO g_s_fieldcat-seltext_l, "Material Type 'L' TO g_s_fieldcat-ddictxt, 13 TO g_s_fieldcat-outputlen. PERFORM fc_s_flat USING 'MATNR1' 'MARA' 'MATNR'. MOVE : text-118 TO g_s_fieldcat-seltext_l, "Material Desc 'L' TO g_s_fieldcat-ddictxt, 13 TO g_s_fieldcat-outputlen. PERFORM fc_s_flat USING 'MAT_TXT' 'MAKT' 'MAKTX'. PERFORM fc_s_flat USING 'CHARG' 'MCHB' 'CHARG'. MOVE : text-119 'L' 14 TO g_s_fieldcat-seltext_l, "Consumption TO g_s_fieldcat-ddictxt, TO g_s_fieldcat-outputlen.

PERFORM fc_s_flat USING 'CONS' 'MSEG' 'ERFMG'. ***stock Transfer MOVE : text-120 TO g_s_fieldcat-seltext_l, "Stock Transfer 'L' TO g_s_fieldcat-ddictxt, 14 TO g_s_fieldcat-outputlen. PERFORM fc_s_flat USING 'ST_TRAN' 'MSEG' 'ERFMG'. ***Material to Material Transfer MOVE : text-121 TO g_s_fieldcat-seltext_l, "Material To Material T ransfer 'L' TO g_s_fieldcat-ddictxt, 29 TO g_s_fieldcat-outputlen. PERFORM fc_s_flat USING 'MM_TRAN' 'MSEG' 'ERFMG'. MOVE : text-122 TO 'L' TO 15 TO PERFORM fc_s_flat USING 'SALE' *--INSERTED BY TULASI 30.01 g_s_fieldcat-seltext_l, "Sale g_s_fieldcat-ddictxt, g_s_fieldcat-outputlen. 'MSEG' 'ERFMG'.

* * * * * * * * * *

MOVE : 'OPENING RATE' TO g_s_fieldcat-seltext_l, "FROM DATE TEXT-118 'L' TO g_s_fieldcat-ddictxt, 20 TO g_s_fieldcat-outputlen. PERFORM fc_s_flat USING 'OP_RATE' 'MBEW' 'SALK3'. "'OP_RATE'. MOVE : 'CLOSING RATE' TO g_s_fieldcat-seltext_l, "FROM DATE TEXT-118 'L' TO g_s_fieldcat-ddictxt, 20 TO g_s_fieldcat-outputlen. PERFORM fc_s_flat USING 'CL_RATE' 'MBEW' 'SALK3'. "CL_RATE'.

******** INSERTED BY NITIN 04/09/2010 ***** * IF bwbst = 'X'. ** PROCESS THE VALUES, TOO * MOVE : text-100 TO * 'L' TO * 23 TO * 'WAERS' TO * PERFORM fc_s_flat USING * * MOVE : text-101 TO * 'L' TO * 23 TO * 'WAERS' TO * PERFORM fc_s_flat USING * * MOVE : text-102 TO * 'L' TO * 23 TO * 'WAERS' TO * PERFORM fc_s_flat USING

g_s_fieldcat-seltext_l, "OPENING VALUE g_s_fieldcat-ddictxt, g_s_fieldcat-outputlen, g_s_fieldcat-cfieldname. 'ANFWERT' 'MBEW' 'LBKUM'. g_s_fieldcat-seltext_l, "SUM GR VALUES g_s_fieldcat-ddictxt, g_s_fieldcat-outputlen, g_s_fieldcat-cfieldname. 'SOLLWERT' 'MSEG' 'DMBTR'. g_s_fieldcat-seltext_l, "SUM GI VALUES g_s_fieldcat-ddictxt, g_s_fieldcat-outputlen, g_s_fieldcat-cfieldname. 'HABENWERT' 'MSEG' 'DMBTR'.

* * * * * *

MOVE : text-103 TO 'L' TO 23 TO 'WAERS' TO PERFORM fc_s_flat USING

g_s_fieldcat-seltext_l, "END VALUE g_s_fieldcat-ddictxt, g_s_fieldcat-outputlen, g_s_fieldcat-cfieldname. 'ENDWERT' 'MBEW' 'LBKUM'.

*--INSERTED BY TULASI 29.01 * PERFORM FC_S_FLAT USING 'MTART' 'MARA' 'MTART'. * * MOVE : TEXT-116 TO G_S_FIELDCAT-SELTEXT_L, "FROM DATE * 'L' TO G_S_FIELDCAT-DDICTXT, * 10 TO G_S_FIELDCAT-OUTPUTLEN. * * PERFORM FC_S_FLAT USING 'MATKL' 'MARA' 'MATKL'. * * MOVE : TEXT-117 TO G_S_FIELDCAT-SELTEXT_L, "FROM DATE * 'L' TO G_S_FIELDCAT-DDICTXT, * 10 TO G_S_FIELDCAT-OUTPUTLEN. *--END OF TULASI * PERFORM fc_s_flat USING 'WAERS' 'T001' 'WAERS'. * ENDIF. ENDFORM. " CREATE_FIELDCAT_TOTALS_FLAT.

*----------------------------------------------------------------------* * FC_S_FLAT *----------------------------------------------------------------------* FORM fc_s_flat USING l_fieldname TYPE fieldname l_ref_tabname TYPE ddobjname l_ref_fieldname TYPE fieldname.

ADD : 1 TO g_f_col_pos. MOVE : l_fieldname TO g_s_fieldcat-fieldname, g_f_col_pos TO g_s_fieldcat-col_pos, 'G_T_TOTALS_FLAT' TO g_s_fieldcat-tabname, l_ref_tabname TO g_s_fieldcat-ref_tabname, l_ref_fieldname TO g_s_fieldcat-ref_fieldname. *ENHANCEMENT-POINT FC_S_FLAT_01 SPOTS ES_RM07MLBD. APPEND g_s_fieldcat TO g_t_fieldcat_totals_flat. CLEAR g_s_fieldcat. ENDFORM. "FC_S_FLAT

*----------------------------------------------------------------------* * ALV_FLAT_LIST_SUMS_ONLY *----------------------------------------------------------------------* FORM alv_flat_list_sums_only. PERFORM sort_tab. * ASSIGN THE FORM ROUTINES TO THE EVENTS MOVE : 'PF_STATUS_SET' TO g_t_events_totals_flat-name, 'PF_STATUS_SET_TOTALS' TO g_t_events_totals_flat-form. APPEND g_t_events_totals_flat. MOVE : 'USER_COMMAND' TO g_t_events_totals_flat-name,

'USER_COMMAND_TOTALS' APPEND MOVE : 'TOP_OF_PAGE' 'TOP_OF_PAGE_TOTALS' APPEND MOVE : APPEND 'END_OF_LIST' 'PRINT_END_OF_LIST'

TO g_t_events_totals_flat-form. g_t_events_totals_flat. TO g_t_events_totals_flat-name, TO g_t_events_totals_flat-form. g_t_events_totals_flat. TO g_t_events_totals_flat-name, TO g_t_events_totals_flat-form. g_t_events_totals_flat.

* HANDLING FOR DOUBLE CLICK g_s_layout_totals_flat-f2code = '9PBP'. g_s_layout_totals_flat-coltab_fieldname = 'COLOR'. IF g_flag_break-b6 = 'X'. "N921164 BREAK-POINT ID mmim_rep_mb5b. "N921164 * DYNAMIC BREAK-POINT : CHECK INPUT DATA FOR LIST VIEWER "N921164 ENDIF. "N921164 *--INSERTED BY TULASI FOR FILTERING MAT TYPE & GRP IF mtart IS INITIAL. ELSE. DELETE g_t_totals_flat WHERE mtart NOT IN mtart. ENDIF. IF matkl IS INITIAL. ELSE. DELETE g_t_totals_flat WHERE matkl NOT IN matkl. ENDIF. ****** ADDED BY NITIN FOR PAC CONVERSION WHERE MAT GRP FP1205 ******* END OF NITIN 17/12/2009 **** * LISTE AUFBAUEN *--BASIC LIST SCREEN DISPLAY BY TULASI IF r1 = 'X'. * * CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY' * EXPORTING * i_interface_check = g_flag_i_check * i_callback_program = repid * is_layout = g_s_layout_totals_flat * it_fieldcat = g_t_fieldcat_totals_flat[] * it_sort = g_t_sorttab * i_default = 'X' "ALLOW DEFAULT VARIANT * i_save = 'A' * is_variant = g_s_vari_sumfl * it_events = g_t_events_totals_flat[] * is_print = g_s_print * TABLES * t_outtab = g_t_totals_flat * EXCEPTIONS * OTHERS = 1. * * IF sy-subrc NE 0. * MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno * WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. * ENDIF.

* *

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING i_interface_check = g_flag_i_check i_callback_program = repid is_layout = g_s_layout_totals_flat it_fieldcat = g_t_fieldcat_totals_flat[] it_sort = g_t_sorttab i_default = 'X' "ALLOW DEFAULT VARIANT i_save = 'A' is_variant = g_s_vari_sumfl IT_EVENTS = G_T_EVENTS_TOTALS_FLAT[] "TULASI it_events = g_t_events_totals_flat1[] "TULASI is_print = g_s_print TABLES t_outtab = g_t_totals_flat EXCEPTIONS OTHERS = 1. IF sy-subrc NE 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. ELSE. g_t_events_totals_flat1[] = g_t_events_totals_flat[]. DELETE g_t_events_totals_flat1[] WHERE name EQ 'TOP_OF_PAGE'. DELETE g_t_events_totals_flat1[] WHERE name EQ 'END_OF_LIST'. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING i_interface_check = g_flag_i_check i_callback_program = repid is_layout = g_s_layout_totals_flat it_fieldcat = g_t_fieldcat_totals_flat[] it_sort = g_t_sorttab i_default = 'X' "ALLOW DEFAULT VARIANT i_save = 'A' is_variant = g_s_vari_sumfl IT_EVENTS = G_T_EVENTS_TOTALS_FLAT[] "TULASI it_events = g_t_events_totals_flat1[] "TULASI is_print = g_s_print TABLES t_outtab = g_t_totals_flat EXCEPTIONS OTHERS = 1. IF sy-subrc NE 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. ENDIF.

ENDFORM.

"ALV_FLAT_LIST_SUMS_ONLY

*----------------------------------------------------------------------* * CREATE_FIELDCAT_TOTALS_HQ *----------------------------------------------------------------------*

*BAUSTELLE FORM create_fieldcat_totals_hq. * CREATE FIELDCAT CLEAR : g_s_fieldcat, g_f_col_pos.

* PART 1 : FOR THE HEADER TABLE IF bwbst = 'X'. "N999530 PERFORM fc_hq USING 'G_T_TOTALS_HEADER' 'BWKEY' 'MBEW' 'BWKEY'. ENDIF. "N999530 IF bwbst IS INITIAL. "N999530 PERFORM fc_hq USING 'G_T_TOTALS_HEADER' 'WERKS' 'MARC' 'WERKS'. MOVE : 'X' TO MOVE : 30 TO text-024 TO 'L' TO PERFORM fc_hq USING 'G_T_TOTALS_HEADER' ENDIF. g_s_fieldcat-no_out. g_s_fieldcat-outputlen, "N999530 g_s_fieldcat-seltext_l, "N999530 g_s_fieldcat-ddictxt. "N999530 'NAME1' 'T001W' 'NAME1'. "N999530

PERFORM fc_hq USING 'G_T_TOTALS_HEADER' 'MATNR' 'MARA' 'MATNR'. IF sobkz IS INITIAL. MOVE : 'X' TO g_s_fieldcat-no_out. ENDIF. *--INS BY TULASI 29.01 PERFORM fc_hq USING 'G_T_TOTALS_HEADER' 'MTART' 'MARA' 'MTART'. PERFORM USING *--END OF PERFORM USING fc_hq 'G_T_TOTALS_HEADER' 'MATKL' 'MARA' 'MATKL'. TULASI fc_hq 'G_T_TOTALS_HEADER' 'SOBKZ' 'MSLB' 'SOBKZ'.

PERFORM fc_hq USING 'G_T_TOTALS_HEADER' 'MAKTX' 'MAKT' 'MAKTX'. IF xchar IS INITIAL. MOVE : 'X' ENDIF. TO g_s_fieldcat-no_out.

PERFORM fc_hq USING 'G_T_TOTALS_HEADER' 'CHARG' 'MCHB' 'CHARG'. ** PART 2 : FOR THE ITEM TABLE * HIDDEN KEY FIELDS MOVE : 'X' TO g_s_fieldcat-no_out. PERFORM fc_hq USING 'G_T_TOTALS_ITEM' 'BWKEY' 'MBEW' 'BWKEY'. MOVE : 'X' TO g_s_fieldcat-no_out. PERFORM fc_hq USING 'G_T_TOTALS_ITEM' 'WERKS' 'MARC' 'WERKS'.

MOVE : 'X' TO g_s_fieldcat-no_out. PERFORM fc_hq USING 'G_T_TOTALS_ITEM' 'MATNR' 'MARA' 'MATNR'. MOVE : 'X' TO g_s_fieldcat-no_out. PERFORM fc_hq USING 'G_T_TOTALS_ITEM' 'CHARG' 'MCHB' 'CHARG'. MOVE : 'X' TO g_s_fieldcat-no_out. PERFORM fc_hq USING 'G_T_TOTALS_ITEM' 'COUNTER' ' ' ''. MOVE : 40 TO g_s_fieldcat-outputlen. PERFORM fc_hq USING 'G_T_TOTALS_ITEM' 'STOCK_TYPE' space space. * DO NOT ALLOW TO FORM SUMS FOR THE COLUMN QUANTITY "N951316 MOVE : 'X' TO g_s_fieldcat-no_sum. "N951316 MOVE : 23 TO g_s_fieldcat-outputlen, text-104 TO g_s_fieldcat-seltext_l, "QUANTITIES 'L' TO g_s_fieldcat-ddictxt, 'MENGE_D' TO g_s_fieldcat-rollname, 'MEINS' TO g_s_fieldcat-qfieldname. PERFORM fc_hq USING 'G_T_TOTALS_ITEM' 'MENGE' space space. PERFORM fc_hq USING 'G_T_TOTALS_ITEM' 'MEINS' * * 'MARA' 'MEINS'.

IF bwbst = 'X'. WITH VALUATION DO NOT ALLOW TO FORM SUMS FOR THE COLUMN VALUE "N951316 MOVE : 'X' TO g_s_fieldcat-no_sum. "N951316 MOVE : 23 TO g_s_fieldcat-outputlen, text-105 TO g_s_fieldcat-seltext_l, "VALUES 'L' TO g_s_fieldcat-ddictxt, 'DMBTR' TO g_s_fieldcat-rollname, 'WAERS' TO g_s_fieldcat-cfieldname. PERFORM fc_hq USING 'G_T_TOTALS_ITEM' 'WERT' space space. PERFORM fc_hq USING 'G_T_TOTALS_ITEM' 'WAERS' ENDIF. 'T001' 'WAERS'.

ENDFORM.

"CREATE_FIELDCAT_TOTALS_HQ

*----------------------------------------------------------------------* * FC_HQ *----------------------------------------------------------------------* FORM fc_hq USING l_tabname l_fieldname l_ref_tabname l_ref_fieldname TYPE TYPE TYPE TYPE ddobjname fieldname ddobjname fieldname.

ADD : 1 MOVE : l_fieldname g_f_col_pos

TO g_f_col_pos. TO g_s_fieldcat-fieldname, TO g_s_fieldcat-col_pos,

l_tabname l_ref_tabname l_ref_fieldname * ENHANCEMENT-POINT FC_HQ_01 APPEND g_s_fieldcat CLEAR ENDFORM.

TO g_s_fieldcat-tabname, TO g_s_fieldcat-ref_tabname, TO g_s_fieldcat-ref_fieldname. SPOTS ES_RM07MLBD. TO g_t_fieldcat_totals_hq. g_s_fieldcat. "FC_HQ

*----------------------------------------------------------------------* * ALV_HIERSEQ_LIST_TOTALS *----------------------------------------------------------------------* FORM alv_hierseq_list_totals. * FILL LAYOUT : CONSIDER DOUBLE CLICK AND COLOR SUBTABLES g_s_layout_totals_hq-coltab_fieldname = 'COLOR'. g_s_layout_totals_hq-f2code = '9PBP'. * CREATE OTHER TABLES AND STRUCTURES MOVE : 'BWKEY' TO g_s_keyinfo_totals_hq-header01, 'BWKEY' TO g_s_keyinfo_totals_hq-item01, 'WERKS' 'WERKS' 'MATNR' 'MATNR' 'CHARG' 'CHARG' 'COUNTER' TO g_s_keyinfo_totals_hq-header02, TO g_s_keyinfo_totals_hq-item02, TO g_s_keyinfo_totals_hq-header03, TO g_s_keyinfo_totals_hq-item03, TO g_s_keyinfo_totals_hq-header04, TO g_s_keyinfo_totals_hq-item04, TO g_s_keyinfo_totals_hq-item05.

* CREATE THE EVENTS TABLE MOVE : 'PF_STATUS_SET' TO events_hierseq-name, 'PF_STATUS_SET_TOTALS' TO events_hierseq-form. APPEND events_hierseq. MOVE : 'USER_COMMAND' 'USER_COMMAND_TOTALS' APPEND MOVE : 'TOP_OF_PAGE' 'TOP_OF_PAGE_TOTALS' APPEND MOVE : APPEND 'END_OF_LIST' 'PRINT_END_OF_LIST' TO events_hierseq-name, TO events_hierseq-form. events_hierseq. TO events_hierseq-name, TO events_hierseq-form. events_hierseq. TO events_hierseq-name, TO events_hierseq-form. events_hierseq.

* CREATE THE SORT TABLE G_T_SORT_TOTALS_HQ CLEAR g_s_sort_totals_hq. MOVE : 'G_T_TOTALS_ITEM' TO g_s_sort_totals_hq-tabname, 'X' TO g_s_sort_totals_hq-up. MOVE 'BWKEY' ADD 1 APPEND g_s_sort_totals_hq TO g_s_sort_totals_hq-fieldname. TO g_s_sort_totals_hq-spos. TO g_t_sort_totals_hq.

MOVE 'WERKS' ADD 1 APPEND g_s_sort_totals_hq MOVE 'MATNR' ADD 1 APPEND g_s_sort_totals_hq MOVE 'CHARG' ADD 1 APPEND g_s_sort_totals_hq MOVE 'COUNTER' ADD 1 APPEND g_s_sort_totals_hq

TO g_s_sort_totals_hq-fieldname. TO g_s_sort_totals_hq-spos. TO g_t_sort_totals_hq. TO g_s_sort_totals_hq-fieldname. TO g_s_sort_totals_hq-spos. TO g_t_sort_totals_hq. TO g_s_sort_totals_hq-fieldname. TO g_s_sort_totals_hq-spos. TO g_t_sort_totals_hq. TO g_s_sort_totals_hq-fieldname. TO g_s_sort_totals_hq-spos. TO g_t_sort_totals_hq.

IF g_flag_break-b7 = 'X'. "N921164 BREAK-POINT ID mmim_rep_mb5b. "N921164 * DYNAMIC BREAK-POINT : CHECK INPUT DATA FOR LIST VIEWER "N921164 ENDIF. "N921164 CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY' EXPORTING i_interface_check = g_flag_i_check i_callback_program = repid it_events = events_hierseq[] is_layout = g_s_layout_totals_hq is_print = g_s_print it_fieldcat = g_t_fieldcat_totals_hq it_sort = g_t_sort_totals_hq i_default = 'X' i_save = 'A' is_variant = g_s_vari_sumhq i_tabname_header = 'G_T_TOTALS_HEADER' i_tabname_item = 'G_T_TOTALS_ITEM' is_keyinfo = g_s_keyinfo_totals_hq TABLES t_outtab_header = g_t_totals_header[] t_outtab_item = g_t_totals_item[] EXCEPTIONS OTHERS = 1. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. ENDFORM. " ALV_HIERSEQ_LIST_TOTALS

*-----------------------------------------------------------"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 ***************************** * ************************* 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 xchar = ' ' AND NOT xnomchb 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 * COMPANY CODE AND MODE IS VALUATED STOCK IF curm = '3' AND bwbst = 'X'. IF NOT werks[] IS INITIAL. "N599218 "N599218 "N599218 "N599218 "N599218

"838360_V "838360_^

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.

*ENHANCEMENT-SECTION RM07MLBD_02 SPOTS ES_RM07MLBD. 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. *END-ENHANCEMENT-SECTION. 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 IF NOT alv_default_variant IS INITIAL. * BUT THE SAP-LIST-VIEWER WILL APPLY THE EXISTING * INITIAL DISPLAY VARIANT / EMERGE WARNING 393 ? CALL FUNCTION 'ME_CHECK_T160M' EXPORTING i_arbgb = 'M7' i_msgnr = '393' EXCEPTIONS nothing = 0 OTHERS = 1. * IF sy-subrc <> 0. LIST WILL BE CREATED USING THE INITIAL LAYOUT & MESSAGE w393(m7) WITH alv_default_variant. ENDIF. ENDIF. CLEAR variante. variante-report = repid. ENDIF. ENDFORM. " EINGABEN_PR FEN

"N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218

*----------------------------------------------------------------------* * VARIANT_CHECK_EXISTENCE *----------------------------------------------------------------------* FORM variant_check_existence USING l_vari LIKE disvariant-variant ls_vari LIKE disvariant ls_vari_def LIKE disvariant. MOVE l_vari TO ls_vari-variant.

IF NOT l_vari IS INITIAL. PARAMETER FOR THE VARIANT IS FILLED. CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE' EXPORTING i_save = 'A' CHANGING cs_variant = ls_vari.

* *

IN THE CASE THE VARIANT DOES NOT EXIST THIS FUNCTION MODULE SENDS THE ERROR MESSAGE DIRECTLY ELSE. * THE USER WANTS NO INITIAL DISPLAY VARIANT IF NOT ls_vari_def-variant IS INITIAL. * BUT THE SAP-LIST-VIEWER WILL APPLY THE EXISTING * INITIAL DISPLAY VARIANT / EMERGE WARNING 393 ? CALL FUNCTION 'ME_CHECK_T160M' EXPORTING i_arbgb = 'M7' i_msgnr = '393' EXCEPTIONS nothing = 0 OTHERS = 1. * IF sy-subrc <> 0. LIST WILL BE CREATED USING THE INITIAL LAYOUT & MESSAGE w393(m7) WITH ls_vari_def-variant. ENDIF. ENDIF. ENDIF. "VARIANT_CHECK_EXISTENCE

"N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218

ENDFORM.

*----------------------------------------------------------------------* * GET_THE_DEFAULT_VARIANT *----------------------------------------------------------------------* FORM get_the_default_variant USING l_vari LIKE disvariant-variant ls_vari LIKE disvariant ls_vari_def LIKE disvariant. CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET' EXPORTING i_save = variant_save CHANGING cs_variant = ls_vari_def EXCEPTIONS not_found = 2. * IF sy-subrc = 0. SAVE THE INITIAL, E.G. DEFAULT VARIANT MOVE-CORRESPONDING ls_vari_def TO ls_vari. MOVE : ls_vari_def-variant TO l_vari. ENDIF. "VARIANT_VALUE_REQUEST_F4

ENDFORM.

*----------------------------------------------------------------------* * VARIANT_VALUE_REQUEST_F4

*----------------------------------------------------------------------* FORM variant_value_request_f4 USING l_vari LIKE disvariant-variant ls_vari LIKE disvariant. DATA : ls_vari_return LIKE disvariant.

CALL FUNCTION 'REUSE_ALV_VARIANT_F4' EXPORTING is_variant = ls_vari i_save = 'A' * IT_DEFAULT_FIELDCAT = IMPORTING e_exit = variant_exit es_variant = ls_vari_return EXCEPTIONS not_found = 2. IF sy-subrc = 2. MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ELSE. IF variant_exit = space. MOVE ls_vari_return-variant TO l_vari. ENDIF. ENDIF. ENDFORM. "VARIANT_VALUE_REQUEST_F4

*&---------------------------------------------------------------------* *---------------------- BEWERTETER BESTAND ----------------------------* FORM aktuelle_bst_bwbst. * DEFINE LOCAL WORKING AREAS * DATABASE SELECTIONS AND THE DATA : l_t_mbew l_s_mbew l_s_mbew_split l_s_mbew_normal l_flag_split(01) / FOR THE RESULT OF THE CONTROL BREAK TYPE stab_mbew, TYPE stype_mbew, TYPE stype_mbew, TYPE stype_mbew, TYPE c. "N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N450764

* READ THE MATCHING VALUATION ENTRIES SELECT matnr bwkey bwtar lbkum salk3 FROM mbew INTO CORRESPONDING FIELDS OF TABLE l_t_mbew WHERE matnr IN matnr AND bwkey IN g_ra_bwkey AND bwtar IN bwtar. IF sy-subrc NE 0. MESSAGE s289. * KEIN MATERIAL IN SELEKTION VORHANDEN. PERFORM anforderungsbild. ENDIF. * READ THE MATCHING VALUATION RECORDS OF THE VALUATED * SPECIAL STOCK SALES ORDER

SELECT matnr bwkey bwtar SUM( lbkum ) AS lbkum SUM( salk3 ) AS salk3 FROM ebew APPENDING CORRESPONDING FIELDS OF TABLE l_t_mbew WHERE matnr IN matnr AND bwkey IN g_ra_bwkey AND bwtar IN bwtar GROUP BY matnr bwkey bwtar. * READ THE MATCHING VALUATION RECORDS OF THE VALUATED * SPECIAL STOCK PROJECTS SELECT matnr bwkey bwtar SUM( lbkum ) AS lbkum SUM( salk3 ) AS salk3 FROM qbew APPENDING CORRESPONDING FIELDS OF TABLE l_t_mbew WHERE matnr IN matnr AND bwkey IN g_ra_bwkey AND bwtar IN bwtar GROUP BY matnr bwkey bwtar. * READ THE MATCHING VALUATION RECORDS OF THE VALUATED * SPECIAL SUBCONTRACTOR STOCK OBEW SELECT matnr bwkey bwtar SUM( lbkum ) AS lbkum SUM( salk3 ) AS salk3 FROM obew APPENDING CORRESPONDING FIELDS OF TABLE l_t_mbew WHERE matnr IN matnr AND bwkey IN g_ra_bwkey AND bwtar IN bwtar GROUP BY matnr bwkey bwtar. * CREATE TABLE G_T_ORGAN IF IT IS STILL EMPTY IF g_t_organ[] IS INITIAL. * CREATE WORKING TABLE G_0000_RA_BWKEY WITH THE VALUATION LOOP AT l_t_mbew INTO l_s_mbew. ON CHANGE OF l_s_mbew-bwkey. MOVE : l_s_mbew-bwkey TO g_0000_ra_bwkey-low, 'I' TO g_0000_ra_bwkey-sign, 'EQ' TO g_0000_ra_bwkey-option. COLLECT g_0000_ra_bwkey. ENDON. ENDLOOP. PERFORM f0000_create_table_g_t_organ USING c_no_error. ENDIF. SORT l_t_mbew * BY matnr bwkey.

"N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N497992 "N497992 "N497992 "N497992 "N497992 "N497992 "N497992 "N497992 "N497992 "N497992 "N433765 AREAS "N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N450764

LOOP AT l_t_mbew INTO l_s_mbew. PROCESS A SINGLE ENTRY / ADD THE STOCK AND VALUE IF l_s_mbew-bwtar IS INITIAL. MOVE : l_s_mbew-matnr TO l_s_mbew_normal-matnr, l_s_mbew-bwkey TO l_s_mbew_normal-bwkey. ADD : l_s_mbew-lbkum TO l_s_mbew_normal-lbkum, l_s_mbew-salk3 TO l_s_mbew_normal-salk3. ELSE. * MATERIAL HAS SPLIT VALUATION MOVE : 'X' TO l_flag_split,

"N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N450764 "N450764

* * * *

"N450764 "N450764 "N450764 "N450764 "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 "N450764

l_s_mbew-matnr l_s_mbew-bwkey ADD : l_s_mbew-lbkum l_s_mbew-salk3 ENDIF.

TO TO TO TO

l_s_mbew_split-matnr, l_s_mbew_split-bwkey. l_s_mbew_split-lbkum, l_s_mbew_split-salk3.

* NO ENTRIES LEFT IN TABLE G_T_MBEW ? IF g_t_mbew[] IS INITIAL. MESSAGE s289. * KEIN MATERIAL IN SELEKTION VORHANDEN. PERFORM anforderungsbild. ENDIF. ENDFORM. "AKTUELLE_BST_BWBST

*&---------------------------------------------------------------------* *& 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 COLLECT ENDLOOP.

TO k2-bwart. k2.

* 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. 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 CONTINUE. ENDIF. g_t_mseg_lean. "311588

READ TABLE it156 WITH KEY bwart = g_s_mseg_lean-bwart wertu = g_s_mseg_lean-wertu mengu = g_s_mseg_lean-mengu

sobkz kzbew kzzug kzvbr BINARY rc = sy-subrc. IF g_s_mseg_lean-bustm g_s_mseg_lean-bustw rc MOVE : it156-bustm it156-bustw ENDIF. IF rc = 0. MOVE : it156-lbbsa IF NOT MOVE ELSE. MOVE ENDIF. ELSE. MOVE : ENDIF.

= g_s_mseg_lean-sobkz = g_s_mseg_lean-kzbew = g_s_mseg_lean-kzzug = g_s_mseg_lean-kzvbr SEARCH. "147374

= space AND = space AND = 0. TO g_s_mseg_lean-bustm, TO g_s_mseg_lean-bustw.

"147374 "147374 "147374 "147374

TO g_s_mseg_lean-lbbsa.

it156-bwagr IS INITIAL. : it156-bwagr TO g_s_mseg_lean-bwagr. : 'REST' 'REST' TO g_s_mseg_lean-bwagr. TO g_s_mseg_lean-bwagr. "147374 FROM g_s_mseg_lean. " BEWEGUNGSARTEN_LESEN

MODIFY g_t_mseg_lean ENDLOOP. ENDFORM.

*&---------------------------------------------------------------------* *& 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 IF g_flag_is_oil_active = 'X'. "IS-OIL ? "N599218 IF ( imsweg-bustm <> 'MEU1' ) OR "N599218 ( imsweg-bustm = 'MEU1' "N599218 AND NOT imsweg-oiglcalc IS INITIAL "N599218 AND NOT imsweg-oiglsku IS INITIAL ). "N599218 MOVE-CORRESPONDING imsweg TO mat_weg. "N599218 COLLECT mat_weg. "N599218 ELSE. "N599218 DELETE imsweg. "N599218 ENDIF. "N599218 ELSE. "N599218 MOVE-CORRESPONDING imsweg TO mat_weg. "N599218 COLLECT mat_weg. "N599218 ENDIF. "N599218

A A A A A A A A A A A A A A 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'. SORT g_t_mseg_lean "AUF CHARGENEBENE 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 IF g_flag_is_oil_active = 'X'. "IS-OIL ? "N599218 IF ( g_s_mseg_lean-bustm <> 'MEU1' ) OR "N599218 ( g_s_mseg_lean-bustm = 'MEU1' "N599218 AND NOT g_s_mseg_lean-oiglcalc IS INITIAL "N599218 AND NOT g_s_mseg_lean-oiglsku IS INITIAL ). "N599218 MOVE-CORRESPONDING g_s_mseg_lean "N599218 TO mat_sum. "N599218 COLLECT mat_sum. "N599218 ELSE. "N599218 DELETE g_t_mseg_lean. "N599218 ENDIF. "N599218 ELSE. "N599218 MOVE-CORRESPONDING g_s_mseg_lean "N599218 TO mat_sum. "N599218 COLLECT mat_sum. "N599218 ENDIF. "N599218 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 ENDIF. MODIFY mat_sum. ENDLOOP. TO mat_sum-bwkey.

A A A A A A A A A A A A A A A A A

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

*&---------------------------------------------------------------------* *& FORM BELEGSELEKTION *&---------------------------------------------------------------------* FORM belegselektion. * 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. 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 ENDIF. PERFORM kontiert_aussortieren. bewegungsarten_lesen. "N450764

* 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 ENDFORM. belege_sortieren. "BELEGSELEKTION

*&--------------------------------------------------------------------* *& 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.

*&---------------------------------------------------------------------* *& FORM UEBERSCHRIFT *&---------------------------------------------------------------------* FORM ueberschrift. MOVE-CORRESPONDING bestand PERFORM ENDFORM. TO g_s_bestand. top_of_page_render. " UEBERSCHRIFT "#EC CALLED

*&---------------------------------------------------------------------* *& FORM UEBERSCHRIFT1 *&---------------------------------------------------------------------* FORM ueberschrift1. MOVE-CORRESPONDING bestand1 TO g_s_bestand. PERFORM top_of_page_render. ENDFORM. " UEBERSCHRIFT1 "#EC CALLED

*&---------------------------------------------------------------------* *& FORM UEBERSCHRIFT_DETAIL *&---------------------------------------------------------------------* FORM ueberschrift_detail. MOVE-CORRESPONDING g_s_bestand_detail TO g_s_bestand. PERFORM ENDFORM. top_of_page_render. " UEBERSCHRIFT_DETAIL "#EC CALLED

*&---------------------------------------------------------------------* *& 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 AND mjahr = storno-sjahr AND zeile = storno-smblp. ENDLOOP. ENDFORM. " STORNO

"204463 "204463 "204463

*----------------------------------------------------------------------* * F0400_CREATE_FIELDCAT *----------------------------------------------------------------------* * * 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 g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat * SONDERBESTANDSKENNZEICHEN g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat MOVEMENT TYPE = 'BWART'. = 'MSEG'. = 'M'. USING c_take

c_out.

SPECIAL STOCK INDICATOR = 'SOBKZ'. = 'MSEG'. = 'B'. USING c_take c_out.

* NUMMER DES MATERIALBELEGS g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat * POSITION IM MATERIALBELEG g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat * IF bwbst = 'X'. NUMMER BUCHHALTUNGSBELEG g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat ENDIF.

NUMBER OF MATERIAL DOCUMENT = 'MBLNR'. = 'MKPF'. = 'O'. USING c_take c_out. ITEM IN MATERIAL DOCUMENT = 'ZEILE'. = 'MSEG'. = 'O'. USING c_take c_out. ACCOUNTING DOCUMENT NUMBER = 'BELNR'. = 'BSIM'. = 'O'. USING c_take c_out. POSTING DATE IN THE DOCUMENT = 'BUDAT'. = 'MKPF'. = 'D'. USING c_take c_out. = 'MENGE'. " MENGE = 'MSEG'. " QUANTITY = 'MEINS'. = 'M'. USING c_take c_out. = 'MEINS'. " BASISMENGENEINHEIT = 'MSEG'. " BASE UNIT OF MEASURE = 'M'. USING c_take c_out.

* BUCHUNGSDATUM IM BELEG g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-qfieldname g_s_fieldcat-sp_group PERFORM f0410_fieldcat g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat *

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 G_S_FIELDCAT-REF_TABNAME G_S_FIELDCAT-SP_GROUP PERFORM F0410_FIELDCAT = 'WAERS'. " WAEHRUNGS-SCHLUESSEL = 'T001'. " CURRENCY KEY = 'M'. 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 g_s_fieldcat-ref_tabname = 'GJAHR'. = 'BKPF'. " GESCH FTSJAHR " FISCAL YEAR

g_s_fieldcat-sp_group PERFORM f0410_fieldcat *---INSERTED BY TULASI g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat *---END OF TULASI g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat

= 'D'. USING c_take

c_no_out.

= 'MTART'. " GESCH FTSJAHR = 'MARA'. " FISCAL YEAR = 'D'. USING c_take c_no_out. = 'MATKL'. " GESCH FTSJAHR = 'MARA'. " FISCAL YEAR = 'D'. USING c_take c_no_out.

= 'VGART'. " VORGANGSART = 'MKPF'. " TRANSACTION/EVENT TYPE = 'M'. USING c_take c_no_out. = 'USNAM'. " NAME DES BENUTZERS = 'MKPF'. " USER NAME = 'O'. USING c_take c_no_out. = 'CPUDT'. " TAG DER ERFASSUNG = 'MKPF'. " ACC. DOC. ENTRY DATE = 'D'. USING c_take c_no_out. = 'CPUTM'. " UHRZEIT DER ERFASSUNG = 'MKPF'. " TIME OF ENTRY = 'D'. USING c_take c_no_out. = 'SHKZG'. " SOLL-/HABEN-KENNZEICHEN = 'MSEG'. " DEBIT/CREDIT INDICATOR = 'M'. USING c_take c_no_out. = 'BWTAR'. " BEWERTUNGSART = 'MSEG'. " VALUATION TYPE = 'B'. 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 g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname

c_no_out.

= 'CHARG'. " CHARGENNUMMER = 'MSEG'. " BATCH NUMBER = 'B'. USING c_take c_no_out. = 'BUKRS'. = 'T001'. " BUCHUNGSKREIS " COMPANY CODE

g_s_fieldcat-sp_group PERFORM f0410_fieldcat g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat

= 'O'. USING c_take

c_no_out.

= 'KZBEW'. " BEWEGUNGSKENNZEICHEN = 'MSEG'. " MOVEMENT INDICATOR = 'M'. USING c_take c_no_out. = 'KZVBR'. " KENNZ. VERBRAUCHSBUCHUNG = 'MSEG'. " CONSUMPTION POSTING = 'M'. USING c_take c_no_out. = 'KZZUG'. " ZUGANGSKENNZEICHEN = 'MSEG'. " RECEIPT INDICATOR = 'M'. USING c_take c_no_out. = 'BUSTM'. " BUCHUNGSSTRING F R MENGEN = 'MSEG'. " POSTING STRING FOR QUANTITIES = 'B'. USING c_take c_no_out. = 'BUSTW'. " BUCHUNGSSTRING F R WERTE = 'MSEG'. " POSTING STRING FOR VALUES = 'B'. 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 PERFORM f0410_fieldcat = 'M'. USING c_take c_no_out. "N450596 "N450596 "N450596 "N450596 "N450596

* PROCESS 'GOODS RECEIPT/ISSUE SLIP' AS HIDDEN FIELD g_s_fieldcat-fieldname = 'XABLN'. g_s_fieldcat-ref_tabname = 'MKPF'. g_s_fieldcat-sp_group = 'S'. PERFORM f0410_fieldcat USING c_take c_no_out.

* 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 g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat * * * * * * = 'INSMK'. " BESTANDSART = 'MSEG'. " STOCK TYPE = 'B'. USING c_check c_no_out. = 'LIFNR'. " KONTONUMMER LIEFERANT = 'MSEG'. " VENDOR'S ACCOUNT NUMBER = 'E'. USING c_check c_no_out. = 'KUNNR'. " KONTONUMMER DES KUNDEN = 'MSEG'. " ACCOUNT NUMBER OF CUSTOMER = 'V'. 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 g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat = 'KDAUF'. " KUNDENAUFTRAGSNUMMER = 'MSEG'. " SALES ORDER NUMBER = 'V'. USING c_check c_no_out. = 'KDPOS'. " POSITIONSNUMMER = 'MSEG'. " ITEM NUMBER IN SALES ORDER = 'V'. USING c_check c_no_out. DELIVERY SCHEDULE FOR SALES ORDER = 'KDEIN'. = 'MSEG'. = 'F'. USING c_check c_no_out.

* EINTEILUNG KUNDENAUFTRAG g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat

* 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 g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat = 'ERFME'. " ERFASSUNGSMENGENEINHEIT = 'MSEG'. " UNIT OF ENTRY = 'M'. 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 g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat = 'BPRME'. " BESTELLPREISMENGENEINHEIT = 'MSEG'. " ORDER PRICE UNIT = 'E'. USING c_check c_no_out. = 'EBELN'. " BESTELLNUMMER = 'MSEG'. " PURCHASE ORDER NUMBER = 'E'. 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 g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat = 'SJAHR'. " MATERIALBELEGJAHR = 'MSEG'. " MATERIAL DOC. YEAR = 'D'. USING c_check c_no_out. = 'SMBLN'. " NUMMER DES MATERIALBELEGS = 'MSEG'. " NUMBER OF MATERIAL DOC. = 'O'. USING c_check c_no_out. = 'SMBLP'. " POSITION IM MATERIALBELEG = 'MSEG'. " ITEM IN MATERIAL DOCUMENT = 'O'. USING c_check c_no_out. = 'ELIKZ'. " ENDLIEFERUNGSKENNZEICHEN = 'MSEG'. "DELIVERY COMPLETED" INDICATOR = 'E'. USING c_check c_no_out. = 'SGTXT'. " POSITIONSTEXT = 'MSEG'. " ITEM TEXT = 'E'. USING c_check c_no_out. = 'WEMPF'. " WARENEMPF NGER = 'MSEG'. " GOODS RECIPIENT = 'V'. USING c_check c_no_out. = 'ABLAD'. " ABLADESTELLE = 'MSEG'. " UNLOADING POINT = 'V'. USING c_check c_no_out.

g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat

= 'GSBER'. " GESCH FTSBEREICH = 'MSEG'. " BUSINESS AREA = 'O'. 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 g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat = 'PARBU'. " VERRECHNENDER BUCHUNGSKREIS = 'MSEG'. " CLEARING COMPANY CODE = 'O'. USING c_check c_no_out. = 'KOSTL'. " KOSTENSTELLE = 'MSEG'. " COST CENTER = 'K'. USING c_check c_no_out. = 'AUFNR'. " AUFTRAGSNUMMER = 'MSEG'. " ORDER NUMBER = 'K'. USING c_check c_no_out. = 'ANLN1'. " ANLAGEN-HAUPTNUMMER = 'MSEG'. " MAIN ASSET NUMBER = 'K'. 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 g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat = 'UMCHA'. " EMPFANGENDE/ABGEBENDE CHARGE = 'MSEG'. " RECEIVING/ISSUING BATCH = 'M'. 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 g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat = 'KSTRG'. " KOSTENTR GER = 'MSEG'. " COST OBJECT = 'K'. 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 g_s_fieldcat-sp_group PERFORM f0410_fieldcat

= 'MSEG'. " PROFIT CENTER = 'O'. USING c_check c_no_out.

* PROJEKTSTRUKTURPLANELEMENT (PSP-ELEMENT) * WORK BREAKDOWN STRUCTURE ELEMENT (WBS ELEMENT) * * * * * PROCESS THE WBS RELEASE 4.5B AND HIGHER 4.0B ELEMENT DEPENDS ON THE RELEASE FIELD MAT_PSPNR PS_PSP_PNR = 'MAT_PSPNR'. = 'MSEG'. = 'K'. USING c_check c_no_out. = 'PS_PSP_PNR'. = 'MSEG'. = 'K'. USING c_check c_no_out. "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218

g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat

* 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 g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat = 'AUFPS'. " NUMMER DER AUFTRAGSPOSITION = 'MSEG'. " ORDER ITEM NUMBER = 'K'. 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 g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat = 'BSTME'. " BESTELLMENGENEINHEIT = 'MSEG'. " ORDER UNIT = 'E'. 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 g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat = 'PPRCTR'. " PARTNER-PROFIT CENTER = 'MSEG'. " PARTNER-PROFIT CENTER = 'O'. 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'. 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'. g_s_fieldcat-ref_tabname = 'MSEG'. g_s_fieldcat-sp_group = 'B'. PERFORM f0410_fieldcat USING c_check c_no_out.

"NOTE 201670

"NOTE 201670

g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat

= 'VPRSV'. " PREISSTEUERUNGSKENNZEICHEN = 'MSEG'. " PRICE CONTROL INDICATOR = 'S'. 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'. 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'. 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.

"NOTE 201670

"NOTE 201670

* 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 g_s_fieldcat-fieldname g_s_fieldcat-ref_tabname g_s_fieldcat-sp_group PERFORM f0410_fieldcat ENDIF.

HIDDEN, TOO = 'WAERS'. "CURRENCY KEY = 'T001'. = 'M'. USING c_take c_no_out.

"N497992 "N497992 "N497992 "N497992 "N497992 "N497992

ENDFORM.

"F0400_CREATE_FIELDCAT

*----------------------------------------------------------------------* * F0410_FIELDCAT *----------------------------------------------------------------------* FORM f0410_fieldcat USING l_f_check l_f_no_out DATA : l_f_continue(01) l_f_type(01) l_f_fieldname FIELD-SYMBOLS : <l_fs>. IF l_f_check = c_take. TAKE THIS ENTRY WITHOUT MOVE 'X' ELSE. * CREATE KEY AND LOOK FOR CONCATENATE * CHECK TO l_f_continue. FIELDNAME g_s_fieldcat-ref_tabname '~' g_s_fieldcat-fieldname INTO l_f_fieldname.

TYPE TYPE c, TYPE c, TYPE

slis_fieldcat_main-no_out.

stype_fields.

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 : * CLEAR THE WORKING AREA FOR THE FIELD CATALOG WHEN * THE CURRENT FIELD SHOULD NOT BE PROCESSED CLEAR g_s_fieldcat. CLEAR l_f_continue. ENDIF. ENDIF. * APPEND ENTRY TO FIELD CATALOG IF FIELD IS IN STRUCTURE * ELSE LEAVE THIS ROUTINE IF l_f_continue IS INITIAL. CLEAR g_s_fieldcat. EXIT. ENDIF. IF NOT l_f_no_out IS INITIAL. MOVE l_f_no_out TO g_s_fieldcat-no_out. ENDIF.

"N480130 "N480130 "N480130 "N480130

ADD : 1 MOVE : g_f_col_pos g_f_tabname APPEND g_s_fieldcat

TO TO TO TO

g_f_col_pos. g_s_fieldcat-col_pos, g_s_fieldcat-tabname. 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 g_s_fieldcat-fieldname g_s_fieldcat-fieldname g_s_fieldcat-fieldname g_s_fieldcat-fieldname g_s_fieldcat-fieldname g_s_fieldcat-fieldname g_s_fieldcat-fieldname g_s_fieldcat-fieldname g_s_fieldcat-fieldname g_s_fieldcat-fieldname * = = = = = = = = = = = 'BPMNG' 'BPRME' 'BSTMG' 'BSTME' 'EXBWR' 'VKWRT' 'EXVKW' 'VKWRA' 'LSMNG' 'LSMEH' 'SHKZG'. OR OR OR OR OR OR OR OR OR OR

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 <l_fs>. IF sy-subrc IS INITIAL. DESCRIBE FIELD <l_fs> TYPE l_f_type. 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. "F0410_FIELDCAT

ENDFORM.

*&----------------------------------------------------------"N443935 "N443935 *&---------------------------------------------------------------------* *& FORM BELEGE_ERGAENZEN_2 *&---------------------------------------------------------------------* * TEXT *----------------------------------------------------------------------* 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, g_s_mseg_old-mjahr TO matkey-mjahr. READ TABLE g_t_bsim_lean INTO g_s_bsim_lean WITH KEY bukrs = g_s_mseg_old-bukrs bwkey = g_s_mseg_old-bwkey matnr = g_s_mseg_old-matnr bwtar = g_s_mseg_old-bwtar shkzg = g_s_mseg_old-shkzg meins = g_s_mseg_old-meins budat = g_s_mseg_old-budat blart = g_s_mseg_old-blart awkey = matkey BINARY SEARCH. IF sy-subrc IS INITIAL. MOVE sy-tabix * TO g_f_tabix_start.

CONTINUE WITH SEQUENTIAL READ OF WORKING TABLE LOOP AT g_t_bsim_lean INTO g_s_bsim_lean FROM g_f_tabix_start. AND AND AND AND AND AND AND AND

IF g_s_bsim_lean-bukrs = g_s_mseg_old-bukrs g_s_bsim_lean-bwkey = g_s_mseg_old-bwkey g_s_bsim_lean-matnr = g_s_mseg_old-matnr g_s_bsim_lean-bwtar = g_s_mseg_old-bwtar g_s_bsim_lean-shkzg = g_s_mseg_old-shkzg g_s_bsim_lean-meins = g_s_mseg_old-meins g_s_bsim_lean-budat = g_s_mseg_old-budat g_s_bsim_lean-blart = g_s_mseg_old-blart g_s_bsim_lean-awkey = matkey. * SELECT ALL MATCHING ENTRIES ADD 1 TO g_cnt_bsim_entries. MOVE-CORRESPONDING g_s_bsim_lean TO g_s_bsim_work. MOVE sy-tabix TO g_s_bsim_work-tabix. APPEND g_s_bsim_work TO g_t_bsim_work. ELSE. EXIT. ENDIF. ENDLOOP. ENDIF. IF g_flag_break-b1 = 'X'. BREAK-POINT ID mmim_rep_mb5b. * DYNAMIC BREAK-POINT : RESULTS IN CONTOL BREAK ENDIF. * HOW MANY MATCHING ENTRIES FROM BSIM FOUND ? IF g_cnt_bsim_entries IS INITIAL. * NO BSIM ENTRIES FOUND -> NO ACTION.

"N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N921164 "N921164 "N921164 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935

ELSEIF g_cnt_bsim_entries = 1 AND g_cnt_mseg_entries = 1. * THE IDEAL CASE 1 MM AND 1 FI DOCUMENT; * MARK THIS FI DOC FOR DELETION LOOP AT g_t_bsim_work INTO g_s_bsim_work. READ TABLE g_t_bsim_lean INTO g_s_bsim_lean INDEX g_s_bsim_work-tabix.

CHECK : sy-subrc IS INITIAL. MOVE : 'D' TO g_s_bsim_lean-accessed. MODIFY g_t_bsim_lean FROM g_s_bsim_lean INDEX g_s_bsim_work-tabix TRANSPORTING accessed. * SET THE FI DOC NUMBER INTO THE ENTRY OF THE MM DOC READ TABLE g_t_mseg_work INTO g_s_mseg_work INDEX 1. CHECK : sy-subrc IS INITIAL. MOVE : g_s_bsim_work-belnr TO g_s_mseg_work-belnr, g_s_bsim_work-gjahr TO g_s_mseg_work-gjahr.

"N443935 "N443935 "N443935 "N443935 "N451923 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935 "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 IF g_flag_is_oil_active = 'X'. "IS-OIL ? "N599218 IF g_s_mseg_work-oiglcalc = 'L' AND "N599218 g_s_mseg_work-shkzg = 'H' AND "N599218 g_s_mseg_work-dmbtr = 0. "N599218 MOVE g_s_bsim_work-dmbtr "N599218 TO g_s_mseg_work-dmbtr. "N599218 ENDIF. "N599218 "N599218 MODIFY g_t_mseg_work "N599218 FROM g_s_mseg_work "N599218 INDEX 1 "N599218 TRANSPORTING belnr gjahr dmbtr. "N599218 ELSE. "N599218 MODIFY g_t_mseg_work FROM g_s_mseg_work "N599218 INDEX 1 "N599218 TRANSPORTING belnr gjahr. "N599218 ENDIF. "N599218 "N443935 "N443935 ELSE. "N443935 * THERE ARE A LOT OF MM DOCS "N443935 PERFORM belege_ergaenzen_several_docs. "N443935 "N443935 ENDIF. "N443935 ENDLOOP.

A A A A A A A A A A A A A A A A A A

* COPY THE NUMBER AND FISCAL YEAR INTO THE MATCHING * ENTRY OF THE MAIN TABLE G_T_MSEG_LEAN LOOP AT g_t_mseg_work INTO g_s_mseg_work. * ONLY WITH USEFUL FI DOC DATA CHECK : NOT g_s_mseg_work-belnr IS INITIAL. * READ THE ORIGINAL ENTRY AND CHANGE IT READ TABLE g_t_mseg_lean INTO g_s_mseg_update INDEX g_s_mseg_work-tabix. CHECK : sy-subrc IS INITIAL. "ENTRY FOUND ? MOVE : g_s_mseg_work-belnr TO g_s_mseg_update-belnr, g_s_mseg_work-gjahr TO g_s_mseg_update-gjahr. * **# **" **" **" **" **" **" **" **# * * * **# * CONSIDER SPECIAL GAIN/LOSS-HANDLING OF IS-OIL IF EXIST OI001 MOVE G_S_MSEG_WORK-DMBTR TO G_S_MSEG_UPDATE-DMBTR.

"N443935 "N451923 "N451923 "N451923 "N451923 "N451923 "N443935 "N451923 "N451923 "N451923 "N443935 "N451923 "N451923 "N451923 "N451923 "N451923 "N497992 "N497992 "N497992 "N497992 "N497992 "N497992 "N497992 "N497992

MODIFY G_T_MSEG_LEAN FROM G_S_MSEG_UPDATE INDEX G_S_MSEG_WORK-TABIX TRANSPORTING BELNR GJAHR DMBTR. 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 "N451923 belege_ergaenzen_clear.

ENDLOOP. PERFORM

"N443935 "N443935 ENDFORM. "BELEGE_ERGAENZEN_2 "N443935 "N443935 *&----------------------------------------------------------"N443935 *& BELEGE_ERGAENZEN_CLEAR *&----------------------------------------------------------"N443935 "N443935 *&---------------------------------------------------------------------* *& FORM BELEGE_ERGAENZEN_CLEAR *&---------------------------------------------------------------------* * TEXT

*----------------------------------------------------------------------* 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 * BELEGE_ERGAENZEN_SEVERAL_DOCS *&----------------------------------------------------------"N443935 "N443935 *&---------------------------------------------------------------------* *& FORM BELEGE_ERGAENZEN_SEVERAL_DOCS *&---------------------------------------------------------------------* * TEXT *----------------------------------------------------------------------* 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 IF g_flag_break-b2 = 'X'. BREAK-POINT ID mmim_rep_mb5b. * DYNAMIC BREAK-POINT : IN CONTROL BREAK ENDIF. * * * IF g_cnt_mseg_entries NE g_cnt_mseg_done. THERE ARE MM DOCS WITHOUT FI DOC LEFT SUBTRACT THE QUANTITY AND VALUE FROM MM DOC FROM THE FIELDS OF THE FI DOC LOOP AT g_t_mseg_work INTO g_s_mseg_work. "N921164 "N921164 "N921164 "N921164 "N443935 "N443935 "N443935 "N443935 "N443935 "N443935

"N443935 "N443935 "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 * CHANGE QUANTITY AND VALUE IN WORKING TABLE, TOO "N747306 TRANSPORTING accessed menge dmbtr. "N747306 "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 *&---------------------------------------------------------------------* *& FORM USER_COMMAND * * TAKE ONLY THE ENTRIES WITHOUT FI DOC NUMBER CHECK : g_s_mseg_work-belnr IS INITIAL.

*&---------------------------------------------------------------------* FORM user_command USING "#EC CALLED 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) ls_sel lt_sel l_lines ls_fc lt_fc ls_selfield l_fi_doc. * * * * * * * * * * * TYPE TYPE TYPE LIKE TYPE TYPE TYPE n, ty_s_sel, ty_t_sel, sy-tabix, slis_fieldcat_alv, slis_t_fieldcat_alv, slis_selfield,

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 THEREFOR 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.

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. READ AND SAVE THE USER PARAMETERS BEFORE CALLING TRANSACTION MIGO OR FB03 PERFORM user_parameters_save. 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' EXPORTING i_action = 'A04' i_refdoc = 'R02' i_notree = 'X' i_no_auth_check = ' ' i_deadend = 'X' i_skip_first_screen = 'X' i_okcode = 'OK_GO' i_mblnr = ls_sel-mblnr i_mjahr = ls_sel-mjahr i_zeile = ls_sel-zeile. 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. * RESTORE THE FORMER USER PARAMETERS PERFORM user_parameters_restore. ENDCASE. ENDFORM. " USER_COMMAND

"N547170 "N547170 "N547170 "N547170 "N547170 "N547170 "N547170 "N547170 "N547170 "N547170 "N547170 "N547170

*-----------------------------------------------------------"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 lgbst bwbst sbbst xchar xsum pa_sumfl nosto PARAMETERS FROM THE LAST RUN = oref_settings->get( 'LGBST' ). = oref_settings->get( 'BWBST' ). = oref_settings->get( 'SBBST' ). = oref_settings->get( 'XCHAR' ). = oref_settings->get( 'XSUM' ). = oref_settings->get( 'PA_SUMFL' ). = oref_settings->get( 'NOSTO' ). "N599218

** GET THE PARAMETERS FOR THE LIST CATEGORIES

pa_wdzer pa_wdzew pa_wdwiz pa_wdwuw pa_wdwew pa_ndsto pa_ndzer xnomchb

= = = = = = = =

oref_settings->get( oref_settings->get( oref_settings->get( oref_settings->get( oref_settings->get( oref_settings->get( oref_settings->get( oref_settings->get(

'PA_WDZER' ). 'PA_WDZEW' ). 'PA_WDWIZ' ). 'PA_WDWUW' ). 'PA_WDWEW' ). 'PA_NDSTO' ). 'PA_NDZER' ). 'XNOMCHB' ).

"N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "838360

** 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. "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N547170

* AT THE FIRST TIME ( OR IN A LOWER RELEASE ) ALL SEVEN * LIST CATEGORIES WILL BE INITIAL --> ACTIVATE THEM ALL PERFORM f0850_empty_parameters. IF g_cnt_empty_parameter MOVE : 'X' 'X' 'X' 'X' 'X' 'X' 'X' ENDIF. ENDFORM. = 7. TO TO TO TO TO TO TO pa_wdzer, pa_wdzew, pa_wdwiz, pa_wdwuw, pa_wdwew, pa_ndsto, pa_ndzer.

"ESDUS_GET_PARAMETERS

*-----------------------------------------------------------"N547170 * ESDUS_SAVE_PARAMETERS "N547170 *-----------------------------------------------------------"N547170 FORM esdus_save_parameters. * 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' "N547170 "N547170

i_active = sbbst ). CALL METHOD oref_settings->set( i_element = 'XCHAR' i_active = xchar ). CALL METHOD oref_settings->set( i_element = 'XNOMCHB' "838360 i_active = xnomchb ). "838360 * * * * * * * * CALL METHOD OREF_SETTINGS->SET( I_ELEMENT = 'XONUL' I_ACTIVE = XONUL ). CALL METHOD OREF_SETTINGS->SET( I_ELEMENT I_ACTIVE CALL METHOD OREF_SETTINGS->SET( I_ELEMENT I_ACTIVE SAVE THE LIST CATEGORIES CALL METHOD oref_settings->set( i_element i_active CALL METHOD oref_settings->set( i_element i_active CALL METHOD oref_settings->set( i_element i_active CALL METHOD oref_settings->set( i_element i_active CALL METHOD oref_settings->set( i_element i_active CALL METHOD oref_settings->set( i_element i_active CALL METHOD oref_settings->set( i_element i_active = = = = = = = = = = = = = = = = = = 'XVBST' XVBST ). 'XNVBST' XNVBST ). "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218 "N599218

'PA_WDZER' pa_wdzer ). 'PA_WDZEW' pa_wdzew ). 'PA_WDWIZ' pa_wdwiz ). 'PA_WDWUW' pa_wdwuw ). 'PA_WDWEW' pa_wdwew ). 'PA_NDSTO' pa_ndsto ). 'PA_NDZER' pa_ndzer ).

CALL METHOD oref_settings->set( i_element = 'XSUM' i_active = xsum ). CALL METHOD oref_settings->set( i_element = 'PA_SUMFL' i_active = pa_sumfl ). 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 COMMAND DOES NOT ALLOW TO RECORD THIS TRANSACTION FOR A BATCH INPUT SESSION USING TRANSACTION SHDB CALL FUNCTION 'DB_COMMIT'. "ESDUS_SAVE_PARAMETERS "N599218 "N599218 "N599218 "N599218 "N547170

ENDFORM.

*-----------------------------------------------------------"N547170 "N599218 A *&---------------------------------------------------------------------* *& FORM CHECK_IS_OIL_SYSTEM *&---------------------------------------------------------------------* * TEXT *----------------------------------------------------------------------* 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 "N599218 A "N599218 A "N599218 A "N599218 A "N599218 A "N599218 A "N599218 A "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 *----------------------------------------------------------------------* * CALCULATE_OFFSETS. *----------------------------------------------------------------------* * DOES DATABASE OI001 EXIST IN THIS SYSTEM ? CALL FUNCTION 'DDIF_NAMETAB_GET' EXPORTING tabname = g_f_dcobjdef_name TABLES x031l_tab = g_t_x031l EXCEPTIONS OTHERS = 1. * CALCULATE THE OFFSETS FOR THE LIST HEADER FORM calculate_offsets. * WORKING AREA DATA : l_text(132) * GET THE PERFORM PERFORM PERFORM PERFORM TYPE c. ELEMENTS TO BE USED text-020. text-021. text-022. text-023.

MAXIMAL LENGTH OF THE TEXT get_max_text_length USING get_max_text_length USING get_max_text_length USING get_max_text_length USING

PERFORM get_max_text_length USING text-025. g_offset_header CLEAR * = g_f_length_max + 3. g_f_length_max.

IF bwbst IS INITIAL. STOCKS AND QUANTITIES ONLY MOVE text-007 TO g_date_line_from-text. WRITE : datum-low TO g_date_line_from-datum DD/MM/YYYY. CONDENSE g_date_line_from. PERFORM get_max_text_length USING g_date_line_from. MOVE text-005 TO g_text_line-text. PERFORM get_max_text_length USING g_text_line. MOVE text-006 TO g_text_line. PERFORM get_max_text_length USING g_text_line.

MOVE text-007 TO g_date_line_to-text. WRITE : datum-high TO g_date_line_to-datum DD/MM/YYYY. CONDENSE g_date_line_to. ELSE. * STOCKS, QUANTITIES, AND VALUES MOVE text-008 TO g_date_line_from-text. WRITE : datum-low TO g_date_line_from-datum DD/MM/YYYY. CONDENSE g_date_line_from. * * THE START AND END DATES WERE SHOWN INCORRECTLY IN THE "N856424 HEADLINES IN THE MODE VALUATED STOCK "N856424 PERFORM get_max_text_length USING g_date_line_from. "N856424 MOVE text-030 TO g_text_line-text. PERFORM get_max_text_length USING g_text_line. MOVE text-031 TO g_text_line-text. PERFORM get_max_text_length USING g_text_line. MOVE text-008 WRITE : datum-high CONDENSE ENDIF. TO g_date_line_to-text. TO g_date_line_to-datum DD/MM/YYYY. g_date_line_to.

* CALCULATE THE OFFSETS FOR THE FOLLOWING COLUMNS g_offset_qty = g_f_length_max + 2. g_offset_unit = g_offset_qty + 25. g_offset_value = g_offset_unit + 8. g_offset_curr = g_offset_value + 25. ENDFORM. " CALCULATE_OFFSETS.

*----------------------------------------------------------------------* * GET_MAX_TEXT_LENGTH *----------------------------------------------------------------------* FORM get_max_text_length g_f_length = STRLEN( l_text ). IF g_f_length > g_f_length_max. USING l_text TYPE any.

MOVE g_f_length ENDIF. ENDFORM.

TO g_f_length_max. " GET_MAX_TEXT_LENGTH

*----------------------------------------------------------------------* * CONTAINS FORM ROUTINES WITHOUT PREPROCESSOR COMMANDS AND "N547170 * NO TEXT ELEMENTS "N547170 INCLUDE zrm07mlbd_form_01n_mat. *INCLUDE ZRM07MLBD_FORM_01N. "N547170NITIN INCLUDE zrm07mlbd_form_02n_mat. *INCLUDE ZRM07MLBD_FORM_02N. "N547170NITIN

*----------------------------------------------------------------------* *&---------------------------------------------------------------------* *& FORM BUILD_USER_DROP_DOWN_LIST *&---------------------------------------------------------------------* * TEXT *----------------------------------------------------------------------* * --> P1 TEXT * <-- P2 TEXT *----------------------------------------------------------------------* FORM build_user_drop_down_list . DATA: name TYPE vrm_id, list TYPE vrm_values, value LIKE LINE OF list. DATA: it247 TYPE t247 OCCURS 0 WITH HEADER LINE. CLEAR list. REFRESH list. name = 'MONTHS'. SELECT * INTO CORRESPONDING FIELDS OF TABLE it247 FROM t247 WHERE spras = 'EN'. SORT it247. LOOP AT it247. CLEAR value. value-key = it247-mnr. value-text = it247-ltx. APPEND value TO list. ENDLOOP. * SET THE VALUES CALL FUNCTION 'VRM_SET_VALUES' EXPORTING id = name values = list. ENDFORM. " BUILD_USER_DROP_DOWN_LIST

*&---------------------------------------------------------------------* *& Form colorize_totals_flat1 *&---------------------------------------------------------------------*

* text *----------------------------------------------------------------------* * -->L_FIELDNAME text *----------------------------------------------------------------------* FORM colorize_totals_flat1 USING l_fieldname TYPE any. DATA : l_f_fieldname(30) TYPE c. FIELD-SYMBOLS : <l_fs_field>. * CUSTOMIZING : SET THE COLOR INFORMATION CHECK : g_cust_color = 'X'. CONCATENATE 'G_S_TOTALS_FLAT-' l_fieldname INTO l_f_fieldname. ASSIGN (l_f_fieldname) TO <l_fs_field>. CHECK sy-subrc IS INITIAL. IF <l_fs_field> > 0. MOVE : l_fieldname TO g_s_color-fieldname, '5' TO g_s_color-color-col, '0' TO g_s_color-color-int. APPEND g_s_color TO it_color.

"GREEN

ELSEIF <l_fs_field> < 0. MOVE : l_fieldname TO g_s_color-fieldname, '6' TO g_s_color-color-col, "RED '0' TO g_s_color-color-int. APPEND g_s_color TO it_color. ENDIF. ENDFORM. " COLORIZE_TOTALS_FLAT