Logical solution in data selection

Hi Experts,
I have one problem in in my code.  I have a selection sceen for input two dates and a check box in my screen. For Extractind data i m using folloing statement.
SELECTdebit credit profit loss tdate FROM Zpfaccount INTO
     (itab-debit, itab-credit, itab- profit , itab-loss,i tab-tdate) WHERE  TDATE BETWEEN FDATE AND EDATE.
FDATE and Edate my selection screen dates name.
but i need when i select checkbox and click on ok button the data should be extract on between these date as well as one more month of EDATE.
iternal table hold only between table data of FDATE and EDATE. Whenever i select checkbox the EDATE should be icremented by 1.(Ex. If EDATE  is 28.02.2009  it should be 31.03.2009)
I hope u guys r getting my point.
Regards,
Swapnika

Hi,
Try the below.
if the check box is not checked
SELECTdebit credit profit loss tdate FROM Zpfaccount INTO
(itab-debit, itab-credit, itab- profit , itab-loss,i tab-tdate) WHERE TDATE BETWEEN FDATE AND EDATE.
if checkbox = 'X'.
now fill the ranges.
like
ranges : r_dates for tdate.
r_dates-sign = 'I'.
r_dates-option = 'BT'.
r_dates-low    = fdate.
r_dates-high   = edate.
append r_dates. clear r_dates.
now find the begin and end date from your edate for the next month of edate.
keep it in next_begin_date and next_end_date.
r_dates-sign = 'I'.
r_dates-option = 'BT'.
r_dates-low    = next_begin_date.
r_dates-high   = next_end_date.
append r_dates. clear r_dates.
now use this in ur select.
SELECTdebit credit profit loss tdate FROM Zpfaccount INTO
(itab-debit, itab-credit, itab- profit , itab-loss,i tab-tdate) WHERE TDATE IN r_dates
Hope this helps.
Guru.

