07-29-2014 12:44 PM
Hi Experts,
We want to call ME5J transaction code from a zprogram using Submit statement.
We used following code to call the report
SUBMIT RM06BKPS WITH TCNT-PROF_DB EQ '000000000001' WITH CN_PROJN IN PROJECT EXPORTING LIST TO MEMORY AND RETURN.
After using this statement we are getting output of the report. We don't need to display the result. We want to fetch data from above report using
CALL FUNCTION 'LIST_FROM_MEMORY'.
How to hide output display of ME5J?
Regards,
Sibin
08-05-2014 11:30 AM
Hello,
you can use the class cl_salv_bs_runtime_info=>get_data_ref to get the standard report output without displaying the ALV grid.
Check the Blog by glen simpson.
you would get the result in a type table declared and then do the Processing as per the requirement.
Sample code for same.
*&---------------------------------------------------------------------*
*& Report ZCALL_STANDARD*&*&---------------------------------------------------------------------**&*&*&---------------------------------------------------------------------*
REPORT zcall_standard.
TABLES : cdhdr.
PARAMETERS : udate TYPE sy-datlo DEFAULT sy-datlo OBLIGATORY,
udate_to TYPE sy-datlo DEFAULT sy-datlo OBLIGATORY,
utime_fr TYPE sy-timlo DEFAULT sy-timlo OBLIGATORY,
utime_to TYPE sy-timlo DEFAULT sy-timlo OBLIGATORY.SELECT-OPTIONS : user FOR cdhdr-username.
FIELD-SYMBOLS <lt_data> TYPE ANY TABLE.DATA: lr_data TYPE REF TO data,
ls_metadata TYPE cl_salv_bs_runtime_info=>s_type_metadata.DATA lr_data_descr TYPE REF TO cl_abap_datadescr.
DATA: r_alv_table TYPE REF TO cl_salv_table,
r_func TYPE REF TO cl_salv_functions.DATA: r_display TYPE REF TO cl_salv_display_settings.
DATA: r_columns TYPE REF TO cl_salv_columns.DATA: r_column TYPE REF TO cl_salv_column.
DATA: lr_events TYPE REF TO cl_salv_events_table,
lr_functions_list TYPE REF TO cl_salv_functions_list.
cl_salv_bs_runtime_info=>set(
EXPORTING display = abap_false
metadata = abap_true
data = abap_true ).
SUBMIT rsvtprot WITH cusobj = 'V_T001B'
WITH dbeg = udate* WITH tbeg = utime_fr
WITH dend = udate_to* WITH tend = utime_to
WITH users = user[]
WITH alv_grid = 'X' AND RETURN.
TRY.
cl_salv_bs_runtime_info=>get_data_ref(
IMPORTING r_data_descr = lr_data_descr ).
CREATE DATA lr_data TYPE HANDLE lr_data_descr.
ASSIGN lr_data->* TO <lt_data>.
cl_salv_bs_runtime_info=>get_data(
IMPORTING
t_data = <lt_data>
).
* TRY.
CALL METHOD cl_salv_bs_runtime_info=>get_metadata
RECEIVING
value = ls_metadata.* CATCH cx_salv_bs_sc_runtime_info .* ENDTRY.
CATCH cx_salv_bs_sc_runtime_info.
MESSAGE `Unable to retrieve ALV data` TYPE 'E'.
ENDTRY.
cl_salv_bs_runtime_info=>clear_all( ).
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = r_alv_table
CHANGING
t_table = <lt_data>.
CALL METHOD r_alv_table->get_functions
RECEIVING
value = r_func.
CALL METHOD r_func->set_all
EXPORTING
value = abap_true.
r_display = r_alv_table->get_display_settings( ).
r_display->set_striped_pattern( cl_salv_display_settings=>true ).
lr_functions_list = r_alv_table->get_functions( ).
r_columns = r_alv_table->get_columns( ).
r_columns->set_optimize( if_salv_c_bool_sap=>true ).
CALL METHOD r_alv_table->display.
07-29-2014 1:35 PM
I think when you use SUBMIT and RETURN, it executes all sequence of ABAP statements and then comes back. So part that is displaying the report o/p cannot be hidden.
An alternative but a tedious job - create a copy of ME5J and then call. May be you can debug ME5J and analysis which selects are giving outputs.
~Lokesh
07-29-2014 1:41 PM
Hi Lokesh,
We tried this for MM60 and the output was not displaying in ALV format. But for ME5J it is happening like this. We want to execute many reports in this zprogram and display it in a separate format. So copying these programs is not acceptable for us. Please provide an alternate solution.
Regards,
Sibin
07-29-2014 1:50 PM
Check if these tables have all enough data for your requirement:
PRPS - WBS (Work Breakdown Structure) Element Master Data
AUFK - Order master data
ACT01 - Activity for LDB 01
VBAP - Sales Document: Item Data
EBKN - Purchase Requisition Account Assignment
EBAN - Purchase Requisition
Select the fields and display in your requirement format.
07-29-2014 10:09 PM
Actually Database profile was not capturing from the below code
SUBMIT RM06BKPS WITH TCNT-PROF_DB EQ '000000000001' WITH CN_PROJN IN PROJECT EXPORTING LIST TO MEMORY AND RETURN.
When we execute above code, a popup with Enter profile is getting displayed. How to hide this popup?
Regards,
Sibin
07-29-2014 10:22 PM
Hello sibin,
You can hide Database Profile popup using:
LV_PROF_DB = '000000000001'.
SET PARAMETER ID 'PDB' value LV_PROF_DB.
I hope you help.
07-30-2014 9:57 AM
Hi Pau Gavino,
Thanks a lot for your valuable inputs. Now we can hide the profile and can extract values using
CALL FUNCTION 'LIST_FROM_MEMORY'
Using
SPLIT t_tab2-w_text AT '|' INTO
we are able to get values. But there are many columns and if we want to get value of a fixed column for eg: column 10, do we need to split values of all columns and get the value?
Regards,
Sibin
07-30-2014 11:54 AM
Hello sibin,
Implements the same logic that include FM06BF01_START
dumps the contents of memory ID 'ZYX' in a variable with the same structure BAN
You can handle as an internal table values.
I hope you help.
07-29-2014 1:49 PM
Hi Sibin,
Not sure if it would work, but what about using the SUBMIT command in background task and maybe a WAIT UP TO [n] SECONDS if needed? Wouldn't it solve your problem?
Cheers!
07-29-2014 10:56 PM
Hello sibin,
Report RM06BKPS search and export data to memory id 'ZYX.
Then call report RM06BL00 to print or display results.
This report IMPORT data from memory ID 'ZYX',
You can retrieve the results from memory id 'ZYX' and use in your report.
I hope you help.
08-05-2014 6:39 AM
Hi Pau Gavino,
I was able to call ME5J and ME2J transactions using submit statement. We also want to call S_ALR_87013558 report but by using Submit it is not working. How to call this tcode?
Regards,
Sibin
08-05-2014 7:12 AM
Hi Sibin,
you need to append the select-options or parameters in standard report structure
* Submit program to get the data from mb5b based on the plants and materials
rspar_line-selname = 'PA_NDSTO'.
rspar_line-kind = 'P'.
rspar_line-sign = 'I'.
rspar_line-option = 'EQ'.
rspar_line-low = 'X'.
APPEND rspar_line TO rspar_tab.
APPEND rspar_line TO rspar_tab1.
CLEAR: rspar_line.
* * Append start off with selection date into an internal table
* rspar_line-selname = 'SOBKZ'.
* rspar_line-kind = 'P'.
* rspar_line-sign = 'I'.
* rspar_line-option = 'EQ'.
* rspar_line-low = ' '.
* APPEND rspar_line TO rspar_tab.
* APPEND rspar_line TO rspar_tab1.
* CLEAR: rspar_line.
* Export flag to memory to get the list from mb5b
EXPORT flag2 TO MEMORY ID 'Z'.
* Submit program to get the data from mb5b based on the plants and materials
SUBMIT rm07mlbd WITH SELECTION-TABLE rspar_tab AND RETURN.
* Import the material and other details from mb5b
IMPORT it_table FROM MEMORY ID 'Z'.
* Delete the data from the memory
DELETE FROM MEMORY ID 'Z'.
DELETE FROM MEMORY ID 'Z'.
* Export flag to memory to get the list from mb5b
EXPORT flag3 TO MEMORY ID 'Z'.
* Submit program to get the data from mb5b based on the plants and materials
SUBMIT rm07mlbd WITH SELECTION-TABLE rspar_tab1 AND RETURN.
* Import the material and other details from mb5b
IMPORT it_table FROM MEMORY ID 'Z'.
* Delete the data from the memory
DELETE FROM MEMORY ID 'Z'.
DELETE FROM MEMORY ID 'Z'.
08-05-2014 7:40 AM
Hi Kabil,
We are getting
error messgae while using SUBMIT statement.
The program name is GPD5SK2B48KQAYJKJWAQFCPNXXK.
Regards,
Sibin
08-05-2014 9:19 AM
Hi Sibin,
if you want to call a transaction from wothin a program, why do you want to submit a program?
Use CALL TRANSACTION instead.
...
DATA: gt_bdcdata type standard table of bdcdata.
...
CALL TRANSACTION S_ALR_87013558
AND SKIP FIRST SCREEN using gt_bdcdata MODE 'N'.
...
where bdcdata holds the necessary values you want to pass to the transaction, MODE 'N' instructs the transaction to be called silent, that is, no dialogs will be invoked.
Regards - Jörg
08-05-2014 10:28 AM
Hi Jörg Wulf,
We want to run the SLR report using our zprogram and fetch details from this report to the called zprogram.
Regards,
Sibin
08-05-2014 11:27 AM
Hi Sibin,
in that case i'd suggest, you go to TA SE38, chose your program GPD5SK2B48KQAYJKJWAQFCPNXXK and try to run it. You will notice, that there are two additional parameters, that don't show when started by TA S_ALR_87013558.
One is labelled print, the other save. If none is checked, the mentioned error message occurrs.
So make sure, that you provide a value for either one when submitting.
Since i haven't tried what the output in each case would be, it's up to you to figure out, which suits your needs best.
BR - Jörg
08-05-2014 12:04 PM
Hi Jorg,
Thanks for your valuable inputs. We tried to run the report as per your suggestion. But the output is going to spool and the displayed data differs from S_ALR_87013558 report.Why this Print report option is getting displayed by running the program and not from the tcode? Can we hide these values?
Regards,
Sibin
08-06-2014 12:18 PM
Hi Jörg,
Now we are able to call the report but spool is getting generated and we couldn't get these values using LIST_FROM_MEMORY Fm. How to import these values?
Regards,
Sibin
08-06-2014 1:22 PM
Hi Sibin,
did you submit the report with the print option checked?
This will cause the report to generate a retrieveable list. And then there's parameter LISTART.
Depending on which output you need, you can set it to either 1 or 2 (3 will not be accepted)
08-06-2014 1:33 PM
Hi Jörg,
SUBMIT GPD5SK2B48KQAYJKJWAQFCPNXXK WITH CN_PROJN IN PROJECT WITH DRUCKEN eq 'X' WITH LISTART EQ '1' EXPORTING LIST TO MEMORY AND RETURN.
Here DRUCKEN EQ 'X" is the print option and LISTART EQ '1' is the list type.
Even after passing these values, we are not getting the desired data.
Regards,
Sibin
08-06-2014 5:48 PM
Hi Sibin,
i took a look on that report and it seems, that the parameter DRUCKEN forces the program to output to spool. That's why you don't get an imported list from memory.
Maybe, you should try to read the spool instead.
You could do like this:
DATA: l_rtime type RSLGTIM,
l_rqident type RSPOID.
...
concatenate sy-datum sy-uzeit into l_rtime.
* your submit here
SUBMIT GPD5SK2B48KQAYJKJWAQFCPNXXK WITH CN_PROJN IN PROJECT WITH DRUCKEN eq 'X' WITH LISTART EQ '1' EXPORTING LIST TO MEMORY AND RETURN.
...
* retreiving the spool ident number
select single rqident into l_rqident from TSP01
where RQOWNER = SY-UNAME
and RQ0NAME = 'LIST1S'
and RQ2NAME like 'GPD5SK2%'
and RQMODTIME ge l_rslgtime´
and RQDOCTYPE = 'LIST'.
* check sy-subrc eq 0.
* reading the spool into memory
submit rspolst2 exporting list to memory and return
with rqident = l_rqident
with first = 1.
...
continue with LIST_FROM_MEMORY
Not exactly the holy grail, but IMO as close as you can get.
BR - Jörg
08-07-2014 7:41 AM
Hi Jorg,
submit rspolst2 exporting list to memory and return
with rqident = l_rqident
with first = 1.
is taking so much time to execute. We want to call 2 such S_ALR reports along with 5 other tcodes.
Regards,
Sibin
08-07-2014 8:57 AM
Hi Jorg,
SUBMIT GPD5SK2B48KQAYJKJWAQFCPNXXK WITH CN_PROJN IN PROJECT WITH DRUCKEN eq 'X' WITH LISTART EQ '1' EXPORTING LIST TO MEMORY AND RETURN.
also resulting in more than 4000 pages into spool. But in SLR report using tcode, there is only 1 page. Also all pages will be printed using this submit. How to avoid this?
Regards,
Sibin
08-07-2014 9:47 AM
Hi Sibin,
in that case you might try to reduce the amount of transferred data (setting first and last) or you could
use FM RSPO_RETURN_BIN_DATA instead.
You'd have to feed the complete line of TSP01 as import parameter RQ and you'd receive a table of type RSPO_DSX which consists of an integer line index and a raw-data.
you have to implement something to make the raw data readable..
your code would then look more like this:
DATA: l_rtime type RSLGTIM,
l_rq type TSP01SYS.
data: lt_bind type standard table of RSPO_DSX,
ls_bind type RSPO_DSX,
l_xstr type xstring.
DATA: l_list type string,
lt_list type STANDARD TABLE OF string.
...
concatenate sy-datum sy-uzeit into l_rtime.
* your submit here
SUBMIT GPD5SK2B48KQAYJKJWAQFCPNXXK WITH CN_PROJN IN PROJECT WITH DRUCKEN eq 'X' WITH LISTART EQ '1' EXPORTING LIST TO MEMORY AND RETURN.
...
* retreiving the spool ident number
select single * into l_rq from TSP01
where RQOWNER = SY-UNAME
and RQ0NAME = 'LIST1S'
and RQ2NAME like 'GPD5SK2%'
and RQMODTIME ge l_rslgtime´
and RQDOCTYPE = 'LIST'.
* check sy-subrc eq 0.
CALL FUNCTION 'RSPO_RETURN_BIN_DATA'
EXPORTING
rq = l_rq
tables
bindata = lt_bind.
loop at lt_bind into ls_bind.
l_xstr = ls_bind-data_line.
* make the raw data readable
CALL FUNCTION 'NLS_STRING_CONVERT_TO_SYS'
EXPORTING
lang_used = 'E' "<put your language here>
source = l_xstr
IMPORTING
RESULT = l_list.
append l_list to lt_list.
endloop.
...
Be aware, that this list might look different from what you would epect, since it might contain formatting, column separators etc.
Probably it'd be best if you analyse a sample spool output before and decide, which parts of it you'll need.
BR - Jörg
08-14-2014 6:54 AM
Hi Jorg,
It is taking so muh time to execute from spool. Is there any other turn around? There is an option Rebuild frozen report data. If we select it and execute the report, we are getting
How to fetch this result? It is generating in background.
Regards,
Sibin
08-05-2014 11:30 AM
Hello,
you can use the class cl_salv_bs_runtime_info=>get_data_ref to get the standard report output without displaying the ALV grid.
Check the Blog by glen simpson.
you would get the result in a type table declared and then do the Processing as per the requirement.
Sample code for same.
*&---------------------------------------------------------------------*
*& Report ZCALL_STANDARD*&*&---------------------------------------------------------------------**&*&*&---------------------------------------------------------------------*
REPORT zcall_standard.
TABLES : cdhdr.
PARAMETERS : udate TYPE sy-datlo DEFAULT sy-datlo OBLIGATORY,
udate_to TYPE sy-datlo DEFAULT sy-datlo OBLIGATORY,
utime_fr TYPE sy-timlo DEFAULT sy-timlo OBLIGATORY,
utime_to TYPE sy-timlo DEFAULT sy-timlo OBLIGATORY.SELECT-OPTIONS : user FOR cdhdr-username.
FIELD-SYMBOLS <lt_data> TYPE ANY TABLE.DATA: lr_data TYPE REF TO data,
ls_metadata TYPE cl_salv_bs_runtime_info=>s_type_metadata.DATA lr_data_descr TYPE REF TO cl_abap_datadescr.
DATA: r_alv_table TYPE REF TO cl_salv_table,
r_func TYPE REF TO cl_salv_functions.DATA: r_display TYPE REF TO cl_salv_display_settings.
DATA: r_columns TYPE REF TO cl_salv_columns.DATA: r_column TYPE REF TO cl_salv_column.
DATA: lr_events TYPE REF TO cl_salv_events_table,
lr_functions_list TYPE REF TO cl_salv_functions_list.
cl_salv_bs_runtime_info=>set(
EXPORTING display = abap_false
metadata = abap_true
data = abap_true ).
SUBMIT rsvtprot WITH cusobj = 'V_T001B'
WITH dbeg = udate* WITH tbeg = utime_fr
WITH dend = udate_to* WITH tend = utime_to
WITH users = user[]
WITH alv_grid = 'X' AND RETURN.
TRY.
cl_salv_bs_runtime_info=>get_data_ref(
IMPORTING r_data_descr = lr_data_descr ).
CREATE DATA lr_data TYPE HANDLE lr_data_descr.
ASSIGN lr_data->* TO <lt_data>.
cl_salv_bs_runtime_info=>get_data(
IMPORTING
t_data = <lt_data>
).
* TRY.
CALL METHOD cl_salv_bs_runtime_info=>get_metadata
RECEIVING
value = ls_metadata.* CATCH cx_salv_bs_sc_runtime_info .* ENDTRY.
CATCH cx_salv_bs_sc_runtime_info.
MESSAGE `Unable to retrieve ALV data` TYPE 'E'.
ENDTRY.
cl_salv_bs_runtime_info=>clear_all( ).
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = r_alv_table
CHANGING
t_table = <lt_data>.
CALL METHOD r_alv_table->get_functions
RECEIVING
value = r_func.
CALL METHOD r_func->set_all
EXPORTING
value = abap_true.
r_display = r_alv_table->get_display_settings( ).
r_display->set_striped_pattern( cl_salv_display_settings=>true ).
lr_functions_list = r_alv_table->get_functions( ).
r_columns = r_alv_table->get_columns( ).
r_columns->set_optimize( if_salv_c_bool_sap=>true ).
CALL METHOD r_alv_table->display.