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 with ALV list

Former Member
0 Likes
517

Hi friends,

I have created one program with alv list, but i am unable to add one header and footer, also i have to add one logo to the program. Plese some one tell me a easy procedure to add a header, footer and also a logo. If you can show me one with example that would be very helpful.

This is my program, plz add the necessary parts.

&----


*& Report Y_BOM2_ALV

*&

&----


*&

*&

&----


REPORT y_bom2_alv LINE-SIZE 350 LINE-COUNT 350.

&----


*& Include YINCLUDE1

&----


TABLES : mast, stko, stpo.

TYPE-POOLS : slis.

DATA : BEGIN OF iall OCCURS 10,

matnr LIKE mast-matnr,

werks LIKE mast-werks,

stlan LIKE mast-stlan,

stlal LIKE mast-stlal,

stlst LIKE stko-stlst,

posnr LIKE stpo-posnr,

idnrk LIKE stpo-idnrk,

menge LIKE stpo-menge,

meins LIKE stpo-meins,

ausch LIKE stpo-ausch,

lgort LIKE stpo-lgort,

END OF iall.

DATA : i_repid LIKE sy-repid,

i_lines LIKE sy-tabix.

DATA : int_fcat TYPE slis_t_fieldcat_alv.

SELECTION-SCREEN BEGIN OF BLOCK a1 WITH FRAME TITLE title1.

PARAMETER : p_werks LIKE mast-werks.

SELECT-OPTIONS : s_matnr FOR mast-matnr.

SELECTION-SCREEN END OF BLOCK a1.

INITIALIZATION.

title1(50) = ' Bill Of Material Input Screen '.

&----


*& Include YINCLUDE2

&----


START-OF-SELECTION.

SELECT mastmatnr mastwerks maststlan maststlal stko~stlst

stpoposnr stpoidnrk stpomenge stpomeins stpo~ausch

stpo~lgort INTO TABLE iall FROM stpo INNER JOIN stko ON

stpostlnr = stkostlnr INNER JOIN mast ON

stpostlnr = maststlnr WHERE mast~werks EQ

p_werks AND mast~matnr IN s_matnr.

IF sy-subrc <> 0 OR p_werks EQ ' ' OR s_matnr EQ ' '.

CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'

EXPORTING

titel = 'ERROR MESSAGE ( INPUT ERROR / WRONG INPUT ) '

textline1 = ' PLANT / MATERIAL Invalid or Empty '

textline2 = ' Plese enter plant no / material no again '

start_column = 20

start_row = 5.

EXIT.

ENDIF.

CLEAR i_lines.

DESCRIBE TABLE iall LINES i_lines.

IF i_lines LT 1.

WRITE: /

'No materials found.'.

EXIT.

ENDIF.

END-OF-SELECTION.

i_repid = sy-repid.

&----


*& Include YINCLUDE3

&----


CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = i_repid

i_internal_tabname = 'IALL'

i_inclname = i_repid

CHANGING

ct_fieldcat = int_fcat

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

IF sy-subrc <> 0.

WRITE: /

'Returncode',

sy-subrc,

'from FUNCTION REUSE_ALV_FIELDCATALOG_MERGE'.

ENDIF.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

i_callback_program = i_repid

it_fieldcat = int_fcat

i_save = 'A'

TABLES

t_outtab = iall

EXCEPTIONS

program_error = 1

OTHERS = 2.

IF sy-subrc <> 0.

WRITE: /

'Returncode',

sy-subrc,

'from FUNCTION REUSE_ALV_LIST_DISPLAY'.

ENDIF.

1 ACCEPTED SOLUTION
Read only

naimesh_patel
Active Contributor
0 Likes
496

It is not possible to have logo in the ALV List, it is possible to have in ALV Grid.

Use Events like this for the header and footer.

data:  WA_EVENT      TYPE SLIS_ALV_EVENT,
         T_EVENT      TYPE SLIS_T_EVENT.


  CLEAR WA_EVENT.
  WA_EVENT-NAME = 'TOP_OF_PAGE'.
  WA_EVENT-FORM = 'TOP-OF-PAGE'.
  APPEND WA_EVENT TO T_EVENT.

  WA_EVENT-NAME = 'END_OF_PAGE.
  WA_EVENT-FORM = 'END-OF-PAGE'.
  APPEND WA_EVENT TO T_EVENT.

  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
      ......
      IT_EVENTS          = T_EVENT[]
      ......

