Can we call ALV grid in a method?

hello everybody,
Is it possible to display the output in ALV from a <b>class-method(Global class)</b>?
in a class-method wee cannot call a screen, so is there any other possibility to display the grid??
thanx in advance,
abhilash.

Don't USE ALV Function modules wherever possible.  Go OO --it's simple once you get the hang of it.
Of course you can do it.
Here's a general class including an event handler in the SAME class. This can be used for DYNAMIC tables, DYNAMIC FCATS and custom events. The method DISPLAY_GRID here will do what you want.
Your structure list and fcat data are in the field-symbols  <fs1> and <fs2>
Here's the code. This program just reads 200 lines from KNA1 and displays some data in a GRID with a toolbar. Press the EXIT arror to quit the program.
You need to define a blank screen (SE51) with a custom control on it called CCONTAINER1.
The screen logic as follows
PBO.
MODULE status_0100 OUTPUT.
You don't need a PAI as we are using the toolbar with events.
OK here goes.
The CLASS bit first
FIELD-SYMBOLS :
  <fs1>          TYPE  ANY,
  <fs2>          TYPE  STANDARD TABLE,
  <dyn_table>    TYPE  STANDARD TABLE,
  <dyn_field>,
  <dyn_wa>.
CLASS zcl_dog DEFINITION.
PUBLIC SECTION.
METHODS:
  constructor
      IMPORTING       z_object type ref to zcl_dog,
  return_structure,
  create_dynamic_fcat
      EXPORTING       it_fldcat TYPE lvc_t_fcat,
  display_grid
      CHANGING        it_fldcat type lvc_t_fcat,
  on_user_command FOR EVENT before_user_command OF cl_gui_alv_grid
      IMPORTING       e_ucomm
                      sender,
  on_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
      IMPORTING      e_object
                   e_interactive.
  PRIVATE SECTION.
DATA:
    lr_rtti_struc   TYPE REF TO cl_abap_structdescr,        "RTTI
    zog             LIKE LINE OF lr_rtti_struc->components, "RTTI
    wa_it_fldcat    TYPE lvc_s_fcat,
    grid_container1 TYPE REF TO cl_gui_custom_container,
    grid1           TYPE REF TO cl_gui_alv_grid.
TYPES:
   struc            LIKE  zog.
DATA:
    zogt           TYPE TABLE OF struc.
ENDCLASS.
CLASS zcl_dog IMPLEMENTATION.
METHOD constructor.
    CREATE OBJECT grid_container1
        EXPORTING
            container_name = 'CCONTAINER1'.
    CREATE OBJECT  grid1
        EXPORTING i_parent = grid_container1.
    SET HANDLER z_object->on_user_command for grid1.
    SET HANDLER z_object->on_toolbar for grid1.
ENDMETHOD.
METHOD return_structure.
  lr_rtti_struc ?= cl_abap_structdescr=>DESCRIBE_BY_DATA( <fs1> ).
  zogt[]  = lr_rtti_struc->components.
  ASSIGN zogt[] TO <fs2>.
ENDMETHOD.
METHOD create_dynamic_fcat.
    LOOP AT <fs2>  INTO zog.
      CLEAR wa_it_fldcat.
      wa_it_fldcat-fieldname = zog-name .
      wa_it_fldcat-datatype = zog-type_kind.
      wa_it_fldcat-inttype = zog-type_kind.
      wa_it_fldcat-intlen = zog-length.
      wa_it_fldcat-decimals = zog-decimals.
      wa_it_fldcat-coltext = zog-name.
      wa_it_fldcat-lowercase = 'X'.
      APPEND wa_it_fldcat TO it_fldcat .
    ENDLOOP.
ENDMETHOD.
METHOD display_grid.
CALL METHOD grid1->set_table_for_first_display
    CHANGING
         it_outtab       = <dyn_table>
         it_fieldcatalog = it_fldcat.
ENDMETHOD.
METHOD on_user_command.
    CASE e_ucomm.
      WHEN 'EXIT'.
        LEAVE PROGRAM.
       WHEN 'SAVE'.
   ENDCASE.
ENDMETHOD.                    "on_user_command
METHOD on_toolbar.
DATA: ls_toolbar TYPE stb_button.
     CLEAR ls_toolbar.
     MOVE 0 TO ls_toolbar-butn_type.
     MOVE 'EXIT' TO ls_toolbar-function.
     MOVE SPACE TO ls_toolbar-disabled.
     MOVE icon_system_end TO ls_toolbar-icon.
     MOVE 'Click2Exit' TO ls_toolbar-quickinfo.
     APPEND ls_toolbar TO e_object->mt_toolbar.
     CLEAR ls_toolbar.
     MOVE  0 TO ls_toolbar-butn_type.
     MOVE 'SAVE' TO ls_toolbar-function.
     MOVE SPACE TO ls_toolbar-disabled.
     MOVE  icon_system_save TO ls_toolbar-icon.
     MOVE 'Save data' TO ls_toolbar-quickinfo.
     APPEND ls_toolbar TO e_object->mt_toolbar.
   ENDMETHOD.
