Monday, May 23, 2011

Creating a Tabstrip on the selection screen

Report ZTEST.
DATA flag(1) TYPE c.
* SUBSCREEN 1
SELECTION-SCREEN BEGIN OF SCREEN 100 AS SUBSCREEN. SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME. PARAMETERS: Field1(20) TYPE c,             Field2(20) TYPE c,             Field3(20) TYPE c. SELECTION-SCREEN END OF BLOCK b1. SELECTION-SCREEN END OF SCREEN 100.
* SUBSCREEN 2
SELECTION-SCREEN BEGIN OF SCREEN 200 AS SUBSCREEN. SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME. PARAMETERS: q1(20) TYPE c ,             q2(20) TYPE c ,             q3(20) TYPE c . SELECTION-SCREEN END OF BLOCK b2. SELECTION-SCREEN END OF SCREEN 200.
* STANDARD SELECTION SCREEN
SELECTION-SCREEN: BEGIN OF TABBED BLOCK mytab FOR 10 LINES,                   TAB (20) button1 USER-COMMAND push1,                   TAB (20) button2 USER-COMMAND push2,                   END OF BLOCK mytab.
INITIALIZATION.   button1 = 'TAB1'.   button2 = 'TAB2'.   mytab-prog = sy-repid.   mytab-dynnr = 100.   mytab-activetab = 'BUTTON1'.
AT SELECTION-SCREEN.   CASE sy-dynnr.     WHEN 1000.       CASE sy-ucomm.         WHEN 'PUSH1'.           mytab-dynnr = 100.           mytab-activetab = 'BUTTON1'.         WHEN 'PUSH2'.           mytab-dynnr = 200.           mytab-activetab = 'BUTTON2'.       ENDCASE.     WHEN 100.       MESSAGE s888(sabapdocu) WITH text-040 sy-dynnr.     WHEN 200.       MESSAGE s888(sabapdocu) WITH text-050 sy-dynnr.   ENDCASE.
MODULE init_0100 OUTPUT.   LOOP AT SCREEN.     IF screen-group1 = 'MOD'.       CASE flag.         WHEN 'X'.           screen-input = '1'.         WHEN ' '.           screen-input = '0'.       ENDCASE.       MODIFY SCREEN.     ENDIF.   ENDLOOP. ENDMODULE.
MODULE user_command_0100 INPUT.   MESSAGE s888(sabapdocu) WITH text-050 sy-dynnr.   CASE sy-ucomm.     WHEN 'TOGGLE'.       IF flag = ' '.         flag = 'X'.       ELSEIF flag = 'X'.         flag = ' '.       ENDIF.   ENDCASE. ENDMODULE.
START-OF-SELECTION.   WRITE: / 'Field1:', Field1,'Q1:', q1,          / 'Field2:', Field2,'Q2:', q2,          / 'Field3:', Field3,'Q3:', q3.

Output:

TAB1

TAB2

Displaying 3D Graphs in ABAP

