Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ALV's

Former Member
0 Likes
809

A report to be generated to know the non-moving material in a particular period for a particular plant and storage location.the output need to be an ALV grid display.

A report to be generated to know the non-moving material in a particular period for a particular plant and storage location.the output need to be an ALV grid display.

5 REPLIES 5
Read only

Former Member
0 Likes
736

hi,

1. Please give me general info on ALV.

http://www.sapfans.com/forums/viewtopic.php?t=58286

http://www.sapfans.com/forums/viewtopic.php?t=76490

http://www.sapfans.com/forums/viewtopic.php?t=20591

http://www.sapfans.com/forums/viewtopic.php?t=66305 - this one discusses which way should you use - ABAP Objects calls or simple function modules.

2. How do I program double click in ALV?

http://www.sapfans.com/forums/viewtopic.php?t=11601

http://www.sapfans.com/forums/viewtopic.php?t=23010

3. How do I add subtotals (I have problem to add them)...

http://www.sapfans.com/forums/viewtopic.php?t=20386

http://www.sapfans.com/forums/viewtopic.php?t=85191

http://www.sapfans.com/forums/viewtopic.php?t=88401

http://www.sapfans.com/forums/viewtopic.php?t=17335

4. How to add list heading like top-of-page in ABAP lists?

http://www.sapfans.com/forums/viewtopic.php?t=58775

http://www.sapfans.com/forums/viewtopic.php?t=60550

http://www.sapfans.com/forums/viewtopic.php?t=16629

5. How to print page number / total number of pages X/XX in ALV?

http://www.sapfans.com/forums/viewtopic.php?t=29597 (no direct solution)

6. ALV printing problems. The favourite is: The first page shows the number of records selected but I don't need this.

http://www.sapfans.com/forums/viewtopic.php?t=64320

http://www.sapfans.com/forums/viewtopic.php?t=44477

7. How can I set the cell color in ALV?

http://www.sapfans.com/forums/viewtopic.php?t=52107

8. How do I print a logo/graphics in ALV?

http://www.sapfans.com/forums/viewtopic.php?t=81149

http://www.sapfans.com/forums/viewtopic.php?t=35498

http://www.sapfans.com/forums/viewtopic.php?t=5013

9. How do I create and use input-enabled fields in ALV?

http://www.sapfans.com/forums/viewtopic.php?t=84933

http://www.sapfans.com/forums/viewtopic.php?t=69878

10. How can I use ALV for reports that are going to be run in background?

http://www.sapfans.com/forums/viewtopic.php?t=83243

http://www.sapfans.com/forums/viewtopic.php?t=19224

11. How can I display an icon in ALV? (Common requirement is traffic light icon).

http://www.sapfans.com/forums/viewtopic.php?t=79424

http://www.sapfans.com/forums/viewtopic.php?t=24512

12. How can I display a checkbox in ALV?

http://www.sapfans.com/forums/viewtopic.php?t=88376

http://www.sapfans.com/forums/viewtopic.php?t=40968

http://www.sapfans.com/forums/viewtopic.php?t=6919

Link containing all the important PDFS. ( There is a PDF for ALV Grid in this link)

http://www.easymarketplace.de/online-pdfs.php

Hope this helps, Do reward.

Read only

0 Likes
736

Hi

I'm afraid posts like these containing numerous links obviously "cut and pasted" from zillions of previous posts on this topic (some of which don't even work any more or are so old that they make DINOSAUR TECHNOLOGY seem modern by comparison) don't help the OP in any way whatsoever.

Zillions of links don't help in any case even if the links were good -- there is such a thing as "Information Overload" especially for new comers to the subject. One (or at the most 2) helpful links are all that is needed in these cases.

Whilst I'm totally also against some Abapper trying to get his / her whole project developed for free via SDN or other sites without the person concerned at least having to do some work I can appreciate (judging by the volumes of posts on ALV GRIDS still using the old obsolete SLIS function modules) that OO concepts are not necessarily the easiest to grasp -- but the SIMPLEST WAY TO LEARN THIS STUFF is to actually DO IT.

The stupid plane / airline application that SAP uses isn't also of much help either.

The best way is to provide the code for simple understandable application which can be used as model for further learning and development.

