Range wise output

I have one table as test ot_shop_transmittal_test and the sample reords inserted as below, i want a output in range like below
STMH_NO     STMH_BATCH_NO     STMH_PM_CODE     STMH_PM_DESC     STMH_REV_NO     
PR-1107-0001     0001     1107040-1001 - 1107040-1003     FRAME, COLUMN     0     
PR-1107-0001     0002     1107040-1004     FRAME     0     
PR-1107-0001     0001     1107040-1006     GIRDER     0     
CREATE TABLE OT_SHOP_TRANSMITTAL_TEST
        STMH_NO VARCHAR2(15),
        STMH_JOB_NO VARCHAR2(12),
        STMH_BATCH_NO VARCHAR2(12),
        STMH_PM_CODE VARCHAR2(35),
        STMH_PM_DESC VARCHAR2(240),
        STMH_REV_NO  VARCHAR2(12)
INSERT INTO OT_SHOP_TRANSMITTAL_TEST VALUES ('PR-1107-0001','1107040','0001','1107040-1001','FRAME','0');
INSERT INTO OT_SHOP_TRANSMITTAL_TEST VALUES ('PR-1107-0001','1107040','0001','1107040-1002','FRAME','0');
INSERT INTO OT_SHOP_TRANSMITTAL_TEST VALUES ('PR-1107-0001','1107040','0001','1107040-1003','COLUMN','0');
INSERT INTO OT_SHOP_TRANSMITTAL_TEST VALUES ('PR-1107-0001','1107040','0002','1107040-1004','FRAME','0');
INSERT INTO OT_SHOP_TRANSMITTAL_TEST VALUES ('PR-1107-0001','1107040','0001','1107040-1005','FRAME','0');
INSERT INTO OT_SHOP_TRANSMITTAL_TEST VALUES ('PR-1107-0001','1107040','0001','1107040-1006','GIRDER','0');
--What i want is like rownumber to considered also the output will be
STMH_NO       STMH_BATCH_NO     STMH_PM_CODE                      STMH_PM_DESC     STMH_REV_NO     
PR-1107-0001     0001     1107040-1001 - 1107040-1003     FRAME, COLUMN     0       
PR-1107-0001     0002     1107040-1004                     FRAME             0            
PR-1107-0001     0001     1107040-1006                     GIRDER             0     
select rn,stmh_batch_no,
    MIN (a)
         || DECODE (MIN (a),
                    MAX (a), '',
                    ' - ' || MAX (a)
                   ) STMH_PM_CODE,
MIN (b)|| DECODE (MIN (b),MAX (b), '',' - ' || MAX (b)) des
from (
SELECT DECODE (rn, 1, STMH_PM_CODE, stmh_pm_code) A,
       DECODE (rn, 1, STMH_PM_DESC, stmh_pm_desc) B,
       rn,
       stmh_batch_no
       FROM
    (   SELECT STMH_NO,STMH_BATCH_NO,
STMH_PM_CODE,
STMH_PM_DESC,
ROW_NUMBER () OVER
                 (PARTITION BY STMH_BATCH_NO,STMH_PM_DESC
                  ORDER BY stmh_PM_CODE) rn
FROM OT_SHOP_TRANSMITTAL_TEST
ORDER BY 3,5 ) T1 ) t2
where t2.rn=1
group by rn,stmh_batch_no
-- i am getting the result as below with the above query and its wrong since i want 1107040-1006 in a seperate line
STMH_NO       STMH_BATCH_NO     STMH_PM_CODE                      STMH_PM_DESC     STMH_REV_NO     
PR-1107-0001     0001     1107040-1001 - 1107040-1006     COLUMN-GIRDER     0       
PR-1107-0001     0002     1107040-1004                     FRAME                     0