*Simple report to create graph in ABAP *using GRAPH_MATRIX_3D function module *The graph shows the performance of 3 companies for the Four *quarters of a single year *AUTHOR : Swarna.S.
REPORT Z_3DGRAPH.
*structure declaration for performance measurement
TYPES: BEGIN OF ty_performance,       company(15) TYPE c,       q1 TYPE i,       q2 TYPE i,       q3 type i,       q4 type i,       END OF ty_performance.
*structure declaration for options table types : BEGIN OF ty_opttable,         options(30) TYPE c,         END OF ty_opttable.
*Internal table and work area declarations DATA: it_performance TYPE STANDARD TABLE OF ty_performance,       wa_performance TYPE ty_performance.
DATA : it_opttable type standard table of ty_opttable,        wa_opttable type ty_opttable.
*initialization event INITIALIZATION.
*start of selection event START-OF-SELECTION.
*clearing the work areas CLEAR WA_PERFORMANCE. CLEAR wa_opttable.
*appending values into the performance internal table wa_performance-company = 'Company A'. wa_performance-q1      = 78. wa_performance-q2      = 68. wa_performance-q3      = 79. wa_performance-q4      = 80.
append wa_performance to it_performance.
wa_performance-company = 'Company B'. wa_performance-q1      = 48. wa_performance-q2      = 68. wa_performance-q3      = 69. wa_performance-q4      = 70.
append wa_performance to it_performance.
wa_performance-company = 'Company C'. wa_performance-q1      = 78. wa_performance-q2      = 48. wa_performance-q3      = 79. wa_performance-q4      = 85.
append wa_performance to it_performance.
*appending values into the options internal table
wa_opttable-options = 'P3TYPE = TO'. APPEND wa_opttable TO it_opttable.
wa_opttable-options = 'P2TYPE = VB'. APPEND wa_opttable TO it_opttable.
wa_opttable-options = 'TISIZE = 1'. APPEND wa_opttable TO it_opttable.
*calling the graph function module   CALL FUNCTION 'GRAPH_MATRIX_3D'     EXPORTING       col1      = 'Quarter 1'       col2      = 'Quarter 2'       col3      = 'Quarter 3'       col4      = 'Quarter 4'        dim1      = 'In Percentage%'       set_focus = 'X'       titl      = 'Company Performances'     TABLES       data      = it_performance       opts      = it_opttable     EXCEPTIONS       others    = 1.
 

Creating a dynamic selection screen on a report

Description

This is a demo application to make a dynamic screen in a report.

This change the parameters according a radio button choice:

1st moment - Click on the radio button Local

- In the block “Enter Parameters”, we’ll have 2 parameters.

- The parameter in the block “Path” is named as Local Path and the match code will lead you to a File Open Dialog.

2nd moment - Click in the radio button Server

- In the Enter Parameters, we’ll have just 1 parameter.

- The parameter in the block “Path” is now named as Server Path and the field will be disabled.

Step by Step Approach:

Create a new report.

In the SELECTION SCREEN put all the fields, blocks and parameters necessary, notice that in the radio button have the addiction USER-COMMAND to enable the event AT SELECTION-SCREEN OUTPUT.

Look that in the Block 2 we have the both parameters p_local and p_sever, at the same time.

At this time the report is something like this:

Event AT SELECTION-SCREEN OUTPUT

In this event you can manipulate all the objects that appears in the screen using LOOP AT SCREEN changing the value of the structure screen the way you want . See below:

All this characteristics in the structure are possible to be changed:

NAME, GROUP1, GROUP2, GROUP3, GROUP4, REQUIRED, INPUT, OUTPUT, INTENSIFIED, INVISIBLE, LENGTH, ACTIVE, DISPLAY_3D, VALUE_HELP, REQUEST, VALUES_IN_COMBO and COLOR.

Below we have the full source code of our example.
*&---------------------------------------------------------------------* *& Report  ZDYNAMIC_SCREEN *&---------------------------------------------------------------------*
REPORT  zdynamic_screen.
* Published at SAPTechnical.com
************************************************************************ * External Tables                                                      * ************************************************************************ TABLES: kna1.
************************************************************************ * Internal Tables                                                      * ************************************************************************ DATA: i_filetable TYPE filetable.
************************************************************************ * Screen Parameters                                                    * ************************************************************************ * Begin - Block 1 SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: r_local RADIOBUTTON GROUP rad1 USER-COMMAND flg, "Local             r_server RADIOBUTTON GROUP rad1 DEFAULT 'X'.     "Server
* Begin - Block 2 SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002. PARAMETER: p_local  LIKE rlgrap-filename DEFAULT 'C:\' OBLIGATORY. PARAMETER: p_server LIKE rlgrap-filename DEFAULT '/default' OBLIGATORY. * End - Block 2 SELECTION-SCREEN END OF BLOCK b2.
* Begin - Block 3 SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-003. SELECT-OPTIONS: s_kunnr FOR kna1-kunnr, "Customer Number 1                 s_land1 FOR kna1-land1. "Country Key * End - Block 3 SELECTION-SCREEN END OF BLOCK b3.
* End - Block 1 SELECTION-SCREEN END OF BLOCK b1.
************************************************************************ * At Selection Screen OUTPUT                                           * ************************************************************************ AT SELECTION-SCREEN OUTPUT.
* Check what radiobutton is selected * Local   IF r_local = 'X'.     LOOP AT SCREEN.       IF "screen-name = 'P_LOCAL'. " OR          screen-name = '%_P_LOCAL_%_APP_%-TEXT'.         screen-invisible = '0'.         screen-input = '1'.         MODIFY SCREEN.
      ELSEIF screen-name = 'P_SERVER'. " OR              screen-name = '%_P_SERVER_%_APP_%-TEXT'.         screen-invisible = '1'.         screen-input = '0'.         MODIFY SCREEN.       ENDIF.     ENDLOOP.
