Internal tables & select query for clasical report

hello all,
       i am a novice in ABAP.i need to retrive data from 4 DB tables to do a classical report. i declared internal tables as below and then retrieved the data as per the below select statements. is there any other way in which i can do the same with a comparitively lesser amt of code.
data: begin of i_vbak occurs 0,
      vbeln like vbak-vbeln,
      kunnr like vbak-kunnr,
      waerk like vbak-waerk,
      end of i_vbak.
data: begin of i_vbap occurs 0,
      vbeln like vbap-vbeln,
      kwmeng like vbap-kwmeng,
      posnr like vbap-posnr,
      vrkme like vbap-vrkme,
      netpr like vbap-netpr,
      end of i_vbap.
data: begin of i_lips occurs 0,
      vbeln like lips-vbeln,
      vgpos like lips-vgpos,
      vrkme like lips-vrkme,
      lfimg like lips-lfimg,
      end of i_lips.
data: begin of i_vbep occurs 0,
      vbeln like vbep-vbeln,
      posnr like vbep-posnr,
      edatu like vbep-edatu,
      end of i_vbep.
data: begin of i_out occurs 0,
      kunnr like vbak-kunnr,
      vbeln like vbak-vbeln,
      kwmeng like vbap-kwmeng,
      netpr like vbap-netpr,
      waerk like vbak-waerk,
      vrkme like vbap-vrkme,
      lfimg like lips-lfimg,
      posnr like vbep-posnr,
      edatu like vbep-edatu,
      end of i_out.
      RETRIVING THE DATA INTO INTERNAL TABLE                         *
select vbeln kunnr waerk from vbak into table i_vbak where kunnr in
s_kunnr and vbeln in s_vbeln.
select vbeln kwmeng posnr vrkme netpr from vbap into table i_vbap for
all entries in i_vbak where vbeln = i_vbak-vbeln.
select vbeln vgpos vrkme lfimg from lips into table i_lips for all
entries in i_vbak where vbeln = i_vbak-vbeln and vgpos in s_vgpos.
select vbeln posnr edatu from vbep into table i_vbep for all entries in
i_vbak where vbeln = i_vbak-vbeln.
<b>Points are guaranteed for good answers.</b>
Thanks in advance
seenu

Hi,
If u will use in ALV means  how many tables u want u can put it. After that u can maintain one internal table that's enough. Afterthat  put select queries after that display the internal table fileds.
If u will ALV  report means u have to code same coding for every report slight changes only there.
Herewith i am sending sample ALV REPORT it is useful for u.
REPORT CODING:
REPORT  YMS_COLOURALV NO STANDARD PAGE HEADING.
TYPE-POOLS: SLIS, ICON.
DATA: FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA: BEGIN OF IMARA OCCURS 0,
          LIGHT(4) TYPE C,
          MATNR TYPE MARA-MATNR,
          MTART TYPE MARA-MTART,
          MAKTX TYPE MAKT-MAKTX,
          COLOR_LINE(4) TYPE C,
          TCOLOR TYPE SLIS_T_SPECIALCOL_ALV,  "cell
      END OF IMARA.
DATA: XCOLOR TYPE SLIS_SPECIALCOL_ALV.
START-OF-SELECTION.
  PERFORM GET_DATA.
  PERFORM WRITE_REPORT.
Get_Data
FORM GET_DATA.
  WRITE ICON_GREEN_LIGHT AS ICON TO IMARA-LIGHT.
      IMARA-MATNR = 'ABC'.
      IMARA-MTART = 'ZCFG'.
      IMARA-MAKTX = 'This is description for ABC'.
  APPEND IMARA.
  WRITE ICON_YELLOW_LIGHT AS ICON TO IMARA-LIGHT.
      IMARA-MATNR = 'DEF'.
      IMARA-MTART = 'ZCFG'.
      IMARA-MAKTX = 'This is description for DEF'.
  APPEND IMARA.
  WRITE ICON_RED_LIGHT AS ICON TO IMARA-LIGHT.
      IMARA-MATNR = 'GHI'.
      IMARA-MTART = 'ZCFG'.
      IMARA-MAKTX = 'This is description for GHI'.
  APPEND IMARA.
  LOOP AT IMARA.
    IF SY-TABIX = 1.
      IMARA-COLOR_LINE = 'C410'.     " color line
    ENDIF.
    IF SY-TABIX = 2.                "  color CELL
      CLEAR XCOLOR.
      XCOLOR-FIELDNAME = 'MTART'.
      XCOLOR-COLOR-COL = '3'.
      XCOLOR-COLOR-INT = '1'.       " Intensified on/off
      XCOLOR-COLOR-INV = '0'.
      APPEND XCOLOR TO IMARA-TCOLOR.
    ENDIF.
    MODIFY IMARA.
  ENDLOOP.
