Application Development and Automation 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: 
Read only

ALV problem (using CL_SALV_TABLE)

Former Member
0 Likes
1,834

I have created a dynamic table (<fs_it>) using CL_SALV_TABLE and try to display it as normal list.

And I have problems displaying the content as it gives me short dump. Further investigation, I found that it has something to do with report width limit (1023 characters only?).

Now, how can I display this dynamic table <fs_it> in a number of pages. For example, this <fs_it> table has 192 columns of 15char width, so I want to display the first 16 columns in page 1, the next 16 columns in page 2 and so on. In the end I should have 12 pages.

If I can't do this, please can you recommend alternative way? Thanks.

7 REPLIES 7
Read only

Former Member
0 Likes
1,670

Hi Waheeda ,

please check the blog of Poornanand Mandalika

/people/sap.user72/blog/2005/09/14/a-new-approach-to-alv-programming

I think you can display it only as Grid List types , you can not display as Classical ALV List with 192 columns as I know .

In the blog , you will see the code ..

If you do just as it does your problem will be solved i think.

CALL METHOD cl_salv_table=>factory

EXPORTING

list_display = if_salv_c_bool_sap=>false

IMPORTING

r_salv_table = gr_table

CHANGING

t_table = <newtab>.

Hope this helps

Caglar

Message was edited by:

A. Caglar Ozkor

Read only

0 Likes
1,670

Hi Caglar,

Thanks for your reply. Unfortunately, that is exactly the code that I did to display the dynamic table as a list. And unfortunately, again, it can't display all the 192 as I mentioned earlier.

Now, another approach is to display this table in X number of pages. Meaning, I will display the first 16 columns in page 1, column 17 - 32 in page 2, and so on. Is there a way to do this without having to revamp the whole program?

Read only

0 Likes
1,670

Hello Waheeda,

Sorry for the misunderstood , I should have read it correctly.

As an answer to your question , i think you can not do that without changing it.

best regards ,

Caglar

Message was edited by:

A. Caglar Ozkor

Read only

0 Likes
1,670

Hello Waheeda,

Sorry for the misunderstood , I should have read it correctly.

As an answer to your question , i think you can not do that without changing it.

best regards ,

Caglar

Message was edited by:

A. Caglar Ozkor

Read only

0 Likes
1,670

Hi Calgar,

It's okay. What I meant was - I don't want to revamp my whole program - probably just change the part where I display the dynamic table. Now, I need some ideas how to go about it (display a number of columns in pages) with the dynamic table that I have.

Say, the following code is the example. I now have <FS_IT> as the dynamic table and I want to display this in X number of pages (column 1 - 16 in page 1, column 17 - 32 in page 2 and so on). Please can you or anyone help? Thanks in advance.

<i>REPORT ZJP_TEST02_DYN_STRUCTURES.

TYPE-POOLS: ABAP.

TYPES: BEGIN OF COLTYPE,

FIELDNAME TYPE CHAR7,

FIELDOUTP TYPE CHAR8,

END OF COLTYPE.

DATA: IT_COLNAME TYPE STANDARD TABLE OF COLTYPE,

WA_COLNAME LIKE LINE OF IT_COLNAME,

CARRID TYPE SFLIGHT-CARRID,

CONNID TYPE SFLIGHT-CONNID.

DATA: IT_COMPONENT TYPE ABAP_COMPONENT_TAB,

WA_COMPONENT TYPE abap_componentdescr.

DATA: R_DATADESCR TYPE REF TO CL_ABAP_DATADESCR,

R_STRUCTDESCR TYPE REF TO CL_ABAP_STRUCTDESCR,

R_TABLEDESCR TYPE REF TO CL_ABAP_TABLEDESCR.

DATA: IT_SFLIGHT TYPE STANDARD TABLE OF SFLIGHT,

WA_SFLIGHT LIKE LINE OF IT_SFLIGHT.

DATA: FIELDNAME TYPE CHAR7.

DATA: IDX TYPE I.

DATA: REF_IT TYPE REF TO DATA,

REF_WA TYPE REF TO DATA.

FIELD-SYMBOLS: <FS_IT> TYPE STANDARD TABLE,

<FS_WA> TYPE ANY,

<FS_COMP> TYPE ANY.

DATA: R_TABLE TYPE REF TO CL_SALV_TABLE,

R_COLUMNS_TABLE TYPE REF TO CL_SALV_COLUMNS_TABLE,

R_COLUMN_TABLE TYPE REF TO CL_SALV_COLUMN_TABLE.

START-OF-SELECTION.

SELECT * FROM SFLIGHT INTO TABLE IT_SFLIGHT.

SELECT DISTINCT CARRID CONNID

FROM SFLIGHT

INTO (CARRID, CONNID).

CONCATENATE CARRID CONNID INTO WA_COLNAME-FIELDNAME.

CONCATENATE CARRID CONNID INTO WA_COLNAME-FIELDOUTP SEPARATED BY SPACE.

APPEND WA_COLNAME TO IT_COLNAME.

ENDSELECT.

R_DATADESCR ?= CL_ABAP_DATADESCR=>DESCRIBE_BY_DATA( FIELDNAME ).

WA_COMPONENT-NAME = 'DETAIL'.

WA_COMPONENT-TYPE = R_DATADESCR.

APPEND WA_COMPONENT TO IT_COMPONENT.

LOOP AT IT_COLNAME INTO WA_COLNAME.

WA_COMPONENT-NAME = WA_COLNAME-FIELDNAME.

