‎2012 Jan 20 12:11 PM
Hi,
I searched many blogs and the SDN forum but couldn't find a solution.
I need to know the layout fields of an ALV report for a later usage. Let me explain it with code:
I used below code to extract data of a dynamic program.
cl_salv_bs_runtime_info=>set(
EXPORTING display = abap_false
metadata = abap_true
data = abap_true ).
Submit (program) USING SELECTION-SET variant EXPORTING LIST TO MEMORY
AND RETURN.
TRY.
cl_salv_bs_runtime_info=>get_data_ref(
IMPORTING r_data = lf_ref ).
ASSIGN lf_ref->* TO <lt_data>.
CATCH cx_salv_bs_sc_runtime_info.
MESSAGE `Unable to retrieve ALV data` TYPE 'E'.
ENDTRY.
cl_salv_bs_runtime_info=>clear_all( ).
CREATE DATA lf_ref1 LIKE LINE OF <lt_data>.
ASSIGN lf_ref1->* TO <lt_line>.What I need is to submit program with a (known) layout. If it is not possible, how can i modify the ALV report to fit a layout's display properties. (If I can manage to get -dynamic program- layout's visible fields, it will work too.)
Thank you.
‎2012 Jan 23 6:39 AM
Hello guys,
Thanks for your answers but it doesn't help unfortunately. Table LTDX stores the details of a layout like user id, last change data etc.
What I need is the table header properties (visible or not).
I took your suggestion and debugged a program which takes layout variant as parameter. (Program name is RFITEMAP). In this program, ABAP takes pa_vari parameter and send it to ALV layout as gs_variant-variant. The reason that I can't use it in my program is the dynamic variant and dynamic submitted program. I mean I can't send variant name to a submitted program as parameter as long as I can't know its name in that program.
Also spooling doesn't work for my situation.
Any other ideas?
‎2012 Jan 20 2:15 PM
hello
the layout fields is
alv_variant-variant,
where
DATA: alv_variant LIKE disvariant.
Regards
R
‎2012 Jan 20 2:18 PM
Hi,
Your questions seems to be a little unclear. can you explain a little more?
Let me try if i understood it correctly: You are trying to call a program in you code dynamically and and you want to pass the layout name to that program?
Thanks,
Venkatesh.
‎2012 Jan 20 2:20 PM
hello
you can submit a report that contain an ALV and when submit it you can pass the layout as a parameters.
The field that I mentioned contain the layout.
‎2012 Jan 20 2:25 PM
hello venkatesh333,
In general, I am creating a program, which submit another program (with dynamic name and variant) and get its output tables (in a saved layout) to send as a mail in EXCEL format. Shortly, I am copying the "send mail as xls attachment" function of the alv report. The difference is that my program does it automatically. For example, people from MM can send a (xls) mail to a end user everyday with same program, same variant and same layout. I hope it is more clear.
‎2012 Jan 20 2:28 PM
Hello Roberto,
My submitted report is dynamic so I can't know the name of the layout field (alv_variant) before run-time. Does this name generic for all ALV reports? If so, this may work.
Edit: We cant impose other program to use alv_variant-variant as parameter. Also, other program may use own definitions for this parameter.
Edited by: kerimmkilic on Jan 20, 2012 3:39 PM
‎2012 Jan 20 7:52 PM
can you try sending spool data as email, rather trying to get the layout dynamically and then trying to send th email.
‎2012 Jan 20 8:32 PM
Table LTDX seems to store ALV variants. If that helps any. I would debug an ALV report with a variant specified to find a FM or select that retrieves the rest of the layout data.
‎2012 Jan 20 8:50 PM
Hi,
>
> I searched many blogs and the SDN forum but couldn't find a solution.
>
> I need to know the layout fields of an ALV report for a later usage. Let me explain it with code:
>
> I used below code to extract data of a dynamic program.
>
>
cl_salv_bs_runtime_info=>set( > EXPORTING display = abap_false > metadata = abap_true > data = abap_true ). > Submit (program) USING SELECTION-SET variant EXPORTING LIST TO MEMORY > AND RETURN. > TRY. > cl_salv_bs_runtime_info=>get_data_ref( > IMPORTING r_data = lf_ref ). > ASSIGN lf_ref->* TO <lt_data>. > CATCH cx_salv_bs_sc_runtime_info. > MESSAGE `Unable to retrieve ALV data` TYPE 'E'. > ENDTRY. > cl_salv_bs_runtime_info=>clear_all( ). > CREATE DATA lf_ref1 LIKE LINE OF <lt_data>. > ASSIGN lf_ref1->* TO <lt_line>.>
> What I need is to submit program with a (known) layout. If it is not possible, how can i modify the ALV report to fit a layout's display properties. (If I can manage to get -dynamic program- layout's visible fields, it will work too.)
>
> Thank you.
You can read the metadata of an ALV layout using the FM LT_DBDATA_READ_FROM_LTDX, the type of variant should be 'F'.
-Rajesh.
‎2012 Jan 23 6:39 AM
Hello guys,
Thanks for your answers but it doesn't help unfortunately. Table LTDX stores the details of a layout like user id, last change data etc.
What I need is the table header properties (visible or not).
I took your suggestion and debugged a program which takes layout variant as parameter. (Program name is RFITEMAP). In this program, ABAP takes pa_vari parameter and send it to ALV layout as gs_variant-variant. The reason that I can't use it in my program is the dynamic variant and dynamic submitted program. I mean I can't send variant name to a submitted program as parameter as long as I can't know its name in that program.
Also spooling doesn't work for my situation.
Any other ideas?
‎2012 Jan 23 6:51 AM
Hi ,
Check this LINK you can take help from this
create dynamic varient and pass to Submit program .
OR :
you can use function module to get layout names and reprot
ranges: lr_report for ltdx-report,
lr_handle for ltdx-handle,
lr_log_group for ltdx-log_group,
lr_username for ltdx-username,
lr_variant for ltdx-variant,
lr_type for ltdx-type.
call function 'LT_VARIANTS_READ_FROM_LTDX'
exporting
i_tool = r_tool
i_text = r_text
tables
et_variants = rt_variants
it_ra_report = lr_report
it_ra_handle = lr_handle
it_ra_log_group = lr_log_group
it_ra_username = lr_username
it_ra_variant = lr_variant
it_ra_type = lr_type
exceptions
not_found = 1
others = 2.regards
Deepak.
Edited by: Deepak Dhamat on Jan 23, 2012 8:18 AM
‎2012 Jan 24 5:20 AM
Table LTDX stores the details of a layout like user id, last change data etc.
> What I need is the table header properties (visible or not).
Well, the db table LTDX also stores the metadata of the ALV layout in the field LTDX-CLUSTD in compressed format, you may read its contents using the FM LT_DBDATA_READ_FROM_LTDX.
What I need is to submit program with a (known) layout. If it is not possible,
how can i modify the ALV report to fit a layout's display properties.
(If I can manage to get -dynamic program- layout's visible fields, it will work too.)
From your previous post, it is understood/assumed that, you very well know the name of the ALV layout of the dynamic program that needs to be submitted, if this understanding/assumption is correct, you can care less about the layout with which the ALV of the submitted program is displayed, as you can read back the complete contents(all the columns) of the internal table using the data reference returned by the method GET_DATA_REF( ), now you just have to apply the metadata read back from the FM LT_DBDATA_READ_FROM_LTDX to the contents returned from the method GET_DATA_REF( ), however, for any reason you wish to read the metadata with which the submitted program has displayed the ALV, you can use the method cl_salv_bs_runtime_info=>get_metadata( ).
-Rajesh.
‎2012 Jan 24 6:58 AM
Hello Rajesh,
Your answer is very helpful. My solution lays beyond FM LT_DBDATA_READ_FROM_LTDX. However, I couldn't manage to read LTDX-CLUSTD. I used it like this:
data: rt_variants like STANDARD TABLE OF LTDXDATA,
lr_report like STANDARD TABLE OF LTDXDATA,
lr_handle like STANDARD TABLE OF LTDXDATA,
lr_log_group like standard table of LTDXDATA,
is_varkey type STANDARD TABLE OF LTDXKEY with header line.
is_varkey-report = program. "working program name.
is_varkey-variant = layout. "working saved layout name.
is_varkey-type = 'F'. "no idea about it.
append is_varkey.
call function 'LT_DBDATA_READ_FROM_LTDX'
exporting
* i_tool = "optional. do i really need to input something here?
is_varkey = is_varkey
tables
t_dbfieldcat = rt_variants
* t_dbsortinfo = lr_report
* t_dbfilter = lr_handle
t_dblayout = lr_log_group
exceptions
not_found = 1
others = 2.Can you tell me how to use this funciton or show an example usage? And how can I find LTDX-CLUSTD in these tables?
Thank you.
Edit: Many Thanks Rajesh. At last, I solved the problem.
Edited by: kerimmkilic on Jan 24, 2012 8:51 AM
‎2012 Jan 24 2:50 PM
Hi,
glad that the answer was helpful, hope you had success in retrieving the layout info from the FM, make sure that you are populating the 'USERNAME' field, if your ALV layout is user specific(and if the report name/username/layout/type combination doesn't uniquely identify the ALV layout, you may have to transfer additioanal parameters)...and if you are displaying hierarchial ALVs you may have to transfer the value 'HI' to the importing parameter I_TOOL of the FM and for displaying normal ALVs the default value 'LT' of the parameter would suffice...
-Rajesh.
‎2012 Jan 24 2:56 PM
Thanks again for additional useful info Rajesh.
The solution is perfectly working. I am just transferring program name, variant, layout and mail details in my main program and it sends mails with excel attachment of the alv report of the related program. I have some formatting issues that need to be solved but I can figure it out from now on.
See you around.
‎2012 Jan 23 8:36 AM
hi,
From your question what I understood is that you are just submitting a program with a name ( dynamic ) & you need the layout used for display. Here as you are not passing any variant name to the program , you will be able to get the details of the default layout using the function LVC_VARIANT_SELECT. Please note that you have opened several threads related to the same question, try to close it.