2006 May 17 5:05 PM
Hi,
in my report i´ve got a dynpro and within this dynpro i´ve got two custom containers. Each container displays an ALV.
In the first container i have no standard toolbar.
In the second container i´ve got the standard toolbar with print button.
What i want is that when i click on this print button i get as output a list containing the content of both ALV´s.
Is this possible?
Am i wrong trying to print the whole content of the dynpro in this way?
Best regards.
2006 May 18 3:23 PM
Hi,
in my system 4.7 i don´t have package SALV.
is this the reason for the message ("The type CL_SALV_TABLE is inknown")?
What do i need to do in order to get it?
Best regards.
2006 May 17 5:23 PM
2006 May 17 5:34 PM
Hi,
If you want to use the new version of building ALV output via class CL_SALV* you can try this:
I used 4 ALV in custom containers on the screen.
I call a subroutine for every ALV to be printed by passing the content of the internal table for the ALVs and the structure name to a subroutine:
new-page print on parameters G_S_PRINT_PARAMETERS no dialog.
perform PRINT_ALV using G_T_TOPDEF_P 'ZPES_ALV_TOP_DEFECTS'.
perform PRINT_ALV using G_T_TOPDEF_A 'ZPES_ALV_TOP_DEFECTS'.
perform PRINT_ALV using G_T_TOPDEF_F 'ZPES_ALV_TOP_DEFECTS'.
perform PRINT_ALV using G_T_TOPDEF_T 'ZPES_ALV_TOP_DEFECTS'.
new-page print off.
...
*&---------------------------------------------------------------------*
*& Form PRINT_ALV
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_T_REVIEW_ITEM text
*----------------------------------------------------------------------*
form PRINT_ALV using P_T_REVIEW_ITEM P_TABNAME.
field-symbols : <L_T_NEW> type TABLE.
data: L_T_DYNTAB type standard table of DNTAB,
L_S_DYNTAB type DNTAB,
DREF type ref to DATA,
L_T_FCAT type LVC_T_FCAT,
L_S_FCAT type LVC_S_FCAT,
L_TABNAME type DDOBJNAME,
L_O_T_SALV type ref to CL_SALV_TABLE,
L_O_LINETYPE type ref to CL_ABAP_STRUCTDESCR,
L_O_T_TABLETYPE type ref to CL_ABAP_TABLEDESCR,
L_O_PRINT type ref to CL_SALV_PRINT.
L_TABNAME = P_TABNAME.
L_O_LINETYPE ?= CL_ABAP_TYPEDESCR=>DESCRIBE_BY_NAME( L_TABNAME ).
L_O_T_TABLETYPE = CL_ABAP_TABLEDESCR=>CREATE(
P_LINE_TYPE = L_O_LINETYPE
P_TABLE_KIND = CL_ABAP_TABLEDESCR=>TABLEKIND_STD ).
create data DREF type handle L_O_T_TABLETYPE.
assign DREF->* to <L_T_NEW>.
<L_T_NEW> = P_T_REVIEW_ITEM.
try.
call method CL_SALV_TABLE=>FACTORY
exporting
LIST_DISPLAY = ABAP_TRUE
importing
R_SALV_TABLE = L_O_T_SALV
changing
T_TABLE = <L_T_NEW>.
catch CX_SALV_MSG.
endtry.
* DO NOT enable - prompts for printer selection!!!
* L_O_PRINT = L_O_T_SALV->GET_PRINT( ).
* L_O_PRINT->SET_PRINT_ONLY( IF_SALV_C_BOOL_SAP=>TRUE ).
L_O_T_SALV->DISPLAY( ).
endform. " PRINT_ALV
Let me know whether this helps...
Thanks,
Guenther
2006 May 18 10:20 AM
Hi,
thanks for your answers but i don´t get the idea.
1.- if i use REUSE_ALV_BLOCK_LIST_INIT etc, How and where i´m i supposed to use them.
2.- if i use Guenther´s solution, How and where do i declare class CL_ALV_PRINT and all the rest?
Best regards.
2006 May 18 1:34 PM
Hi again,
<u>Answer to 1)</u>
First of all, you have to be aware that none of those fm is actually released by SAP (see the function module documentation).
I tested it by calling REUSE_ALV_BLOCK_LIST_INIT at the beginning of PBO and then call REUSE_ALV_BLOCK_LIST_APPEND for every ALV I build in a subroutine. REUSE_ALV_BLOCK_LIST_DISPLAY is then called in my PAI in case the print button was pushed. As I mentioned, I got it to work - it prints all the individual ALVs (in my case 4) - but there was still a slight problem since it always printed the content of last ALV; maybe this is because all my ALVs share the same layout, field catalog etc. I didn't really spend a lot of time to investigate since I decided to go for the CL_SALV approach anyway...
<u>Answer to 2)</u>
Well, you should have everything you need already declared and defined in the subroutine itself.
I just wrote a little shell program to call the form:
*&---------------------------------------------------------------------*
*& Report ZZ_GHS_TEST_01
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
report ZZ_GHS_TEST_02 message-id ZPES.
data: G_T_SFLIGHT type table of SFLIGHT,
G_S_PRINT_PARAMETERS type PRI_PARAMS.
start-of-selection.
select * from SFLIGHT into table G_T_SFLIGHT up to 10 rows.
*
call function 'GET_PRINT_PARAMETERS'
exporting
DESTINATION = 'LOCL'
MODE = 'CURRENT'
* NO_DIALOG = 'X'
importing
OUT_PARAMETERS = G_S_PRINT_PARAMETERS
* VALID = L_VALID
exceptions
ARCHIVE_INFO_NOT_FOUND = 1
INVALID_PRINT_PARAMS = 2
INVALID_ARCHIVE_PARAMS = 3
others = 4.
if SY-SUBRC <> 0.
* BREAK .
endif.
new-page print on parameters G_S_PRINT_PARAMETERS no dialog.
perform PRINT_ALV using G_T_SFLIGHT 'SFLIGHT'.
new-page print off.
leave program.
Works just fine...
You can also check:
/people/sap.user72/blog/2005/09/14/a-new-approach-to-alv-programming
for a blog on the new ALV approach.
Hope this helps!
Guenther
2006 May 18 2:18 PM
Hi Guenther,
when i try to activate your sample code i get message:
<u>"The type CL_SALV_TABLE" is unknown".</u>have i missed something?
Best regards
2006 May 18 3:23 PM
Hi,
in my system 4.7 i don´t have package SALV.
is this the reason for the message ("The type CL_SALV_TABLE is inknown")?
What do i need to do in order to get it?
Best regards.
2006 May 18 4:32 PM
You have to be on Basis 6.40 in order to use this approach.
I am pretty sure though that the "new-page print on..." logic will work with the < 6.40 ABAP OO version as well.
Use CL_GUI_ALV_GRID and method SET_TABLE_FOR_FIRST_DISPLAY and populate parameter IS_PRINT accordingly.
Cheers,
Guenther