WA_COMPONENT-TYPE = R_DATADESCR.

APPEND WA_COMPONENT TO IT_COMPONENT.

ENDLOOP.

TRY.

R_STRUCTDESCR = CL_ABAP_STRUCTDESCR=>CREATE(

P_COMPONENTS = IT_COMPONENT

  • P_STRICT = TRUE

).

CATCH CX_SY_STRUCT_CREATION .

WRITE: / 'CX_SY_STRUCT_CREATION ERROR'.

ENDTRY.

CREATE DATA REF_WA TYPE HANDLE R_STRUCTDESCR.

ASSIGN REF_WA->* TO <FS_WA>.

CREATE DATA REF_IT LIKE STANDARD TABLE OF <FS_WA>.

ASSIGN REF_IT->* TO <FS_IT>.

ASSIGN COMPONENT 1 OF STRUCTURE <FS_WA> TO <FS_COMP>.

<FS_COMP> = 'Count'.

LOOP AT IT_COLNAME INTO WA_COLNAME.

IDX = SY-TABIX.

ADD 1 TO IDX.

ASSIGN COMPONENT IDX OF STRUCTURE <FS_WA> TO <FS_COMP>.

<FS_COMP> = 10.

ENDLOOP.

APPEND <FS_WA> TO <FS_IT>.

CREATE DATA REF_WA TYPE HANDLE R_STRUCTDESCR.

ASSIGN REF_WA->* TO <FS_WA>.

ASSIGN COMPONENT 1 OF STRUCTURE <FS_WA> TO <FS_COMP>.

<FS_COMP> = 'Seats Max'.

LOOP AT IT_COLNAME INTO WA_COLNAME.

IDX = SY-TABIX.

ADD 1 TO IDX.

ASSIGN COMPONENT IDX OF STRUCTURE <FS_WA> TO <FS_COMP>.

<FS_COMP> = 1000.

ENDLOOP.

APPEND <FS_WA> TO <FS_IT>.

CREATE DATA REF_WA TYPE HANDLE R_STRUCTDESCR.

ASSIGN REF_WA->* TO <FS_WA>.

ASSIGN COMPONENT 1 OF STRUCTURE <FS_WA> TO <FS_COMP>.

<FS_COMP> = 'Seats Occ'.

LOOP AT IT_COLNAME INTO WA_COLNAME.

IDX = SY-TABIX.

ADD 1 TO IDX.

ASSIGN COMPONENT IDX OF STRUCTURE <FS_WA> TO <FS_COMP>.

<FS_COMP> = 800.

ENDLOOP.

APPEND <FS_WA> TO <FS_IT>.

  • TRY.

CL_SALV_TABLE=>FACTORY(

EXPORTING

LIST_DISPLAY = 'X'

  • R_CONTAINER =

  • CONTAINER_NAME =

IMPORTING

R_SALV_TABLE = R_TABLE

CHANGING

T_TABLE = <FS_IT>

).

  • CATCH CX_SALV_MSG .

  • ENDTRY.

PERFORM SET_COLUMN_NAMES.

R_TABLE->DISPLAY( ).

WRITE: / 'DONE'.

FORM SET_COLUMN_NAMES.

DATA: COLNAME TYPE LVC_FNAME.

DATA: OUTP TYPE SCRTEXT_S.

R_COLUMNS_TABLE = R_TABLE->GET_COLUMNS( ).

R_COLUMN_TABLE ?= R_COLUMNS_TABLE->GET_COLUMN( 'DETAIL' ).

R_COLUMN_TABLE->SET_SHORT_TEXT( 'Details' ).

LOOP AT IT_COLNAME INTO WA_COLNAME.

COLNAME = WA_COLNAME-FIELDNAME.

OUTP = WA_COLNAME-FIELDOUTP.

R_COLUMN_TABLE ?= R_COLUMNS_TABLE->GET_COLUMN( COLNAME ).

R_COLUMN_TABLE->SET_SHORT_TEXT( OUTP ).

ENDLOOP.

ENDFORM.</i>

Read only

0 Likes
1,670

Hi Waheeda ,

I' m not quite sure that this will work but may be it is an option to change cl_salv_table to Alv_block_list_append ...

( I know you want to achieve this with CL_SALV_TABLE

but i couldn' t find a solution ).

By this way you can split your Internal table into seperate tables i.e. : 12 itabs ( I know it is not so handy ) , and you can print them in seperate pages by changing the is_print options in the function module ,

May be this could give you an idea ;

<a href="/people/alvaro.tejadagalindo/blog/2006/11/27/dynamic-alv-list-display:///people/alvaro.tejadagalindo/blog/2006/11/27/dynamic-alv-list-display

hope this helps,

Kind regards ,

Caglar

Read only

0 Likes
1,670

Hi Caglar,

Thanks for the tips. It's very helpful to get some ideas (and now I know it can be done if there is any future needs). The only difference is, in that example, the number of columns is pretty much fixed, as well as the column names, whereas in my program, the number of columns varies and the column names are derived from a table.

Anyway, I have found another alternative to display it by pages - I break the big itab into a few internal tables (by using the # of lines of the itab and use do..enddo to capture col 1 - col n into a new smaller itab1, and have itab1to go through the same "process" - create_dynamic_table, fill_dynamic_table & display_dynamic_table. But the funny thing is, if you want to go to the next page, you have to click on the "Back" button - I'm trying to find out if there is other solution, but if you have any idea, please throw it here .

Now, I'm stuck with "how to print" this ALV, now that the client feels like they want to print the list. Any idea?