‎2007 Apr 18 11:33 AM
‎2007 Apr 18 11:36 AM
hi Vamshi,
could you be clear with what do you mean by extract data ?
regards,
Navneeth.K
‎2007 Apr 18 11:37 AM
Hi..,
<b>Generally we use Either HIDE or READ LINE.. to extract data from list !!</b>
Check this sample code..
*"Table declarations...................................................
tables:
vbak. " Sales document Header data
*"Selection screen elements............................................
selection-screen begin of block blck with frame .
select-options
s_docno for vbak-vbeln . " Sales documetnt number.
selection-screen end of block blck.
*" Type declarations...................................................
"----
Type declaration of the structure to hold sales documet header data *
from table VBAK . *
"----
types:
begin of type_s_sales_documentdata,
vbeln type vbak-vbeln, " Sales document number
erdat type vbak-erdat, " Sales document creation date
ernam type vbak-ernam, " Created by.
vbtyp type vbak-vbtyp, " Document category
auart type vbak-auart, " Document type
lifsk type vbak-lifsk, " Delivery block
faksk type vbak-faksk, " Billing block
netwr type vbak-netwr, " Net value of the document
waerk type vbak-waerk, " SD document currency
vkorg type vbak-vkorg, " Sales organization
kunnr type vbak-kunnr, " Sold to party
end of type_s_sales_documentdata.
"----
Type declaration of the structure to hold sales documet ITEM data *
from table VBAP. *
"----
types:
begin of type_s_itemdata,
vbeln type vbap-vbeln, " Sales document
posnr type vbap-posnr, " Sales document item
matnr type vbap-matnr, " Material number
meins type vbap-meins, " Base unit of measure
end of type_s_itemdata.
"----
Internal table to hold sales document header data *
"----
data
t_sales_documentdata type standard table
of type_s_sales_documentdata
initial size 0.
"----
Internal table to hold sales document item data *
"----
data
t_itemdata type standard table
of type_s_itemdata
initial size 0.
"----
Work area to hold sales document header data *
"----
data
wa_sales_documentdata type type_s_sales_documentdata.
"----
Work area to hold sales document item data *
"----
data
wa_itemdata type type_s_itemdata.
"----
AT LINE-SELECTION EVENT *
"----
at line-selection.
if sy-lsind lt 2.
perform disp_itemdata.
else.
message 'Choose a valid funtion'(009) type 'S'.
endif. " IF sy-lsind lt 2
"----
AT SELECTION-SCREEN EVENT *
"----
at selection-screen.
perform read_vbak.
"----
END-OF-SELECTION EVENT *
"----
end-of-selection.
perform display_salesdocument.
"----
TOP-OF-PAGE DURING LINE-SELECTION EVENT *
"----
top-of-page during line-selection.
perform headings.
&----
*& Form read_vbak
&----
This subroutine retrieves the required data from Vbak table. *
----
There are no interface parameters to be passed to this subroutine. *
----
form read_vbak .
select vbeln " Sales document number
erdat " Sales document creation date
ernam " Created by
vbtyp " Document category
auart " Document type
lifsk " Delivery block
faksk " Billing block
netwr " Net value of the document
waerk " SD document currency
vkorg " Sales organization
kunnr " Sold to party
from vbak
into table t_sales_documentdata
where vbeln in s_docno.
if sy-subrc ne 0.
message 'No Data found'(001) type 'E'.
endif. " If sy-subrc ne 0.
endform. " Form read_vbak
&----
*& Form display_Salesdocument *
&----
This subroutine generates the list with sales document header data *
----
There are no interface parameters to be passed to this subroutine. *
----
form display_salesdocument .
loop at t_sales_documentdata into wa_sales_documentdata.
write:
/ sy-vline, wa_sales_documentdata-vbeln,sy-vline,
wa_sales_documentdata-erdat, 30 sy-vline,
wa_sales_documentdata-ernam, 48 sy-vline,
wa_sales_documentdata-vbtyp, 55 sy-vline,
wa_sales_documentdata-auart, 60 sy-vline,
wa_sales_documentdata-lifsk, 70 sy-vline,
wa_sales_documentdata-faksk, 80 sy-vline,
wa_sales_documentdata-netwr currency
wa_sales_documentdata-waerk, 107 sy-vline,
wa_sales_documentdata-waerk, 116 sy-vline,
wa_sales_documentdata-vkorg, 125 sy-vline,
wa_sales_documentdata-kunnr, 138 sy-vline.
hide :
wa_sales_documentdata-vbeln,
wa_sales_documentdata-erdat,
wa_sales_documentdata-ernam,
wa_sales_documentdata-vbtyp,
wa_sales_documentdata-auart,
wa_sales_documentdata-lifsk,
wa_sales_documentdata-faksk,
wa_sales_documentdata-netwr,
wa_sales_documentdata-waerk,
wa_sales_documentdata-vkorg,
wa_sales_documentdata-kunnr.
endloop.
uline (138).
clear wa_sales_documentdata.
endform. " Form display_Salesdocument
&----
*& Form disp_itemdata *
&----
This subroutine generates the secondary list with item data *
----
There are no interface parameters to be passed to this subroutine. *
----
form disp_itemdata .
if wa_sales_documentdata-vbeln is initial.
message 'Invalid line selection'(008) type 'E'.
endif.
select vbeln " Sales document
posnr " Sales document item
matnr " Material number
meins " Base unit of measure
from vbap
into table t_itemdata
where vbeln eq wa_sales_documentdata-vbeln.
clear wa_sales_documentdata-vbeln.
if sy-subrc eq 0.
loop at t_itemdata into wa_itemdata.
uline /(49).
write:
/ sy-vline,
wa_itemdata-vbeln under 'Sales Doc'(002), 14 sy-vline,
wa_itemdata-posnr under 'Doc Item'(003), 24 sy-vline,
wa_itemdata-matnr under 'Material No'(004), 42 sy-vline,
wa_itemdata-meins under 'Unit'(005), 49 sy-vline.
endloop.
uline /(49).
else.
message 'No Data found'(001) type 'E'.
endif. " IF sy-subrc eq 0
endform. " Form disp_itemdata
&----
*& Form headings *
&----
This subroutine writes headings on the secondary list.
----
There are no interface parameters to be passed to this subroutine. *
----
form headings .
write : 'Item data'(007).
uline /(49).
format color col_heading.
write :
/'|', 'Sales Doc'(002),' |',15 'Doc Item'(003),'|',
30 'Material No'(004), '|',45 'Unit'(005) no-gap,'|'.
format color off.
endform. " Form headings
plz do remember to close your thread, when ur problem is solvedd !!
<b>reward all helpful answers..
sai ramesh</b>
‎2007 Apr 18 11:38 AM
hi
The data can be downloaded in two different ways: List>> Download to file, or System>> List>> Save>> Local File. Both methods have their good points. The List>> Download file method gives you the option to save in the DBF format that auto-parses into spreadsheets, databases and ACL. The other method seems to download large data files without the size issues, and is helpful if a criterion within a field is to be used as a filter (instead of using substring commands in ACL).
How to import a file into ACL, a spreadsheet or a database is common knowledge. The downloaded file is generally imported using the application's import wizard. Analysis of the data now begins.
regards
ravish
<b>plz reward points if helpful</b>
‎2007 Apr 18 11:39 AM
Hi,
Follow this path
System-> List-> Save->Local File
Regards,
Santosh
Message was edited by:
Santosh Kumar Patha
‎2007 Apr 18 11:39 AM
Hi,
extracting data means if you want to take print out or to save as local file go to menu bar in the list screen then System-List-Save-LocalFile.
With regards,
Jay.
‎2007 Apr 18 11:39 AM
Hi,
Before writing the Output, you can export all the data into Memory ..
here is the example Program
report zrich_0003 .
data: begin of listout occurs 0,
line(1024) type c,
end of listout.
* Submit the report and export list to memory
submit z_your_report exporting list to memory
and return.
* Get list from memory and convert to ascii
perform retrieve_list_from_memory tables listout.
loop at listout.
write:/ listout.
endloop.
************************************************************************
* RETRIEVE_LIST_FROM_MEMORY
************************************************************************
form retrieve_list_from_memory tables reportlines.
data: list like abaplist occurs 0 with header line.
data: txtlines(1024) type c occurs 0 with header line.
clear list. refresh list.
clear reportlines. refresh reportlines.
call function 'LIST_FROM_MEMORY'
tables
listobject = list
exceptions
not_found = 1
others = 2.
check sy-subrc = 0.
call function 'LIST_TO_ASCI'
tables
listobject = list
listasci = txtlines
exceptions
empty_list = 1
list_index_invalid = 2
others = 3.
check sy-subrc = 0.
reportlines[] = txtlines[].
call function 'LIST_FREE_MEMORY'.
endform.
Also please check this link for more sample codes.
http://www.sapdevelopment.co.uk/reporting/rep_submit.htm
Regards
Sudheer
‎2007 Apr 18 11:44 AM
hi..
use the following link for interactive lists.
http://help.sap.com/saphelp_45b/helpdata/en/d3/2e974d35c511d1829f0000e829fbfe/frameset.htm
reagards,
veeresh
‎2007 Apr 18 11:45 AM
hi
if u want to get some field value from list u can use either hide stmt or get cursor
stmt..which can b used later....
or else use sy-lisel -
which contains the data of the line selected.
hope this helps
‎2007 Apr 18 11:45 AM
Hi,
For example if u want to get MATNR and its description from MARA,
then..
do as below.
go to MAKT table in SE11
u will get the records
goto Settings>list format>choose fields
deselect all the fields , and choose MATNR and MAKTX
click on copy
then goto systems>list>save>local file>spread sheet
and save ur file
like this try it out for ur requirements.
Hope this answers ur question.
****reward points if useful.
All the best.