Wednesday, February 1, 2017

Multiple ALVs with Different Header

In the following example we have prepared two ALV Grid report in one single screen. There are two custom screens – one is for finished goods materials and another is for Raw materials. We also have mentioned two different header texts by using the Layout. Step by step approach is as follows:

1. At first create a report and create a custom screen (9000) without modifying the standard one.


2. Go to Layout and then create the custom containers (here 2 is in our example).


3. Now create the PBO & PAI modules at the custom screen.


4. In PBO we are creating custom container, ALV grid & calling the ALV grid method along with PF status & Title Bar.





5. In PAI the BACK, EXIT & CANCEL buttons are activated.


The detailed coding is as follows.

REPORT zsr_test NO STANDARD PAGE HEADING.

TABLESmara.

"-General Material Data
TYPESBEGIN OF ty_mara,
         matnr TYPE mara-matnr,
         ersda TYPE mara-ersda,
         mtart TYPE mara-mtart,
       END OF ty_mara.
DATAwa_mara TYPE ty_mara,
      it_mara TYPE TABLE OF ty_mara.

"-Material Descriptions
TYPESBEGIN OF ty_makt,
         matnr TYPE makt-matnr,
         maktx TYPE makt-maktx,
       END OF ty_makt.
DATAwa_makt TYPE ty_makt,
      it_makt TYPE TABLE OF ty_makt.

"-Output Table
TYPESBEGIN OF ty_out,
         matnr TYPE mara-matnr,
         maktx TYPE makt-maktx,
         ersda TYPE mara-ersda,
         mtart TYPE mara-mtart,
       END OF ty_out.
DATAwa_out TYPE ty_out,
      it_fg  TYPE TABLE OF ty_out"-Finished Goods Table
      it_rm  TYPE TABLE OF ty_out"-Raw Materials Table

"-Field Catalouge
DATAwa_fcat TYPE lvc_s_fcat,
      it_fcat TYPE TABLE OF lvc_s_fcat.

"-Custom Container Object
DATAob_cont_fg TYPE REF TO cl_gui_custom_container,
      ob_cont_rm TYPE REF TO cl_gui_custom_container.

"-ALV Grid Object
DATAob_grid_fg TYPE REF TO cl_gui_alv_grid,
      ob_grid_rm TYPE REF TO cl_gui_alv_grid.

"-Layout
DATAwa_lay_fg TYPE lvc_s_layo,
      wa_lay_rm TYPE lvc_s_layo,
      ok_code   TYPE sy-ucomm.

INITIALIZATION.
  SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
  SELECT-OPTIONS   s_ersda FOR mara-ersda OBLIGATORY.
  SELECTION-SCREEN END OF BLOCK b1.

CLASS cl_material DEFINITION.
  PUBLIC SECTION.
    METHODS:
      get_material,
      prepare_output,
      fieldcat.
ENDCLASS.

