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

problem in ALV_BLOCK_LIST_APPEND

SwarnaliBasu
Participant
0 Likes
2,221

HI

i am using ALV_BLOCK_LIST_APPEND, in that the fieldcatalog has fileds as

f1 f1 f3

and the itab which is paased in the ALV

contains values as

f1 f2 f3

1 2 3

4 5 6

but during the display the o/p is coming as header

f1 f2 f3

the corrosponding values are not shown

please help

23 REPLIES 23
Read only

Former Member
0 Likes
2,192

Hi ,

The values are not geting transferred from the internal table .

Can you paste your code so that the error can be detected.

Else you can debug your program and see why the values are not getting transferred to the internal table .

you can also refer to the Alvaro's blog on List display.....

/people/alvaro.tejadagalindo/blog/2006/11/27/dynamic-alv-list-display

Hope this helps you .

Thanks and Regards

Aditi Wason

Read only

0 Likes
2,192

HI

as i have said there is no problem in the internal table , in the internal table infact the values are correctly populated, but its not coming in display, so cant understand the issue

Read only

0 Likes
2,192

can you paste your code so that we can identify the problem

Read only

0 Likes
2,192

HI

i have pasted my code can u plz check now?

Read only

0 Likes
2,192

Hi,

take the sample code... its tested and is working perfectly fine.... you can use this example in your code solve your issue... it replicates your issue to some extent...

TYPE-POOLS : slis.

DATA : BEGIN OF wg_field_form,
          field1 TYPE char30,
          field2 TYPE char30,
          field3 TYPE char30,
        END OF wg_field_form.
DATA i_field_form LIKE TABLE OF wg_field_form.
DATA wa_print TYPE slis_print_alv.
DATA : wa_fieldcat1_slis TYPE slis_fieldcat_alv.
DATA : lt_fieldcat1_slis TYPE slis_t_fieldcat_alv.
DATA ls_layout TYPE slis_layout_alv.
DATA t_events TYPE slis_t_event.

DO 10 TIMES.
  wg_field_form-field1 = sy-index.
  wg_field_form-field2 = 2 * sy-index.
  wg_field_form-field3 = 3 * sy-index.
  APPEND wg_field_form to i_field_form.
ENDDO.

wa_fieldcat1_slis-col_pos = '1'.
wa_fieldcat1_slis-fieldname = 'FIELD1'.
wa_fieldcat1_slis-tabname = 'I_field_form'.
wa_fieldcat1_slis-seltext_l = 'FIELD1'.
wa_fieldcat1_slis-outputlen = 30.
APPEND wa_fieldcat1_slis TO lt_fieldcat1_slis.

Read only

0 Likes
2,192

wa_fieldcat1_slis-col_pos = '2'.
wa_fieldcat1_slis-fieldname = 'FIELD2'.
wa_fieldcat1_slis-tabname = 'I_field_form'.
wa_fieldcat1_slis-seltext_l = 'FIELD2'.
wa_fieldcat1_slis-outputlen = 30.
APPEND wa_fieldcat1_slis TO lt_fieldcat1_slis.

wa_fieldcat1_slis-col_pos = '3'.
wa_fieldcat1_slis-fieldname = 'FIELD3'.
wa_fieldcat1_slis-tabname = 'I_field_form'.
wa_fieldcat1_slis-seltext_l = 'FIELD3'.
wa_fieldcat1_slis-outputlen = 30.
APPEND wa_fieldcat1_slis TO lt_fieldcat1_slis.



*call the initial function module
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
  EXPORTING
    i_callback_program             = sy-repid
*   I_CALLBACK_PF_STATUS_SET       = ' '
*   I_CALLBACK_USER_COMMAND        = ' '
*   IT_EXCLUDING                   =
.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
  EXPORTING
    is_layout                        = ls_layout

    it_fieldcat                      = lt_fieldcat1_slis
    i_tabname                        = 'I_FIELD_FORM'
    "'i_field_form'
    it_events                        = t_events
