09-30-2008 8:51 AM
Hi all,
I have an internal table where all the fields are in list format. i wanted to convert the list report into an table format. is there any function module to do this thing?. also please give any other option to solve this problem?
thanks,
navin
09-30-2008 8:55 AM
Use FM DISPLAY_BASIC_LIST
Check out this Sample Code
**************************************
TABLES: kna1.
DATA: BEGIN OF i_kunden OCCURS 0,
kunnr LIKE kna1-kunnr,
name1 LIKE kna1-name1,
END OF i_kunden.
DATA: i_data_tab LIKE hrdatatab OCCURS 20 WITH HEADER LINE.
DATA: i_fieldnames LIKE hrfieldnam OCCURS 20 WITH HEADER LINE.
CONSTANTS: c_filename(7) VALUE 'SAPDATA'.
START-OF-SELECTION.
Data Selection
SELECT kunnr name1 FROM kna1 UP TO 50 ROWS
INTO CORRESPONDING FIELDS OF TABLE i_kunden.
Master data table for transfer to Fubau
LOOP AT i_kunden.
i_data_tab-langtext1 = i_kunden-kunnr.
i_data_tab-langtext2 = i_kunden-name1.
APPEND i_data_tab.
ENDLOOP.
*Master heading table
i_fieldnames-field = 'Kundennummer'.
i_fieldnames-field2 = 'KNA1'.
i_fieldnames-field3 = 'KUNNR'.
i_fieldnames-key = 'X'.
APPEND i_fieldnames.
CLEAR i_fieldnames.
i_fieldnames-field = 'Kundenname'.
i_fieldnames-field2 = 'KNA1'.
i_fieldnames-field3 = 'NAME1'.
APPEND i_fieldnames.
List of Control as table
CALL FUNCTION 'DISPLAY_BASIC_LIST'
EXPORTING
file_name = c_filename
TABLES
data_tab = i_data_tab
fieldname_tab = i_fieldnames
EXCEPTIONS
download_problem = 1
no_data_tab_entries = 2
table_mismatch = 3
print_problems = 4
OTHERS = 5.
09-30-2008 12:42 PM
Hi bala,
I have put down the code below.the list content is stored in ASCITAB.
im calling a report ZSMREP06D_R3ENT using submit command.the values are returned in the LINE field. which is in list format. i want to convert the values in ASCITAB internal table to TABLE format. So that the fields from internal table are to be assigned to an Structure created by me for displaying it in the output.
i hope you understood my problem.
SUBMIT ZSMREP06D_R3ENT with selection-table seltab
EXPORTING LIST TO MEMORY AND RETURN.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = itab_list.
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2
.
DATA: BEGIN OF ASCITAB OCCURS 1,
LINE(256),
END OF ASCITAB.
IF sy-subrc eq 0.
CALL FUNCTION 'LIST_TO_ASCI'
EXPORTING
list_index = -1
TABLES
listasci = ASCITAB
listobject = itab_list
EXCEPTIONS
empty_list = 1
list_index_invalid = 2
OTHERS = 3.
ENDIF.