How to handle the ref cursor which is returning "no rows"

I have written a function which is returning the REF CURSOR. But in one situation the REF CURSOR returns "no rows selected". To handle this situation an exception is raised "when no data found". But i dont know in this situation how should NULL cursor be returned through this function. Since I want to call this function in another procedure so something should be returned through this function by means of ref cursor. But since i am not able to handle this "no rows selected" situation i am not able move further.
Thanks in advance........

I agree.
You would simply process the returned ref cursor irrespective of any rows actually returned in the cursor or not. You would be able to do at least one FETCH from the cursor (even if it does not actually contain any rows) and then determine the %NOTFOUND status to do the rest of the processing.
SQL> variable cur refcursor
SQL> exec open :cur for select * from scott.emp where rownum = 1 ;
PL/SQL procedure successfully completed.
SQL> print cur
     EMPNO ENAME      JOB              MGR HIREDATE           SAL       COMM     DEPTNO
      7369 SMITH      CLERK           7902 17-DEC-1980        800                    20
1 row selected.
SQL>
SQL> exec open :cur for select * from scott.emp where 1 = 2 ;
PL/SQL procedure successfully completed.
SQL> print cur
no rows selected
SQL>
SQL> SET SERVEROUTPUT ON
SQL> DECLARE
  2      rec scott.emp%ROWTYPE;
  3      bol BOOLEAN;
  4      cur sys_refcursor;
  5  BEGIN
  6      OPEN cur FOR
  7          SELECT * FROM scott.emp WHERE 1 = 2; /* assume this is your function call returning a ref cursor */
  8      bol := FALSE;
  9      LOOP
10          FETCH cur
11              INTO rec;
12          EXIT WHEN cur%NOTFOUND;
13          --
14          -- process the data here
15          --
16          bol := TRUE;
17      END LOOP;
18      CLOSE cur;
19      IF (bol)
20      THEN
21          dbms_output.put_line('At least one row was found');
22      ELSE
23          dbms_output.put_line('No rows were selected');
24      END IF;
25  END;
26  /
No rows were selected
PL/SQL procedure successfully completed.
SQL>