*   IT_SORT                          =
*   I_TEXT                           = ' '
  TABLES
    t_outtab                         = i_field_form
 EXCEPTIONS
   program_error                    = 1
   maximum_of_appends_reached       = 2
   OTHERS                           = 3.

wa_print-reserve_lines = 1.
*
*   *display the data
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
  EXPORTING
    is_print = wa_print.

Regards,

Siddarth

Read only

0 Likes
2,192

hi

I HAVE USED THE SAME LOGIC , EXCEPT THE PART DO 10 TIMES. wg_field_form-field1 = sy-index. wg_field_form-field2 = 2 * sy-index. wg_field_form-field3 = 3 * sy-index. APPEND wg_field_form to i_field_form. ENDDO.

but just to see it even if i put it same way in my code its creating in output so many lines but output is not coming.

please help

Read only

0 Likes
2,192

there were certain lines which I had changed and those lines you had commented actually... just copy and paste the complete code removing the do 10 times......enddo.....

copy and paste the code with the call function part also......

and then see if it works or not... if it does not....

copy the complete code in a new program and then check if it works... if it works then compare both the prog line by line....

Regards,

Siddarth

Read only

0 Likes
2,192

Hi, Try to change your code like below.


  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
    EXPORTING
      is_layout                        = ls_layout1
 
      it_fieldcat                      = lt_fieldcat1_slis
      i_tabname                        = 'I_FIELD_FORM'  "Instead of 'i_field_form'. Capital letters in quotes not small letters
      it_events                        = t_events
*   IT_SORT                          =
*   I_TEXT                           = ' '
    TABLES
      t_outtab                         = i_field_form
   EXCEPTIONS
     program_error                    = 1
     maximum_of_appends_reached       = 2
     OTHERS                           = 3.
I hope that it solves. Thanks Venkat.O

Read only

0 Likes
2,192

hi

I DID THE SAME BUT ITS OF NO USE, its still in the same stage. no output

Read only

0 Likes
2,192

HI

see the basic idea of cretaing i_field_form is it should have data, i am seeing data inside it but its not getting populated, i copied your program in a new one and saw its wroking but when i implement it in my program i_field_form contains values but it cannot connect with fieldcatlaog i suppose.

Read only

0 Likes
2,192

Hi,

did you paste the code which i had given in my previous ex. if not... just paste this and comment your code of appending fieldcatalog....

wa_fieldcat1_slis-col_pos = '1'.
wa_fieldcat1_slis-fieldname = 'FIELD1'.
wa_fieldcat1_slis-tabname = 'I_FIELD_FORM'.
wa_fieldcat1_slis-seltext_l = 'FIELD1'.
wa_fieldcat1_slis-outputlen = 30.
APPEND wa_fieldcat1_slis TO lt_fieldcat1_slis.

wa_fieldcat1_slis-col_pos = '2'.
wa_fieldcat1_slis-fieldname = 'FIELD2'.
wa_fieldcat1_slis-tabname = 'I_FIELD_FORM'.
wa_fieldcat1_slis-seltext_l = 'FIELD2'.
wa_fieldcat1_slis-outputlen = 30.
APPEND wa_fieldcat1_slis TO lt_fieldcat1_slis.
 
wa_fieldcat1_slis-col_pos = '3'.
wa_fieldcat1_slis-fieldname = 'FIELD3'.
wa_fieldcat1_slis-tabname = 'I_FIELD_FORM'.
wa_fieldcat1_slis-seltext_l = 'FIELD3'.
wa_fieldcat1_slis-outputlen = 30.
APPEND wa_fieldcat1_slis TO lt_fieldcat1_slis.

Regards,

Siddarth

Read only

0 Likes
2,192

hi

thats ok, but the 1st row of itab i_field_form should come as a header of ALV, and from the second row the content should follow with correspondence with the 1st row.

