‎2011 Mar 10 4:57 PM
Hi Forums,
I have to two reports which are exactly the same. One is called from the Portal (which is a Function Module) and one is run in ECC (so it is an ABAP report). These both exist now today.
To avoid duplicate effort I would like to have the Portal Report (Function Module) call the ABAP report where I would like to keep all main report logic and any future changes.
What I would like to accomplish is to have the FM call the ABAP report passing in a table of records (what would be entered on selection screen on ECC report) and then the ABAP report would pass back a table of COMPLETED records and leaving the function module only to pass back this table to calling program.
Would a SUMBIT <program> etc work for this? OR would this be better suited for a using a import \ export?
Any further questions let me know.
Cheers
‎2011 Mar 10 5:10 PM
Even with a submit report you will need to pass the output table to the RFC FM, and submit won't achieve that (unless you use export list to memory in the submit command, but even so, it does envolve a bit of work to put it into a table of the structure of the output table). So, i would say a combination of both, and in the report have a no-display parameter which will only be filled by the submit in the FM and in that case, instead of output to screen, do a export to memory and catch it in the RFC. That's my opinion.
‎2011 Mar 10 7:06 PM
Hi Forums,
I have explored a way that I think may fit the requirement using this code.
What I have yet to figure out is the Table i passing lt_passed_ee how do i get it recognize that I would like the values to be in the selection screen table PNPPERNR ? As when I debug the program it is empty.
DATA: txtlines(3000) TYPE c OCCURS 0 WITH HEADER LINE.
DATA:lt_listobject TYPE TABLE OF abaplist.
ls_passed_ee-selname = 'PNPPERNR'.
ls_passed_ee-sign = 'I'.
ls_passed_ee-option = 'EQ'.
*load each pernr that is passed in from the UI and pass to report
LOOP AT lt_ee INTO ls_direct_ee.
ls_passed_ee-low = ls_direct_ee-objid.
APPEND ls_direct_ee TO lt_direct_ee.
ENDLOOP.
SUBMIT zhrecm_spend_ee_KW USING SELECTION-SCREEN '1000'
WITH SELECTION-TABLE lt_passed_ee
EXPORTING LIST TO MEMORY
AND RETURN.
* read list from memory into table
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = lt_listobject
EXCEPTIONS
not_found = 1
OTHERS = 2.
*Spool content in Ascii format
call function 'LIST_TO_ASCI'
tables
listobject = lt_listobject
listasci = txtlines
exceptions
empty_list = 1
list_index_invalid = 2
others = 3.
call function 'LIST_FREE_MEMORY'
tables
listobject = lt_listobject.
Edited by: Keith Warnock on Mar 10, 2011 8:33 PM
‎2011 Mar 10 8:19 PM
My code is currently setup like this and I am now getting the error:
IMPORT_ALIGNMENT_MISMATCH
Error analysis
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_SY_IMPORT_MISMATCH_ERROR', was
not caught in
procedure "IMPORT_SELTAB_FROM_MEM" "(FORM)", nor was it propagated by a RAISING
clause.
Since the caller of the procedure could not have anticipated that the
exception would occur, the current program is terminated.
The reason for the exception is:
When importing object "%_SELTAB", the structure did not match the
structure of the target object. The error occurred in component
no. 2.
This may be due to one of the following reasons:
- the structure is actually different (the next field has, for
example, a different data type) or
- the same sequence of components were exported and imported,
but the fields were from other include units.
DATA: txtlines(3000) TYPE c OCCURS 0 WITH HEADER LINE.
DATA:lt_listobject TYPE TABLE OF abaplist.
DATA: lt_passed_ee TYPE RANGE OF pernr WITH HEADER LINE,
ls_passed_ee LIKE LINE OF lt_passed_ee.
"ls_passed_ee-selname = 'PNPPERNR'.
ls_passed_ee-sign = 'I'.
ls_passed_ee-option = 'EQ'.
*load each pernr that is passed in from the UI and pass to report
LOOP AT lt_ee INTO ls_direct_ee.
ls_passed_ee-low = ls_direct_ee-objid.
APPEND ls_passed_ee TO lt_passed_ee.
ENDLOOP.
SET PARAMETER ID 'PER' FIELD space.
SUBMIT zhrecm_spend_ee WITH SELECTION-TABLE lt_passed_ee
WITH pnppernr IN lt_passed_ee
EXPORTING LIST TO MEMORY
AND RETURN.
* read list from memory into table
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = lt_listobject
EXCEPTIONS
not_found = 1
OTHERS = 2.
‎2011 Mar 11 7:30 AM
Hi Keith
Since your internal table is a of range type PERNR and with header line, what you are passing to the SUBMIT is a work area.
So change your line from,
WITH pnppernr IN lt_passed_ee
To,
WITH pnppernr IN lt_passed_ee[]
That should avoid this runtime error.
Regards
Ranganath
Edited by: Ranganath Ramesh on Mar 11, 2011 8:30 AM
‎2011 Mar 11 8:32 AM
Hello Keith,
Few points to correct:
1. If PNPPERNR is defined as a select-option in the program ZHRECM_SPRND_EE then you can pass it directly using:
SUBMIT zhrecm_spend_ee "No need to pass the SELECTION-TABLE
WITH pnppernr IN lt_passed_ee
EXPORTING LIST TO MEMORY
AND RETURN.2. Also note the selection table defined in WITH SELECTION-TABLE should be of type RSPARAMS. Which is the reason you're code is getting a runtime error! If i understand correctly you don't have to use it in your case
3. You have defined LT_PASSED_EE as:
DATA: lt_passed_ee TYPE RANGE OF pernr WITH HEADER LINE.You must be knowing WITH HEADER LINE is an obsolete statement & should be remove(as a matter-of-fact you don't need it). So change the definition to :
DATA: lt_passed_ee TYPE RANGE OF pernr.Just out of curiosity, do you want to send the list output of the Z-report back to the caller?
BR,
Suhas
‎2011 Mar 11 2:42 PM
Hi Everyone,
I was able to figure out a way to do this with the code below
Function module code:
DATA: gt_passed_ee TYPE TABLE OF zhrecm_spending_ee.
DATA: gs_passed_ee TYPE zhrecm_spending_ee.
DATA: gt_output_tab TYPE TABLE OF zhrecm_spending_ee.
LOOP AT lt_ee INTO ls_direct_ee.
gs_passed_ee-pernr = ls_direct_ee-objid.
APPEND gs_passed_ee TO gt_passed_ee.
ENDLOOP.
EXPORT gt_passed_ee TO MEMORY ID 'ZZ_KW_TEST'.
SUBMIT zhrecm_spend_ee_kw EXPORTING LIST TO MEMORY AND RETURN.
IMPORT gt_output_tab FROM MEMORY ID 'ZZ_TEST_OUTPUT'.
APPEND LINES OF gt_output_tab TO ee_spend_rpt.
Statement in ECC report once processing is finished.
EXPORT gt_output_tab TO MEMORY ID 'ZZ_TEST_OUTPUT'.
Edited by: Keith Warnock on Mar 11, 2011 3:42 PM
‎2011 Mar 11 5:02 PM
Also, you can use IMPORT/EXPORT ... FROM DATABASE INDX ...
I don't know if the output of the report is more or less static, but if it is, you can store the results in database INDX and when you call the RFC try the import with a unique key (employee number for example) and it SUBR = 0 then it's been run before with those parameters and therefore no need to submit the report. Of course this will only work with a static output, shall we say, for each month or year, something like that. If the results are different everytime you run the report, then this won't improve anything but performance.