Now, you need to create 2 FORMS for that in the program.

Like this :

FORM TOP-OF-PAGE .
  DESCRIBE TABLE T_OUTPUT LINES SY-TFILL.
  WRITE: /2 'Number of Orders: ', SY-TFILL.
ENDFORM.         

FORM END-OF-PAGE .
  write: / 'I am end of page'.
ENDFORM.     

Regards,

Naimesh Patel

Hi friends,

I have created one program with alv list, but i am unable to add one header and footer, also i have to add one logo to the program. Plese some one tell me a easy procedure to add a header, footer and also a logo. If you can show me one with example that would be very helpful.

This is my program, plz add the necessary parts.

&----


*& Report Y_BOM2_ALV

*&

&----


*&

*&

&----


REPORT y_bom2_alv LINE-SIZE 350 LINE-COUNT 350.

&----


*& Include YINCLUDE1

&----


TABLES : mast, stko, stpo.

TYPE-POOLS : slis.

DATA : BEGIN OF iall OCCURS 10,

matnr LIKE mast-matnr,

werks LIKE mast-werks,

stlan LIKE mast-stlan,

stlal LIKE mast-stlal,

stlst LIKE stko-stlst,

posnr LIKE stpo-posnr,

idnrk LIKE stpo-idnrk,

menge LIKE stpo-menge,

meins LIKE stpo-meins,

ausch LIKE stpo-ausch,

lgort LIKE stpo-lgort,

END OF iall.

DATA : i_repid LIKE sy-repid,

i_lines LIKE sy-tabix.

DATA : int_fcat TYPE slis_t_fieldcat_alv.

SELECTION-SCREEN BEGIN OF BLOCK a1 WITH FRAME TITLE title1.

PARAMETER : p_werks LIKE mast-werks.

SELECT-OPTIONS : s_matnr FOR mast-matnr.

SELECTION-SCREEN END OF BLOCK a1.

INITIALIZATION.

title1(50) = ' Bill Of Material Input Screen '.

&----


*& Include YINCLUDE2

&----


START-OF-SELECTION.

SELECT mastmatnr mastwerks maststlan maststlal stko~stlst

stpoposnr stpoidnrk stpomenge stpomeins stpo~ausch

stpo~lgort INTO TABLE iall FROM stpo INNER JOIN stko ON

stpostlnr = stkostlnr INNER JOIN mast ON

stpostlnr = maststlnr WHERE mast~werks EQ

p_werks AND mast~matnr IN s_matnr.

IF sy-subrc <> 0 OR p_werks EQ ' ' OR s_matnr EQ ' '.

CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'

EXPORTING

titel = 'ERROR MESSAGE ( INPUT ERROR / WRONG INPUT ) '

textline1 = ' PLANT / MATERIAL Invalid or Empty '

textline2 = ' Plese enter plant no / material no again '

start_column = 20

start_row = 5.

EXIT.

ENDIF.

CLEAR i_lines.

DESCRIBE TABLE iall LINES i_lines.

IF i_lines LT 1.

WRITE: /

'No materials found.'.

EXIT.

ENDIF.

END-OF-SELECTION.

i_repid = sy-repid.

&----


*& Include YINCLUDE3

&----


CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = i_repid

i_internal_tabname = 'IALL'

i_inclname = i_repid

CHANGING

ct_fieldcat = int_fcat

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

IF sy-subrc <> 0.

WRITE: /

'Returncode',

sy-subrc,

'from FUNCTION REUSE_ALV_FIELDCATALOG_MERGE'.

ENDIF.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

i_callback_program = i_repid

it_fieldcat = int_fcat

i_save = 'A'

TABLES

t_outtab = iall

EXCEPTIONS

program_error = 1

OTHERS = 2.

IF sy-subrc <> 0.

WRITE: /

'Returncode',

sy-subrc,

'from FUNCTION REUSE_ALV_LIST_DISPLAY'.

