Skip to Content

PRINT button in ALV output without using OOPS

Hi Folks,

Can anyone here please let me know how to add a print button in the ALV output without using OOPS.I had added the syntax

set pf-status 'ZAT' and then print in this status but in vain.

Kindly let me know how to do this.

REPORT ZEDITALV .

<b>type-pools:slis,icon.</b>

TABLES:MAKT.

*Declarations for ALV

DATA:itfieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.

DATA:itfieldcat1 TYPE slis_t_fieldcat_alv WITH HEADER LINE.

DATA:itprintparams TYPE slis_print_alv.

DATA:itrepid TYPE sy-repid.

itrepid = sy-repid.

DATA:itevent TYPE slis_t_event.

DATA:itlistheader TYPE slis_t_listheader.

DATA:walistheader LIKE LINE OF itlistheader.

DATA:itlayout TYPE slis_layout_alv.

DATA:top TYPE slis_formname.

DATA:itsort TYPE slis_t_sortinfo_alv WITH HEADER LINE.

DATA : grid TYPE REF TO cl_gui_alv_grid.

data:begin of imakt occurs 0,

matnr like makt-matnr,

spras like makt-spras,

maktx like makt-maktx,

label1(03) TYPE C,

qty1(03) type c,

label2(03) type c,

qty2(03) type c,

end of imakt.

data:imakt1 like imakt occurs 0 with header line.

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

SELECT-OPTIONS:MATNR FOR MAKT-MATNR OBLIGATORY.

SELECTION-SCREEN END OF BLOCK B1.

<b>set pf-status 'ZAT'.</b>

START-OF-SELECTION.

select matnr spras maktx from makt into CORRESPONDING FIELDS OF TABLE IMAKT where spras = sy-langu.

if sy-subrc = 0.

perform alv.

ELSE.

STOP.

ENDIF.

FORM ALV.

DEFINE m_fieldcat.

itfieldcat-fieldname = &1.

itfieldcat-col_pos = &2.

itfieldcat-seltext_l = &3.

itfieldcat-do_sum = &4.

itfieldcat-outputlen = &5.

itfieldcat-edit = &6.

append itfieldcat to itfieldcat.

clear itfieldcat.

END-OF-DEFINITION.

m_fieldcat 'MATNR' '' 'MATERIAL No' '' 18 ''.

m_fieldcat 'SPRAS' '' 'Language' '' 02 ''.

m_fieldcat 'MAKTX' '' 'Description' '' 40 ''.

m_fieldcat 'LABEL1' '' 'LABEL1' '' 12 'X'.

m_fieldcat 'QTY1' '' 'QTY1' '' 12 'X'.

m_fieldcat 'LABEL2' '' 'LABEL2' '' 12 'X'.

m_fieldcat 'QTY2' '' 'QTY2' '' 12 'X'.

itlayout-zebra = 'X'.

itlayout-colwidth_optimize = 'X'.

itlayout-no_subtotals = ' '.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

is_layout = itlayout

i_callback_user_command = 'LIST1'

i_callback_top_of_page = 'TOP'

it_fieldcat = itfieldcat[]

i_save = 'A'

  • is_variant = ITVARIANT

it_events = itevent[]

is_print = ITPRINTPARAMS

it_sort = itsort[]

TABLES

t_outtab = imakt

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.

clear itfieldcat.

ENDFORM.

FORM list1 USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

CASE R_UCOMM.

WHEN 'EXIT'.

STOP.

WHEN '&IC1'.

IF rs_selfield-fieldname = 'QTY1' .

READ TABLE IMAKT INDEX rs_selfield-tabindex.

SET PARAMETER ID 'QTY' FIELD iMAKT-QTY1.

ENDIF.

ENDCASE.

*test

if sy-subrc = 0.

loop at imakt.

move-corresponding imakt to imakt1.

append imakt1.

endloop.

DEFINE k_fieldcat.

itfieldcat1-fieldname = &1.

itfieldcat1-col_pos = &2.

itfieldcat1-seltext_l = &3.

itfieldcat1-outputlen = &4.

append itfieldcat1 to itfieldcat1.

clear itfieldcat.

END-OF-DEFINITION.

k_fieldcat 'MATNR' '' 'MATERIAL No' 18 .

k_fieldcat 'SPRAS' '' 'Language' 02 .

