‎2007 Sep 06 6:10 AM
Dear Abapers,
I have created a dynamic report for Material Consumption where for material it automatically generates Months & year like Apr-2006 , based on the required date parameters. All working ok.
my problem is that , when i use selection-option it does not support IN statement in SQL query.
to the run the report I have to use parameters for selection of material.
But some time we have to exclude some items from selection, I want to user In statemnet in query.
Pl. help.
regards
Vikas
‎2007 Sep 06 6:18 AM
Hi,
Use
SELECT matnr
werks
INTO TABLE i_mara
FROM marc
WHERE matnr IN s_matnr AND
werks IN s_werks .
like the above or just send me u r query format what is problem.
Regards,
Nandha
‎2007 Sep 06 6:21 AM
‎2007 Sep 06 6:23 AM
‎2007 Sep 06 6:33 AM
<b>Error : The IN operator with "P_MATNR1" is followed, neither by an internal table nor by a value list.</b>
Query is
APPEND ` IF P_MVT = '311'.` to TAB.
APPEND ` SELECT BMATNR ABUDAT BBWART BMENGE BMEINS BSHKZG BLGORT BKOSTL BDMBTR CMAKTX` TO tab.
APPEND ` INTO CORRESPONDING FIELDS OF TABLE IT_TREND1 FROM MKPF AS A INNER JOIN MSEG AS B ` TO tab.
APPEND ` ON AMBLNR = BMBLNR ` TO tab.
APPEND ` AND AMJAHR = BMJAHR ` TO tab.
APPEND ` INNER JOIN MAKT AS C on BMATNR = CMATNR ` TO tab.
APPEND ` WHERE ( ABUDAT >= P_DATE1 AND ABUDAT <= P_DATE2 )` to TAB.
APPEND ` AND B~BWART = P_MVT` to TAB.
APPEND ` AND B~LGORT like P_SLOC` to TAB.
*APPEND ` AND B~SHKZG = 'S'` to TAB.
APPEND ` AND B~MATNR in P_MATNR1 ` to TAB.
APPEND ` ORDER BY BMATNR ABUDAT B~BWART.` to TAB.
APPEND ` ENDIF ` To tab.
‎2007 Sep 06 6:35 AM
‎2007 Sep 06 6:42 AM
Hi Vikas ,
i suppose you are creating a report code dynimicaly . well can u send the code of the dynimicaly generated report . it will help me to understand the problem
well what is the case to use dynamic report . i would like to know more about it
‎2007 Sep 06 6:44 AM
REPORT z_pp_consump_trend_a NO STANDARD PAGE HEADING.
DATA: prog TYPE string,
tab TYPE STANDARD TABLE OF string,
mess TYPE string,
sid TYPE string.
TABLES: mseg , mkpf , makt.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-101.
PARAMETER : p_mvt LIKE mseg-bwart DEFAULT '261' OBLIGATORY .
PARAMETER : p_sloc LIKE mseg-lgort DEFAULT 'GENS' OBLIGATORY MODIF ID abc.
SELECT-OPTIONS : p_matnr1 FOR mseg-matnr.
PARAMETER : p_matnr LIKE MSEG-matnr default '%'.
PARAMETER : p_date1 LIKE mkpf-budat DEFAULT '20060401' OBLIGATORY .
PARAMETER : p_date2 LIKE mkpf-budat OBLIGATORY DEFAULT sy-datum .
SELECTION-SCREEN END OF BLOCK b1.
APPEND `PROGRAM subpool. ` TO tab.
DATA : ch1 TYPE c LENGTH 1 VALUE 'X'.
FOR SCREEN CONTROL
*AT SELECTION-SCREEN OUTPUT.
IF P_MVT = '261'.
LOOP AT SCREEN.
IF SCREEN-GROUP1 = 'ABC'.
SCREEN-INPUT = '0'.
SCREEN-INVISIBLE = '1'.
SCREEN-REQUEST = '1'.
p_sloc = ' '.
*
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ELSE.
p_sloc = 'GENS'.
ENDIF.
*----
----
*WRITE:/ 'date1'.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
PERCENTAGE = 1
TEXT = 'Step -1 '.
.
APPEND ` TYPE-POOLS: slis. ` TO tab.
APPEND `LOAD-OF-PROGRAM. ` TO tab.
*APPEND `write:/ 'HELLO' . ` TO tab.
DATA: wfield TYPE c LENGTH 50.
APPEND ` DATA: Gs_SORT TYPE SLIS_SORTINFO_ALV. ` to tab.
APPEND `DATA: WDATE LIKE MKPF-BUDAT, ` TO tab.
APPEND ` WDT2 LIKE MKPF-BUDAT, ` TO tab.
APPEND ` WDT1 LIKE MKPF-BUDAT , ` TO tab.
APPEND ` WDT LIKE MKPF-BUDAT, ` TO tab.
APPEND ` WDT3 LIKE MKPF-BUDAT, ` TO tab.
APPEND ` COL TYPE I, ` TO tab.
APPEND ` WCAT TYPE C LENGTH 40, ` TO tab.
APPEND ` WNAME TYPE C LENGTH 40, ` TO tab.
APPEND ` WCOLS TYPE I VALUE 17, ` TO tab.
APPEND ` WCOLS1 TYPE I VALUE 14, ` TO tab.
APPEND ` WCOLS2 TYPE I VALUE 15, ` TO tab.
APPEND ` P_DATE1 TYPE SY-DATUM, ` TO tab.
APPEND ` P_DATE2 TYPE SY-DATUM, ` TO tab.
APPEND ` P_SLOC TYPE MSEG-LGORT, ` TO tab.
APPEND ` P_MATNR TYPE MSEG-MATNR, ` TO tab.
APPEND ` P_MATNR1 TYPE MSEG-MATNR, ` TO tab.
APPEND ` P_MVT TYPE mseg-bwart. ` TO tab.
CONCATENATE `P_DATE1 = '` p_date1 `'.` INTO wfield.
APPEND wfield TO tab.
CONCATENATE `P_DATE2 = '` p_date2 `'.` INTO wfield.
APPEND wfield TO tab.
CONCATENATE `P_MATNR = '` p_MATNR `'.` INTO wfield.
APPEND wfield TO tab.
CONCATENATE `P_mvt = '` p_mvt `'.` INTO wfield.
APPEND wfield TO tab.
CONCATENATE `P_sloc = '` p_sloc `'.` INTO wfield.
APPEND wfield TO tab.
*APPEND `write:/ 'PDate ',P_DATE1.` TO tab.
*APPEND `write:/ 'PDate2 ',P_DATE2.` TO tab.
APPEND ` DATA: WPR TYPE P LENGTH 10 DECIMALS 2 ,` TO tab.
APPEND ` WPR1 TYPE P LENGTH 10 DECIMALS 2 ,` TO tab.
APPEND ` WPR2 TYPE P LENGTH 10 DECIMALS 2 ,` TO tab.
APPEND ` WDIFF TYPE P LENGTH 10 DECIMALS 2 ,` TO tab.
APPEND ` WWORD TYPE C LENGTH 24,` TO tab.
APPEND ` WWPR TYPE C LENGTH 10,` TO tab.
APPEND ` WWPR1 TYPE C LENGTH 10,` TO tab.
APPEND ` WD TYPE P LENGTH 5 DECIMALS 2 VALUE '0.01'.` TO tab.
APPEND ` DATA: WPRE TYPE C LENGTH 4.` TO tab.
APPEND ` CLEAR WPR.` TO tab.
APPEND `wdt3 = p_date1. ` TO tab.
APPEND `wdt1 = wdt3. ` TO tab.
APPEND `CONCATENATE p_date2+0(6) '01' INTO wdt2. ` TO tab.
CLEAR wfield.
CONCATENATE `P_MVT = '` p_mvt `'.` INTO wfield.
APPEND wfield TO tab.
CLEAR wfield.
CONCATENATE `P_MATNR = '` p_matnr `'.` INTO wfield.
APPEND wfield TO tab.
CLEAR wfield.
CONCATENATE `P_MATNR1 = '` p_matnr1 `'.` INTO wfield.
APPEND wfield TO tab.
CLEAR wfield.
CONCATENATE `P_SLOC = '` p_sloc `'.` INTO wfield.
APPEND wfield TO tab.
working ok Step 1
MONTH DIFF FUNCTION *****************************
APPEND ` DATA: WMONTHS TYPE I VALUE 1. ` TO tab.
APPEND ` CALL FUNCTION 'MONTHS_BETWEEN_TWO_DATES' ` TO tab.
APPEND ` EXPORTING ` TO tab.
APPEND ` I_DATUM_BIS = WDT2 ` TO tab.
APPEND ` I_DATUM_VON = WDT1 ` TO tab.
APPEND ` I_KZ_INCL_BIS = ' ' ` TO tab.
APPEND ` IMPORTING ` TO tab.
APPEND ` E_MONATE = WMONTHS. ` TO tab.
****************************************************************
APPEND ` DATA: BEGIN OF IT_RANGE OCCURS 0, ` TO tab.
APPEND ` PR1 TYPE C LENGTH 1 , ` TO tab.
APPEND ` PRANGE TYPE C LENGTH 24, ` TO tab.
APPEND ` END OF IT_RANGE. ` TO tab.
DATA: wdate1 TYPE sy-datum .
DATA: wdate2 TYPE sy-datum.
DATA: wmonth3 TYPE n LENGTH 2.
DATA: wyear3 TYPE n LENGTH 4.
DATA: wmonth4 TYPE n LENGTH 2.
DATA: wyear4 TYPE n LENGTH 4.
wdate1 = p_date1.
wdate2 = p_date2.
wmonth3 = wdate1+4(2).
wmonth4 = wdate2+4(2).
wyear3 = wdate1+0(4).
wyear4 = wdate2+0(4).
APPEND ` data: fieldcatalog type slis_t_fieldcat_alv with header line,` TO tab.
APPEND ` gd_tab_group type slis_t_sp_group_alv, ` TO tab.
APPEND ` gd_layout type slis_layout_alv,` TO tab.
APPEND ` gd_sort type slis_t_sortinfo_alv,` TO tab.
APPEND ` gd_repid like sy-repid,` TO tab.
APPEND ` gt_events type slis_t_event,` TO tab.
APPEND ` gd_prntparams type slis_print_alv. ` TO tab.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
PERCENTAGE = 2
TEXT = 'Step -2 '.
DATA: BEGIN OF it_test1 OCCURS 0,
name1 TYPE c LENGTH 100,
name2 TYPE c LENGTH 100,
name3 TYPE c LENGTH 100,
name4 TYPE c LENGTH 100,
name5 TYPE c LENGTH 100,
name6 TYPE c LENGTH 1,
size TYPE n length 2,
END OF it_test1.
DATA: wmon type c length 10.
MOVE ' TYPES: BEGIN OF IT_ORD_TREND, ' TO it_test1-name1.
APPEND it_test1.
MOVE ' MATNR LIKE MSEG-MATNR, ' TO it_test1-name1.
MOVE 'MATNR ' TO it_test1-name3.
MOVE 'Material' TO it_test1-name4.
MOVE 'R' TO it_test1-name6.
MOVE 18 TO it_test1-size.
APPEND it_test1.
MOVE ' BWART LIKE MSEG-BWART, ' TO it_test1-name1.
MOVE 'BWART ' TO it_test1-name3.
MOVE 'Mvt' TO it_test1-name4.
MOVE ' ' TO it_test1-name6.
MOVE 4 TO it_test1-size.
APPEND it_test1.
MOVE ' BUDAT LIKE MKPF-BUDAT, ' TO it_test1-name1.
MOVE 'BUDAT ' TO it_test1-name3.
MOVE 'DATE' TO it_test1-name4.
MOVE ' ' TO it_test1-name6.
MOVE 10 TO it_test1-size.
APPEND it_test1.
MOVE ' MAKTX LIKE MAKT-MAKTX, ' TO it_test1-name1.
MOVE 'MAKTX ' TO it_test1-name3.
MOVE 'Description' TO it_test1-name4.
MOVE 'R' TO it_test1-name6.
MOVE 35 TO it_test1-size.
APPEND it_test1.
MOVE ' MENGE TYPE P LENGTH 10 DECIMALS 3, ' TO it_test1-name1.
MOVE 'MENGE ' TO it_test1-name3.
MOVE 'Qty' TO it_test1-name4.
MOVE ' ' TO it_test1-name6.
MOVE 16 TO it_test1-size.
APPEND it_test1.
MOVE ' MEINS TYPE MSEG-MEINS, ' TO it_test1-name1.
MOVE 'MEINS ' TO it_test1-name3.
MOVE 'Uom' TO it_test1-name4.
MOVE 'R' TO it_test1-name6.
MOVE 10 TO it_test1-size.
APPEND it_test1.
MOVE ' SHKZG LIKE MSEG-SHKZG, ' TO it_test1-name1.
MOVE 'SHKZG ' TO it_test1-name3.
MOVE 'CREDIT' TO it_test1-name4.
MOVE ' ' TO it_test1-name6.
MOVE 5 TO it_test1-size.
APPEND it_test1.
MOVE ' LGORT LIKE MSEG-LGORT, ' TO it_test1-name1.
MOVE 'LGORT ' TO it_test1-name3.
MOVE 'S.Loc' TO it_test1-name4.
MOVE 'R' TO it_test1-name6.
MOVE 8 TO it_test1-size.
APPEND it_test1.
MOVE ' KOSTL LIKE MSEG-KOSTL, ' TO it_test1-name1.
MOVE 'KOSTL ' TO it_test1-name3.
MOVE 'C.Centre' TO it_test1-name4.
MOVE 'R' TO it_test1-name6.
MOVE 15 TO it_test1-size.
APPEND it_test1.
MOVE ' DMBTR LIKE MSEG-DMBTR, ' TO it_test1-name1.
MOVE 'DMBTR ' TO it_test1-name3.
MOVE 'Value' TO it_test1-name4.
MOVE 'R' TO it_test1-name6.
MOVE 16 TO it_test1-size.
APPEND it_test1.
MOVE ' LG_MAT TYPE C length 25, ' TO it_test1-name1.
MOVE 'LG_MAT ' TO it_test1-name3.
MOVE 'LG_MAT' TO it_test1-name4.
MOVE ' ' TO it_test1-name6.
MOVE 25 TO it_test1-size.
APPEND it_test1.
MOVE ' dt_fld TYPE C LENGTH 7, ' TO it_test1-name1.
MOVE 'DT_FLD ' TO it_test1-name3.
MOVE 'DTFLD' TO it_test1-name4.
MOVE ' ' TO it_test1-name6.
MOVE 10 TO it_test1-size.
APPEND it_test1.
MOVE ' MATNRNEW TYPE C LENGTH 35, ' TO it_test1-name1.
MOVE 'MATNRNEW ' TO it_test1-name3.
MOVE 'MATNEW' TO it_test1-name4.
MOVE ' ' TO it_test1-name6.
MOVE 35 TO it_test1-size.
APPEND it_test1.
DO.
IF wyear3 = wyear4 AND wmonth3 = wmonth4.
CONCATENATE ` M` wmonth3 wyear3 ` TYPE P LENGTH 10 DECIMALS 3,` INTO it_test1-name1 .
CONCATENATE `MOVE it_trend1-menge to M` wmonth3 wyear3 `,` INTO it_test1-name2 .
CONCATENATE `M` wmonth3 wyear3 INTO it_test1-name3.
clear wmon.
select single ltx from t247 into wmon where spras = sy-langu and mnr = wmonth3.
CONCATENATE wmon+0(3) '-' wyear3 INTO it_test1-name4.
CONCATENATE wmon+0(3) '-' wyear3 INTO it_test1-name5.
move `R` TO it_test1-name6.
MOVE 16 TO it_test1-size.
APPEND it_test1.
EXIT.
ENDIF.
CLEAR wfield.
CONCATENATE ` M` wmonth3 wyear3 ` TYPE P LENGTH 10 DECIMALS 3,` INTO it_test1-name1 .
CONCATENATE `MOVE it_trend1-menge to M` wmonth3 wyear3 `,` INTO it_test1-name2 .
CONCATENATE `M` wmonth3 wyear3 INTO it_test1-name3.
select single ltx from t247 into wmon where spras = sy-langu and mnr = wmonth3.
CONCATENATE wmon+0(3) '-' wyear3 INTO it_test1-name4.
CONCATENATE wmon+0(3) '-' wyear3 INTO it_test1-name5.
move `R` TO it_test1-name6.
MOVE 16 TO it_test1-size.
APPEND it_test1.
IF wmonth3 = 12.
wyear3 = wyear3 + 1.
wmonth3 = 1.
ELSE.
wmonth3 = wmonth3 + 1.
ENDIF.
ENDDO.
MOVE ' MENGE1 TYPE P LENGTH 10 DECIMALS 3, ' TO it_test1-name1.
MOVE 'MENGE1 ' TO it_test1-name3.
MOVE 'Total' TO it_test1-name4.
MOVE 'R' TO it_test1-name6.
MOVE 16 TO it_test1-size.
APPEND it_test1.
MOVE ' DMBTR1 LIKE MSEG-DMBTR, ' TO it_test1-name1.
MOVE 'DMBTR1 ' TO it_test1-name3.
MOVE 'Total Value' TO it_test1-name4.
MOVE 'R' TO it_test1-name6.
MOVE 16 TO it_test1-size.
APPEND it_test1.
MOVE ' END OF IT_ORD_TREND. ' TO it_test1-name1.
move ` ` tO it_test1-name2 .
move ` ` tO it_test1-name3.
move ` ` tO it_test1-name4.
move ` ` tO it_test1-name5.
move ` ` TO it_test1-name6.
APPEND it_test1.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
PERCENTAGE = 3
TEXT = 'Step -3 '.
LOOP AT it_test1.
APPEND it_test1-name1 TO tab.
ENDLOOP.
APPEND ` DATA: begin OF it_test2 OCCURS 0 , ` TO tab.
APPEND ` name1 type c length 100 , ` TO tab.
APPEND ` name2 type c length 100 , ` TO tab.
APPEND ` name3 type c length 100 , ` TO tab.
APPEND ` name4 type c length 100 , ` TO tab.
APPEND ` name5 type c length 100 , ` TO tab.
APPEND ` END of it_test2. ` TO tab.
CLEAR wfield.
LOOP AT it_test1.
CLEAR wfield.
CONCATENATE ` it_test2-name3 = '` it_test1-name3 `'.` INTO wfield.
APPEND wfield TO tab.
CLEAR wfield.
CONCATENATE ` it_test2-name4 = '` it_test1-name4 `'.` INTO wfield.
APPEND wfield TO tab.
APPEND 'append it_test2.' TO tab.
ENDLOOP.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
PERCENTAGE = 4
TEXT = 'Step -4 '.
**
APPEND `DELETE it_test2 where name3 = space.` TO tab.
APPEND ` loop at it_test2.` TO tab.
APPEND ` endloop.` TO tab.
*
APPEND ` DATA: IT_TREND1 TYPE IT_ORD_TREND OCCURS 0 WITH HEADER LINE,` TO tab.
APPEND ` IT_TREND2 TYPE IT_ORD_TREND OCCURS 0 WITH HEADER LINE,` TO tab.
APPEND ` IT_TREND3 TYPE IT_ORD_TREND OCCURS 0 WITH HEADER LINE,` TO tab.
APPEND ` IT_TREND4 TYPE IT_ORD_TREND OCCURS 0 WITH HEADER LINE.` TO tab.
WORKING OK STEP 3
****************************************************
APPEND ` DATA: WCOUNT TYPE I VALUE 0.` TO tab.
APPEND ` CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR' ` TO tab.
APPEND ` EXPORTING ` TO tab.
APPEND ` PERCENTAGE = 10 ` TO tab.
APPEND ` TEXT = 'Step -5 Data '. ` TO tab.
APPEND `FORM loop_at_tab1.` TO tab. "******************* Form Loot_at_tab1.***********************************
APPEND ` IF P_MVT = '311'.` to TAB.
APPEND ` SELECT BMATNR ABUDAT BBWART BMENGE BMEINS BSHKZG BLGORT BKOSTL BDMBTR CMAKTX` TO tab.
APPEND ` INTO CORRESPONDING FIELDS OF TABLE IT_TREND1 FROM MKPF AS A INNER JOIN MSEG AS B ` TO tab.
APPEND ` ON AMBLNR = BMBLNR ` TO tab.
APPEND ` AND AMJAHR = BMJAHR ` TO tab.
APPEND ` INNER JOIN MAKT AS C on BMATNR = CMATNR ` TO tab.
APPEND ` WHERE ( ABUDAT >= P_DATE1 AND ABUDAT <= P_DATE2 )` to TAB.
APPEND ` AND B~BWART = P_MVT` to TAB.
APPEND ` AND B~LGORT like P_SLOC` to TAB.
*APPEND ` AND B~SHKZG = 'S'` to TAB.
APPEND ` AND B~MATNR like P_MATNR ` to TAB.
APPEND ` AND B~MATNR in P_MATNR1 ` to TAB.
APPEND ` ORDER BY B~MATNR A~BUDAT B~BWART.` to TAB.
APPEND ` ELSEif P_MVT = '261'.` to TAB.
APPEND ` SELECT B~MATNR A~BUDAT B~BWART B~MENGE B~MEINS B~SHKZG B~LGORT B~KOSTL B~DMBTR C~MAKTX` TO tab.
APPEND ` INTO CORRESPONDING FIELDS OF TABLE IT_TREND1 FROM MKPF AS A INNER JOIN MSEG AS B ` TO tab.
APPEND ` ON A~MBLNR = B~MBLNR ` TO tab.
APPEND ` AND A~MJAHR = B~MJAHR ` TO tab.
APPEND ` INNER JOIN MAKT AS C on B~MATNR = C~MATNR ` TO tab.
APPEND ` where B~BWART = P_MVT ` TO tab.
APPEND ` AND B~SHKZG = 'H'` to TAB.
APPEND ` and ( A~BUDAT >= p_date1 and a~budat <= p_date2 ) ` TO tab.
APPEND ` AND B~MATNR LIKE P_MATNR ORDER BY B~MATNR A~BUDAT B~BWART.` to TAB.
APPEND ` ELSEif P_MVT = '201'.` to TAB.
APPEND ` SELECT B~MATNR A~BUDAT B~BWART B~MENGE B~MEINS B~SHKZG B~LGORT B~KOSTL b~DMBTR C~MAKTX` TO tab.
APPEND ` INTO CORRESPONDING FIELDS OF TABLE IT_TREND1 FROM MKPF AS A INNER JOIN MSEG AS B ` TO tab.
APPEND ` ON A~MBLNR = B~MBLNR ` TO tab.
APPEND ` AND A~MJAHR = B~MJAHR ` TO tab.
APPEND ` INNER JOIN MAKT AS C on B~MATNR = C~MATNR ` TO tab.
APPEND ` where B~BWART = P_MVT ` TO tab.
APPEND ` AND B~LGORT like P_SLOC ` to TAB.
APPEND ` AND B~SHKZG = 'H'` to TAB.
APPEND ` and ( A~BUDAT >= p_date1 and a~budat <= p_date2 ) ` TO tab.
APPEND ` AND B~MATNR LIKE P_MATNR ORDER BY B~MATNR A~BUDAT B~BWART.` to TAB.
APPEND ` ELSE.` to TAB.
APPEND ` SELECT B~MATNR A~BUDAT B~BWART B~MENGE B~MEINS B~SHKZG B~LGORT B~KOSTL B~DMBTR C~MAKTX` TO tab.
APPEND ` INTO CORRESPONDING FIELDS OF TABLE IT_TREND1 FROM MKPF AS A INNER JOIN MSEG AS B ` TO tab.
APPEND ` ON A~MBLNR = B~MBLNR ` TO tab.
APPEND ` AND A~MJAHR = B~MJAHR ` TO tab.
APPEND ` INNER JOIN MAKT AS C on B~MATNR = C~MATNR ` TO tab.
APPEND ` WHERE ( A~BUDAT >= P_DATE1 AND A~BUDAT <= P_DATE2 )` to TAB.
APPEND ` AND B~BWART = P_MVT` to TAB.
APPEND ` AND B~SHKZG = 'S'` to TAB.
APPEND ` AND B~LGORT like P_SLOC ` to TAB.
APPEND ` AND B~MATNR like P_MATNR ORDER BY B~MATNR A~BUDAT B~BWART.` to TAB.
APPEND ` ENDIF.` to TAB.
*
*
APPEND `ENDFORM.` TO tab.
*********************************************************************************************************************************
APPEND ` DATA: WQTYV TYPE P LENGTH 10 DECIMALS 3.` TO tab.
APPEND ` FORM loop_at_tab. ` TO tab.
APPEND ` LOOP AT IT_TREND1.` TO tab.
APPEND ` CONCATENATE IT_TREND1-BUDAT0(4) IT_TREND1-BUDAT4(2) '01' INTO WDATE. "CONVERSION OF DATES TO START DATE FOR RELEVANT MONTHS OF THE DATE.` TO tab.
APPEND ` MOVE WDATE TO IT_TREND1-BUDAT.` TO tab.
APPEND ` concatenate it_trend1-matnr it_trend1-lgort inTO IT_TREND1-LG_MAT.` TO tab.
APPEND ` concatenate 'M' it_trend1-budat4(2) it_trend1-budat0(4) INTO IT_TREND1-DT_fld.` TO tab.
APPEND ` concatenate IT_TREND1-LG_MAT IT_TREND1-DT_fld INTO IT_TREND1-MATNRNEW.` TO tab.
APPEND ` IF it_trend1-shkzg = 'H' and it_trend1-bwart = '311'. ` to tab. " New Changes on 30.08.2007
APPEND ` it_trend1-menge = it_trend1-menge. ` to tab.
APPEND ` ENDIF. ` to Tab.
APPEND ` IF it_trend1-shkzg = 'S' and it_trend1-bwart = '311'. ` to tab. " New Changes on 30.08.2007
APPEND ` it_trend1-menge = - it_trend1-menge. ` to tab.
APPEND ` ENDIF. ` to Tab.
APPEND ` MODIFY IT_TREND1.` TO tab.
APPEND ` ENDLOOP.` TO tab.
*
*
*
APPEND ` SORT IT_TREND1 BY MATNR BUDAT .` TO tab.
APPEND ` DATA: WDAT TYPE DATE.` TO tab.
APPEND ` DATA: WMAT TYPE I VALUE 0.` TO tab.
APPEND ` DATA:WPRA TYPE C LENGTH 18,` TO tab.
APPEND ` H TYPE I VALUE 1,` TO tab.
APPEND ` WQTY TYPE P LENGTH 10 DECIMALS 3,` TO tab.
APPEND ` WMEINS TYPE C LENGTH 5,` TO tab.
APPEND ` MNA TYPE C LENGTH 3,` TO tab.
APPEND ` WNO1 TYPE I,` TO tab.
APPEND ` WYER1 TYPE C LENGTH 8,` TO tab.
APPEND ` WVAL TYPE P LENGTH 13 DECIMALS 2,` TO tab.
APPEND ` WMATNR TYPE C LENGTH 40.` TO tab.
*APPEND ` LOOP AT IT_TREND1 where menge > 0 .` TO tab.
**APPEND ` write:/ 'BBB----',it_trend1-matnr,it_trend1-BUDAT,it_trend1-BWART,it_trend1-MENGE,it_trend1-meins,it_trend1-SHKZG,it_trend1-LGORT,it_trend1-LG_MAT,it_trend1-DT_fld,it_trend1-MATNRNEW.` TO tab.
*APPEND ` ENDLOOP.` TO tab.
APPEND ` ENDFORM. ` TO tab.
APPEND ` FORM loop_at_tab2.` TO tab.
APPEND ` SORT IT_TREND1 by MATNRnew.` TO tab.
APPEND `data: wmatnrnew type c length 35.` TO tab.
APPEND `data: wdt_fld type c length 7.` TO tab.
APPEND `data: wlg_mat type c length 25.` TO tab.
APPEND `data: wqty type P LENGTH 10 DECIMALS 3 value 0.` TO tab.
APPEND `data: wvalue type P LENGTH 15 DECIMALS 2 value 0.` TO tab.
APPEND `data: H type i value 0.` TO tab.
APPEND `data: whelp type c length 50.` TO tab.
APPEND ` LOOP AT IT_TREND1. ` TO tab.
APPEND ` clear whelp. ` to tab.
APPEND ` Concatenate 'Material---> ' IT_TREND1-matnrnew into whelp. ` to tab.
APPEND ` CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR' ` TO tab.
APPEND ` EXPORTING ` TO tab.
APPEND ` PERCENTAGE = 41 ` TO tab.
APPEND ` TEXT = whelp. ` TO tab.
APPEND ` IF it_trend1-lg_mat <> wlg_mat.` TO TAB.
APPEND ` IF H > 0.` TO TAB.
APPEND ` LOOP AT IT_TREND2 WHERE lg_mat = Wlg_mat. ` TO TAB.
APPEND ` IT_TREND2-MENGE1 = IT_TREND2-MENGE1 + WQTY .` TO TAB.
APPEND ` IT_TREND2-DMBTR1 = IT_TREND2-DMBTR1 + WVALUE .` TO TAB.
*APPEND ` WRITE:/ 'mENGE1---',WMATNRNEW,IT_TREND2-MENGE1. ` TO TAB.
APPEND ` MODIFY IT_TREND2 . ` TO TAB.
loop at it_test1 where name5 <> space.
concatenate ` if wdt_fld = '` it_test1-name3 `'.` into wfield.
append wfield to tab.
concatenate `it_trend2-` it_test1-name3 ` = wqty .` into wfield.
append wfield to tab.
append 'modify it_trend2 .' to tab.
append 'endif.' to tab.
endloop.
APPEND ` ENDLOOP. ` TO TAB.
APPEND ` ENDIF.` TO TAB.
APPEND ` move it_trend1-MATNR to it_trend2-MATNR.` TO TAB.
APPEND ` move it_trend1-DT_FLD to it_trend2-DT_FLD.` TO TAB.
APPEND ` move it_trend1-matnrnew to it_trend2-matnrnew.` TO TAB.
APPEND ` move it_trend1-LG_MAT to it_trend2-LG_MAT.` TO TAB.
APPEND ` move it_trend1-KOSTL to it_trend2-KOSTL.` TO TAB.
APPEND ` move 0 TO it_trend2-MENGE1 .` TO TAB.
APPEND ` move 0 TO it_trend2-MENGE .` TO TAB.
APPEND ` move it_trend1-LGORT to it_trend2-LGORT.` TO TAB.
APPEND ` move it_trend1-MAKTX to it_trend2-MAKTX.` TO TAB.
APPEND ` move it_trend1-MEINS to it_trend2-MEINS.` TO TAB.
APPEND ` append it_trend2.` TO TAB.
APPEND ` wmatnrnew = it_trend1-matnrnew.` TO TAB.
APPEND ` wlg_mat = it_trend1-lg_mat.` TO TAB.
APPEND ` wdt_fld = it_trend1-dt_fld.` TO TAB.
loop at it_test1 where name5 <> space.
APPEND ` LOOP AT IT_TREND2 WHERE lg_mat = Wlg_mat. ` TO TAB.
concatenate `it_trend2-` it_test1-name3 ` = 0 .` into wfield.
append wfield to tab.
append 'modify it_trend2 .' to tab.
APPEND ` ENDLOOP. ` to tab.
endloop.
APPEND ` WQTY = 0.` TO TAB.
APPEND ` WVALUE = 0.` TO TAB.
APPEND ` endif.` TO TAB.
APPEND ` if it_trend1-lg_mat = wlg_mat.` TO TAB.
APPEND ` if it_trend1-matnrnew <> wmatnrnew.` TO TAB.
APPEND ` LOOP AT IT_TREND2 WHERE lg_mat = Wlg_mat. ` TO TAB.
APPEND ` IT_TREND2-MENGE1 = IT_TREND2-MENGE1 + WQTY .` TO TAB.
*APPEND ` IT_TREND2-DMBTR1 = IT_TREND2-DMBTR1 + WVALUE .` TO TAB.
*APPEND ` WRITE:/ 'mENGE1---',WMATNRNEW,IT_TREND2-MENGE1. ` TO TAB.
APPEND ` MODIFY IT_TREND2 . ` TO TAB.
loop at it_test1 where name5 <> space.
concatenate ` if wdt_fld = '` it_test1-name3 `'.` into wfield.
append wfield to tab.
concatenate `it_trend2-` it_test1-name3 ` = wqty .` into wfield.
append wfield to tab.
append 'modify it_trend2 .' to tab.
append ` wqty = 0. ` to tab.
append 'endif.' to tab.
endloop.
APPEND ` ENDLOOP. ` TO TAB.
APPEND ` WQTY = 0.` TO TAB.
**
APPEND ` endif.` TO TAB.
APPEND ` WQTY = WQTY + IT_TREND1-MENGE.` TO TAB.
APPEND ` WVALUE = WVALUE + IT_TREND1-DMBTR.` TO TAB.
APPEND ` wmatnrnew = it_trend1-matnrnew.` TO TAB.
APPEND ` wdt_fld = it_trend1-dt_fld.` TO TAB.
APPEND ` wlg_mat = it_trend1-lg_mat.` TO TAB.
APPEND ` IF H < 3.` TO TAB.
APPEND ` H = H + 1.` TO TAB.
APPEND ` ENDIF.` TO TAB.
APPEND ` endif.` TO TAB.
APPEND ` ENDLOOP. ` TO tab.
*********************************
APPEND ` LOOP AT IT_TREND2 WHERE lg_mat = Wlg_mat. ` TO TAB.
APPEND ` IT_TREND2-MENGE1 = IT_TREND2-MENGE1 + WQTY .` TO TAB.
APPEND ` IT_TREND2-DMBTR1 = IT_TREND2-DMBTR1 + WVALUE .` TO TAB.
*APPEND ` WRITE:/ 'mENGE1---',WMATNRNEW,IT_TREND2-MENGE1. ` TO TAB.
APPEND ` MODIFY IT_TREND2 . ` TO TAB.
loop at it_test1 where name5 <> space.
concatenate ` if wdt_fld = '` it_test1-name3 `'.` into wfield.
append wfield to tab.
concatenate `it_trend2-` it_test1-name3 ` = wqty .` into wfield.
append wfield to tab.
append 'modify it_trend2 .' to tab.
append ` wqty = 0. ` to tab.
append 'endif.' to tab.
endloop.
APPEND ` ENDLOOP. ` to tab.
APPEND ` LOOP AT IT_TREND2. ` TO tab.
*APPEND ` write:/ 'ccc----',it_trend2-matnr,it_trend2-BWART,it_trend2-MENGE,it_trend2-MENGE1,it_trend2-meins,it_trend2-SHKZG,it_trend2-LGORT,it_trend2-LG_MAT,it_trend2-DT_fld,it_trend2-MATNRNEW.` TO tab.
APPEND ` ENDLOOP. ` TO tab.
APPEND ` ENDFORM.` TO tab.
APPEND `FORM loop_at_tab3.` TO tab.
APPEND `data: wfname type c length 30.` TO tab.
APPEND `data: wfname1 type c length 30.` TO tab.
*LOOP AT it_test1 WHERE name3 <> space and name6 = 'R'.
data: h1(3) type n value 0.
LOOP AT it_test1 WHERE name6 = 'R'.
CLEAR wfield.
APPEND `it_trend2-MATNR = 'Hello'.` TO tab.
CONCATENATE `fieldcatalog-fieldname = '` it_test1-name3 `'.` INTO wfield.
APPEND wfield TO tab.
CLEAR wfield.
CONCATENATE `fieldcatalog-seltext_m = '` it_test1-name4 `'.` INTO wfield.
APPEND wfield TO tab.
concatenate ` fieldcatalog-outputlen = ` it_test1-size `.` into wfield.
APPEND wfield TO tab.
concatenate ` fieldcatalog-col_pos = ` h1 `.` into wfield.
APPEND wfield TO tab.
if h1 < 2.
append ` fieldcatalog-emphasize = 'X'.` to tab.
append ` fieldcatalog-key = 'X'.` to tab.
endif.
APPEND ` append fieldcatalog to fieldcatalog.` TO tab.
APPEND ` clear fieldcatalog.` TO tab.
h1 = h1 + 1.
ENDLOOP.
APPEND ` CLEAR Gs_SORT. ` to tab.
APPEND ` Gs_SORT-FIELDNAME = 'MATNR'. ` to tab.
APPEND ` Gs_SORT-SPOS = 0. ` to tab.
APPEND ` Gs_SORT-UP = 'X'. ` to tab.
Gs_SORT-DOWN = 'X'. ` to tab.
APPEND ` APPEND Gs_SORT TO Gd_SORT. ` to tab.
APPEND ` Gs_SORT-FIELDNAME = 'MAKTX'. ` to tab.
APPEND ` Gs_SORT-SPOS = 1. ` to tab.
APPEND ` Gs_SORT-UP = 'X'. ` to tab.
Gs_SORT-DOWN = 'X'. ` to tab.
APPEND ` APPEND Gs_SORT TO Gd_SORT. ` to tab.
APPEND `ENDFORM.` TO tab. " BUILD_FIELDCATALOG
fieldcatalog-fieldname = 'KNAME'.
fieldcatalog-seltext_m = 'Name'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 20.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
*
*
fieldcatalog-fieldname = 'VNUMBER'.
fieldcatalog-seltext_m = 'Feature Code'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
*
*
fieldcatalog-fieldname = 'FEATURE'.
fieldcatalog-seltext_m = 'Feature Name'.
fieldcatalog-col_pos = 1.
fieldcatalog-outputlen = 35.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
*form build_layout.
APPEND `FORM loop_at_tab4.` TO tab.
APPEND ` gd_layout-no_input = 'X'.` TO tab.
APPEND ` gd_layout-colwidth_optimize = 'X'.` TO tab.
APPEND ` gd_layout-totals_text = 'Totals'.` TO tab.
APPEND ` gd_layout-totals_only = 'X'.` TO tab.
*gd_layout- f2code = 'DISP'. "Sets fcode for when double
"click(press f2)
APPEND ` gd_layout-zebra = 'X'.` TO tab.
APPEND ` gd_layout-group_change_edit = 'X'.` TO tab.
APPEND ` gd_layout-header_text = 'helllllo'.` TO tab.
APPEND `ENDFORM.` TO tab. " BUILD_LAYOUT
*
APPEND `FORM loop_at_tab5.` TO tab.
APPEND ` gd_repid = sy-repid.` TO tab.
APPEND ` call function 'REUSE_ALV_GRID_DISPLAY'` TO tab.
APPEND ` exporting` TO tab.
APPEND ` i_callback_program = gd_repid` TO tab.
APPEND ` I_BACKGROUND_ID = 'ALV_BACKGROUND'` TO tab.
APPEND ` i_callback_top_of_page = 'TOP-OF-PAGE'` TO tab.
*APPEND ` i_callback_top_of_page = 'LOOP_AT_TAB7'` TO tab.
*APPEND ` i_callback_user_command = 'USER_COMMAND'` TO tab.
APPEND ` is_layout = gd_layout` TO tab.
APPEND ` it_fieldcat = fieldcatalog[] ` TO tab.
APPEND ` IT_SORT = Gd_SORT[] ` TO tab.
*APPEND ` it_events = gt_events ` TO tab.
*APPEND ` is_print = gd_prntparams ` TO tab.
APPEND ` tables` TO tab.
APPEND ` t_outtab = it_trend2` TO tab.
APPEND ` exceptions` TO tab.
APPEND ` program_error = 1` TO tab.
APPEND ` others = 2.` TO tab.
APPEND ` if sy-subrc <> 0.` TO tab.
APPEND ` MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO` TO tab.
APPEND ` WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.` TO tab.
APPEND ` endif.` TO tab.
APPEND `ENDFORM. ` TO tab. " DISPLAY_ALV_REPORT
*
*----
Form TOP-OF-PAGE *
*----
ALV Report Header *
*----
APPEND `FORM top-of-page.` TO tab.
APPEND ` data: t_header type slis_t_listheader, ` TO TAB.
APPEND ` wa_header type slis_listheader, ` TO TAB.
APPEND ` t_line like wa_header-info, ` TO TAB.
APPEND ` ld_lines type i, ` TO TAB.
APPEND ` ld_linesc(10) type c. ` TO TAB.
Title
APPEND ` wa_header-typ = 'H'. ` TO TAB.
APPEND ` wa_header-info = 'Materil Consumption Trend Report '. ` TO TAB.
APPEND ` append wa_header to t_header. ` TO TAB.
APPEND ` clear wa_header. ` TO TAB.
*
Date
APPEND ` wa_header-typ = 'S'. ` TO TAB.
APPEND ` wa_header-key = 'Date: '. ` TO TAB.
APPEND ` CONCATENATE sy-datum+6(2) '.' ` TO TAB.
APPEND ` sy-datum+4(2) '.' ` TO TAB.
APPEND ` sy-datum(4) ' - User : ' sy-uname ` TO TAB.
APPEND ` INTO wa_header-info. ` TO TAB.
APPEND ` append wa_header to t_header. ` TO TAB.
APPEND ` clear: wa_header. ` TO TAB.
*
Movement Type
APPEND ` wa_header-typ = 'S1'. ` TO TAB.
APPEND ` wa_header-key = 'Movement Type: '. ` TO TAB.
APPEND ` MOVE p_mvt TO wa_header-info. ` TO TAB.
APPEND ` append wa_header to t_header. ` TO TAB.
APPEND ` clear: wa_header. ` TO TAB.
Storage Location Type
APPEND ` IF p_mvt <> '261'. ` to tab.
APPEND ` wa_header-typ = 'S2'. ` TO TAB.
APPEND ` wa_header-key = 'Storage loc : '. ` TO TAB.
APPEND ` MOVE p_sloc TO wa_header-info. ` TO TAB.
APPEND ` append wa_header to t_header. ` TO TAB.
APPEND ` clear: wa_header. ` TO TAB.
APPEND ` ENDIF. ` to tab.
Material Location Type
APPEND ` wa_header-typ = 'S3'. ` TO TAB.
APPEND ` wa_header-key = 'Material : '. ` TO TAB.
APPEND ` MOVE p_matnr TO wa_header-info. ` TO TAB.
APPEND ` append wa_header to t_header. ` TO TAB.
APPEND ` clear: wa_header. ` TO TAB.
Material Location Type
APPEND ` wa_header-typ = 'S4'. ` TO TAB.
APPEND ` wa_header-key = 'Date from : '. ` TO TAB.
APPEND ` Concatenate p_date16(2) '.' p_date14(2) '.' p_date10(4) ' ..To.. ' p_date26(2) '.' p_date24(2) '.' p_date20(4) INTO wa_header-info. ` TO TAB.
APPEND ` append wa_header to t_header. ` TO TAB.
APPEND ` clear: wa_header. ` TO TAB.
Date
wa_header-typ = 'S2'.
wa_header-key = 'Date: '.
CONCATENATE sy-datum+6(2) '.'
sy-datum+4(2) '.'
sy-datum(4) ' - User : ' sy-uname
INTO wa_header-info.
append wa_header to t_header.
clear: wa_header.
**
*
*
**sy-uname
Total No. of Records Selected
describe table it_feat1 lines ld_lines.
ld_linesc = ld_lines.
concatenate 'Customer : ' p_custom3(10) '-' p_custom13(10)
into t_line separated by space.
*
wa_header-typ = 'A'.
wa_header-info = t_line.
append wa_header to t_header.
clear: wa_header, t_line.
*
APPEND ` call function 'REUSE_ALV_COMMENTARY_WRITE' ` to tab.
APPEND ` exporting ` to tab.
APPEND ` it_list_commentary = t_header. ` to tab.
i_logo = 'Z_LOGO'.
APPEND ` ENDFORM.` to tab.
*
*
*
**&----
**& Form BUILD_EVENTS
**&----
Build events table
**----
*
**
*form build_events.
data: ls_event type slis_alv_event.
*
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = gt_events[].
read table gt_events with key name = slis_ev_end_of_page
into ls_event.
if sy-subrc = 0.
move 'END_OF_PAGE' to ls_event-form.
append ls_event to gt_events.
endif.
*
read table gt_events with key name = slis_ev_end_of_list
into ls_event.
if sy-subrc = 0.
move 'END_OF_LIST' to ls_event-form.
append ls_event to gt_events.
endif.
*endform. " BUILD_EVENTS
*
*
**&----
*
**
**& Form BUILD_PRINT_PARAMS
**&----
*
**
Setup print parameters
**----
*
**
*form build_print_params.
gd_prntparams-reserve_lines = '3'. "Lines reserved for footer
gd_prntparams-no_coverpage = 'X'.
*
*endform. " BUILD_PRINT_PARAMS
*
*
**&----
*
**
**& Form END_OF_PAGE
**&----
*
**
*form END_OF_PAGE.
write:/40 'Page:', sy-pagno .
*
*endform.
*
*
**&----
*
**
**& Form END_OF_LIST
**&----
*
**
*form END_OF_LIST.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
*
skip.
write:/40 'Page:', sy-pagno .
*endform.
*
*****************************************************************************************************************
GENERATE SUBROUTINE POOL tab NAME prog
MESSAGE mess
SHORTDUMP-ID sid.
IF sy-subrc = 0.
WRITE:/ 'data----'.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
PERCENTAGE = 20
TEXT = 'Step -20 '.
PERFORM ('LOOP_AT_TAB1') IN PROGRAM (prog) IF FOUND.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
PERCENTAGE = 30
TEXT = 'Step -30 '.
PERFORM ('LOOP_AT_TAB') IN PROGRAM (prog) IF FOUND.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
PERCENTAGE = 40
TEXT = 'Step -40 '.
PERFORM ('TOP-OF-PAGE') IN PROGRAM (prog) IF FOUND.
PERFORM ('LOOP_AT_TAB2') IN PROGRAM (prog) IF FOUND.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
PERCENTAGE = 50
TEXT = 'Step -50 '.
PERFORM ('LOOP_AT_TAB3') IN PROGRAM (prog) IF FOUND.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
PERCENTAGE = 60
TEXT = 'Step -60 '.
PERFORM ('LOOP_AT_TAB4') IN PROGRAM (prog) IF FOUND.
PERFORM ('build_events') IN PROGRAM (prog) IF FOUND.
PERFORM ('build_print_params') IN PROGRAM (prog) IF FOUND.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
PERCENTAGE = 90
TEXT = 'Step -90 '.
PERFORM ('LOOP_AT_TAB5') IN PROGRAM (prog) IF FOUND.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
PERCENTAGE = 100
TEXT = 'Step -100 '.
ELSEIF sy-subrc = 4.
MESSAGE mess TYPE 'I'.
ELSEIF sy-subrc = 8.
MESSAGE sid TYPE 'I'.
ENDIF.
*
*