Read only

0 Likes
2,192

now copy and paste this code completely.....

READ TABLE i_field_form INTO wg_field_form INDEX 1.

IF sy-subrc = 0.
  wa_fieldcat1_slis-col_pos = '1'.
  wa_fieldcat1_slis-fieldname = 'FIELD1'.
  wa_fieldcat1_slis-tabname = 'I_field_form'.
  wa_fieldcat1_slis-seltext_l = wg_field_form-field1.
  wa_fieldcat1_slis-outputlen = 30.
  APPEND wa_fieldcat1_slis TO lt_fieldcat1_slis.

  wa_fieldcat1_slis-col_pos = '2'.
  wa_fieldcat1_slis-fieldname = 'FIELD2'.
  wa_fieldcat1_slis-tabname = 'I_field_form'.
  wa_fieldcat1_slis-seltext_l = wg_field_form-field2.
  wa_fieldcat1_slis-outputlen = 30.
  APPEND wa_fieldcat1_slis TO lt_fieldcat1_slis.

  wa_fieldcat1_slis-col_pos = '3'.
  wa_fieldcat1_slis-fieldname = 'FIELD3'.
  wa_fieldcat1_slis-tabname = 'I_field_form'.
  wa_fieldcat1_slis-seltext_l = wg_field_form-field3.
  wa_fieldcat1_slis-outputlen = 30.
  APPEND wa_fieldcat1_slis TO lt_fieldcat1_slis.

  DELETE i_field_form INDEX 1.

*call the initial function module
  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
    EXPORTING
      i_callback_program             = sy-repid
*   I_CALLBACK_PF_STATUS_SET       = ' '
*   I_CALLBACK_USER_COMMAND        = ' '
*   IT_EXCLUDING                   =
  .
  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
    EXPORTING
      is_layout                        = ls_layout

      it_fieldcat                      = lt_fieldcat1_slis
      i_tabname                        = 'I_FIELD_FORM'
      "'i_field_form'
      it_events                        = t_events
*   IT_SORT                          =
*   I_TEXT                           = ' '
    TABLES
      t_outtab                         = i_field_form
   EXCEPTIONS
     program_error                    = 1
     maximum_of_appends_reached       = 2
     OTHERS                           = 3.

  wa_print-reserve_lines = 1.
*
*   *display the data
  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
    EXPORTING
      is_print = wa_print.

ENDIF.

Read only

0 Likes
2,192

hi

Thanks a lot it solved my problem as of now,but the fieldcatalog is not dynamic, can it be made dynamic by any means

Read only

0 Likes
2,192

yes sure it can be made dynamic.....

DO 10 TIMES.
  wg_field_form-field1 = sy-index.
  wg_field_form-field2 = 2 * sy-index.
  wg_field_form-field3 = 3 * sy-index.
  APPEND wg_field_form TO i_field_form.
ENDDO.

READ TABLE i_field_form INTO wg_field_form INDEX 1.
DATA W_STRING TYPE STRING.
IF sy-subrc = 0.

do 3 times.
  W_STRING = SY-INDEX.
  CONDENSE W_STRING NO-GAPS.
  concatenate 'FIELD' W_STRING INTO W_STRING.
  perform field_catalog USING sy-index W_STRING.
ENDDO.

  DELETE i_field_form INDEX 1.

*call the initial function module
  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
    EXPORTING
      i_callback_program             = sy-repid  .
  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
    EXPORTING
      is_layout                        = ls_layout
      it_fieldcat                      = lt_fieldcat1_slis
      i_tabname                        = 'I_FIELD_FORM'
      "'i_field_form'
      it_events                        = t_events
    TABLES
      t_outtab                         = i_field_form
   EXCEPTIONS
     program_error                    = 1
     maximum_of_appends_reached       = 2
     OTHERS                           = 3.

  wa_print-reserve_lines = 1.

  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
    EXPORTING
      is_print = wa_print.