user5206327 wrote:
thanks frank, oracle version is 10.2.0.1.0 and can you please demonstrate the query with STRAGG , stmh_rev_no is like stmh_batch_no, and whenver it changes , the result set will also change using your query i am getting the result as below .
STMH_NO     STMH_JOB_NO     STMH_BATCH_NO     pm_code      desc
PR-1107-0001     1107040     0001     1107040-1001-1107040-1006      COLUMN,FRAME,GIRDER
PR-1107-0001     1107040     0002     1107040-1004-1107040-1004     FRAMEIt looks like you changed the query.
When I run what I posted, I get
`               STMH_                             STMH
                BATCH                             _REV
STMH_NO         _NO   STMH_PM_CODES               _NO
PR-1107-0001    0001  1107040-1001 - 1107040-1003 0
PR-1107-0001    0002  1107040-1004                0
PR-1107-0001    0001  1107040-1005 - 1107040-1006 0That is, 3 rows of output, no stmh_job_no or desc columns, but I do get a stmh_rev_no column. Post exactly what you ran.
i want the output like this below.
STMH_NO     STMH_JOB_NO     STMH_BATCH_NO     pm_code      desc
PR-1107-0001     1107040     0001     1107040-1001-1107040-1003     COLUMN,FRAME
PR-1107-0001     1107040     0002     1107040-1004      FRAME
PR-1107-0001     1107040     0001     1107040-1005-1107040-1006     FRAME,GIRDERWhen I run the following query, I get that output:
WITH     got_diff   AS
     SELECT  stmh_no
     ,     stmh_job_no
     ,     stmh_batch_no
     ,     stmh_pm_code
     ,     stmh_pm_desc
     ,     stmh_rev_no
     ,     ROW_NUMBER () OVER ( PARTITION BY  stmh_no
                                 ORDER BY         stmh_pm_code
           -     ROW_NUMBER () OVER ( PARTITION BY  stmh_batch_no
                                     ,                    stmh_rev_no
                               ,                    stmh_no
                                 ORDER BY         stmh_pm_code
                       ) AS diff
     FROM    ot_shop_transmittal_test
SELECT       stmh_no
,       MIN (stmh_job_no)               AS stmh_job_no
,       stmh_batch_no
,       MIN (stmh_pm_code) || CASE
                                   WHEN  COUNT (DISTINCT stmh_pm_code) > 1
                        THEN '-' || MAX (stmh_pm_code)
                               END                  AS stmh_pm_codes
,       STRAGG (DISTINCT stmh_pm_desc)        AS stmh_pm_descs
FROM       got_diff
GROUP BY  stmh_no
,            stmh_batch_no
,       stmh_rev_no
,       diff
ORDER BY  stmh_no
,       stmh_pm_codes
,            stmh_batch_no
,       stmh_rev_no
;except that I called the last column stmh_pm_descs instead of desc. DESC is a keyword in Oracle (it's used for sorting in DESCending order), so it's not a very good column name.
If stmh_rev_no is similar to stmh_batch_no, then use stmh_rev_no and stmh_batch_no together in all PARTITION BY and GROUP BY clauses.
I still don't understand what role stmh_job_no plays in this problem. If stmh_job_no is like stmh_rev_no and stmh_batch_no, then use all 3 columns together in the PARTITION BY and GROUP BY clauses.

Similar Messages

  • Column wise output for different date range

    I m having a query which gives the output like
    DISTRIBUTOR_CODE APR MAY JUN JUL AUG
    R127 01/04/2005
    R127 02/04/2005
    R127 03/04/2005
    R127 01/05/2005
    R127 02/05/2005
    R127 03/05/2005
    R127                     01/06/2005
    while the output needed by me is
    DISTRIBUTOR_CODE APR MAY JUN JUL AUG
    R127 01/04/2005 01/05/2005 01/06/2005
    R127 02/04/2005 02/05/2005
    R127 03/04/2005 03/05/2005
    R127
    The query is
    The query used by me is as below
    select distributor_code,
    decode(to_char(param_date,'MM'),to_char(add_months(min(mindt),0),'MM'),param_date) apr,
    decode(to_char(param_date,'MM'),to_char(add_months(min(mindt),1),'MM'),param_date) may,
    decode(to_char(param_date,'MM'),to_char(add_months(min(mindt),2),'MM'),param_date) jun,
    decode(to_char(param_date,'MM'),to_char(add_months(min(mindt),3),'MM'),param_date) jul
    ,decode(to_char(param_date,'MM'),to_char(add_months(min(mindt),4),'MM'), param_date) aug
    ,decode(to_char(param_date,'MM'),to_char(add_months(min(mindt),5),'MM'), param_date) sep,
    decode(to_char(param_date,'MM'),to_char(add_months(min(mindt),6),'MM'),param_date) oct,
    decode(to_char(param_date,'MM'),to_char(add_months(min(mindt),7),'MM'),param_date) nov,
    decode(to_char(param_date,'MM'),to_char(add_months(min(mindt),8),'MM'),param_date) dec
    from ppbsnew.dms_audit_trail t,(select distributor_code dcode ,min(param_date) mindt
    from ppbsnew.dms_audit_trail
    where trunc(param_Date) between '01-APR-05' and '31-DEC-05' group by distributor_code) t2
    where t.distributor_code=t2.dcode
    and trunc(param_Date) between '01-APR-05' and '31-DEC-05'
    and t.distributor_name is not null
    group by distributor_code,param_Date

    hi
    SQL>  select job,
      2              decode(to_char(hiredate,'MON'),'JAN',hiredate, NULL ) JAN,
      3              decode(to_char(hiredate,'MON'),'FEB',hiredate, NULL ) FEB,
      4              decode(to_char(hiredate,'MON'),'MAR',hiredate, NULL ) MAR,
      5              decode(to_char(hiredate,'MON'),'APR',hiredate, NULL ) APR,
      6              decode(to_char(hiredate,'MON'),'MAY',hiredate, NULL ) MAY,
      7              decode(to_char(hiredate,'MON'),'JUN',hiredate, NULL ) JUN,
      8              decode(to_char(hiredate,'MON'),'JUL',hiredate, NULL ) JUL,
      9              decode(to_char(hiredate,'MON'),'AUG',hiredate, NULL ) AUG,
    10              decode(to_char(hiredate,'MON'),'SEP',hiredate, NULL ) SEP,
    11              decode(to_char(hiredate,'MON'),'OCT',hiredate, NULL ) OCT,
    12              decode(to_char(hiredate,'MON'),'NOV',hiredate, NULL ) NOV,
    13              decode(to_char(hiredate,'MON'),'DEC',hiredate, NULL ) DEC
    14   from emp where to_date(hiredate,'DD-MON-YY') between '01-JAN-81' and '31-DEC-81';
    JOB       JAN       FEB       MAR       APR       MAY       JUN       JUL       AUG       SEP       OCT       NOV       DEC
    SALESMAN            20-FEB-81
    SALESMAN            22-FEB-81
    MANAGER                                 02-APR-81
    SALESMAN                                                                                  28-SEP-81
    MANAGER                                           01-MAY-81
    MANAGER                                                     09-JUN-81
    PRESIDENT                                                                                                     17-NOV-81
    SALESMAN                                                                                  08-SEP-81
    CLERK                                                                                                                   03-DEC-81
    ANALYST                                                                                                                 03-DEC-81
    10 rows selected.Is that you wana achieve??
    Khurram Siddiqui
    [email protected]

  • How 2 Change of column wise o/p  to row wise output in ABAP?

    Hi all,
    I am getting the output in column wise as normally but how can I get the ouput in row wise.in ABAP.
    its urgent. can any one help me how to change the output layout?
    thanks in advance,
    Sakthi.C

    if it is normal report  .then
    go through the write  statents  . one of that is below 
    Loop at itab .
    write  : itab  .
    endloop.
    if it is  ALV  then you have to  define an internal table which are the fieldds  you  want palce in the  Row .
    so  that  
    data  c type  i value    '1'.
    loop at  itab .
    fieldcatalog-fieldname   = itab-field.
    fieldcatalog-col_pos     = c.
    append fieldcatalog to fieldcatalog.
    clear  fieldcatalog
    c = c + 1.
    endloop.
    so that  the Col_pos  will be increased  and the  Column data will be moved into Row .
    reward  points if it is usefull...
    Girish

  • Parallel Port address out of range for output.vi

    Hi all,
    I know people have had this question before, but I don't seem to follow the responses.
    Basically, I have a Parallel Port connected through a PCI slot with the address BCC8, and I've been trying to talk to a stepper motor using output.vi, but as far as I can tell the address input is limited to I16 values.  Is there away to get around this?
    Hann

    Hi Hann,
    What forum postings have you been researching before posting? We need more information about your application, perhaps posting your code would be helping in resolving your issue. Are you using a particular LabVIEW toolkit like the LabVIEW Motion Control Tools or are you using VISA Read and Write functions?Where are you getting the output.vi? What version of LabVIEW are you using.
    Joshua B.
    National Instruments
    NI Services
    NI Support Resources
    NI Training Resources

  • MIssing Number Range

    Hi
    I need number range for between date wise. i use standard program 'RFBNUM00N' but this give whole year output. so i don't want i need date wise output
    thanks
    With Regards
    I.Muthukumar.

    Hi,
    Create the Number Range Object using SNRO tcode
    and define/maintain the number ranges for that object using SNUM tcode
    and then use the fun module NUMBER_GET_NEXT in the code to get the next continuous numbers for that field
    see the sample code
    CALL FUNCTION 'NUMBER_GET_NEXT'
    EXPORTING
    nr_range_nr = '01'
    object = 'ZDOCNUM'
    QUANTITY = '1'
    SUBOBJECT = ' '
    TOYEAR = '0000'
    IGNORE_BUFFER = ' '
    IMPORTING
    number = v_docno
    QUANTITY =
    RETURNCODE =
    EXCEPTIONS
    interval_not_found = 1
    number_range_not_intern = 2
    object_not_found = 3
    quantity_is_0 = 4
    quantity_is_not_1 = 5
    interval_overflow = 6
    buffer_overflow = 7
    OTHERS = 8.
    IF sy-subrc 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

  • Date Range Selection

    Dear friends,
    How to select the record from BSEG table between Date range. Please give me the solution . Am also try to find the solution in SDN also.
    select-options post_dt for bkpf-budat obligatory default sy-datum NO-EXTENSION.
    select belnr budat from bkpf into corresponding fields of table it_head
        where bukrs eq compcode
        and gjahr eq year
        and blart eq doctype
        and budat in post_dt
        order by belnr budat.
    For this select query is working in perfect for single date only. But i want to select the date date range wise.
    Thanks
    Saravanan R

    HI,
           U can check the Select Quert by using IN s_option.
    Like eg:--
        Select * form Zemp where empno in s_empno.
    Hope this example will help u...
    here Zemp is a table...... empno is a field     s_empno is a Select-option.
    Thanks and rEgards
    Suraj S Nair

  • [Bug?] In Range and Coerce Comparison Mode

    It seems that changing the Comparison Mode of the IR&C function with Arrays or Clusters attached does not trigger Type Propagation, or whatever is responsible for selecting the proper instance.  For example, if I wire up three arrays to the inputs of IR&C, change comparison mode to Compare Aggregates, then create an Indicator from the In Range? output, the result is the wrong indicator and a broken wire.  Likewise, I can change the mode on an IR&C function with a wired In Range? output and it will not break the wire until a later change triggers a recompile or type propagation.
    LV10 (not SP1) and Win7.
    Solved!
    Go to Solution.

    Hi Darin,
    As mentioned, that CAR refers specifically to clusters and the 'In Range?' boolean output of the In Range and Coerce function. The specific VI that showed the issue always had an In Range output of true for all elements of the cluster except the first. However, it is worth note that the Coerced results showed correct behavior, unbundling showed correct behavior, changing the numeric representation of the compared elements (even changing back to the original representation of U32) corrected the behavior, this error is fixed in LabVIEW 2011, and when I recreated the VI from scratchn in LabVIEW 2010 it behaved as expected.
    So, it is very unlikely that the error fixed in this CAR will impact your use of the In Range and Coerce function.
    Matt
    Product Owner - NI Community
    National Instruments

  • Creating age range

    Hi All,
    I am creating a technical specification document for below report. and as of now i dont have sandbox system
    age range  ,     no. employee as per age range  ,  No. of spouse as per age range.
    we are having 0age_range  and 0age  in standard cube 0PA_C01 .
    i have a doubt here if i create a calculated keyfigure for age of spouse using DOB add it in my cube and then in query designer if i drag age range in columns and age and spouse age in rows will i get age range wise number of employees and number of spouse ???
    Apoorva

    Yes you can do that. Here is an example from another thread. The chart is using the data in the "stacked bar chart" table which was derived from the raw data. The bars for the first series are formatted so they are invisible (no fill). You can simplify it somewhat if you don't need a median.

  • SFP output power control

    Hi, I can see from the spec of an SFP module it has a range of output power. How do i control that in the IOS or does it do it automatically based on rx power level?
    I know there is 'show interface tranceiver' to show me whats happening but not sure how to set anything.
    Any help appreciated.

    I agree with baileyshbr. One cannot generally control the SFP output (or sensitivity) via software. Optical platforms (e.g. ONS series) allow this, but that's one of the (many) reasons why they cost so much more than LAN switches.
    If field measurements indicate you are outside of accepatable operating ranges, you either need to attenuate (using readily available optical atenuation patch cables) or increase launch power (using an optical amplifier or different launching optics).
    You are correct that a given module's launch power should not have a 6 dB variability. It should actually vary within a much smaller range, due primarily to temperature of the components. So get some actual measurements of the ones) you install and then adjust accordingly if necessary.

  • General Ledger report with Op Bal , Trans Line Items and Closing Balance

    Hi Experts,
    My clients needs a General Ledger report which should show Opening balance and all transactions line items with closing figure in a single report for a fiscal year in the given date range wise. Can I get a report in standard sap. Waiting for your reply.
    Thanks in Advance,
    Arabinda Parida

    Hi Parida,
    There is no such report in SAP. Basically all standard report gives line items not with opening and closing balances. Anyway check mentioned transaction which may help to you.
    S_ALR_87012309....It is cash journal report. Anyway you can enter GL account get opening and closing balances with all relavent transactions.
    Regards
    Suma

  • SAP Standard report to view the asset balance- Based on the calender year

    Hi ALL
    Any sap standard programs are available to view the asset balance based on the calendar year not for the fiscal year. 
    Asset balance report S_ALR_87011964 will display based on the fiscal year in report date. For example I want to view the September month asset balance, Any standard report to view the calendar year wise output.
    Regards
    K.Gunasekar

    Dear Gunasekar,
    in Asset balance report S_ALR_87011964 you can view also a calendar year, you can enter every Reporting date in the progrm.
    In RABEWG_ALV01 you can enter also a Capitalization date "from to". I think this is what you want.
    regars Bernhard

  • No SDO Communication Using CAN over EtherCAT (CoE) with 3rd Party Slave

    Dear all
    We are trying to establish an EtherCAT communication between a cRIO 9024 as EtherCAT master with a 3rd party frequency comverter (bmaxx 4432) as EtherCAT slave. CanOPEN over EtherCAT is industry standard.
    The slave device has a CAN in Automation (CiA) configuration 402, i.e. motion and drives. Thus it has a well configured address range, input/output parameters and the like. The frequency converter remains in INIT mode and waits for a PDO definition, sent via an SDO communication. 
    In LabView, adding an EtherCAT master in the cRIO system works fine. Adding targets and devices on the configured EtherCAT master also works fine after we imported an XML description of our third party EtherCAT slave. LabView detects the slave type and the version correctly. Thus, there must already be a rudimentary EtherCAT communication working between LabView and our 3rd party slave.
    The problem is that we cannot establish a first SDO communication.
    Every description I found was about using CANopen on a CAN bus hardware (e.g. NI 9861) plugged into the cRIO. Descriptions concerning EtherCAT are usually concerning an NI cRIO 9144 extension as slave, which is not what we have.
    The NI CANopen library seems to definitely require the NI 9861.
    Is this correct?
    1)
    Either it should be possible to define a kind of virtual CAN port based on the EtherCAT port, on which we can write to and read from with the NI CANopen library. This would be the preferred solution so we can use the CANopen VIs.
    Is there a way to do this?
    2)
    Otherwise, there should be a possibility to establish a more basic SDO/PDO communication directly based on the EtherCAT interface.
    Are there any NMT/SDO/PDO VIs available to do the programming?
    Is there a manual document which would describe how to start the first communication setup via EtherCAT (CoE)?
    My sincere thanks for any advice you can give.
    Many cheers
     Markus

    Dear all,
    I'm trying to establish a connection between a cRIO9068 and a BM 3300 via CoE.
    I already had a hard time establishing a normal EtherCAT-connection.
    Finally I could set the Scan engine to active, and I was able to get from "ini" and  "pre operational" into "Safe operational" and "operational".
    As I can see, you had similar problems as I do.
    When I add my cRIO to my project (with the EterCAT-master)  I can look for the slave device, and add it to my project.
    Within this slave device, I can add two mods, as seen in the attachment.
    These slots should include all the parameters, the drive provides, but actually I only end up with some "position mode" -parameters, I think those are the SDO's.
    If I add these to a VI, the cRIO scan engine switches to configuration mode, but can't switch back to active mode.
    Actually, the Baumüller slave device should be able to provide multiple parameters for read and write.
    I can see them, wehn I go to "online device state" in the rightklick menu of the slave device (Parameter.png), but there's no way I can actually use them.
    I can't add these "slots" on every computer.
    On some computers it's possible, on some it isn't.
    Thanks for any advice, you can give.
    Yours sincerely
    Karl
    Attachments:
    slot 1.PNG ‏6 KB
    slot 2.PNG ‏9 KB
    Parameter.PNG ‏46 KB

  • Check box creation

    Hi Experts,
    i hae to create a check box for account assaignment default value ticked, ifit is ticked out put should come other wise output should not come
    could any one help me, account assaignment field is ekpo-knttp.
    i am giving the code below
    REPORT zmmr_po_spendreport NO STANDARD PAGE HEADING
           MESSAGE-ID zs.
    Program ID   :                                                      *
    Version      : 1.0                                                  *
    SAP Version  : R/3 System Ver. 4.6C                                 *
    Program Name : ZMMR_PO_SPENDREPORT                                  *
    Created by   : Venu Goli                                            *
    Created on   : 6/1/2007                                             *
    Description  : A Report on Direct and Indirect spend to find out    *
                    the lead time in PO and Invoice creation             *
    Tables
    TABLES: ekko,   "Purchasing Document Header
            ekpo,   "Purchasing Document Item
            rbkp.   "Document Header: Invoice Receipt
    Type-Pools
    TYPE-POOLS : slis.   " Has to be declared to use ALVs
    To hold ALV field catgory data
    DATA : it_fieldcat TYPE slis_t_fieldcat_alv,
           wa_fieldcat LIKE LINE OF it_fieldcat.
    Internal tables declarations
    Internal table to hold Report data
    DATA: BEGIN OF it_output OCCURS 0,
           dir_indir(9),
           bukrs LIKE ekko-bukrs,    "company code
           ebeln LIKE ekko-ebeln,    "Purchasing Document Number
           ebelp LIKE ekpo-ebelp,    "Item
           aedat LIKE ekko-aedat,    "Date on which the record was created
           belnr LIKE rseg-belnr,    "Accounting document number
           bldat LIKE rbkp-bldat,    "Document date in document
           budat LIKE rbkp-budat,    "Posting date in the document
           wrbtr LIKE rseg-wrbtr,    "Amount in document currency
           curr  LIKE t880-curr,     "Price unit (Local Curr)
           bednr LIKE ekpo-bednr,    "Requirement tracking number
           lifnr LIKE ekko-lifnr,    "Vendor's account number
           name1 LIKE lfa1-name1,                               "name1
           name2(30),                "preparer name
           name3(30),                "requester name
           gjahr LIKE rseg-gjahr,    "Fiscal year
           ernam LIKE ekko-ernam,    "Name of Person who Created the Object
           kursf LIKE rbkp-kursf,    "Exchange rate
           shkzg LIKE rseg-shkzg,    "Debit/credit indicator
           banfn LIKE ekpo-banfn,    "Purchase requisition number
           knttp LIKE ekpo-knttp,    "account assignment category
          END OF it_output.
    Selection Screen
    SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    PARAMETERS: p_bukrs LIKE ekko-bukrs OBLIGATORY,
                   kntpp AS CHECKBOX DEFAULT 'X'.
    SELECT-OPTIONS: s_invdat FOR rbkp-bldat,    "Document date in document
                    s_vendor FOR ekko-lifnr,    "Vendor's account number
                    s_purcdo FOR ekko-ebeln,    "Purchasing Document no
                    s_credat FOR ekko-aedat OBLIGATORY,"create date
                    s_plant  FOR ekpo-werks,    "Plant
                    s_doctyp FOR ekko-bsart,    "Purchasing document type
                    s_purorg FOR ekko-ekorg,    "Purchasing organization
                    s_trcnum FOR ekpo-bednr,    "Requirement tracking number
                    s_knttp  FOR ekpo-knttp.    "account assignment category
    SELECTION-SCREEN: END OF BLOCK b1.
    DATA: count TYPE i VALUE 0.            " Used to count records
              INITIALIZATION                                             *
    INITIALIZATION.
    At Selection Screen
    AT SELECTION-SCREEN.
    Checking for the input values of selection screen fields.
      PERFORM validate_params.
    Start Of Selection
    START-OF-SELECTION.
      PERFORM get_data.
    End Of Selection
    END-OF-SELECTION.
    SUBROUTINE TO CALL THE FUNCTION MERGE TO ENSURE PROPER DISPLAY.
      PERFORM merge_fieldcatalog.
      PERFORM modify_fieldcat.
      PERFORM alv_report.
          FORM validate_params                                          *
    FORM validate_params.
    Validate company code
      SELECT SINGLE COUNT(*) FROM t001 WHERE bukrs = p_bukrs.
      IF sy-subrc <> 0.
        MESSAGE e021 WITH 'Please enter a valid Company code'.
      ENDIF.
    *Validate Vendor.
      SELECT SINGLE COUNT(*) FROM lfa1 WHERE lifnr IN s_vendor.
      CASE sy-subrc.
        WHEN 0.
        WHEN OTHERS.
          MESSAGE e021 WITH 'Please enter a valid Vendor'.
      ENDCASE.
    *Validate PO doc type
      SELECT SINGLE COUNT(*) FROM t161 WHERE bsart IN s_doctyp.
      CASE sy-subrc.
        WHEN 0.
        WHEN OTHERS.
          MESSAGE e021 WITH 'Please enter a valid PO Doc. Type'.
      ENDCASE.
    *Validate plant
      SELECT SINGLE COUNT(*) FROM t001w WHERE werks IN s_plant.
      CASE sy-subrc.
        WHEN 0.
        WHEN OTHERS.
          MESSAGE e021 WITH 'Please enter a valid Plant. Type'.
      ENDCASE.
    *Validate Purch. Org
      SELECT SINGLE COUNT(*) FROM t024e WHERE ekorg IN s_purorg.
      CASE sy-subrc.
        WHEN 0.
        WHEN OTHERS.
          MESSAGE e021 WITH 'Please enter a valid Purch. Org.'.
      ENDCASE.
    ENDFORM.                               " PERFORM VALIDATE_PARAMS.
          FORM get_data                                                 *
    FORM get_data.
      DATA: l_persnumber LIKE usr21-persnumber.
    Get PO data
      SELECT a~bukrs a~ebeln b~ebelp a~aedat a~lifnr a~ernam
             b~knttp b~bednr b~banfn
             c~belnr c~wrbtr c~gjahr c~shkzg
             d~bldat d~budat d~kursf
             e~dir_indir
      INTO CORRESPONDING FIELDS OF TABLE it_output
      FROM ekko AS a
      JOIN ekpo AS b ON b~ebeln = a~ebeln
      JOIN rseg AS c ON c~ebeln = b~ebeln
                    AND c~ebelp = b~ebelp
                    AND c~bukrs = a~bukrs
      JOIN rbkp AS d ON d~belnr = c~belnr
                    AND d~gjahr = c~gjahr
      LEFT JOIN zpo_dirindir AS e ON e~knttp = b~knttp
      WHERE a~bukrs = p_bukrs
        AND a~lifnr IN s_vendor
        AND a~ebeln IN s_purcdo
        AND a~bsart IN s_doctyp
        AND a~ekorg IN s_purorg
        AND a~aedat IN s_credat
        AND b~knttp IN s_knttp
        AND b~werks IN s_plant
        AND b~bednr IN s_trcnum.
      LOOP AT it_output.
      Get posting date, Doc. date & Curr. Key
        IF it_output-kursf <> 0.
          it_output-wrbtr = it_output-wrbtr * it_output-kursf.
        ENDIF.
      get local currency
        SELECT SINGLE waers INTO it_output-curr FROM t001
                 WHERE bukrs = it_output-bukrs.
      Get vendor name.
        SELECT SINGLE name1 FROM lfa1 INTO it_output-name1
        WHERE lifnr = it_output-lifnr.
      Get PO created person name
        SELECT SINGLE persnumber INTO l_persnumber FROM usr21
         WHERE bname = it_output-ernam.
        IF sy-subrc = 0.
          SELECT SINGLE name_text FROM adrp INTO it_output-name2
           WHERE persnumber = l_persnumber.
        ELSE.
          it_output-name2 = it_output-ernam.
        ENDIF.
      Get get requested by from reciepent point in PO
      else PR created by (If PR exists)
        CASE it_output-dir_indir.
          WHEN 'I'.
          Take requested by from Reciepent point.
            SELECT SINGLE wempf INTO it_output-name3 FROM ekkn
             WHERE ebeln = it_output-ebeln
               AND ebelp = it_output-ebelp .
          WHEN 'D'.
            SELECT SINGLE ernam INTO it_output-name3 FROM eban
             WHERE banfn = it_output-banfn
               AND ebelp = it_output-ebelp.
            IF sy-subrc <> 0.
              MOVE it_output-ernam TO it_output-name3.
            ENDIF.
            SELECT SINGLE persnumber INTO l_persnumber FROM usr21
                WHERE bname = it_output-name3.
            IF sy-subrc = 0.
              SELECT SINGLE name_text FROM adrp INTO it_output-name3
               WHERE persnumber = l_persnumber.
            ENDIF.
        ENDCASE.
      translate direction indicator to Indirect or Direct
        CASE it_output-dir_indir.
          WHEN 'I'. it_output-dir_indir = 'Indirect'.
          WHEN 'D'. it_output-dir_indir = 'Direct'.
        ENDCASE.
        MODIFY it_output.
      ENDLOOP.
    ENDFORM.
    FORM MERGE_FIELDCATALOG                                             *
    FORM merge_fieldcatalog.
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
           EXPORTING
                i_program_name         = sy-cprog
                i_internal_tabname     = 'IT_OUTPUT'
                i_inclname             = sy-cprog
           CHANGING
                ct_fieldcat            = it_fieldcat[]
           EXCEPTIONS
                inconsistent_interface = 1
                program_error          = 2
                OTHERS                 = 3.
    ENDFORM. " MERGE_FIELDCATALOG
          FORM modify_fieldcat                                          *
    FORM modify_fieldcat.
      DATA: wa_fieldcat TYPE slis_fieldcat_alv.
      LOOP AT it_fieldcat INTO wa_fieldcat.
        CASE wa_fieldcat-fieldname.
          WHEN 'DIR_INDIR'.
            wa_fieldcat-seltext_m = 'Direct/Indirect'.
          WHEN 'NAME2'.
            wa_fieldcat-seltext_m = 'PREPARER NAME'.
          WHEN 'NAME3'.
            wa_fieldcat-seltext_m = 'REQUESTER NAME'.
          WHEN 'BEDNR'.
            wa_fieldcat-seltext_m = 'SSP PO'.
          WHEN 'AEDAT'.
            wa_fieldcat-seltext_m = 'PO DOCUMENT DATE'.
          WHEN 'BLDAT'.
            wa_fieldcat-seltext_m = 'INVOICE DOCU DATE'.
          WHEN 'BUDAT'.
            wa_fieldcat-seltext_m = 'POSTAGE DATE'.
          WHEN 'WRBTR'.
            wa_fieldcat-seltext_m = 'LOCAL AMOUNT'.
            wa_fieldcat-cfieldname = 'CURR'.
            wa_fieldcat-ctabname   =  wa_fieldcat-tabname.
          WHEN 'CURR'.
            wa_fieldcat-seltext_m = 'LOCAL CURR'.
          WHEN 'NAME1'.
            wa_fieldcat-seltext_m = 'VENDOR NAME'.
        ENDCASE.
        MODIFY it_fieldcat FROM wa_fieldcat.
      ENDLOOP.
    ENDFORM.
          FORM ALV_REPORT                                               *
    FORM alv_report.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                i_callback_program = sy-cprog
                it_fieldcat        = it_fieldcat[]
           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.

    REPORT zmmr_po_spendreport NO STANDARD PAGE HEADING
    MESSAGE-ID zs.
    Program ID : *
    Version : 1.0 *
    SAP Version : R/3 System Ver. 4.6C *
    Program Name : ZMMR_PO_SPENDREPORT *
    Created by : Venu Goli *
    Created on : 6/1/2007 *
    Description : A Report on Direct and Indirect spend to find out *
    the lead time in PO and Invoice creation *
    Tables
    TABLES: ekko, "Purchasing Document Header
    ekpo, "Purchasing Document Item
    rbkp. "Document Header: Invoice Receipt
    Type-Pools
    TYPE-POOLS : slis. " Has to be declared to use ALVs
    To hold ALV field catgory data
    DATA : it_fieldcat TYPE slis_t_fieldcat_alv,
    wa_fieldcat LIKE LINE OF it_fieldcat.
    Internal tables declarations
    Internal table to hold Report data
    DATA: BEGIN OF it_output OCCURS 0,
    dir_indir(9),
    bukrs LIKE ekko-bukrs, "company code
    ebeln LIKE ekko-ebeln, "Purchasing Document Number
    ebelp LIKE ekpo-ebelp, "Item
    aedat LIKE ekko-aedat, "Date on which the record was created
    belnr LIKE rseg-belnr, "Accounting document number
    bldat LIKE rbkp-bldat, "Document date in document
    budat LIKE rbkp-budat, "Posting date in the document
    wrbtr LIKE rseg-wrbtr, "Amount in document currency
    curr LIKE t880-curr, "Price unit (Local Curr)
    bednr LIKE ekpo-bednr, "Requirement tracking number
    lifnr LIKE ekko-lifnr, "Vendor's account number
    name1 LIKE lfa1-name1, "name1
    name2(30), "preparer name
    name3(30), "requester name
    gjahr LIKE rseg-gjahr, "Fiscal year
    ernam LIKE ekko-ernam, "Name of Person who Created the Object
    kursf LIKE rbkp-kursf, "Exchange rate
    shkzg LIKE rseg-shkzg, "Debit/credit indicator
    banfn LIKE ekpo-banfn, "Purchase requisition number
    knttp LIKE ekpo-knttp, "account assignment category
    END OF it_output.
    Selection Screen
    SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    PARAMETERS: p_bukrs LIKE ekko-bukrs OBLIGATORY,
    kntpp AS CHECKBOX DEFAULT 'X'.
    SELECT-OPTIONS: s_invdat FOR rbkp-bldat, "Document date in document
    s_vendor FOR ekko-lifnr, "Vendor's account number
    s_purcdo FOR ekko-ebeln, "Purchasing Document no
    s_credat FOR ekko-aedat OBLIGATORY,"create date
    s_plant FOR ekpo-werks, "Plant
    s_doctyp FOR ekko-bsart, "Purchasing document type
    s_purorg FOR ekko-ekorg, "Purchasing organization
    s_trcnum FOR ekpo-bednr, "Requirement tracking number
    s_knttp FOR ekpo-knttp. "account assignment category
    parameters : p_knntp as checkbox default 'X'.
    SELECTION-SCREEN: END OF BLOCK b1.
    DATA: count TYPE i VALUE 0. " Used to count records
    INITIALIZATION *
    INITIALIZATION.
    At Selection Screen
    AT SELECTION-SCREEN.
    Checking for the input values of selection screen fields.
    PERFORM validate_params.
    Start Of Selection
    START-OF-SELECTION.
    if p_knttp = 'X'.
    PERFORM get_data.
    else.
    message 'no output'.
    endif.
    End Of Selection
    END-OF-SELECTION.
    SUBROUTINE TO CALL THE FUNCTION MERGE TO ENSURE PROPER DISPLAY.
    PERFORM merge_fieldcatalog.
    PERFORM modify_fieldcat.
    PERFORM alv_report.
    FORM validate_params *
    FORM validate_params.
    Validate company code
    SELECT SINGLE COUNT(*) FROM t001 WHERE bukrs = p_bukrs.
    IF sy-subrc <> 0.
    MESSAGE e021 WITH 'Please enter a valid Company code'.
    ENDIF.
    *Validate Vendor.
    SELECT SINGLE COUNT(*) FROM lfa1 WHERE lifnr IN s_vendor.
    CASE sy-subrc.
    WHEN 0.
    WHEN OTHERS.
    MESSAGE e021 WITH 'Please enter a valid Vendor'.
    ENDCASE.
    *Validate PO doc type
    SELECT SINGLE COUNT(*) FROM t161 WHERE bsart IN s_doctyp.
    CASE sy-subrc.
    WHEN 0.
    WHEN OTHERS.
    MESSAGE e021 WITH 'Please enter a valid PO Doc. Type'.
    ENDCASE.
    *Validate plant
    SELECT SINGLE COUNT(*) FROM t001w WHERE werks IN s_plant.
    CASE sy-subrc.
    WHEN 0.
    WHEN OTHERS.
    MESSAGE e021 WITH 'Please enter a valid Plant. Type'.
    ENDCASE.
    *Validate Purch. Org
    SELECT SINGLE COUNT(*) FROM t024e WHERE ekorg IN s_purorg.
    CASE sy-subrc.
    WHEN 0.
    WHEN OTHERS.
    MESSAGE e021 WITH 'Please enter a valid Purch. Org.'.
    ENDCASE.
    ENDFORM. " PERFORM VALIDATE_PARAMS.
    FORM get_data *
    FORM get_data.
    DATA: l_persnumber LIKE usr21-persnumber.
    Get PO data
    SELECT a~bukrs a~ebeln b~ebelp a~aedat a~lifnr a~ernam
    b~knttp b~bednr b~banfn
    c~belnr c~wrbtr c~gjahr c~shkzg
    d~bldat d~budat d~kursf
    e~dir_indir
    INTO CORRESPONDING FIELDS OF TABLE it_output
    FROM ekko AS a
    JOIN ekpo AS b ON b~ebeln = a~ebeln
    JOIN rseg AS c ON c~ebeln = b~ebeln
    AND c~ebelp = b~ebelp
    AND c~bukrs = a~bukrs
    JOIN rbkp AS d ON d~belnr = c~belnr
    AND d~gjahr = c~gjahr
    LEFT JOIN zpo_dirindir AS e ON e~knttp = b~knttp
    WHERE a~bukrs = p_bukrs
    AND a~lifnr IN s_vendor
    AND a~ebeln IN s_purcdo
    AND a~bsart IN s_doctyp
    AND a~ekorg IN s_purorg
    AND a~aedat IN s_credat
    AND b~knttp IN s_knttp
    AND b~werks IN s_plant
    AND b~bednr IN s_trcnum.
    LOOP AT it_output.
    Get posting date, Doc. date & Curr. Key
    IF it_output-kursf <> 0.
    it_output-wrbtr = it_output-wrbtr * it_output-kursf.
    ENDIF.
    get local currency
    SELECT SINGLE waers INTO it_output-curr FROM t001
    WHERE bukrs = it_output-bukrs.
    Get vendor name.
    SELECT SINGLE name1 FROM lfa1 INTO it_output-name1
    WHERE lifnr = it_output-lifnr.
    Get PO created person name
    SELECT SINGLE persnumber INTO l_persnumber FROM usr21
    WHERE bname = it_output-ernam.
    IF sy-subrc = 0.
    SELECT SINGLE name_text FROM adrp INTO it_output-name2
    WHERE persnumber = l_persnumber.
    ELSE.
    it_output-name2 = it_output-ernam.
    ENDIF.
    Get get requested by from reciepent point in PO
    else PR created by (If PR exists)
    CASE it_output-dir_indir.
    WHEN 'I'.
    Take requested by from Reciepent point.
    SELECT SINGLE wempf INTO it_output-name3 FROM ekkn
    WHERE ebeln = it_output-ebeln
    AND ebelp = it_output-ebelp .
    WHEN 'D'.
    SELECT SINGLE ernam INTO it_output-name3 FROM eban
    WHERE banfn = it_output-banfn
    AND ebelp = it_output-ebelp.
    IF sy-subrc <> 0.
    MOVE it_output-ernam TO it_output-name3.
    ENDIF.
    SELECT SINGLE persnumber INTO l_persnumber FROM usr21
    WHERE bname = it_output-name3.
    IF sy-subrc = 0.
    SELECT SINGLE name_text FROM adrp INTO it_output-name3
    WHERE persnumber = l_persnumber.
    ENDIF.
    ENDCASE.
    translate direction indicator to Indirect or Direct
    CASE it_output-dir_indir.
    WHEN 'I'. it_output-dir_indir = 'Indirect'.
    WHEN 'D'. it_output-dir_indir = 'Direct'.
    ENDCASE.
    MODIFY it_output.
    ENDLOOP.
    ENDFORM.
    FORM MERGE_FIELDCATALOG *
    FORM merge_fieldcatalog.
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
    i_program_name = sy-cprog
    i_internal_tabname = 'IT_OUTPUT'
    i_inclname = sy-cprog
    CHANGING
    ct_fieldcat = it_fieldcat[]
    EXCEPTIONS
    inconsistent_interface = 1
    program_error = 2
    OTHERS = 3.
    ENDFORM. " MERGE_FIELDCATALOG
    FORM modify_fieldcat *
    FORM modify_fieldcat.
    DATA: wa_fieldcat TYPE slis_fieldcat_alv.
    LOOP AT it_fieldcat INTO wa_fieldcat.
    CASE wa_fieldcat-fieldname.
    WHEN 'DIR_INDIR'.
    wa_fieldcat-seltext_m = 'Direct/Indirect'.
    WHEN 'NAME2'.
    wa_fieldcat-seltext_m = 'PREPARER NAME'.
    WHEN 'NAME3'.
    wa_fieldcat-seltext_m = 'REQUESTER NAME'.
    WHEN 'BEDNR'.
    wa_fieldcat-seltext_m = 'SSP PO'.
    WHEN 'AEDAT'.
    wa_fieldcat-seltext_m = 'PO DOCUMENT DATE'.
    WHEN 'BLDAT'.
    wa_fieldcat-seltext_m = 'INVOICE DOCU DATE'.
    WHEN 'BUDAT'.
    wa_fieldcat-seltext_m = 'POSTAGE DATE'.
    WHEN 'WRBTR'.
    wa_fieldcat-seltext_m = 'LOCAL AMOUNT'.
    wa_fieldcat-cfieldname = 'CURR'.
    wa_fieldcat-ctabname = wa_fieldcat-tabname.
    WHEN 'CURR'.
    wa_fieldcat-seltext_m = 'LOCAL CURR'.
    WHEN 'NAME1'.
    wa_fieldcat-seltext_m = 'VENDOR NAME'.
    ENDCASE.
    MODIFY it_fieldcat FROM wa_fieldcat.
    ENDLOOP.
    ENDFORM.
    FORM ALV_REPORT *
    FORM alv_report.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    i_callback_program = sy-cprog
    it_fieldcat = it_fieldcat[]
    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.

  • J1INCERT sectionwise vendor report not accessible

    Hi,
    In J1inCERT, Printing Withholding Tax Certificate for Vendor when i run it for same vendor with same dates for different sections (194c,194j,....etc) i am getting the same output. I want section wise output in printing. What are settings missing ? Is it 'TDS Section Maintenance' & 'Assign TDS Section to Tax Codes' IMG nodes or i need to check in Vendor Master also?
    Abhijit.
    Edited by: Abhijit on Jul 28, 2009 3:38 AM

    Hi,
    Swati.
    As per Anuj said if you directly go for print the system will generate certificate number. But if you see the print preview
    system will neither generate certificate number nor update the values for same.
    Tell me one thing for any special purpose are you using Z program for J1INCERT ?
    If it so problem may arise because of that too. Earlier in my case I have gone through the same case.
    Check your settings in SM30.
    Is it for all sections or vendor or for particular ?
    For further clarification please revert so other consultants also can contribute their valuable suggestions.
    Regards,
    Pankaj.

  • Report experience

    Hi, xperts
    I really got good knowledge from SDN .
    I am very thank full to all guys, who believe to share our though and to help.
    Creating report on infoset,
    Selection screen having fields
    1 – Vendor (range)
    2 – Company code
    3 – Profit Center (range)
    4 – Posting date (range)
    Want output field.
    1-     Opening balance.
    2-      Period balance in 0-30, 30-60, 60-90, 90-365 (days total 4 column) .
    3-     Vendor
    Opening balance column --- need balance amount (I have) of vendor, till the previous date of postig date(low value) in variable.
    Period balance—
    This should come according to given posting date for report.

    Examples you can use
    Variable of key date
    CKF1 total balance 0-30 open = RKF1 balance 0-30 open + RKF2 balance 0-30 cleared
    RKF1 item status = 0 posting date <= key date 0deb_cre_amt_lc. due date between key date and key date +30 (in the variable offset)
    RKF2 cleared date > key date, 0deb_cre_amt_lc, due date between key date and key date +30 (in the variable offset) posting date <= key date
    Then repeat for the rest of the aging but change the variable offsets (you end up with quite a few CKFs and RKFs)
    Take some time to go through the above example to really understand what is going on - then it will become clear what is happening
    BTW - I don;t think you are going to see profit centres - as the AR4 shouldn;t contain the proft centre as that is a revenue.cost posting (ie the opposite side of the FI jnl)
    ie one AP posting can have multiple profit centres on them
    And what are you going to do about partially allocated/referenced items? ie credit notes or accounting journals
    Not a good idea to have a posting date range
    What I would do with this is to split it up into two queries - one an aged creditor and the other a Vendor turnover by profit centre

Maybe you are looking for