2006 Jun 07 2:17 PM
Hi guys,
Does anyone know how to copy ALV layouts between programs in the same client? I have created a copy of a report which uses the ALV functionality via the REUSE_* function modules. The original report has over 40 layouts, so I don't want to have to re-create them manually in the new program. These programs are in the same client on the same system, so the Import Layout and Transport Layout options aren't going to be of any use (as far as I can see...)
Any ideas greatly appreciated.
Cheers,
Andrew
2006 Jun 07 2:27 PM
hii Andrew
First call <b>LVC_VARIANT_SELECT</b> to read variant from the first program and
then call <b>LVC_VARIANT_SAVE</b> to save it for the second program.
check this demo program for more info
<b>BCALV_GRID_11</b>
Regards
Naresh
Hi guys,
Does anyone know how to copy ALV layouts between programs in the same client? I have created a copy of a report which uses the ALV functionality via the REUSE_* function modules. The original report has over 40 layouts, so I don't want to have to re-create them manually in the new program. These programs are in the same client on the same system, so the Import Layout and Transport Layout options aren't going to be of any use (as far as I can see...)
Any ideas greatly appreciated.
Cheers,
Andrew
2006 Jun 07 2:25 PM
2006 Jun 07 2:27 PM
Hi Andrew,
you can do like this..
instead of sy-repid
G_VARIANT-REPORT = sy-REPID.
use this..
repid = 'the program which is having 40 variants'.
G_VARIANT-REPORT = repid .
and but when you create new one then the new variant also saves under the original program(having 40 layouts)
i hope you got it.
Regards
vijay
2006 Jun 07 2:41 PM
Thanks Vijay. This will certainly help in the short term, but as you correctly point out, this will just make my new program work with the old program's variants, and any changes I make will also affect the old program.
I'm still looking for a way to copy the display variants/layouts from one program to the other so they each have their own.
2006 Jun 07 2:27 PM
hii Andrew
First call <b>LVC_VARIANT_SELECT</b> to read variant from the first program and
then call <b>LVC_VARIANT_SAVE</b> to save it for the second program.
check this demo program for more info
<b>BCALV_GRID_11</b>
Regards
Naresh
2007 May 04 9:34 PM
I took this approach and it worked for me:
1) Change your program so that everytime an ALV function is called it is using the original program name in the variant declaration, ensure you keep the original code commented out, you will need to put it back later. Examples:
FORM variant_init USING varname TYPE slis_vari.
CLEAR g_variant.
g_variant-report = g_repid.
g_variant-report = 'ORIGINAL_PROGRAM_NAME'.
FORM f4_for_variant.
g_variant-report = sy-repid.
g_variant-report = ORIGINAL_PROGRAM_NAME.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
FORM check_variant.
IF NOT p_vari IS INITIAL.
g_variant-report = sy-repid.
g_variant-report = ORIGINAL_PROGRAM_NAME.
g_variant-variant = p_vari.
CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
2) Display function lt_variant_save via SE37, set a breakpoint at the first executable line:
perform variant_save tables it_fieldcat
4) Run your program with the layout variant you wish to copy.
5) Hit Save Variant. You are now in debug mode.
6) Enter variable CS_VARIANT-REPORT in the variables 1 panel.
7) Double-click on CS_VARIANT-REPORT.
😎 Hit the Change Field Content button
9) Change the value to the name of your new program, then hit Enter.
10) Hit Execute (F8). You have now saved the variant under your new program name.
11) Exit and rerun your program as necessary for as many variants as you want to copy
12) Change your program back to using sy-repid (or whatever else it was referencing) wherever you changed it in step 1.
13) The variants have now been copied and you can run your program with the new variants.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |