Skip to Content
author's profile photo Former Member
Former Member

ADD ICON

IN alv I NEED TO ADD ICON THAT WHEN I CLICK ON IT

IT PRINT SMARTFORM LAYOUT

DO TOU KNOW ?

THANKS

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jun 06, 2006 at 09:55 AM

    Are u creating ur alv using OOPS concept .. ? If so then you can add your ICON( i understand that it is a button that you want on the grid ).Check the sample code below :

    CLASS lcl_event_receiver DEFINITION.
      PUBLIC SECTION.
        METHODS: handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
                            IMPORTING e_object e_interactive,
                 handle_fcode FOR EVENT user_command OF cl_gui_alv_grid
                            IMPORTING e_ucomm.
      PRIVATE SECTION.
    ENDCLASS.                    "LCL_EVENT_RECEIVER DEFINITION
    
    CLASS lcl_event_receiver IMPLEMENTATION.
    
      METHOD handle_toolbar.
        DATA: wl_toolbar TYPE stb_button.
        wl_toolbar-butn_type = 3.
        APPEND wl_toolbar TO e_object->mt_toolbar.
        CLEAR wl_toolbar.
        wl_toolbar-quickinfo = text-002.
        wl_toolbar-disabled  = space.
        wl_toolbar-icon      = icon_release.
        wl_toolbar-function  = c_post.
        APPEND wl_toolbar TO e_object->mt_toolbar.
    
        CLEAR wl_toolbar.
        wl_toolbar-butn_type = 3.
        APPEND wl_toolbar TO e_object->mt_toolbar.
        CLEAR wl_toolbar.
        wl_toolbar-quickinfo = text-004.
        wl_toolbar-disabled  = space.
        wl_toolbar-icon      = icon_delete.
        wl_toolbar-function  = c_dlte.
        APPEND wl_toolbar TO e_object->mt_toolbar.
    
      ENDMETHOD.                    "HANDLE_TOOLBAR

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 06, 2006 at 10:18 AM

    Hi,

    After click the button then you need to submit the print program of smartform by using SUBMIT statement.

    Cheers,

    Bujji.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 06, 2006 at 10:40 AM

    Hi Liat,

    For ALV grid function module. Below is the code i have written to display list of contacts. the user has able to select mutliple contacts displayed in the screen and select the Button 'PRINT CONTRACT' to print smartform.

    If need complete code give me your mail id, i will send you.

    My code works for Tcode VA42.

    You have to create GUI status in SE41 to display button on tool bar.

    • Display output in a ALV Grid

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    I_CALLBACK_PROGRAM = gs_repid

    I_CALLBACK_PF_STATUS_SET = 'ALV_STATUS'

    I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

    IS_LAYOUT = gs_layout

    IT_FIELDCAT = gt_fieldcat

    IT_SORT = gs_sort

    I_SAVE = 'A'

    TABLES

    T_OUTTAB = it_cntrt

    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 user_command USING l_ucomm LIKE sy-ucomm

    l_selfield TYPE slis_selfield.

    RANGES: r_kappl FOR nast-kappl,

    r_objky FOR nast-objky,

    r_kschl FOR nast-kschl,

    r_nacha FOR nast-nacha.

    DATA: l_jobname TYPE TBTCJOB-JOBNAME,

    l_jobcount TYPE TBTCJOB-JOBCOUNT,

    l_repid TYPE sy-repid,

    l_print_params TYPE PRI_PARAMS,

    l_arc_params TYPE ARC_PARAMS,

    l_valid TYPE c,

    l_retcode TYPE sy-subrc,

    l_blines TYPE i.

    CASE l_ucomm.

    • Process button seleted

    WHEN c_sform.

    • process selected records.

    LOOP AT it_cntrt INTO wa_cntrt.

    IF wa_cntrt-box = 'X'.

    • place output type in the contract

    PERFORM bdc_output USING wa_cntrt

    CHANGING l_retcode.

    IF l_retcode = 0.

    • add record for jobground job

    r_objky-sign = 'I'.

    r_objky-option = 'EQ'.

    r_objky-low = wa_cntrt-vbeln.

    APPEND r_objky.

    ENDIF.

    CLEAR: wa_cntrt, l_retcode, r_objky.

    ENDIF.

    ENDLOOP.

    WHEN c_dclick.

    • set contract number id with the selected contract

    SET PARAMETER ID 'AUN' FIELD l_selfield-value.

    SET PARAMETER ID 'KTN' FIELD l_selfield-value.

    • call va42 tcode when double click on contract

    CALL TRANSACTION c_tcode AND SKIP FIRST SCREEN.

    ENDCASE.

    DESCRIBE TABLE r_objky LINES l_blines.

    • IF NOT r_objky[] IS INITIAL.

    IF l_blines > 0.

    • Background job name.

    CONCATENATE 'XCM_INDEXATION' sy-uname '_' sy-uzeit

    INTO l_jobname.

    • Application

    r_kappl-sign = 'I'.

    r_kappl-option = 'EQ'.

    r_kappl-low = 'V1'.

    APPEND r_kappl.

    • Message Type

    r_kschl-sign = 'I'.

    r_kschl-option = 'EQ'.

    r_kschl-low = c_kschl.

    APPEND r_kschl.

    • Message transmission medium

    r_nacha-sign = 'I'.

    r_nacha-option = 'EQ'.

    r_nacha-low = '1'.

    APPEND r_nacha.

    l_repid = sy-repid.

    • Print Parameters

    CALL FUNCTION 'GET_PRINT_PARAMETERS'

    EXPORTING

    DESTINATION = p_print

    MODE = c_batch

    NO_DIALOG = 'X'

    REPORT = l_repid

    EXPIRATION = 2

    IMMEDIATELY = 'X'

    NEW_LIST_ID = 'X'

    IMPORTING

    OUT_ARCHIVE_PARAMETERS = l_arc_params

    OUT_PARAMETERS = l_print_params

    VALID = l_valid

    EXCEPTIONS

    ARCHIVE_INFO_NOT_FOUND = 1

    INVALID_PRINT_PARAMS = 2

    INVALID_ARCHIVE_PARAMS = 3

    OTHERS = 4.

    IF SY-SUBRC <> 0.

    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    • opening the job

    CALL FUNCTION 'JOB_OPEN'

    EXPORTING

    JOBNAME = l_jobname

    IMPORTING

    JOBCOUNT = l_jobcount

    EXCEPTIONS

    CANT_CREATE_JOB = 1

    INVALID_JOB_DATA = 2

    JOBNAME_MISSING = 3

    OTHERS = 4.

    IF SY-SUBRC <> 0.

    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    • Job submit

    SUBMIT rsnast00 TO SAP-SPOOL

    USER sy-uname

    WITH s_kappl IN r_kappl

    WITH s_objky IN r_objky

    WITH s_kschl IN r_kschl

    WITH s_nacha IN r_nacha

    WITH p_print EQ p_print

    VIA JOB l_jobname NUMBER l_jobcount

    SPOOL PARAMETERS l_print_params

    WITHOUT SPOOL DYNPRO

    AND RETURN.

    IF sy-subrc <> 0.

    • display message when error in scheduling background job

    MESSAGE E016 WITH 'Error scheduling Job'.

    ENDIF.

    • Job close

    CALL FUNCTION 'JOB_CLOSE'

    EXPORTING

    JOBCOUNT = l_jobcount

    JOBNAME = l_jobname

    STRTIMMED = 'X'

    EXCEPTIONS

    CANT_START_IMMEDIATE = 1

    INVALID_STARTDATE = 2

    JOBNAME_MISSING = 3

    JOB_CLOSE_FAILED = 4

    JOB_NOSTEPS = 5

    JOB_NOTEX = 6

    LOCK_FAILED = 7

    OTHERS = 8.

    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.

    ENDFORM.

    FORM bdc_output USING wa_cntrt TYPE ty_cntrt

    CHANGING l_retcode TYPE sy-subrc.

    DATA: l_nast TYPE TABLE OF nast,

    it_nast TYPE TABLE OF nast,

    w_nast TYPE nast,

    l_cellno(2) TYPE n,

    l_vbelv TYPE vbfa-vbelv,

    l_vbpa TYPE vbpa,

    l_yes(1),

    l_temp(40) TYPE c,

    l_lines TYPE i,

    l_lesscnt TYPE i,

    l_less(1),

    l_lines1(2) TYPE n.

    REFRESH: it_nast, l_nast, it_bdc.

    CLEAR: l_nast, w_nast, l_yes, l_cellno,

    it_nast, l_nast, it_bdc.

    PERFORM dyn_scr USING 'SAPMV45A' '0102' 'X'.

    PERFORM dyn_fld USING 'VBAK-VBELN' wa_cntrt-vbeln.

    PERFORM dyn_fld USING 'BDC_OKCODE' '/00'.

    PERFORM dyn_scr USING 'SAPMV45A' '4001' 'X'.

    PERFORM dyn_fld USING 'BDC_OKCODE' '=HEAD'.

    PERFORM dyn_scr USING 'SAPMV45A' '4002' 'X'.

    PERFORM dyn_fld USING 'BDC_OKCODE' '=KDOK'.

    SELECT *

    FROM nast

    INTO CORRESPONDING FIELDS OF TABLE l_nast

    WHERE kappl = c_kappl

    AND objky = wa_cntrt-vbeln.

    IF sy-subrc = 0.

    SORT l_nast BY kschl vstat.

    DESCRIBE TABLE l_nast LINES l_lines.

    LOOP AT l_nast INTO w_nast.

    l_cellno = sy-tabix.

    IF w_nast-kschl = c_kschl AND w_nast-vstat = 0.

    EXIT.

    ENDIF.

    IF w_nast-kschl > c_kschl OR

    ( w_nast-kschl = c_kschl AND w_nast-vstat <> 0 ).

    IF l_less = space.

    l_cellno = l_cellno - 1.

    ENDIF.

    CLEAR l_less.

    IF l_cellno = 0.

    l_cellno = 1.

    ENDIF.

    l_lines = l_lines + 1.

    l_lines1 = l_lines.

    PERFORM dyn_scr USING 'SAPDV70A' '0100' 'X'.

    CONCATENATE 'DNAST-KSCHL(' l_lines1 ')' INTO l_temp.

    CONDENSE l_temp.

    PERFORM dyn_fld USING l_temp 'Y6C4'.

    CLEAR: l_temp, l_lines, l_lines1.

    PERFORM dyn_fld USING 'BDC_OKCODE' '/00'.

    EXIT.

    ELSEIF w_nast-kschl < c_kschl.

    l_less = 'X'.

    l_lesscnt = l_lesscnt + 1.

    ENDIF.

    ENDLOOP.

    ELSE.

    l_cellno = '01'.

    PERFORM dyn_scr USING 'SAPDV70A' '0100' 'X'.

    CONCATENATE 'DNAST-KSCHL(' l_cellno ')' INTO l_temp.

    CONDENSE l_temp.

    PERFORM dyn_fld USING l_temp 'Y6C4'.

    CLEAR l_temp.

    PERFORM dyn_fld USING 'BDC_OKCODE' '/00'.

    ENDIF.

    IF l_less = 'X'.

    l_lesscnt = l_lesscnt + 1.

    l_cellno = l_lesscnt.

    l_lines = l_lines + 1.

    l_lines1 = l_lines.

    PERFORM dyn_scr USING 'SAPDV70A' '0100' 'X'.

    CONCATENATE 'DNAST-KSCHL(' l_lines1 ')' INTO l_temp.

    CONDENSE l_temp.

    PERFORM dyn_fld USING l_temp 'Y6C4'.

    CLEAR: l_temp, l_lines, l_lines1.

    PERFORM dyn_fld USING 'BDC_OKCODE' '/00'.

    ENDIF.

    PERFORM dyn_scr USING 'SAPDV70A' '0100' 'X'.

    CONCATENATE 'DV70A-SELKZ(' l_cellno ')' INTO l_temp.

    CONDENSE l_temp.

    PERFORM dyn_fld USING l_temp 'X'.

    CLEAR l_temp.

    PERFORM dyn_fld USING 'BDC_OKCODE' '=V70P'.

    PERFORM dyn_scr USING 'SAPDV70A' '0101' 'X'.

    PERFORM dyn_fld USING 'NAST-LDEST' p_print.

    PERFORM dyn_fld USING 'NAST-DIMME' 'X'.

    PERFORM dyn_fld USING 'NAST-TDARMOD' '1'.

    PERFORM dyn_fld USING 'BDC_OKCODE' '=V70B'.

    PERFORM dyn_scr USING 'SAPDV70A' '0100' 'X'.

    CONCATENATE 'DV70A-SELKZ(' l_cellno ')' INTO l_temp.

    CONDENSE l_temp.

    PERFORM dyn_fld USING l_temp 'X'.

    CLEAR l_temp.

    PERFORM dyn_fld USING 'BDC_OKCODE' '=V70I'.

    PERFORM dyn_scr USING 'SAPDV70A' '0102' 'X'.

    PERFORM dyn_fld USING 'NAST-VSZTP' '1'.

    PERFORM dyn_fld USING 'BDC_OKCODE' '=V70B'.

    PERFORM dyn_scr USING 'SAPDV70A' '0100' 'X'.

    PERFORM dyn_fld USING 'BDC_OKCODE' '=V70S'.

    CALL TRANSACTION c_tcode USING it_bdc

    MODE c_mode "'N'

    UPDATE c_updat "'A'

    MESSAGES INTO it_mesg.

    IF sy-subrc = 0.

    l_retcode = 0.

    ENDIF.

    ENDFORM. " bdc_output

    &----


    *& Form dyn_scr

    &----


    • text

    ----


    • -->P_0642 text

    • -->P_0643 text

    • -->P_0644 text

    ----


    FORM dyn_scr USING P_0642

    P_0643

    P_0644.

    MOVE: p_0642 TO wa_bdc-program,

    p_0643 TO wa_bdc-dynpro,

    p_0644 TO wa_bdc-dynbegin.

    APPEND wa_bdc TO it_bdc.

    CLEAR wa_bdc.

    ENDFORM. " dyn_scr

    &----


    *& Form dyn_fld

    &----


    • text

    ----


    • -->P_0654 text

    • -->P_0655 text

    ----


    FORM dyn_fld USING P_0654

    P_0655.

    MOVE: p_0654 TO wa_bdc-fnam,

    p_0655 TO wa_bdc-fval.

    APPEND wa_bdc TO it_bdc.

    CLEAR wa_bdc.

    ENDFORM. " dyn_fld

    FORM alv_sort.

    DATA: wa_sortcat TYPE slis_sortinfo_alv.

    WA_SORTCAT-SPOS = 1.

    WA_SORTCAT-FIELDNAME = 'KUNNR'.

    WA_SORTCAT-UP = 'X'.

    WA_SORTCAT-EXPA = 'X'.

    • Appending gd_sortcat-tabname

    APPEND WA_SORTCAT TO gs_sort.

    CLEAR wa_sortcat.

    WA_SORTCAT-SPOS = 2.

    WA_SORTCAT-FIELDNAME = 'VBELN'.

    WA_SORTCAT-UP = 'X'.

    WA_SORTCAT-EXPA = 'X'.

    • Appending gd_sortcat-tabname

    APPEND WA_SORTCAT TO gs_sort.

    WA_SORTCAT-SPOS = 3.

    WA_SORTCAT-FIELDNAME = 'VUNTDAT'.

    WA_SORTCAT-UP = 'X'.

    WA_SORTCAT-EXPA = 'X'.

    • Appending gd_sortcat-tabname

    APPEND WA_SORTCAT TO gs_sort.

    ENDFORM. " alv_sort

    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.