Question about exceptions in function module GUI_DOWNLOAD

To all,
I add the function module 'GUI_DOWNLOAD' in the ABAP report program. After the user download the data to excel, the program also displays a report on the screen for print output.
If the user keep the excel file open and tries to replace the file on download, the program gives an error message 'Access to file denied' and the program ends without displaying a report on the screen.
Is there any way not to end the program even if download is failed?
I would like the program displays a report after it gives an error message.
So I am trying to use exceptions. But if I code to give messages, the programs ends as above. And if I just make exit when it happens, no error message and the program displays a report but the user don't know if the excel file was updated or not.
Could anybody kindly let me know how to code exceptions and messages if it is possible the program works I hope.
Thank you very much in advance.
Best regards,
Miki Komatsu

 I figured out how to do that.
  Thanks.
  Best regards,
  Miki

Similar Messages

  • Function Module GUI_DOWNLOAD: Type String Issue

    I am working in 4.6C. I have used this Function Module many times in the past without issue, but not at this site. It abends and gives me the error message:
    The call to the function module "GUI_DOWNLOAD" is incorrect:                                                                               
    The function module interface allows you to specify only fields          
    of a particular type under "FILENAME". The field "FNAME" specified here  
    has a different field type.                                              
    Here is the field declaration in the code:
    PARAMETER: fname type rlgrap-filename DEFAULT 'C:/New_PO_Format.xls'.
    The import parameter in GUI_DOWNLOAD for FILENAME is type STRING. When I double click on STRING in the FM I get "Unable to find a tool to process request". And, TYPE STRING does not exist in the system? I started making a Z version of GUI_DOWNLOAD, but it started giving me headaches because I had to start copying other SAP function modules.
    Am I missing something? Or, is there a new and improved version of GUI_DOWNLOAD to use?

    data : v_file type string.
    PARAMETER: fname type rlgrap-filename DEFAULT 'C:/New_PO_Format.xls'.
    start-of-selection.
    v_file = fname.
    use v_file in gui_download parameter.
    Thanks
    Seshu

  • How to raise the exception in function module

    Dear abaper's.
                   I am creating a Function module .In that in' EXCEPTION' Tab i am giving
    3 exception .1.NO_DATA_FOUND 2.NO_PRINTER_FOUND 3.SMARTFORM_INTERFACE_NOT_FOUND.
    In my coding if this condtion matches i want to raise this exception.how can i do this in my coding .can any one suggest me..
    advance thanks,
    Warm regards,
    Veera

    Hi,
    if that condition is not satisfied,and u didn't handle that exception while calling function module then in the runtime error u will get the text as the description of the exception in function module definition.
    rgds,
    bharat.

  • How to write the exceptions in function module

    dear all,
         how to write the exceptions in function modules with example.
    thanq
    jyothi

    Hi,
    Raising Exceptions
    There are two ABAP statements for raising exceptions. They can only be used in function modules:
    RAISE except.
    und
    MESSAGE.....RAISING except.
    The effect of these statements depends on whether the calling program handles the exception or not. The calling program handles an exception If the name of the except exception or OTHERS is specified after the EXCEPTION option of the CALL FUNCTION statement.
    If the calling program does not handle the exception
    · The RAISEstatement terminates the program and switches to debugging mode.
    · The MESSAGE..... RAISING statement displays the specified message. Processing is continued in relation to the message type.
    If the calling program handles the exception, both statements return control to the program. No values are transferred. The MESSAGE..... RAISING statement does not display a message. Instead, it fills the system fields sy-msgid, sy-msgty, sy-msgno , and SY-MSGV1 to SY-MSGV4.
    Source Code of READ_SPFLI_INTO_TABLE
    The entire source code of READ_SPFLI_INTO_TABLE looks like this:
    FUNCTION read_spfli_into_table.
    ""Local Interface:
    *" IMPORTING
    *" VALUE(ID) LIKE SPFLI-CARRID DEFAULT 'LH '
    *" EXPORTING
    *" VALUE(ITAB) TYPE SPFLI_TAB
    *" EXCEPTIONS
    *" NOT_FOUND
    SELECT * FROM spfli INTO TABLE itab WHERE carrid = id.
    IF sy-subrc NE 0.
    MESSAGE e007(at) RAISING not_found.
    ENDIF.
    ENDFUNCTION.
    The function module reads all of the data from the database table SPFLI where the key field CARRID is equal to the import parameter ID and places the entries that it finds into the internal table spfli_tab. If it cannot find any entries, the exception NOT_FOUND is triggered with MESSAGE ... RAISING. Otherwise, the table is passed to the caller as an exporting parameter.
    Calling READ_SPFLI_INTO_TABLE
    The following program calls the function module READ_SPFLI_INTO_TABLE:
    REPORT demo_mod_tech_fb_read_spfli.
    PARAMETERS carrier TYPE s_carr_id.
    DATA: jtab TYPE spfli_tab,
    wa LIKE LINE OF jtab.
    CALL FUNCTION 'READ_SPFLI_INTO_TABLE'
    EXPORTING
    id = carrier
    IMPORTING
    itab = jtab
    EXCEPTIONS
    not_found = 1
    OTHERS = 2.
    CASE sy-subrc.
    WHEN 1.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno.
    WHEN 2.
    MESSAGE e702(at).
    ENDCASE.
    LOOP AT jtab INTO wa.
    WRITE: / wa-carrid, wa-connid, wa-cityfrom, wa-cityto.
    ENDLOOP.
    The actual parameters carrier and jtab have the same data types as their corresponding interface parameters in the function module. The exception NOT_FOUND is handled in the program. It displays the same message that the function module would have displayed had it handled the error.
    Or
    just have to decide what exceptions u want and under what conditions.
    then declarethese exeptions under the exceptions tab.
    in the source code of ur function module.
    if
    like this u can code .
    now when u call the function module in tme mainprogram.
    if some error occurs and u have declared a exception for this then it will set sy-subrc = value u give inthe call of this fm.
    in the fm u can program these sy-subrc values and trigger the code for ur exception.
    Please reward if useful
    Regards,
    Ravi
    Edited by: Ravikanth Alapati on Mar 27, 2008 9:36 AM

  • Some question about the renegotiation function in SRM Contract (GOA)

    Hi All Expert,
    We are on SRM 5/4.6,  there is a question about the renegotiation function in SRM GOA.
    Can we renegotiate the price for some parts in the GOA items with this function ( e.g. Only renegotiate one item in the contract) ?
    Will the item price updated automatically after the renegotiation?
    Many thanks in advance!!!
        Wendrin

    Hi Sanjeev,
    Many thanks for your help.
    One more question, if I add a new item when we renegotiation, will it be transfered to contract and create a new item after that?
    Thanks and best regards
    Wendrin

  • Questions about user-defined functions

    Hello all,
    I've got some questions about user-defined function in a message mapping:
    1) How can I get the current date/time in format yyyy-mm-dd hh:mm:ss ? What is the java code for this?
    2) I want to use the StreamTransformation constant TIME_SENT, only this is not in the right time-zone.
    It is GMT and it should be CET (1 hour difference). How can I convert this in Java?
    Can somebody help me with this?
    Thanks in advance.
    Kind regards,
    Marco van Iersel

    Hi Marco,
    If the date format is fixed as you have mentioned,please use this:
                                    String test = "2009-03-27 23:15:30";
              String test1 = test.substring(11,13);
              if(!test1.equals("23"))
              int a = Integer.parseInt(test1);
              int b = a+1;
              System.out.println("b"+b);
              String c = Integer.toString(b);
                                    test = test.substring(0,10)+" " + c + test.substring(13,19);
                                    return test;
              if(test1.equals("23"))
              test = test.substring(0,10)+ " 00" + test.substring(13,19);
              return test;
                                    else return "";
    Kindly let me know if this works.
    Thanks.
    Regards.
    Shweta

  • Exception in Function Module

    Hi,
    How to use exception in Function module ?
    How Can I use the exception  my program while calling the Function Module ?
    Can anyone explain with example ?
    Thanks
    NK

    HI,
    if something happens in ur FM and u want it to be tracked in ur calling program, then u can use exception...............
    If u r having(say) 3 exceptions in ur FM....
    and in ur calling program its like below.
    EXCEPTIONS
      exception1 = 1
      exception2 = 2
      exception3 = 3
    then if the first exception is raised in ur FM,then sy-subrc value ll be 1(  exception1 = 1 )....llly if the second exception is raised in ur FM,then sy-subrc value ll be 2(  exception2 = 2 ).........
    now u can use this sy-subrc values like below....
    If sy-subrc = '1'.
    message 'First exception is raised' type 'I'.
    else.
    message '2nd or 3rd exception is raised' type 'I'.
    endif.
    Cheers,
    jose.

  • Exceptions in function module.... for beginner......

    Dear all experts,
    I am new to ABAP. 
    Can anybody please tell, how to use the exceptions in function module ?
    and if any exception happens, then how to link some messages to that exceptions?
    I will also like to know, how to create those messages ?
    <b>Can anybody please illustrate with help of example, so that a beginner will be able to understand. ?</b>
    <b>eg,</b> i am adding two numbers in function module, and if any one passing number is negative, then i need to raise exception with message please do not enter -ve numbers for addition.
    your help will be surely, rewarded with points.
    waiting for reply.
    Regards & Thanks
    Vinay.

    hi..
    Raising Exceptions
    There are two ABAP statements for raising exceptions. They can only be used in function modules:
    RAISE <except>.
    and
    MESSAGE..... RAISING <except>.
    The effect of these statements depends on whether the calling program handles the exception or not. If the name <except> of the exception or OTHERS occurs in the EXCEPTIONS addition of the CALL FUNCTION statement, the exception is handled by the calling program.
    If the calling program does not handle the exception
    The RAISE statement terminates the program and switches to debugging mode.
    The MESSAGE ..... RAISING statement display the specified message. How the processing continues depends on the message type.
    If the calling program handles the exception, both statements return control to the program. No values are transferred. The MESSAGE ..... RAISING statement does not display a message. Instead, it fills the system fields SY-MSGID, SY-MSGTY, SY-MSGNO, and SY-MSGV1 to SY-MSGV4.
    Source Code of READ_SPFLI_INTO_TABLE
    The entire source code of READ_SPFLI_INTO_TABLE looks like this:
    FUNCTION READ_SPFLI_INTO_TABLE.
    ""Local interface:
    *"       IMPORTING
    *"             VALUE(ID) LIKE  SPFLI-CARRID DEFAULT 'LH '
    *"       EXPORTING
    *"             VALUE(ITAB) TYPE  SPFLI_TAB
    *"       EXCEPTIONS
    *"              NOT_FOUND
      SELECT * FROM SPFLI INTO TABLE ITAB WHERE CARRID = ID.
      IF SY-SUBRC NE 0.
        MESSAGE E007(AT) RAISING NOT_FOUND.
      ENDIF.
    ENDFUNCTION.
    The function module reads all of the data from the database table SPFLI where the key field CARRID is equal to the import parameter ID and places the entries that it finds into the internal table SPFLI_TAB. If it cannot find any entries, the exception NOT_FOUND is triggered using MESSAGE...RAISING. Otherwise, the table is passed to the caller as an exporting parameter.
    Also check these links
    http://help.sap.com/search/highlightContent.jsp
    http://help.sap.com/search/highlightContent.jsp
    http://help.sap.com/search/highlightContent.jsp
    regards,
    veeresh

  • Exceptions in function module

    Hi,
    What are the exceptions in function module.
    Thanks in advance

    HI,
    Exceptions are used to return the error which happens in function module to the calling program.
    You can't show error messages directly from Function modules. So when there are some error occurs in function module it raises the desired exception. and this exception number is passed back to calling program. in this way calling program can trace out the error happens in function module.
    REgards,

  • What is the Exceptions in function module

    Hi,
    wt is the exceptions in function module? can anyone tell me?
    Thanks
    swathi

    Exception is the mechanism by which you can give the error messages back to the program.
    Say for the REUSE_ALV_GRID_DISPLAY, we have so many exceptions. Every exception has some meaning. Say the exception PROGRAM_NOT_FOUND will be raised when you had passed wrong program name in the CALLBACK program.
    PROGRAM_NOT_FOUND  = 1...
    If the exception was raised than this value will be set to the SY-SUBRC.
    SO, by accessing SY-SUBRC, you can get to know which exception was raised.
    Regards,
    Naimesh Patel

  • Function Module GUI_DOWNLOAD in SAP 4.6c

    Hi All,
    I have uploaded a JPG file to a database table and when using the below function modules in the SAP 4.7 server its not opening the file.
    The Below code is written for the double click event. The same code works for the ECC 6.0 version
    please  help.
    Moderator message - Please respect the 2,500 character maximum when posting. Post only the relevant portions of code. (Your orioginal post included code that was commented out.)
    Thanks in Advance.
    Regards
    Ninan
    Edited by: NINAN on Jan 27, 2010 7:50 AM
    Edited by: NINAN on Jan 27, 2010 10:07 AM
    Edited by: NINAN on Jan 27, 2010 11:12 AM
    Edited by: Rob Burbank on Jan 27, 2010 9:20 AM

    This is the code  NINAN  is talking about
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
    EXPORTING
    * BIN_FILESIZE = FILENAME = FNAM FILETYPE = 'BIN'
    * APPEND = SPACE
    * WRITE_FIELD_SEPARATOR = SPACE
    * HEADER = '00'
    * TRUNC_TRAILING_BLANKS = SPACE
    * WRITE_LF = 'X' * COL_SELECT = SPACE * COL_SELECT_MASK = SPACE
    * DAT_MODE = SPACE
    * CONFIRM_OVERWRITE = SPACE
    * NO_AUTH_CHECK = SPACE
    * CODEPAGE = SPACE
    * IGNORE_CERR = ABAP_TRUE
    * REPLACEMENT = '#'
    * WRITE_BOM = SPACE
    * TRUNC_TRAILING_BLANKS_EOL = 'X'
    IMPORTING
      FILELENGTH = FILE_LENGTH
    CHANGING
      DATA_TAB = IT_PIC_TAB_DOWN
    EXCEPTIONS
      FILE_WRITE_ERROR = 1
      NO_BATCH = 2
      GUI_REFUSE_FILETRANSFER = 3
      INVALID_TYPE = 4
      NO_AUTHORITY = 5
      UNKNOWN_ERROR = 6
      HEADER_NOT_ALLOWED = 7
      SEPARATOR_NOT_ALLOWED = 8
      FILESIZE_NOT_ALLOWED = 9
      HEADER_TOO_LONG = 10
      DP_ERROR_CREATE = 11
      DP_ERROR_SEND = 12
      DP_ERROR_WRITE = 13
      UNKNOWN_DP_ERROR = 14
      ACCESS_DENIED = 15
      DP_OUT_OF_MEMORY = 16
      DISK_FULL = 17
      DP_TIMEOUT = 18
      FILE_NOT_FOUND = 19
      DATAPROVIDER_EXCEPTION = 20
      CONTROL_FLUSH_ERROR = 21
      NOT_SUPPORTED_BY_GUI = 22
      ERROR_NO_GUI = 23
      OTHERS = 24 .
    IF SY-SUBRC 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CALL METHOD CL_GUI_CFW=>FLUSH
      EXCEPTIONS
        CNTL_SYSTEM_ERROR = 1
        CNTL_ERROR        = 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.
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>EXECUTE
    EXPORTING
    DOCUMENT = FNAM
    * APPLICATION =
    * PARAMETER =
    * DEFAULT_DIRECTORY =
    * MAXIMIZED =
    * MINIMIZED =
    * SYNCHRONOUS = operation = 'OPEN'
    EXCEPTIONS
    CNTL_ERROR = 1
    ERROR_NO_GUI = 2
    BAD_PARAMETER = 3
    FILE_NOT_FOUND = 4
    PATH_NOT_FOUND = 5
    FILE_EXTENSION_UNKNOWN = 6
    ERROR_EXECUTE_FAILED = 7
    SYNCHRONOUS_FAILED = 8
    NOT_SUPPORTED_BY_GUI = 9
    OTHERS = 10 .
    IF SY-SUBRC 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

  • Help! Question on calling a function module

    Hi,everybody.
    I have a problem about function module. I created a normal function module which would call itself when user double clicked some screen elements. But when I exit the function called in second time, the value of the global variants in function called in first time changed to the value in function called in second time. It seems that they shared the global variants. So is there any ease approach to recover the data to the original value?
    Thanks for any help!

    Hi Dan,
      you can use field-symbols instead.
    check the following code
    IM_TEST is the importing parameter
    EX_TEST is the exporting parameter
    FUNCTION ZTEST_RECURSION.
    *"*"Local interface:
    *"  IMPORTING
    *"     REFERENCE(IM_TEST) TYPE  C
    *"  EXPORTING
    *"     REFERENCE(EX_TEST) TYPE  C
    field-symbols : <var> type c.
    if im_test = 1.
    assign im_test to <var>.
    *<var> = 4.
    elseif im_test = 3.
    assign im_test to <var>.
    endif.
    if im_test = 1.
    CALL FUNCTION 'ZTEST_RECURSION'
      EXPORTING
        IM_TEST       = '3'
    endif.
    ex_test = <var>.
    ENDFUNCTION.
    i hope this will help you.
    regards,
    Kinshuk Saxena
    PS reward points if you find the post helpful

  • What are the system built exceptions in function modules?

    Hi Experts,
    When we are creating the function module in se37 without exceptions ,but system  will assign  2 default exceptions? what are the those exceptions? please provide the information on this issue.
    Thanks,
    Srinivas.

    Hi,
    The system raises exceptions
    1) COMMUNICATION_FAILURE and
    2) SYSTEM_FAILURE  by default.
    Regards,
    Lokeswari.

  • Question about PL/SQL Function in report

    Hi all. I have a (basic) question about using a PL/SQL function in a report. In my report page I have an item (PL/SQL function) that has the following syntax:
    return username from t1
    where username like 'Le%'
    I reference this item in an email process. Ideally this function would return all usernames that begin with 'Le' in the drafted email; however, its not looping so I'm only getting a return on the first name.
    I have a few books on PL/SQL but I'm not exactly sure where to start - I imagine there is a loop process I need to integrate into the function but, like I said, I'm not sure.
    I would have posted this to the PL/SQL forum but also wanted some feedback on whether or not using this method is the best way forward. Essentially I have a table with usernames and just want to send email messages based on some simple logic.
    Thanks!
    Len

    Hi Sergio,
    First, it's an honor to have you reply to my post. Thanks!
    To be more specific,
    T1 is a table containing the results from a user security scan. Username is a column in this table containing user names. What I have done is create a page in HTML DB with the following elements:
    1. An 'Item' containing the PL/SQL function that is hidden. The purpose of this Item is to generate information from T1 that meets the simple logic parameters - in this case, the user names that begin with "Le". I have called this Item P145_TT
    2. A 'Process' containing references to HTMLDB_MAIL. The 'Process' looks similar to this:
    HTMLDB_MAIL.SEND(
    P_TO => '[email protected]',
    P_FROM => 'Anon Email Account',
    P_BODY => 'Note: This message was automatically generated. Do not attempt to reply to this email.
    These are the users that begin with Le: '||:P145_TT||' ',
    P_SUBJ => 'Summary');
    3. A 'Button' to submit the process and (hopefully) send the message containing all users that adhere to the logic in the function.
    4. If I use 'return username from t1...' I will get a username generated, but like I said previously, it only gives me the first and does not loop.

  • Raise exception in function module call from SAP owned program

    I need to raise an exception in a function module to terminate a transaction, display a error message and return to to previous selection screen so the user can fix the error before moving forward.......  
    How do you do this when the program using the function module is SAP owned?
    Thank You!
    Jeff

    Hi,
    After calling the function module, you can do something like this.
    IF SY-SUBRC <> 0.
      RAISE EXCEPTION.
    ENDIF.
    Regards,
    Ferry Lianto

