Restrict 'Executing report in background' from selection screen

I want user to not to select option for executing report in background from Selection Screen of the program.
i.e. 'Execute Program in Background' option in 1st menu bar tab should either be disabled OR if user clicks on it then he should get error message on selection screen itself.
Thanks,
Falguni

Hi Falguni,
Write the code based on function code SJOB in the event AT SELECTION-SCREEN. Write the following code :
AT SELECTION-SCREEN
CASE SY-UCOMM.
WHEN 'SJOB'.
MESSAGE E000 WITH 'You cannot schedule background job'.
ENDCASE.
Thanks & Regards,
Faheem.

Similar Messages

  • Running a report in background from selection screen input

    Hi,
    i had created one report and i want to sechedule it in background based on the condition that if a check box is checked it will run in background otherwise in foreground.

    Hi Raymond,
    you was quicker
    Didn't know this solution yet. Great.
    (Hint, you have tho check the SY-BATCH also, otherwise the Job wants to schedule itselfs again, tried it right now).
      IF sy-batch IS INITIAL.
        IF  sscrfields-ucomm EQ 'ONLI' AND checkbox = 'X'.
          sscrfields-ucomm = 'SJOB'.
        ENDIF.
      ENDIF.
    Regards, Uwe

  • To run a report in background in selection screen using a new button

    hi friends iam new member to this site
    nice to meet u all
    i want to run a report in background using the selection screen of the same report and i want to keep a button in application tool bar.
    after enter the values in the selection screen by clicking that button it should move to the screen which we get generally by menu option
    program-->execute in background
    and by entering the output device and start condition it should be scheduled in the background.
    with job_open,job_submit and job_close we need variants.
    for this i tried through bp_jobvariant_schedule and
    bp_jobvariant_overview but with this we can run with variants only
    but the user wants to enter the values in selection screen and need a button to run background
    ok friends i think u understood me
    please inform soon ok bye have a nice time

    Hi Jagadish
       There are two ways for you to handle the situation.
    1. Train the users to enter the values in selection screen and manually go for backgroung scheduling.
    2. Use At user command and within that basing on the option selection selected, use FM:JOB_OPEN with sy-repid get the job number, submit the program with the values on the selection screen and lastly executing FM: JOB_CLOSE with the job number from JOB_OPEN and SY-REPID.
    Note that you have to set 'X' for export parameter something like startimmed while calling FM: JOB_CLOSE for immediate execution. Am not on SAP to give you the exact parameter.
      Hope the above info helps you.
    Kind Regards
    Eswar

  • How to execute report in Background from Dialog process?

    How, or what is the best way, to lauch an executable program (report) into the background from a dialog program (dynpro)?
    <b>Example:</b>  The SUBMIT...AND RETURN still executes the called program before it returns control to the calling program.  I just want the report to be kicked off and the dialog to continue as normal.  I do not want the report execution time to affect the dialog process.
    Thanks in advance for your time.

    Hi Nablan, I'm also trying to do parallel processing and created a function module that kicks of another report program.
    However, the process doesn't seem to work. The Main program runs from start to finish but the called program in the function module doesn't seem to run. When I used the option STARTING NEW TASK task name the code ran but in the foreground. I don't want to use this option as it runs in the foreground and SAP limits one to six sessions. Is there something I'm missing in the attributes of the function module I created. Currently the attributes are: Processing type Remote enable module and it's set to start immediately. I had used Normal function module initially but this did not work with the STARTING NEW TASK task name option.
    Below are the codes segements I used.
    In my main program I have the following code segement
    CALL FUNCTION 'Z_CA_PROG_CALL'
      IN BACKGROUND TASK
      EXPORTING
        zprogram            = 'ZCA_TEST1'
      EXCEPTIONS
        program_call_failed = 1
        invalid             = 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.
    COMMIT WORK.
    In the function module I have the following code.
    FUNCTION z_ca_prog_call.
    ""Local interface:
    *"  IMPORTING
    *"     VALUE(ZPROGRAM) LIKE  ZCA_INTERFPROG-ZPROGRAM
    *"  EXCEPTIONS
    *"      PROGRAM_CALL_FAILED
    *"      INVALID
      SUBMIT (zprogram).
      IF sy-subrc <> 0.
        CASE sy-subrc.
          WHEN 1.
            RAISE program_call_failed.
          WHEN OTHERS.
            RAISE invalid.
        ENDCASE.
      ENDIF.
    ENDFUNCTION.

  • RESCIS - Unable to select custom report from Selection Screen

    Hi all,
    we have developed a custom report for transaction "RESCIS-Evaluation of service charge settlement" but we have found that althought the report appears in selection screen field called "REPORT" it throws message RESCIS003 but the report is not shown.
    If we doesn't fulfill report field in selection screen, the program shows a second screen where a couple of ALVGrids are shown allowing the user to select the report that will be displayed. Here we are able to select our custom report and the data in it is displayed.
    We have analyzed the standard program that is executed via transaction RESCIS and we've found that the selection screen executes standard function RESC_GUI_ANYREPORTS_APPL that doesn't executes reports dinamically but statically. That means that SAP doesn't allows to execute custom reports directly from selection screen.
    I think this is a SAP error but afert opening an OSS message SAP sais that is not an error but a bad configuration or lack of knowledge for customizing it.
    Has anyone developed a custom report for RESCIS transaction?

    Hm what exactly did you want to change? Normally it is in REFX cases you should not copy standard REPORTS. In your case with transaction RESCIS, I myself do not see any need to add any functionality in this report because it is only a sum of all lists from your service charge settlement. What else do you want to see there?
    For displaying new fields in the separate lists maybe there is some BADI for it.
    Regards
    Michael

  • Need to schedule a report in background from an user exit

    Hi Experts,
    I have a requirement to execute a report in background from an <b>user exit</b>. Please advise.
    Thanks in advance,
    Vivenchandar R

    Use the <b>submit</b> statement.
    For example
    SUBMIT zipr_trans_details "VIA SELECTION-SCREEN
                                  WITH so_trdt  IN lr_tr_period
                                  WITH so_empno IN lr_emp
                                  AND RETURN.
    Where <b>zipr_trans_details</b> is the report name.
    Message was edited by:
            Naren Someneni

  • SUBMIT a report without showing the selection-screen

    hey guys,
      i want to submit a report(rep2) from my report.(rep1)
    rep2 has selection-screen.(it also has ldb associated).
    i am apssing all the data for selection-screen(of rep2) using an itab.
    but now i dont want selection-screen of rep2 to be displayed when rep1 is executed.
    how to go about?

    Dear Kumar,
    you can use the below specified variants
    SUBMIT <REPORT NAME>
    1. ... USING SELECTION-SET vari
    2. ... WITH p op f SIGN s
    3. ... WITH p BETWEEN f1 AND f2 SIGN s
    4. ... WITH p NOT BETWEEN f1 AND f2 SIGN s
    5. ... WITH p IN sel
    6. ... WITH SELECTION-TABLE seltab
    7. ... WITH FREE SELECTIONS texpr
    Eg.,
    CLEAR paramtrs.
        REFRESH paramtrs.
        PERFORM append_selection_table USING :
                      'SO_NUM' 'P' 'EQ' 123456
                      'ITEM'   'P' 'EQ'  abcdef,
                      'POS'    'P' 'EQ'  10.
        SUBMIT <abc>  WITH SELECTION-TABLE paramtrs AND RETURN.
    FORM append_selection_table USING fname ftype fopre fvalue.
      MOVE : fname  TO paramtrs-selname,
             ftype  TO paramtrs-kind,
             fopre  TO paramtrs-option,
             fvalue TO paramtrs-low.
      APPEND paramtrs.
    ENDFORM.
    where SO_NUM, ITEM AND POS  are the report abc's input selection screen.

  • Execute report in background

    hi
    we have one requirement for execute report in background
    we want to run the report ME5A for a large date range and at plant level.
    Due to this, transaction data selected is large and so reportis taking very long time when executed in foreground.
    so requirement is
    execute report in background (i know possible in SAP)
    download the report output on desktop automatically
    can you pl suggest how to do this without customisation
    regards
    sara

    Hi Sara,
    Go to ME5A then enter the required field then go to Programme and then select the option execute in background

  • HOW TO PASS THE DATA FROM SELECTION SCREEN TO STANDARD TRANSACTION?

    HI,
    HOW TO PASS THE DATA FROM SELECTION SCREEN TO STANDARD TRANSACTION?
    thanks,
    samba.

    By selection screen, what do you mean?   There is no selection screen in WDA as there was in classic dynpro. Do you mean you are using the Select-Options reusable component?  Are you wanting to call a standard transaction via ITS - SAPGUI for HTML?  Please provide more details to your question.

  • Problem in getting parameter value from selection screen in web dynpro abap

    Hi,
    I am facing problem in getting parameter value from selection screen.
    Please find my code below:
    DATA LT_PAR_ITEM TYPE IF_WD_SELECT_OPTIONS=>TT_SELECTION_SCREEN_ITEM.
    FIELD-SYMBOLS:<FS_PAR_ITEM> LIKE LINE OF LT_PAR_ITEM,
                                 <FS_OBJ_USAGE>    TYPE REF TO data.
      WD_THIS->M_HANDLER->GET_PARAMETER_FIELDS( IMPORTING ET_FIELDS = LT_PAR_ITEM ).
      LOOP AT LT_PAR_ITEM ASSIGNING <FS_PAR_ITEM>.
        CASE <FS_PAR_ITEM>-M_ID.
          WHEN `OBJ_USAGE`.
             ASSIGN <FS_PAR_ITEM>-M_VALUE->* TO <FS_OBJ_USAGE>.      
    [ Here, sy-subrc is 4,  <FS_OBJ_USAGE> is not assigning.]
        ENDCASE.
      ENDLOOP. 
    So, can any one solve this problem.
    Thanks in advance,
    Radhika

    Hi Radhika,
    Try using GET_RANGE_TABLE_OF_SEL_FIELD...
    Please Refer below code..
       DATA: NODE_FLIGHTS TYPE REF TO IF_WD_CONTEXT_NODE.
      DATA: RT_CARRID TYPE REF TO DATA.
      DATA: ISFLIGHT TYPE TABLE OF SFLIGHT.
      DATA: WSFLIGHT TYPE SFLIGHT.
      FIELD-SYMBOLS: <FS_CARRID> TYPE TABLE.
    Retrieve the data from the select option
      RT_CARRID = WD_THIS->M_HANDLER->GET_RANGE_TABLE_OF_SEL_FIELD( I_ID = 'S_CARR_ID' ).
    Assign it to a field symbol
      ASSIGN RT_CARRID->* TO <FS_CARRID>.
      CLEAR ISFLIGHT. REFRESH ISFLIGHT.
      SELECT * INTO CORRESPONDING FIELDS OF TABLE ISFLIGHT FROM SFLIGHT
                           WHERE CARRID IN <FS_CARRID>.
      NODE_FLIGHTS = WD_CONTEXT->GET_CHILD_NODE( NAME = `FLIGHTS` ).
      NODE_FLIGHTS->BIND_ELEMENTS( ISFLIGHT ).
    Thanks,
    Regards,
    Kiran

  • Report which has four selection screens called in a specific order

    Hi All,
    In a report, how can I call multiple selection screens predefined, and  create BDC recording in the program based on the values entered in the selection screens. The selection screens are 4 in my scenario in a specific order. Please send across sample code which has the logic to call multiple selection screens and create BDC recording for sales order, delivery, PGI..Thanks
    Ricky

    If ur option is to creat multiple screens...go for tabstrip option in ur report and record it.
    selection-screen begin of screen 001 as subscreen.
    selection-screen begin of block b1 with frame title text-001.
    selection-screen begin of line.
    selection-screen comment 2(10) text-003.
    parameters:par1 type marc-matnr.
    selection-screen end of line.
    selection-screen end of block b1.
    selection-screen end of screen 001.
    selection-screen begin of screen 002 as subscreen.
    selection-screen begin of block b2 with frame title text-002.
    selection-screen begin of line.
    selection-screen comment 2(10) text-003.
    parameters:par2 type marc-matnr.
    selection-screen end of line.
    selection-screen end of block b2.
    selection-screen end of screen 002.
    selection-screen begin of tabbed block tabstrip for 10 lines.
    selection-screen tab (15) tabs1 user-command t1 default screen 001.
    selection-screen tab (15) tabs2 user-command t2 default screen 002.
    selection-screen end of block tabstrip.
    initialization.
    tabs1 = 'TAB1'.
    tabs2 = 'TAB2'.

  • Executing a report in background,without selection scr  with a variant

    Dear All,
    Please let me know whether I can execute a report which doesn't has a selection-screen, in background, <b>using a variant</b> ?
    Alok.

    Hi,
    In order to restrict the user to run it only in background , you can as well check for SY-BATCH condition.
    The other way is try to remove "execute in foreground" option from the menu and this can be done with the function module .
    Do reward points if useful and close the thread if the doubt is cleared
    data: begin of int_exc occurs 0,
    code like sy-ucomm,
    end of int_exc.
    data wf_repid .
    initialization.
    clear int_exc.
    int_exc-code = 'ONLI'.
    append int_exc.
    int_exc-code = 'PRIN'.
    append int_exc.
    move: sy-repid to wf_repid .
    call function 'RS_SET_SELSCREEN_STATUS'
    exporting
    p_status = '%_00'
    p_program = 'wf_repid'
    tables
    p_exclude = int_exc
    Regards,
    Ram
    Pls reward points if helpful....

  • How to use a parameter  of a report program from selection screen in a dialog program

    how to use a parameter value(entered ) of a report program from a selection screen in a dialog program.
    I have to fetch the value entered in the parameter of report program and display it in a dialog program

    Hi Aasim,
    Just mention like below in your ABAP report.
       PARAMETERS: p_aufnr TYPE aufnr MEMORY ID ord.
    and mention the same memory ID name in the module pool screen property it automatically populates the value to and fro

  • Passing parameter from selection screen to corresponding report program.

    Hi all,
    I am developing a report in which there is a selection screen containing 2 list boxes having month 'from' and 'to' ;ie the month range for which  the report is to be run and a parameter for year.below it i have 2 radio button options which will lead to the report that the user clicks on.
    I have done the following in the code.
    selection-screen begin of block b1 with frame title text-001.
    parameters: month1(10) as listbox visible length 10 obligatory.
    parameters: month2(10) as listbox visible length 10.
    parameters: year(4) obligatory.
    selection-screen : end of block b1.
    selection-screen: begin of block b2 with frame title text-002.
    parameters: rb1  radiobutton group g1,
                        rb2  radiobutton group g1.
    selection-screen : end of block b2.
    if rb1 = 'X'.
    submit ZMIS1.
    ENDIF.
    if rb2 = 'X'.
    submit ZMIS2.
    endif.
    Now i want the values selected in the listbox and the year to be passed in the report that will be selected in the radiobutton (ie  ZMIS1 or ZMIS2) so that the corresponding report output will be displayed directly with the inputs given in the selection screen .
    Please tell me how to do this.Thanks in advance.

    You also have to pass Selection-screen data for called program the way it has been shown down.
    REPORT  ZVENKAT_ALV_LIST.
    DATA:
          IT_RSPARAMS TYPE STANDARD  TABLE OF RSPARAMS,
          WA_RSPARAMS LIKE LINE OF IT_RSPARAMS.
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    PARAMETERS: MONTH1(10) AS LISTBOX VISIBLE LENGTH 10 OBLIGATORY.
    PARAMETERS: MONTH2(10) AS LISTBOX VISIBLE LENGTH 10.
    PARAMETERS: YEAR(4) OBLIGATORY.
    SELECTION-SCREEN : END OF BLOCK B1.
    SELECTION-SCREEN: BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.
    PARAMETERS: RB1 RADIOBUTTON GROUP G1 USER-COMMAND UC1,
                RB2 RADIOBUTTON GROUP G1.
    SELECTION-SCREEN : END OF BLOCK B2.
    IF RB1 = 'X'.
      WA_RSPARAMS-SELNAME = 'P_MATNR'. "PARAMETER or SELECT-OPTION of the called program
      WA_RSPARAMS-KIND    = 'P'.       "S=Select-options P=Parameters
      WA_RSPARAMS-SIGN    = 'I'.
      WA_RSPARAMS-OPTION  = 'EQ'.
      WA_RSPARAMS-LOW     = '11010'.
      WA_RSPARAMS-HIGH    = SPACE.
      SUBMIT ZMIS1 WITH SELECTION-TABLE RSPARAMS AND RETURN.
    ENDIF.
    IF RB2 = 'X'.
      WA_RSPARAMS-SELNAME = 'P_MATNR'. "PARAMETER or SELECT-OPTION of the called program
      WA_RSPARAMS-KIND    = 'P'.       "S=Select-options P=Parameters
      WA_RSPARAMS-SIGN    = 'I'.
      WA_RSPARAMS-OPTION  = 'EQ'.
      WA_RSPARAMS-LOW     = '11010'.
      WA_RSPARAMS-HIGH    = SPACE.
      SUBMIT ZMIS2 WITH SELECTION-TABLE RSPARAMS AND RETURN.
    ENDIF.
    Thanks
    Venkat.O

  • ALV grid list  report when selected  from  selection screen

    Hi folks,
                I need to get ALV grid display in my list report when selected the interval values from  the selection screen. If I change the values in list of ALV grid it needs to be updated when I press UPDATE pushbutton. The output of list should be in ALV grid display.I need sorting ,flitering,totaling functionality in the list output.
    For example if I selected BUKRS = 100 and 200 in the selection screen ,I need to display the ALV grid list in below the selection screen as ALV grid display...
    Its urgent as  I am new to ALV grid functionality...
    Thanks in advance..

    hi raja,
    check with the folllowing code.
    REPORT zca0m_zca0fcstftop NO STANDARD PAGE HEADING
                                    MESSAGE-ID zcsv_usrtbl_maintain.
    Type pools                                                           *
    TYPE-POOLS : slis.                          " Used for ALV display
    Tables
    TABLES: zca0fcstftop,
            dd04t,                         "R/3 DD: Data element texts
            tactt.                         "Activities that can be protected
    internal tables
    DATA: BEGIN OF wa_zca0fcstftop .
            INCLUDE STRUCTURE zca0fcstftop.
    DATA: END OF wa_zca0fcstftop.
    DATA: t_zca0fcstftop LIKE STANDARD TABLE OF wa_zca0fcstftop.
    DATA: BEGIN OF i_fcode OCCURS 0,
            fcode LIKE sy-ucomm,
          END OF i_fcode.
    *Record for variant selection
    DATA : BEGIN OF ws_variant,
             selected TYPE c,
             variant  LIKE ltdx-variant,  "Variant name
             text     LIKE ltdxt-text,    "Variant description
           END OF ws_variant.
    *Table for variant selection
    data : itab_variant LIKE STANDARD TABLE OF ws_variant WITH HEADER LINE.
    Variant selection pop-up global variables
    DECLARATION OF TABLECONTROL 'VARIANT_CNTL' ITSELF
    CONTROLS: variant_cntl TYPE TABLEVIEW USING SCREEN 0200.
    LINES OF TABLECONTROL 'VARIANT_CNTL'
    DATA:     g_variant_cntl_lines  LIKE sy-loopc.
    DATA:grid1 TYPE REF TO  cl_gui_alv_grid ,
         g_custom_container TYPE REF TO cl_gui_custom_container.
    Work fields
    DATA: table_name LIKE dd02l-tabname,   "To store table name
          field_name LIKE dd03l-fieldname, "To Store Field Name
          act_auth LIKE tactz-actvt,       "To pass Activity ID
          tab_maint LIKE dd02l-tabname,    "To pass Table Name to be Maintd.
          wg_confirm_ind,                  "To trap User responses
          flag,                            "To trap changes made to an entry
          f_copy,                          "To Identify 'COPY' Command Use
          f_select,                        "To decide between Select-options
                                           " and Internal Table
          l_transaction_code LIKE tstc-tcode,
          v_langu LIKE sy-langu,
          v_repid LIKE sy-repid,
          s_variant TYPE disvariant.
    DATA: ok_code LIKE sy-ucomm.
    DATA:selected_rows TYPE lvc_t_row  ,
         sel_rows TYPE lvc_t_row WITH HEADER LINE.
    DATA:t_lines TYPE i.
    Constants                                                            *
    CONSTANTS :
               c_x TYPE c VALUE 'X',             " Constant 'X'.
               c_f TYPE c VALUE 'F'.             " Constant 'F'.
    Parameters and Selection Options
    *Selection Screen for table maintenance
    *Selection option for Plant
    SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE text-b01.
    PARAMETERS:  p_werks   LIKE zca0fcstftop-werks OBLIGATORY.
    SELECT-OPTIONS: s_prdfml  FOR zca0fcstftop-product_family,
                    s_bmach   FOR zca0fcstftop-base_machine,
                    s_factop FOR zca0fcstftop-factory_top,
                    s_optval  FOR zca0fcstftop-option_value,
                    s_week    FOR zca0fcstftop-week.
    SELECTION-SCREEN END OF BLOCK block1.
    SELECTION-SCREEN BEGIN OF BLOCK block2 WITH FRAME TITLE text-b02.
    PARAMETERS     : p_varant LIKE ltdx-variant.          " ALV variant
    SELECTION-SCREEN END OF BLOCK block2.
    At selection screen                                                  *
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_varant.
      PERFORM alv_variant_f4 CHANGING p_varant.
    AT SELECTION-SCREEN ON p_werks .
    Validating Plant on the selection screen
      PERFORM validate_plant.
    Initialization
    INITIALIZATION.
    Check Authorization for the Transaction
    Authorization Check For T Code
      SELECT tcode
         INTO l_transaction_code
         FROM tstc UP TO 1 ROWS
         WHERE pgmna = sy-repid.
      ENDSELECT.
      AUTHORITY-CHECK OBJECT 'S_TCODE'
                          ID 'TCD' FIELD l_transaction_code.
      IF sy-subrc NE 0.
        MESSAGE e001 WITH l_transaction_code.
      ENDIF.
      v_langu = sy-langu.                             " language
      v_repid = sy-repid .                            " abap Program name
    Start Of Selection
    START-OF-SELECTION.
      CALL SCREEN 0050.
    *&      Form  validate_plant                                           *
          Validating Plant on the selection screen                       *
    FORM validate_plant .
      DATA : l_werks LIKE t001w-werks.                          " Plant
      IF p_werks IS NOT INITIAL.
        SELECT SINGLE werks
            FROM t001w
            INTO l_werks
            WHERE werks EQ p_werks.
        IF sy-subrc NE 0.
          MESSAGE e100(ra) WITH text-001 .
        ENDIF.
      ENDIF.
      AUTHORITY-CHECK OBJECT 'Z_PP_PLANT'
               ID 'ACTVT' FIELD '03'
               ID 'WERKS' FIELD p_werks
               ID 'TCD' FIELD l_transaction_code.
      IF sy-subrc NE 0.
        MESSAGE e000(oo) WITH 'No authorization for plant:'(e80) p_werks.
      ENDIF.
    ENDFORM.                    " validate_plant
    *&      Form  get_data                                                 *
          Get data                                                       *
    FORM get_data .
      SELECT * FROM zca0fcstftop
        INTO TABLE t_zca0fcstftop
        WHERE werks           = p_werks
          AND product_family IN s_prdfml
          AND base_machine   IN s_bmach
          AND factory_top    IN s_factop
          AND option_value   IN s_optval
          AND week           IN s_week.
    ENDFORM.                    " get_data
    *&      Form  fill_fcode
    FORM fill_fcode USING    value(p_0029).
      i_fcode-fcode = p_0029.
      APPEND i_fcode.
      CLEAR i_fcode.
    ENDFORM.                               " fill_fcode
    *&      Module  STATUS_0100  OUTPUT
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'UPDATE'.
      CLEAR flag.
    ENDMODULE.                             " STATUS_0100  OUTPUT
    *&      Module  MODIFY_0100  OUTPUT
    MODULE modify_0100 OUTPUT.
      IF sy-ucomm = 'CHNG' OR
           sy-ucomm = 'PICK'.
        LOOP AT SCREEN.
          CHECK screen-group1 = 'CHG'.
          screen-required = '0'.
          screen-output   = '1'.
          screen-input    = '0'.
          MODIFY SCREEN.
        ENDLOOP.
      ENDIF.
    Check if you are in create mode & if yes then set the screen elements
    as mandatory
      IF ok_code = 'CREA'.
        LOOP AT SCREEN.
          CHECK screen-group1 = 'CHG'.
          screen-required = '1'.
          screen-output   = '1'.
          screen-input    = '1'.
          MODIFY SCREEN.
        ENDLOOP.
      ENDIF.
    ENDMODULE.                             " MODIFY_0100  OUTPUT
    *&      Module  Check_Exit  INPUT
          text
    MODULE check_exit INPUT.
      IF ( sy-ucomm = 'BACK' OR sy-ucomm = 'CANC' OR sy-ucomm = 'EXIT' ) AND
           ( flag = 'Y' ).
        CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
          EXPORTING
            defaultoption  = 'Y'
            textline1      = text-008
            textline2      = text-009
            titel          = text-004
            cancel_display = ' '
          IMPORTING
            answer         = wg_confirm_ind.
        CASE wg_confirm_ind.
          WHEN 'J'.                                             "Yes
            sy-ucomm = 'SAVE'.
            CLEAR flag.
          WHEN 'N'.                                             "No
            sy-ucomm = 'BACK'.
            CLEAR flag.
        ENDCASE.
      ENDIF.
    ENDMODULE.                             " Check_Exit  INPUT
    *&      Module  Exit_0100  INPUT
          text
    MODULE exit_0100 INPUT.
      SET SCREEN 0. LEAVE SCREEN.
    ENDMODULE.                             " Exit_0100  INPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    MODULE user_command_0100 INPUT.
      CASE sy-ucomm.
        WHEN 'SAVE'.                       "Save
        Check to see if the user has the appropriate authorization
          IF p_werks NE zca0fcstftop-werks.
          could not update - not in selection
            MESSAGE e000(oo) WITH 'Entry not within selection'.
            SET SCREEN 0. LEAVE SCREEN.
            PERFORM get_data.
          ENDIF.
          IF f_copy = 'X'.
            INSERT zca0fcstftop.
            IF sy-subrc = 0.
              MESSAGE s004.
              PERFORM initialize.
              SET SCREEN 0. LEAVE SCREEN.
              PERFORM get_data.
            ELSE.
              MESSAGE w005.
            ENDIF.
          ELSE.
            MODIFY zca0fcstftop.
            IF sy-subrc = 0.
              MESSAGE s004.
              PERFORM initialize.
              SET SCREEN 0. LEAVE SCREEN.
              PERFORM get_data.
            ELSE.
              MESSAGE w005.
            ENDIF.
          ENDIF.
          PERFORM get_data.
        WHEN 'BACK'.                       "Back
          SET SCREEN 0. LEAVE SCREEN.
        WHEN 'CANC'.                       "Cancel
          SET SCREEN 0. LEAVE SCREEN.
        WHEN OTHERS.
      ENDCASE.
      COMMIT WORK.
    ENDMODULE.                             " USER_COMMAND_0100  INPUT
    *&      Form  Initialize
    FORM initialize.
      CLEAR :   table_name,
                field_name,
                wg_confirm_ind,
                f_copy,
                flag,
                t_zca0fcstftop,
                zca0fcstftop,
                wa_zca0fcstftop,
                i_fcode.
      REFRESH: t_zca0fcstftop.
    ENDFORM.                               " Initialize
    *&      Form  alv_variant_f4
          text
         <--P_VARIANT  text
    FORM alv_variant_f4  CHANGING variant.
      DATA: rs_variant LIKE disvariant.
      DATA nof4 TYPE c.
      CLEAR nof4.
      LOOP AT SCREEN.
        IF screen-name = 'VARIANT'.
          IF screen-input = 0.
            nof4 = 'X'.
          ENDIF.
        ENDIF.
      ENDLOOP.
      rs_variant-report   = sy-repid.
      rs_variant-username = sy-uname.
      CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
        EXPORTING
          is_variant = rs_variant
          i_save     = 'A'
        IMPORTING
          es_variant = rs_variant
        EXCEPTIONS
          OTHERS     = 1.
      IF sy-subrc = 0 AND nof4 EQ space.
        variant = rs_variant-variant.
      ENDIF.
    ENDFORM.                               " ALV_VARIANT_F4
    *&      Module  STATUS_0050  OUTPUT
          text
    MODULE status_0050 OUTPUT.
    In this module Initialize the container and put the grid in it
      DATA:grid_layout  TYPE lvc_s_layo,
           fieldcat TYPE lvc_t_fcat,
           wa_fieldcat LIKE LINE OF fieldcat.
      PERFORM set_auth.
      SET PF-STATUS 'UPD_0050' EXCLUDING i_fcode.
      SET TITLEBAR 'UPD_0050'.
      IF g_custom_container IS INITIAL .
        CREATE OBJECT g_custom_container
           EXPORTING
              container_name = 'FTDATA'.
        CREATE OBJECT grid1
           EXPORTING
            i_parent = g_custom_container.
      ELSE.
        CALL METHOD grid1->free.
        CALL METHOD g_custom_container->free.
        CREATE OBJECT g_custom_container
           EXPORTING
              container_name = 'FTDATA'.
        CREATE OBJECT grid1
           EXPORTING
            i_parent = g_custom_container.
      ENDIF.
    Every time refresh The variables
      PERFORM initialize.
      PERFORM get_data.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name = 'ZCA0FCSTFTOP'
        CHANGING
          ct_fieldcat      = fieldcat.
      grid_layout-grid_title = text-t01.
      grid_layout-sel_mode = 'A'.
      grid_layout-stylefname = 'CT'.
      s_variant-report   = sy-repid.
      s_variant-username = sy-uname.
      s_variant-variant  = p_varant.
      CALL METHOD grid1->set_table_for_first_display
        EXPORTING
          i_structure_name = 'ZCA0FCSTFTOP'
          is_layout        = grid_layout
          is_variant       = s_variant
          i_save           = 'A'
        CHANGING
          it_outtab        = t_zca0fcstftop
          it_fieldcatalog  = fieldcat.
      Create Object to receive events and link them to handler methods.
      When the ALV Control raises the event for the specified instance
      the corresponding method is automatically called.
    CREATE OBJECT event_receiver.
    SET HANDLER event_receiver->handle_button_click FOR grid1.
    ENDMODULE.                 " STATUS_0050  OUTPUT
    *&      Module  USER_COMMAND_0050  INPUT
    MODULE user_command_0050 INPUT.
      CALL METHOD grid1->get_selected_rows
        IMPORTING
          et_index_rows = selected_rows.
      DESCRIBE TABLE selected_rows LINES t_lines.
      IF t_lines > 1 .
        MESSAGE e048(zcsv_sfdr).
      ENDIF.
    Clear Header
      CLEAR wa_zca0fcstftop.
      sel_rows[] = selected_rows .
      READ TABLE sel_rows INDEX 1.
      READ TABLE t_zca0fcstftop INTO wa_zca0fcstftop INDEX sel_rows-index.
      CASE ok_code.
        WHEN 'EXIT'.
          PERFORM exit_program.
        WHEN 'CREA'.
          CLEAR zca0fcstftop.
          ok_code = sy-ucomm.
          zca0fcstftop-werks = p_werks.
          CALL SCREEN 100.
        WHEN 'COPY'.
          MOVE wa_zca0fcstftop TO zca0fcstftop .
          CLEAR wa_zca0fcstftop.
          f_copy = 'X'.
          CALL SCREEN 100.
        WHEN 'CHNG'.
          CHECK NOT wa_zca0fcstftop IS INITIAL.
          MOVE wa_zca0fcstftop TO zca0fcstftop .
          CLEAR wa_zca0fcstftop.
          ok_code = sy-ucomm.
          CALL SCREEN 100.
        WHEN 'DELE'.
          CHECK NOT wa_zca0fcstftop IS INITIAL.
          CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
            EXPORTING
              defaultoption  = 'N'
              textline1      = text-005
              textline2      = text-006
              titel          = text-007
              cancel_display = ' '
            IMPORTING
              answer         = wg_confirm_ind.
          IF wg_confirm_ind EQ 'J'.
            DELETE zca0fcstftop FROM wa_zca0fcstftop .
            IF sy-subrc EQ 0.
              MESSAGE s004.
            ELSE.
              MESSAGE e005.
            ENDIF.
          ELSEIF wg_confirm_ind EQ 'N'.
          ENDIF.
      ENDCASE.
      CLEAR ok_code.
    ENDMODULE.                 " USER_COMMAND_0050  INPUT
    *&      Form  exit_program
    FORM exit_program .
      CALL METHOD g_custom_container->free.
      CALL METHOD cl_gui_cfw=>flush.
      SET SCREEN 0.
      LEAVE SCREEN.
    ENDFORM.                    " exit_program
    *&      Form  set_auth
    FORM set_auth.
      REFRESH: i_fcode.
    Check authorization for change
      MOVE '02' TO act_auth.        "02 --> Change
      MOVE 'ZCA0FCSTFTOP' TO tab_maint.
      AUTHORITY-CHECK OBJECT 'ZZ:TABLMNP'
        ID 'ACTVT' FIELD act_auth
        ID 'TABLE' FIELD tab_maint.
      IF sy-subrc NE 0.
        PERFORM fill_fcode USING 'CHNG'.
      ENDIF.
    Check for authorization for create
      MOVE '01' TO act_auth.        "01 --> Create
      MOVE 'ZCA0FCSTFTOP' TO tab_maint.
      AUTHORITY-CHECK OBJECT 'ZZ:TABLMNP'
        ID 'ACTVT' FIELD act_auth
        ID 'TABLE' FIELD tab_maint.
      IF sy-subrc NE 0.
        PERFORM fill_fcode USING 'CREA'.
        PERFORM fill_fcode USING 'COPY'.
      ENDIF.
    Check for authorization for delete
      MOVE '06' TO act_auth.        "06 --> Delete
      MOVE 'ZCA0FCSTFTOP' TO tab_maint.
      AUTHORITY-CHECK OBJECT 'ZZ:TABLMNP'
        ID 'ACTVT' FIELD act_auth
        ID 'TABLE' FIELD tab_maint.
      IF sy-subrc NE 0.
        PERFORM fill_fcode USING 'DELE'.
      ENDIF.
    ENDFORM.                    " set_auth
    *&      Module  check_change  INPUT
    MODULE check_change INPUT.
      flag = 'Y'.
    ENDMODULE.                 " check_change  INPUT
    regards,
    vikas.
    plz reward if helpful

Maybe you are looking for