* Server   ELSE.
    LOOP AT SCREEN.       IF screen-name = 'P_SERVER' OR          screen-name = '%_P_SERVER_%_APP_%-TEXT'.
        screen-invisible = '0'.         screen-input = '0'.         MODIFY SCREEN.
      ELSEIF screen-name = 'P_LOCAL' OR              screen-name = '%_P_LOCAL_%_APP_%-TEXT' OR              screen-name = '%_S_KUNNR_%_APP_%-TEXT' OR              screen-name = '%_S_KUNNR_%_APP_%-OPTI_PUSH' OR              screen-name = 'S_KUNNR-LOW' OR              screen-name = '%_S_KUNNR_%_APP_%-TO_TEXT' OR              screen-name = 'S_KUNNR-HIGH' OR              screen-name = '%_S_KUNNR_%_APP_%-VALU_PUSH'.             .
        screen-invisible = '1'.         screen-input = '0'.         MODIFY SCREEN.       ENDIF.     ENDLOOP.   ENDIF.
************************************************************************ * At Selection Screen ON VALUE REQUEST                                 * ************************************************************************ AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_local.   PERFORM filename_local CHANGING p_local.
************************************************************************ START-OF-SELECTION. ************************************************************************
************************************************************************ * Forms                                                                * ************************************************************************ *&---------------------------------------------------------------------* *&      Form  filename_local *&---------------------------------------------------------------------* *& FORM filename_local CHANGING p_file TYPE rlgrap-filename.
  DATA: vl_rc           TYPE i,         vl_action       TYPE i.
* Open the File Open Dialog   CALL METHOD cl_gui_frontend_services=>file_open_dialog     EXPORTING       file_filter             = ''       initial_directory       = 'C:\'     CHANGING       file_table              = i_filetable       rc                      = vl_rc       user_action             = vl_action     EXCEPTIONS       file_open_dialog_failed = 1       cntl_error              = 2       error_no_gui            = 3       not_supported_by_gui    = 4       OTHERS                  = 5.
  IF sy-subrc <> 0 OR vl_rc < 0.     MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.   ELSE.     IF vl_action EQ cl_gui_frontend_services=>action_ok.       CLEAR p_file.       READ TABLE i_filetable INDEX 1 INTO p_file.     ENDIF.   ENDIF.
ENDFORM.                               " filename_local

Creating a Function Module

1. Open SE37 transaction.

Go to Goto à Function groups à Create group.

2. Give the function group name and short text. And click on Save.

3. Save this function group as local object.

4. Then open the transaction se80 and select the ‘Function group’ from the drop down list. Enter the function group name. Press Enter.

5. Right click on ZSSR and press activate.

6. Then you will get the following screen. Press Enter.

7. Go to the transaction se37 again and click on create.

8. Now it will ask for the function group. Enter the function group and give the short text. Press Save.

9. Click on the Attributes tab and give the short text.

10. Click on the Import tab and enter the Parameter name, Type and Reference type of variables A and B.

11. Click on Export tab and enter the Parameter name, Type and reference type of RES.



12. Click on Exceptions tab and enter the Exception and short text for that exception.

13. Now click on the Source code tab and write the following lines as shown bellow.

14. Press syntax check button or Ctrl+F2.

15. Now press on Activate button or press Ctrl+F3.

16. Press Enter.

17. Now Press on Test button or Press F8.

18. Enter values for A and B. And press Execute or F8.

19. The following screen will be displayed with result.