k_fieldcat 'MAKTX' '' 'Description' 40 .

k_fieldcat 'LABEL1' '' 'LABEL1' 12 .

k_fieldcat 'QTY1' '' 'QTY1' 12 .

k_fieldcat 'LABEL2' '' 'LABEL2' 12 .

k_fieldcat 'QTY2' '' 'QTY2' 12 .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

is_layout = itlayout

i_callback_user_command = 'LIST2'

i_callback_top_of_page = 'TOP'

it_fieldcat = itfieldcat1[]

i_save = 'A'

  • is_variant = ITVARIANT

it_events = itevent[]

is_print = ITPRINTPARAMS

it_sort = itsort[]

TABLES

t_outtab = imakt1

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.

endif.

clear:itfieldcat1,ITFIELDCAT.

ENDFORM.

FORM list2 USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

CASE R_UCOMM.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

WHEN 'OTHERS'.

EXIT.

ENDCASE.

ENDFORM.

form top.

data:title(70) type c.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = itevent

  • EXCEPTIONS

  • LIST_TYPE_WRONG = 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.

title = 'TEST'.

walistheader-typ = 'H'.

walistheader-info = title.

APPEND walistheader TO itlistheader.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = itlistheader

  • I_LOGO = ''.

  • I_END_OF_LIST_GRID =

.

CLEAR itlistheader.

ENDFORM. "TOP

Message was edited by:

Kiran K

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Sep 17, 2007 at 08:48 AM

    Hello Kiran,

    In REUSE_ALV_GRID_DISPLAY there is an export parameter called

    <b>I_CALLBACK_PF_STATUS_SET = ' '</b> Give some PF status name in quotations and add ur own button by doble clicking it. and write relevent code in user command of that pf status.

    Reward If Helpful.

    Regards

    --

    Sasidhar Reddy Matli.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 17, 2007 at 05:01 AM

    Hi Folks,

    Looking forward to SDN Experts replies.

    Thanks,

    K.Kiran.

    Message was edited by:

    Kiran K

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 17, 2007 at 05:54 AM

    Hi Kiran,

    You have done it in the right way for the User Command Do the same it for PF status.

    FORM call_alv TABLES p_out STRUCTURE wa_out.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    i_callback_program = g_repid

    i_callback_pf_status_set = 'PF_STATUS_SET'

    i_callback_user_command = 'USER_COMMAND'

    is_layout = i_layout

    it_fieldcat = i_fieldcat[]

    TABLES

    t_outtab = p_out

    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.

    ENDFORM. " call_alv

    You have to pass 'PF_STATUS_SET' as it is passed to FM as shown above and you will have to write a form with the same name as 'PF_STATUS_SET'

    &----


    *& Form PF_STATUS_SET

    &----


    • Setting PF Status

    ----


    FORM pf_status_set USING rt_extab TYPE slis_t_extab.

    SET PF-STATUS 'ZAT' .

    ENDFORM. "PF_STATUS_SET

    If you still face problem reply otherwise reward point.

    Regards,

    Mukesh Kumar

    Add a comment
    10|10000 characters needed characters exceeded

    • Mukesh,

      i_callback_pf_status_set = 'PF_STATUS_SET'

      The moment I add this the ,default buttons like save,back,cancel,exit are getting disabled.

      I want the printbutton in ALV tool bar.

      Thanks,

      K.Kiran.

      Message was edited by:

      Kiran K

      Message was edited by:

      Kiran K

  • author's profile photo Former Member
    Former Member
    Posted on Sep 17, 2007 at 06:02 AM

    hi,

    by default PRINT button will appear...

    if u have included ur own PF_STATUS,

    include this line in ALV_GRID_DISPLAY ...

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    I_CALLBACK_PROGRAM = SY-CPROG

    I_CALLBACK_USER_COMMAND = 'F_USERCOMMAND_ALV'

    <b> I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'</b>

    I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

    IS_LAYOUT = ILAYOUT

    IT_FIELDCAT = INT_FIELDCAT

    TABLES

    T_OUTTAB = INT_DATA2.

    <b>FORM SET_PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.

    SET PF-STATUS 'ZSTATUS' .

    ENDFORM.</b>

    reply back...

    With Rgds,

    S.Barani

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 22, 2007 at 06:52 AM

    Thanks a lot,

    K.Kiran.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.