Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

re-using a report functionality

Former Member
0 Likes
590

hi guys,

i need to use a functionality from a report, this one do a very big query with validations, merge several tables, and print it without an ALV.

i want to call this report and get one of the internal tables that are displayed.

is there any way to call the report and store some of the tables in memory or something?

tks in advance

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
545

hi javier,

Execute(Submit) ABAP Report

The SUBMIT statement executes a report from within a report. i.e. you could have a drill-down which

calls another report. Can only execute reports of type '1'.

*Code used to execute a report

SUBMIT Zreport.

*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'.

Other additions for SUBMIT

*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.

*Example Code (Retrieving list from memory)

DATA BEGIN OF itab_list OCCURS 0.

INCLUDE STRUCTURE abaplist.

DATA END OF itab_list.

DATA: BEGIN OF vlist OCCURS 0,

filler1(01) TYPE c,

field1(06) TYPE c,

filler(08) TYPE c,

field2(10) TYPE c,

filler3(01) TYPE c,

field3(10) TYPE c,

filler4(01) TYPE c,

field4(3) TYPE c,

filler5(02) TYPE c,

field5(15) TYPE c,

filler6(02) TYPE c,

field6(30) TYPE c,

filler7(43) TYPE c,

field7(10) TYPE c,

END OF vlist.

SUBMIT zreport EXPORTING LIST TO MEMORY.

CALL FUNCTION 'LIST_FROM_MEMORY'

TABLES

listobject = itab_list

EXCEPTIONS

not_found = 4

OTHERS = 8.

CALL FUNCTION 'LIST_TO_ASCI'

EXPORTING

list_index = -1

TABLES

listasci = vlist

listobject = itab_list

EXCEPTIONS

empty_list = 1

list_index_invalid = 2

OTHERS = 3.

IF sy-subrc NE '0'.

WRITE:/ 'LIST_TO_ASCI error !! ', sy-subrc.

ENDIF.

Submit report as job

*Submit report as job(i.e. in background)

data: jobname like tbtcjob-jobname value

' TRANSFER TRANSLATION'.

data: jobcount like tbtcjob-jobcount,

host like msxxlist-host.

data: begin of starttime.

include structure tbtcstrt.

data: end of starttime.

data: starttimeimmediate like btch0000-char1.

  • Job open

call function 'JOB_OPEN'

exporting

delanfrep = ' '

jobgroup = ' '

jobname = jobname

sdlstrtdt = sy-datum

sdlstrttm = sy-uzeit

importing

jobcount = jobcount

exceptions

cant_create_job = 01

invalid_job_data = 02

jobname_missing = 03.

if sy-subrc ne 0.

"error processing

endif.

  • Insert process into job

SUBMIT zreport and return

with p_param1 = 'value'

with p_param2 = 'value'

user sy-uname

via job jobname

number jobcount.

if sy-subrc > 0.

"error processing

endif.

  • Close job

starttime-sdlstrtdt = sy-datum + 1.

starttime-sdlstrttm = '220000'.

call function 'JOB_CLOSE'

exporting

event_id = starttime-eventid

event_param = starttime-eventparm

event_periodic = starttime-periodic

jobcount = jobcount

jobname = jobname

laststrtdt = starttime-laststrtdt

laststrttm = starttime-laststrttm

prddays = 1

prdhours = 0

prdmins = 0

prdmonths = 0

prdweeks = 0

sdlstrtdt = starttime-sdlstrtdt

sdlstrttm = starttime-sdlstrttm

strtimmed = starttimeimmediate

targetsystem = host

exceptions

cant_start_immediate = 01

invalid_startdate = 02

jobname_missing = 03

job_close_failed = 04

job_nosteps = 05

job_notex = 06

lock_failed = 07

others = 99.

if sy-subrc eq 0.

"error processing

endif.

thanks

karthik

<REMOVED BY MODERATOR>

Edited by: Alvaro Tejada Galindo on Apr 11, 2008 3:18 PM

3 REPLIES 3
Read only

Former Member
0 Likes
546

hi javier,

Execute(Submit) ABAP Report

The SUBMIT statement executes a report from within a report. i.e. you could have a drill-down which

