{"id":489,"date":"2013-04-26T10:15:18","date_gmt":"2013-04-26T09:15:18","guid":{"rendered":"http:\/\/oprsteny.cz\/?p=489"},"modified":"2013-04-30T10:49:56","modified_gmt":"2013-04-30T09:49:56","slug":"alv-tutorial-01-basic-alv","status":"publish","type":"post","link":"https:\/\/oprsteny.cz\/?p=489","title":{"rendered":"ALV tutorial 01 &#8211; Basic ALV"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"358\" data-permalink=\"https:\/\/oprsteny.cz\/?attachment_id=358\" data-orig-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/SAP.jpg\" data-orig-size=\"44,50\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Picasa&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1365690880&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"SAP\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/SAP.jpg\" class=\"alignleft size-full wp-image-358\" alt=\"SAP\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/SAP.jpg\" width=\"44\" height=\"50\" \/>In this first step we&#8217;ll create the core of ALV &#8211; just grab some data and display it in form of ALV grid<!--more--><\/p>\n<ol>\n<li>Run TCode SE80 and create new program<\/li>\n<li>In this program create new screen 0100<\/li>\n<li>In the object tree double click on screen 0100 and in tab &#8220;Flow logic&#8221; enter the following code:\n<pre lang=\"abap\">PROCESS BEFORE OUTPUT.\r\n  MODULE STATUS_0100.    \" Just un-comment this line\r\n*\r\nPROCESS AFTER INPUT.\r\n* MODULE USER_COMMAND_0100.<\/pre>\n<\/li>\n<li>Double click on line <code>MODULE STATUS_0100<\/code> and create it&#8217;s definition within the main program with the following contents:\n<pre lang=\"abap\">MODULE status_0100 OUTPUT.\r\n  PERFORM read_data.\r\n  PERFORM display_grid.\r\nENDMODULE.<\/pre>\n<\/li>\n<li>Now write the program<br \/>\nNote: We will use the whole screen to display the ALV grid so we don&#8217;t have to create a container on screen 0100. Screen&#8217;s 0100 container is returned by command <code>cl_gui_container=&gt;default_screen<\/code> or\u00a0<code>cl_gui_container=&gt;screen0<\/code>.<\/p>\n<pre lang=\"abap\">DATA:\r\n  gt_data TYPE TABLE OF sflight,\r\n  g_grid TYPE REF TO cl_gui_alv_grid.\r\n\r\nCONSTANTS:\r\n  c_max_rows TYPE i VALUE 100.\r\n\r\nCALL SCREEN 100.\r\n\r\n*&amp;---------------------------------------------------------------------*\r\n*&amp;      Form  read_data\r\n*&amp;---------------------------------------------------------------------*\r\nFORM read_data.\r\n  SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_data\r\n    FROM sflight\r\n    UP TO c_max_rows ROWS.\r\nENDFORM.                    \r\n\r\n*&amp;---------------------------------------------------------------------*\r\n*&amp;      Form  display_grid\r\n*&amp;---------------------------------------------------------------------*\r\nFORM display_grid.\r\n  CREATE OBJECT g_grid\r\n    EXPORTING\r\n      i_parent = cl_gui_container=&gt;default_screen.\r\n\r\n  CALL METHOD g_grid-&gt;set_table_for_first_display\r\n    EXPORTING\r\n      i_structure_name              = 'SFLIGHT'\r\n    CHANGING\r\n      it_outtab                     = gt_data\r\n    EXCEPTIONS\r\n      invalid_parameter_combination = 1\r\n      program_error                 = 2\r\n      too_many_lines                = 3\r\n      OTHERS                        = 4.\r\n  IF sy-subrc &lt;&gt; 0.\r\n    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno\r\n               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.\r\n  ENDIF.\r\nENDFORM.<\/pre>\n<\/li>\n<li>Output will look like this:<a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/ALV_DEMO_01.png\"><img decoding=\"async\" data-attachment-id=\"476\" data-permalink=\"https:\/\/oprsteny.cz\/?attachment_id=476\" data-orig-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/ALV_DEMO_01.png\" data-orig-size=\"\" data-comments-opened=\"1\" data-image-meta=\"[]\" data-image-title=\"Basic ALV &amp;#8211; Output\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/ALV_DEMO_01.png\" class=\"alignleft size-full wp-image-476\" alt=\"Basic ALV - Output\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/ALV_DEMO_01.png\" \/><\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>In this first step we&#8217;ll create the core of ALV &#8211; just grab some data and display it in form of ALV grid<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[16,136,9],"tags":[446,447,17,111],"class_list":["post-489","post","type-post","status-publish","format-standard","hentry","category-abap","category-alv-tutorial","category-development","tag-abap","tag-alv","tag-sap","tag-screen"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p3nYbe-7T","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/489","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=489"}],"version-history":[{"count":4,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/489\/revisions"}],"predecessor-version":[{"id":567,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/489\/revisions\/567"}],"wp:attachment":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=489"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=489"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=489"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}