So here's a simple piece of code but the OP will have to create a screen (SE51) with a custom container on it called CCUSTOM1 and a standard status 001 (SE41) with BACK, EXIT and CANCEL buttons on it and a titlebar 000. (If the OP can't do this at least for him/herself) then what are they doing working as an Abapper.

This will display sales orders, materials, customer etc (up to 200 entries).

The order number is a hotspot Mouse click on order will display VA03 order details.

If you double click on the other columns the material / customer etc is displayed.

You can also edit the cell contents (not the order number but the other ones). The data entry doesn't actually do anything except calls the routine and issues a break point where you can code your own stuff to handle data entry.

It's just used as a model for developing your own code.

I've used table VAPMA - link for orders==>material==> customers as most people usually have sales (SD) data in their systems. I assume most businesses actually are trying to SELL something to make money.



PROGRAM zzz_simple_editable_grid.
INCLUDE <icon>.
DATA grid1 TYPE REF TO cl_gui_alv_grid.
DATA grid2 TYPE ref to cl_gui_alv_grid.
DATA: es_row_no TYPE lvc_s_roid,
     ls_row_id  TYPE lvc_s_row,
     ls_col_id TYPE  lvc_s_col,
     ls_row    TYPE i,
     ls_value  TYPE c,
     ls_col    TYPE i,
     ls_row_no  TYPE lvc_s_roid.

CLASS lcl_event_handler DEFINITION .
  PUBLIC SECTION .
    METHODS:
**Hot spot Handler
    handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
                      IMPORTING e_row_id e_column_id es_row_no,
**Double Click Handler
    handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
                                    IMPORTING e_row e_column es_row_no,
** Toolbar handler.
 handle_toolbar
        FOR EVENT toolbar OF cl_gui_alv_grid
            IMPORTING e_object e_interactive,
* button press
    handle_user_command
        FOR EVENT user_command OF cl_gui_alv_grid
            IMPORTING e_ucomm,
* data changed
 handle_data_changed
    for event data_changed of cl_gui_alv_grid
      importing er_data_changed,
*data changed finished
 handle_data_changed_finished
     for event data_changed of cl_gui_alv_grid.


ENDCLASS.                    "lcl_event_handler DEFINITION


CLASS lcl_event_handler IMPLEMENTATION.

*Handle Hotspot Click
  METHOD handle_hotspot_click .
    PERFORM mouse_click
      USING e_row_id
            e_column_id.
    CALL METHOD grid1->get_current_cell
       IMPORTING
         e_row     = ls_row
         e_value   = ls_value
         e_col     = ls_col
         es_row_id = ls_row_id
        es_col_id = ls_col_id
        es_row_no = es_row_no.


    CALL METHOD grid1->refresh_table_display.
    CALL METHOD grid1->set_current_cell_via_id

  EXPORTING
    is_column_id =  e_column_id
    is_row_no  =  es_row_no.



  ENDMETHOD.                    "lcl_event_handler

*Handle Double Click
  METHOD  handle_double_click.

    PERFORM double_click
       USING e_row
       e_column.

    CALL METHOD grid1->get_current_cell
    IMPORTING
    e_row     = ls_row
    e_value   = ls_value
    e_col     = ls_col
    es_row_id = ls_row_id
   es_col_id = ls_col_id
   es_row_no = es_row_no.

    CALL METHOD grid1->refresh_table_display.

    CALL METHOD grid1->set_current_cell_via_id

  EXPORTING
    is_column_id =  ls_col_id
    is_row_no  =  es_row_no.



  ENDMETHOD.

  METHOD handle_toolbar.
    DATA: ls_toolbar  TYPE stb_button.
* append a separator to normal toolbar
    CLEAR ls_toolbar.
    MOVE 3 TO ls_toolbar-butn_type.
    APPEND ls_toolbar TO e_object->mt_toolbar.
* append an icon for your function
    CLEAR ls_toolbar.
    MOVE 'FUNC' TO ls_toolbar-function.
    MOVE icon_railway TO ls_toolbar-icon.
    MOVE 'Your Function' TO ls_toolbar-quickinfo.
    MOVE 'Your user function' TO ls_toolbar-text.
    MOVE ' ' TO ls_toolbar-disabled.
    APPEND ls_toolbar TO e_object->mt_toolbar.

  ENDMETHOD.
  METHOD handle_user_command.
    BREAK-POINT 1.
    CASE e_ucomm.
      WHEN 'FUNC'.    "Your button
