07-03-2013 8:15 AM
I have a requirement where the user will be selecting a variant for a report before executing. This report has output as ALV and mail.
Right now ALV is considering the varaint selected and is preparing the layout based on the variant (I am using 'REUSE_ALV_GRID_DISPLAY' for ALV display). The same needs to be done for mail also.
So I want to capture this variant layout so that I can prepare an internal table which i will send as an excel attachment in the mail.
07-04-2013 6:31 AM
Hi Umesh,
Variant details are stores in LTDX table you can check it by se16.
By passing RELID = 'LT',
REPORT = 'Report Name'
and other details which are relevant for your variant, ask your functional member.
Once you get the variant details pass it to FM 'LT_DBDATA_READ_FROM_LTDX'. FM will return the field layout set for the variant.
DATA: WA_LTDX TYPE LTDX,
V_VARKEY TYPE LTDXKEY,
IT_FCAT TYPE STANDARD TABLE OF LTDXDATA,
IT_SORT_INFO TYPE STANDARD TABLE OF LTDXDATA,
IT_FILTER TYPE STANDARD TABLE OF LTDXDATA.
CONSTANTS: C_RELID TYPE LTDX-RELID VALUE 'LT'.
SELECT SINGLE * FROM LTDX INTO WA_LTDX
WHERE RELID = C_RELID
AND REPORT = P_IV_PROG_NAME
* AND VARIANT = V_VARIANT.
IF SY-SUBRC = 0.
MOVE-CORRESPONDING WA_LTDX TO V_VARKEY.
* will get the layout fields
CALL FUNCTION 'LT_DBDATA_READ_FROM_LTDX'
EXPORTING
I_TOOL = C_RELID
IS_VARKEY = V_VARKEY
TABLES
T_DBFIELDCAT = IT_FCAT " To create Field Catalog
T_DBSORTINFO = IT_SORT_INFO " Sort category set
T_DBFILTER = IT_FILTER " Filter category set
.
In debugger mode check internal table IT_FCAT for any additional Manipulation and create internal table for Field catalog.
ENDIF.
After doing so use the above field catalog table to prepare report output to send via email. In this way you can get the report output in selected layout format .
Hope so this might help you.
Regards,
M Nair
07-03-2013 6:09 PM
Hi,
You can check sy-variant in your program and get the variant contents using FM RS_VARIANT_CONTENTS.
07-03-2013 7:59 PM
I would say, it would be difficult to "apply" all the settings - columns, subtotals, sorting, filters, layout settings - from the saved display variants over your internal table data.
Best way to achieve, what you are looking for is:
Regards,
Naimesh Patel
07-04-2013 6:31 AM
Hi Umesh,
Variant details are stores in LTDX table you can check it by se16.
By passing RELID = 'LT',
REPORT = 'Report Name'
and other details which are relevant for your variant, ask your functional member.
Once you get the variant details pass it to FM 'LT_DBDATA_READ_FROM_LTDX'. FM will return the field layout set for the variant.
DATA: WA_LTDX TYPE LTDX,
V_VARKEY TYPE LTDXKEY,
IT_FCAT TYPE STANDARD TABLE OF LTDXDATA,
IT_SORT_INFO TYPE STANDARD TABLE OF LTDXDATA,
IT_FILTER TYPE STANDARD TABLE OF LTDXDATA.
CONSTANTS: C_RELID TYPE LTDX-RELID VALUE 'LT'.
SELECT SINGLE * FROM LTDX INTO WA_LTDX
WHERE RELID = C_RELID
AND REPORT = P_IV_PROG_NAME
* AND VARIANT = V_VARIANT.
IF SY-SUBRC = 0.
MOVE-CORRESPONDING WA_LTDX TO V_VARKEY.
* will get the layout fields
CALL FUNCTION 'LT_DBDATA_READ_FROM_LTDX'
EXPORTING
I_TOOL = C_RELID
IS_VARKEY = V_VARKEY
TABLES
T_DBFIELDCAT = IT_FCAT " To create Field Catalog
T_DBSORTINFO = IT_SORT_INFO " Sort category set
T_DBFILTER = IT_FILTER " Filter category set
.
In debugger mode check internal table IT_FCAT for any additional Manipulation and create internal table for Field catalog.
ENDIF.
After doing so use the above field catalog table to prepare report output to send via email. In this way you can get the report output in selected layout format .
Hope so this might help you.
Regards,
M Nair
07-14-2013 8:18 AM
Thanks all for your response and special thanks to Manikandan D Nair.
12-30-2015 1:52 PM
Can you share you code... how you can achive all those thing...
Please help me...
Thanks,
Satya