‎2010 Feb 08 10:25 PM
Hi All,
I have a Standard Report program which on input of particular parameter value displays a ALV Grid Output.
But, ,my requirement is as follows:-
I generate a Z-program which has Select-option for a field.
For each value in the Select-option , I need to submit the Standard Report program in background using SUBMIT statement.
Now, I dont want ALV Grid Output to be displayed , instead want to get back the Output Data into the Z-program.
Then, after processing for all Select-option values I will be displaying the required Output from my Z-program.
Please guide me how can I do this.
Main issues are:-
1. On running a program through SUBMIT, how to suppress the Output which gets displayed?
2. How to get back the data from Called program to Calling program?
Thanks,
Shivaa.....
‎2010 Feb 09 4:10 AM
Hi,
You can use Submit report as below:
SUBMIT rm07docs USING SELECTION-SET 'PLANT 4000'
WITH p_online = 'X'
TO SAP-SPOOL
SPOOL PARAMETERS %_print
WITHOUT SPOOL DYNPRO
AND RETURN.Then find out what the spool number is that was just created:
DATA: l_i_tsp01 TYPE STANDARD TABLE OF tsp01 WITH HEADER LINE .
DATA: l_c_rq2name LIKE tsp01-rq2name.
CONCATENATE report+0(8)
sy-uname+0(3)
INTO l_c_rq2name SEPARATED BY '_'.
SELECT * FROM tsp01 INTO TABLE l_i_tsp01 WHERE rq2name = l_c_rq2name.
SORT l_i_tsp01 BY rqcretime DESCENDING.
READ TABLE l_i_tsp01 INDEX 1.
v_spool_num = l_i_tsp01-rqident.
IF sy-subrc NE 0.
CLEAR v_spool_num.
ENDIF.Use FM 'RSPO_RETURN_ABAP_SPOOLJOB' to convert in into table.
TYPES: BEGIN OF ty_spool_output,
default(256) TYPE c,
END OF ty_spool_output,
ty_t_spool_output TYPE STANDARD TABLE OF ty_spool_output.
*-- INTERNAL TABLES
DATA :i_spool_output TYPE ty_t_spool_output,
wa_spool_output TYPE ty_spool_output.
CALL FUNCTION 'RSPO_RETURN_ABAP_SPOOLJOB'
EXPORTING
rqident = v_spool_num
TABLES
buffer = i_spool_output
EXCEPTIONS
no_such_job = 1
not_abap_list = 2
job_contains_no_data = 3
selection_empty = 4
no_permission = 5
can_not_access = 6
read_error = 7
OTHERS = 8.Then process this internal table and use it in your program.
Thanks,
Archana
‎2010 Feb 09 3:20 AM
Dear Shiva,
You can try this:(My suggestion)
1. You can copy the standard program in Z-namespace and comment the code which displays the output in ALV gird. After the result set is prepared, add the code like:
EXPORT <result_table> TO MEMORY ID 'RES_TABLE'.
2. You can create the selection parameters table in your Z program and call the copied standard program using the SUBMIT keyword.
the code snippet:
DATA:
gt_params TYPE TABLE OF rsparams,
gw_params TYPE rsparams.
" To prepare the selection parameters table, loop on the select-option field as shown:
LOOP AT <selectio-option>.
CLEAR: gw_params.
gw_params-selname = '....'. " selname should match with the field used in the standard program while firing the SELECT "query. It should be in Capital letters.
gw_params-kind = 'S'. " P: if parameter, S: select-option
gw_params-sign = <selectio-option>-sign.
gw_params-option = <selectio-option>-option.
gw_params-low = <selectio-option>-low.
gw_params-high = <selectio-option>-high.
APPEND gw_params TO gt_params.
ENDLOOP.
" Continue with the other SELECT-OPTIONS in the same manner, if any.
" Call the copied program
SUBMIT <copied_stand_prg> AND RETURN
USER sy-uname
WITH SELECTION-TABLE gt_params.
" Import the result set
" make sure that the type of the tables match
IMPORT <result_table> TO gt_tabl FROM MEMORY ID 'RES_TABLE'.
" Now you can perform any operation on this table and display the result set in ALV grid
I hope you will find this useful...:)
Regards
s@k
‎2010 Feb 09 4:10 AM
Hi,
You can use Submit report as below:
SUBMIT rm07docs USING SELECTION-SET 'PLANT 4000'
WITH p_online = 'X'
TO SAP-SPOOL
SPOOL PARAMETERS %_print
WITHOUT SPOOL DYNPRO
AND RETURN.Then find out what the spool number is that was just created:
DATA: l_i_tsp01 TYPE STANDARD TABLE OF tsp01 WITH HEADER LINE .
DATA: l_c_rq2name LIKE tsp01-rq2name.
CONCATENATE report+0(8)
sy-uname+0(3)
INTO l_c_rq2name SEPARATED BY '_'.
SELECT * FROM tsp01 INTO TABLE l_i_tsp01 WHERE rq2name = l_c_rq2name.
SORT l_i_tsp01 BY rqcretime DESCENDING.
READ TABLE l_i_tsp01 INDEX 1.
v_spool_num = l_i_tsp01-rqident.
IF sy-subrc NE 0.
CLEAR v_spool_num.
ENDIF.Use FM 'RSPO_RETURN_ABAP_SPOOLJOB' to convert in into table.
TYPES: BEGIN OF ty_spool_output,
default(256) TYPE c,
END OF ty_spool_output,
ty_t_spool_output TYPE STANDARD TABLE OF ty_spool_output.
*-- INTERNAL TABLES
DATA :i_spool_output TYPE ty_t_spool_output,
wa_spool_output TYPE ty_spool_output.
CALL FUNCTION 'RSPO_RETURN_ABAP_SPOOLJOB'
EXPORTING
rqident = v_spool_num
TABLES
buffer = i_spool_output
EXCEPTIONS
no_such_job = 1
not_abap_list = 2
job_contains_no_data = 3
selection_empty = 4
no_permission = 5
can_not_access = 6
read_error = 7
OTHERS = 8.Then process this internal table and use it in your program.
Thanks,
Archana
‎2010 Feb 09 4:11 AM
Hi,
try this. for eg.
data: it_listobject1 LIKE abaplist OCCURS 1 WITH HEADER LINE,
it_ascii1 TYPE STANDARD TABLE OF ty_ascii WITH HEADER LINE,
SUBMIT rm07docs WITH werks EQ p_werks
WITH lifnr IN s_lifnr "select-option
....
EXPORTING LIST TO MEMORY
AND RETURN.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = it_listobject1.
CALL FUNCTION 'LIST_TO_ASCI'
TABLES
listasci = it_ascii1
listobject = it_listobject1.
LOOP AT it_ascii1 .
SEARCH it_ascii1-text FOR '-----' .
IF sy-subrc EQ 0.
DELETE it_ascii1.
CLEAR it_ascii1.
ENDIF.
ENDLOOP.
LOOP AT it_ascii1 .
g_count1 = g_count1 + 1.
IF g_count1 GT 2.
IF it_ascii1-text+61(4) EQ p_werks.
wa_it_stock-matnr = it_ascii1-text+1(18).
wa_it_stock-werks = it_ascii1-text+61(4).
l_matnr = wa_it_stock-matnr.
l_werks = wa_it_stock-werks.
ELSE.
wa_it_stock-matnr = l_matnr.
wa_it_stock-werks = l_werks.
wa_it_stock-bwart = it_ascii1-text+6(3).
wa_it_stock-mblnr = it_ascii1-text+12(10).
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' " adding leading zero
EXPORTING
input = wa_it_stock-matnr
IMPORTING
output = wa_it_stock-matnr.
APPEND wa_it_stock TO it_stock.
CLEAR wa_it_stock.
ENDIF.
ENDIF.
ENDLOOP.