Similar Messages

  • How to handle empty  ref cursor

    when my ref cursor is empty how do i prevent null pointer exception
    Thanks

    What are you doing now? Do something else.

  • How to handle the word document which is already opened(Add content to it) using VbScript using "Word.Application" method

    Hello,
    I want to add some content to the word document which is opened already and active using vbscript.
    Here is the sample code to have an idea.Kindly Help.
    Set oWord = CreateObject("Word.Application")
    oWord.Documents.Open
    "c:\test.docx" ----->Here i dont want to open the Document as such as my document which is opened already,i have get the control over that document-I try to achive this by using HP UFT tool for word document automation
    oWord.Selection.EndKey
    6,0
    oWord.Selection.TypeText
    " This text has been entered by opening the exisitng document. "
    oWord.ActiveDocument.Save
    oWord.Quit
    Set oWord = Nothing

    Hello,
    Nice to see the Reply from you. I have done the same thing what you have suggested but unfortunately i am not achieving the result as expected.
    Here i explain you clearly,
    Business Scenario:
    Using an aplication we will create word documents-To do this we need to fill all the document properties and click on OK button-After this,Application automatically launches a Word Document with the File name given by itself as per the Configuration and
    it will be available for the Editing-After user add content,he has to check in the document in the application in order to replicate the changes made by user to the document-This is the Business process
    Here my Document actually resides in the Users Folder-"C:\Users\narayanasamy_r\Documentum\Checkout\" before checkin event happened,once i add content,save,close the document,i will navigate to the document in the application  and Do check-in
    operation.
    Interesting point is that,after i do check-in operation my actual document which was resided in "C:\Users\narayanasamy_r\Documentum\Checkout\" will not be available anymore
    So My logic Should be,
    1.identify that particular Document from the Folder and add content,save and close(Note:i dont want to open the document from "word.application" control here, as the application itself opens up the Document)
    Kindly Help On the same.
    Thanks,
    Narayan

  • How to print/store in file the ref cursor in pl/sql block ?

    How to print/store in file the ref cursor in pl/sql block ?.

    How to print/store in file the ref cursor in pl/sql block ?.You question is quite confusing?
    So, i'm providing link in this manner.
    For RefCursor,
    http://www.oracle-base.com/articles/misc/UsingRefCursorsToReturnRecordsets.php
    http://www.oracle.com/technology/oramag/code/tips2003/042003.html
    For UTL_FILE,
    http://www.morganslibrary.org/reference/utl_file.html
    Regards.
    Satyaki De.
    Updated with new morgan library link.
    Edited by: Satyaki_De on Feb 24, 2010 9:03 PM

  • How to get the current cursor position in word report?

    I am generating a word report. But I would like to keep the table in one page. However, I did not find the way to do it in labview. Somebody would give me some suggestions? I appreciate a lot.
    One way I think I can do is to find the current cursor position. Since I know the table size so I can figure out if the left space in the current page is enough to hold the table. But I do not know how to locate the curent cursor position in word document in labview programmatically. I appreciate any suggestions on this question.
    Thanks.

    Hi,
    when you insert data in a word document you have to refer to bookmarks rather than cursor position.
    If you are using the Report Generation Toolkit for Office it is explained in the manual chapter 3-1.
    See also the example: Generate Report From Template (Word).vi included in the toolkit.
    If you aren't using the toolkit, you still have to refer to bookmark as reference points to insert and/or fetch data.
    The principle is:
    - First create a document in which you insert bookmarks where you wish and save it as a template
    - In LV open your template document and insert in it your data referring to bookmarks as insertion points
    - At the end save your report with another name, so you still have the template
    I hope I have been clear enough, if not just as
    k!
    Good luck,
    Alberto

  • How to specify the directory in which we want to store the uploaded files

    Hello !!
    I am using apache commonfile upload for uploading my files.I followed the user guide and tried to run a program,but my problem is I am not able to understand as to how to mention the directory in which the uploaded file will be saved..My code is given below :
    package r;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.sql.*;
    import java.util.*;
    import org.apache.commons.fileupload.*;
    import org.apache.commons.fileupload.servlet.*;
    import org.apache.commons.fileupload.disk.*;
    import org.apache.commons.io.*;
    import java.lang.Exception;
    public class fileupload extends HttpServlet
         public void doGet(HttpServletRequest request,HttpServletResponse response)throws IOException,ServletException
                   // Check that we have a file upload request
                  boolean isMultipart = ServletFileUpload.isMultipartContent(request);
                 System.out.println(isMultipart);
                 if (ServletFileUpload.isMultipartContent(request))
                 // Create a factory for disk-based file items
                   FileItemFactory factory = new DiskFileItemFactory();
                   // Create a new file upload handler
                   ServletFileUpload upload = new ServletFileUpload(factory);
                   // Parse the request
                   try {
                               List items= upload.parseRequest(request);               
                             Iterator iter = items.iterator();
                             while (iter.hasNext())
                                   FileItem item = (FileItem) iter.next();                    
                                 if (item.isFormField()) //NORMAL FORM FIELD
                                 String name = item.getFieldName();
                                  String value = item.getString();
                                  System.out.println(value);                                                             
                                  else
                                 String fileName = item.getName();
                                 System.out.println(fileName);
                                    String contentType = item.getContentType();
                                  File saveTo = new File("/info/upload_files/myFile.jpeg");
                             try
                                       item.write(saveTo);
                                       System.out.println("File written" );                    
                             catch(Exception e)
                                         System.out.println("File not written");
                                   // InputStream fs= item.getInputStream();                    
                                   fileName = FilenameUtils.getName(fileName);
                                    System.out.println(fileName);
                        }//end of try
              catch (Exception e) { }
         public void doPost(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException
                 doGet(request,response);
    The problem is that the control doesn't reach the try statement and I get " File not written" on the console because it enters catch everytime..Please tell me how the path to the directory should be given...Rest of the code is working fine

    No, the problem is that when an Exception is thrown, you ignore it completely and throw away all the information associated with it. That leaves you to guess at what the problem is. So instead of answering your guess at a good question, I'm going to suggest that in all of your catch blocks you put this code:e.printStackTrace();Then you can look at the output in the log file and see what the problem is. Start from there.

  • How to handle the control records in case of file to idoc scenario.

    Hi All,
    can you please clarify me how to handle the control records in case of file to idoc scenario.

    Hi,
    In File to Idoc scenario even though you selected apply control record values from payload and you are not getting those correct values which you have provided in the mapping.
    Also check the checkboxes Take sender from payload and Take receiver from payload along with the Apply control record values from payload checkbox
    Regards
    Seshagiri

  • How to handle the extended vo in the extended controller

    Hi,
    I want to know how to handle the extended vo attributes in the extended controller.
    I extended CompetenceElementsVO as 'CompetenceElementsEx' with 2 transient attributes called col1 and col2.
    Here i want to pass value according based on some condition. for this i want to know how to handle these attributes.
    I tried by using the extended vo name in the controller, if i use means then it is throwing error after the extended controller is implemented.
    Same time if i try to refer this attributes from the original vo definition, jdev itself showing error.
    please tell me how to handle this?
    Thanks in advance,
    SAN

    Hi San,
    You have to extend the controller where your region is associated with,
    And in that controller you get the AM(if there is more than one AM and your VO is associated with a child AM, first you have to get your required AM) and then
    get the ViewObject(standard).
    Then you should be able to get your newly added attributes.
    Please find the below sample code to get the AM handle and VO from there, update the code according to your requirement,
         Get all the VOs under the Root AM
         writeLog(pageContext, "Room AM"+ pageContext.getRootApplicationModule());
    String[] rootViewNames = pageContext.getRootApplicationModule().getViewObjectNames();
    /* writeLog(pageContext," Length of the VOs from Rootm AM "+rootViewNames.length);
    for (int j =0 ;j<rootViewNames.length ;j++ )
    writeLog(pageContext,j +" Value "+rootViewNames[j]);
         // Get requested AM from Root am
    public OAApplicationModule getRequestedAM(OAPageContext pageContext, String requestedAMName)
    writeLog(pageContext,"Requested AM called to check the AM "+requestedAMName );
    String amName = "";
    String objectivesAMName = requestedAMName;//"ObjectivesAM";
    String nestedAMArray[] = pageContext.getRootApplicationModule().getApplicationModuleNames();
    pageContext.writeDiagnostics(this,"Root AM=>"+pageContext.getRootApplicationModule().getName() + " Child AMs=>"+ nestedAMArray.length,1);
    OAApplicationModule currentAM = null;
    currentAM = (OAApplicationModule)pageContext.getRootApplicationModule();
    for(int i = 0; i < nestedAMArray.length; i++)
    amName = nestedAMArray;
    pageContext.writeDiagnostics(this,"Nested AM Name=>"+amName + "and amName.indexOf(objectivesAMName) "+amName.indexOf(objectivesAMName),1);
    currentAM = (OAApplicationModule)pageContext.getRootApplicationModule().findApplicationModule(amName);
                        //Get the view names
                   String[] viewNames = currentAM.getViewObjectNames();
    for (int i =0 ;i<viewNames.length ;i++ )
    writeLog(pageContext,i +" Value "+viewNames[i]);
    if(!(amName.indexOf(objectivesAMName)==-1))
    pageContext.writeDiagnostics(this,"Found Handle to My Nested AM " + amName ,1);
    break;
    return currentAM;
    Get the VO from the AM
    OAViewObject objAssessmentVO = (OAViewObject)yourAM.findViewObject("yourVO");
    Thanks.
    With Regards,
    Kali.
    OSSi.

  • How to handle the call transaction in method of a custom business object

    Hello all,
    There is a custom report " RPTCORAPP" for approving leaves . As per my requirement i have develop a copy of leave workflow and for approval process i have call  "RPTCORAPP" in Custom method of custom object. i have made a transaction for this custom report for approving attendances. I am calling this method though call transaction statement within method.
    Problem: while approving the attendance workitem is not disappearing from the portal. Problem is due to call transaction statement.
                   once workitem come to the user, user click on it. control goes to the report, which display all the leave to approve on
                   the portal.
                   If after approving/ rejecting attendance user close the screen.workflow remain in the "process" status.Control wont come  back after call transaction statement in the method.
                 At the same time if user clicks on back button inspite of closing the screen. it is working fine. workitem disappears from the portal.
    How to handle the scenarion. if after approving/rejecting, i want the control to come back to the NEXT STATEMENT after call transactionstatement in my method.
    Please help it out........:)

    Hi swami,
    thanks for reply. but i am not using BDC in my method. iam just calling a custom transaction thriugh statement
    Call transaction 'ZHR_APPROVE_CLINOUT'. This transaction directly run the report RPTCORAPP and display all the request.

  • How to handle the #error in ssrs expression

    hi 
    Please any one help me to resolve this #error ,
    I have a calculated filed in that expression i given a if condition like below 
    data of column is coming like this 0 , 0.0 
    =IIF(Fields!Column1.Value=0,0,((Fields!Column2.Value - Fields!Column1.Value)/( Fields!Column1.Value)))
    how to handle the #error 
    Please let me know any one 

    Hi deepuk23,
    According to your description, when you use the IIF() function in the report you got some error,right?
    The issue can be caused by the column1 and column2 have different datatype, I assumed that one is integer and another is float, when the Column1 is 0 or null,  because IIF() function always evaluates both the true part and the false part, even
    though it returns only one of them, it will throw out the error. 
    To resolve the issue, you should use a nested IIF() function to avoid the zero-divisor in any rate like below:
    =IIF(Fields!Column1.Value=0,0,((Fields!Column2.Value - Fields!Column1.Value)/(IIF(Fields!Column1.Value=0,1,Fields!Column1.Value))))
    For more information, please refer to this article:
    FAQ: Why does the “Attempted to divide by zero” error still happen?
    If you still have any problem, please feel free to ask.
    Regards,
    Vicky Liu
    Vicky Liu
    TechNet Community Support

  • Want to manipulate the ref cursor

    Hi,
    iam having a procedure whiuch returns a ref cursor as a output parameter having 20 columns.
    i had to manipulate only 2 columns in that ref cursor output in another calling procedure.
    iam getting an error when iam fetching the ref cursor result into only 2 variables.
    How can i achieve this ?

    Why?
    Let's see it ->
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    Elapsed: 00:00:00.18
    satyaki>
    satyaki>create or replace procedure r_gen_arg(
      2                                         choice in number,
      3                                         b in out sys_refcursor
      4                                       )
      5  is  
      6    str   varchar2(500);
      7  begin   
      8    if choice = 1 then      
      9        str := 'select * from emp';   
    10    elsif choice = 2 then      
    11      str := 'select * from dept';   
    12    end if;       
    13   
    14    open b for str;
    15  exception  
    16    when others then     
    17      dbms_output.put_line(sqlerrm);
    18  end;
    19  /
    Procedure created.
    Elapsed: 00:00:04.51
    satyaki>
    satyaki>
    satyaki>declare   
      2    rec_x emp%rowtype;   
      3    rec_y dept%rowtype;       
      4    w sys_refcursor;
      5  begin  
      6    dbms_output.enable(1000000);  
      7    r_gen_arg(1,w);  
      8    loop    
      9      fetch w into rec_x;     
    10        exit when w%notfound;             
    11        dbms_output.put_line('Employee No: '||rec_x.empno||' - '||                          
    12                             'Name: '||rec_x.ename||' - '||                          
    13                             'Job: '||rec_x.job||' - '||                          
    14                             'Manager: '||rec_x.mgr||' - '||                          
    15                             'Joining Date: '||rec_x.hiredate||' - '||                          
    16                             'Salary: '||rec_x.sal||' - '||                          
    17                             'Commission: '||rec_x.comm||' - '||                          
    18                             'Department No: '||rec_x.deptno);  
    19     end loop;  
    20     close w;    
    21    
    22     r_gen_arg(2,w);  
    23     loop    
    24       fetch w into rec_y;
    25        exit when w%notfound;            
    26        dbms_output.put_line('Department No: '||rec_y.deptno||' - '||                           
    27                             'Name: '||rec_y.dname||' - '||                           
    28                             'Location: '||rec_y.loc);  
    29     end loop;  
    30     close w;
    31  exception  
    32    when others then    
    33       dbms_output.put_line(sqlerrm);
    34  end;
    35  /
    Employee No: 9999 - Name: SATYAKI - Job: SLS - Manager: 7698 - Joining Date: 02-NOV-08 - Salary: 55000 - Commission: 3455 - Department No: 10
    Employee No: 7777 - Name: SOURAV - Job: SLS - Manager:  - Joining Date: 14-SEP-08 - Salary: 45000 - Commission: 3400 - Department No: 10
    Employee No: 7521 - Name: WARD - Job: SALESMAN - Manager: 7698 - Joining Date: 22-FEB-81 - Salary: 1250 - Commission: 500 - Department No: 30
    Employee No: 7566 - Name: JONES - Job: MANAGER - Manager: 7839 - Joining Date: 02-APR-81 - Salary: 2975 - Commission:  - Department No: 20
    Employee No: 7654 - Name: MARTIN - Job: SALESMAN - Manager: 7698 - Joining Date: 28-SEP-81 - Salary: 1250 - Commission: 1400 - Department No: 30
    Employee No: 7698 - Name: BLAKE - Job: MANAGER - Manager: 7839 - Joining Date: 01-MAY-81 - Salary: 2850 - Commission:  - Department No: 30
    Employee No: 7782 - Name: CLARK - Job: MANAGER - Manager: 7839 - Joining Date: 09-JUN-81 - Salary: 4450 - Commission:  - Department No: 10
    Employee No: 7788 - Name: SCOTT - Job: ANALYST - Manager: 7566 - Joining Date: 19-APR-87 - Salary: 3000 - Commission:  - Department No: 20
    Employee No: 7839 - Name: KING - Job: PRESIDENT - Manager:  - Joining Date: 17-NOV-81 - Salary: 7000 - Commission:  - Department No: 10
    Employee No: 7844 - Name: TURNER - Job: SALESMAN - Manager: 7698 - Joining Date: 08-SEP-81 - Salary: 1500 - Commission: 0 - Department No: 30
    Employee No: 7876 - Name: ADAMS - Job: CLERK - Manager: 7788 - Joining Date: 23-MAY-87 - Salary: 1100 - Commission:  - Department No: 20
    Employee No: 7900 - Name: JAMES - Job: CLERK - Manager: 7698 - Joining Date: 03-DEC-81 - Salary: 950 - Commission:  - Department No: 30
    Employee No: 7902 - Name: FORD - Job: ANALYST - Manager: 7566 - Joining Date: 03-DEC-81 - Salary: 3000 - Commission:  - Department No: 20
    Department No: 10 - Name: ACCOUNTING - Location: NEW YORK
    Department No: 20 - Name: RESEARCH - Location: DALLAS
    Department No: 30 - Name: SALES - Location: CHICAGO
    Department No: 40 - Name: LOGISTICS - Location: CHICAGO
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.85
    satyaki>
    satyaki>Here, i don't have to use separate variable to hold those required value.
    Regards.
    Satyaki De.

  • How to handle the Timestamp datasource while migration

    Hi All
    " I tried searching the forum,but didnt get the relevant one,hence posting this question".
    While migration from 4.7 to ECC in R/3 system,
    how to handle the Timestamp datasources( especially FI like COPA and other ) while extarcting the data from source to BW during source system migration.Since we need to empty the delta queue and should make sure that there are no delta records exists in delta queue.
    Like for sales datasources using LO,we will be executing the V3 jobs for execting the LUW's from LBWQ to RSA7?  In the same way is there any particular way for this also.
    Anyone whi knows abt this pls share your views
    Regards
    Shankar

    Hello Shankar.
    Before the upgrade (import of a queue), all extraction queues and open
    update orders in all clients must be processed. The content of the setup
    tables must be deleted. To avoid problems during the upgrade or to
    correct them, carry out the following steps:
    1. Call transaction SMQ1 and check whether all queues in all clients
    (client = '', queue name 'MCEX') have been processed. To process the
    queues, start the collective run report for each application in the
    displayed clients. If you no longer need the data in the BW system,
    deactivate the relevant extraction queues and DataSource in the LO
    cockpit (transaction LBWE) and delete the queue entries in transaction
    SMQ1.
    2. If you use the V3 update that is not serialized (usually only for
    application 03): Start collective run report RMBWV303. Then check the
    update orders in transaction SM13. If there are incorrect update orders
    in transaction SM13, correct the orders and then start the collective
    run report again. If you no longer require the update orders, you can
    delete them. There may be inconsistencies between tables VBMOD and
    VBHDR. For further information about this, see Notes 652310 and 67014.
    3. Before the upgrade, delete the contents of the setup tables. Execute
    report RMCEX_SETUP_ENTRIES to find out which setup tables still contain
    entries. You can use transaction LBWG to delete the contents of the
    setup tables for all clients.
    Unfortunately the check that the system carries out during the upgrade
    or when you import a Support Package does not display all affected
    applications. Therefore, Note 1083709 provides a check report that you
    can use to determine all affected applications and tables or queues.
    More detailed information please check these following notes:
    1083709-Error when you import Support Packages
    1081287-Data extraction orders block the upgrade process
    I hope I can be helpful.
    Thanks,
    Walter Oliveira.

  • How to handle the contents of a carousel

    Hi,all
    Now I have a trouble in how to handle the contents of a carousel.
    I use codes below:
              locator=(PMTElementaryStream es).getDvbLocator();
              serviceDomain.attach(locator);
              dsmccObject=new DSMCCObject(serviceDomain.getMountPoint().toString());
              file=new File(serviceDomain.getMountPoint().toString());
              content= file.list();
    to get some file or directories, such as *.png, *.class, *.mpg, xml, MHPdataloader, sport, and so on.
    How can I do for next procedure.
    Thank you.

    What do you want to do next? You can create a DSMCCObject that refers to one of the files in your carousel, and use this to control the loading and caching of that file. To actually read a file, however, you will need to create a FileInputStream or RandomAccessFile that refers to that file. You can then use this like any other file access.
    This may help you:
    // create a new ServiceDomain object to represent
    // the carousel we will use
    ServiceDomain carousel = new ServiceDomain();
    // now create a Locator that refers to the service
    // that contains our carousel
    org.davic.net.Locator locator;
    locator = new org.davic.net.Locator
      ("dvb://123.456.789");
    // finally, attach the carousel to the ServiceDomain
    // object (i.e. mount it) so that we can actually
    // access the carousel.  In this case, we don't specify
    // the stream containing the carousel in the locator, so
    // we pass in the carousel ID as part of the attach
    // request
    carousel.attach(locator, 1);
    // we have to create our DSMCCObject with an absolute
    // path name, which means we need to get the mount point
    // for the service domain
    DSMCCObject dsmccObj;
    dsmccObj = new DSMCCObject(carousel.getMountPoint(),
      "graphics/image1.jpg");
    // now we create a FileInputStream instance to access
    // our DSM-CC object.  Alternatively, we could create
    // a RandomAccessFile instance if we wanted random
    // instead of sequential access to the file.
    FileInputStream inputStream;
    inputStream = new FileInputStream(dsmccObj);
    // we can now use the FileInputStream just like any
    // other FileInputStream

  • How to handle the messages.

    Hi,
    I am doing interactive report. In that how to handle the error meesages.
    Regards
    Srinu

    HI
    IF YOU WANT HANDLE THE ERROE MESSAGES
    *& Report  ZNNR_REPORT
    REPORT  ZNNR_REPORT NO STANDARD PAGE HEADING <b>MESSAGE-ID ZNNR</b> LINE-SIZE 100 LINE-COUNT 65(4).
    ******DATA DECLARATIONS**********
    DATA : BEGIN OF IT_PLANT OCCURS 0,
            MATNR LIKE MARA-MATNR,
            WERKS LIKE MARC-WERKS,
            PSTAT LIKE MARC-PSTAT,
            EKGRP LIKE MARC-EKGRP,
           END OF IT_PLANT.
    DATA : BEGIN OF IT_PONO OCCURS 0,
            EBELN LIKE EKKO-EBELN,
            EBELP LIKE EKPO-EBELP,
            MATNR LIKE EKPO-MATNR,
            WERKS LIKE EKPO-WERKS,
            LGORT LIKE EKPO-LGORT,
           END OF IT_PONO.
    TABLES EKKO.
    ********END OF DATA DECLARATIONS*********
    ********SELECTION SCREEN DESIGN ***********
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    PARAMETER : P_WERKS LIKE MARC-WERKS MODIF ID S1.
    SELECT-OPTIONS : S_EBELN FOR EKKO-EBELN NO INTERVALS MODIF ID S2.
    SELECTION-SCREEN END OF BLOCK B1.
    SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-004.
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS : R1 RADIOBUTTON GROUP G1 DEFAULT 'X'.
    SELECTION-SCREEN COMMENT 5(20) TEXT-002 FOR FIELD R1.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS : R2 RADIOBUTTON GROUP G1.
    SELECTION-SCREEN COMMENT 5(20) TEXT-003 FOR FIELD R2.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END OF BLOCK B2.
    ******END OF SELECTION SCREEN DESIGN****************
    *********INITIALIZATION OF SELECTION SCREEN ELEMENTS.*****
    INITIALIZATION.
    P_WERKS = '1000'.
    S_EBELN-LOW = '4500016926'.
    S_EBELN-OPTION = 'EQ'.
    S_EBELN-SIGN = 'I'.
    APPEND S_EBELN.
    CLEAR S_EBELN.
    ************END OF INITIALIZATION***********************
    ***********SCREEN MODIFICATIONS*******************
    AT SELECTION-SCREEN OUTPUT.
      LOOP AT SCREEN.
        IF R1 EQ 'X' AND SCREEN-GROUP1 EQ 'S2'.
          SCREEN-INPUT = 0.
          MODIFY SCREEN.
        ENDIF.
        IF R2 EQ 'X' AND SCREEN-GROUP1 EQ 'S1'.
          SCREEN-INPUT = 0.
          MODIFY SCREEN.
        ENDIF.
      ENDLOOP.
    ********END OF SCREEN MODIFICATIONS*****************
    ***************SCREEN VALIDATIONS *****************
    at selection-screen.
      SELECT SINGLE *
               FROM EKKO
               INTO EKKO
               WHERE EBELN IN S_EBELN.
      IF SY-SUBRC <> 0.
        SET CURSOR FIELD 'S_EBELN-LOW'.
        <b>MESSAGE E999 WITH TEXT-005</b>.
      ENDIF.
    ********end of screen validation*****************
    START-OF-SELECTION.
    *set pf-status '100'.
      IF R1 EQ 'X'.
        SELECT MATNR
               WERKS
               PSTAT
               EKGRP
           FROM MARC
           INTO TABLE IT_PLANT
           WHERE WERKS = P_WERKS.
        LOOP AT IT_PLANT.
          WRITE : SY-VLINE , 2 IT_PLANT-MATNR COLOR COL_KEY,
                 21 SY-VLINE , 22  IT_PLANT-WERKS COLOR COL_KEY,
                 27 SY-VLINE ,28 IT_PLANT-PSTAT COLOR COL_NORMAL,
                 43 SY-VLINE ,44 IT_PLANT-EKGRP COLOR COL_NORMAL.
        ENDLOOP.
      ENDIF.
      IF R2 EQ 'X'.
        SELECT EBELN EBELP MATNR WERKS LGORT
               FROM EKPO
               INTO TABLE IT_PONO
               WHERE EBELN IN S_EBELN.
        LOOP AT IT_PONO.
          WRITE : SY-VLINE , 2 IT_PONO-EBELN COLOR COL_KEY,
                 12 SY-VLINE , 13 IT_PONO-EBELP COLOR COL_KEY,
                 18 SY-VLINE , 19 IT_PONO-MATNR COLOR COL_NORMAL,
                 37 SY-VLINE , 38 IT_PONO-WERKS COLOR COL_NORMAL,
                 44 SY-VLINE , 45 IT_PONO-LGORT COLOR COL_NORMAL, 49 SY-VLINE..
        ENDLOOP.
      ENDIF.
    TOP-OF-PAGE.
      IF R1 EQ 'X'.
    *ULINE AT /1(48).
        WRITE : SY-VLINE ,2 'MATERIAL NUMBER',
                21 SY-VLINE , 22 'PLANT',
                27 SY-VLINE , 28 'STATUS',
                43 SY-VLINE , 44 'GRUP', 48 SY-VLINE.
        ULINE AT /1(48).
      ENDIF.
      IF R2 EQ 'X'.
        WRITE : SY-VLINE , 2 'PO NUMBER',
               12 SY-VLINE, 13 'ITEM',
               18 SY-VLINE,19 'MATERIAL NUMBER',
               37 SY-VLINE, 38 'PLANT',
               44 SY-VLINE, 45 'GRUP',
               49 SY-VLINE.
        ULINE AT /1(50).
      ENDIF.
    END-OF-PAGE.
      ULINE AT /1(50).
      WRITE :/10 'PAGE NUMBER', SY-PAGNO.
    WRITE THE CONDITION WHAT EVER YOU WANT TO CHECK AND IF THAT IS TRUE SY-SUBRC = 0 THEN NO MESS IF NE 0 THEN RAISE A ERROR MESSAGE LIKE ABOVE
    REWARD IF USEFULL

  • How to handle the OK button of the parameters prompt of a crystal report

    Hi,
    how to handle the OK button of the parameters prompt of a crystal report in vba.NET?
    I want to use the parameter prompt from the crystal report itself and I want to know when the report is ready. I need to export programatically by sending email to a list of employees after the parameters has been set. The emails I send depends on the results of the report.
    Im using a CrystalReportViewer control  in VS2010 and Crystal Report for VS2010 v13.0.1.220.

    Right. But the parameter screen is driven by the viewer. Unless you create your own parameter screen and pass the parameters to the report via code.
    Another thing I am not sure about:
    "Then by code I want to read all the employees id from the report and send email to them with specified pages of the report. (1 page per employee)"
    How do you plan on reading the employee ID from the report? I am not aware of any API that will read a value in a report so that you can then decide what page to send to whom.
    I think you're approaching this kinda backwards. A question to ask is; can you do what you are trying to do in code in the CR designer? If not, using APIs will not work either. I suspect your approach should be a report that uses an employee filter. Run the report for employee x, get the report populated with the data for that employee and email it. Repeat for employee x1, employee x2, etc.
    - Ludek

Maybe you are looking for

  • Message no. 8I766 Number Ranges are not maintained For Extended Withholding

    Dear All, I am facing the following problem when i am trying to generate the withholding tax certificate 1.) Message no. 8I766 Number Ranges are not maintained For Extended Withholding Tax       Number Ranges are not maintained for Business Place and

  • Pinned taskbar links no longer work

    Since updating to Firefox 24, the pinned taskbar links that I have added to the Firefox launcher no longer work. I am getting a popup that reads: "Unable to open this Internet Shortcut. The protocol "FirefoxURL" does not have a registered program." F

  • Can I watch a DVD on my iPhone?

    Is there any legal way for me to watch a DVD on my iPhone?  My workouts are on DVD, and it would be much easier to bring my iPhone to the gym than my macbook. Thanks, Jaws

  • HT5295 Can I create a playlist in podcasts?

    Can I create a playlist in podcasts?  How?

  • Adding custom link for CIM Agent Console

    Hello all, I have a received a request to add a new custom button in the Information pane of CIM Agent console.The agents want to use this to show a drop-down with skillgroup/queues and then transfer the activity to the selected skill-group. Can anyb