"SAP_CONVERT_TO_XML_FORMAT" for users of SAP 46c. It converts an internal table to an xml-table and downloads it.
This code needs 3 variables: FILENAME, XML-document-Name DOC_NAME(freetext) and the internal table (TAB) which you want to convert to XML.
TYPES: TRUXS.
TYPES : BEGIN OF TRUXS_XML_LINE,
DATA(256) TYPE X,
END OF TRUXS_XML_LINE.
TYPES: TYPE_XMLTAB TYPE TABLE OF TRUXS_XML_LINE.
DATA: XMLTAB TYPE TYPE_XMLTAB, BIN_SIZE TYPE I.
CALL FUNCTION 'SAP_CONVERT_TO_XML_FORMAT'
EXPORTING
* I_FIELD_SEPERATOR = ''
* I_LINE_HEADER = ''
I_FILENAME = FILENAME
* I_APPL_KEEP = ''
I_XML_DOC_NAME = DOC_NAME
IMPORTING
PE_BIN_FILESIZE = BIN_SIZE
TABLES
I_TAB_SAP_DATA = TAB
CHANGING
I_TAB_CONVERTED_DATA = XMLTAB
EXCEPTIONS
CONVERSION_FAILED = 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.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
BIN_FILESIZE = BIN_SIZE
* CODEPAGE = ' '
FILENAME = FILENAME
FILETYPE = 'BIN'
* MODE = ' '
* WK1_N_FORMAT = ' '
* WK1_N_SIZE = ' '
* WK1_T_FORMAT = ' '
* WK1_T_SIZE = ' '
* COL_SELECT = ' '
* COL_SELECTMASK = ' '
* NO_AUTH_CHECK = ' '
* IMPORTING
* FILELENGTH TABLES
DATA_TAB = XMLTAB
* FIELDNAMES EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2
INVALID_FILESIZE = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_WIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
OTHERS = 10
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
In ABAP, there are a total of 7 types of reports. They are:
Interactive Reports
Logical Database Reports
ABAP query
ALV Reports (ALV stands for ABAP List Viewer)
Report Writer/Report Painter
Views (There are different types of views also)
These are the most simple reports. It is just an output of data using the Write statement inside a loop.
Classical reports are normal reports. These reports are not having any sub reports. IT IS HAVING ONLY ONE SCREEN/LIST FOR OUTPUT
As the name suggests, the user can Interact with the report. We can have a drill down into the report data. For example, Column one of the report displays the material numbers, and the user feels that he needs some more specific data about the vendor for that material, he can HIDE that data under those material numbers.
And when the user clicks the material number, another report (actually sub report/secondary list) which displays the vendor details will be displayed.
We can have a basic list (number starts from 0) and 20 secondary lists (1 to 21).
Logical database is another tool for ABAP reports. Using LDB we can provide extra features for ABAP reports.
While using LDB there is no need for us to declare Parameters.
Selection-screen as they will be generated automatically.
We have to use the statement NODES in ABAP report.
ABAP query is another tool for ABAP. It provides efficency for ABAP reports. These reports are very accurate.
Transaction Code : SQ01
Giving them the ability to report on additional fields at their discretion shifts the report maintenance burden to them, saving SAP support groups time and effort normally spent creating and maintaining the reports.
Sap provides a set of ALV (ABAP LIST VIEWER) function modules which can be put into use to embellish the output of a report. This set of ALV functions is used to enhance the readability and functionality of any report output. Cases arise in sap when the output of a report contains columns extending more than 255 characters in length.
In such cases, this set of ALV functions can help choose selected columns and arrange the different columns from a report output and also save different variants for report display. This is a very efficient tool for dynamically sorting and arranging the columns from a report output.
The report output can contain up to 90 columns in the display with the wide array of display options.
Reports and Transactions:
1. What is LDB. Disadvantages of LDB and also advantages.
Logical Database is special ABAP program. It’s nested select statements.
Advantages: If you use LDB, it retrieves data as per foreign key relations from different tables. You need not know the relations among tables.
Disadvantages: Runtime will be increased if you use LDB.
2. What are the events associated with LDB and their purpose.
GET and GET LAST. GET will be triggered for each record and retrieves a record. GET LAST will be triggered at end of each record.
3. In which order they will be triggered.
First Get and then Get last of same table.
4. How will you change the selection screen of a LDB.
Selection screen can be changed through you add selection screen option in the program, these will be automatically added to LDB selection screen for this program.
5. Where you attach the LDB to a report.
One is Attributes, two at report header.
6. How many LDBs you can use in a Report.
Only one.
7. Order of events triggered during execution of report program.
Initialization, selection-screen, at selection-screen, start-of-selection etc
8. How to get help and/or possible values for selection screen fields
Events AT SELECTION-SCREEN ON HELP REQUEST and AT SELECTION-SCREEN ON VALUE REQUEST.
9. How many secondary lists you can have in a report.
20 secondary list and 1 basic list.
10. What are events, which triggers secondary lists.
At line-selection, At PFnn, At User-command.
11. What is the purpose of HIDE statement.
1. What is LDB. Disadvantages of LDB and also advantages.
Logical Database is special ABAP program. It’s nested select statements.
Advantages: If you use LDB, it retrieves data as per foreign key relations from different tables. You need not know the relations among tables.
Disadvantages: Runtime will be increased if you use LDB.
2. What are the events associated with LDB and their purpose.
GET and GET LAST. GET will be triggered for each record and retrieves a record. GET LAST will be triggered at end of each record.
3. In which order they will be triggered.
First Get and then Get last of same table.
4. How will you change the selection screen of a LDB.
Selection screen can be changed through you add selection screen option in the program, these will be automatically added to LDB selection screen for this program.
5. Where you attach the LDB to a report.
One is Attributes, two at report header.
6. How many LDBs you can use in a Report.
Only one.
7. Order of events triggered during execution of report program.
Initialization, selection-screen, at selection-screen, start-of-selection etc
8. How to get help and/or possible values for selection screen fields
Events AT SELECTION-SCREEN ON HELP REQUEST and AT SELECTION-SCREEN ON VALUE REQUEST.
9. How many secondary lists you can have in a report.
20 secondary list and 1 basic list.
10. What are events, which triggers secondary lists.
At line-selection, At PFnn, At User-command.
11. What is the purpose of HIDE statement.
Any other methods other than HIDE for same purpose.Hide will
help in transferring data from basic list to secondary list or one list to
other list. Other methods are GET CURSOR and SY-LISEL.
12. What are the different techniques for Data processing/refining in ABAP reports.
1. Internal Tables. 2. Extracts (Field Groups)
13. Can you put a SQL Join statement in ABAP? If yes, How
Through alias (only in 4.0 and above versions)
14. What is the system variable, which tells about number database records handled.
SY-DBCNT
15. What are different techniques available for modularization.
Internal Subroutines, External Subroutines, Macros, Function modules and Include programs.
16. What are different types of internal tables and their usage.
Standard Internal Tables
Standard tables have a linear index. You can access them using either the index or the key. If you use the key, the response time is in linear relationship to the number of table entries. The key of a standard table is always non-unique, and you may not include any specification for the uniqueness in the table definition.
This table type is particularly appropriate if you want to address individual table entries using the index. This is the quickest way to access table entries. To fill a standard table, append lines using the (APPEND) statement. You should read, modify and delete lines by referring to the index (INDEX option with the relevant ABAP command). The response time for accessing a standard table is in linear relation to the number of table entries. If you need to use key access, standard tables are appropriate if you can fill and process the table in separate steps. For example, you can fill a standard table by appending records and then sort it. If you then use key access with the binary search option (BINARY), the response time is in logarithmic relation to the number of table entries.
Sorted Internal Tables
Sorted tables are always saved correctly sorted by key. They also have a linear key, and, like standard tables, you can access them using either the table index or the key. When you use the key, the response time is in logarithmic relationship to the number of table entries, since the system uses a binary search. The key of a sorted table can be either unique, or non-unique, and you must specify either UNIQUE or NON-UNIQUE in the table definition. Standard tables and sorted tables both belong to the generic group index tables.
This table type is particularly suitable if you want the table to be sorted while you are still adding entries to it. You fill the table using the (INSERT) statement, according to the sort sequence defined in the table key. Table entries that do not fit are recognised before they are inserted. The response time for access using the key is in logarithmic relation to the number of table entries, since the system automatically uses a binary search. Sorted tables are appropriate for partially sequential processing in a LOOP, as long as the WHERE condition contains the beginning of the table key.
Hashed Internal Tables
Hashes tables have no internal linear index. You can only access hashed tables by specifying the key. The response time is constant, regardless of the number of table entries, since the search uses a hash algorithm. The key of a hashed table must be unique, and you must specify UNIQUE in the table definition.
This table type is particularly suitable if you want mainly to use key access for table entries. You cannot access hashed tables using the index. When you use key access, the response time remains constant, regardless of the number of table entries. As with database tables, the key of a hashed table is always unique. Hashed tables are therefore a useful way of constructing and using internal tables that are similar to database tables.
17. One of my users has access to SE38 transaction, and so he can run the program developed by you. You have attached this report/transactional program to a particular Z* transaction. To restrict the users to Execute this program, what you do it from programming side?
Check for Authorization object S_TCODE with value “Z----” in initialization event.
(Code:
Authority-check object 'S_TCODE'
id 'TCD' field 'ZBC_REQ'.)
18. We need to download an internal table to the Presentation Server (local workstation).
Whenever we run the program, the same file has to be saved as a separate file in sequential order. Ex: 0001.txt, 0002.txt etc. Where can we store the last file number?
SAP has a table TVARV for storing the variants.
A record may be created in TVARV for all the programs that require these kind of incremental records.
For Ex: the record could be 010ZBC_TEST MM sequence rec where first part consists of client code and the program being run. Client code is required because TVARV does not have a field for client code. The second part is the description indicating the purpose what the record is created. This entire string may be posted in the Name field (char - 30).
The Type field (char- 1) may be populated with P or S (Parameter or Selection)
Low field (char- 45) may be populated with '0001' when run first time and increment it by one in your program for downloading of the internal table.
19. When we create a customer the information is updated in structure RF02D and the
Some tables like KNA1 are updated. How can we find the tables for master data transactions?
Go to ABAP Workbench -> Overview -> application hierarchy - SAP -> (or SE81 transaction code) follow the customizing based tree for your application. Double click on a lowest level to get for the correct marked development class. Then, here you can find all the tables, views, logical databases etc..,
12. What are the different techniques for Data processing/refining in ABAP reports.
1. Internal Tables. 2. Extracts (Field Groups)
13. Can you put a SQL Join statement in ABAP? If yes, How
Through alias (only in 4.0 and above versions)
14. What is the system variable, which tells about number database records handled.
SY-DBCNT
15. What are different techniques available for modularization.
Internal Subroutines, External Subroutines, Macros, Function modules and Include programs.
16. What are different types of internal tables and their usage.
Standard Internal Tables
Standard tables have a linear index. You can access them using either the index or the key. If you use the key, the response time is in linear relationship to the number of table entries. The key of a standard table is always non-unique, and you may not include any specification for the uniqueness in the table definition.
This table type is particularly appropriate if you want to address individual table entries using the index. This is the quickest way to access table entries. To fill a standard table, append lines using the (APPEND) statement. You should read, modify and delete lines by referring to the index (INDEX option with the relevant ABAP command). The response time for accessing a standard table is in linear relation to the number of table entries. If you need to use key access, standard tables are appropriate if you can fill and process the table in separate steps. For example, you can fill a standard table by appending records and then sort it. If you then use key access with the binary search option (BINARY), the response time is in logarithmic relation to the number of table entries.
Sorted Internal Tables
Sorted tables are always saved correctly sorted by key. They also have a linear key, and, like standard tables, you can access them using either the table index or the key. When you use the key, the response time is in logarithmic relationship to the number of table entries, since the system uses a binary search. The key of a sorted table can be either unique, or non-unique, and you must specify either UNIQUE or NON-UNIQUE in the table definition. Standard tables and sorted tables both belong to the generic group index tables.
This table type is particularly suitable if you want the table to be sorted while you are still adding entries to it. You fill the table using the (INSERT) statement, according to the sort sequence defined in the table key. Table entries that do not fit are recognised before they are inserted. The response time for access using the key is in logarithmic relation to the number of table entries, since the system automatically uses a binary search. Sorted tables are appropriate for partially sequential processing in a LOOP, as long as the WHERE condition contains the beginning of the table key.
Hashed Internal Tables
Hashes tables have no internal linear index. You can only access hashed tables by specifying the key. The response time is constant, regardless of the number of table entries, since the search uses a hash algorithm. The key of a hashed table must be unique, and you must specify UNIQUE in the table definition.
This table type is particularly suitable if you want mainly to use key access for table entries. You cannot access hashed tables using the index. When you use key access, the response time remains constant, regardless of the number of table entries. As with database tables, the key of a hashed table is always unique. Hashed tables are therefore a useful way of constructing and using internal tables that are similar to database tables.
17. One of my users has access to SE38 transaction, and so he can run the program developed by you. You have attached this report/transactional program to a particular Z* transaction. To restrict the users to Execute this program, what you do it from programming side?
Check for Authorization object S_TCODE with value “Z----” in initialization event.
(Code:
Authority-check object 'S_TCODE'
id 'TCD' field 'ZBC_REQ'.)
18. We need to download an internal table to the Presentation Server (local workstation).
Whenever we run the program, the same file has to be saved as a separate file in sequential order. Ex: 0001.txt, 0002.txt etc. Where can we store the last file number?
SAP has a table TVARV for storing the variants.
A record may be created in TVARV for all the programs that require these kind of incremental records.
For Ex: the record could be 010ZBC_TEST MM sequence rec where first part consists of client code and the program being run. Client code is required because TVARV does not have a field for client code. The second part is the description indicating the purpose what the record is created. This entire string may be posted in the Name field (char - 30).
The Type field (char- 1) may be populated with P or S (Parameter or Selection)
Low field (char- 45) may be populated with '0001' when run first time and increment it by one in your program for downloading of the internal table.
19. When we create a customer the information is updated in structure RF02D and the
Some tables like KNA1 are updated. How can we find the tables for master data transactions?
Go to ABAP Workbench -> Overview -> application hierarchy - SAP -> (or SE81 transaction code) follow the customizing based tree for your application. Double click on a lowest level to get for the correct marked development class. Then, here you can find all the tables, views, logical databases etc..,
What is a report?
Report is a program used to fetch data from the database tables and display it on the screen. It has 2 screens selection screen(optional) and list or output screen.
When the TOP-OF-PAGE event does get triggered?
TOP-OF-PAGE event will be triggered when the first ULINE, WRITE or SKIP statement occurs in a program.
What is the difference between SKIP and RESERVE?
SKIP provides empty space between lines, while RESERVE executes a page break on the current page if the number of lines between current line and the page footer is less than the number specified in RESERVE statement.
What is the difference between SKIP and NEW-LINE?
SKIP generates a blank line, while the NEW-LINE causes the control to move to next line.
What is hotspot?
Hotspot is an area on the list where the mouse pointer turns into an upright hand symbol. A single click on the hotspot does the same thing as a double-click.
What does HIDE statement do?
The HIDE statement hides the contents of the line along with the line numbers in a system defined HIDE area. This is used in interactive reporting.
What are the events in classical reports?
- INITIALIZATION
- AT SELECTION-SCREEN
- START-OF-SELECTION
- END-OF-SELECTION
- TOP-OF-PAGE
- END-OF-PAGE
20
What is the name of the system variable that holds the contents of the selected line in interactive reporting?
SY-LISEL
Can we set page headers to details lists?
Yes. Use TOP-OF-PAGE DURING LINE-SELECTION event..
Question 18: Can you show multiple ALVs on a Single Screen?
Yes, there are multiple ways of doing this:
Yes, there are multiple ways of doing this:
· If you are using OOALV, you can create multiple custom containers
(cl_gui_custom_container) & put an ALV control (cl_gui_alv_grid) in each of those.
(cl_gui_custom_container) & put an ALV control (cl_gui_alv_grid) in each of those.
· You can even use a Splitter container control and place multiple ALVs in each of
the split container.
the split container.
· If you are using Normal ALV, You can use the following FMS:
1. REUSE_ALV_BLOCK_LIST_INIT
2. REUSE_ALV_BLOCK_LIST_APPEND
3. REUSE_ALV_BLOCK_LIST_DISPLAY
REPORT zvg_test_04. TYPES: BEGIN OF ty_cust, kunnr LIKE kna1-kunnr, name1 LIKE kna1-name1, ort01 LIKE kna1-ort01, END OF ty_cust, BEGIN OF ty_vbrk , vbeln LIKE vbrk-vbeln, kunag LIKE vbrk-kunag, fkdat LIKE vbrk-fkdat, END OF ty_vbrk. DATA: gv_container TYPE REF TO cl_gui_custom_container, gv_alvgrid TYPE REF TO cl_gui_alv_grid, gv_struct_name TYPE dd02l-tabname, gv_variant TYPE disvariant. DATA: wa_layout TYPE lvc_s_layo, wa_fcatlg TYPE lvc_s_fcat, it_fcatlg TYPE lvc_t_fcat, it_cust TYPE TABLE OF ty_cust, it_vbrk TYPE TABLE OF ty_vbrk. START-OF-SELECTION. SELECT kunnr name1 ort01 FROM kna1 INTO TABLE it_cust UP TO 10 ROWS. SELECT vbeln kunag fkdat FROM vbrk INTO TABLE it_vbrk UP TO 10 ROWS. CALL SCREEN 100. &--------------------------------------------------------------------- *& Module STATUS_0100 OUTPUT &--------------------------------------------------------------------- text ---------------------------------------------------------------------- MODULE status_0100 OUTPUT. SET PF-STATUS 'PF_STATUS'. --- First ALV --- Creating Container IF gv_container IS INITIAL. PERFORM create_container USING 'CONTAINER01'. Creating ALV grid PERFORM create_alvgrid. Creating Field catalog manually PERFORM create_fieldcat USING: '1' 'KUNNR' 'IT_CUST' 'This is Customer Code' 'Cust No', '2' 'NAME1' 'IT_CUST' 'This is Customer Name' 'Customer Name', '3' 'ORT01' 'IT_CUST' 'This is Customer City' ' C i t y '. Displaying the final output PERFORM display_tab TABLES it_cust. REFRESH it_fcatlg. --- Second ALV --- Creating Container IF gv_container IS INITIAL. PERFORM create_container USING 'CONTAINER02'. Creating ALV grid PERFORM create_alvgrid. Creating Field catalog manually PERFORM create_fieldcat USING: '1' 'VBELN' 'IT_VBRK' 'This is Billing Document' 'Bill Doc', '2' 'KUNAG' 'IT_VBRK' 'This is Sold-to party' 'Sold-to-Party', '3' 'FKDAT' 'IT_VBRK' 'This is Billing Date' 'Date '. Displaying the final output PERFORM display_tab TABLES it_vbrk. ENDIF. For Creating Field catalog Automatically CALL FUNCTION 'LVC_FIELDCATALOG_MERGE' ENDMODULE. " STATUS_0100 OUTPUT &--------------------------------------------------------------------- *& Module USER_COMMAND_0100 INPUT &--------------------------------------------------------------------- text ---------------------------------------------------------------------- MODULE user_command_0100 INPUT. CASE sy-ucomm. WHEN 'BACK'. CALL METHOD cl_gui_cfw=>flush. LEAVE TO SCREEN 0. WHEN 'EXIT'. PERFORM exit. ENDCASE. ENDMODULE. " USER_COMMAND_0100 INPUT &--------------------------------------------------------------------- *& Form EXIT &--------------------------------------------------------------------- text ---------------------------------------------------------------------- FORM exit . CALL METHOD gv_container->free. CALL METHOD cl_gui_cfw=>flush. LEAVE PROGRAM. ENDFORM. " EXIT &--------------------------------------------------------------------- *& Form CREATE_CONTAINER &--------------------------------------------------------------------- text ---------------------------------------------------------------------- -->P_TEXT text ---------------------------------------------------------------------- FORM create_container USING p_text. CREATE OBJECT gv_container EXPORTING container_name = p_text EXCEPTIONS cntl_error = 1 cntl_system_error = 2 create_error = 3 lifetime_error = 4 lifetime_dynpro_dynpro_link = 5 OTHERS = 6. IF sy-subrc IS NOT INITIAL. MESSAGE text-003 TYPE 'S' DISPLAY LIKE 'E'. LEAVE TO LIST-PROCESSING. ENDIF. ENDFORM. " CREATE_CONTAINER &--------------------------------------------------------------------- *& Form CREATE_ALVGRID &--------------------------------------------------------------------- text ---------------------------------------------------------------------- FORM create_alvgrid . CREATE OBJECT gv_alvgrid EXPORTING i_parent = gv_container EXCEPTIONS error_cntl_create = 1 error_cntl_init = 2 error_cntl_link = 3 error_dp_create = 4 OTHERS = 5. IF sy-subrc IS NOT INITIAL. MESSAGE text-005 TYPE 'S' DISPLAY LIKE 'E'. LEAVE TO LIST-PROCESSING. ENDIF. ENDFORM. " CREATE_ALVGRID &--------------------------------------------------------------------- *& Form DISPLAY_TAB &--------------------------------------------------------------------- text ---------------------------------------------------------------------- -->P_TAB text ---------------------------------------------------------------------- FORM display_tab TABLES p_tab. gv_variant-report = sy-repid. CALL METHOD gv_alvgrid->set_table_for_first_display EXPORTING is_variant = gv_variant i_save = 'A' CHANGING it_outtab = p_tab[] it_fieldcatalog = it_fcatlg EXCEPTIONS invalid_parameter_combination = 1 program_error = 2 too_many_lines = 3 OTHERS = 4. IF sy-subrc IS NOT INITIAL. MESSAGE text-e05 TYPE 'S' DISPLAY LIKE 'E'. LEAVE TO LIST-PROCESSING. ENDIF. "Insert correct name for <...>. ENDFORM. " DISPLAY_TAB &--------------------------------------------------------------------- *& Form create_fieldcat &--------------------------------------------------------------------- text ---------------------------------------------------------------------- -->COL_POS text -->FIELDNAME text -->TABNAME text -->TOOLTIP text -->REPTEXT text ---------------------------------------------------------------------- FORM create_fieldcat USING col_pos fieldname tabname tooltip reptext. wa_fcatlg-col_pos = col_pos. wa_fcatlg-fieldname = fieldname. wa_fcatlg-tabname = tabname. wa_fcatlg-tooltip = tooltip. wa_fcatlg-reptext = reptext. APPEND wa_fcatlg TO it_fcatlg. CLEAR wa_fcatlg. ENDFORM. "create_fieldcat
All about ABAP List Viewer ( List Display, Grid Display, Using OOP)
ALV programming
Content:
Ø Introduction
Ø ALV List Display
Ø ALV Grid Display
Ø ALV Hierarchical Display
Ø ALV using OOPs
Ø Editing and coloring
Ø Code snippets
Introduction:
Common Steps:
- Data declarations
- Fetch the required data form the tables
- Prepare field catalog
- Build up the event table if required
- Display ALV output by Calling FM
All the definitions TYPES and STRUCTURES and CONSTANTS are defined in the TYPE-POOL ‘SLIS’, so it should be declared first.
ALV List Display:
- Field catalog can be prepared manually (should contain at least TABNAME, FIELDNAME, REF_TABNAME, SELTECT_M) or by using REUSE_ALV_FIELDCATALOG_MERGE.
- To get all possible events REUSE_ALV_EVENTS_GET can be used.
- To write proper comments use REUSE_ALV_COMMENTARY_WRITE.
- To print the data REUSE_ALV_LIST_DISPLAY can be used.
- Build up the event table if required
- Display ALV output by Calling FM
All the definitions TYPES and STRUCTURES and CONSTANTS are defined in the TYPE-POOL ‘SLIS’, so it should be declared first.
ALV List Display:
- Field catalog can be prepared manually (should contain at least TABNAME, FIELDNAME, REF_TABNAME, SELTECT_M) or by using REUSE_ALV_FIELDCATALOG_MERGE.
- To get all possible events REUSE_ALV_EVENTS_GET can be used.
- To write proper comments use REUSE_ALV_COMMENTARY_WRITE.
- To print the data REUSE_ALV_LIST_DISPLAY can be used.
ALV Grid Display:
- The first 3 function modules mentioned above can be used and to print the data REUSE_ALV_GRID_DISPLAY is used.
- The first 3 function modules mentioned above can be used and to print the data REUSE_ALV_GRID_DISPLAY is used.
Hierarchical ALV:
- Hierarchical display is used for displaying data that are related. Like sales order and item details.
- REUSE_ALV_HIERSEQ_LIST_DISPLAY is used to print the data.
- Hierarchical display is used for displaying data that are related. Like sales order and item details.
- REUSE_ALV_HIERSEQ_LIST_DISPLAY is used to print the data.
ALV Using OOPs:
- Create Docking/custom container.
- Create a grid inside container.
- Call function LVC_FIELDCATALOG_MERGE to get the field catalog.
- Call method SET_TABLE_FOR_FIRST_DISPLAY for o/p.
Editing and Coloring:
- Coloring an entire column
- Create Docking/custom container.
- Create a grid inside container.
- Call function LVC_FIELDCATALOG_MERGE to get the field catalog.
- Call method SET_TABLE_FOR_FIRST_DISPLAY for o/p.
Editing and Coloring:
- Coloring an entire column
To make an entire
column be painted with the color you want, you can use the "emphasize"
option of the field catalog. Simply assign a color code to this field of
the row added for your column. Color codes are constructed as follows:
Cxyz: - x: 1-7 (1 for example is gray-blue, 6 is red), y: intensified on/off, z: inverse on/off.
- Coloring an entire row
Cxyz: - x: 1-7 (1 for example is gray-blue, 6 is red), y: intensified on/off, z: inverse on/off.
- Coloring an entire row
Coloring a row is a bit more complicated. To enable row coloring, you should add an additional field to your list data table. It should be of character type and at least 4 bit long. This field will contain the color code for the row. So for example:
DATA: BEGIN OF gt_list occurs 0.
INCLUDE STRUCTURE .
DATA rowcolor(4) TYPE c.
DATA: END OF gt_list.
As you guess, you should fill the color code to this field. Its format is as explained before. For second you must pass the name of the field to the layout structure:E.g. ps_layout-info_fname = 'ROWCOLOR'.
- Coloring an individual cell:
Likely coloring rows, you must append an internal table to each line of gt_list containing the color information:
DATA: BEGIN OF gt_list occurs 0.
INCLUDE STRUCTURE .
DATA cellcolors TYPE lvc_t_scol.
DATA: END OF gt_list.
If you want to modify the cell in the 5 row and the 2 column, you have to set:
DATA: cellcolor type line of lvc_t_scol.
READ TABLE gt_list INDEX 2.
cellcolor-fname = '.cellcolor-color-col = '6'.
cellcolor-color-int = '0'.
APPEND cellcolor TO gt_list-cellcolors.
Modify GT_LIST INDEX 5.
As like coloring rows, you have to pass the info for coloring cell to the layout-structure:
ps_layout-info_ctab_fname = 'CELLCOLOR'.
- Editing an entire column:
When you want to do edit only for particular column and not for the entire grid then you need to perform fieldcat in that particular column only. Loop the field catalog and for that column make the EDIT field of catalog as ‘X’ and then modify catalog.
- Editing a single cell:Add a table to your list data table.
Data begin of gt_grid occurs 0.
data cellstyles type lvc_t_styl.
Data end of gt_grid.Form make_field_edit using pt_grid like gt_grid[].
data: ls_grid like line of pt_grid,
ls_style type lvc_s_styl,
lt_style type lvc_t_styl.Loop at pt_grid into ls_grid.
If ls_grid-curr = xyz. 'your condition for the row
ls_style-fieldname = 'CURR'.
ls_style-style = cl_gui_alv_grid=>mc_style_enabled.
append ls_style to lt_style.
endif.
Insert lines of lt_style into ls_grid-celltyles.modify pt_grid from ls_grid.
Endloop.
Endform.
When you want to do edit only for particular column and not for the entire grid then you need to perform fieldcat in that particular column only. Loop the field catalog and for that column make the EDIT field of catalog as ‘X’ and then modify catalog.
- Editing a single cell:Add a table to your list data table.
Data begin of gt_grid occurs 0.
data cellstyles type lvc_t_styl.
Data end of gt_grid.Form make_field_edit using pt_grid like gt_grid[].
data: ls_grid like line of pt_grid,
ls_style type lvc_s_styl,
lt_style type lvc_t_styl.Loop at pt_grid into ls_grid.
If ls_grid-curr = xyz. 'your condition for the row
ls_style-fieldname = 'CURR'.
ls_style-style = cl_gui_alv_grid=>mc_style_enabled.
append ls_style to lt_style.
endif.
Insert lines of lt_style into ls_grid-celltyles.modify pt_grid from ls_grid.
Endloop.
Endform.
Introduction:
When
an ABAP report (Type 1) is executed, the program context and memory
space variables are made available on the application server. The
subsequent program flow is controlled by the ABAP runtime system. If the
program contains a selection screen, the ABAP runtime system sends it
to the presentation server at the start of the program.
When the user executes the report after entering selection fields, the data entered on the selection screen is automatically placed in the corresponding data objects. The ABAP runtime system takes over control of the program. Then the program sends information to the database about the records that should be read. The database returns the required database records and the runtime system ensures that the data is placed in the relevant data objects.
The list output is also programmed in the processing block. After the processing block finishes, the runtime system sends the list as a screen to the presentation server. The events START-OF-SELECTION, GET, END-OF-SELECTION, TOP-OF-PAGE and END-OFPAGE can be used only to create basic lists.
When the user executes the report after entering selection fields, the data entered on the selection screen is automatically placed in the corresponding data objects. The ABAP runtime system takes over control of the program. Then the program sends information to the database about the records that should be read. The database returns the required database records and the runtime system ensures that the data is placed in the relevant data objects.
The list output is also programmed in the processing block. After the processing block finishes, the runtime system sends the list as a screen to the presentation server. The events START-OF-SELECTION, GET, END-OF-SELECTION, TOP-OF-PAGE and END-OFPAGE can be used only to create basic lists.
· To create detail lists, use the events AT LINE-SELECTION or AT USER-COMMAND. We use TOP-OF-PAGE DURING LINE-SELECTION for page headers on detail lists.
· Each
detail list event exists only once in the program and is shared by all
detail lists. You must therefore ensure yourself, within the processing
block, that the correct list is created.
· To do this, use a CASE structure that uses the system field sy-lsind. This system field contains the list index of the list that you are currently generating.
· Use the statement HIDE global field to store the contents of the global data field
global_field for the current line.
global_field for the current line.
· If the user selects the line, the data field is automatically filled with the value that you retained for the line.
· You do not have to display the field on the list in order to retain its value using HIDE.
· The field can be a structure. However, deep structures (structures containing internal tables as components) are not supported.
· When
the user selects a line on an interactive list, all of the global data
fields whose values you stored using the HIDE statement while you were
creating the basic list are filled with those values.
· The
line selection is based on the cursor position when the AT
LINE-SELECTION and AT USERCOMMAND events occur. (System field sy-lilli).
· GET CURSOR gets the cursor position on a screen or in an interactive list event.
Syntax : GET CURSOR FIELD [OFFSET ] [LINE ][VALUE ] [LENGTH ]. GET CURSOR LINE [OFFSET ] [VALUE ] [LENGTH ].
At a user action on a
list or screen, the statement writes the position, value, and displayed
length of a field or line into the corresponding variables.· GET CURSOR gets the cursor position on a screen or in an interactive list event.
Syntax : GET CURSOR FIELD [OFFSET ] [LINE ][VALUE ] [LENGTH ]. GET CURSOR LINE [OFFSET ] [VALUE ] [LENGTH ].
· If
you choose a line using the READ LINE... statement, the values are
placed back in the original fields according to the line numbers.
· To
check whether the user selected a valid line, you can use the fact that
the hide area only contains data for valid lines. When you have
finished creating the list, initialize a suitable test field.
· This allows you to check before you create the detail list whether a value from the hide area has been placed in the test field.
· Once
you have created the detail list, re-initialize the test field to
ensure that the user cannot choose an invalid line once he or she
returns from the detail list and attempts to select another line for a
new detail list.
An interactive report generally works in the following fashion:
1. Basic list is displayed.
2. User double clicks on any valid line
or
User selects a line and presses as button on the tool bar.
3. The corresponding event is triggered
4. Then in the code, the line on which action was done, is read.
5. Depending on the values in that selected line, a secondary list is displayed.
6. Steps from 2-5 are repeated till the end.
2. User double clicks on any valid line
or
User selects a line and presses as button on the tool bar.
3. The corresponding event is triggered
4. Then in the code, the line on which action was done, is read.
5. Depending on the values in that selected line, a secondary list is displayed.
6. Steps from 2-5 are repeated till the end.
No comments:
Post a Comment