‎2008 Aug 27 10:21 AM
Hi ,
I have one requirement such that i should use submit statement to run a zreport2
from my current zreport1.
My doubt is that how can i pass the input values to this zreport2 and how can i
retrieve the output values from this zreport2 in my current program zreport1.
Points will be awarded.
Thanks&Regards.
Arun.
‎2008 Aug 27 10:23 AM
‎2008 Aug 27 10:23 AM
‎2008 Aug 27 10:24 AM
‎2008 Aug 27 10:24 AM
‎2008 Aug 27 10:25 AM
Hi,
Check this sample code.
Here I'm sending t_spfli table to memory Id ABC. Then I'm calling another program. In 2nd program, I'm extracting the same table from same memory Id.
PROGRAM 1
REPORT z_abap_memory.
DATA:
w_carrid TYPE spfli-carrid,
BEGIN OF fs_spfli,
carrid LIKE spfli-carrid,
connid LIKE spfli-connid,
fltime LIKE spfli-fltime,
END OF fs_spfli.
DATA:
t_spfli LIKE
TABLE OF
fs_spfli.
SELECT-OPTIONS:
s_carrid FOR w_carrid.
START-OF-SELECTION.
PERFORM get_spfli.
PERFORM disp_spfli.
AT LINE-SELECTION.
IF sy-lsind EQ 1.
EXPORT t_spfli TO MEMORY ID 'ABC'.
SUBMIT Z_ABAP_MEMORY1 AND RETURN.
ENDIF.
END-OF-SELECTION.
PERFORM disp_spfli.
*&---------------------------------------------------------------------*
*& Form get_spfli
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_spfli .
SELECT carrid
connid
fltime
FROM spfli
INTO TABLE t_spfli
WHERE carrid IN s_carrid.
ENDFORM. " get_spfli
*&---------------------------------------------------------------------
*
*& Form disp_spfli
*&---------------------------------------------------------------------
*
* text
*----------------------------------------------------------------------
*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------
*
FORM disp_spfli .
LOOP AT t_spfli INTO fs_spfli.
WRITE: / fs_spfli-carrid,
fs_spfli-connid,
fs_spfli-fltime.
ENDLOOP.
HIDE:
fs_spfli-carrid,
fs_spfli-connid.
ENDFORM. " disp_spfli
PROGRAM 2
REPORT z_abap_memory1.
DATA:
BEGIN OF fs_spfli,
carrid LIKE spfli-carrid,
connid LIKE spfli-connid,
fltime LIKE spfli-fltime,
END OF fs_spfli,
fs_fl LIKE fs_spfli.
DATA:
BEGIN OF fs_flight,
carrid LIKE sflight-carrid,
connid LIKE sflight-connid,
fldate LIKE sflight-fldate,
END OF fs_flight.
DATA:
t_spfli LIKE
TABLE OF
fs_spfli.
DATA:
t_fl LIKE t_spfli.
DATA:
t_flight LIKE
TABLE OF
fs_flight.
IMPORT t_spfli FROM MEMORY ID 'ABC'.
t_fl = t_spfli.
SELECT carrid
connid
fldate
FROM sflight
INTO TABLE t_flight
FOR ALL ENTRIES IN t_spfli
WHERE carrid = t_spfli-carrid
AND connid = t_spfli-connid.
LOOP AT t_flight INTO fs_flight.
WRITE: / fs_flight-carrid,
fs_flight-connid,
fs_flight-fldate.
ENDLOOP.
Regards
Abhijeet
‎2008 Aug 27 10:26 AM
hi arun
SUBMIT Report2 WITH report2_field1 = report1_field1
WITH report2_field2 = report1_field2
AND RETURN.
above statement call the report2 from report1 and process report2 and return to report1
Regards
Deva
‎2008 Aug 27 10:27 AM
Hi,
You have to use IMPORT and EXPORT the data from the reports into a memory ID...
IMPORT <f1> [TO <g 1>] <f 2> [TO <g 2>] ... FROM MEMORY ID <key>.
EXPORT <f1> [FROM <g 1>] <f 2> [FROM <g 2>] ... TO MEMORY ID <key>.
Please do an F1 Help on the IMPORT and EXPORT statements for syntax
Then after the statement, Use the submit statement
Regards
Sk
‎2008 Aug 27 10:27 AM
there are multiple options...
1) you can export your data to memory from the first report (using the EXPORT TO MEMORY ID statement) and retrieve them in the second report using IMPORT statement
2) for getting the output of second report, you can either use the option (1) or you can use the FMs LIST_TO_MEMORY and LIST_TO_ASCI to get the report output.
3) for passing inputs, you can use the SUBMIT statement using VIA selection screen as suggested
‎2008 Aug 27 10:28 AM
first of all find out the variables of the selection-screen in report2
and then pass values from report1 to that values.
SUBMIT <REPORTNAME>
VARIBLES........
EXPORTING LIST TO MEMORY.
and then by using function modules u can achieve it
'LIST_FROM_MEMORY'.
'LIST_TO_ASCII'.
'WRITE_LIST'.
LIST_FREE_MEMORY'.
‎2008 Aug 27 10:28 AM
Hi ,
Chk this.
*Code used to populate 'select-options' & execute report
DATA: seltab type table of rsparams,
seltab_wa like line of seltab.
seltab_wa-selname = 'PNPPERNR'.
seltab_wa-sign = 'I'.
seltab_wa-option = 'EQ'.
load each personnel number accessed from the structure into
parameters to be used in the report
loop at pnppernr.
seltab_wa-low = pnppernr-low.
append seltab_wa to seltab.
endloop.
SUBMIT zreport with selection-table seltab
via selection-screen.
*Code used to populate 'parameters' & execute report
SUBMIT zreport with p_param1 = 'value'
with p_param2 = 'value'.
*Submit report and return to current program afterwards
SUBMIT zreport AND RETURN.
*Submit report via its own selection screen
SUBMIT zreport VIA SELECTION-SCREEN.
*Submit report using selection screen variant
SUBMIT zreport USING SELECTION-SET 'VARIANT1'.
*Submit report but export resultant list to memory, rather than
*it being displayed on screen
SUBMIT zreport EXPORTING LIST TO MEMORY.
Once report has finished and control has returned to calling
program, use function modules LIST_FROM_MEMORY, WRITE_LIST and
DISPLAY_LIST to retrieve and display report.
Regards,
Chitra