ENDFORM.                    "get_data
WRITE_REPORT
FORM WRITE_REPORT.
  DATA: LAYOUT TYPE  SLIS_LAYOUT_ALV.
  LAYOUT-COLTAB_FIELDNAME = 'TCOLOR'.
  LAYOUT-INFO_FIELDNAME = 'COLOR_LINE'.
  PERFORM BUILD_FIELD_CATALOG.
CALL ABAP LIST VIEWER (ALV)
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      IS_LAYOUT   = LAYOUT
      IT_FIELDCAT = FIELDCAT
    TABLES
      T_OUTTAB    = IMARA.
ENDFORM.                    "write_report
BUILD_FIELD_CATALOG
FORM BUILD_FIELD_CATALOG.
  DATA: FC_TMP TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE.
  CLEAR: FIELDCAT. REFRESH: FIELDCAT.
  CLEAR: FC_TMP.
  FC_TMP-REPTEXT_DDIC    = 'Status'.
  FC_TMP-FIELDNAME  = 'LIGHT'.
  FC_TMP-TABNAME   = 'IMARA'.
  FC_TMP-OUTPUTLEN  = '4'.
  FC_TMP-ICON       = 'X'.
  APPEND FC_TMP TO FIELDCAT.
  CLEAR: FC_TMP.
  FC_TMP-REPTEXT_DDIC    = 'Material Number'.
  FC_TMP-FIELDNAME  = 'MATNR'.
  FC_TMP-TABNAME   = 'IMARA'.
  FC_TMP-OUTPUTLEN  = '18'.
  APPEND FC_TMP TO FIELDCAT.
  CLEAR: FC_TMP.
  FC_TMP-REPTEXT_DDIC    = 'Material Type'.
  FC_TMP-FIELDNAME  = 'MTART'.
  FC_TMP-TABNAME   = 'IMARA'.
  FC_TMP-OUTPUTLEN  = '10'.
  APPEND FC_TMP TO FIELDCAT.
  CLEAR: FC_TMP.
  FC_TMP-REPTEXT_DDIC    = 'Material'.
  FC_TMP-FIELDNAME  = 'MAKTX'.
  FC_TMP-TABNAME   = 'IMARA'.
  FC_TMP-OUTPUTLEN  = '40'.
  FC_TMP-EMPHASIZE = 'C610'.   " color column
  APPEND FC_TMP TO FIELDCAT.
ENDFORM.                    "build_field_catalog
Thanks,
Shankar