CLASS cl_material IMPLEMENTATION.
  METHOD get_material.
    IF s_ersda[] IS NOT INITIAL.
      SELECT matnr ersda mtart
        FROM mara INTO TABLE it_mara
        WHERE ersda IN s_ersda
          AND mtart IN 'FERT''ROH' ).

      "-FERT - Finished Goods
      "-ROH  - Raw Materials

      IF sy-subrc 0.
        SORT it_mara BY matnr.
        SELECT matnr maktx
          FROM makt INTO TABLE it_makt
          FOR ALL ENTRIES IN it_mara
          WHERE matnr it_mara-matnr.

        IF sy-subrc 0.
          SORT it_makt BY matnr.
        ENDIF.
      ENDIF.
    ENDIF.
  ENDMETHOD.

  METHOD prepare_output.
    IF it_mara IS NOT INITIAL.
      LOOP AT it_mara INTO wa_mara.
        READ TABLE it_makt INTO wa_makt
        WITH KEY matnr wa_mara-matnr
        BINARY SEARCH.
        IF sy-subrc 0.
          wa_out-maktx wa_makt-maktx.
        ENDIF.
        wa_out-matnr wa_mara-matnr.
        wa_out-ersda wa_mara-ersda.
        wa_out-mtart wa_mara-mtart.

        IF wa_out-mtart 'FERT'.
          APPEND wa_out TO it_fg.         "-Finished Goods Table
          CLEARwa_outwa_marawa_makt.

        ELSE.
          APPEND wa_out TO it_rm.         "-Raw Materials Table
          CLEARwa_outwa_marawa_makt.
        ENDIF.
      ENDLOOP.
    ENDIF.
    FREEit_marait_makt.
  ENDMETHOD.

  METHOD fieldcat.

    "-Creating Field Catalouge
    REFRESH it_fcat.
    DATAlv_col TYPE VALUE 0.
    lv_col            lv_col + 1.
    wa_fcat-col_pos   lv_col.
    wa_fcat-fieldname 'MATNR'.
    wa_fcat-reptext   'Material Code'.
    APPEND wa_fcat TO it_fcat.
    CLEAR wa_fcat.

    lv_col            lv_col + 1.
    wa_fcat-col_pos   lv_col.
    wa_fcat-fieldname 'MAKTX'.
    wa_fcat-reptext   'Description'.
    APPEND wa_fcat TO it_fcat.
    CLEAR wa_fcat.

    lv_col            lv_col + 1.
    wa_fcat-col_pos   lv_col.
    wa_fcat-fieldname 'ERSDA'.
    wa_fcat-reptext   'Created On'.
    APPEND wa_fcat TO it_fcat.
    CLEAR wa_fcat.

    lv_col            lv_col + 1.
    wa_fcat-col_pos   lv_col.
    wa_fcat-fieldname 'MTART'.
    wa_fcat-reptext   'Material Type'.
    APPEND wa_fcat TO it_fcat.
    CLEAR wa_fcat.

    "-Creating Layout
    wa_lay_fg-zebra      'X'.
    wa_lay_fg-cwidth_opt 'X'.
    wa_lay_fg-grid_title 'Finished Goods Materials'.
    wa_lay_rm-zebra      'X'.
    wa_lay_rm-cwidth_opt 'X'.
    wa_lay_rm-grid_title 'Raw Materials'.
  ENDMETHOD.
ENDCLASS.

START-OF-SELECTION.
  DATAob_material TYPE REF TO cl_material.
  CREATE OBJECT ob_material.
  CALL METHODob_material->get_material,
               ob_material->prepare_output,
               ob_material->fieldcat.
  CALL SCREEN 9000.                  "-Calling Custom Screen

*&---------------------------------------------------------------------*
*&      Module  STATUS_9000  OUTPUT
*&---------------------------------------------------------------------*
*       PBO of 9000
*----------------------------------------------------------------------*
MODULE status_9000 OUTPUT.
  SET PF-STATUS 'PF_9000'.
  SET TITLEBAR 'MAT'.

  PERFORM finished_goods_alv.
  PERFORM raw_materials_alv.

ENDMODULE.
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9000  INPUT
*&---------------------------------------------------------------------*
*       PAI of 9000
*----------------------------------------------------------------------*
MODULE user_command_9000 INPUT.

  IF   ok_code 'BACK'
    OR ok_code 'EXIT'
    OR ok_code 'CANCEL'.
    FREEob_cont_fgob_grid_fgob_cont_rmob_grid_rm,
          it_fcatit_fgit_rm.
    LEAVE TO SCREEN 0.
  ENDIF.

ENDMODULE.
*&---------------------------------------------------------------------*
*&      Form  FINISHED_GOODS_ALV
*&---------------------------------------------------------------------*
*       ALV of FG
*----------------------------------------------------------------------*
FORM finished_goods_alv .
  CREATE OBJECT ob_cont_fg
    EXPORTING
      container_name 'CONT_FG'"-Creating Container
  "-In layout CONT_FG name is given

  CREATE OBJECT ob_grid_fg
    EXPORTING
      i_parent ob_cont_fg"-Creating ALV Grid

  "-ALV Grid Display Method
  CALL METHOD ob_grid_fg->set_table_for_first_display
    EXPORTING
      is_layout       wa_lay_fg
    CHANGING
      it_fieldcatalog it_fcat
      it_outtab       it_fg.
ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  RAW_MATERIALS_ALV
*&---------------------------------------------------------------------*
*       ALV of RM
*----------------------------------------------------------------------*
FORM raw_materials_alv .
  CREATE OBJECT ob_cont_rm
    EXPORTING
      container_name 'CONT_RM'"-Creating Container
  "-In layout CONT_RM name is given

  CREATE OBJECT ob_grid_rm
    EXPORTING
      i_parent ob_cont_rm"-Creating ALV Grid

  "-ALV Grid Display Method
  CALL METHOD ob_grid_rm->set_table_for_first_display
    EXPORTING
      is_layout       wa_lay_rm
    CHANGING
      it_fieldcatalog it_fcat
      it_outtab       it_rm.