ENDIF.


FORM field_catalog  USING    p_sy_index TYPE i
                             p_w_string TYPE string.

  FIELD-SYMBOLS : <fs> TYPE ANY.

  DATA lw_index TYPE string.
  lw_index = sy-index.
  CONDENSE lw_index NO-GAPS.

  wa_fieldcat1_slis-col_pos = lw_index.
  wa_fieldcat1_slis-fieldname = p_w_string.
  wa_fieldcat1_slis-tabname = 'I_field_form'.

  CONCATENATE 'WG_FIELD_FORM-' p_w_string INTO p_w_string.
  ASSIGN (p_w_string) TO <fs>.
  wa_fieldcat1_slis-seltext_l = <fs>.
  wa_fieldcat1_slis-outputlen = 30.
  APPEND wa_fieldcat1_slis TO lt_fieldcat1_slis.

ENDFORM.

Regards,

Siddarth

Read only

0 Likes
2,192

hi

since you knw that 3 coulmn are there u r using

do 3 times.

W_STRING = SY-INDEX.

CONDENSE W_STRING NO-GAPS.

concatenate 'FIELD' W_STRING INTO W_STRING.

perform field_catalog USING sy-index W_STRING.

ENDDO.

what if we dont knw how many coloumns will be there, i mean i am reading data from a file in AL11, it can have any no of data and as such the 1st line will come as column heading , so can we do something where we do not need to hardcore the coulmn no.

Read only

0 Likes
2,192

hi,

u can use the code given below.... in that case.... its completely dynamic and will work for sure....

FIELD-SYMBOLS : <fs> TYPE ANY.

READ TABLE i_field_form INTO wg_field_form INDEX 1.
DATA w_string TYPE string.
IF sy-subrc = 0.

  WHILE 1 = 1.
    w_string = sy-index.
    ASSIGN COMPONENT sy-index OF STRUCTURE wg_field_form TO <fs>.
    IF sy-subrc = 0.
      CONDENSE w_string NO-GAPS.
      CONCATENATE 'FIELD' w_string INTO w_string.
      PERFORM field_catalog USING sy-index w_string.
    ELSE.
      EXIT.
    ENDIF.
  ENDWHILE.

  DELETE i_field_form INDEX 1.

  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
    EXPORTING
      i_callback_program             = sy-repid.

  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
    EXPORTING
      is_layout                        = ls_layout

      it_fieldcat                      = lt_fieldcat1_slis
      i_tabname                        = 'I_FIELD_FORM'
      "'i_field_form'
      it_events                        = t_events
    TABLES
      t_outtab                         = i_field_form
   EXCEPTIONS
     program_error                    = 1
     maximum_of_appends_reached       = 2
     OTHERS                           = 3.

  wa_print-reserve_lines = 1.

  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
    EXPORTING
      is_print = wa_print.

ENDIF.

FORM field_catalog  USING    p_sy_index TYPE i
                             p_w_string TYPE string.

  DATA lw_index TYPE string.
  lw_index = sy-index.
  CONDENSE lw_index NO-GAPS.

  wa_fieldcat1_slis-col_pos = lw_index.
  wa_fieldcat1_slis-fieldname = p_w_string.
  wa_fieldcat1_slis-tabname = 'I_field_form'.

  wa_fieldcat1_slis-seltext_l = <fs>.
  CONDENSE wa_fieldcat1_slis-seltext_l NO-GAPS.
  wa_fieldcat1_slis-outputlen = 30.
  APPEND wa_fieldcat1_slis TO lt_fieldcat1_slis.

ENDFORM.                    " field_catalog

Read only

Former Member
0 Likes
2,192

hii swarnil,

it seems that yoou didn't pass the sy-repid value in the variable V_REPID.just chk it

form DISPLAY_DATA .

V_REPID = SY-REPID.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = V_REPID