Similar Messages

  • Internal table select query

    Hi Experts,
    I have one internal table with some values like
    PLNNR           PLNAL                ZAEHL
    5000021            01                      01
    5000021            01                      02
    5000021            01                      03
    5000021            01                      04
    5000021            01                      05
    I want to fetch greatest value from ZAEHL column.
    Can any one pls help me.
    Thanks,
    Madhu.

    Hi Gordan,
    I am getting error like " itab is not defined in the ABAP Dictionary as a table , projection view or database view."
    Can you pls guide me .
    Thanks,
    Kaladhar.

  • How to get select query for crystal report in c# code

    In C#, (Visual Studio 2008 ) I need to use the native Crystal Reports objects to get the complete SQL statement as it appears when you view it in Crystal Reports.
    In Crystal Reports 12.0, Go to "Database > Show SQL Query..." ... That is what I need to get via C# code. I can get bits and pieces of parameter info etc but I just want the whole SQL statement.
    How to get this?

    Hi Ganesh,
    It's simple to use RAS, include the assemblies and use this to open your report document:
    using CrystalDecisions.CrystalReports.Engine;
    using CrystalDecisions.Shared;
    using CrystalDecisions.ReportAppServer.ClientDoc;
    using CrystalDecisions.ReportAppServer.Controllers;
    using CrystalDecisions.ReportAppServer.ReportDefModel;
    using CrystalDecisions.ReportAppServer.DataSetConversion;
    using CrystalDecisions.ReportAppServer.DataDefModel;
            CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            ISCDReportClientDocument rptClientDoc;
    To open the report use:
         object rptName = openFileDialog.FileName;
                    rpt.Load(rptName.ToString());
                    rptClientDoc = rpt.ReportClientDocument;
    Then to get the SQL set the log on info:
                rptClientDoc.DatabaseController.LogonEx("10.50.212.77,1433", "xtreme", "sa", "password");
                GroupPath gp = new GroupPath();
                string tmp = String.Empty;
                rptClientDoc.RowsetController.GetSQLStatement(gp, out tmp);
                MessageBox.Show(tmp, "Data Source Set and SQL Statement", MessageBoxButtons.OK, MessageBoxIcon.Information);
    Thank you
    Don

  • Select query in a report

    Hi!
    Is it possible to modify a select query for a report in the following way:
    I have created two fields where users input values and operators.
    Operators selection is a static list consisting of: =, like , in
    Value field is a text field.
    The current query is:
    SELECT
    A,
    B,
    C
    from TABLE
    I would like to add:
    WHERE
    A : P1_OPERATOR : P1_VALUE
    but it doesn't work; I get a notification that the operator is incorrect.
    It has a defaulft value = and when I set let's say 5 in the value field the whole query should be:
    SELECT
    A,
    B,
    C
    from TABLE
    WHERE
    A = 5
    Regards!

    Hmm, I get the following error:
    Updatable report parse error:
    ORA-20001: Query must begin with SELECT or WITH
    The only difference I see is that your type is SQL Query (PL/SQL function body returning SQL query) while I have SQL Query (updateable report) hardcoded.
    I have APEX 4.2.2, I'm not quite sure how to change this...
    This is my code:
    begin
    :P7_QUERY := 'select ROWID,BNK_ID,MSR_PRD_ID,SRC_STM_ID,ID,ID_RETKA,RSP,OZNAKA_RETKA,DATUM_STANJA,OZNAKA_IZVJESCA,OZNAKA_KOMITENTA,MBR_KOMITENTA,KOMITENT_NEREZ,ZUPANIJA,DRZAVA,SEKTOR_NEREZIDENTA,VRSTA_POVEZANOSTI,INSTRUMENT,ISIN,VALUTA,OTKAZNI_ROK,IZVORNO_DOSPIJECE,VRSTA_INDEKSACIJE,VALUTA_INDEKSACIJE,PORTFELJ,UTRZIVOST_KREDITA,ZNACAJKE_KAPITALA,RIZICNA_SKUPINA,UGRADJENI_DERIVAT,ODNOSNA_VARIJABLA,PREDZNAK,IZNOS,IZNOS_ACTUAL,VRSTA_IZNOSA,KOMITENT_PBR,UDJELI_POVEZ_C,AR_ID,AU_ID,ACT_AR_BAL_KN,ACT_AR_BAL,AR_BUSS_ID,MTI_CCY_TP_ID,REG_NO,REG_SFX,JMBG_ID_NO,IP_ID,NO_DYS_OO,TAX_ID_NO,INSTRUMENT_OLD,PREDZNAK_OLD,IZNOS_ACTUAL_OLD,ACT_AR_BAL_KN_OLD,ACT_AR_BAL_OLD,NAPOMENA,NOVI_POSAO_F,LISTA_SUMARNA,LISTA_REKAP,POSTOTAK1,POSTOTAK2,POSTOTAK3,DZS_IDY_CL_ID,HNB_IP_CL_ID,EXG_RT_CRD_RSK_F from DWP.IZV_SLOG_DET
    where ' || :P7_X_FC1 || :P7_X_O1 || :P7_X_O1;
    return :P7_QUERY;
    end;
    I have also set Use Generic Column Names (parse query at runtime only) nad P7_QUERY as page item to submit.
    Regards,
    Ivan

  • Select query for picking data in a dynamic internal table

    Dear All,
    Please help.
    <u>The code is :</u>
    p_table1 = itab_final-tabname1.
            p_field1 = itab_final-fieldname1.         
            SELECT (p_field1) FROM (p_table1) INTO CORRESPONDING FIELDS OF TABLE <dyntable1>.      
    It is working fine when the domain is of CHAR
    The piece of code is not working where domain is DATS, CURR, DEC, etc.
    What shall I do so that it works for other domains also. Please its urgent......
    <u>ERROR that came:</u>
    An exception occurred. This exception will be dealt with in more detail
    below. The exception, assigned to the class 'CX_SY_OPEN_SQL_DB', was not
    caught, which                                                         
    led to a runtime error. The reason for this exception is:             
    The data read during a SELECT access could not be inserted into the    
    target field.                                                          
    Either conversion is not supported for the target field's type or the  
    target field is too short to accept the value or the data are not in a 
    form that the target field can accept

    Check below code
    REPORT zpwtest .
    *** Tables
    DATA: lt_data TYPE REF TO data.
    DATA: lt_fieldcatalog TYPE lvc_t_fcat.
    data : p_field type string ,
           p_table type string .
    *** Structure
    DATA: ls_fieldcatalog TYPE lvc_s_fcat.
    *** Data References
    DATA: new_line TYPE REF TO data.
    *** Field Symbols
    FIELD-SYMBOLS: <fs_data> TYPE REF TO data,
                   <fs_1> TYPE ANY TABLE,
                   <fs_2>,
                   <fs_3>.
    ls_fieldcatalog-fieldname = 'MANDT'.
    APPEND ls_fieldcatalog TO lt_fieldcatalog.
    ls_fieldcatalog-fieldname = 'CARRID'. "Fieldname
    ls_fieldcatalog-inttype = 'C'. "Internal Type C-> Character
    APPEND ls_fieldcatalog TO lt_fieldcatalog.
    ls_fieldcatalog-fieldname = 'CONNID'.
    ls_fieldcatalog-inttype = 'N'.
    APPEND ls_fieldcatalog TO lt_fieldcatalog.
    ls_fieldcatalog-fieldname = 'FLDATE'.
    ls_fieldcatalog-inttype = 'D'.
    APPEND ls_fieldcatalog TO lt_fieldcatalog.
    ls_fieldcatalog-fieldname = 'PRICE'.
    ls_fieldcatalog-inttype = 'P'.
    APPEND ls_fieldcatalog TO lt_fieldcatalog.
    ls_fieldcatalog-fieldname = 'CURRENCY'.
    ls_fieldcatalog-inttype = 'C'.
    APPEND ls_fieldcatalog TO lt_fieldcatalog.
    ASSIGN lt_data TO <fs_data>.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
         EXPORTING
           it_fieldcatalog = lt_fieldcatalog
         IMPORTING
           ep_table = <fs_data>
         EXCEPTIONS
           generate_subpool_dir_full = 1
           OTHERS = 2
    IF sy-subrc <> 0.
    ENDIF.
    *** So <FS_1> now points to our dynamic internal table.
    ASSIGN <fs_data>->* TO <fs_1>.
    *** Next step is to create a work area for our dynamic internal table.
    CREATE DATA new_line LIKE LINE OF <fs_1>.
    *** A field-symbol to access that work area
    ASSIGN new_line->*  TO <fs_2>.
    <b>
    p_field = 'mandt carrid connid fldate price currency' .
    p_table = 'sflight' .
    *** And to put the data in the internal table
    SELECT (p_field)
      FROM (p_table)
      INTO CORRESPONDING FIELDS OF TABLE <fs_1>.
    </b>
    *** Access contents of internal table
    LOOP AT <fs_1> ASSIGNING <fs_2>.
      ASSIGN COMPONENT 5 OF STRUCTURE <fs_2> TO <fs_3>.
      WRITE: / <fs_3>.
    ENDLOOP.

  • Select query for fetching from 3 tables.

    Can we have a single Select query for fetching same fields (kappl,kschl,vkorg,vtweg,spart,kunwe,datbi,knuma,datab,knumh)
    from 3 tables >> KOTE707,KOTE708 and KOTE709 into an internal table for a particular KUNNR?
    Regards,
    Shashank.

    Hi,
    If you have kunnr field in all the 3 tables then it is possible. use inner join as below
    PARAMETERS: p_cityfr TYPE spfli-cityfrom,
                p_cityto TYPE spfli-cityto.
    DATA: BEGIN OF wa,
             fldate TYPE sflight-fldate,
             carrname TYPE scarr-carrname,
             connid   TYPE spfli-connid,
           END OF wa.
    DATA itab LIKE SORTED TABLE OF wa
                   WITH UNIQUE KEY fldate carrname connid.
    SELECT c~carrname p~connid f~fldate
           INTO CORRESPONDING FIELDS OF TABLE itab
           FROM ( ( scarr AS c
             INNER JOIN spfli AS p ON p~carrid   = c~carrid
                                  AND p~cityfrom = p_cityfr
                                  AND p~cityto   = p_cityto )
             INNER JOIN sflight AS f ON f~carrid = p~carrid
                                    AND f~connid = p~connid ).
    LOOP AT itab INTO wa.
      WRITE: / wa-fldate, wa-carrname, wa-connid.
    ENDLOOP.
    <b>Reward Points if this helps,</b>
    Satish

  • Can any one send select query for this?

    Hi,
    can any one plese send select query for the following query.please send as early as possible.
    Loop through the I_BSID internal table to fill records in I_OUTPUT.Combine data from I_BSID, I_KNKK, I_KNKK_KNKLI, I_KNA1 and I_KNVV into I_OUTPUT based on the linking conditions .Field Description Source are
    I_OUTPUT-BUKRS     Company code     I_BSID-BUKRS
    I_OUTPUT-KUNNR     Customer number     I_BSID-KUNNR
    I_OUTPUT-NAME1     Customer Name     I_KNA1-NAME1
    I_OUTPUT-KNKLI     Credit account     I_KNKK-KNKLI
    I_OUTPUT-KDGRP     Customer Group     I_KNKK-KDGRP
    I_OUTPUT-KLIMK     Credit Limit     I_KNKK_KNKLI-KLIMK
    I_OUTPUT-KVGR1     Business Unit     I_KNVV-KVGR1
    I_OUTPUT-REBZG     Invoice Number     I_BSID-REBZG
    I_OUTPUT-BLDAT     Invoice Date     I_BSID-BLDAT
    I_OUTPUT-WAERS     Document Currency     I_BSID-WAERS
    I_OUTPUT-DUE_DATE     Due Date     Based on below
    Calculation
      Get the Payment terms days combining I_BSID and I_T052 based on the linking conditions mentioned above.    Note : a) Baseline Date : If baseline date I_BSID-ZFBDT is blank , use the Document Date.b) Payment Term Days :If I_BSID-ZBD3T is not blank, take this as Payment Term Days for Due date calculation.
                       If I_BSID-ZBD3T is Blank, then get payment term days from I_T052 based on I_BSID-ZTERM. If there are more than one record in I_T052 for the given Payment term, get the day part from baseline date and select the first record where the day limit I_T052-ZTAGG is greater than the day part.If I_BSID-ZBD3T is blank and I_BSID-ZTERM is also blank, then take Y000 (Due Immediately) as Payment term and proceed with the above logic. Set the payment term field blank while printing.
    Calculate Due date : For Debits, Determine Due Date = Baseline Date + Payment term Days(not discount days)                                                          For  Credits  Due date = Baseline date.Then, move the amount I_BSID-DMBTR to respective buckets (Not yet Due, Current Due, Past due 1-30, Past Due 31-60 etc.)  Based on the due date.
    Thanks&Regards,
    praveen kumar.A

    HI,
    To get Open Items you can use Function module:
    data:i_items TYPE STANDARD TABLE OF rfpos.
    CALL FUNCTION 'CUSTOMER_OPEN_ITEMS'
    EXPORTING
    bukrs = p_bukrs
    kunnr = wa_customer-kunnr
    TABLES
    t_postab = i_items
    EXCEPTIONS
    no_open_items = 1
    OTHERS = 2.
    Table I_items will have all the open items for that Customer in the given company code.
    Well for Clear Items: Try
    GET_CLEARED_ITEMS or FMITPOFM_CLEARED_ITEMS_GET.
    Hope it helps.
    Manish

  • Crosstab query for a report

    I've created the below crosstab query for a report.
    Select Grouping_Condition,Warehouse,Max(Value) Over (Partition By Grouping_Condition,Warehouse) As Total,
    Sum(Value) Over (Partition By Warehouse) As Total_Containers_Per_Warehouse,
    Sum(Vat1Ue) Over () As Total_Containers,
    (Max(Vat1Ue) Over (Partition By Grouping_Condition,Warehouse))
    /(Sum(Vat1Ue) Over (Partition By Warehouse))*100 As Total_Pct
    From
    Seleect Grouping_Condition,Warehouse,Count(*) As Value
    From
    Set1Ect
    T1.Warehouse,Shipped_Weight As Shipped_Tons,T1.Max_Weight As Maxtonnes,
    Case When (Shipped_Weight)< (T1.Max_Weight*0.001)*0.95 Then 'containers_under_95'
    When (Shipped_Weight*0.001) Between (T1.Max_Weight*0.001)*0.95 And (T1.Max_Weight*0.001) Then 'containers_95_100'
    Et1Se 'containers_above_weight'
    End Grouping_Condition
    From
    Tabt1E1 T1
    ,Tabt1E2 T2
    ,Tabt1E3 C
    Where
    T1.Co11 = T2.Col1
    And T1.Col2=C.Col2
    And More Conditions
    Where Warehouse In ('W1','W2','W3','W4','W5')
    Group By (Grouping_Condition,Warehouse)
    The Above Query Gives Me Output Something Like Below:
    Grouping_Condition Warehouse Total Total_Containers_Per_Warehouse Total_Containers Total_Pct
    Containers_95_100 W1 5 10 60 50
    Containers_Under_95 W1 5 10 60 50
    Containers_95_100 W2 10 20 60 50
    I've Got Report In The Below Format
    W1 W2 W3 W4 W5 Total
    Total_Containers 10 20 60
    Containers_95_100 5 10 15
    Containes_95_100_% 50 50 ????
    I Need To Calculate The Total Percentage In The Above Table With ????
    Any Help Is Much Appreciated..

    It appears as though you already have your groupings and counts per grouping, but require a ratio of each groupings count against all other counts. Is that correct ?
    If so, try the new 11g analytic function, something like this:
    select Grouping_Condition
          ,Warehouse
          ,ratio_to_report(Value) over () as Count_Ratio_over_Report
    ..

  • Need a query for monthly Report

    Hello All,
    I need a query for monthly report,
    comp_code
    emp_id
    dept_id
    work_day
    100
    A100
    MECH
    01/01/2013
    100
    A100
    MECH
    02/01/2013
    100
    A100
    MECH
    03/01/2013
    100
    A100
    MECH
    04/01/2013
    100
    A100
    MECH
    05/02/2013
    100
    A100
    MECH
    08/02/2013
    100
    A100
    MECH
    09/02/2013
    100
    A100
    MECH
    10/02/2013
    100
    A100
    MECH
    12/05/2013
    100
    A100
    MECH
    13/05/2013
    100
    A101
    CIV
    01/04/2013
    100
    A101
    CIV
    02/04/2013
    100
    A101
    CIV
    03/04/2013
    100
    A101
    CIV
    04/04/2013
    100
    A101
    CIV
    06/04/2013
    100
    A101
    CIV
    06/06/2013
    100
    A101
    CIV
    07/06/2013
    100
    A101
    CIV
    08/06/2013
    100
    A101
    CIV
    09/06/2013
    100
    A101
    CIV
    10/06/2013
    100
    A101
    CIV
    11/12/2013
    100
    A101
    CIV
    12/12/2013
    100
    A101
    CIV
    13/12/2013
    100
    A101
    CIV
    14/12/2013
        Dear friends this the sample table of my report.In which table has contain list of  employees with their working days(actual table has contain almost 5laks of records).
    suppose user choose the date between 01/01/2013 and 31/12/2013 then the result should be like this.
    comp_code
    emp_id
    dept_id
    month
    Total_work
    100
    A100
    MECH
    JANUARY
    4
    100
    A100
    MECH
    FEBRUARY
    2
    100
    A100
    MECH
    MARCH
    0
    100
    A100
    MECH
    APRIL
    0
    100
    A100
    MECH
    MAY
    2
    100
    A100
    MECH
    JUNE
    0
    100
    A100
    MECH
    JULY
    0
    100
    A100
    MECH
    AUGUST
    0
    100
    A100
    MECH
    SEPTEMBER
    0
    100
    A100
    MECH
    OCTOBER
    0
    100
    A100
    MECH
    NOVEMBER
    0
    100
    A100
    MECH
    DECEMBER
    0
    100
    A101
    CIV
    JANUARY
    0
    100
    A101
    CIV
    FEBRUARY
    0
    100
    A101
    CIV
    MARCH
    0
    100
    A101
    CIV
    APRIL
    5
    100
    A101
    CIV
    MAY
    0
    100
    A101
    CIV
    JUNE
    5
    100
    A101
    CIV
    JULY
    0
    100
    A101
    CIV
    AUGUST
    0
    100
    A101
    CIV
    SEPTEMBER
    0
    100
    A101
    CIV
    OCTOBER
    0
    100
    A101
    CIV
    NOVEMBER
    0
    100
    A101
    CIV
    DECEMBER
    4

    Hi,
    If you want the output to include months where no work was done (with 0 in the total_work column) then you need to outer-join a "table" that has one row per month, and make it a partitioned outer join:
    WITH  got_end_points   AS
       SELECT  TRUNC (MIN (work_day), 'MONTH')   AS first_month
       ,       TRUNC (MAX (work_day), 'MONTH')   AS last_month
       FROM    table_x
    ,   all_months   AS
       SELECT  ADD_MONTHS (first_month, LEVEL - 1)   AS a_month
       ,       ADD_MONTHS (first_month, LEVEL)       AS next_month
       FROM    got_end_points
       CONNECT BY  LEVEL <= 1 + MONTHS_BETWEEN (last_month, first_month)
    SELECT    t.comp_code
    ,         t.emp_id
    ,         t.dept_id
    ,         m.a_month
    ,         COUNT (t.work_day) AS total_work
    FROM             all_months  m
    LEFT OUTER JOIN  table_x     t  PARTITION BY (t.comp_code, t.emp_id, t.ept_id)
                                    ON   t.work_day  >= a.a_month
                                    AND  t.work_day  <  a.next_month
    GROUP BY  t.comp_code
    ,         t.emp_id
    ,         t.dept_id
    ,         m.a_month
    ORDER BY  t.comp_code
    ,         t.emp_id
    ,         t.dept_id
    ,         m.a_month
    As posted, this include every month that is actually in the table.  You can change the first sub-query if you want to enter first and last months.
    I hope this answers your question.
    If not, post  a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    Point out where the query above is giving the wrong results, and explain, using specific examples, how you get the correct results from the given data in those places.  If you changed the query at all, post your code.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • Sample query for Aging Report

    Hi! Anybody who has a sample sql query for aging report? basically this is the table structure and sample data
    bill_no B1-01 B1-02 B1-03
    bill_date 01-JAN 01-FEB 01-MAR
    previous_balance 100 600 800
    current_charges 500 200 400
    total_due 600 800 1200
    As of march 1, total due is 1200. how can i get the breakdown of 1200 as to the number of days it has been due. ex. 500 (60 days old 01-JAN to 01-MAR), 200 (30 days old), 400 (current)
    please help. thanks!
    null

    SELECT CEIL((SELECT MAX(Bill_Date) FROM Bill)- Bill_Date) Days , Previous_Balance, Current_Charges FROM Bill ORDER BY Days ASC
    Then create a matrix reprot.

  • Customizing a query for a report according to login user name

    Hi, I am new to the portal, so I have a urgent question:
    In my company we have local departments who are supposed to use
    the same report but only with their own data.
    I have a table with all users and their parameters (e.g.
    username + deptno) and might be able to create a function which
    gets the username (found that in one of the standard packages)
    and retrieves the parameter from the database via SELECT. The
    function should then return the parameter to be used where ever
    needed.
    Big question: How can I use this function in a SELECT-Statement
    for my report? I guess it must be something like
    SELECT * FROM -table or view- WHERE deptno = -schema.function-
    Right? Does the function have to be part of a package?
    Thanks in advance for any help.
    Yours
    Reinhard Piper
    Munich / Germany

    the table or view is WWSEC_person this is where the users are..
    Ruud

  • Improving a query for a report in b1

    Dear All,
    We have a query  for a report. this report display all invoices with it´s Dscription in the system just have 3 descriptions so i need the the report display the this description in column not in row and then have the sum by  description. i dont know how can i put a picture for showing the example.
    Some one knows how can i do? down the code.
    Regards
    NANCY
    SELECT distinct  T1.visorder as 'No. Linea',
                            T0.DocNum as 'No. Factura',
                            T0.DocDate as 'Fecha',
                            T0.CardName as 'Cliente',
                            T1.U_CANTIDAD as 'Tonelaje',
                            T0.U_OPERACION as 'No. Operación',
                            T0.DocCur as 'Moneda',
                            T0.GrosProfit as 'Ingreso total de factura',
                            T1.ItemCode as 'Código',
                            T1.Dscription,
                            T1.Quantity*T1.Price as 'Importe por Servicio',
                            T1.LineVat as 'IVA por servicio',
                            T0.VatSum as 'IVA por factura',
                            T2.PlngGroup as 'Cuenta SUN'
    FROM OINV T0 LEFT JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry
    inner join OCRD T2 ON T0.CardCode = T2.CardCode
    WHERE T0.Series = 49 and
                T0.DocDate BETWEEN [%0] AND [%1]

    Hi Nancy,
    I'm not sure that I understand your requirement 100% but assuming you only have 3 descriptions then the following would give you totals for your different descriptions...
    Simply replace the text ' etc in the code below with the descriptions values.
    SELECT distinct 
         T1.visorder as 'No. Linea',
            T0.DocNum as 'No. Factura',
            T0.DocDate as 'Fecha',
            T0.CardName as 'Cliente',
            T1.U_CANTIDAD as 'Tonelaje',
            T0.U_OPERACION as 'No. Operación',
            T0.DocCur as 'Moneda',
            T0.GrosProfit as 'Ingreso total de factura',
            T1.ItemCode as 'Código',
            CASE
                   WHEN T1.Dscription = '<description1>'
                   THEN T1.Quantity*T1.Price
                   ELSE 0
              END as '<description1>',
              CASE
                   WHEN T1.Dscription = '<description2>'
                   THEN T1.Quantity*T1.Price
                   ELSE 0
              END as '<description2>',
              CASE
                   WHEN T1.Dscription = '<description3>'
                   THEN T1.Quantity*T1.Price
                   ELSE 0
              END as '<description3>',
            T1.LineVat as 'IVA por servicio',
            T0.VatSum as 'IVA por factura',
            T2.PlngGroup as 'Cuenta SUN'
    FROM OINV T0 LEFT JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry
    inner join OCRD T2 ON T0.CardCode = T2.CardCode
    WHERE T0.Series = 49 and
                T0.DocDate BETWEEN [%0] AND [%1]
    Hope this helps.
    Regards,
    Sean

  • Select Query for smart form-invoice

    Hi Folks,
    I have to fetch the following fields as per the requirement for desiging a invoice smartform.I had copied lb_bill_invoice smartform into z format.
    Can anyone here please give me the select query for the same.
    fields to fetched are as follows:-
    1.vbrp-arktx,
    2.vbrp-fkimg,
    3.konv-kbetr with respect to vbrk-knumv
    4.konv-kwert.
    And also what all I have to give in format interface and global definitions of the smartform.
    please help  me in this regard.
    Points will be given.
    K.Kiran.

    Hi,
    declare the variables V_arktx(40) and v_Qty like vbrp-fkimp  and other varaibles for Kbetr, kwert, knumv on the global definitions.
    select  single arktx fkimg into (v_arktx, v_qty) from vbrp
    where vbeln = LBBIL_IT_REFPURORD-BIL_NUMBER.
    select single knumv into v_knumv from vbrk where where vbeln = LBBIL_IT_REFPURORD-BIL_NUMBER.
    this select has to fire in the item level and in the loop.
    so have to write in the correct place.
    select kbetr kwert into (v_kbetr, v_kwert) from konv
    where where knumv = v_knumv and kposn = LBBIL_IT_REFPURORD-ITM_NUMBER.
    regards,
    anji

  • How can i read local excel file into internal table in webdynpro for abap a

    Could someone tell me how How can i read local excel file into an internal table in webdynpro for abap application.
    thank u for your reply

    Deep,
    File manuplations...............................
    1. At the presentation level:
    ->GUI_UPLOAD
    ->GUI_DOWNLOAD
    ->CL_GUI_FRONTEND
    2. At the application server level:
    ->OPEN DATASET : open a file in the application server for reading or writing.
    ->READ DATASET : used to read from a file on the application server that has been opened for reading
    -> TRANSFER DATASET : writing data to a file.
    -> CLOSE DATASET : closes the file
    -> DELETE DATASET : delete file
    If file is on the local PC,use the function module GUI_UPLOAD to upload it into an internal table by passing the given parameters......
    call function 'GUI_UPLOAD'
    exporting
    filename = p_file
    filetype = 'ASC'
    has_field_separator = '#'
    tables
    data_tab = t_data
    p_file : excel file path.
    t_data : internal table
    <b>reward points if useful.</b>
    regards,
    Vinod Samuel.

  • Is it possible to change values in pagination select list for a report?

    The values showing up in my pagination select list for a report are 10,15,20,30,50,100,200,500,1000,5000.
    Is it possible to not have this list show the 1000 and 5000 values? I've tried setting various row values in the layout and pagination section of the report, but nothing changes in the select list. Is there a way to change this, or is it set up in a template somewhere that I can change?
    APEX version 3.0
    Thanks

    Figured this one out. Using the P1_ROWS item, added a static LOV with the correct values to override the one APEX was providing. The P1_ROWS item goes in the Number of Rows (Item) field in the layout and pagination section of the report.

Maybe you are looking for

  • Userform controls disappearing in Word 2013/Windows 8.1 with High-Res display - DLL error?

    I have a .dotm file with a large number of modules and userforms. Creating new documents from the template works fine on almost every computer I've tested it on (hundreds), but I've run into a setup that fails consistently. Two different Samsung ATIV

  • Can we call a report program in smartforms

    hai    I need my report progrm output should be called in smartforms. i.e my report  output is displayed in a table in smartforms pls give suggestion

  • I cannot clear a signature!

    Hello! I'm using an Oberthur token for Digital Signature and my computer crashed after I have signed a document, but before I input de password for the token. Now the signature is not valid and I cannot erase it. The only options I have for that sign

  • Where are Optimizer settings stored?

    I need to deploy PDF Optimizer settings throughout my organization, like I did with joboptions. So far I have been unsuccessful in searching for a file with the name into which I saved my optimizer settings. Where are the optimizer settings stored? 

  • Mail not coming with information broadcasting scheduling

    dear all, when i execute directly the setting for information broadcasting a mail is being sent but when i schedule the same setting in transaction SOST it is showing warning 'waiting for communication service'.how to remove that. ajay