Enterprise Resource
Planning Portal

 

Advertise | Founder BLOG

ERPGenie.COM ABAP Tips and Tricks Database

THE ultimate
ERP website

 

Forums | Vote for us |

Google    Other Search Options

Home arrow Sample Code arrow ABAP Reports
ABAP Reports
Creating internal table of any type PDF Print E-mail
User Rating: / 5
Written by Alexander Bykov   
Thursday, 17 September 2009
***********************************************************************
* This program is freeware and is provided on as-is basis without *
* warranty of any kind. *
***********************************************************************
* Author * Alexander Bykov *
* E-mail * This e-mail address is being protected from spam bots, you need JavaScript enabled to view it *
***********************************************************************
* Description *
* Create internal table of any type on the fly *
***********************************************************************
data:
lt_fcat type lvc_t_fcat.
data:
tabname type ref to data,
tabline type ref to data.

field-symbols:
<gt> type standard table,
<gs> type any.

call function 'LVC_FIELDCATALOG_MERGE'
exporting
i_structure_name = 'DDIC_STRUCTURE'
changing
ct_fieldcat = lt_fcat
exceptions
inconsistent_interface = 1
program_error = 2
others = 3.

* Creating table
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = lt_fcat
importing
ep_table = tabname.

assign tabname->* to <gt>.
create data tabline like line of <gt>.
assign tabline->* to <gs>.
Ny
 
ALV Grid Using Function Modules PDF Print E-mail
User Rating: / 1
Written by H Franks   
Saturday, 07 March 2009
This simple example shows how to create an ALV grid report using function modules.
REPORT zhfnk_alvtest.


TYPES:
BEGIN OF t_makt,
matnr LIKE makt-matnr,
maktx LIKE makt-maktx,
END OF t_makt.

DATA:
it_makt TYPE STANDARD TABLE OF t_makt,
wa_makt TYPE t_makt.

******************************************************************'
* Data declarations for the ALV grid
******************************************************************'
DATA: r_grid TYPE REF TO cl_gui_alv_grid.

DATA: alv_fieldcat TYPE slis_t_fieldcat_alv,
wa_alv_fieldcat TYPE slis_fieldcat_alv,
alv_layout TYPE slis_layout_alv,
gd_repid LIKE sy-repid.

******************************************************************'

START-OF-SELECTION.
PERFORM alv_setup.
PERFORM read_data.
END-OF-SELECTION.
  PERFORM display_alv.

*&---------------------------------------------------------------------*
*& Form read_data
*&---------------------------------------------------------------------*

FORM read_data.
SELECT matnr maktx
FROM makt
INTO TABLE it_makt
WHERE spras = 'E'.
ENDFORM. " read_data

*&---------------------------------------------------------------------*
*& Form alv_setup
*&---------------------------------------------------------------------*
*
* Setup of the columns in the ALV grid
*
*----------------------------------------------------------------------*
FORM alv_setup.

CLEAR wa_alv_fieldcat.
REFRESH alv_fieldcat.

* Matnr field
wa_alv_fieldcat-key = 'X'. "This is a key column
wa_alv_fieldcat-fieldname = 'MATNR'. "Name of the table field
wa_alv_fieldcat-seltext_s = 'Matnr'. "Short column heading
wa_alv_fieldcat-seltext_m = 'Material nr.'. "Medium column heading
wa_alv_fieldcat-seltext_l = 'Material number'. "Long column heading
APPEND wa_alv_fieldcat TO alv_fieldcat.

* Mat text field
wa_alv_fieldcat-key = ''. "This is not a key column
wa_alv_fieldcat-fieldname = 'MAKTX'.
wa_alv_fieldcat-seltext_s = 'Mat. txt'.
wa_alv_fieldcat-seltext_m = 'Material txt'.
wa_alv_fieldcat-seltext_l = 'Material text'.
APPEND wa_alv_fieldcat TO alv_fieldcat.
ENDFORM. " alv_setup
*&---------------------------------------------------------------------*
*& Form display_alv
*&---------------------------------------------------------------------*
* Display data in the ALV grid
*
*----------------------------------------------------------------------*
FORM display_alv.