20. If you enter A value as 5. it will throw exception.

21. Output with Exception.

22. Now create and enjoy more Function Modules.


Downloading file on to the application server

Description

This is a demo application to download the data from the internal table of the application to a file in the application server.

Step by Step Guidance.

Go to transaction SE38 to open ABAP editor and Type in the program name click the create button. Here we have used “ZDOWNLOAD_APPL_DEMO” as the program name.

Enter the Short Description for the program

Select the Program type to be “Executable program”

Click on SAVE CHECK and ACTIVATE.

Give the path of the file which has to be uploaded

Here we have the file in location “\USR\SAP\SRI\SYS\SRC\DOWN.TXT”

The drive name is taken as the default SAP installation drive.

OUTPUT LIST SCREEN

The data from the internal table is moved in to DOWN.TXT file in the Presentation server and out put displayed on the list screen shows the data in the internal table.

Output File in the Application server.

Go to Transaction AL11 to see the SAP installation directories

Find our directory double click

Find our downloaded file in the directory and double click it

The Downloaded data is displayed

SOURCE CODE
REPORT  ZDOWNLOAD_APPL_DEMO.
TYPES : BEGIN OF ST_DEMO,         REG_NO(10) TYPE C,         NAME(20) TYPE C,         ADDR(20) TYPE C,         END OF ST_DEMO.
DATA : WA_DEMO TYPE ST_DEMO,        IT_DEMO TYPE TABLE OF ST_DEMO,        L_FNAME TYPE STRING .
PARAMETERS: P_FNAME(128) TYPE C DEFAULT '\usr\sap\SRI\SYS\src\DOWN.TXT' OBLIGATORY. L_FNAME = P_FNAME. WA_DEMO-REG_NO = '100001'. WA_DEMO-NAME = 'ANAND'. WA_DEMO-ADDR = 'NAGARKOVIL'.  APPEND WA_DEMO TO IT_DEMO.
WA_DEMO-REG_NO = '100002'. WA_DEMO-NAME = 'VIKRAM'. WA_DEMO-ADDR = 'CHENNAI'. APPEND WA_DEMO TO IT_DEMO.
  OPEN DATASET L_FNAME FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.   WRITE :5 'REG NUM',16 'NAME',37 'ADDRESS' .   LOOP AT IT_DEMO INTO WA_DEMO.     IF SY-SUBRC = 0.       TRANSFER WA_DEMO TO L_FNAME.       WRITE :/5 WA_DEMO-REG_NO,16 WA_DEMO-NAME,37 WA_DEMO-ADDR.     ENDIF.   ENDLOOP.

Demo on Interactive reporting (One more example)

REQUIREMENT: -

Get the Plant and storage location from the user and to get the available materials in the particular storage location and display in a report.

When the material number in the report is selected the material description and other complete details are displayed in a new screen using interactive report.

STEPS FOLLOWED TO ACHIEVE THE GOAL:

Go to SE38 ABAP Editor create a new program.

Code the logic in the ABAP Editor.

Check –Activate- and Execute the code.

Type in the Required Parameters or select a value from F4 Help Screen.

Execute the project

The Report is displayed in the output Screen.

Select a record using the mouse double click.

A new screen shows the output based on the selected record achieving the interactive reporting.

For the complete program,

*&----------------------------------------------------------------* *& Report  ZVikram_interactive                                    * *&                                                                * *&----------------------------------------------------------------* *& Published at SAPTechnical.COM                                  * *&                                                                * *&----------------------------------------------------------------*
REPORT  ZVikram_interactive NO STANDARD PAGE HEADING LINE-SIZE 255.
********** THE INITIALIZATION PART CREATING STRUCTURES*************
INITIALIZATION.
TYPES : BEGIN OF TY_MARD,         MATNR TYPE MARD-MATNR,         WERKS TYPE MARD-WERKS,         LGORT TYPE MARD-LGORT,         END OF TY_MARD,
        BEGIN OF TY_MARA,         MATNR TYPE MARA-MATNR,         ERSDA TYPE MARA-ERSDA,         ERNAM TYPE MARA-ERNAM,         MTART TYPE MARA-MTART,         MATKL TYPE MARA-MATKL,         END OF TY_MARA,
        BEGIN OF TY_MAKT,         MATNR TYPE MAKT-MATNR,         SPRAS TYPE MAKT-SPRAS,         MAKTX TYPE MAKT-MAKTX,         END OF TY_MAKT,
        BEGIN OF TY_FINAL,         MATNR TYPE MARA-MATNR,         ERSDA TYPE MARA-ERSDA,         ERNAM TYPE MARA-ERNAM,         MTART TYPE MARA-MTART,         MATKL TYPE MARA-MATKL,         WERKS TYPE MARD-WERKS,         LGORT TYPE MARD-LGORT,         SPRAS TYPE MAKT-SPRAS,         MAKTX TYPE MAKT-MAKTX,         END OF TY_FINAL.
***** THE INITIALIZATION PART CREATING WORKAREA AND INTERNAL TABLE***** 
DATA : W_MARD TYPE TY_MARD,        I_MARD TYPE TABLE OF TY_MARD,
       W_MARA TYPE TY_MARA,        I_MARA TYPE TABLE OF TY_MARA,
       W_MAKT TYPE TY_MAKT,        I_MAKT TYPE TABLE OF TY_MAKT,
       W_FINAL TYPE TY_FINAL,        I_FINAL TYPE TABLE OF TY_FINAL. **************************START-OF-SELECTION.**************************
START-OF-SELECTION.
*************************GET INPUT FROM USER***************************
PARAMETER : PLANT TYPE MARD-WERKS,
            STLOC TYPE MARD-LGORT.
****SELECT DATA FROM DATABASE INTO INTERNAL TABLES*********************
**SELECT FROM MARD THE REQUIRED FIELDS FOR THE GIVEN INPUT*************
SELECT MATNR WERKS LGORT FROM MARD INTO TABLE I_MARD WHERE WERKS = PLANT AND LGORT = STLOC.
*****CHECK IF RECORDS ARE FETCHED IF NO EXIT OUT OF THE PROGRAM********
IF SY-SUBRC <> 0.    WRITE 'NO RECORDS'.    EXIT. ELSE.
***IF RECORDS ARE FETCHED FROM FRIST TABLE***************************** ****FETCH RELATED RECORDS FROM NEXT TABLE******************************
    SELECT MATNR ERSDA ERNAM MTART MATKL     FROM MARA     INTO TABLE I_MARA     FOR ALL ENTRIES IN I_MARD     WHERE MATNR = I_MARD-MATNR.       IF SY-SUBRC <> 0.          WRITE 'NO MASTER DATA'.          STOP.       ELSE.         SELECT MATNR SPRAS MAKTX         FROM MAKT         INTO TABLE I_MAKT         FOR ALL ENTRIES IN I_MARA         WHERE MATNR = I_MARA-MATNR AND SPRAS = 'E'.       ENDIF. ENDIF.
*****READ FROM INTERNAL TABLE FOR OUTPUT ******************************
LOOP AT I_MARA INTO W_MARA. AT FIRST.
WRITE : SY-ULINE(100),         /1 SY-VLINE,         25 'EXAMPLE INTERACTIVE REPORT',         100 SY-VLINE,         / SY-ULINE(100),
        /1 SY-VLINE,         2  'MATERIAL NUMBER' ,         20 SY-VLINE,         22 'CREATION DATE',         40 SY-VLINE,         42 'USER NAME',         60 SY-VLINE,         62 'MATERIAL TYPE',         80 SY-VLINE,         82 'MATERIAL GROUP',         100 SY-VLINE,       / SY-ULINE(100). ENDAT.