ENDFORM.

Output.



124 comments:

Video Tutorials said...

Good post! Thanks for sharing this Information.The information you Provided is much useful on sap video

Video Tutorials said...

Thanks for the great information in your blog on It was so nice article Thank you for valuable informationsap video tutorials

ERP Training Videos said...

Thank you. It is such a wonderful post. it has great information it is very useful for sap video tutorials.

Reddy sap installation said...


Well it Was Very Good Information. Thanks for sharing this Information. sap video

Video Tutorials said...

Thankyou for information excellent blog have a great possible sap video tutorials

Reddy sap installation said...


This article is really contains lot more information about This Topic on sap training videos

Reddy sap installation said...



Thank you for giving this best information. It’s a very nice topic. sap video tutorials

Video Tutorials said...

Thanks for the great information in your blog on It was so nice article Thank you for valuable informationsap video tutorials

Reddy sap installation said...

Thanks for Sharing this Information.You are providing very valuable information.Sap videos

Video Tutorials said...

Good post! Thanks for sharing this Information.The information you Provided is much useful on sap video

Video Tutorials said...

Thankyou for information excellent blog have a great possible sap video tutorials

Reddy sap installation said...

Thank you sir.Thanks for Nice and Informative Post on.Sap videos

Video Tutorials said...

Thank you sir.I get a lot of great information from this blog on sap video

Reddy sap installation said...

Good post! Thanks for sharing this Information.The information you Provided is much useful on sap video

Video Tutorials said...

Thankyou for information excellent blog have a great possible sap video tutorials

Video Tutorials said...

Thanks for Sharing this Information.You are providing very valuable information.Sap videos

ERP Training Videos said...

Thankyou for wonderful article. It has more Information in Your Website sap video tutorials.

ERP Training said...

Fabulous..!! Thank you.The information you provided is much usful information on sap videos.

Reddy sap installation said...

Thank you sir.It was so nice article Thank you for valuable information.Sap videos

Video Tutorials said...


This article is really contains lot more information about This Topic on sap video

Reddy sap installation said...


Thank you sir.This article is really contains lot more information about This Topic on. Sap videos

Video Tutorials said...


I get a lot of great information from this blog on sap video

Reddy sap installation said...


Good post! Thanks for sharing this Information.The information you Provided is much useful on sap video

Video Tutorials said...

Thanks for Sharing this Information.You are providing very valuable information.Sap videos

Reddy sap installation said...

Thank you for giving this best information. It’s a very nice topic. sap video

Video Tutorials said...


This article is really contains lot more information about This Topic on. sap training videos

Reddy sap installation said...


Thank you sir.It was so nice article Thank you for valuable information.Sap videos

Reddy sap installation said...


Fabulous..!!! The information you Provided is much useful. sap video tutorials

Reddy sap installation said...

Thanks for the great information in your blog on It was so nice article Thank you for valuable informationsap video tutorials

Video Tutorials said...


It was so nice article.I was really satisified by seeing this article. Sap videos

Reddy sap installation said...

Thank you for giving this best information. It’s a very nice topic..Sap videos

Video Tutorials said...

Thankyou for information excellent blog have a great possible sap video tutorials

Video Tutorials said...



Thanks for Sharing this Information.You are providing very valuable information.Sap videos

Video Tutorials said...


Good post! Thanks for sharing this Information.The information you Provided is much useful on sap video

Video Tutorials said...



This article is really contains lot more information about This Topic on. Sap videos

Video Tutorials said...


Thank you sir.It was so nice article.I was really satisified by seeing this article. sap video tutorials

Reddy sap installation said...

Well, I found this information really useful. Thanks a ton for this. sap video tutorials

Video Tutorials said...

Thank you sir.The information you have given here is truly helpful to me. Sap videos

Reddy sap installation said...


I get a lot of great information from this blog. Thank you for your sharing this informative blog sap video

Video Tutorials said...


Well it Was Very Good Information. Thanks for sharing this Information sap video tutorials

sanayamohit said...

SAP Success Factors Real Time Hands on Training in Chennai...

Don't always Depend on Training Institute Alone and so please aware of Best Trainers too..

http://thecreatingexperts.com/sap-successfactors-training-in-chennai/