gd_repid = sy-repid.

* Configure layout of screen
alv_layout-colwidth_optimize = 'X'.
alv_layout-zebra = 'X'.
alv_layout-no_min_linesize = 'X'.

* Now call display function
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP_OF_PAGE_SETUP' "Ref to form
is_layout = alv_layout
it_fieldcat = alv_fieldcat
* i_grid_title = text-005
TABLES
t_outtab = it_makt
EXCEPTIONS
program_error = 1
OTHERS = 2.

IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " display_alv
*&---------------------------------------------------------------------*
*& Form top_of_page_setup
*&---------------------------------------------------------------------*
*
* Set-up what to display at the top of the ALV pages
* Note that the link to this form is in the
* CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' parameter
* i_callback_top_of_page = 'TOP_OF_PAGE' in form display_alv
*----------------------------------------------------------------------*
FORM top_of_page_setup.

DATA: t_header TYPE slis_t_listheader,
wa_header TYPE slis_listheader.


wa_header-typ = 'H'.
wa_header-info = 'This is a test of the ALV grid'.
APPEND wa_header TO t_header.

CLEAR wa_header.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = t_header.
ENDFORM. " top_of_page_setup
The resulting report:

 
Reading mulitiple selected lines in a list PDF Print E-mail
User Rating: / 1
Written by Kevin Wilson   
Tuesday, 24 February 2009
Scenario: List with check boxes. You want to read all lines in the list where the check boxes are checked into an internal table.


* Define checkbox
data: markfield(1) type c value space.

* Write list

loop at itab.
write: / markfield as checkbox, itab1-myfield.
endloop.


When you are ready to read the list igain:


* Holds the number of the current line
lineno type i.


lineno = 0.

*Read the report line by line
do.
lineno = lineno + 1.

* Read markfield
read line lineno field value markfield.

* Check that you haven't reached the end of the report
if sy-subrc ne 0.
exit.
endif.

* If markfield = X then read the report line again and append it to another internal

* table
if markfield = 'X'.
* read the line igain to retrieve all fields of the line
read current line
field value itab1-myfield
into itab2-myfield.
append itab2.
endif.


enddo.


Example by Henrik Frank
var fe = FindFrame("toc", top); if ((fe != null) && (chmtop.c2wtopf.jstree != null)) { if (chmtop.c2wtopf.FITEMS[chmtop.c2wtopf.pagenum] != chmtop.c2wtopf.pageid) chmtop.c2wtopf.jstree.OpenTreeNode("" + chmtop.c2wtopf.pageid); }
 
Percentage Complete progress indicator PDF Print E-mail
User Rating: / 0
Written by anon.   
Saturday, 05 July 2008
REPORT  zprogind.

TYPES: BEGIN OF t_mara,
matnr LIKE mara-matnr,
END OF t_mara.
DATA: it_mara TYPE STANDARD TABLE OF t_mara INITIAL SIZE 0,
wa_mara TYPE t_mara.
DATA: mara_lines TYPE i,
gd_percent TYPE i.
 START-OF-SELECTION.

SELECT matnr
INTO TABLE it_mara
FROM mara.

CHECK sy-subrc EQ 0.
mara_lines = sy-dbcnt.
clear: gd_percent.

LOOP AT it_mara INTO wa_mara.
PERFORM progress_bar USING 'Retrieving data...'(001)
sy-tabix
mara_lines.
* WAIT UP TO 2 SECONDS.
ENDLOOP.
 
FORM progress_bar USING    p_value
p_tabix
p_nlines.

DATA: w_text(40),
w_percentage TYPE p,
w_percent_char(3).

w_percentage = ( p_tabix / p_nlines ) * 100.
w_percent_char = w_percentage.
SHIFT w_percent_char LEFT DELETING LEADING ' '.
CONCATENATE p_value w_percent_char '% Complete'(002) INTO w_text.