* Perform what you need to do.
      WHEN OTHERS.
    ENDCASE.
  ENDMETHOD.

  method handle_data_changed.
  perform data_changed using er_data_changed.

  endmethod.                    "data_changed

  method handle_data_changed_finished.
    perform data_changed_finished.
  endmethod.                    "data_changed_finished

ENDCLASS.

* Define any structure
TYPES:  BEGIN OF s_elements,
  vbeln   TYPE vapma-vbeln,
  posnr   TYPE vapma-posnr,
  matnr   TYPE vapma-matnr,
  kunnr   TYPE vapma-kunnr,
  werks   TYPE vapma-werks,
  vkorg   TYPE vapma-vkorg,
  vkbur   TYPE vapma-vkbur,
  status  TYPE c,

END OF  s_elements.

* end of your structure
DATA:wa_elements TYPE s_elements.
DATA: ord_nr TYPE vapma-vbeln,
      mat_nr TYPE vapma-matnr,
      cus_nr TYPE vapma-kunnr.


DATA lr_rtti_struc TYPE REF TO cl_abap_structdescr .
DATA:
    zog                     LIKE LINE OF lr_rtti_struc->components .
DATA:
  zogt                    LIKE TABLE OF zog,
wa_it_fldcat TYPE lvc_s_fcat,
it_fldcat TYPE lvc_t_fcat ,
dy_line            TYPE REF TO data,
dy_table           TYPE REF TO data.


DATA:  dref               TYPE REF TO data.
FIELD-SYMBOLS: <fs> TYPE ANY,
   <dyn_table>    TYPE  STANDARD TABLE,
   <dyn_wa>.

DATA grid_container1 TYPE REF TO cl_gui_custom_container .
DATA grid_container2 type ref to cl_gui_custom_container.
DATA: g_handler TYPE REF TO lcl_event_handler. "handler

DATA: ok_code TYPE sy-ucomm.
DATA: struct_grid_lset TYPE lvc_s_layo.

START-OF-SELECTION.
*now I want to build a field catalog
* First get your data structure into a field symbol

  CREATE DATA dref TYPE s_elements.
  ASSIGN dref->* TO <fs>.

  lr_rtti_struc ?= cl_abap_structdescr=>describe_by_data( <fs> ).

* Now get the structure details into a table.
* table zogt[] contains the structure details
* From which we can build the field catalog

  zogt[]  = lr_rtti_struc->components.
  LOOP AT zogt 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'.
    IF wa_it_fldcat-fieldname = 'VBELN'.
      wa_it_fldcat-hotspot = 'X'.
    ENDIF.
    APPEND wa_it_fldcat TO it_fldcat.

  ENDLOOP.
*
* You can perform any modifications / additions to your field catalog
* here such as your own column names etc.

* Now using the field catalog created above we can
* build a dynamic table
* and populate it

* First build the dynamic table
* the table will contain entries for
* our structure defined at the start of the program

  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 DATA dy_line LIKE LINE OF <dyn_table>.
  ASSIGN dy_line->* TO <dyn_wa>.

* Now fill our table with data

  SELECT vbeln posnr matnr kunnr werks vkorg vkbur
         UP TO 200 ROWS
         FROM vapma
         INTO  CORRESPONDING FIELDS OF TABLE <dyn_table>.

* Call the screen to display the grid
  CALL SCREEN 100.


FORM double_click
USING e_row   TYPE lvc_s_row
e_column      TYPE lvc_s_col.
  READ TABLE <dyn_table> INDEX e_row INTO wa_elements.

  CASE e_column-fieldname.
    WHEN 'MATNR'.
      mat_nr = wa_elements-matnr.
      SET PARAMETER ID 'MAT'  FIELD mat_nr.
      CALL TRANSACTION  'MM03' AND SKIP FIRST SCREEN.
    WHEN 'KUNNR'.
      cus_nr = wa_elements-kunnr.
      SET PARAMETER ID 'KUN'  FIELD cus_nr.
      CALL TRANSACTION  'XD03' AND SKIP FIRST SCREEN.
    WHEN OTHERS.
  ENDCASE.
  wa_elements-status = 'V'.
  MODIFY <dyn_table> FROM wa_elements INDEX e_row.

