Plz help, A select query for table giving foll o/p

A table has a single column with following data
Col1
170
10
140
520
20
60
70
The select query should return the data in the following format
Col1 Col2 Col3 Col4
170 3 1 0
10 0 0 1
140 2 2 0
520 10 1 0
20 0 1 0
60 1 0 1
70 1 1 0

Using my awesome puzzle solving brain I note that Col2 = 50 Col3 = 20 Col4 = 10.
But you should be telling US that.
select col1, floor(col1/50) col2, floor(mod(col1,50)/20) col3, floor(mod(mod(col1,50),20)/10) col4
from mytable.
I win the internets!
Edited by: Dave Hemming on Dec 19, 2008 11:35 AM

Similar Messages

  • 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

  • Need help writing a query for following scenario

    Hi all, I need some help writing a query for the following case:
    One Table : My_Table
    Row Count: App 5000
    Columns of Interest: AA and BB
    Scenario: AA contains some names of which BB contains the corresponding ID. Some
    names are appearing more than once with different IDs. For example,
    AA BB
    Dummy 10
    Me 20
    Me 30
    Me 40
    You 70
    Me 50
    Output needed: I need to write a query that will display only all the repeating names with their corresponding IDs excluding all other records.
    I would appreciate any input. Thanks

    Is it possible to have a records with the same values for AA and BB? Are you interested in these rows or do you only care about rows with the same value of AA and different BB?
    With a slight modification of a previous posting you can only select those rows that have distinct values of BB for the same value of AA
    WITH t AS (
    SELECT 'me' aa, 10 bb FROM dual
    UNION ALL
    SELECT 'me' aa, 20 bb FROM dual
    UNION ALL
    SELECT 'you' aa, 30 bb FROM dual
    UNION ALL
    SELECT 'you' aa, 30 bb FROM dual
    SELECT DISTINCT aa, bb
      FROM (SELECT aa, bb, COUNT(DISTINCT bb) OVER(PARTITION BY aa) cnt FROM t)
    WHERE cnt > 1;

  • 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 to write selection Query for the following requirment.

    Hi All,
    I am new to ABAP, I need a help ,
    I need to select all plants(WERKS) from MARC at Plant/Material level,
    then I need to take all sales organozation(VKORG) from T001w,
    then I need the company code(BUKRS) from TVKO based on VKORG,
    then I need the currency key(WAERS) from T001 based on BUKRS,
    Can any one help me in writing selection Query for the same?
    Thanks All,
    Debrup.

    Hi,
    Its easy for you if you learn SELECT with JOIN to complete your task. So SEARCH the forum with SELECT statement and you will get a lot of examples using which you can write your own.
    If you struck up anywhere revert back.
    Regards
    Karthik D

  • Need helping in writing query for finding percentage of duration

    Can any one please help in writing query for this.
    The table is like this :-
    ID     Region     Month     Duration
    I1 R1     Jan     80
    I2     R2     Jan     70
    I3     R1     Jan     70
    I4     R3     Jan     40
    I5     R1     Feb     80
    I6     R2     Feb     30
    I7     R3     Mar     100
    I want to write a query to find
    % of duration for each and every region against each and every month.
    Please help in solving this query. I am in urgent need of this.
    Thanks in advance.

    I also have to do in MS Access 2003You also have to ask into an other forum since here it's an Oracle forum, to try to find Oracle solution.
    Nicolas.

  • Selection groups for tables and header tables

    A couple of questions or rather observations around Selection Groups for tables and conversion objectu2026
    1) For tables that do not really have a date field, for instance table PDSNR, it appears that you cannot specify a selection group. Consequently, you have to transfer the table in its entirety. Is this something that can be modified via customizing?
    2) And what about the header tables, for example, X_ANLC, I have tried but not able to change the selection groups on these objects.
    Thanks!
    Harmeet

    Hi Harmeet.
    Since you mention you can only filter by date I am assuming you are using TDTIM.
    How would you want to filter PDSNR, for example? Would it want to filter all entries >= a given sequence number?
    The only way I know to do that is to work directly with the configuration tables. In your case you will need to use CNVMBTSEL* tables. Check how the standard selection groups are configured, and it should not be too difficult to follow the same logic and create your own selection groups.
    CNVMBTSELGRP                   MBT PCL Selection groups              (main table to create the selection group)
    CNVMBTSELMEMTYPE               MBT PCL Selection group member types  (main table to define members => fields for the selection group)
    CNVMBTSELGRPDEF                MBT PCL Selection group definition    (definition of the fields in that selection group)
    CNVMBTSELGRPVAL                MBT PCL Selection group values        (values for each field; you can use GE for >=)
    CNVMBTSELCLAUSE                MBT PCL Selection group clause        (should also be straightforward if you are using only one field)
    CNVMBTSELVAR                   MBT PCL Selection group variants     (configure the same variant for your selection group as for the others)
    CNVMBTSELREF                   MBT PCL Selection group reference     (assignment of selection group to conversion object)
    Hope this helps,
    Rui Dantas

  • Hi, i am badly in need of help. i partitioned my mac hd yesterday and now the boot camp is nt working as i was using win 7 on it. i am using macbook pro 13'' 2011. plz help me. anxiously waiting for response... specially from "Christopher"

    hi, i am badly in need of help. i partitioned my mac hd yesterday and now the boot camp is nt working as i was using win 7 on it. i am using macbook pro 13'' 2011. plz help me. anxiously waiting for response... specially from "Christopher murphy"

    you can't add or mofidy partition numbers. especially not if and once you have windows installed.
    boot from Windows 7 DVD afterwards
    but first you have to tell us and Christopher what and how you partitioned your system.
    Successful setup of OS X Lion + Data Partition + Bootcamp Win7 Ult
    https://discussions.apple.com/thread/3293948
    So after many, many hours I think I've finally figured out how to successfully setup Mac OS X Lion on one partition, a seperate data partition, and Windows 7 Ultimate on a Bootcamp partition . Here is a screenshot of my setup on my 13" MacBook Pro
    Thread with suggestions on Windows backup methods:
    https://discussions.apple.com/thread/3798090
    Paragon CampTune
    Paragon CampTune is a commercial product that is designed expressly for this task. http://www.paragon-software.com/home/camptune/ It consists of a downloadable ISO that needs to be burned to a disc and booted from in order to resize the partitions costs US$19.95.
    Securing Dual-System Configuration
    Imaging is still the most affordable and robust way to secure computer data. Unfortunately Mac OS X backs up only HFS+ volumes, leaving Windows with dual-system configurations unsecured. You can permanently lose all of your data unless you have a Windows-compatible backup solution.
    Paragon’s CampTune and Paragon’s Drive Copy for Mac can secure the entire dual-system configuration. CampTune creates traditional images of volumes or entire hard disks, Drive Copy can copy them to other disks. In case of an emergency, you can restore the previously created image or copy all your data back to its original state.
    GParted Live
    GParted Live is similar to CampTune as it is also distributed as a bootable image that needs to be copied to a CD/DVD or USB flash drive. As free and open source software, distributed under the GPL, it will always be available free. Since it has more functions than CampTune, it may be harder for folks who are not as experienced with partitioning hard drives. http://gparted.sourceforge.net/
    iPartition
    Coriolis Systems' iPartition is a £29.95 ($44.95 US) utility that runs in Mac OS X and allows resizing of all of the relevant partition formats, including HFS+, FAT32, and NTFS. It provides a Mac-oriented user interface that may be easier to manage than some of the free utilities. As it is not capable of resizing the boot disk, it requires a bootable external disk or a boot DVD. (A tool to create a boot DVD is included.)
    Paragon Partition Manager
    From the makes of CampTune is a commercial tool that is similar in functionality to GParted Live, but has a more polished/friendly user interface than GParted Live. Previously only the US$79.95 Professional version supported all the features required for this, but as of version 11 the US$39.95 Personal version has also been reported to work. http://www.paragon-software.com/home/pm-personal/
    Winclone/Disk Utility
    Winclone is a free tool for creating and restoring backup images of your Windows partition. One of its key features is that it can restore to a larger partition than the one the image was created from.
    NOTE: Winclone has been discontinued, but for now remains available and capable of completing these tasks (including creating and restoring Windows 7 images).
    Winclone updated to support Lion Winclone updates and download
    Disk Utility can resize HFS+ (Mac OS) partitions, but is currently incapable of resizing NTFS partitions, so you could use it to reduce the size of the HFS+ partition and create a new larger placeholder MS-DOS (FAT) partition
    The full process would be:
    Backup Windows partition with Winclone.
    (if the new Windows partition is smaller than the old one make sure you set the preferences in Winclone to save the image as an uncompressed dmg)
    Delete old Windows partition
    Resize current Mac Partition
    Create new Windows partition as MS-DOS (FAT) in free space after Mac OS partition.
    (If the new Windows partition is smaller than the old one an additional step is required: shrink the filesystem on the image by selecting Tools->Shrink Windows (NTFS) Filesystem)
    Reboot your computer for the new Windows partition to mount properly (winclone may not restore if you don't reboot)
    Restore Winclone partition over new Windows partition
    An alternate Winclone based process is described in the External Guides section
    Native OS utilities
    MR user Kazyua reports that you can use the disk management utilities provided with the current operating systems if you want to do it manually. Windows 7 and OS X both have partition resizing functions built in. In OS X, open Disk Utility and manually shrink the mac HFS+ partition by dragging the lower right corner. Then in windows go to the start menu and type "disk management" into the search box then hit enter. You should get an overview of the drives you have and the individual partitions. Right-clicking on the partition gives an "Extend Volume" option. The Windows NTFS volume should then be extended into the free space you created with Disk Utility. This method has not worked for other users, so try at your own risk.
    Resizing under VMWare Fusion
    If you are looking to allocate more space to Windows under VMWare please refer to the following thread http://forums.macrumors.com/showthread.php?t=828182
    From http://guides.macrumors.com/Extend/Resize_Boot_Camp_Partition
    Thread with suggestions on Windows backup methods:
    https://discussions.apple.com/thread/3798090

  • While selecting Frame for Table in Smartform

    hi
      While i am selecting Frame for Table in Smartform , it displaying very Bold frame.
    wat is the reason,
    guide me

    hi,
    do this steps,
    ->first in the shading of the table select white color
    ->provide the saturation as 100
    ->select the pattern and select any one of the pattern
    ->and then check the output
    you will get the required do this in the same fashion i explained
    Thanks,
    Nethaji.

  • Hey all..i hv problm .. i cant connect wifi properly ..its stucking itself after evry 5 mints and reconnect after evry 5 mints ..plz helpe...sorry for bad english but hope u will understand

    hey all..i hv problm .. i cant connect wifi properly ..its disconnect itself after evry 5 mints and reconnect after evry 5 mints.. signal showing but there is no avail internet ..plz helpe...sorry for bad english but hope u will understand..

    If your connection won't 'stick', check for interference in that area from other devices on competing channels, etc.
    Configure your choice of band/channel with interference robustness, but mainly reduce the sources to be sure it's not just a too noisy environement.
    Still no joy, be sure your software is up to date and then walk it into the nearest Apple store for a professional opinion
    Good luck in any case.

  • Select query for 6 different tables with vbeln as same selction criteria

    Hi,
    I have a query..
    I am using 6 differnet tables with vbeln being the same primary key on the basis of which i have to match the data.
    I have assign vbeln with different name but in the select query it gives me the error that vbeln2 is not the correct field.
    Can anyone please suggest how can i use the different field name and read the data from the table.

    hi,
    Use alias name for fields / tables in select query, problem will solve
    Regards,
    Praveen Savanth.N

  • Plz help me to find out tables and fields........based on SD,PM,FICO Module

    Hi plz help me to find out the table name and field names as i am unable to find .....In the spec am given requirements in the following pattern.
    Description          SAP-Term                                       Explaination
    1.Salesman        Equipment AC Mgr.                          VBPA2 – this is the salesman code - I need the                                                                               
    description for this.
    2.Vendor              MEPO_TOPLINE-SUPERFIELD     Vendor field is pull from me23n where the                                                                               
    condition will be that COBL-KDAUF (this is a
                                                                                    structure from me23n in item data-account
                                                                                    assignment-sales order. The number here should
                                                                                    be the corresponding contract number. This field
                                                                                    should include a multiple selection function. User                                                                               
    can put more than one description to search for.
    3. Val. Period   Val. Period Category                           Val. Period Category from va41 header-contract
        Category                                                               data. This field should include a multiple selection                                                                               
    function. User can put more than one description                                                                               
    to search for.
    4. Service Order/    CAUFVD-GSTRP/                         This should be the document date where by it is in
        Purchase Order      MEPO_TOPLINE-BEDAT          between the range the user input
        Document Date    
    5. B2B Vendor      MEPO_TOPLINE-SUPERFIELD     Vendor field is pull from me23n where the condition                                                                               
    will be that COBL-KDAUF (this is a structure from
                                                                                    me23n in item data-account assignment-sales                                                                               
    order. The number here should be the                                                                               
    corresponding contract number.
    6. B2B Cost         MEPO1211-NETPR                       This cost is pulled from PO (me23n) however take
                                                                                    note that the price will be pulled out base on line                                                                               
    item Net Price. Make sure that price is taken                                                                               
    corresponding only to the equipment tied to it.                                                                               
    Check on Number 7 to see how is the line item tied                                                                               
    to the equipment.                                                                               
    If this is in other currency please make it to SGD                                                                               
    with the exchange rate field Exchange rate                                                                               
    (MEPO1226-WKURS)
                                                                                  NOTE:: I need to know the table from which I can                                                                               
    determine the currency type as can be seen in the                                                                               
    ME23N transaction and also te exchange rate for                                                                               
    that particular currency.
    7. No of faults                                                          The service order (CAUFVD-AUFNR) created base                                                                               
    on the equipment in Number 8. This should exclude                                                                               
    the service order of type RD08. Service order can be                                                                               
    access by IW33.
    8. Faults Completed                                                This would be the number of faults (Number 13)                                                                               
    which has a system status (CAUFVD-STTXT) of                                                                               
    TECO. System status can be viewed in IW33 Sys.                                                                               
    Status. Take note service order type RD08 will be                                                                               
    excluded
    9. Time Spent on Fault   AFVGD-ISMNW                   This field is in IW41 in confirmation base on the                                                                               
    order created. This field will be the actual time                                                                               
    spent. This will correspond to the Faults                                                                               
    Completed (Number 14). This means only orders                                                                               
    with system status TECO will be pull. Take not                                                                               
    service order type RD08 will be excluded
    10. Fault Cost         RIHAUFK_LIST- DGESKOSIST   This will be the total cost for a service order which                                                                               
    have the status TECO. Those which are not TECO                                                                               
    will not be needed. This field can be obtain from                                                                               
    IW39 (standard report). Execute the report and                                                                               
    there will be a field for Total Actual Cost. You might                                                                               
    need to change the screen layout to be able to view                                                                               
    this. Take note service order type RD08 will be                                                                               
    excluded
    11. PM Hours      AFVGD-ISMNW                            This field is in IW41 in confirmation base on the
                                                                                 order created. This field will be the actual time
                                                                                 spent. This will correspond to the Faults Completed
                                                                                 This means only orders with system
                                                                                 status TECO will be pull. Take note service only
                                                                                 take order type RD08.
    12. Spare Cost   Spare part cost                              This field will be in IW33 under cost tab, and cost
                             PMCOEA-IKOSTENKGR                tab in item level. This will be the actual cost of spare
                                                                                 part after TECO. This will include all order type.
    13. Credit Note   Credit Memo                                 The programs need to pull out credit memo which is
                                                                                 reference from the contract. If there is a credit memo
                                                                                 reference from the contract then the value will be net
                                                                                 price per equipment.

    Can u tell me purpose of this spec ?
    Regards,
    pandu.

  • Select query for fields in selection screen

    SELECT * FROM hrus_d2
               INTO TABLE ta_list
               WHERE us_name IN subs_obj
               and begdat in date_ran.
              and enddat in date_ran
    How can I rewrite the above query for high and low ranges of date_ran field in condition? It doesn't allow in operator with date_ran-low.Can u please help me out

    Hi
    rahul
    SELECT *
    FROM hrus_d2
    INTO TABLE ta_list
    WHERE us_name IN subs_obj
    and begdat = date_ran-low
    and enddat = date_ran -high.
    u can write like this or i amnot getting why u r expliciting this date u can give directly as
    SELECT *
    FROM hrus_d2
    INTO TABLE ta_list
    WHERE us_name IN subs_obj
    date in date_ran.
    plzz reward if i am usefull to u in any way.. plzz dont forget to reward

  • Plz help me out with for all entries

    hi to all experts,
                              This is my sample code plz tell me how to output the data.plz help me out.im very much beginner in ABAP and i dont want to use loop and endloop is there any way
                                  REPORT  Z_FORALLENTERIES                        .
    types : begin  of ty_lfa1,
              lifnr type lfa1-lifnr,
              name1 type lfa1-name1,
              land1 type lfa1-land1,
            end of ty_lfa1.
    types : begin of ty_lfb1 ,
              lifnr type lfb1-lifnr,
              bukrs type lfb1-bukrs,
              pernr type lfb1-pernr,
            end of ty_lfb1.
    types : begin of ty_lfc1 ,
              lifnr type lfc1-lifnr,
              gjahr type lfc1-gjahr,
              usnam type lfc1-usnam,
             end of ty_lfc1.
    types :  begin of ty_lfbk ,
              lifnr type lfbk-lifnr,
              banks type lfbk-banks,
              bankl type lfbk-bankl,
              bankn type lfbk-bankn,
            end of ty_lfbk.
    types : begin of ty_final,
              lifnr type lfa1-lifnr,
              name1 type lfa1-name1,
              land1 type lfa1-land1,
              bukrs type lfb1-bukrs,
              pernr type lfb1-pernr,
              gjahr type lfc1-gjahr,
              usnam type lfc1-usnam,
              banks type lfbk-banks,
              bankl type lfbk-bankl,
              bankn type lfbk-bankn,
            end of ty_final.
    data : it_lfa1 type standard table of ty_lfa1 initial size 0 with header line.
    data : it_lfb1 type standard table of ty_lfb1 initial size 0 with header line.
    data : it_lfc1 type standard table of ty_lfc1 initial size 0 with header line.
    *--internal for outputting data--
    data : it_lfbk type standard table of ty_lfbk initial size 0 with header line.
    data : it_final type  standard table of ty_final initial size 0,
           wa_final like line of it_final.
    select lifnr name1 land1
           into table it_lfa1[]
           from lfa1 up to 10 rows.
    if it_lfa1[]  is not initial.
    select lifnr bukrs pernr
           into table it_lfb1[]
           from lfb1
           for all entries in it_lfa1[]
           where lifnr eq it_lfa1-lifnr.
    endif.
    if it_lfb1[] is not initial.
    select lifnr gjahr usnam
           into table it_lfc1[]
           from lfc1
           for all entries in it_lfb1[]
           where lifnr eq it_lfb1-lifnr.
    endif.
    if it_lfc1[] is not initial.
    select lifnr banks bankl bankn
           into table it_lfbk[]
           from lfbk
           for all entries in it_lfc1[]
           where lifnr eq it_lfc1-lifnr.
    endif.

    Hi
    see this program  almost same req
    **************DATA TYPES DECLARATION **********************
    TABLES: HRP1001, HRP1026, HRP1000,PCHDY.
    TYPE-POOLS SLIS.
    TYPES :BEGIN OF ST_OUTPUT,
            COUNT TYPE STRING,
            OBJID TYPE HRP1001-OBJID,
            STEXT TYPE HRP1000-STEXT,
            BEGDA TYPE HRP1000-BEGDA,
            ENDDA TYPE HRP1000-ENDDA,
            CANCRT TYPE T77CRT-CANCRT,
            AEDTM TYPE HRP1026-AEDTM,
            UNAME TYPE HRP1026-UNAME,
            LSTEXT TYPE HRP1000-STEXT,
           RINVT TYPE T777V-RINVT,
           END OF ST_OUTPUT.
    TYPES: BEGIN OF ST_HRP1000,
            OBJID TYPE HRP1001-OBJID,
            STEXT TYPE HRP1000-STEXT,
           END OF ST_HRP1000.
    TYPES : BEGIN OF ST_HRP1001,
             OTYPE TYPE HRP1001-OTYPE,
             OBJID TYPE HRP1001-OBJID,
             RELAT type hrp1001-RELAT,
             BEGDA TYPE HRP1001-BEGDA,
             ENDDA TYPE HRP1001-ENDDA,
             SCLAS TYPE HRP1001-SCLAS,
             SOBID TYPE HRP1001-SOBID,
            END OF ST_HRP1001.
    TYPES : BEGIN OF ST_HRP1026,
             OTYPE TYPE HRP1026-OTYPE,
             OBJID TYPE HRP1001-OBJID,
             AEDTM TYPE HRP1026-AEDTM,
             UNAME TYPE HRP1026-UNAME,
             DELET TYPE HRP1026-DELET,
             CANCR TYPE HRP1026-CANCR,
            END OF ST_HRP1026.
    TYPES : BEGIN OF ST_REASON,
             CANCR TYPE HRP1026-CANCR,
             CANCRT TYPE T77CRT-CANCRT,
            END OF ST_REASON.
    TYPES : BEGIN OF ST_SOBID,
             OTYPE TYPE HRP1001-OTYPE,
             OBJID TYPE HRP1001-OBJID,
             RELAT type hrp1001-OBJID,
             BEGDA TYPE HRP1001-BEGDA,
             ENDDA TYPE HRP1001-ENDDA,
             SCLAS TYPE HRP1001-SCLAS,
             SOBID TYPE HRP1001-OBJID,
            END OF ST_SOBID.
    TYPES : BEGIN OF ST_OBJID,
             OBJID TYPE HRP1001-OBJID,
            END OF ST_OBJID.
    TYPES : BEGIN OF ST_LOCATION,
             OTYPE TYPE HRP1001-OTYPE,
             OBJID TYPE HRP1001-OBJID,
             RSIGN TYPE HRP1001-RSIGN,
             RELAT TYPE HRP1001-RELAT,
             SCLAS TYPE HRP1001-SCLAS,
             SOBID TYPE HRP1001-SOBID,
            END OF ST_LOCATION.
    TYPES : BEGIN OF ST_LOCATION1,
             OTYPE TYPE HRP1001-OTYPE,
             OBJID TYPE HRP1001-OBJID,
             RSIGN TYPE HRP1001-RSIGN,
             RELAT TYPE HRP1001-RELAT,
             SCLAS TYPE HRP1001-SCLAS,
             SOBID TYPE HRP1001-OBJID,
            END OF ST_LOCATION1.
    TYPES : BEGIN OF ST_LSTEXT,
             OTYPE TYPE HRP1000-OTYPE,
             OBJID TYPE HRP1000-OBJID,
             LSTEXT TYPE HRP1000-STEXT,
            END OF ST_LSTEXT.
    TYPES : BEGIN OF ST_OBJID_SH,
             OTYPE TYPE HRP1000-OTYPE,
             OBJID TYPE HRP1000-OBJID,
            END OF ST_OBJID_SH.
    DATA : IT_OBJID_SH TYPE STANDARD TABLE OF ST_OBJID_SH.
    DATA : WA_OBJID_SH TYPE ST_OBJID_SH.
    DATA : IT_LSTEXT TYPE STANDARD TABLE OF ST_LSTEXT.              "TOS STORE THE TEXT OF COURCE LOCATION
    DATA : WA_LSTEXT TYPE ST_LSTEXT.
    DATA : IT_LOCATION TYPE STANDARD TABLE OF ST_LOCATION.          " TO STORE THE LOCATION OF COURCE
    DATA : WA_LOCATION TYPE ST_LOCATION.
    DATA : IT_LOCATION1 TYPE STANDARD TABLE OF ST_LOCATION1.        " TO CONVERT SOBID INTO OBJID FOR COURCE LOCATION
    DATA : WA_LOCATION1 TYPE ST_LOCATION1.
    DATA : IT_SOBID TYPE STANDARD TABLE OF ST_SOBID.                " TO CHANGE THE SOBID OF HRP1001 TO OBJID OF HRP1026
    DATA : WA_SOBID TYPE ST_SOBID.                                   " BY USING FOR ALL ENTRIES
    DATA : IT_REASON TYPE STANDARD TABLE OF ST_REASON.              "TO STORE T HE REASON FOR CANCELL TEXT
    DATA : WA_REASON TYPE ST_REASON.
    DATA : IT_OUTPUT TYPE STANDARD TABLE OF ST_OUTPUT.               "OUTPUT FEILDS OF REPORT.
    DATA : WA_OUTPUT TYPE ST_OUTPUT.
    DATA : IT_OUTPUT_1 TYPE STANDARD TABLE OF ST_OUTPUT.               " TEMP OUTPUT FEILDS OF REPORT.
    DATA : WA_OUTPUT_1 TYPE ST_OUTPUT.
    DATA : IT_HRP1000 TYPE STANDARD TABLE OF ST_HRP1000.             "DATA FROM HRP1000 TABLE
    DATA : WA_HRP1000 TYPE ST_HRP1000.
    DATA : IT_HRP1001 TYPE STANDARD TABLE OF ST_HRP1001.             "DATA FROM HRP1001 TABLE
    DATA : WA_HRP1001 TYPE ST_HRP1001.
    DATA : IT_HRP1026 TYPE STANDARD TABLE OF ST_HRP1026.              "DATA FROM HRP1026 TABLE
    DATA : WA_HRP1026 TYPE ST_HRP1026.
    DATA : IT_OBJID TYPE STANDARD TABLE OF ST_OBJID.                  " TO STORE THE OBJID OF HRP1001
    DATA : WA_OBJID TYPE ST_OBJID.
    DATA: WS_FCAT    TYPE SLIS_FIELDCAT_ALV .                         " FEILDCATALOG FOR ALV REPORT
    DATA: IN_FCAT    TYPE SLIS_T_FIELDCAT_ALV.
    DATA: W_LAYOUT   TYPE SLIS_LAYOUT_ALV.
    DATA : LV_COUNT TYPE I.                                           "FEILD FOR SERIAL NUMBER
    ***************************END OF DATA DECLARATION******************************************
    ***********SELECTION SCREEN DESIGN***********************
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    *SELECT-OPTIONS : S_OTYPE FOR HRP1001-OTYPE NO INTERVALS .
    SELECT-OPTIONS : S_OBJID FOR HRP1001-OBJID NO INTERVALS .
    SELECT-OPTIONS : DATE FOR SY-DATUM NO-EXTENSION OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK B1.
    **********END OF SELECTION SCREEN DESIGN*****************
    *****INITIALIZATION VENT TO ASIGN DEFAULT VALUES TO OTYPE
    *INITIALIZATION.
    S_OTYPE-LOW = 'D'.
    S_OTYPE-SIGN = 'I'.
    S_OTYPE-OPTION = 'EQ'.
    APPEND S_OTYPE.
    CLEAR S_OTYPE.
    *************END OF EVENT INITIALIZATION*****************
    *********VALIDATION FOR SCREEN FIELDS********************
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_OBJID-LOW.
    IF S_OBJID IS NOT INITIAL.
        SELECT OTYPE OBJID FROM HRP1000
                     INTO TABLE IT_OBJID_SH
                     WHERE OTYPE = 'D'.
    IF SY-SUBRC EQ 0.
    SEARCH HELP FOR QUALIFICATION.
        CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
          EXPORTING
                 DDIC_STRUCTURE         = ' '
            RETFIELD               =  'OBJID'
                 PVALKEY                = ' '
           DYNPPROG               = SY-REPID
           DYNPNR                 = SY-DYNNR
           DYNPROFIELD            = 'S_OBJID'
                 STEPL                  = 0
                 WINDOW_TITLE           =
                 VALUE                  = ' '
           VALUE_ORG              = 'S'
                 MULTIPLE_CHOICE        = ' '
                 DISPLAY                = ' '
                 CALLBACK_PROGRAM       = ' '
                 CALLBACK_FORM          = ' '
                 MARK_TAB               =
               IMPORTING
                 USER_RESET             =
          TABLES
            VALUE_TAB              =  IT_OBJID_SH
                 FIELD_TAB              =
                 RETURN_TAB             = RETURN_TAB
                 DYNPFLD_MAPPING        =
               EXCEPTIONS
                 PARAMETER_ERROR        = 1
                 NO_VALUES_FOUND        = 2
                 OTHERS                 = 3
        IF SY-SUBRC <> 0.
              MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                      WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
      ENDIF.
       IF SY-SUBRC NE 0.
         MESSAGE 'NO RECORD FOUND FOR THE GIVEN SELECTION CRITERIA.' TYPE 'E'.
       ENDIF.
    ENDIF.
    REFRESH IT_OBJID.
    ***************VALIDATION OF SCREEN FIELDS ENDS***********
    *****************START OF SELECTION ************************
    START-OF-SELECTION.
      SELECT OTYPE
             OBJID
             RELAT
             BEGDA
             ENDDA
             SCLAS
             SOBID FROM HRP1001 INTO TABLE IT_HRP1001
                        WHERE OTYPE = 'D'
                            AND OBJID IN S_OBJID
                            AND BEGDA GE DATE-LOW
                            AND ENDDA LE DATE-HIGH
                            AND ( SCLAS = 'E' OR SCLAS = 'ET' ).
      IF SY-SUBRC NE 0.
        MESSAGE 'NO RECORD FOUND FOR THE GIVEN SELECTION CRITERIA ' TYPE 'E'.
      ENDIF.
      LOOP AT IT_HRP1001 INTO WA_HRP1001.
        WA_SOBID-OTYPE = WA_HRP1001-OTYPE.
        WA_SOBID-OBJID = WA_HRP1001-OBJID.
        WA_SOBID-RELAT = WA_HRP1001-RELAT.
        WA_SOBID-BEGDA = WA_HRP1001-BEGDA.
        WA_SOBID-ENDDA = WA_HRP1001-ENDDA.
        WA_SOBID-SCLAS = WA_HRP1001-SCLAS.
        WA_SOBID-SOBID = WA_HRP1001-SOBID.
        APPEND WA_SOBID TO IT_SOBID.
      ENDLOOP.
      SELECT OTYPE
             OBJID
             AEDTM
             UNAME
             DELET
             CANCR
            NCONT
              FROM HRP1026
              INTO TABLE IT_HRP1026
              FOR ALL ENTRIES IN IT_SOBID
                 WHERE OBJID = IT_SOBID-SOBID
                 AND ( OTYPE = 'E' OR OTYPE = 'ET' )
                     AND DELET = 'X' AND
                     BEGDA GE DATE-LOW  AND
                     ENDDA LE DATE-HIGH.
      IF SY-SUBRC EQ 0.
        SELECT OBJID
               STEXT
               FROM HRP1000
               INTO TABLE IT_HRP1000
               FOR ALL ENTRIES IN IT_SOBID
                  WHERE OBJID = IT_SOBID-SOBID AND
                        BEGDA GE DATE-LOW  AND
                        ENDDA LE DATE-HIGH.
        SELECT CANCR
               CANCRT
               FROM T77CRT
               INTO TABLE IT_REASON
               FOR ALL ENTRIES IN IT_HRP1026
               WHERE CANCR = IT_HRP1026-CANCR
                 AND LANGU = 'E' .
    ********PERFORM FOR GETTING T HE LOCATION OF THE COURCE**
      PERFORM GET_LOCATION.
    **************END OF LOCATION OF COURCE ******************
      ELSE.
        MESSAGE 'NO RECORD FOUND FOR THE GIVEN SELECTION CRITERIA ' TYPE 'E'.
      ENDIF.
    *****PERFORM FOR GETTING DATA INTO THE FINAL INTERNAL TABLE IT_OUTPUT**
      PERFORM GET_DATA.
    *********************************END OF PERFORM ET DATA ***************
    ***********LOGIC FOR PRONTING NUMBER OF RECORDS ***********************
      LV_COUNT = 0.
      LOOP  AT IT_OUTPUT INTO WA_OUTPUT.
        LV_COUNT = LV_COUNT + 1.
        WA_OUTPUT-COUNT = LV_COUNT.
        APPEND WA_OUTPUT TO IT_OUTPUT_1.
      ENDLOOP.
      REFRESH IT_OUTPUT.
      IT_OUTPUT = IT_OUTPUT_1.
    ********************END OF LOGIC FOR NUMBER OF RECORDS ***************
    ****************DISPLAYING OUTPUT BY USEING GRID DISPLAY**********
      PERFORM ALV_DISPLAY.
    ****************************END OF PERFORM FOR DISPLAYING **********
    *&      Form  PERFORM_ALV
    DISPLAY THE RECORDS IN ALV GRID FORMAT.
    FORM ALV_DISPLAY.
      PERFORM FIELD_CATALOG USING 'COUNT' 'Sr. No.'.
      PERFORM FIELD_CATALOG USING 'OBJID' 'COURCE ID.'.
      PERFORM FIELD_CATALOG USING 'STEXT' 'COURCE NAME'.
        PERFORM FIELD_CATALOG USING 'LSTEXT' 'COURCE LOATION'.
      PERFORM FIELD_CATALOG USING 'BEGDA' 'BEGIN DATE '.
      PERFORM FIELD_CATALOG USING 'ENDDA' 'END DATE '.
      PERFORM FIELD_CATALOG USING 'CANCRT' 'REASON'.
      PERFORM FIELD_CATALOG USING 'AEDTM' 'DATE Of CANCEL'.
    PERFORM FIELD_CATALOG USING 'NCONT' 'NUMBER OF BOOKINGS'.
    PERFORM FIELD_CATALOG USING 'LOCTX' 'COURCE LOCATION'.
      PERFORM FIELD_CATALOG USING 'UNAME' 'WHO CANCELLED'.
    PERFORM FIELD_CATALOG USING 'LSTEXT' 'COURCE LOATION'.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          I_STRUCTURE_NAME = 'IT_OUTPUT'
          I_GRID_TITLE     = ' Cancelled courses with reason '
          IT_FIELDCAT      = IN_FCAT
        TABLES
          T_OUTTAB         = IT_OUTPUT.
      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.                    "PERFORM_ALV
    *&      Form  FIELD_CATALOG
          text
         -->FIELD_NAME text
         -->DIS_TEXT   text
    FORM FIELD_CATALOG USING FIELD_NAME DIS_TEXT.
      CLEAR WS_FCAT.
      WS_FCAT-TABNAME = 'IT_OUTPUT'.
      WS_FCAT-FIELDNAME = FIELD_NAME.
      WS_FCAT-SELTEXT_M = DIS_TEXT.
      APPEND WS_FCAT TO IN_FCAT .
    ENDFORM.                    "FIELD_CATALOG
    *&      Form  GET_DATA
          text
    -->  p1        text
    <--  p2        text
    FORM GET_DATA .
    *sort it_sobid by objid.
      LOOP AT IT_SOBID INTO WA_SOBID." where otype eq s_otype and objid eq s_objid.
        READ TABLE IT_HRP1026 WITH KEY OBJID = WA_SOBID-SOBID OTYPE = WA_SOBID-SCLAS INTO WA_HRP1026.
        IF SY-SUBRC EQ 0.
          READ TABLE IT_HRP1000 WITH KEY OBJID = WA_SOBID-SOBID INTO WA_HRP1000.
       READ TABLE IT_REASON WITH KEY CANCR = WA_HRP1026-CANCR INTO WA_REASON.
          WA_OUTPUT-OBJID = WA_HRP1026-OBJID.
          WA_OUTPUT-BEGDA = WA_SOBID-BEGDA.
          WA_OUTPUT-ENDDA = WA_SOBID-ENDDA.
          WA_OUTPUT-AEDTM = WA_HRP1026-AEDTM.
          WA_OUTPUT-UNAME = WA_HRP1026-UNAME.
       WA_OUTPUT-NCONT = WA_HRP1026-NCONT.
       READ TABLE IT_HRP1000 WITH KEY OBJID = WA_SOBID-SOBID INTO WA_HRP1000.
          WA_OUTPUT-STEXT = WA_HRP1000-STEXT.
          READ TABLE IT_REASON WITH KEY CANCR = WA_HRP1026-CANCR INTO WA_REASON.
          WA_OUTPUT-CANCRT = WA_REASON-CANCRT.
          CLEAR WA_REASON-CANCRT.
          READ TABLE IT_LOCATION1 WITH KEY OBJID = WA_HRP1026-OBJID INTO WA_LOCATION1..
          READ TABLE IT_LSTEXT WITH KEY OBJID = WA_LOCATION1-SOBID OTYPE = 'F' INTO WA_LSTEXT.
                 WA_OUTPUT-LSTEXT = WA_LSTEXT-LSTEXT.
                 CLEAR WA_LSTEXT-LSTEXT.
          APPEND WA_OUTPUT TO IT_OUTPUT.
          CLEAR WA_OUTPUT.
          CLEAR WA_OUTPUT-CANCRT.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    " GET_DATA
    *&      Form  GET_LOCATION
          text
    -->  p1        text
    <--  p2        text
    FORM GET_LOCATION .
    SELECT OTYPE
           OBJID
           RSIGN
           RELAT
           SCLAS
          SOBID
          FROM HRP1001
          INTO TABLE IT_LOCATION
          FOR ALL ENTRIES IN IT_HRP1026
          WHERE OTYPE = 'E' AND OBJID = IT_HRP1026-OBJID
           AND RSIGN = 'A' AND RELAT = '024' AND SCLAS = 'F'
                    AND BEGDA GE DATE-LOW AND ENDDA LE DATE-HIGH.
    IF SY-SUBRC NE 0.
        MESSAGE 'NO RECORD FOUND FOR THE GIVEN SELECTION CRITERIA ' TYPE 'E'.
      ENDIF.
      LOOP AT IT_LOCATION INTO WA_LOCATION.
        WA_LOCATION1-OTYPE = WA_LOCATION-OTYPE.
        WA_LOCATION1-OBJID = WA_LOCATION-OBJID.
            WA_LOCATION1-RSIGN = WA_LOCATION-RSIGN.
        WA_LOCATION1-RELAT = WA_LOCATION-RELAT.
        WA_LOCATION1-SCLAS = WA_LOCATION-SCLAS.
        WA_LOCATION1-SOBID = WA_LOCATION-SOBID.
        APPEND WA_LOCATION1 TO IT_LOCATION1.
       CLEAR WA_LOCATION1.
      ENDLOOP.
    SELECT OTYPE
           OBJID
           STEXT
           FROM HRP1000
           INTO TABLE IT_LSTEXT
           FOR ALL ENTRIES IN IT_LOCATION1
           WHERE OBJID = IT_LOCATION1-SOBID
              AND OTYPE = 'F'.
             AND BEGDA GE DATE-LOW
             AND ENDDA LE DATE-HIGH.
    ENDFORM.                    " GET_LOCATION
    <b>Reward if usefull</b>

Maybe you are looking for

  • SecurePDF on Hp-UX

    I want to generate password-protected pdf files with reports. Based on a note I downloaded SecurePDFDestination from OTN together with Plop 2.1. I followed the instructions to install this on HP-UX, but when I run the report using: http://server:port

  • Error while running a Dynpro Application

    Hi, I am using an RFC that use GUI_DOWNLOAD FM to push the file data to an internal table, but when it comes to Dynpro application it through an error u2018Access via Null Reference is not possible u2019 (Exception 1 of GUI_DOWNLOAD) while assigning

  • Sqlnet.ora doesn't seem to be read since oci8 1.3.4

    Hello, I used to use oci8 version 1.2.3 and I wanted to update to last version (1.3.4). Everything works fine except the fact that "sqlnet.ora" does not seems to be read anymore. I use the following string to describe my database in oci_connect: "MEN

  • Value Mapping issue

    Hi,      Value Mapping is not allowing me to add the following combinations is there any work around possible? Source  A Target   a1 Source  B Target   a1 Thank you in adavance.

  • Adobe 9 Installed 98.9% Won't Go Further

    During Adobe 9 installation up to 98.9%, it said that it could not continue, due to not being able to unistall older version. I tried to remove Adobe 8 through Control Panel and received the following message: This patch package could not be opened.