If You need a Best Trainer over SAP Success Factors Means??? Please ready for an DEMO From the Trainer MR.Karthick
CONTACT:8122241286

Both Classroom/Online Training is Available!!!!!!

Reddy sap installation said...

It was so nice article.I was really satisified by seeing this article..Sap videos

Video Tutorials said...

Thank you sir.It was so nice article.I was really satisified by seeing this article.sap video tutorials

Video Tutorials said...



Thank you for giving this best information. It’s a very nice topic.. Sap videos

Reddy sap installation said...

Good post! Thanks for sharing this Information.The information you Provided is much useful on sap video

Video Tutorials said...

Thankyou for information excellent blog have a great possible sap video tutorials

Video Tutorials said...


The information you have posted here is really useful and interesting too & here. Sap videos

Reddy sap installation said...

Thank you sir.I am very greatful to you that you share very informative post with us sap video

SUN TRAININGS said...

Thank u sharing a good information for SAP ABAP SAPABAP_Online_Training

Video Tutorials said...


Thank you for giving this best information. It’s a very nice topic..Sap videos

Reddy sap installation said...

Thank you sir.Thanks for Nice and Informative Post on. Sap videos

Video Tutorials said...

Good post! Thanks for sharing this Information.The information you Provided is much useful on sap video

Video Tutorials said...

Thanks for the great information in your blog on It was so nice article Thank you for valuable informationsap video tutorials

Reddy sap installation said...


Thank you sir.Thanks for Nice and Informative Post on. sap video

Video Tutorials said...



Thankyou for information excellent blog have a great possible. Sap videos

sushma said...

SAP Success Factors Real Time Hands on Training in Chennai…

Don’t always Depend on Training Institute alone.Please aware of Best Trainers too..

http://thecreatingexperts.com/sap-successfactors-training-in-chennai/

If You need a Best Trainer in SAP Success Factors??? Then be ready for a DEMO From the Trainer MR.Karthick
CONTACT:8122241286
http://thecreatingexperts.com/sap-mm-training-in-chennai/

Both Classroom/Online Training is Available!!!!!!

Reddy sap installation said...


Well, I found this information really useful. Thanks a ton for this.. Sap videos

Reddy sap installation said...

Thank you. sir, Really I like your post on. sap video tutorials

Video Tutorials said...

Thankyou for information excellent blog have a great possible .Sap videos

Video Tutorials said...


Thank you for giving this best information. It’s a very nice topic. Sap videos

Video Tutorials said...


Thank you sir.It is such a wonderful post. sap video

Reddy sap installation said...

Thankyou for information excellent blog have a great possible sap video tutorials

Video Tutorials said...

I am very greatful to you that you share very informative post with us. sap video tutorials

Reddy sap installation said...

Thankyou for Sharing Great Information. It is Very Helpful Information on.Sap videos

Reddy sap installation said...

Thank you. sir, Really I like your post on. sap video tutorials

Reddy sap installation said...


I get a lot of great information from this blog on. Sap videos

Video Tutorials said...

Good post! Thanks for sharing this Information.The information you Provided is much useful on sap video

sanayamohit said...

Best SAP Success Factor Training in Chennai

http://thecreatingexperts.com/sap-training-in-chennai/
http://thecreatingexperts.com/sap-successfactors-training-in-chennai/
http://thecreatingexperts.com/sap-mm-training-in-chennai/
http://thecreatingexperts.com/sap-fico-training-in-chennai/

Video Tutorials said...

Fabulous..!!! The information you Provided is much useful.. Sap videos

Video Tutorials said...

Thankyou for Sharing Great Information. It is Very Helpful Information on. sap video

Video Tutorials said...

Thanks for Nice and Informative Post on. Sap videos

Reddy sap installation said...

The information you posted here is useful to make my career better keep updates. Sap videos

Video Tutorials said...

It was so nice article Thank you for valuable information. sap video

Video Tutorials said...


I get a lot of great information from this blog on. Sap videos

Reddy sap installation said...

Good post! Thanks for sharing this Information.The information you Provided is much useful on sap video

Reddy sap installation said...


Thank you. It is such a wonderful post. sap video tutorials

Reddy sap installation said...


I get a lot of great information from this blog.. Sap videos

Video Tutorials said...

Thanks for sharing this informative blog. sap training videos

Video Tutorials said...

Thanks for sharing this informative blog..Your blog is really useful for me..Sap videos