ENDFORM.

FORM mouse_click
  USING e_row TYPE lvc_s_row
        e_column_id TYPE  lvc_s_col.
  READ TABLE <dyn_table> INDEX e_row INTO wa_elements.


  ord_nr = wa_elements-vbeln.
  SET PARAMETER ID 'AUN'  FIELD ord_nr.

  CALL TRANSACTION  'VA03' AND SKIP FIRST SCREEN.
  wa_elements-status = 'V'.
  MODIFY <dyn_table> FROM wa_elements INDEX e_row.

ENDFORM.

form data_changed
  using er_data_changed.

  break-point 1.
endform.
form data_changed_finished.


  break-point 1.
endform.


form instantiate_grid
   using  grid_container  type REF TO cl_gui_custom_container
          class_object  type ref to cl_gui_alv_grid
          container_name type SCRFNAME.

          CREATE OBJECT grid_container
              EXPORTING
                container_name = container_name.
       CREATE OBJECT  class_object
       EXPORTING
          i_parent = grid_container.

         struct_grid_lset-sel_mode = 'D'.
  CREATE OBJECT g_handler.
  SET HANDLER g_handler->handle_double_click FOR class_object.
  SET HANDLER g_handler->handle_hotspot_click FOR class_object.
  SET HANDLER g_handler->handle_toolbar FOR class_object.
  SET HANDLER g_handler->handle_user_command FOR class_object.
  SET HANDLER g_handler->handle_data_changed FOR class_object.
  SET HANDLER g_handler->handle_data_changed_finished FOR class_object.
  CALL METHOD class_object->register_edit_event
       EXPORTING
          i_event_id = cl_gui_alv_grid=>mc_evt_enter.
       CALL METHOD class_object->set_table_for_first_display
    EXPORTING is_layout =  struct_grid_lset
    CHANGING
               it_outtab       = <dyn_table>
               it_fieldcatalog = it_fldcat.

endform.


* PBO module

MODULE status_0100 OUTPUT.

    IF grid_container1 IS INITIAL.
  perform instantiate_grid
     using grid_container1
           grid1
           'CCONTAINER1'.
     endif.


    SET PF-STATUS '001'.
  SET TITLEBAR '000'.

ENDMODULE.

* PAI module

MODULE user_command_0100 INPUT.
  CASE sy-ucomm.
    WHEN 'BACK'.
      LEAVE PROGRAM.
    WHEN 'EXIT'.
      LEAVE PROGRAM.
    WHEN 'RETURN'.
      LEAVE PROGRAM.
    WHEN OTHERS.
  ENDCASE.
ENDMODULE.

Cheers

jimbo

Read only

ThomasZloch
Active Contributor
0 Likes
736

>

> A report to be generated to know the non-moving material in a particular period for a particular plant and storage location.the output need to be an ALV grid display.

this must be the boldest, rudest attempt to have others do the work that I have seen in a while, even in this forum. Jimbo, all effort is wasted here.

Read only

0 Likes
736

Hi Thomas

Not to worry as I already had the code so it's no work - and having been a contractor in SAP for a number of years I'm not actually starving yet.

Whilst I know some really great people from The Indian sub-continent a lot of posts of the type you refer to do seem to come from this particular area. (Any Indian reading this -- please don't get offended --some guys are really good and knowledgeable -- it's a lot of the others who let the side down).

I'm glad that at least in Europe some of the original ideas that created the "Off Shoring" stuff for I-T are now being looked at again - and some stuff like ABAP , and Business Functional analysis is being bought back again.

Basic functions like help desks and network services work great but business functionality and abap coding I'm afraid really don't work off shore and it's great to see this stuff being developed again in Europe.

Moderating Forums is hugely time consuming - especially if people have regular jobs as well so I can understand the problems here.

What really does amaze me however is how "Scared"some people seem to be of pressing F1 for help on the most basic Abap question or even a little bit of googling or search on the SDN forums BEFORE POSTING their questions.

We were all beginners once but I'm sure we all used to to a little bit of research before posting questions.

Cheers

Jimbo

Read only

0 Likes
736

all agreed. Visit us at coffee corner for ongoing discussions of these topics

Cheerio

Thomas