Hello everyone, In this ABAP in Eclipse tutorial, we will learn how to create ALV ABAP program in Eclipse IDE. We all know developing ALV programs using SAP GUI in SE38-ABAP编辑器 transaction.Today we are re-writing the same program in Eclipse IDE.If you have not introduced to ABAP in Eclipse, please click here to know more about it. So let’s get started.
1. Creation of every ABAP Repository Object in Eclipse starts with creation of ABAP Project.To know how to create a ABAP Project to connect to your ECC system, please click here.
2.After successful creation of ABAP Project in the above step, we need to create ABAP Program.To create an ABAP Program right click on package → New → ABAP Program.
3. In Selection of Transport Request window, choose the transport request in which you want to save the program and hit Finish button.Here we are saving the program in $TMP package so transport request not required.
4. ABAP editor will be available in a window beside, right to Project Explorer.Here you can write the same ABAP code we were writing in SE38-ABAP编辑器 transaction in ECC system.
> Data Declarations
1 2 3 |
DATA: lo_alv TYPE REF TO cl_salv_table, gt_materials TYPE STANDARD TABLE OF bapi_epm_product_header, ls_maxrows TYPE bapi_epm_max_rows. |
> Data Retrieval Logic
1 2 3 4 5 6 |
ls_maxrows-bapimaxrow = 20. CALL FUNCTION 'BAPI_EPM_PRODUCT_GET_LIST' EXPORTING max_rows = ls_maxrows TABLES headerdata = gt_materials. |
> Display ALV Code Snippet
1 2 3 4 5 6 7 8 9 10 |
TRY. CALL METHOD cl_salv_table=>factory IMPORTING r_salv_table = lo_alv CHANGING t_table = gt_materials. CATCH cx_salv_msg. ENDTRY. CALL METHOD lo_alv->display. |
5. After adding above code in the code editor, save and active the program.
6. Execute the program by clicking on execute button in the application toolbar. A new window will open to display the ALV in Eclipse.
1.Tips and Tricks
In step 4.2 we have used BAPI function module to get the data.In Eclipse to call a functional module
You need to type the name of Function Model prefixing it with CALL FUNCTION.
After that, place the cursor at the end of the statement and press Cntrl+Space, a code completion window open like below.
Press Shift+Enter to insert the code in the program.
You have successfully created an ALV report ABAP program in Eclipse IDE. Stay tuned to us for more ABAP in Eclipse tutorials. Please feel free to comment and let us know your feedback.
Thank you.