‎2005 Oct 11 6:12 PM
I have a sap program that display the table in ALV_OUTPUT. I want to create custom program to call the sap program and get the resulting ALV_OUTPUT table back into my custom program without modifying the sap program. Any help will be greatly appreciated.
‎2005 Oct 11 6:17 PM
‎2005 Oct 11 6:21 PM
I'm trying to get the ALV_OUTPUT into an internal table first then use custom code to add it to another internal table, then download it to excel.
‎2005 Oct 11 6:25 PM
Here is a sample program illistrating how to pull a list. This submits the program behind transaction MMBE and brings the list back, then displays the internal table. Enter any valid material number and execute.
report zrich_0002.
data: begin of listout occurs 0,
line(1024) type c,
end of listout.
parameters: p_matnr type mara-matnr.
ranges: r_matnr for mara-matnr.
start-of-selection.
r_matnr-sign = 'I'.
r_matnr-option = 'EQ'.
r_matnr-low = p_matnr.
append r_matnr.
* Submit the report and export list to memory
submit RMMMBEST exporting list to memory
with ms_matnr-low in r_matnr
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.
Regards,
Rich HEilman
‎2005 Oct 11 6:26 PM
What Rich was asking is, does the SAP standard report displays an ALV grid or or an ALV list output? If the standard SAP program is displaying the output in a grid, then it is not possible to export it to memory and then read it. But if it is displaying it in ALV list format, then you can.
Remember, by exporting list to memory, you are exporting a formatted output, not the internal table. Your import will give you only data in a long string. You will have write some parsing code to read it into an internal table with fields.
Srinivas
‎2005 Oct 11 6:29 PM
It's alv list. and thanks for all the help. I'll try it out.
‎2005 Oct 11 6:34 PM
‎2005 Oct 11 6:39 PM
‎2005 Oct 11 10:05 PM
It didn't work. The sap program still shows on the screen and the alv_output table didn't get copy over to the custom program. Do you have any other suggestions? Anything that help will be great.
‎2005 Oct 12 12:49 AM
The only other thing would be to copy the program into a "Z" program, then comment out the call to the ALV and just pass the ALV_OUTPUT to a memory id. The import it in your other program. Or you could comment out the call to ALV and just write it out with basic WRITE statements, then you would be able to use the EXPORT LIST TO MEMORY code.
Regards,
Rich Heilman
‎2005 Oct 11 6:23 PM
here is the code to call the sap program
SUBMIT rhpe_expired_quali
WITH pchplvar = pchplvar
WITH pchotype = pchotype
WITH pchobjid IN pchobjid
WITH pchbegda = se_begd
WITH pchendda = se_endd
WITH h_qual = h_qual
WITH h_events = h_events
AND RETURN.