....

rgrds,

Shweta

Read only

0 Likes
2,192

HI

no i have passed sy-repid in the ALV init, so that is nt the problem. please help

Read only

SwarnaliBasu
Participant
0 Likes
2,192
 LOOP AT i_bdclog1 INTO wg_bdclog1.
    SPLIT wg_bdclog1 AT cl_abap_char_utilities=>horizontal_tab
       INTO
            wg_field_form-field1
            wg_field_form-field2
            wg_field_form-field3
            wg_field_form-field4
            wg_field_form-field5
            wg_field_form-field6
            wg_field_form-field7
            wg_field_form-field8
            wg_field_form-field9
            wg_field_form-field10
            wg_field_form-field11
            wg_field_form-field12
            wg_field_form-field13
            wg_field_form-field14
            wg_field_form-field15.



    APPEND  wg_field_form TO i_field_form .

    CLEAR:wg_field_form,wg_bdclog1.

here i_bdclog1 contains the value of a file which is present in AL11, and the file is read and taken in an internal table

Edited by: swarnali_IBM on Aug 24, 2009 7:55 AM

Read only

SwarnaliBasu
Participant
0 Likes
2,192
READ TABLE i_field_form INTO wg_field_form INDEX 1.

  IF sy-subrc = 0.


  wa_fieldcat1_slis-col_pos = '0'.
    wa_fieldcat1_slis-fieldname = wg_field_form-field1.
*  wa_fieldcat1_slis-fieldname = 'field1'.
  wa_fieldcat1_slis-tabname = 'I_field_form'.
    wa_fieldcat1_slis-seltext_l = wg_field_form-field1.
*  wa_fieldcat1_slis-seltext_l = 'field1'.

  wa_fieldcat1_slis-outputlen = 30.
  APPEND wa_fieldcat1_slis TO lt_fieldcat1_slis.

  wa_fieldcat1_slis-col_pos = '1'.
    wa_fieldcat1_slis-fieldname = wg_field_form-field2.
*  wa_fieldcat1_slis-fieldname = 'field2'.

  wa_fieldcat1_slis-tabname = 'I_field_form'.
    wa_fieldcat1_slis-seltext_l = wg_field_form-field2.
*  wa_fieldcat1_slis-seltext_l = 'field2'.

  wa_fieldcat1_slis-outputlen = 30.
  APPEND wa_fieldcat1_slis TO lt_fieldcat1_slis.

  wa_fieldcat1_slis-col_pos = '3'.
    wa_fieldcat1_slis-fieldname = wg_field_form-field3.
*  wa_fieldcat1_slis-fieldname = 'field3'.

  wa_fieldcat1_slis-tabname = 'I_field_form'.
    wa_fieldcat1_slis-seltext_l = wg_field_form-field3.
*  wa_fieldcat1_slis-seltext_l = 'field3'.
  wa_fieldcat1_slis-outputlen = 30.
  APPEND wa_fieldcat1_slis TO lt_fieldcat1_slis.
Read only

SwarnaliBasu
Participant
0 Likes
2,192
call the initial function module
  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
    EXPORTING
      i_callback_program             = sy-repid
*   I_CALLBACK_PF_STATUS_SET       = ' '
*   I_CALLBACK_USER_COMMAND        = ' '
*   IT_EXCLUDING                   =

  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
    EXPORTING
      is_layout                        = ls_layout1

      it_fieldcat                      = lt_fieldcat1_slis
      i_tabname                        = 'i_field_form'
      it_events                        = t_events
*   IT_SORT                          =
*   I_TEXT                           = ' '
    TABLES
      t_outtab                         = i_field_form
   EXCEPTIONS
     program_error                    = 1
     maximum_of_appends_reached       = 2
     OTHERS                           = 3.

wa_print-reserve_lines = 1.
*
*   *display the data
  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
    EXPORTING
      is_print = wa_print.