ON CHANGE OF W_MARA-MATNR. READ TABLE I_MARD INTO W_MARD WITH KEY MATNR = W_MARA-MATNR. ENDON.
WRITE :/1 SY-VLINE,         2 W_MARA-MATNR ,        20 SY-VLINE,         22 W_MARA-ERSDA,         40 SY-VLINE,         42 W_MARA-ERNAM,         60 SY-VLINE,         62 W_MARA-MTART,         80 SY-VLINE,         82 W_MARA-MATKL,         100 SY-VLINE. 
HIDE W_MARA-MATNR. CLEAR W_MARA-MATNR.
WRITE: / SY-ULINE(100).
ENDLOOP.
*****************END-OF-SELECTION.*************************************
END-OF-SELECTION.
****MOVING VALUES IN TO FINAL INTERNAL TABLE **************************
LOOP AT I_MARA INTO W_MARA. ON CHANGE OF W_MARA-MATNR. READ TABLE I_MAKT INTO W_MAKT WITH KEY MATNR = W_MARA-MATNR. READ TABLE I_MARD INTO W_MARD WITH KEY MATNR = W_MARA-MATNR. ENDON. 
        W_FINAL-MATNR = W_MARA-MATNR.         W_FINAL-ERSDA = W_MARA-ERSDA.         W_FINAL-ERNAM = W_MARA-ERNAM.         W_FINAL-MTART = W_MARA-MTART.         W_FINAL-MATKL = W_MARA-MATKL.         W_FINAL-WERKS = W_MARD-WERKS.         W_FINAL-LGORT = W_MARD-LGORT.         W_FINAL-SPRAS = W_MAKT-SPRAS.         W_FINAL-MAKTX = W_MAKT-MAKTX.
        APPEND  W_FINAL TO I_FINAL.
ENDLOOP.
********AT LINE-SELECTION EVENT TRIGERING INTERACTIVE REPORTING.*******
AT LINE-SELECTION.
CASE SY-LSIND.
WHEN 1.
**DISPLAY OUTPUT IN NEW SCREEN AT LINE SELECTION BY USER MOUSE CLICK ** WRITE: / W_MARA-MATNR COLOR 2.
READ TABLE I_FINAL INTO W_FINAL WITH KEY MATNR = W_MARA-MATNR  SPRAS = 'EN'.
ULINE 1(200). WRITE : /1 SY-VLINE,         75 'EXAMPLE INTERACTIVE REPORT',         200 SY-VLINE,         SY-ULINE(200),         /1 SY-VLINE,         2  'MATERIAL NUMBER' ,         20 SY-VLINE,         22 'CREATION DATE',         40 SY-VLINE,         42 'USER NAME',         60 SY-VLINE,         62 'MATERIAL TYPE',         80 SY-VLINE,         82 'MATERIAL GROUP',         100 SY-VLINE,         102 'PLANT NUMBER',         120 SY-VLINE,         122 'STORAG LOCATION',         140 SY-VLINE,         142 'LANGUAGE',         160 SY-VLINE,         162 'DESCRIPTION',         200 SY-VLINE,         / SY-ULINE(200).
WRITE :/1 SY-VLINE,         2 W_FINAL-MATNR ,         20 SY-VLINE,         22 W_FINAL-ERSDA,         40 SY-VLINE,         42 W_FINAL-ERNAM,         60 SY-VLINE,         62 W_FINAL-MTART,         80 SY-VLINE,         82 W_FINAL-MATKL,         100 SY-VLINE,         102 W_FINAL-WERKS,         120 SY-VLINE,         122 W_FINAL-LGORT,         140 SY-VLINE,         142 W_FINAL-SPRAS,         160 SY-VLINE,         162 W_FINAL-MAKTX,         200 SY-VLINE,       / SY-ULINE(200).
CLEAR W_MARA-MATNR.
ENDCASE.


Sunday, May 22, 2011

Developing a simple interactive report

“In this scenario, we would take an example of a material and develop an interactive report. Once you click on require “material no” on the basic list, the corresponding material information on the secondary list.”

Following is a sample interactive report developed for our demo purpose:

REPORT zintractive .

TYPES : BEGIN OF str_mard,         matnr TYPE mard-matnr,         lgort TYPE mard-lgort,         werks TYPE mard-werks,         END OF str_mard.
DATA : wa_mard TYPE str_mard,        it_mard TYPE TABLE OF str_mard.
TYPES : BEGIN OF str_makt,         matnr TYPE makt-matnr,         maktg TYPE makt-maktg,
        END OF str_makt.