calls another report. Can only execute reports of type '1'.

*Code used to execute a report

SUBMIT Zreport.

*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'.

Other additions for SUBMIT

*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.

*Example Code (Retrieving list from memory)

DATA BEGIN OF itab_list OCCURS 0.

INCLUDE STRUCTURE abaplist.

DATA END OF itab_list.

DATA: BEGIN OF vlist OCCURS 0,

filler1(01) TYPE c,

field1(06) TYPE c,

filler(08) TYPE c,

field2(10) TYPE c,

filler3(01) TYPE c,

field3(10) TYPE c,

filler4(01) TYPE c,

field4(3) TYPE c,

filler5(02) TYPE c,

field5(15) TYPE c,

filler6(02) TYPE c,

field6(30) TYPE c,

filler7(43) TYPE c,

field7(10) TYPE c,

END OF vlist.

SUBMIT zreport EXPORTING LIST TO MEMORY.

CALL FUNCTION 'LIST_FROM_MEMORY'

TABLES

listobject = itab_list

EXCEPTIONS

not_found = 4

OTHERS = 8.

CALL FUNCTION 'LIST_TO_ASCI'

EXPORTING

list_index = -1

TABLES

listasci = vlist

listobject = itab_list

EXCEPTIONS

empty_list = 1

list_index_invalid = 2

OTHERS = 3.

IF sy-subrc NE '0'.

WRITE:/ 'LIST_TO_ASCI error !! ', sy-subrc.

ENDIF.

Submit report as job

*Submit report as job(i.e. in background)

data: jobname like tbtcjob-jobname value

' TRANSFER TRANSLATION'.

data: jobcount like tbtcjob-jobcount,

host like msxxlist-host.

data: begin of starttime.

include structure tbtcstrt.

data: end of starttime.

data: starttimeimmediate like btch0000-char1.

  • Job open

call function 'JOB_OPEN'

exporting

delanfrep = ' '

jobgroup = ' '

jobname = jobname

sdlstrtdt = sy-datum

sdlstrttm = sy-uzeit

importing

jobcount = jobcount

exceptions

cant_create_job = 01

invalid_job_data = 02

jobname_missing = 03.

if sy-subrc ne 0.

"error processing

endif.

  • Insert process into job

SUBMIT zreport and return

with p_param1 = 'value'

with p_param2 = 'value'

user sy-uname

via job jobname

number jobcount.

if sy-subrc > 0.

"error processing

endif.

  • Close job

starttime-sdlstrtdt = sy-datum + 1.

starttime-sdlstrttm = '220000'.

call function 'JOB_CLOSE'

exporting

event_id = starttime-eventid

event_param = starttime-eventparm

event_periodic = starttime-periodic

jobcount = jobcount

jobname = jobname

laststrtdt = starttime-laststrtdt

laststrttm = starttime-laststrttm

prddays = 1

prdhours = 0

prdmins = 0

prdmonths = 0

prdweeks = 0

sdlstrtdt = starttime-sdlstrtdt

sdlstrttm = starttime-sdlstrttm

strtimmed = starttimeimmediate

targetsystem = host

exceptions

cant_start_immediate = 01

invalid_startdate = 02

jobname_missing = 03

job_close_failed = 04

job_nosteps = 05

job_notex = 06

lock_failed = 07

others = 99.

if sy-subrc eq 0.

"error processing

endif.

thanks

karthik

<REMOVED BY MODERATOR>

Edited by: Alvaro Tejada Galindo on Apr 11, 2008 3:18 PM

Read only

Former Member
0 Likes
545

Hi javier santana ,

You can do the below :

1) Copy the logic of the data retrievel , that you have inside the report to a Function module or check the existing report is this is already done in the re-usable framework(form routines / Function Modules? Class methods) .

Let me know if you have any questions.

Thanks,

Greetson

Read only

Former Member
0 Likes
545

It is not going to be easy to capture the contents of the internal table of a different program, but you can easily access the list output.

ABAP statement SUBMIT has an option EXPORTING LIST TO MEMORY. From your program, you SUBMIT the other report program using EXPORTING LIST TO MEMORY and then use the statement IMPORT FROM MEMORY.

Good luck.