ENDCLASS.
Now the program is incredibly simple and will work for almost ANY table with just a call to the methods in the class . Saves Zillions of coding different ABAPS.
start of program data to demo use of above class ************
INCLUDE  <icon>.
TABLES : kna1.
TYPES:  BEGIN OF s_elements,
  kunnr   TYPE kna1-kunnr,
  name1   TYPE kna1-name1,
  stras   TYPE kna1-stras,
  telf1   TYPE kna1-telf1,
  ort01   TYPE kna1-ort01,
  pstlz   TYPE kna1-pstlz,
END OF  s_elements.
DATA:  z_object type ref to zcl_dog,  "Instantiate our class
       t_elements   TYPE TABLE OF s_elements, "refers to our ITAB
       wa_elements   TYPE s_elements,
       wa_dyn_table_line TYPE REF TO DATA,
       it_fldcat TYPE lvc_t_fcat,
       new_table TYPE REF TO DATA,
       dy_table TYPE REF TO data,
       dy_line  TYPE REF TO data.
START-OF-SELECTION.
CALL SCREEN 100.
END-OF-SELECTION..
MODULE status_0100 OUTPUT.
ASSIGN  wa_elements TO <fs1>.
*Instantiate our zcl_dog class
CREATE OBJECT
     z_object
       EXPORTING
        z_object = z_object.
Get structure of your ITAB
CALL METHOD z_object->return_structure.
build fcat.
CALL METHOD z_object->create_dynamic_fcat
      IMPORTING
        it_fldcat = it_fldcat.
build dynamic table
CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
      it_fieldcatalog = it_fldcat
    IMPORTING
      ep_table        = dy_table.
ASSIGN dy_table->* TO <dyn_table>.
Create dynamic work area and assign to FS
  CREATE DATA dy_line LIKE LINE OF <dyn_table>.
  ASSIGN dy_line->* TO <dyn_wa>.
fill it
PERFORM populate_dynamic_itab.
Display ALV grid with our EXIT tool button
CALL METHOD z_object->display_grid
       CHANGING it_fldcat = it_fldcat.
ENDMODULE.
MODULE user_command_0100 INPUT.
PAI not needed as we are using EVENTS
ENDMODULE.
FORM populate_dynamic_itab.
just read 200 lines as a demo from KNA1
assign dynamic table created to <field symbol> so you can fill it
with data.  Table also now acessible to methods in the classes
defined in this program.
SELECT kunnr name1 stras telf1 ort01 pstlz
    UP TO 200 rows
    FROM kna1
    INTO  CORRESPONDING FIELDS OF TABLE <dyn_table>.
ENDFORM.
If you save the class  with SE24 you can see all you need to do in the program is
1)  Define your data
2) Instantiate the class
  CREATE OBJECT
     z_object
       EXPORTING
        z_object = z_object.
3) Get structure of your ITAB (can be ANY itab including deep structures)
CALL METHOD z_object->return_structure.
4)  build your FCAT automatically using the structure returned from 3).
CALL METHOD z_object->create_dynamic_fcat
      IMPORTING
        it_fldcat = it_fldcat.
5)  build dynamic table
CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
      it_fieldcatalog = it_fldcat
    IMPORTING
      ep_table        = dy_table.
6) * Create dynamic work area and assign to FS
ASSIGN dy_table->* TO <dyn_table>.
  CREATE DATA dy_line LIKE LINE OF <dyn_table>.
  ASSIGN dy_line->* TO <dyn_wa>.
7) Fill it
PERFORM populate_dynamic_itab.
8)  Now display Display ALV grid with our EXIT tool button
CALL METHOD z_object->display_grid
       CHANGING it_fldcat = it_fldcat.
