Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to retrieve layout variant selected in the report selection screen so that same can be send as an attachment in mail

umesh_nailwal
Discoverer
0 Kudos

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.

1 ACCEPTED SOLUTION

former_member216769
Participant
0 Kudos

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

5 REPLIES 5

satyajit_mohapatra
Active Contributor
0 Kudos

Hi,

You can check sy-variant in your program and get the variant contents using FM RS_VARIANT_CONTENTS.

naimesh_patel
Active Contributor
0 Kudos

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:

  • Submit your ALV with Display variant to generate a Spool. This way all the settings from the display variants are captured in your output.
  • Convert the Spool to PDF
  • Attach the PDF to your email

Regards,
Naimesh Patel

former_member216769
Participant
0 Kudos

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

0 Kudos

Thanks all for your response and special thanks to Manikandan D Nair.

0 Kudos

Can you share you code... how you can achive all those thing...

Please help me...

Thanks,

Satya