* This check needs to be in otherwise when looping around big tables
* SAP will re-display indicator too many times causing report to run
* very slow. (No need to re-display same percentage anyway)

if w_percentage gt gd_percent or p_tabix eq 1.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
percentage = w_percentage
text = w_text.
gd_percent = w_percentage.
endif.
endform. " PROGRESS_BAR


WRITE: /20 'Report is "Complete" OK'.
 
 
Undelete an Event Handler in SAP EM PDF Print E-mail
User Rating: / 0
Written by Kevin Wilson   
Wednesday, 11 June 2008
This program is a utility to flag an Event Handler as deleted or undelete an EH that is already deleted.
Read more...
 
ABAP code to display SAP icons PDF Print E-mail
User Rating: / 0
Written by Kevin Wilson   
Wednesday, 28 May 2008
Below is the ABAP code to produce a list of icons including what they look like, name and code.
Also see std. SAP program RSTXICON 
Last Updated ( Wednesday, 28 May 2008 )
Read more...
 
Create a Directory in the user local hardisk PDF Print E-mail
User Rating: / 0
Written by Kevin Wilson   
Monday, 05 May 2008

REPORT ZGUI_DIR.

call function 'GUI_CREATE_DIRECTORY'
  exporting
    dirname       = 'C:\TEST'
  EXCEPTIONS
    FAILED        = 1
    OTHERS        = 2.

if sy-subrc <> 0.
  WRITE: / 'Error Code ',SY-SUBRC.
endif.

 
ABAP Program to Extract the Units of Measure PDF Print E-mail
User Rating: / 2
Written by Anon.   
Monday, 05 May 2008
Read more...
 
ALV - Details of Y/Z objects with lists of users/date/time/description during creation or change PDF Print E-mail
User Rating: / 11
Written by Swarna S   
Wednesday, 27 February 2008
A simple ALV - Details of Y/Z objects with lists of users/date/time/description during creation or change of the object.
Last Updated ( Wednesday, 27 February 2008 )
Read more...
 
Automatic Refresh Report - periodically refreshes PDF Print E-mail
User Rating: / 0
Written by SAPDev   
Monday, 25 February 2008
The below code demonstrates how to create a simple report which automatically updates itself every 10
seconds and displays the new results on screen. This is without any intervention from the user.
Read more...
 
A program to load a database table from a UNIX file PDF Print E-mail
User Rating: / 1
Written by Judit Rakovits   
Wednesday, 02 January 2008
Requirement:

Write a program to load a database table from a UNIX file.

Read more...
 
Creating Extract Dataset PDF Print E-mail
User Rating: / 0
Written by Anon.   
Saturday, 29 December 2007
Requirement:

Write a program that lists the Vendors and their Accounting documents. Create extract dataset from KDF logical database. Loop through the dataset to create the required report. Don't list those vendors which has no documents

Read more...
 
Reading database tables - logical database PDF Print E-mail
User Rating: / 0
Written by Anon.   
Thursday, 27 December 2007
Requirement:

Read a logical database (you must have data in those tables, now LFA1), fill up an internal table. Sort the data by a given field and then display the internal table.

Read more...
 
Output Table Fields to a List PDF Print E-mail
User Rating: / 1
Written by Anon.   
Friday, 20 July 2007
When you're looking at the structure of a table, SAP will let you print the structure, but it won't let you save the structure. This can be annoying. This report outputs the table structure to a list. At this point the user can use the System->List->Save->Local file command to save the list to a file. Output Table Fields to a List
Read more...
 
Get Data From MS Access Into Internal Table PDF Print E-mail
User Rating: / 2
Written by Amit Khari   
Wednesday, 18 July 2007
Upload Data From MS Accsess Into an Internal Table
Read more...
 
<< Start < Prev 1 2 3 4 5 6 Next > End >>

Results 1 - 15 of 87

Google Search

Google Ads