Similar Messages

  • How to retrieve data using logical database and custom select options

    Hi all,
    I have a selection screen which is displayed by logical database PSJ and I have two select options of my own. I need to retrieve data based on both selection screen of logical database and my own select options. How can I do it?
    Thanks in advance.

    Hai Gupta
    Check the following Document & Links
    1. A logical database is in fact
    a program only.
    2. This LDB provides two main things :
    a) a pre-defined selection screen
    which handles all user inputs and validations
    b) pre defined set of data
    based upon the user selection.
    3. So we dont have to worry about from
    which tables to fetch data.
    4. Moreover, this LDB Program,
    handles all user-authorisations
    and is efficient in all respects.
    5. tcode is SLDB
    good info about Logical Database. you can check the link.
    http://www.geekinterview.com/question_details/1506
    http://help.sap.com/saphelp_46c/helpdata/EN/35/2cd77bd7705394e10000009b387c12/frameset.htm
    Re: How to Create and Use ldb in reports?
    Re: Logical databases
    http://help.sap.com/saphelp_46c/helpdata/en/9f/db9bed35c111d1829f0000e829fbfe/frameset.htm
    Functions for displaying and changing logical databases:
    Call Transaction SE36 or
    Choose ABAP Workbench -> Development -> Programming environ. -> Logical databases
    Interaction between database program and report:
    During program processing, subroutines are performed in the database program and events are executed in the report.
    To read data from a database tables we use logical database.
    A logical database provides read-only access to a group of related tables to an ABAP/4 program.
    advantages:-
    The programmer need not worry about the primary key for each table.Because Logical database knows how the different tables relate to each other,and can issue the SELECT command with proper where clause to retrieve the data.
    i)An easy-to-use standard user interface.
    ii)check functions which check that user input is complete,correct,and plausible.
    iii)meaningful data selection.
    iv)central authorization checks for database accesses.
    v)good read access performance while retaining the hierarchical data view determined by the application logic.
    disadvantages:-
    i)If you donot specify a logical database in the program attributes,the GET events never occur.
    ii)There is no ENDGET command,so the code block associated with an event ends with the next event
    statement (such as another GET or an END-OF-SELECTION).
    1. transaction code SLDB.
    2.enter name z<ldb-name>
    3.create
    4.short text
    5.create
    6. name of root node (here Ekko)
    7. enter short text (f6)
    8.node type -> data base table.
    9.create
    10 change logical DB
    riht click on ekko and insert node
    here node name ekpo
    11.create
    12. click on selections
    13. press no Should the changed structure of Z<ldb name> be saved first.
    14.select tables which you want to join.
    15.transfer
    16 now you have to o to coding part.
    17. save
    activate.
    19.click to src code
    double click on first include and activate
    Regards
    Sreeni

  • Date selection in query : logic needed!

    Hi,
    we have one calendar day depending on which the query result is displayed!
    Now the requirement is such that when user enters one date the query has to generate the result for the multiple date ranges including the one which he has entered.
    example: if user has entered 15/9/2007 then query should not only display the result of the date 15/9/2007 but also the results of  -5 to +2 ( means 10/9,11/9,12/9,13/9 and 14/9 plus 16/9 and 17/9 )
    simlarly other ranges like -8 to + 7 and so on
    How to define this in query?
    Thanks,
    Ravi

    Hello ,
    I need to make a graph conveying the information of the deliveries by comparing the goods issue date and promised date !
    report also requires how many deliveries were on time, how many were late and how many were early!
    for this requirement, i had thought of making a date selection field which is promised date and make furthur more date ranges selections by query it self so that late deliveries and early deliveries also covered in these date ranges.
    -5 to + 2 is that one range which is on time delivery range
    if the delivery is more eally than the -5 days then it is early delivery. even in ealry delivery i want to make how early it is.
    and suppose the delivery has crossed the promised date 2 days more then it is late delivery.
    all has to be acheived by single date selection and there after the logic which takes care of all the date ranges i had explained.
    i am looking for that logic which i am not finding
    Hope this is clear now
    Thanks,
    Ravi

  • Data selection period seems no use in logical DB PCH??

    Hi experts,I have a problem when using LDB PCH.
    There are object selection period fields PCHOBEG and PCHOEND.
    there are also data selection period fields PCHBEGDA and PCHENDDA .
    I set the data selection fields PCHBEGDA & PCHENDDA values at Start-of-selection event.
    But this seems to have no effect on the data selection.
    on GET OBJEC event,all of the infotype data will be got,but not corrosponding to the data selection period.
    Is this normal?or something wrong?Thanks.

    In PCH you have two periods. One for selecting objects and one for selecting data (infotypes).
    LDB PCH works like PNP or PNPCE

  • Trouble in data selection logic

    Hi All,
    I am hitting 4 tables for selecting some data using inner join. There are three user
    input fields which if filled, has to take part in data selection. These three input fields are independent of each other.
    so while writing select query, how can i take care of all the possiblilities(none of them filled -- every one of them filled ) in the
    most efficient way..?
    Thanks
    -pranati

    Hi,
    IN the select-options you can add NO-EXTENSION NO INTERVALS..Which can be used a parameter..And you have to use IN in the select statement to filter the data..
    Check this example
    TABLES: marc.
    <b>SELECT-OPTIONS: so_matnr FOR marc-matnr NO-EXTENSION NO INTERVALS.
    SELECT-OPTIONS: so_werks FOR marc-werks NO-EXTENSION NO INTERVALS.</b>
    DATA: t_marc TYPE STANDARD TABLE OF marc.
    START-OF-SELECTION.
    Get the first 100 rows.
      SELECT mandt matnr werks UP TO 100 ROWS
             INTO TABLE t_marc
             FROM marc
    <b>         WHERE matnr IN so_matnr
             AND   werks IN so_werks</b>.
      IF sy-subrc = 0.
        WRITE: / 'RECORD COUNT - ', sy-dbcnt.
      ELSE.
        WRITE: / 'NO RECORD FOUND'.
      ENDIF.
    Thanks,
    Naren

  • Populate data into standard component alv from Zcomponent popup data selected

    HI All
    I have to call Zcomponent in standard component and need to pass value into Zcomponent (table) and from  Zcomponent select row and pass back to standard component.
    Steps
    1) Created Zcomponent with interface node
    2) Enhanced the standard component and create used components for  Zcomponent and make it available at component controllers and view controllers.
    When I click on Button in standard component I am calling this Zcomponent as popup window.
    My problem I when I select data in Zcomponent I need to populate the data in ALV of standard component.
    I thought of 2 methods to take my selected back and populate data into standard component ALV.
    1) Create event: EVENT1 and   Interface method Method1 and link to EVENT1
    So that I can raise this event in Zcomponent and populate the data into standard component ALV
    Problem: Under events interface checkbox is visible, when I select my enhancement implementation the interface checkbox not visible under events tab?.
    2) Create Interface method Method1 write logic to populate data into standard component ALV
    But here to when I select my enhancement implementation the interface checkbox not visible under?
    Can anyone please help me why interface checkbox is not visible or any better solution to populate the data back to standard component alv?
    Thanks
    Gopal

    Hi Gopal,
    You can achieve your requirement by using EVENTS as below
    Create an event SET_DATA in component controller of zcomponent and mark it as interface and also include the parameters like context_element( type ref to if_wd_context_element), etc as below
    Now, create an action for the event onLeadSelect of your zcomp Table and write the below code
                     DATA lo_ctx_element TYPE REF TO if_wd_context_element.
                   "get the selected row
                     lo_ctx_element = wdevent->get_context_element( name =
                        'NEW_ROW_ELEMENT' ).
                   "Raise the event with parameter
                   wd_comp_controller->fire_set_data_evt( context_element = lo_ctx_element ).
    Use the Zcomponent in your standard component and make available in std. view's properties
    Create an event handler SET_DATA method for your Zcomp's event as below
    Now, inside this method, you get the parameter CONTEXT_ELEMENT and get the data from this context element as below
                   context_element->get_attrribute( ) or
                   context_element->get_static_attributes( )
    You can populate the data into standard component based on the obtained value from Zcomponent.
    Hope this helps you.
    Regards,
    Rama

  • Data selection from Table

    Hi ,
    My requirement is to have Commercial Documents which are not Accounted. So that I've used the following logic.
      SELECT a~vbeln
                     a~vbtyp
                     a~fkdat
                     a~bukrs
             a~kunrg
             SUM( b~netwr )
           FROM vbrk AS a INNER JOIN vbrp AS b
           ON avbeln EQ bvbeln
           INTO ls_bill WHERE a~vbtyp EQ 'M'          AND
                              a~fkdat IN s_fkdat      AND
                              a~bukrs IN s_bukrs      AND
                              a~kunrg IN s_kunrg
                        GROUP BY a~vbeln
                                 a~vbtyp
                                 a~fkdat
                                 a~bukrs
                                 a~kunrg.
        l_awkey = ls_bill-vbeln.
        SELECT awkey FROM bkpf INTO l_awkey
                     WHERE awtyp EQ 'VBRK'  AND
                           awkey EQ l_awkey AND
                           bukrs EQ ls_bill-bukrs.
        ENDSELECT.
        IF sy-subrc NE 0.
          APPEND ls_bill TO lt_bill.
        ENDIF.
        CLEAR : ls_bill, l_awkey.
      ENDSELECT.
    Is that the above logic for getting data is correct. or  First taking all the entries from VBRK and VBRP table then selecting entries from BKPF and then if any entry of VBRK is not in BKPF then taking that.
    Regards,
    Rajiv.V
    Moderator message - Moved to the correct forum
    Edited by: Rob Burbank on Dec 10, 2009 9:36 AM

    You should have searched SDN for Performance Tuning.
    Solution :
    Please search SDN for Performance Tuning and then try to understand the use of various statements that you have used in terms of performance.

  • Logical operators in Oracle select query

    Hello all,
    Can i use logical operators in oracle select queries?
    for 1 and 0 =0 ; 1 or 0 =0
    if i have two fileds in a table COL1 have a value of 1010 and COL2 have a value of 0001.
    Is there any way to use select col1 or col2 from table? where or is a logical operator?
    Regards,

    Hi,
    NB wrote:
    Hello all,
    Can i use logical operators in oracle select queries?Sure; Oracle has the logical operators AND, NOT and OR. All the comparison operators, including >, >=, = !=, EXISTS, IN, IS NULL, LIKE and REGEXP_LIKE are really logical operators, since they return logical values. You can use them in SELECT statements, and other places, too.
    for 1 and 0 =0 ; 1 or 0 =0
    if i have two fileds in a table COL1 have a value of 1010 and COL2 have a value of 0001.It's unclear what you want. Maybe you'd be interested in the BITAND function:
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/functions014.htm#sthref1080
    BITAND is the only logical function that I know of. Many other functions, especially numberical fucntions such as MOD, have applications in logic.
    Is there any way to use select col1 or col2 from table? where or is a logical operator?Whenever you have a question, please post a little sample data (CREATE TABLE and INSERT statements), and also post the results you want from that data.
    Explain how you get those results from that data.
    Always say which version of Oracle you're using.

  • Logical database : user defined selection screen

    Hi Experts,
                 I am working with HR-ABAP. The logical databases provide a selection screen......but i want to use a selection screen of my own and not that of the LDB.
    Plz help...............

    hi do like this....
    go to attributes-->hr report catagory-->master data...here use the value _____000(5underscores and 000 )..
    you wii get that..
    regards,
    venkat

  • Cube to Cube "Error in data Selection" plz help

    Hi this is Ajay Reddy
    when am sending data from Cube to Cube am getting an error
    "Error in data Selection" plz help

    Hi,
    It needs a Note implementaion. I got similar problem in version BIW 7 and SP 11. We got the solution with on of the note . I am not able to recollect the note number.
    Any way check the notes 920971,155471 may help you or not.
    With rgds,
    Anil Kumar Sharma .P

  • Adding a field in data selection tab of Info Package

    Hello,
    how can I add a field for selection in the data selection tab of the info-package in BW 3.5.
    Thanks,
    SD

    Hi,
    You need check Selection in RSO2 in ECC then that field is available for Selectgion in InfoPackage.
    Here I'm giving 0CUST_SALES_ATTR DataSource Example for Selection Change, so see the logic and accordingly you can change your DataSource Selections.
    See the properties of that field in RSA2 in ECC and you can also make it for selection, use the following program and see it.
    In ROOSFIELD table give the datasource 0CUST_SALES_ATTR and see , select only Active version Fields.
    For the following fields you can find FIELD = X, it indecates that it is abailable for selections, so in this way you try to do it by using following program and check.
    KUNNR
    SPART
    VKORG
    VTWEG
    REPORT ZBI_ROOSFIELD NO STANDARD PAGE HEADING .
    tables ROOSFIELD.
    Update ROOSFIELD set SELECTION = 'X' where
    OLTPSOURCE = '0CUST_SALES_ATTR' and
    FIELD = 'FAKSD '.
    Also see SAP Note : 1033847
    Re: Field Selection in Datasource 0CUST_SALES_ATTR
    Thanks
    Reddy

  • Make the data fit in 1 or 2 pages in Rpt as per the data selection- Hyp IR

    Hi,
    Request to provide me solution for the following issue at the earliest :
    On dashboard I'll have 3 dropdowns drp1,drp2,drp3 and 3 list boxes lb1,lb2,lb3. User selects value from drp1 and selected value can be placed in lb1 thru "=>" button. So any no. of values (less or more values) can be placed in lb1 selected from drp1. Similarly values selected from drp2 placed in lb2 and values selected from drp3 in lb3 thru "=>" buttons.
    After selecting process button I have to place the list box (lb1,lb2,lb3) values (Text) in Text Labels (tlb1,tlb2,tlb3) on the Report. First part of the report contains Pivot with some calculations. Pivot will increase or decrease horizontally. Vertically its size is fixed. Down the pivot, Text Labels tlb1,tlb2,tlb3 are placed down the other. Spring option has been used for tlb1,tlb2,tlb3.
    Now issue I am facing is If user selects more values from drp1,drp2,drp3 then in report tlb1,tlb2,tlb3 are expanding and I am getting the report with 2 pages. After that if user selcts less values from drp1,drp2,drp3 then the data selected getting fitted in single page of report but the 2nd page previously expanded remains exist. But user should not get this 2nd page blank. I tried to apply report grouping . But didn't worked.
    Please suggest me solution for this problem. Can I achieve this requirement if I use any other controls instead of text labels in Report ( less values single page more values 2 pages). Thanks.

    Thanks Eric for the response.
    Our requirement is, in a Production instance, not to allow a DB user (APPS/SYSTEM) to see the confidential data. For example, a user who has the APPS schema password should not be able to see the salary details. However allowing the application like forms/reports/jsp to present the actual data and not the masked data.
    I understand from your reply that the data masking feature CANNOT be used for this purpose as it is rebiulding the tables with the masked data. However we understand that the same feature can be used in a TEST/DEV environment so that we can restrict the developer who is working on the TEST/DEV instance, from accessing the confidential data.
    Any pointers to acheive our requirement will be highly helpful.
    Thanks for your time.
    Ramana.

  • How to put up a calendar in VI for date selection?

    Hi all,
    I need to put up a calendar in my VI for date selection to view historical data like we find on websites of travel agents?
    & also guide me how to get this kind of calendar.....
    please guide me...
    Thanking You,
    Vaibhav Gandhi
    B.E. Instrumentation & Control,
    INDIA
    Solved!
    Go to Solution.

    Thank you so much GURU for your very quick & accurate reply.
    Further I need to know, that how I can remove the word 'value' from indicator? i.e. it is giving "Value -> 6/1/2009" on indicator.. I just need '6/1/2009' on indicator...
    Can it be possible?
    Thanks,
    Vaibhav Gandhi
    B.E. Instrumentation & Control,
    INDIA

  • InfoPackage Data Selection disappear when INIT

    Hi All,
    Just wondering if anyone faced this issue before and/or has a solution.
    I have an infopackage that is loading from an ODS to an InfoCube. The ODS has close to 20 million records.
    When I do a FULL UPDATE, i am able to use the Data Selection tabe to only filter certain criteria to be pulled over to my Cube.
    However, when i try to select and do an INIT, all the fields in my DataSelection tab disappears. and i am forced to load all 20 million records from the ODS.
    Appreciate any input or feedback.
    Regards,
    Gary.

    oh i see...
    i thought otherwise as in the F1  for the init without data transfer, this is what is mentioned...
    "If the delta process has not yet been initialized, but you want to test the delta upload, you have the option of simulating the initialization.
    This runs the help entries in all the required tables in BW and in the source system, without loading any data from the source system.
    In the monitor, you get a message telling you that a record has been loaded. The initialization-simulation request appears in all the data targets in which an update has taken place. However, this request contains only help entries. The simulation does not update any data in the data targets.
    Dependencies
    After you have tested the delta upload in this way, initialize the delta process"

  • PNP Data selection Problem

    Hi ,
    I m using PNP logical database and it is working fine when I m entering payroll area and period at selection screen.
    But it is showing no data found message when I m entering company code and personal sub-area along with payroll area and period.
    I want to fetch data according to company code and personnel subarea also, kindly help me out.
    Thanks in advance

    Hi,
    The PNP database selects and filters the PERNRs according to the data selected on the Selection-Screen. If it shows 'no data found', there might not be any PERNR satisfying the conditions given.
    Pls search for the PERNRs in the respective Database tables(PA tables) of the Infotypes for the required selections. If there are soem PERNRs satisfying the conditions, it prog must be filtering the PERNRs in the GET PERNR event. Pls check where is the PERNR ignored in debug mode.
    Thanks,
    Teja.

Maybe you are looking for