If you look in the method display_grid you'll see that the method can call ALV classes and functions.
Isn't the above much easier than messing around with obsolete function modules --and you can write virtually the same code for ANY table. You can also in the events add eitable functions etc.
In fact we could even make it simpler.
I'll try and post the code later but in fact we could get the CLASS to do almost the entire thing so the only statements you would actually need in your ABAP would be
Your Data
Instantiate the class.
Call the class with a new method to do all the coding up to generating the ITAB.
Populate your Itab
call the method to display your ITAB.
So your new abap would basically just have DATA, your ITAB structure,  2 method calls and a proceedure to fill your ITAB.
(Now your Boss won't take any excuses if it takes you longer than 20 Mins to code an ABAP containing even a complex table display. !!!!).
Cheers
Jimbo

Similar Messages

  • Can we call ALV Grid in another ALV Grid

    Hi,
      I have a requirement where I have an ALV List Displayed and for this we have an User Command and the User Defined Button Placed on the ALV List displaya another ALV Grid. Now the user want an User Command to be activated on the Second ALV Report to call a Third ALV Report.
       Could someone tell me whether this is feasible if so how can it be achieved.
    Thanks & Regards,
    YJR.

    Hi YJR,
      As far as feasibility of the requirement is concerned it is very subjective to your business process.
      But yes, it is possible.
      Just give a different callback user command in the call to ALV and write another form.
      That should solve your problem.
    Regards,
    Ravi

  • Calling ALV grid in class method

    Is it possible to call a ALV grid display in a class~method.
    I thought, I would call a screen and make a ALV grid display using the control frame work,it is no possible to call screen inside a method.
    Then i tried to avoid calling the screen..
    data: dockingleft type ref to cl_gui_docking_container,
            alv_left    type ref to cl_gui_alv_grid,
            repid type syrepid.
      repid = sy-repid.
      check dockingleft is initial.
      create object dockingleft
                  exporting repid     = repid
                            dynnr     = sy-dynnr
                            side      = dockingleft->dock_at_left
                            extension = 1700.
      create object alv_left
                    exporting i_parent = dockingleft .
      call method alv_left->set_table_for_first_display
          exporting
               i_structure_name       = 'SMESG'
          changing
               it_outtab       = TSMESG[]
      EXCEPTIONS
          INVALID_PARAMETER_COMBINATION = 1
          PROGRAM_ERROR                 = 2
          TOO_MANY_LINES                = 3
          others                        = 4.
    This doesn't seem to invoke the ALV grid. Any suggestions ?

    Hi,
    You need to call you custom screen with custom container like the following
      create object g_docking_container_1
        exporting
          repid     = g_repid
          dynnr     = '100'      "Place the custom container in 100
          extension = 1700
          side      = cl_gui_docking_container=>dock_at_left.
    then
      call method alv_left->set_table_for_first_display

  • Reg. can we display alv grid using field groups (extracts)

    Hi,
    can we display alv grid using field groups (extracts). is this possible. i have to develop a blocked alv.
    tnks
    Yerukala Setty

    No, you will need the data in an internal table to use ALV.
    Cheers
    Allan

  • How can we call "SP.UI.Notify.addNotification" methods in sharepoint designer page(.aspx) load without any onclick control?

    Hello Friends,
    How can we call "SP.UI.Notify.addNotification" methods in sharepoint designer page(.aspx) load without any onclick control?
    Scenario: When i was open my page i need to show below script,But here i used button control.
    <script type="text/javascript" src="/_layouts/14/MicrosoftAjax.js"></script><script src="/_layouts/14/sp.runtime.js" type="text/javascript"></script>
    <script src="/_layouts/14/sp.js" type="text/javascript"></script><script type="text/javascript">
    var strNotificationID;
    function showNofication()
     strNotificationID = SP.UI.Notify.addNotification("<font color='#AA0000'>In Progress..</font> <img src='/_Layouts/Images/kpiprogressbar.gif' align='absmiddle'> ", false);
    </script>
    <div class="ms-toolpanefooter"><input class="UserButton" onclick="Javascript:showNofication();" type="button" value="Show Nofitication"/> </div>
    Thanks
    Reddy

    Hi  Reddy,
    You can use the window.onload method for achieving your demand as below:
    <script type="text/javascript">
    window.onload=function(){
    </script>
    Hope this helps!
    Best Regards,
    Eric
    Eric Tao
    TechNet Community Support

  • Calling a Transaction from ALV Grid Using OO method

    Hi,
    My requirement is as follows....
    I have an ALV grid with columns such as PO no., GR no., Invoice no., etc...
    When I double click on any of these cells it should take me to the respective Transaction (say ME23n for PO no.) with the cell content as input in the transaction.
    Thanks and Regards,
    Navaneeth

    Hi,
      then u can write the code in HANDLE_DOUBLE_CLICK method
    CLASS LCL_EVENT_RECEIVER DEFINITION.
      PUBLIC SECTION.
        METHODS:
    *method used for double click
        HANDLE_DOUBLE_CLICK
            FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
                IMPORTING E_ROW E_COLUMN,
    ENDCLASS.                    "LCL_EVENT_RECEIVER DEFINITION
    CLASS LCL_EVENT_RECEIVER IMPLEMENTATION.
    *implementation of the method double click
    *when document no is double clicked in ALV GRID , its value is sent to
    *transaction FPE3 and the corresponding values of the document are
    *displayed
      METHOD HANDLE_DOUBLE_CLICK.
        CLEAR WA_WRT_OFF_FLDS.
        IF E_COLUMN = 'OPBEL'.
          READ TABLE ITAB INTO WA_IAB INDEX E_ROW-INDEX.
               set parameter....
               call transaction...
          endif.
           ENDMETHOD.                    "handle_double_click
    *method to remove unwanted icons from toolbar
    endclass.

  • Problem with focus with an ALV grid using object methods

    Hi, i have an editable ALV and there is something wrong that we haven't been able to solve it yet, hope you can understand my explanation
    Supose a grid 2 x 5
    cell 1 - cell 2 - Cell 3 - Cell 4 - Cell 5
    001      John      Doe
    So when a press tab or enter to the any cell diferent from cell 1 the focus get back to the cell 1, and i have to tab ( in this example) 3 times to fill cell 4, and then 4 times to fill cell 5
    Any ideas???
    ttorres

    Hi,
    Use method :SET_CURRENT_CELL_VIA_ID of grid to set the cursor position in a cell.
    Ex:
    CALL METHOD O_GRID->SET_CURRENT_CELL_VIA_ID
          EXPORTING
            IS_ROW_ID    = V_ROW
            IS_COLUMN_ID = V_COLUMN
            IS_ROW_NO    = V_ROW_NUM.
    use methods : get_current_cell_row_id, get_current_cell
    to get the required parameters for SET_CURRENT_CELL_VIA_ID.
    Regards
    Appana

  • I can't call more than 1 Java method from C

    Hi friends,
    I my program written in C i call two Java methods, but the first method execute correct but the second display a error message:
    Unexpected Signal : EXCEPTION_ACCESS_VIOLATION occurred at PC=0x6d475879
    Function name=JVM_FindSignal
    Library=d:\jdk1.3.1\jre\bin\hotspot\jvm.dll
    I inverted the functions, but ever the second function makes a error.
    This is my C program:
    #include "jni.h"
    #include <stdio.h>
    #include <windows.h>
    #include <stdlib.h>
    #include <string.h>
    char *getclasspath()
    char ambiente[100000];
    static char result[200000];
    strcpy(ambiente,"-Djava.class.path=");
    strcat(ambiente,getenv("CLASSPATH"));
    int tam=strlen(ambiente),i,tamresult=0;
    for(i=0;i<tam;i++)
    if(ambiente!='\\')
    result[tamresult++]=ambiente[i];
    else
    result[tamresult++]='\\';
    result[tamresult++]='\\';
    result[tamresult]=0;
    return result;
    char **__stdcall getServerList(int sessionId)
         JavaVM *vm;
         JNIEnv *env;
         JavaVMInitArgs vm_args;
         JavaVMOption options[1];
         options[0].optionString = getclasspath();
         vm_args.version = JNI_VERSION_1_2;
         vm_args.options = options;
         vm_args.nOptions = 1;
         vm_args.ignoreUnrecognized = 1;
         jclass cls;
         jmethodID mid;
         char *retorno;
         int i=0;
         int k=0;
         int j=0;
         char aux[100][100];
         char *lista_server[20];
         char **lista_server_ret;
         /* Invoca a m�quina virtual Java */
         jint res = JNI_CreateJavaVM(&vm, (void **)&env, &vm_args);
         if (res < 0)
              printf("Can't create Java VM\n");
              exit(1);
         /* Procura pela classe */
         cls = (jclass) env->NewGlobalRef(env->FindClass("br.com.cpqd.sagre.security.argus.SagreWebWrapper"));
         if (cls == 0)
              printf("Can't found br.com.cpqd.sagre.security.argus.SagreWebWrapper class\n");
              exit(1);
         /* Procurando o metodo Java getListServerStr */
         if ((mid = env->GetStaticMethodID (cls,"getServerListStr","(I)Ljava/lang/String;")) == 0)
              fprintf (stderr,"Metodo nao encontrado Str\n");
              exit(1);
         jint param = (jint) sessionId;
         /* Executa o m�todo */
         jstring str_java = (jstring) env->CallStaticObjectMethod(cls,mid,param);
         retorno = (char *) env->GetStringUTFChars(str_java,0);
         vm->DestroyJavaVM ();
         int len = strlen(retorno);
         for(i=0;i<len;i++)
         if(retorno[i]!=' ')
              aux[k][j]= retorno[i];
              j++;
         else
              aux[k][j]='\0';
              k++;
              j=0;
         for(i=0;i<k;i++)
              lista_server[i] = aux[i];
         lista_server_ret=(char**)lista_server;
         return lista_server_ret;
    char __stdcall encrypt(char clearText)
    static JavaVM *vm;
    static JNIEnv *env;
    JavaVMInitArgs vm_args;
    JavaVMOption options[1];
    options[0].optionString = getclasspath();
    /*     "-Djava.class.path=.;.\\SagreUtil.jar";*/
    vm_args.version = JNI_VERSION_1_2;
    vm_args.options = options;
    vm_args.nOptions = 1;
    vm_args.ignoreUnrecognized = 1;
    jclass cls;
    jobject obj;
    jmethodID mid;
    char *retorno;
    /* Invoca a m�quina virtual Java */
    jint res = JNI_CreateJavaVM(&vm, (void **)&env, &vm_args);
    if (res < 0)
    printf("Can't create Java VM\n");
    /* Procura pela classe */
    cls = env->FindClass("br.com.cpqd.sagre.security.argus.SagreWebWrapper");
    if (cls == 0)
    printf("Can't find br.com.cpqd.sagre.security.argus.SagreWebWrapper class\n");
    /* Procurando o metodo Java encrypt */
    if ((mid = env->GetMethodID (cls,"encrypt","(Ljava/lang/String;)Ljava/lang/String;")) == 0)
    fprintf (stderr,"Can't find the encrypt method\n");
    exit(1);
    jstring param = (jstring) env->NewStringUTF (clearText);
    /* Instancia o metodo */
    obj = env->NewObject(cls,mid,param);
    /* Executa o m�todo encrypt */
    jstring str_java = (jstring) env->CallObjectMethod(obj,mid,param);
    if(str_java!=0)
    retorno = (char *) env->GetStringUTFChars(str_java, 0);
    else
         vm->DestroyJavaVM ();
         return NULL;
    /* Destroi JVM */
    vm->DestroyJavaVM ();
    return retorno;
    int main()
         char **teste;
         char *wilson;
         teste = getServerList(-1);
         printf("Fine %s",teste[1]);
         wilson = encrypt("blablabla");
         printf("%s",wilson);
    I appreciate for any reply.
    [ ]'s
    Bruno

    vikram ..
    if u r using ms vc++ then there is an option in the directories tab to specify various include files.
    if this doesn't work then u can use the command line compiler for vc++ , cl.exe. using cl u can give the -I option and specify the path of whatever file u want to add.
    as for the specific file <jni.h> u can find it at :
    driveletter:\jdk1.x\include
    though i have never used this file as an include statement in .c files that i use for jni.
    Dum Spiro Spero

  • Can I call an object with synchronized methods from an EJB

    I have a need for multiple threads (e.g. Message Driven Beans) to access a shared object, lets say a singleton, I'm aware of the "you can't have a singleton in the EJB world" issues) for read/write operations, so the operations will need to be synchronised.
    I've seen various statements such as you can't use read/write static fields in EJBs and you can't use synchronisation primitives in EJBs but I've also seen statements that say its okay to access utility classes such as Vector (which has synchronised methods) from an EJB.
    Does anyone know if there is a definitive answer on this? What are the implications of accessing a shared object with synchronised methods from multiple EJBs? Is it just that the EJB's thread may block which limits the ability of the container to manage the EJBs? In the Vector example above (from Professional Java Server Programming) did they mean its okay to use these utility classes provided they aren't shared across threads?
    If I can't use a plain old Java Object does anyone know if there are other potential solutions for sharing objects across EJBs?
    In my problem, I have an operation that I want to run in a multi-threaded way. Each thread will add information to the shared object, and this info may be used by the other threads. There's no lengthy blocking as such other than the fact that only one thread can be adding/reading information from the shared object at a time.
    I've trawled through this forum looking for similar questions of which there seem to be many, but there doesn't seem to be any definitive answers (sorry if there was and I missed it).
    Thanks
    Martin

    You can share objects among EJB's or among objects used by one or more EJB's. You can use synchronization primitives - nothing will prevent you from doing that.
    After all, the container classes, JVM-provides classes, JDBC, JCA, JNDI and other such classes do all of this with impunity. You can too. You can use file and socket I/O as well, presuming you configure the security profile to allow it. Should you? Well it depends on what you need to accomplish and if there is another practical alternative.
    Yes the specification warns you not to, but you cannot be responsible for the interior hidden implementation of classes provided to you by the JVM or third parties so you can never truly know if your are breaking these written rules.
    But when you do these things, you are taking over some part of the role of the container. For short running methods that only block while another thread is using the method or code block and no I/O or use of other potentially blocking operations are contained in the method/block, you will be fine. If you don't watch out and create deadlocks, you will harm the container and its managed thread pool.
    You should not define EJB methods as synchronized.
    Also, if you share objects between EJB's, you need to realize that the container is free to isolate pools of your EJB in separate classloaders or JVM's. It's behavior can be influenced by your packaging choices (use of .ear, multiple separate .jar's, etc.) and the configuration of the server esp. use of clustering. This will cause duplicate sets of shared classes - so singletons will not necessarily be singleton across the entire server/cluster, but no single EJB instance will see more than one of them. You design needs to be tolerant of that fact in order to work correctly.
    This isn't the definitive answer you asked for - I'll leave that to the language/spec lawyers out there. But in my experience I have run across a number of occasions where I had to go outside of the written rules and ave yet to be burned for it.
    Chuck

  • ECATT SAPGUI method to capture ALV grid contents

    Dear All,
    I am using eCATT SAPGUI method to record the transaction VF04. The problem here is I am unable to capture the contents of the ALV grid present in the transaction.
    Were any one of you able to capture the contents of ALV grid using SAPGUI method, if so, please do help me to solve this problem.
    Thanks in advance,
    Sidharth

    Hi Sidharth,
    Did u find any solution for this problem .
    Iam facing same problem for MRIS,MRRL alv reports.Iam recording through SAP GUI but I want One out put field in log. If U find any solution for this plz forward to me.
    Thanks in advance
    Raju.K

  • Custom total/subtotal formula in an ALV Grid and printing.

    I have an ALV grid using OOPs method (Class cl_gui_alv_grid). The table that I am displaying is a dynamic table.
    call method o_grid->set_table_for_first_display
        exporting
          is_variant      = gx_variant
          i_save          = 'A'
          is_layout       = gs_layout
        changing
          it_fieldcatalog = it_fldcat
          it_outtab       = <gt_tabletotal>.
    On one of the columns in the ALV grid, instead of the regular summation, I had to do weighted averages (not avg).
    I built a logic to manipulate this total field for that column using field symbols.
    CALL METHOD o_grid->get_subtotals
        IMPORTING ep_collect00 = total
                  ep_collect01 = subto.
    ASSIGN total->* TO <ftotal>.
    ASSIGN subto->* TO <fsubto>.
    CALL METHOD o_grid->refresh_table_display
       EXPORTING I_SOFT_REFRESH = '1' .
    I manipulated <ftotal>-mycustomformulafield field there using some logic.
    In my field catalog i have the above field with wa_it_fldcat-do_sum = 'X ' .
    Now, II am able to see my custom formula on the screen. But when I print the grid using the print button or when I export to an excel sheet(I use export to local file and then select excel there) , my custom formula that i calculated above is reset to 0.000 .
    (Also when I email the grid, my custom formula is wiped). How can I avoid this ? Any useful suggestion is well appreciated.

    Hi, Shareen,
    We have the same problema here.
    Could you solve it?
    Thanks in advance

  • Header in alv grid using class

    Hello All,
        I developed alv grid using class method.
    First I created CREATE OBJECT GR_CCONTAINER
    then  CREATE OBJECT GR_ALVGRID
    then  PERFORM FIELD_CATALOG TABLES GT_FIELDCAT----
    for field catalog
        PERFORM LAYOUT CHANGING GS_LAYOUT.----
    for header
        p_gs_layout-grid_title = 'class method'.
      p_gs_layout-sel_mode = 'D'.
      APPEND P_GS_LAYOUT TO IT_LAYOUT.
    and finally CALL METHOD GR_ALVGRID->SET_TABLE_FOR_FIRST_DISPLAY
    the report is cooming fine but in header it comes only "class method".
    but i need also
    1. reporting date
    2. reporting time.
       can any body tell me how i can i put 2 more heading line
    Thanks,
    Rakesh

    Hi Dude,
    Please refer the below link how to handle  the header in alv using abap oo
    https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/abapObjects-ALVModel-UsingHeaderand+Footer
    Hope it clears,..............
    Thanks & Regards
    Ramakrishna Pathi

  • Reg alv grid  using module pool programming

    Dear Friends,
    I have a situation where i am using alv grid in module programming where in when i click the total button in the tool bar for any numeric column, the screen goes for a run time error.
    I have giving all conditions such as made the column in the field structure of lvc_field_catalog as do_sum = 'X',
    still goes for a dump...can anyone throw some hints to do more or the reason behind this and also have not excluded the function code for this total pushbutton while passing to the method set_table_for_first_display
    thanks...

    hi,
    check this up
    internal tables
    DATA: i_tab TYPE TABLE OF zchangereq,
    w_tab TYPE zchangereq.
    display field details
    DATA: w_field_cat_wa TYPE lvc_s_fcat. " Field Catalog work area
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-020.
    PARAMETERS: p_outs RADIOBUTTON GROUP g1,
    p_comp RADIOBUTTON GROUP g1.
    SELECTION-SCREEN END OF BLOCK b1.
    *MACROS
    DEFINE add_field.
    &1 = FIELDNAME &2 = HEADING &3 = Key field flag
    clear w_field_cat_wa.
    w_field_cat_wa-fieldname = &1.
    lw_field_cat_wa-ref_table = p_ref_table.
    lw_field_cat_wa-inttype = p_inttype.
    lw_field_cat_wa-decimals = p_decimals.
    lw_field_cat_wa-coltext = p_coltext.
    lw_field_cat_wa-seltext = p_seltext.
    lw_field_cat_wa-do_sum = p_do_sum.
    lw_field_cat_wa-no_out = p_no_out.
    lw_field_cat_wa-col_pos = p_col_pos.
    lw_field_cat_wa-reptext = p_coltext.
    lw_field_cat_wa-colddictxt = p_colddictxt.
    w_field_cat_wa-scrtext_m = &2.
    w_field_cat_wa-key = &3.
    append w_field_cat_wa to i_field_cat.
    END-OF-DEFINITION.
    ALV specific Declarations...........................................
    ALV specific Internal table declarations.............................
    DATA: i_field_cat TYPE lvc_t_fcat, " Field catalogue
    i_alv_sort TYPE lvc_t_sort. " Sort table
    ALV variables........................................................
    DATA: w_alv_layout TYPE lvc_s_layo, " ALV Layout
    w_alv_save TYPE c, " ALV save
    w_alv_variant TYPE disvariant. " ALV Variant
    ALV Class definitions................................................
    CLASS lcl_event_handler DEFINITION.
    PUBLIC SECTION.
    METHODS: handle_double_click
    FOR EVENT double_click OF cl_gui_alv_grid
    IMPORTING e_row e_column.
    METHODS: handle_hotspot
    FOR EVENT hotspot_click OF cl_gui_alv_grid
    IMPORTING e_row_id e_column_id.
    ENDCLASS. " CLASS LCL_EVENT_HANDLER DEF..
    ALV Class implementation............................................
    In the Event of a Double Click drill down to the corresponding CHANGE REQUEST
    CLASS lcl_event_handler IMPLEMENTATION.
    METHOD handle_double_click.
    DATA: l_tab LIKE LINE OF i_tab.
    CHECK e_row-rowtype(1) EQ space.
    READ TABLE i_tab INDEX e_row-index INTO l_tab.
    SET PARAMETER ID 'ZTY' FIELD l_tab-ztype.
    SET PARAMETER ID 'ZCR' FIELD l_tab-zcref.
    CALL TRANSACTION 'ZCRT' AND SKIP FIRST SCREEN.
    ENDMETHOD. " HANDLE_DOUBLE_CLICK
    not working yet - hotspot seems to stay in the gui!!
    METHOD handle_hotspot.
    DATA: l_tab LIKE LINE OF i_tab.
    CHECK e_row_id-rowtype(1) EQ space.
    READ TABLE i_tab INDEX e_row_id-index INTO l_tab.
    SET PARAMETER ID 'ZTY' FIELD l_tab-ztype.
    SET PARAMETER ID 'ZCR' FIELD l_tab-zcref.
    CALL TRANSACTION 'ZCRT' AND SKIP FIRST SCREEN.
    ENDMETHOD. " HANDLE_DOUBLE_CLICK
    ENDCLASS. " CLASS LCL_EVENT_HANDLER IMPL...
    ALV Grid Control definitions........................................
    DATA:
    ALV Grid Control itself
    o_grid TYPE REF TO cl_gui_alv_grid,
    Container to hold the ALV Grid Control
    o_custom_container TYPE REF TO cl_gui_custom_container,
    Event handler (defined in the class above)
    o_event_handler TYPE REF TO lcl_event_handler.
    INITIALIZATION.
    PERFORM create_field_catalogue. " Create ALV Field Catalog
    START-OF-SELECTION.
    Outstanding requests
    IF p_outs = 'X'.
    SELECT * FROM zchangereq
    INTO TABLE i_tab
    WHERE zstatus < 99.
    ELSE.
    completed requests
    SELECT * FROM zchangereq
    INTO TABLE i_tab
    WHERE zstatus = 99.
    ENDIF.
    END-OF-SELECTION.
    PERFORM list_output_to_alv. " Perform ALV Output operations
    FORM LIST_OUTPUT_TO_ALV *
    This subroutine is used to call the screen for ALV Output. *
    There are no interface parameters to be passed to this subroutine. *
    FORM list_output_to_alv.
    CALL SCREEN 100.
    ENDFORM. " LIST_OUTPUT_TO_ALV
    Module STATUS_0100 OUTPUT *
    This is the PBO module which will be processed befor displaying the *
    ALV Output. *
    MODULE status_0100 OUTPUT.
    SET PF-STATUS '0100'. " PF Status for ALV Output Screen
    IF p_outs = 'X'.
    SET TITLEBAR 'STD'.
    ELSE.
    completed requests
    SET TITLEBAR 'COMP'.
    ENDIF.
    CREATE OBJECT: o_custom_container
    EXPORTING container_name = 'SC_GRID',
    o_grid
    EXPORTING i_parent = o_custom_container.
    PERFORM define_alv_layout. " ALV Layout options definitions
    PERFORM save_alv_layout_options. " save ALV layout options
    PERFORM call_alv_grid. " Call ALV Grid Control
    ENDMODULE. " STATUS_0100 OUTPUT
    Module USER_COMMAND_0100 INPUT *
    This is the PAI module which will be processed when the user performs*
    any operation from the ALV output. *
    MODULE user_command_0100 INPUT.
    CASE sy-ucomm.
    WHEN 'EXIT' OR 'BACK' OR 'CANC'.
    may need to do this so display is refreshed if other report selected
    CALL METHOD o_custom_container->free.
    SET SCREEN 0.
    ENDCASE.
    ENDMODULE. " USER_COMMAND_0100 INPUT
    FORM DEFINE_ALV_LAYOUT *
    This subroutine is used to Define the ALV layout. *
    FORM define_alv_layout .
    w_alv_layout-numc_total = 'X'. " Numc total line
    w_alv_layout-cwidth_opt = 'X'. " Optimal column width
    w_alv_layout-detailinit = 'X'. " Show values that are initial in
    " detail list.
    w_alv_layout-sel_mode = 'A'. " Column selection mode
    w_alv_layout-no_merging = 'X'. " No merging while sorting columns
    w_alv_layout-keyhot = 'X'.
    ENDFORM. " DEFINE_ALV_LAYOUT
    FORM SAVE_ALV_LAYOUT_OPTIONS *
    This subroutine is used to Save the ALV layout options. *
    FORM save_alv_layout_options.
    See the ALV grid control documentation for full list of options
    w_alv_save = 'A'.
    w_alv_variant-report = sy-repid.
    ENDFORM. " SAVE_ALV_LAYOUT_OPTIONS
    FORM CALL_ALV_GRID *
    This subroutine is used to call ALV Grid control for processing. *
    FORM call_alv_grid.
    CALL METHOD o_grid->set_table_for_first_display
    EXPORTING
    is_layout = w_alv_layout
    i_save = w_alv_save
    is_variant = w_alv_variant
    CHANGING
    it_outtab = i_tab[]
    it_sort = i_alv_sort
    it_fieldcatalog = i_field_cat.
    Link used Events and Event Handler Methods
    CREATE OBJECT o_event_handler.
    Set handler o_event_handler->handle_top_of_page for o_grid.
    SET HANDLER o_event_handler->handle_double_click FOR o_grid.
    ENDFORM. " CALL_ALV_GRID
    *& Form create_field_catalogue
    set up field catalogue
    FORM create_field_catalogue .
    Fieldname Heading Key?
    *eg add_field 'ZTYPE' 'Type' 'X'.
    ENDFORM. " create_field_catalogue

  • Sizeable alv grid using set_table_for_first_display

    I would like to be able to resize the alv grid.
    The abap program is executing in a MS-Windows environment
    MS-window, with SAP session,  can be re-sized yet alv grid stays same size
    I would like to be able to re-size (make bigger or smaller) once the MS-window has been maximized
    Using
    CALL METHOD grid->set_table_for_first_display
        EXPORTING
          is_variant      = w_hr_data_grid_layout_variants
          i_save          = w_hr_data_save_layout_option
          is_layout       = gs_layout
        CHANGING
          it_fieldcatalog = gt_fieldcat[]
          it_outtab       = t_reported_pos_std_table
          it_sort         = it_sort.

    Hi,
    It may not be possible to resize the ALV grid using the methods of the CL_GUI_ALV_GRID. It would be possible through the methods of the custom container class CL_GUI_CUSTOM_CONTAINER because the grid id attached to the container. There is an event SIZE_CONTROL in the CL_GUI_CUSTOM_CONTAINER class which may be useful for you.
    regards,
    Sharat.

  • How to Transfer Data from editable ALV grid control to internal table?

    Hi,
    Can anyone give me a simple example by which I can transfer data from editable alv grid control back to the internal table. The ALV has been created by OO approach.
    I would appreciate if the solution is provided without handling any events.
    Regards,
    Auro

    Hello Auro
    You simply need to call method <b>go_grid->check_changed_data</b> at PAI of the dynpro displaying the ALV grid. If data have been changed on the editable ALV grid then this method will raise event DATA_CHANGED. If you do not want or need to handle this event (e.g. for validating the edited values) then you do not define any event handler method.
    Regards
      Uwe

Maybe you are looking for