Video Tutorials said...

Thank you for giving this best information. It’s a very nice topic. sap video tutorials

Video Tutorials said...


I am very greatful to you that you share very informative post with us.Sap videos

Reddy sap installation said...


Thanks for Nice and Informative Post on. sap training videos

Reddy sap installation said...

it has great information it is very useful Post. sap video tutorials

Reddy sap installation said...

Thank you sir.This website is providing the lot of topics. sap video

Video Tutorials said...

Fabulous..!!! The information you Provided is much useful..Sap videos

Reddy sap installation said...


Thank you. It is such a wonderful post. sap video tutorials

Reddy sap installation said...


I get a lot of great information from this blog on. Sap videos

Video Tutorials said...


Thanks for providing this information. Sap videos

Reddy sap installation said...

I am very grateful to you that you share very informative post with us. sap video tutorials

Video Tutorials said...


The information you have posted here is really useful and interesting too & here. Sap videos

Reddy sap installation said...

Good post! Thanks for sharing this Information.The information you Provided is much useful on sap video

Video Tutorials said...

Thanks for the great information in your blog on It was so nice article Thank you for valuable informationsap video tutorials

Video Tutorials said...

Thanks for Nice and Informative Post on. Sap videos

Reddy sap installation said...

Good post! Thanks for sharing this Information.The information you Provided is much useful on sap video

Priyasekar said...

Thanks for your info...Here THE CREATING EXPERTS provide hands on training with real time scenarios

http://thecreatingexperts.com/sap-abap-training-in-chennai/

contact +91-08122241286

Priyasekar said...

Very informative blog...SAP ABAP real Time Hands on Training in Chennai…

http://thecreatingexperts.com/sap-abap-training-in-chennai/

CONTACT:8122241286

Both Classroom/Online Training is Available.

ragu varan said...

Best SAP HANA Training in Chennai by leading HANA Consultant.
Reach at 9003085882
http://thecreatingexperts.com/category/sap-hana-training-in-chennai/

Video Tutorials said...

Thank you for information excellent blog have a great possible sap video tutorials

Reddy sap installation said...

Thanks for sharing this informative blog..Your blog is really useful for me. sap video training

Video Tutorials said...

Fabulous..!!! The information you Provided is much useful. sap video

Reddy sap installation said...

Good post! Thanks for sharing this Information.The information you Provided is much useful on sap video

Video Tutorials said...

Thank you for information excellent blog have a great possible sap video tutorials

Reddy sap installation said...

Thanks for sharing this informative blog..Your blog is really useful for me. sap video training

Video Tutorials said...

Fabulous..!!! The information you Provided is much useful. sap video

Reddy sap installation said...

it has great information it is very useful Post sap videos online

Video Tutorials said...

Thankyou for Sharing Great Information. It is Very Helpful Information on. sap video training

Reddy sap installation said...


Fabulous..!!! The information you Provided is much useful..Sap videos

Reddy sap installation said...


Thanks for Nice and Informative Post on. sap video

Reddy sap installation said...


Thank you for giving this best information. It’s a very nice topic. sapvideos

Video Tutorials said...

Thank you. sir, Really I like your post on sap videos tutorials

Reddy sap installation said...


I get a lot of great information from this blog on. sap videos

Video Tutorials said...


Thanks for the detailed info about SAP..sap video tutorials

Reddy sap installation said...



Thank you for giving this best information. It’s a very nice topic. sapvideos

Reddy sap installation said...


Thanks for the interesting information. sap videos online

Video Tutorials said...

Fabulous..!!! The information you Provided is much useful.. sap video training

Video Tutorials said...


Thanks for the great information in your blog on It was so nice article. Sap videos

Video Tutorials said...


This article is really contains lot more information. sap training videos

Reddy sap installation said...


This article is really contains lot more information. sap video tutorials

Video Tutorials said...

It was so nice article Thank you for valuable information. sap videos tutorials

Reddy sap installation said...


Fabulous..!!! The information you Provided is much useful. sap videos

Reddy sap installation said...


Thanks for Nice and Informative Post on. sap training videos

Video Tutorials said...

Thank you for giving this best information. It’s a very nice topic. sapvideos

Video Tutorials said...

Thank you. It is such a wonderful post. sap tutorial videos

calfre services said...

Good post! Thanks for sharing this Information.The information you Provided is much useful onsap-hr abap online classes