Maybe you are looking for

  • Lenovo Yoga 13 - Tochpad Problems / Cursor Jumps

    Hey everybody, Problem: If I rest one fingertip on my touchpad and do NOT move it, the cursor will jump in vertical direction up and down. My System: I have a Lenovo Yoga 13, i5, 8GB Ram, 128 GB SSD OS: Windows 8.1 x64 fresh install (not original Len

  • My noctua d14 is running to fast on my p67a-g45-b3

    ive just installed noctua d14 with the low noise adapter, but its still to noisy, its spinning around 920rpm how do i lower it more? and what exactly is smart fan target in bios?

  • Email with buttons in it

    Hi I have a requirement to send an Email from webdynpro application on action of submit button, and the email should contain two buttons APPROVE & REJECT. This email is sent to the approver, depending on button selection the email is triggered back t

  • Ran Avast boot scan. Several files quarrantined as infected by a (windows) file - win32:hotbar_be [pup].

    My laptop has been running slow and sometimes freezing up. I ran an Avast scan and it found an infected file which I moved to chest. It recommended I run a boot scan. During the boot scan i had several Firefox extensions and plugins 'moved to chest'.

  • Need to get the difference between two period

    Hi All, I need to get the difference of two posting period like period is in format YYYYMM. I need to subtract posting perid '200512' FROM '200601' how will be it possible. Please suggest. Thanks, Sandy