DATA : wa_makt TYPE str_makt,        it_makt TYPE TABLE OF str_makt.
TYPES : BEGIN OF str_mara,         matnr TYPE mara-matnr,         ersda TYPE mara-ersda,         ernam TYPE mara-ernam,         laeda TYPE mara-laeda,         mtart TYPE mara-mtart,         matkl TYPE mara-matkl,         meins TYPE mara-meins,         END OF str_mara.
DATA : wa_mara TYPE str_mara,        it_mara TYPE TABLE OF str_mara.
TYPES : BEGIN OF str_final,        matnr TYPE mara-matnr,        ersda TYPE mara-ersda,        ernam TYPE mara-ernam,        laeda TYPE mara-laeda,        mtart TYPE mara-mtart,        matkl TYPE mara-matkl,        meins TYPE mara-meins,        lgort TYPE mard-lgort,        werks TYPE mard-werks,        END OF str_final.
DATA: wa_final TYPE str_final,       it_final TYPE TABLE OF str_final.
PARAMETERS : plant TYPE mard-werks,              stor LIKE mard-lgort.
SELECT matnr lgort werks FROM mard INTO TABLE  it_mard WHERE lgort = stor AND werks = plant. .
SELECT  matnr maktg FROM makt INTO TABLE  it_makt FOR ALL ENTRIES IN it_mard WHERE matnr = it_mard-matnr AND spras = 'E'. 
SELECT matnr ersda ernam  laeda mtart matkl meins FROM mara INTO TABLE it_mara FOR ALL ENTRIES IN it_makt WHERE matnr = it_makt-matnr. 
LOOP AT it_makt INTO wa_makt.   WRITE : /1 wa_makt-matnr COLOR 1,           40 wa_makt-maktg COLOR 2.   HIDE wa_makt-matnr. ENDLOOP.
CLEAR wa_mard-matnr.
AT LINE-SELECTION.   REFRESH it_final.   CLEAR wa_final.   ULINE.   IF sy-lsind = 1.     WRITE :  /1 'MATERIAL NO' COLOR 2,              20 'CREATION DATE' COLOR 3,              32 'PERSON CREATED',              50 'DATE OF LIST' ,              65 'MATERIALTYPE',              80 'MATGROUP' ,              90 'UNITOFMEASURE',              110 'STORLOCATION' COLOR 4,              130   'PLANT' COLOR 5.     ULINE.   ENDIF.
  LOOP AT it_mara INTO wa_mara WHERE matnr = wa_makt-matnr.
    wa_final-matnr = wa_mara-matnr.     wa_final-ersda = wa_mara-ersda.     wa_final-ernam = wa_mara-ernam.     wa_final-laeda = wa_mara-laeda.     wa_final-mtart = wa_mara-mtart.     wa_final-matkl = wa_mara-matkl.     wa_final-meins = wa_mara-meins.
    READ TABLE it_mard INTO wa_mard WITH KEY matnr = wa_makt-matnr.
    wa_final-lgort = wa_mard-lgort.     wa_final-werks = wa_mard-werks.
    APPEND  wa_final TO it_final.
  ENDLOOP.
  LOOP AT it_final INTO wa_final.
    WRITE :  /1  wa_final-matnr COLOR 2,              20 wa_final-ersda COLOR 3,              37 wa_final-ernam,              50 wa_final-laeda ,              70 wa_final-mtart ,              85 wa_final-matkl ,              95 wa_final-meins,              115   wa_final-lgort COLOR 4,              130   wa_final-werks COLOR 5.   ENDLOOP.
TOP-OF-PAGE.   WRITE : /1 'MATERIAL NO' COLOR 1,          40  'DISCRIPTION' COLOR 2.   ULINE .

Result

Enter the “Plant” and “Storage Location”

Press the Execute Button.

Double Click on require “Material No” which displays secondary list to corresponding material information.

The result shown below




Tutorials on SAP-ABAP

Adobe Interactive Forms Tutorials

Business Server Pages (BSP)

Userexits/BADIs

Web Dynpro for ABAP (Step by step procedure for web dynpro,Tutorials on Web Dynpro,)

ALV Tutorials

goodsites