ENDIF.

3 REPLIES 3
Read only

naimesh_patel
Active Contributor
0 Likes
497

It is not possible to have logo in the ALV List, it is possible to have in ALV Grid.

Use Events like this for the header and footer.

data:  WA_EVENT      TYPE SLIS_ALV_EVENT,
         T_EVENT      TYPE SLIS_T_EVENT.


  CLEAR WA_EVENT.
  WA_EVENT-NAME = 'TOP_OF_PAGE'.
  WA_EVENT-FORM = 'TOP-OF-PAGE'.
  APPEND WA_EVENT TO T_EVENT.

  WA_EVENT-NAME = 'END_OF_PAGE.
  WA_EVENT-FORM = 'END-OF-PAGE'.
  APPEND WA_EVENT TO T_EVENT.

  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
      ......
      IT_EVENTS          = T_EVENT[]
      ......

Now, you need to create 2 FORMS for that in the program.

Like this :

FORM TOP-OF-PAGE .
  DESCRIBE TABLE T_OUTPUT LINES SY-TFILL.
  WRITE: /2 'Number of Orders: ', SY-TFILL.
ENDFORM.         

FORM END-OF-PAGE .
  write: / 'I am end of page'.
ENDFORM.     

Regards,

Naimesh Patel

Read only

Former Member
0 Likes
496

Hi,

check the below link..for sample programs

http://www.sapdevelopment.co.uk/reporting/alv/alvgrid.htm

Regards,

Maha

Read only

Former Member
0 Likes
496

Hi Tapodipta,

See below example and modify ur code according to ur requirement..


REPORT  ZTEST_ALV_CHECK        .
 
 
TYPE-POOLS: SLIS.
DATA: X_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
      IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
      L_LAYOUT type slis_layout_alv,
      x_events type slis_alv_event,
      it_events type SLIS_T_EVENT.
 
DATA: BEGIN OF ITAB OCCURS 0,
      VBELN LIKE VBAK-VBELN,
      POSNR LIKE VBAP-POSNR,
     END OF ITAB.
 
SELECT VBELN
       POSNR
       FROM VBAP
       UP TO 20 ROWS
       INTO TABLE ITAB.
 
 
X_FIELDCAT-FIELDNAME = 'VBELN'.
X_FIELDCAT-SELTEXT_L = 'VBELN'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = 1.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
 
X_FIELDCAT-FIELDNAME = 'POSNR'.
X_FIELDCAT-SELTEXT_L = 'POSNR'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = 2.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
 
 
  x_events-NAME = SLIS_EV_END_OF_PAGE.
  x_events-FORM = 'END_OF_PAGE'.
  APPEND x_events  TO iT_EVENTS.
  CLEAR x_events .
  x_events-NAME = SLIS_EV_TOP_OF_PAGE.
  x_events-FORM = 'TOP_OF_PAGE'.
  APPEND x_events  TO iT_EVENTS.
  CLEAR x_events .
 
  x_events-NAME = slis_ev_end_of_list.
  x_events-FORM = 'END_OF_LIST'.
  APPEND x_events  TO iT_EVENTS.
  CLEAR x_events .
 
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
  EXPORTING
    I_CALLBACK_PROGRAM       = SY-REPID
    IS_LAYOUT                = L_LAYOUT
    IT_FIELDCAT              = IT_FIELDCAT
    it_events                = it_events
  TABLES
    T_OUTTAB                 = ITAB
  EXCEPTIONS
    PROGRAM_ERROR            = 1
    OTHERS                   = 2.
IF SY-SUBRC <> 0.
 
  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
          WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
 
FORM TOP_OF_PAGE.
* BREAK-POINT.
  WRITE: / 'TOP_OF_PAGE'.
ENDFORM.
FORM END_OF_LIST.
* BREAK-POINT.
"here you can use this for footer
  WRITE: / 'FOR FOOTER'.
ENDFORM.
FORM END_OF_PAGE.
* BREAK-POINT.
  WRITE: / 'END_OF_PAGE'.
ENDFORM.

Go through the link as well..

Hope it will solve ur problem..

<b>Reward points if useful..</b>

Thanks & Regards

ilesh 24x7