22th Aug 730am Alv

download 22th Aug 730am Alv

of 65

Transcript of 22th Aug 730am Alv

  • 7/29/2019 22th Aug 730am Alv

    1/65

    730 AM ALV OBJECTS:

    PROGRAM1(ALV REPORTING USING CLASSES):REPORT Z730AMALV1.

    data : lv_vbeln type vbak-vbeln.select-options : so_vbeln for lv_vbeln.

    types : begin of ty_vbak,vbeln type vbak-vbeln,erdat type vbak-erdat,erzet type vbak-erzet,ernam type vbak-ernam,

    end of ty_vbak.

    data : lt_vbak type standard table of ty_vbak.

    data : o_grid type ref to cl_gui_alv_grid,o_cont type ref to cl_gui_custom_container.

    initialization.so_vbeln-low = '4970'.so_vbeln-high = '4975'.append so_vbeln.

    start-of-selection.call screen 100.

    MODULE STATUS_0100 OUTPUT.if o_cont is initial.

    set pf-status 'ABC'.CREATE OBJECT O_CONT

    EXPORTINGCONTAINER_NAME = 'CST'.

    CREATE OBJECT O_GRIDEXPORTINGI_PARENT = o_cont.

    perform getdata.if lt_vbak[] is not initial.

    perform display.endif.

    endif.

    ENDMODULE. " STATUS_0100 OUTPUT

    MODULE USER_COMMAND_0100 INPUT.case sy-ucomm.

    when 'BACK'.leave program.

  • 7/29/2019 22th Aug 730am Alv

    2/65

    endcase.ENDMODULE. " USER_COMMAND_0100 INPUT

    FORM getdata .select vbeln erdat erzet ernam

    from vbakinto table lt_vbakwhere vbeln in so_vbeln.

    ENDFORM. " getdata

    FORM display .CALL METHOD O_GRID->SET_TABLE_FOR_FIRST_DISPLAY

    CHANGINGIT_OUTTAB = lt_vbak[].

    ENDFORM. " display

    PROGRAM2(ALV REPORTING USING CLASSES):

    REPORT Z730AMALV1.

    data : lv_vbeln type vbak-vbeln.select-options : so_vbeln for lv_vbeln.

    types : begin of ty_vbak,vbeln type vbak-vbeln,erdat type vbak-erdat,erzet type vbak-erzet,ernam type vbak-ernam,

    end of ty_vbak.

    data : lt_vbak type standard table of ty_vbak.

    data : o_grid type ref to cl_gui_alv_grid,o_cont type ref to cl_gui_custom_container.

    initialization.so_vbeln-low = '4970'.so_vbeln-high = '4975'.append so_vbeln.

    start-of-selection.call screen 100.

    MODULE STATUS_0100 OUTPUT.if o_cont is initial.set pf-status 'ABC'.CREATE OBJECT O_CONT

    EXPORTINGCONTAINER_NAME = 'CST'.

    CREATE OBJECT O_GRIDEXPORTINGI_PARENT = o_cont.

  • 7/29/2019 22th Aug 730am Alv

    3/65

    perform getdata.if lt_vbak[] is not initial.

    perform display.endif.

    endif.

    ENDMODULE. " STATUS_0100 OUTPUT

    MODULE USER_COMMAND_0100 INPUT.case sy-ucomm.

    when 'BACK'.leave program.

    endcase.ENDMODULE. " USER_COMMAND_0100 INPUT

    FORM getdata .select vbeln erdat erzet ernam

    from vbakinto table lt_vbakwhere vbeln in so_vbeln.

    ENDFORM. " getdata

    FORM display .CALL METHOD O_GRID->SET_TABLE_FOR_FIRST_DISPLAYEXPORTING

    I_STRUCTURE_NAME = 'VBAK'CHANGING

    IT_OUTTAB = lt_vbak[].

    ENDFORM. " display

    PROGRAM3(ALV REPORTING USING CLASSES):report z730amalv1.

    data : lv_vbeln type vbak-vbeln.select-options : so_vbeln for lv_vbeln.

    types : begin of ty_vbak,vbeln type vbak-vbeln,erdat type vbak-erdat,

    erzet type vbak-erzet,ernam type vbak-ernam,end of ty_vbak.

    data : lt_vbak type standard table of ty_vbak.

    data : o_grid type ref to cl_gui_alv_grid,o_cont type ref to cl_gui_custom_container.

    initialization.

  • 7/29/2019 22th Aug 730am Alv

    4/65

    so_vbeln-low = '4970'.so_vbeln-high = '4975'.append so_vbeln.

    start-of-selection.call screen 100.

    module status_0100 output.if o_cont is initial.

    set pf-status 'ABC'.create object o_cont

    exportingcontainer_name = 'CST'.

    create object o_gridexportingi_parent = o_cont.

    perform getdata.if lt_vbak[] is not initial.

    perform display.endif.

    endif.

    endmodule. " STATUS_0100 OUTPUT

    module user_command_0100 input.case sy-ucomm.

    when 'BACK'.leave program.

    endcase.endmodule. " USER_COMMAND_0100 INPUT

    form getdata .select vbeln erdat erzet ernam

    from vbakinto table lt_vbakwhere vbeln in so_vbeln.

    endform. " getdata

    form display .call method o_grid->set_table_for_first_display

    exportingi_structure_name = 'ZMYVBAK'

    changingit_outtab = lt_vbak[].

    endform. " display

  • 7/29/2019 22th Aug 730am Alv

    5/65

    PROGRAM4(ALV REPORTING USING CLASSES):report z730amalv1.

    data : lv_vbeln type vbak-vbeln.select-options : so_vbeln for lv_vbeln.

    types : begin of ty_vbak,vbeln type vbak-vbeln,erdat type vbak-erdat,erzet type vbak-erzet,ernam type vbak-ernam,

    end of ty_vbak.

    data : lt_vbak type standard table of ty_vbak.

    data : o_grid type ref to cl_gui_alv_grid,o_cont type ref to cl_gui_custom_container.

    data : lt_fcat type lvc_t_fcat,

    * ls_fcat like line of lt_fcat,ls_fcat type lvc_s_fcat.

    initialization.so_vbeln-low = '4970'.so_vbeln-high = '4975'.append so_vbeln.

    start-of-selection.call screen 100.

    module status_0100 output.if o_cont is initial.

    set pf-status 'ABC'.create object o_cont

    exportingcontainer_name = 'CST'.

    create object o_gridexportingi_parent = o_cont.

    perform getdata.if lt_vbak[] is not initial.

    perform fldcat.perform display.

    endif.endif.

    endmodule. " STATUS_0100 OUTPUT

    module user_command_0100 input.case sy-ucomm.

  • 7/29/2019 22th Aug 730am Alv

    6/65

    when 'BACK'.leave program.

    endcase.endmodule. " USER_COMMAND_0100 INPUT

    form getdata .select vbeln erdat erzet ernamfrom vbakinto table lt_vbakwhere vbeln in so_vbeln.

    endform. " getdata

    form display .call method o_grid->set_table_for_first_display

    changingit_outtab = lt_vbak[]it_fieldcatalog = lt_fcat[].

    endform. " display

    form fldcat .call function 'LVC_FIELDCATALOG_MERGE'exportingi_structure_name = 'ZMYVBAK'changingct_fieldcat = lt_fcat[].

    endform. " fldcat

    PROGRAM5(ALV REPORTING USING CLASSES):

    REPORT Z730AMALV1.

    data : lv_vbeln type vbak-vbeln.select-options : so_vbeln for lv_vbeln.

    types : begin of ty_vbak,vbeln type vbak-vbeln,erdat type vbak-erdat,erzet type vbak-erzet,ernam type vbak-ernam,

    end of ty_vbak.

    data : lt_vbak type standard table of ty_vbak.

    data : o_grid type ref to cl_gui_alv_grid,o_cont type ref to cl_gui_custom_container.

    DATA : lt_fcat type lvc_t_fcat,* ls_fcat like line of lt_fcat,

    ls_fcat type lvc_s_fcat.

    initialization.

  • 7/29/2019 22th Aug 730am Alv

    7/65

    so_vbeln-low = '4970'.so_vbeln-high = '4975'.append so_vbeln.

    start-of-selection.call screen 100.

    MODULE STATUS_0100 OUTPUT.if o_cont is initial.

    set pf-status 'ABC'.CREATE OBJECT O_CONT

    EXPORTINGCONTAINER_NAME = 'CST'.

    CREATE OBJECT O_GRIDEXPORTINGI_PARENT = o_cont.

    perform getdata.if lt_vbak[] is not initial.

    perform fldcat.perform display.

    endif.endif.

    ENDMODULE. " STATUS_0100 OUTPUT

    MODULE USER_COMMAND_0100 INPUT.case sy-ucomm.

    when 'BACK'.leave program.

    endcase.ENDMODULE. " USER_COMMAND_0100 INPUT

    FORM getdata .select vbeln erdat erzet ernam

    from vbakinto table lt_vbakwhere vbeln in so_vbeln.

    ENDFORM. " getdata

    FORM display .

    CALL METHOD O_GRID->SET_TABLE_FOR_FIRST_DISPLAYCHANGINGIT_OUTTAB = lt_vbak[]IT_FIELDCATALOG = lt_fcat[].

    ENDFORM. " display

    FORM fldcat .

  • 7/29/2019 22th Aug 730am Alv

    8/65

    CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'EXPORTINGI_STRUCTURE_NAME = 'ZMYVBAK'CHANGINGCT_FIELDCAT = lt_fcat[].

    if lt_fcat[] is not initial.loop at lt_fcat into ls_fcat.if ls_fcat-fieldname = 'ERDAT'.

    ls_fcat-col_pos = 3.modify lt_fcat from ls_fcat

    transporting col_pos.elseif ls_fcat-fieldname = 'ERZET'.

    ls_fcat-col_pos = 2.ls_fcat-coltext = 'Creation time'.modify lt_fcat from ls_fcat

    transporting col_pos coltext.endif.

    endloop.endif.

    ENDFORM. " fldcat

    PROGRAM6(ALV REPORTING USING CLASSES):REPORT Z730AMALV1.

    data : lv_vbeln type vbak-vbeln.select-options : so_vbeln for lv_vbeln.

    types : begin of ty_vbak,vbeln type vbak-vbeln,erdat type vbak-erdat,

    erzet type vbak-erzet,ernam type vbak-ernam,end of ty_vbak.

    data : lt_vbak type standard table of ty_vbak.

    data : o_grid type ref to cl_gui_alv_grid,o_cont type ref to cl_gui_custom_container.

    DATA : lt_fcat type lvc_t_fcat.field-symbols like line of lt_fcat.

    initialization.so_vbeln-low = '4970'.so_vbeln-high = '4975'.append so_vbeln.

    start-of-selection.call screen 100.

    MODULE STATUS_0100 OUTPUT.if o_cont is initial.

  • 7/29/2019 22th Aug 730am Alv

    9/65

    set pf-status 'ABC'.CREATE OBJECT O_CONT

    EXPORTINGCONTAINER_NAME = 'CST'.

    CREATE OBJECT O_GRID

    EXPORTINGI_PARENT = o_cont.

    perform getdata.if lt_vbak[] is not initial.

    perform fldcat.perform display.

    endif.endif.

    ENDMODULE. " STATUS_0100 OUTPUT

    MODULE USER_COMMAND_0100 INPUT.case sy-ucomm.

    when 'BACK'.leave program.

    endcase.ENDMODULE. " USER_COMMAND_0100 INPUT

    FORM getdata .select vbeln erdat erzet ernam

    from vbakinto table lt_vbakwhere vbeln in so_vbeln.

    ENDFORM. " getdata

    FORM display .CALL METHOD O_GRID->SET_TABLE_FOR_FIRST_DISPLAY

    CHANGINGIT_OUTTAB = lt_vbak[]IT_FIELDCATALOG = lt_fcat[].

    ENDFORM. " display

    FORM fldcat .

    CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'EXPORTINGI_STRUCTURE_NAME = 'ZMYVBAK'CHANGINGCT_FIELDCAT = lt_fcat[].

    if lt_fcat[] is not initial.loop at lt_fcat assigning .

    if -fieldname = 'ERDAT'.

  • 7/29/2019 22th Aug 730am Alv

    10/65

    -col_pos = 3.elseif -fieldname = 'ERZET'.

    -col_pos = 2.-coltext = 'Creation time'.

    endif.endloop.

    endif.

    ENDFORM. " fldcat

    PROGRAM7(ALV REPORTING USING CLASSES):REPORT Z730AMALV1.

    data : lv_vbeln type vbak-vbeln.select-options : so_vbeln for lv_vbeln.

    types : begin of ty_vbak,vbeln type vbak-vbeln,erdat type vbak-erdat,

    erzet type vbak-erzet,ernam type vbak-ernam,

    end of ty_vbak.

    data : lt_vbak type standard table of ty_vbak.

    data : o_grid type ref to cl_gui_alv_grid,o_cont type ref to cl_gui_custom_container.

    DATA : lt_fcat type lvc_t_fcat,ls_fcat type lvc_s_fcat.

    initialization.so_vbeln-low = '4970'.so_vbeln-high = '4975'.append so_vbeln.

    start-of-selection.call screen 100.

    MODULE STATUS_0100 OUTPUT.if o_cont is initial.

    set pf-status 'ABC'.CREATE OBJECT O_CONT

    EXPORTING

    CONTAINER_NAME = 'CST'.

    CREATE OBJECT O_GRIDEXPORTINGI_PARENT = o_cont.

    perform getdata.if lt_vbak[] is not initial.

    perform fldcat.perform display.

  • 7/29/2019 22th Aug 730am Alv

    11/65

    endif.endif.

    ENDMODULE. " STATUS_0100 OUTPUT

    MODULE USER_COMMAND_0100 INPUT.case sy-ucomm.

    when 'BACK'.leave program.

    endcase.ENDMODULE. " USER_COMMAND_0100 INPUT

    FORM getdata .select vbeln erdat erzet ernam

    from vbakinto table lt_vbakwhere vbeln in so_vbeln.

    ENDFORM. " getdata

    FORM display .CALL METHOD O_GRID->SET_TABLE_FOR_FIRST_DISPLAY

    CHANGINGIT_OUTTAB = lt_vbak[]IT_FIELDCATALOG = lt_fcat[].

    ENDFORM. " display

    FORM fldcat .clear ls_fcat.ls_fcat-fieldname = 'VBELN'.ls_fcat-col_pos = 1.ls_fcat-coltext = 'Sales Doc'.ls_fcat-outputlen = 12.ls_fcat-tooltip = 'Sales Document'.append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'ERDAT'.ls_fcat-col_pos = 2.ls_fcat-coltext = 'Date'.ls_fcat-outputlen = 10.

    ls_fcat-tooltip = 'Creation date'.append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'ERZET'.ls_fcat-col_pos = 3.ls_fcat-coltext = 'Time'.ls_fcat-outputlen = 10.ls_fcat-tooltip = 'Creation Time'.

  • 7/29/2019 22th Aug 730am Alv

    12/65

    append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'ERNAM'.ls_fcat-col_pos = 4.ls_fcat-coltext = 'Person'.

    ls_fcat-outputlen = 10.ls_fcat-tooltip = 'Created by'.append ls_fcat to lt_fcat.

    ENDFORM. " fldcat

    PROGRAM8(ALV REPORTING USING CLASSES):REPORT Z730AMALV1.

    data : lv_vbeln type vbak-vbeln.select-options : so_vbeln for lv_vbeln.

    types : begin of ty_vbak,vbeln type vbak-vbeln,erdat type vbak-erdat,erzet type vbak-erzet,ernam type vbak-ernam,

    end of ty_vbak.

    data : lt_vbak type standard table of ty_vbak.

    data : o_grid type ref to cl_gui_alv_grid,o_cont type ref to cl_gui_custom_container,o_dock type ref to cl_gui_docking_container.

    DATA : lt_fcat type lvc_t_fcat,ls_fcat type lvc_s_fcat.

    data mode type i.

    initialization.so_vbeln-low = '4970'.so_vbeln-high = '4975'.append so_vbeln.

    start-of-selection.call screen 100.

    MODULE STATUS_0100 OUTPUT.set pf-status 'ABC'.CALL METHOD CL_GUI_ALV_GRID=>OFFLINE

    RECEIVINGE_OFFLINE = mode.

    if mode eq 0.if o_cont is initial.CREATE OBJECT O_CONTEXPORTING

    CONTAINER_NAME = 'CST'.

  • 7/29/2019 22th Aug 730am Alv

    13/65

    CREATE OBJECT O_GRIDEXPORTINGI_PARENT = o_cont.

    endif.else.

    CREATE OBJECT O_GRIDEXPORTINGI_PARENT = o_dock.

    endif.perform getdata.if lt_vbak[] is not initial.

    perform fldcat.perform display.

    endif.

    ENDMODULE. " STATUS_0100 OUTPUT

    MODULE USER_COMMAND_0100 INPUT.case sy-ucomm.

    when 'BACK'.leave program.

    endcase.ENDMODULE. " USER_COMMAND_0100 INPUT

    FORM getdata .select vbeln erdat erzet ernam

    from vbakinto table lt_vbakwhere vbeln in so_vbeln.

    ENDFORM. " getdata

    FORM display .CALL METHOD O_GRID->SET_TABLE_FOR_FIRST_DISPLAY

    CHANGINGIT_OUTTAB = lt_vbak[]IT_FIELDCATALOG = lt_fcat[].

    ENDFORM. " display

    FORM fldcat .clear ls_fcat.

    ls_fcat-fieldname = 'VBELN'.ls_fcat-col_pos = 1.ls_fcat-coltext = 'Sales Doc'.ls_fcat-outputlen = 12.ls_fcat-tooltip = 'Sales Document'.append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'ERDAT'.

  • 7/29/2019 22th Aug 730am Alv

    14/65

    ls_fcat-col_pos = 2.ls_fcat-coltext = 'Date'.ls_fcat-outputlen = 10.ls_fcat-tooltip = 'Creation date'.append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'ERZET'.ls_fcat-col_pos = 3.ls_fcat-coltext = 'Time'.ls_fcat-outputlen = 10.ls_fcat-tooltip = 'Creation Time'.append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'ERNAM'.ls_fcat-col_pos = 4.ls_fcat-coltext = 'Person'.ls_fcat-outputlen = 10.ls_fcat-tooltip = 'Created by'.append ls_fcat to lt_fcat.

    ENDFORM. " fldcat

    PROGRAM9(ALV REPORTING USING CLASSES):REPORT Z730AMALV1.

    data : lv_vbeln type vbak-vbeln.select-options : so_vbeln for lv_vbeln.

    types : begin of ty_vbak,

    vbeln type vbak-vbeln,erdat type vbak-erdat,erzet type vbak-erzet,ernam type vbak-ernam,

    end of ty_vbak.

    data : lt_vbak type standard table of ty_vbak.

    data : o_grid type ref to cl_gui_alv_grid,o_cont type ref to cl_gui_custom_container.

    DATA : lt_fcat type lvc_t_fcat,ls_fcat type lvc_s_fcat.

    data : ls_layo type lvc_s_layo.

    initialization.so_vbeln-low = '4970'.so_vbeln-high = '4975'.append so_vbeln.

    start-of-selection.call screen 100.

  • 7/29/2019 22th Aug 730am Alv

    15/65

    MODULE STATUS_0100 OUTPUT.if o_cont is initial.

    set pf-status 'ABC'.CREATE OBJECT O_CONT

    EXPORTING

    CONTAINER_NAME = 'CST'.

    CREATE OBJECT O_GRIDEXPORTINGI_PARENT = o_cont.

    perform getdata.if lt_vbak[] is not initial.

    perform fldcat.perform layout.perform display.

    endif.endif.

    ENDMODULE. " STATUS_0100 OUTPUT

    MODULE USER_COMMAND_0100 INPUT.case sy-ucomm.

    when 'BACK'.leave program.

    endcase.ENDMODULE. " USER_COMMAND_0100 INPUT

    FORM getdata .select vbeln erdat erzet ernam

    from vbakinto table lt_vbakwhere vbeln in so_vbeln.

    ENDFORM. " getdata

    FORM display .CALL METHOD O_GRID->SET_TABLE_FOR_FIRST_DISPLAY

    EXPORTINGIS_LAYOUT = ls_layo

    CHANGINGIT_OUTTAB = lt_vbak[]

    IT_FIELDCATALOG = lt_fcat[].

    ENDFORM. " display

    FORM fldcat .clear ls_fcat.ls_fcat-fieldname = 'VBELN'.ls_fcat-col_pos = 1.

  • 7/29/2019 22th Aug 730am Alv

    16/65

    ls_fcat-coltext = 'Sales Doc'.ls_fcat-outputlen = 12.ls_fcat-tooltip = 'Sales Document'.append ls_fcat to lt_fcat.

    clear ls_fcat.

    ls_fcat-fieldname = 'ERDAT'.ls_fcat-col_pos = 2.ls_fcat-coltext = 'Date'.ls_fcat-outputlen = 10.ls_fcat-tooltip = 'Creation date'.append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'ERZET'.ls_fcat-col_pos = 3.ls_fcat-coltext = 'Time'.ls_fcat-outputlen = 10.ls_fcat-tooltip = 'Creation Time'.append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'ERNAM'.ls_fcat-col_pos = 4.ls_fcat-coltext = 'Person'.ls_fcat-outputlen = 10.ls_fcat-tooltip = 'Created by'.append ls_fcat to lt_fcat.

    ENDFORM. " fldcat

    FORM layout .clear ls_layo.ls_layo-grid_title = 'SALES DOCUMENT HEADER DATA'.ls_layo-zebra = 'X'.

    ENDFORM. " layout

    PROGRAM10(ALV REPORTING USING CLASSES):REPORT Z730AMALV1.

    data : lv_vbeln type vbak-vbeln.select-options : so_vbeln for lv_vbeln.

    types : begin of ty_vbak,color(4) type c,vbeln type vbak-vbeln,erdat type vbak-erdat,erzet type vbak-erzet,ernam type vbak-ernam,

    end of ty_vbak.

    data : lt_vbak type standard table of ty_vbak,ls_vbak type ty_vbak.

  • 7/29/2019 22th Aug 730am Alv

    17/65

    data : o_grid type ref to cl_gui_alv_grid,o_cont type ref to cl_gui_custom_container.

    DATA : lt_fcat type lvc_t_fcat,ls_fcat type lvc_s_fcat.

    data : ls_layo type lvc_s_layo.

    initialization.so_vbeln-low = '4970'.so_vbeln-high = '4975'.append so_vbeln.

    start-of-selection.call screen 100.

    MODULE STATUS_0100 OUTPUT.if o_cont is initial.

    set pf-status 'ABC'.CREATE OBJECT O_CONT

    EXPORTINGCONTAINER_NAME = 'CST'.

    CREATE OBJECT O_GRIDEXPORTINGI_PARENT = o_cont.

    perform getdata.if lt_vbak[] is not initial.

    perform fldcat.perform colourrows.perform layout.perform display.

    endif.endif.

    ENDMODULE. " STATUS_0100 OUTPUT

    MODULE USER_COMMAND_0100 INPUT.case sy-ucomm.

    when 'BACK'.leave program.

    endcase.

    ENDMODULE. " USER_COMMAND_0100 INPUT

    FORM getdata .select vbeln erdat erzet ernam

    from vbakinto corresponding fields of table lt_vbakwhere vbeln in so_vbeln.

    ENDFORM. " getdata

  • 7/29/2019 22th Aug 730am Alv

    18/65

    FORM display .CALL METHOD O_GRID->SET_TABLE_FOR_FIRST_DISPLAY

    EXPORTINGIS_LAYOUT = ls_layo

    CHANGINGIT_OUTTAB = lt_vbak[]IT_FIELDCATALOG = lt_fcat[].

    ENDFORM. " display

    FORM fldcat .clear ls_fcat.ls_fcat-fieldname = 'VBELN'.ls_fcat-col_pos = 1.ls_fcat-coltext = 'Sales Doc'.ls_fcat-outputlen = 12.ls_fcat-tooltip = 'Sales Document'.append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'ERDAT'.ls_fcat-col_pos = 2.ls_fcat-coltext = 'Date'.ls_fcat-outputlen = 10.ls_fcat-tooltip = 'Creation date'.append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'ERZET'.ls_fcat-col_pos = 3.ls_fcat-coltext = 'Time'.ls_fcat-outputlen = 10.ls_fcat-tooltip = 'Creation Time'.append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'ERNAM'.ls_fcat-col_pos = 4.ls_fcat-coltext = 'Person'.ls_fcat-outputlen = 10.ls_fcat-tooltip = 'Created by'.

    * ls_fcat-emphasize = 'C510'. "column coloringappend ls_fcat to lt_fcat.

    ENDFORM. " fldcat

    FORM colourrows .loop at lt_vbak into ls_vbak.

    if ls_vbak-erdat = '19970103'.ls_vbak-color = 'C016'.

  • 7/29/2019 22th Aug 730am Alv

    19/65

    elseif ls_vbak-erdat = '19970107'.ls_vbak-color = 'C103'.

    else.ls_vbak-color = 'C410'.

    endif.modify lt_vbak from ls_vbak transporting color.

    endloop.ENDFORM. " colourrows

    FORM layout .clear ls_layo.ls_layo-info_fname = 'COLOR'.

    ENDFORM. " layout

    PROGRAM11(ALV REPORTING USING CLASSES):report z730amalv1.

    data : lv_vbeln type vbak-vbeln.select-options : so_vbeln for lv_vbeln.

    types : begin of ty_vbak,lights type c,vbeln type vbak-vbeln,erdat type vbak-erdat,erzet type vbak-erzet,ernam type vbak-ernam,

    end of ty_vbak.

    data : lt_vbak type standard table of ty_vbak,ls_vbak type ty_vbak.

    data : o_grid type ref to cl_gui_alv_grid,o_cont type ref to cl_gui_custom_container.

    data : lt_fcat type lvc_t_fcat,ls_fcat type lvc_s_fcat.

    data : ls_layo type lvc_s_layo.

    initialization.so_vbeln-low = '4970'.so_vbeln-high = '4975'.append so_vbeln.

    start-of-selection.call screen 100.

    module status_0100 output.if o_cont is initial.

    set pf-status 'ABC'.create object o_cont

    exportingcontainer_name = 'CST'.

    create object o_gridexporting

  • 7/29/2019 22th Aug 730am Alv

    20/65

    i_parent = o_cont.

    perform getdata.if lt_vbak[] is not initial.

    perform fldcat.perform trafficlights.

    perform layout.perform display.endif.

    endif.

    endmodule. " STATUS_0100 OUTPUT

    module user_command_0100 input.case sy-ucomm.

    when 'BACK'.leave program.

    endcase.endmodule. " USER_COMMAND_0100 INPUT

    form getdata .select vbeln erdat erzet ernam

    from vbakinto corresponding fields of table lt_vbakwhere vbeln in so_vbeln.

    endform. " getdata

    form display .call method o_grid->set_table_for_first_display

    exportingis_layout = ls_layo

    changingit_outtab = lt_vbak[]it_fieldcatalog = lt_fcat[].

    endform. " display

    form fldcat .clear ls_fcat.

    ls_fcat-fieldname = 'VBELN'. ls_fcat-tooltip = 'Sales Document'.

    ls_fcat-col_pos = 1.ls_fcat-coltext = 'Sales Doc'.ls_fcat-outputlen = 12.

    append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'ERDAT'.ls_fcat-col_pos = 2.

  • 7/29/2019 22th Aug 730am Alv

    21/65

    ls_fcat-coltext = 'Date'.ls_fcat-outputlen = 10.ls_fcat-tooltip = 'Creation date'.append ls_fcat to lt_fcat.

    clear ls_fcat.

    ls_fcat-fieldname = 'ERZET'.ls_fcat-col_pos = 3.ls_fcat-coltext = 'Time'.ls_fcat-outputlen = 10.ls_fcat-tooltip = 'Creation Time'.append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'ERNAM'.ls_fcat-col_pos = 4.ls_fcat-coltext = 'Person'.ls_fcat-outputlen = 10.ls_fcat-tooltip = 'Created by'.

    * ls_fcat-emphasize = 'C510'. "column coloringappend ls_fcat to lt_fcat.

    endform. " fldcat

    form trafficlights.loop at lt_vbak into ls_vbak.

    if ls_vbak-erdat = '19970103'.ls_vbak-lights = '1'.

    elseif ls_vbak-erdat = '19970107'.ls_vbak-lights = '2'.

    else.ls_vbak-lights = '3'.

    endif.modify lt_vbak from ls_vbak transporting lights.

    endloop.endform. " colourrows

    form layout .clear ls_layo.ls_layo-excp_fname = 'LIGHTS'.

    endform. " layout

    PROGRAM12(ALV REPORTING USING CLASSES):

    REPORT Z730AMALV1.

    data : lv_vbeln type vbak-vbeln.select-options : so_vbeln for lv_vbeln.

    types : begin of ty_vbak,product(10) type c,vbeln type vbak-vbeln,erdat type vbak-erdat,

  • 7/29/2019 22th Aug 730am Alv

    22/65

    erzet type vbak-erzet,ernam type vbak-ernam,

    end of ty_vbak.

    data : lt_vbak type standard table of ty_vbak,ls_vbak type ty_vbak.

    data : o_grid type ref to cl_gui_alv_grid,o_cont type ref to cl_gui_custom_container.

    DATA : lt_fcat type lvc_t_fcat,ls_fcat type lvc_s_fcat.

    data : ls_layo type lvc_s_layo.

    data : lt_drop type lvc_t_drop,ls_drop type lvc_s_drop.

    initialization.so_vbeln-low = '4970'.so_vbeln-high = '4975'.append so_vbeln.

    start-of-selection.call screen 100.

    MODULE STATUS_0100 OUTPUT.if o_cont is initial.

    set pf-status 'ABC'.CREATE OBJECT O_CONT

    EXPORTINGCONTAINER_NAME = 'CST'.

    CREATE OBJECT O_GRIDEXPORTINGI_PARENT = o_cont.

    perform getdata.if lt_vbak[] is not initial.

    perform fldcat.perform layout.perform dropdown.perform display.

    endif.endif.

    ENDMODULE. " STATUS_0100 OUTPUT

    MODULE USER_COMMAND_0100 INPUT.case sy-ucomm.

    when 'BACK'.leave program.

    endcase.

  • 7/29/2019 22th Aug 730am Alv

    23/65

    ENDMODULE. " USER_COMMAND_0100 INPUT

    FORM getdata .select vbeln erdat erzet ernam

    from vbak

    into corresponding fields of table lt_vbakwhere vbeln in so_vbeln.ENDFORM. " getdata

    FORM display .CALL METHOD O_GRID->SET_TABLE_FOR_FIRST_DISPLAY

    EXPORTINGIS_LAYOUT = ls_layo

    CHANGINGIT_OUTTAB = lt_vbak[]IT_FIELDCATALOG = lt_fcat[].

    ENDFORM. " display

    FORM fldcat .

    clear ls_fcat.ls_fcat-fieldname = 'PRODUCT'.ls_fcat-tooltip = 'Course'.ls_fcat-col_pos = 1.ls_fcat-coltext = 'Course'.ls_fcat-outputlen = 10.ls_fcat-drdn_hndl = 25.ls_fcat-edit = 'X'.

    append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'VBELN'.ls_fcat-tooltip = 'Sales Document'.ls_fcat-col_pos = 2.ls_fcat-coltext = 'Sales Doc'.ls_fcat-outputlen = 12.

    append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'ERDAT'.ls_fcat-col_pos = 3.

    ls_fcat-coltext = 'Date'.ls_fcat-outputlen = 10.ls_fcat-tooltip = 'Creation date'.append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'ERZET'.ls_fcat-col_pos = 4.ls_fcat-coltext = 'Time'.

  • 7/29/2019 22th Aug 730am Alv

    24/65

    ls_fcat-outputlen = 10.ls_fcat-tooltip = 'Creation Time'.append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'ERNAM'.

    ls_fcat-col_pos = 5.ls_fcat-coltext = 'Person'.ls_fcat-outputlen = 10.ls_fcat-tooltip = 'Created by'.

    * ls_fcat-emphasize = 'C510'. "column coloringappend ls_fcat to lt_fcat.

    ENDFORM. " fldcat

    FORM layout .clear ls_layo.

    ENDFORM. " layout

    FORM dropdown .clear ls_drop.ls_drop-handle = 25.ls_drop-value = 'ABAP'.append ls_drop to lt_drop.

    clear ls_drop.ls_drop-handle = 25.ls_drop-value = 'OOPSABAP'.append ls_drop to lt_drop.

    clear ls_drop.ls_drop-handle = 25.ls_drop-value = 'WEBDYNPRO'.append ls_drop to lt_drop.

    CALL METHOD O_GRID->SET_DROP_DOWN_TABLEEXPORTINGIT_DROP_DOWN = lt_drop[].

    ENDFORM. " dropdown

    PROGRAM13(ALV REPORTING USING CLASSES):REPORT Z730AMALV1.

    data : lv_vbeln type vbak-vbeln.select-options : so_vbeln for lv_vbeln.

    types : begin of ty_vbak,vbeln type vbak-vbeln,erdat type vbak-erdat,

  • 7/29/2019 22th Aug 730am Alv

    25/65

    erzet type vbak-erzet,ernam type vbak-ernam,

    end of ty_vbak.

    data : lt_vbak type standard table of ty_vbak,ls_vbak type ty_vbak.

    data : o_grid type ref to cl_gui_alv_grid,o_cont type ref to cl_gui_custom_container.

    DATA : lt_fcat type lvc_t_fcat,ls_fcat type lvc_s_fcat.

    data : ls_layo type lvc_s_layo.

    data : lt_drop type lvc_t_drop,ls_drop type lvc_s_drop.

    data : lt_fcodes type ui_functions,lv_fcode type ui_func.

    initialization.so_vbeln-low = '4970'.so_vbeln-high = '4975'.append so_vbeln.

    start-of-selection.call screen 100.

    MODULE STATUS_0100 OUTPUT.if o_cont is initial.

    set pf-status 'ABC'.CREATE OBJECT O_CONT

    EXPORTINGCONTAINER_NAME = 'CST'.

    CREATE OBJECT O_GRIDEXPORTINGI_PARENT = o_cont.

    perform getdata.if lt_vbak[] is not initial.

    perform fldcat.perform layout.perform exclude.perform display.

    endif.

    endif.

    ENDMODULE. " STATUS_0100 OUTPUT

    MODULE USER_COMMAND_0100 INPUT.case sy-ucomm.

    when 'BACK'.

  • 7/29/2019 22th Aug 730am Alv

    26/65

    leave program.endcase.

    ENDMODULE. " USER_COMMAND_0100 INPUT

    FORM getdata .

    select vbeln erdat erzet ernamfrom vbakinto table lt_vbakwhere vbeln in so_vbeln.

    ENDFORM. " getdata

    FORM display .CALL METHOD O_GRID->SET_TABLE_FOR_FIRST_DISPLAY

    EXPORTINGIS_LAYOUT = ls_layoIT_TOOLBAR_EXCLUDING = lt_fcodes[]

    CHANGINGIT_OUTTAB = lt_vbak[]IT_FIELDCATALOG = lt_fcat[].

    ENDFORM. " display

    FORM fldcat .

    clear ls_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'VBELN'.ls_fcat-tooltip = 'Sales Document'.ls_fcat-col_pos = 1.ls_fcat-coltext = 'Sales Doc'.ls_fcat-outputlen = 12.ls_fcat-style = cl_gui_alv_grid=>MC_STYLE_BUTTON.

    append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'ERDAT'.ls_fcat-col_pos = 2.ls_fcat-coltext = 'Date'.ls_fcat-outputlen = 10.ls_fcat-tooltip = 'Creation date'.append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'ERZET'.ls_fcat-col_pos = 3.ls_fcat-coltext = 'Time'.ls_fcat-outputlen = 10.ls_fcat-tooltip = 'Creation Time'.append ls_fcat to lt_fcat.

    clear ls_fcat.

  • 7/29/2019 22th Aug 730am Alv

    27/65

    ls_fcat-fieldname = 'ERNAM'.ls_fcat-col_pos = 4.ls_fcat-coltext = 'Person'.ls_fcat-outputlen = 10.ls_fcat-tooltip = 'Created by'.

    * ls_fcat-emphasize = 'C510'. "column coloring

    append ls_fcat to lt_fcat.

    ENDFORM. " fldcat

    FORM layout .clear ls_layo.

    ENDFORM. " layout

    FORM exclude .clear lv_fcode.lv_fcode = cl_gui_alv_grid=>mc_fc_find.append lv_fcode to lt_fcodes.

    clear lv_fcode.lv_fcode = cl_gui_alv_grid=>mc_fc_print.append lv_fcode to lt_fcodes.

    ENDFORM. " exclude

    PROGRAM14(ALV REPORTING USING CLASSES):REPORT Z730AMALV1.

    data : lv_vbeln type vbak-vbeln.select-options : so_vbeln for lv_vbeln.

    types : begin of ty_vbak,cellstyles type lvc_t_styl,vbeln type vbak-vbeln,erdat type vbak-erdat,erzet type vbak-erzet,ernam type vbak-ernam,

    end of ty_vbak.

    data : lt_vbak type standard table of ty_vbak,

    ls_vbak type ty_vbak.

    data : o_grid type ref to cl_gui_alv_grid,o_cont type ref to cl_gui_custom_container.

    DATA : lt_fcat type lvc_t_fcat,ls_fcat type lvc_s_fcat.

    data : ls_layo type lvc_s_layo.

  • 7/29/2019 22th Aug 730am Alv

    28/65

    initialization.so_vbeln-low = '4970'.so_vbeln-high = '4975'.append so_vbeln.

    start-of-selection.

    call screen 100.

    MODULE STATUS_0100 OUTPUT.if o_cont is initial.

    set pf-status 'ABC'.CREATE OBJECT O_CONT

    EXPORTINGCONTAINER_NAME = 'CST'.

    CREATE OBJECT O_GRIDEXPORTINGI_PARENT = o_cont.

    perform getdata.if lt_vbak[] is not initial.

    perform fldcat.perform styles.perform layout.perform display.

    endif.endif.

    ENDMODULE. " STATUS_0100 OUTPUT

    MODULE USER_COMMAND_0100 INPUT.case sy-ucomm.

    when 'BACK'.leave program.

    endcase.ENDMODULE. " USER_COMMAND_0100 INPUT

    FORM getdata .select vbeln erdat erzet ernam

    from vbakinto corresponding fields of table lt_vbakwhere vbeln in so_vbeln.

    ENDFORM. " getdata

    FORM display .CALL METHOD O_GRID->SET_TABLE_FOR_FIRST_DISPLAY

    EXPORTINGIS_LAYOUT = ls_layo

    CHANGINGIT_OUTTAB = lt_vbak[]IT_FIELDCATALOG = lt_fcat[].

  • 7/29/2019 22th Aug 730am Alv

    29/65

    ENDFORM. " display

    FORM fldcat .

    clear ls_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'VBELN'.ls_fcat-tooltip = 'Sales Document'.ls_fcat-col_pos = 1.ls_fcat-coltext = 'Sales Doc'.ls_fcat-outputlen = 12.

    append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'ERDAT'.ls_fcat-col_pos = 2.ls_fcat-coltext = 'Date'.ls_fcat-outputlen = 10.ls_fcat-tooltip = 'Creation date'.append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'ERZET'.ls_fcat-col_pos = 3.ls_fcat-coltext = 'Time'.ls_fcat-outputlen = 10.ls_fcat-tooltip = 'Creation Time'.append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'ERNAM'.ls_fcat-col_pos = 4.ls_fcat-coltext = 'Person'.ls_fcat-outputlen = 10.ls_fcat-tooltip = 'Created by'.append ls_fcat to lt_fcat.

    ENDFORM. " fldcat

    FORM styles .data : ls_styl type lvc_s_styl.

    loop at lt_vbak into ls_vbak.if ls_vbak-erdat = '19970121'.ls_Styl-fieldname = 'VBELN'.ls_styl-style = cl_gui_alv_grid=>mc_style_button.append ls_styl to ls_vbak-cellstyles.modify lt_vbak from ls_vbak

    transporting cellstyles.endif.

    endloop.

  • 7/29/2019 22th Aug 730am Alv

    30/65

    ENDFORM. " styles

    FORM layout .clear ls_layo.ls_layo-stylefname = 'CELLSTYLES'.

    ENDFORM. " layoutPROGRAM15(ALV REPORTING USING CLASSES):REPORT Z730AMALV14.

    data : lv_vbeln type vbak-vbeln.data : lv_matnr type matnr.select-options : so_vbeln for lv_vbeln.

    types : begin of ty_vbak,vbeln type vbak-vbeln,erdat type vbak-erdat,erzet type vbak-erzet,ernam type vbak-ernam,

    end of ty_vbak.

    data : lt_vbak type standard table of ty_vbak,ls_vbak type ty_vbak.

    types : begin of ty_vbap,vbeln type vbap-vbeln,posnr type vbap-posnr,matnr type vbap-matnr,

    end of ty_vbap.

    data : lt_vbap type standard table of ty_vbap,ls_vbap type ty_vbap.

    types : begin of ty_mara,matnr type mara-matnr,mtart type mara-mtart,matkl type mara-matkl,

    end of ty_mara.

    data : lt_mara type standard table of ty_mara,ls_mara type ty_mara.

    data : o_grid type ref to cl_gui_alv_grid,o_cont type ref to cl_gui_custom_container.

    data : o_grid1 type ref to cl_gui_alv_grid,o_cont1 type ref to cl_gui_custom_container.

    data : o_grid2 type ref to cl_gui_alv_grid,o_cont2 type ref to cl_gui_custom_container.

    DATA : lt_fcat type lvc_t_fcat,ls_fcat type lvc_s_fcat.

  • 7/29/2019 22th Aug 730am Alv

    31/65

    data : ls_layo type lvc_s_layo.

    class lcl_eventreceiver definition.public section.methods : handle_hotspot_click

    for event hotspot_click of cl_gui_alv_gridimporting e_row_id.methods : handle_double_click

    for event double_click of cl_gui_alv_gridimporting e_row.

    methods : handle_button_clickfor event button_click of cl_gui_alv_gridimporting es_row_no.

    endclass.

    class lcl_eventreceiver implementation.method handle_hotspot_click.

    read table lt_vbak into ls_vbakindex e_row_id-index.

    if sy-subrc eq 0.lv_vbeln = ls_vbak-vbeln.if lv_vbeln is not initial.

    perform getvbap.if lt_vbap[] is not initial.

    call screen 200.endif.

    endif.endif.

    endmethod.

    method handle_double_click.read table lt_vbap into ls_vbap

    index e_row-index.if sy-subrc eq 0.

    lv_matnr = ls_vbap-matnr.if lv_matnr is not initial.

    perform getmara.if lt_mara[] is not initial.

    call screen 300.else.message 'No material data' type 'I'.

    endif.endif.

    endif.endmethod.

    method handle_button_click.read table lt_mara into ls_mara

    index es_row_no-row_id.if sy-subrc eq 0.clear lv_matnr.lv_matnr = ls_mara-matnr.set parameter id 'MAT' field lv_matnr.call transaction 'MM02'.

  • 7/29/2019 22th Aug 730am Alv

    32/65

    endif.endmethod.

    endclass.

    data ob type ref to lcl_eventreceiver.

    initialization.so_vbeln-low = '4970'.so_vbeln-high = '4975'.append so_vbeln.

    start-of-selection.call screen 100.

    MODULE STATUS_0100 OUTPUT.if o_cont is initial.

    set pf-status 'ABC'.CREATE OBJECT O_CONT

    EXPORTINGCONTAINER_NAME = 'CST'.

    CREATE OBJECT O_GRIDEXPORTINGI_PARENT = o_cont.

    perform getdata.if lt_vbak[] is not initial.

    perform fldcat.perform layout.perform register.perform display.

    endif.endif.

    ENDMODULE. " STATUS_0100 OUTPUT

    MODULE USER_COMMAND_0100 INPUT.case sy-ucomm.

    when 'BACK'.leave program.

    endcase.ENDMODULE. " USER_COMMAND_0100 INPUT

    FORM getdata .select vbeln erdat erzet ernam

    from vbakinto table lt_vbakwhere vbeln in so_vbeln.

    ENDFORM. " getdata

    FORM display .

  • 7/29/2019 22th Aug 730am Alv

    33/65

    CALL METHOD O_GRID->SET_TABLE_FOR_FIRST_DISPLAYEXPORTINGIS_LAYOUT = ls_layo

    CHANGINGIT_OUTTAB = lt_vbak[]IT_FIELDCATALOG = lt_fcat[].

    ENDFORM. " display

    FORM fldcat .

    clear ls_fcat.ls_fcat-fieldname = 'VBELN'.ls_fcat-tooltip = 'Sales Document'.ls_fcat-col_pos = 1.ls_fcat-coltext = 'Sales Doc'.ls_fcat-outputlen = 12.ls_fcat-hotspot = 'X'.

    append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'ERDAT'.ls_fcat-col_pos = 2.ls_fcat-coltext = 'Date'.ls_fcat-outputlen = 10.ls_fcat-tooltip = 'Creation date'.append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'ERZET'.ls_fcat-col_pos = 3.ls_fcat-coltext = 'Time'.ls_fcat-outputlen = 10.ls_fcat-tooltip = 'Creation Time'.append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'ERNAM'.ls_fcat-col_pos = 4.ls_fcat-coltext = 'Person'.ls_fcat-outputlen = 10.ls_fcat-tooltip = 'Created by'.append ls_fcat to lt_fcat.

    ENDFORM. " fldcat

    FORM layout .clear ls_layo.ls_layo-grid_title = 'SALES DOCUMENT HEADER DATA'.

    ENDFORM. " layout

  • 7/29/2019 22th Aug 730am Alv

    34/65

    FORM register .create object ob.set handler ob->handle_hotspot_click for o_grid.

    ENDFORM. " register

    FORM getvbap .select vbeln posnr matnr

    from vbapinto table lt_vbapwhere vbeln = lv_vbeln.

    ENDFORM. " getvbap

    FORM fldcatvbap .refresh lt_fcat.clear ls_fcat.ls_fcat-fieldname = 'VBELN'.ls_fcat-col_pos = 1.ls_fcat-coltext = 'Sales Doc'.ls_fcat-outputlen = 10.append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'POSNR'.ls_fcat-col_pos = 2.ls_fcat-coltext = 'Item No'.ls_fcat-outputlen = 5.append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'MATNR'.ls_fcat-col_pos = 3.ls_fcat-coltext = 'Material'.ls_fcat-outputlen = 10.append ls_fcat to lt_fcat.

    ENDFORM. " fldcatvbap

    MODULE STATUS_0200 OUTPUT.SET PF-STATUS 'PQR'.

    if o_cont1 is initial.CREATE OBJECT O_CONT1

    EXPORTINGCONTAINER_NAME = 'CST1'.

    CREATE OBJECT O_GRID1EXPORTINGI_PARENT = o_cont1.

    perform fldcatvbap.

  • 7/29/2019 22th Aug 730am Alv

    35/65

    perform layoutvbap.perform registerhandler.perform displayvbap.

    else.CALL METHOD O_GRID1->REFRESH_TABLE_DISPLAY.

    endif.

    ENDMODULE. " STATUS_0200 OUTPUT

    FORM displayvbap .CALL METHOD O_GRID1->SET_TABLE_FOR_FIRST_DISPLAY

    EXPORTINGIS_LAYOUT = ls_layo

    CHANGINGIT_OUTTAB = lt_vbap[]IT_FIELDCATALOG = lt_fcat[].

    ENDFORM. " displayvbap

    FORM layoutvbap .clear ls_layo.ls_layo-grid_title = 'SALES DOCUMENT ITEM DATA'.

    ENDFORM. " layoutvbap

    MODULE USER_COMMAND_0200 INPUT.case sy-ucomm.when 'BACK'.leave to screen 100.

    endcase.ENDMODULE. " USER_COMMAND_0200 INPUT

    FORM registerhandler .create object ob.set handler ob->handle_double_click for o_grid1.

    ENDFORM. " registerhandler

    FORM getmara .select single matnr mtart matkl

    from marainto ls_marawhere matnr = lv_matnr.

    if sy-subrc eq 0.refresh lt_mara.append ls_mara to lt_mara.

    endif.ENDFORM. " getmara

    MODULE STATUS_0300 OUTPUT.SET PF-STATUS 'LMN'.if o_cont2 is initial.

  • 7/29/2019 22th Aug 730am Alv

    36/65

    CREATE OBJECT O_CONT2EXPORTING

    CONTAINER_NAME = 'CST2'.

    CREATE OBJECT O_GRID2EXPORTING

    I_PARENT = o_cont2.

    perform fldcatmara.perform layoutmara.perform register_handlers.perform displaymara.

    else.CALL METHOD O_GRID2->REFRESH_TABLE_DISPLAY.

    endif.ENDMODULE. " STATUS_0300 OUTPUT

    FORM fldcatmara .refresh lt_fcat.clear ls_fcat.ls_fcat-fieldname = 'MATNR'.ls_fcat-col_pos = 1.ls_fcat-coltext = 'Material'.ls_fcat-outputlen = 10.ls_fcat-style = cl_gui_alv_grid=>MC_STYLE_BUTTON.append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'MTART'.ls_fcat-col_pos = 2.ls_fcat-coltext = 'Material Type'.ls_fcat-outputlen = 10.append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'MATKL'.ls_fcat-col_pos = 3.ls_fcat-coltext = 'Material Group'.ls_fcat-outputlen = 10.append ls_fcat to lt_fcat.

    ENDFORM. " fldcatmara

    FORM layoutmara .clear ls_layo.ls_layo-grid_title = 'MATERIAL DATA'.

    ENDFORM. " layoutmara

    FORM displaymara .CALL METHOD O_GRID2->SET_TABLE_FOR_FIRST_DISPLAY

    EXPORTINGIS_LAYOUT = ls_layo

  • 7/29/2019 22th Aug 730am Alv

    37/65

    CHANGINGIT_OUTTAB = lt_mara[]IT_FIELDCATALOG = lt_fcat[].

    ENDFORM. " displaymara

    MODULE USER_COMMAND_0300 INPUT.case sy-ucomm.

    when 'BACK'.leave to screen 200.

    endcase.ENDMODULE. " USER_COMMAND_0300 INPUT

    FORM register_handlers .create object ob.set handler ob->handle_button_click for o_grid2.

    ENDFORM. " register_handlers

    PROGRAM16(ALV REPORTING USING CLASSES):report z730amalv16.type-pools icon.

    data : lv_vbeln type vbak-vbeln.

    select-options : so_vbeln for lv_vbeln.

    types : begin of ty_vbak,vbeln type vbak-vbeln,erdat type vbak-erdat,erzet type vbak-erzet,ernam type vbak-ernam,

    end of ty_vbak.

    data : lt_vbak type standard table of ty_vbak,gt_vbak type standard table of ty_vbak,ls_vbak type ty_vbak.

    data : o_grid type ref to cl_gui_alv_grid,o_cont type ref to cl_gui_custom_container.

    data : o_grid1 type ref to cl_gui_alv_grid,o_cont1 type ref to cl_gui_custom_container.

    data : lt_rows type lvc_t_row,ls_rows type lvc_s_row.

    data : lt_fcat type lvc_t_fcat,ls_fcat type lvc_s_fcat.

    data : ls_layo type lvc_s_layo.

    data : ls_toolbar type stb_button.

    class lcl_eventreceiver definition.

  • 7/29/2019 22th Aug 730am Alv

    38/65

    public section.methods : handle_toolbar

    for event toolbar of cl_gui_alv_gridimporting e_object.

    methods : handle_menu_button

    for event menu_button of cl_gui_alv_gridimporting e_object e_ucomm.

    methods : handle_user_commandfor event user_command of cl_gui_alv_gridimporting e_ucomm.

    endclass.

    class lcl_eventreceiver implementation.method handle_toolbar.

    * For disablingloop at e_object->mt_toolbar into ls_toolbar.

    if ls_toolbar-function = cl_gui_alv_grid=>mc_fc_find.ls_toolbar-disabled = 'X'.modify e_object->mt_toolbar from ls_toolbar

    transporting disabled.endif.

    endloop.* For adding custom pushbuttons

    clear ls_toolbar.ls_toolbar-function = 'P1'.ls_toolbar-icon = '@15@'.ls_toolbar-quickinfo = 'But1'.ls_toolbar-butn_type = 0.ls_toolbar-disabled = ''.ls_toolbar-text = 'Button1'.

    * ls_toolbar-checked = 'X'.append ls_toolbar to e_object->mt_toolbar.

    clear ls_toolbar.ls_toolbar-function = 'P2'.

    * ls_toolbar-icon = '@15@'.ls_toolbar-quickinfo = 'But2'.ls_toolbar-butn_type = 3.ls_toolbar-disabled = ''.ls_toolbar-text = 'Button2'.append ls_toolbar to e_object->mt_toolbar.

    clear ls_toolbar.ls_toolbar-function = 'P3'.

    ls_toolbar-icon = '@16@'.ls_toolbar-quickinfo = 'But3'.ls_toolbar-butn_type = 2.ls_toolbar-disabled = ''.ls_toolbar-text = 'Button3'.append ls_toolbar to e_object->mt_toolbar.

    endmethod.

  • 7/29/2019 22th Aug 730am Alv

    39/65

    method handle_menu_button.case e_ucomm.when 'P3'.

    call method e_object->add_functionexportingfcode = 'MI1'

    text = 'Menu item1'.

    call method e_object->add_functionexportingfcode = 'MI2'text = 'Menu item2'.

    call method e_object->add_functionexportingfcode = 'MI3'text = 'Menu item3'.

    endcase.endmethod.

    method handle_user_command.case e_ucomm.when 'P1'.

    call method o_grid->get_selected_rowsimportinget_index_rows = lt_rows[].

    if lt_rows[] is not initial.loop at lt_rows into ls_rows.

    read table lt_vbak into ls_vbakindex ls_rows-index.

    if sy-subrc eq 0.append ls_vbak to gt_vbak.

    endif.endloop.

    if gt_vbak[] is not initial.call screen 200.

    endif.else.message 'Please select atleast one row' type 'I'.

    endif.endcase.

    endmethod.

    endclass.

    data ob type ref to lcl_eventreceiver.

    initialization.so_vbeln-low = '4970'.so_vbeln-high = '4975'.append so_vbeln.

  • 7/29/2019 22th Aug 730am Alv

    40/65

    start-of-selection.call screen 100.

    module status_0100 output.if o_cont is initial.

    set pf-status 'ABC'.

    create object o_contexportingcontainer_name = 'CST'.

    create object o_gridexportingi_parent = o_cont.

    perform getdata.if lt_vbak[] is not initial.

    perform fldcat.perform layout.perform register.perform display.

    endif.endif.

    endmodule. " STATUS_0100 OUTPUT

    module user_command_0100 input.case sy-ucomm.

    when 'BACK'.leave program.

    endcase.endmodule. " USER_COMMAND_0100 INPUT

    form getdata .select vbeln erdat erzet ernam

    from vbakinto table lt_vbakwhere vbeln in so_vbeln.

    endform. " getdataform display .

    call method o_grid->set_table_for_first_displayexportingis_layout = ls_layo

    changing

    it_outtab = lt_vbak[]it_fieldcatalog = lt_fcat[].

    endform. " displayform fldcat .

    clear ls_fcat.ls_fcat-fieldname = 'VBELN'.ls_fcat-tooltip = 'Sales Document'.

  • 7/29/2019 22th Aug 730am Alv

    41/65

    ls_fcat-col_pos = 1.ls_fcat-coltext = 'Sales Doc'.ls_fcat-outputlen = 12.

    append ls_fcat to lt_fcat.

    clear ls_fcat.

    ls_fcat-fieldname = 'ERDAT'.ls_fcat-col_pos = 2.ls_fcat-coltext = 'Date'.ls_fcat-outputlen = 10.ls_fcat-tooltip = 'Creation date'.append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'ERZET'.ls_fcat-col_pos = 3.ls_fcat-coltext = 'Time'.ls_fcat-outputlen = 10.ls_fcat-tooltip = 'Creation Time'.append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'ERNAM'.ls_fcat-col_pos = 4.ls_fcat-coltext = 'Person'.ls_fcat-outputlen = 10.ls_fcat-tooltip = 'Created by'.append ls_fcat to lt_fcat.

    endform. " fldcat

    form layout .clear ls_layo.ls_layo-grid_title = 'SALES DOCUMENT HEADER DATA'.

    * ls_layo-edit = 'X'.ls_layo-sel_mode = 'A'.

    endform. " layout

    form register.create object ob.set handler ob->handle_toolbar for o_grid.set handler ob->handle_menu_button for o_grid.

    set handler ob->handle_user_command for o_grid.endform. " register

    module status_0200 output.set pf-status 'ABD'.

    if o_cont1 is initial.create object o_cont1exporting

    container_name = 'CST1'.

  • 7/29/2019 22th Aug 730am Alv

    42/65

    create object o_grid1exportingi_parent = o_cont1.

    call method o_grid1->set_table_for_first_display

    exportingis_layout = ls_layochanging

    it_outtab = gt_vbak[]it_fieldcatalog = lt_fcat[].

    endif.

    endmodule. " STATUS_0200 OUTPUT

    module user_command_0200 input.case sy-ucomm.

    when 'BACK'.leave to screen 100.

    endcase.endmodule. " USER_COMMAND_0200 INPUT

    PROGRAM17(SPLITTER, TREE AND PICTURE):report z730amalv17 .

    type-pools : cndp,cntl.data pic_url type cndp_url.

    types : begin of ty_nodes.include structure abdemonode.

    types end of ty_nodes.

    data : lt_nodes type standard table of ty_nodes,ls_nodes type ty_nodes.

    data : lt_events type table of cntl_simple_event,ls_event type cntl_simple_event.

    data : cust_cont type ref tocl_gui_custom_container,

    o_split type ref to cl_gui_splitter_container,

    o_cont1 type ref to cl_gui_container,o_cont2 type ref to cl_gui_container,o_tree type ref to cl_gui_simple_tree,o_pic type ref to cl_gui_picture.

    class lcl_eventreceiver definition.public section.

    methods handle_node_double_clickfor event node_double_clickof cl_gui_simple_tree

  • 7/29/2019 22th Aug 730am Alv

    43/65

    importing node_key.endclass.

    class lcl_eventreceiver implementation.method handle_node_double_click.

    case node_key.

    when 'CSO'.call transaction 'VA01'.when 'CHSO'.

    call transaction 'VA02'.when 'CPO'.

    call transaction 'ME21'.when 'CHPO'.

    call transaction 'ME22'.endcase.

    endmethod.endclass.

    data ob type ref to lcl_eventreceiver.

    start-of-selection.call screen 100.

    module status_0100 output.set pf-status 'ABC'.

    if cust_cont is initial.create object cust_contexportingcontainer_name = 'CST'.

    create object o_splitexportingparent = cust_controws = 1columns = 2.

    call method o_split->set_column_widthexportingid = 1width = 6.

    call method o_split->set_column_widthexportingid = 2width = 3.

    call method o_split->get_containerexportingrow = 1column = 1

    receivingcontainer = o_cont1.

    call method o_split->get_container

  • 7/29/2019 22th Aug 730am Alv

    44/65

    exportingrow = 1column = 2

    receivingcontainer = o_cont2.

    perform picture.perform tree.

    endif.

    endmodule. " STATUS_0100 OUTPUT

    module user_command_0100 input.case sy-ucomm.

    when 'BACK'.leave program.

    endcase.endmodule. " USER_COMMAND_0100 INPUT

    form picture .call function 'DP_PUBLISH_WWW_URL'

    exportingobjid = 'ZALV8AM'lifetime = cndp_lifetime_transaction

    importingurl = pic_url.

    create object o_picexportingparent = o_cont2.

    call method o_pic->load_picture_from_urlexportingurl = pic_url.

    endform. " picture

    form tree .create object o_tree

    exportingparent = o_cont1node_selection_mode = cl_gui_simple_tree=>node_sel_mode_single.

    clear ls_nodes.ls_nodes-node_key = 'RT'.ls_nodes-isfolder = 'X'.ls_nodes-expander = 'X'.ls_nodes-text = 'Transactions'.append ls_nodes to lt_nodes.

    clear ls_nodes.

  • 7/29/2019 22th Aug 730am Alv

    45/65

    ls_nodes-node_key = 'SO'.ls_nodes-relatkey = 'RT'.ls_nodes-isfolder = 'X'.ls_nodes-expander = 'X'.ls_nodes-text = 'Sales order'.append ls_nodes to lt_nodes.

    clear ls_nodes.ls_nodes-node_key = 'CSO'.ls_nodes-relatkey = 'SO'.ls_nodes-n_image = '@15@'.ls_nodes-text = 'Create Sales order'.append ls_nodes to lt_nodes.

    clear ls_nodes.ls_nodes-node_key = 'CHSO'.ls_nodes-relatkey = 'SO'.ls_nodes-n_image = '@15@'.ls_nodes-text = 'Change Sales order'.append ls_nodes to lt_nodes.

    clear ls_nodes.ls_nodes-node_key = 'PO'.ls_nodes-relatkey = 'RT'.ls_nodes-isfolder = 'X'.ls_nodes-expander = 'X'.ls_nodes-text = 'Purchase order'.append ls_nodes to lt_nodes.

    clear ls_nodes.ls_nodes-node_key = 'CPO'.ls_nodes-relatkey = 'PO'.ls_nodes-exp_image = '@16@'.ls_nodes-text = 'Create Purchase order'.append ls_nodes to lt_nodes.

    clear ls_nodes.ls_nodes-node_key = 'CHPO'.ls_nodes-relatkey = 'PO'.ls_nodes-exp_image = '@16@'.ls_nodes-text = 'Change Purchase order'.append ls_nodes to lt_nodes.

    create object ob.set handler ob->handle_node_double_click for o_tree.

    * Explicit registrationclear ls_event.ls_event-eventid = cl_gui_simple_tree=>eventid_node_double_click.append ls_event to lt_events.

    call method o_tree->set_registered_eventsexportingevents = lt_events[].

  • 7/29/2019 22th Aug 730am Alv

    46/65

    call method o_tree->add_nodesexportingtable_structure_name = 'ABDEMONODE'node_table = lt_nodes[].

    endform. " tree

    PROGRAM18(TOP OF PAGE , EDITING CELLS):REPORT Z730AMALV18 .

    data : lv_vbeln type vbeln.

    data : cust_cont type ref to cl_gui_custom_container,o_split type ref to cl_gui_splitter_container,o_cont1 type ref to cl_gui_container,o_cont2 type ref to cl_gui_container,o_cont3 type ref to cl_gui_container,vbak_grid type ref to cl_gui_alv_grid,vbap_grid type ref to cl_gui_alv_grid.

    types : begin of ty_vbak,vbeln type vbak-vbeln,erdat type vbak-erdat,erzet type vbak-erzet,ernam type vbak-ernam,

    end of ty_vbak.

    data : lt_vbak type standard table of ty_vbak,ls_vbak type ty_vbak.

    data : lt_fcat type lvc_t_fcat,ls_fcat type lvc_s_fcat.

    data : ls_layo type lvc_s_layo.

    data : ls_modi type lvc_s_modi.

    select-options so_vbeln for lv_vbeln.

    class lcl_eventreceiver definition.public section.

    methods handle_data_changedfor event data_changedof cl_gui_alv_gridimporting ER_DATA_CHANGED.

    methods handle_top_of_pagefor event top_of_pageof cl_gui_alv_gridimporting E_DYNDOC_ID.

    methods handle_onf1for event onf1 of cl_gui_alv_gridimporting e_fieldname ER_EVENT_DATA.

    endclass.

    class lcl_eventreceiver implementation.

  • 7/29/2019 22th Aug 730am Alv

    47/65

    method handle_data_changed.read table er_data_changed->mt_mod_cells into

    ls_modi index 1.if sy-subrc eq 0.

    read table lt_vbak into ls_vbakindex ls_modi-row_id.

    if sy-subrc eq 0.ls_vbak-ernam = ls_modi-value.modify table lt_vbak from ls_vbak

    transporting ernam.update vbak set ernam = ls_modi-value

    where vbeln = ls_vbak-vbeln.endif.

    endif.endmethod.

    method handle_top_of_page.CALL METHOD E_DYNDOC_ID->ADD_TEXTEXPORTING

    TEXT = text-001.

    CALL METHOD E_DYNDOC_ID->ADD_GAPEXPORTING

    WIDTH = 5.

    CALL METHOD E_DYNDOC_ID->ADD_TEXTEXPORTING

    TEXT = text-002.

    CALL METHOD E_DYNDOC_ID->NEW_LINEEXPORTING

    REPEAT = 2.

    CALL METHOD E_DYNDOC_ID->ADD_TEXTEXPORTING

    TEXT = text-003.

    CALL METHOD E_DYNDOC_ID->ADD_PICTUREEXPORTING

    PICTURE_ID = 'ZTOP'.

    CALL METHOD E_DYNDOC_ID->DISPLAY_DOCUMENTEXPORTINGPARENT = o_cont1.

    endmethod.

    method handle_onf1.case e_fieldname.when 'VBELN'.

    er_event_data->M_EVENT_HANDLED = 'X'.CALL FUNCTION 'POPUP_TO_INFORM'EXPORTINGTITEL = 'Custom F1 help'TXT1 = 'VBAK table'

  • 7/29/2019 22th Aug 730am Alv

    48/65

    TXT2 = 'Sales Document'.endcase.

    endmethod.endclass.

    data ob type ref to lcl_eventreceiver.

    initialization.so_vbeln-low = '4970'.so_vbeln-high = '4975'.append so_vbeln.

    start-of-selection.call screen 100.

    MODULE STATUS_0100 OUTPUT.SET PF-STATUS 'ABC'.if cust_cont is initial.

    CREATE OBJECT CUST_CONTEXPORTING

    CONTAINER_NAME = 'CST'.

    CREATE OBJECT O_SPLITEXPORTING

    PARENT = cust_contROWS = 3COLUMNS = 1.

    CALL METHOD O_SPLIT->SET_ROW_HEIGHTEXPORTING

    ID = 1HEIGHT = 4.

    CALL METHOD O_SPLIT->SET_ROW_HEIGHTEXPORTING

    ID = 2HEIGHT = 10.

    CALL METHOD O_SPLIT->SET_ROW_HEIGHTEXPORTING

    ID = 3HEIGHT = 7.

    CALL METHOD O_SPLIT->GET_CONTAINEREXPORTING

    ROW = 1

    COLUMN = 1RECEIVING

    CONTAINER = o_cont1.

    CALL METHOD O_SPLIT->GET_CONTAINEREXPORTING

    ROW = 2COLUMN = 1

    RECEIVING

  • 7/29/2019 22th Aug 730am Alv

    49/65

    CONTAINER = o_cont2.

    CALL METHOD O_SPLIT->GET_CONTAINEREXPORTING

    ROW = 3COLUMN = 1

    RECEIVINGCONTAINER = o_cont3.

    perform sales_header.

    endif.

    ENDMODULE. " STATUS_0100 OUTPUT

    MODULE USER_COMMAND_0100 INPUT.case sy-ucomm.

    when 'BACK'.leave program.

    endcase.ENDMODULE. " USER_COMMAND_0100 INPUT

    FORM sales_header .select vbeln erdat erzet ernam

    from vbakinto table lt_vbakwhere vbeln in so_vbeln.

    if lt_vbak[] is not initial.perform fldcatvbak.perform layoutvbak.

    CREATE OBJECT VBAK_GRIDEXPORTING

    I_PARENT = o_cont2.perform register.perform displayvbak.

    endif.ENDFORM. " sales_header

    FORM fldcatvbak .clear ls_fcat.ls_fcat-fieldname = 'VBELN'.

    ls_fcat-col_pos = 1.ls_fcat-coltext = 'Sales Doc'.ls_fcat-outputlen = 10.ls_fcat-ref_table = 'VBAK'.ls_fcat-ref_field = 'VBELN'.append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'ERDAT'.

  • 7/29/2019 22th Aug 730am Alv

    50/65

    ls_fcat-col_pos = 2.ls_fcat-coltext = 'Creation date'.ls_fcat-outputlen = 10.append ls_fcat to lt_fcat.

    clear ls_fcat.

    ls_fcat-fieldname = 'ERZET'.ls_fcat-col_pos = 3.ls_fcat-coltext = 'Creation time'.ls_fcat-outputlen = 10.append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'ERNAM'.ls_fcat-col_pos = 4.ls_fcat-coltext = 'Created by'.ls_fcat-outputlen = 10.ls_fcat-edit = 'X'.append ls_fcat to lt_fcat.

    ENDFORM. " fldcatvbak

    FORM layoutvbak .clear ls_layo.ls_layo-grid_title = 'SALES DOCUMENT HEADER DATA'.

    ENDFORM. " layoutvbak

    FORM displayvbak .CALL METHOD VBAK_GRID->SET_TABLE_FOR_FIRST_DISPLAY

    EXPORTINGIS_LAYOUT = ls_layo

    CHANGINGIT_OUTTAB = lt_vbak[]IT_FIELDCATALOG = lt_fcat[].

    ENDFORM. " displayvbak

    FORM register .create object ob.set handler ob->handle_data_changed for vbak_grid.

    * Explicit registration of data_changed eventCALL METHOD VBAK_GRID->REGISTER_EDIT_EVENTEXPORTINGI_EVENT_ID = cl_gui_alv_grid=>MC_EVT_MODIFIED.

    set handler ob->handle_top_of_page for vbak_grid.

    * Explicit registration of top_of_page eventdata k type ref to cl_dd_document.create object k.CALL METHOD VBAK_GRID->LIST_PROCESSING_EVENTS

    EXPORTINGI_EVENT_NAME = 'TOP_OF_PAGE'

  • 7/29/2019 22th Aug 730am Alv

    51/65

    I_DYNDOC_ID = k.

    set handler ob->handle_onf1 for vbak_grid.ENDFORM. " register

    PROGRAM19(ALV REPORTING USING CLASSES):REPORT Z730AMALV7.

    data : lv_deptno type zdept-deptno.select-options : so_dno for lv_deptno.

    types : begin of ty_dpt,deptno type zdept-deptno,dname type zdept-dname,

    end of ty_dpt.

    data : lt_dpt type standard table of ty_dpt.

    types : begin of ty_dept.include structure zdept.

    types end of ty_dept.

    data : lt_dept type standard table of ty_dept,ls_dept type ty_dept.

    types : begin of ty_retval.include structure DDSHRETVAL.

    types end of ty_retval.

    data : lt_retval type standard table of ty_retval,ls_retval type ty_retval.

    data : o_grid type ref to cl_gui_alv_grid,o_cont type ref to cl_gui_custom_container.

    DATA : lt_fcat type lvc_t_fcat,ls_fcat type lvc_s_fcat.

    data : lt_f4 type lvc_t_f4,ls_f4 type lvc_s_f4.

    class lcl_eventreceiver definition.public section.

    methods handle_onf4 for event onf4of cl_gui_alv_grid

    importing e_fieldname ES_ROW_NO.endclass.

    class lcl_eventreceiver implementation.method handle_onf4.

    case e_fieldname.when 'DEPTNO'.

    perform getf4data.if lt_dpt[] is not initial.

    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

  • 7/29/2019 22th Aug 730am Alv

    52/65

    EXPORTINGRETFIELD = 'DEPTNO'

    DYNPPROG = sy-repidDYNPNR = sy-dynnrDYNPROFIELD = 'DEPTNO'VALUE_ORG = 'S'

    TABLESVALUE_TAB = lt_dpt[]RETURN_TAB = lt_retval[].

    if lt_retval[] is not initial.read table lt_retval into ls_retval index 1.if sy-subrc eq 0.

    read table lt_dept into ls_deptindex es_row_no-row_id.

    clear lv_deptno.lv_deptno = ls_dept-deptno.ls_dept-deptno = ls_retval-fieldval.modify lt_dept from ls_dept

    transporting deptnowhere deptno = lv_deptno.

    update zdept set deptno = ls_retval-fieldvalwhere deptno = lv_deptno.

    CALL METHOD O_GRID->REFRESH_TABLE_DISPLAY.

    endif.endif.

    endif.endcase.

    endmethod.endclass.

    data ob type ref to lcl_eventreceiver.initialization.

    so_dno-low = 10.so_dno-high = 50.append so_dno.

    start-of-selection.call screen 100.

    MODULE STATUS_0100 OUTPUT.

    if o_cont is initial.set pf-status 'ABC'.CREATE OBJECT O_CONT

    EXPORTINGCONTAINER_NAME = 'CST'.

    CREATE OBJECT O_GRIDEXPORTINGI_PARENT = o_cont.

  • 7/29/2019 22th Aug 730am Alv

    53/65

    perform getdata.if lt_dept[] is not initial.

    perform fldcat.perform register.perform display.

    endif.endif.

    ENDMODULE. " STATUS_0100 OUTPUT

    MODULE USER_COMMAND_0100 INPUT.case sy-ucomm.

    when 'BACK'.leave program.

    endcase.ENDMODULE. " USER_COMMAND_0100 INPUT

    FORM getdata .select *

    from zdeptinto table lt_deptwhere deptno in so_dno.

    ENDFORM. " getdata

    FORM display .CALL METHOD O_GRID->SET_TABLE_FOR_FIRST_DISPLAY

    CHANGINGIT_OUTTAB = lt_dept[]IT_FIELDCATALOG = lt_fcat[].

    ENDFORM. " display

    FORM fldcat .clear ls_fcat.ls_fcat-fieldname = 'DEPTNO'.ls_fcat-col_pos = 1.ls_fcat-coltext = 'DEPTNO'.ls_fcat-outputlen = 12.ls_fcat-tooltip = 'DEPTNO'.ls_fcat-f4availabl = 'X'.append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'DNAME'.ls_fcat-col_pos = 2.ls_fcat-coltext = 'DNAME'.ls_fcat-outputlen = 10.ls_fcat-tooltip = 'DNAME'.append ls_fcat to lt_fcat.

    clear ls_fcat.

  • 7/29/2019 22th Aug 730am Alv

    54/65

    ls_fcat-fieldname = 'LOC'.ls_fcat-col_pos = 3.ls_fcat-coltext = 'LOC'.ls_fcat-outputlen = 10.ls_fcat-tooltip = 'LOC'.append ls_fcat to lt_fcat.

    ENDFORM. " fldcat

    FORM register .create object ob.set handler ob->handle_onf4 for o_grid.

    * Explicit registration of onf4.clear ls_f4.ls_f4-fieldname = 'DEPTNO'.ls_f4-register = 'X'.append ls_f4 to lt_f4.

    CALL METHOD O_GRID->REGISTER_F4_FOR_FIELDSEXPORTINGIT_F4 = lt_f4[].

    ENDFORM. " register

    FORM getf4data .select deptno dname

    from zdeptinto table lt_dptwhere deptno in so_dno.

    ENDFORM. " getf4data

    PROGRAM20(PRINT EVENTS):REPORT Z730AMALV20 .class lcl_eventreceiver definition.

    public section.methods : handle_print_top_of_page

    for event print_top_of_pageof cl_gui_alv_grid,

    handle_print_top_of_listfor event print_top_of_list

    of cl_gui_alv_grid,

    handle_print_end_of_pagefor event print_end_of_pageof cl_gui_alv_grid,

    handle_print_end_of_listfor event print_end_of_listof cl_gui_alv_grid.

    endclass.

  • 7/29/2019 22th Aug 730am Alv

    55/65

    class lcl_eventreceiver implementation.method handle_print_top_of_page.

    write :/ 'Print Top of page event'.endmethod.

    method handle_print_top_of_list.write :/ 'Print Top of list event'.endmethod.

    method handle_print_end_of_page.write :/ 'Print end of page event'.

    endmethod.

    method handle_print_end_of_list.write :/ 'Print end of list event'.

    endmethod.endclass.

    types : begin of ty_vbak,vbeln type vbak-vbeln,erdat type vbak-erdat,erzet type vbak-erzet,ernam type vbak-ernam,

    end of ty_vbak.

    data : lt_vbak type standard table of ty_vbak,ls_vbak type ty_vbak.

    data : lt_fcat type lvc_t_fcat,ls_fcat type lvc_s_fcat.

    data : vbak_cont type ref to cl_gui_custom_container,vbak_Grid type ref to cl_gui_alv_grid.

    data : ls_print type lvc_s_prnt.

    data ob type ref to lcl_eventreceiver.

    start-of-selection.call screen 100.

    module STATUS_0100 output.SET PF-STATUS 'ABC'.

    if vbak_cont is initial.

    create object vbak_contexportingcontainer_name = 'CST'.

    create object vbak_gridexportingi_parent = vbak_cont.

    perform getdata.

  • 7/29/2019 22th Aug 730am Alv

    56/65

    if lt_vbak[] is not initial.perform fldcat.perform register.perform display.

    endif.endif.

    endmodule. " STATUS_0100 OUTPUT

    form getdata .select vbeln erdat erzet ernam

    from vbakinto table lt_vbakup to 300 rows.

    endform. " getdata

    form fldcat .clear ls_fcat.ls_fcat-fieldname = 'VBELN'.ls_fcat-col_pos = 1.ls_fcat-coltext = 'Sales Doc'.append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'ERDAT'.ls_fcat-col_pos = 2.ls_fcat-coltext = 'Creation date'.append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'ERZET'.ls_fcat-col_pos = 3.ls_fcat-coltext = 'Creation time'.append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'ERNAM'.ls_fcat-col_pos = 4.ls_fcat-coltext = 'Created by'.append ls_fcat to lt_fcat.

    endform. " fldcatform display .

    ls_print-RESERVELNS = 2.call method vbak_grid->set_table_for_first_display

    * exporting* IS_PRINT = ls_print

    changingit_outtab = lt_vbak[]IT_FIELDCATALOG = lt_fcat[].

    endform. " display

    module USER_COMMAND_0100 input.

  • 7/29/2019 22th Aug 730am Alv

    57/65

    case sy-ucomm.when 'BACK'.leave program.

    endcase.

    endmodule. " USER_COMMAND_0100 INPUT

    form register .create object ob.

    set handler ob->handle_print_top_of_page for vbak_grid.set handler ob->handle_print_top_of_list for vbak_grid.set handler ob->handle_print_end_of_page for vbak_grid.set handler ob->handle_print_end_of_list for vbak_grid.

    endform. " register

    PROGRAM21(ALV FM1, IMAGE, EVENT HANDLING):REPORT Z730AMALV21 .

    type-pools slis.

    data : lv_vbeln type vbak-vbeln.

    select-options : so_vbeln for lv_vbeln.

    types : begin of ty_vbak.include structure zmyvbak.

    types end of ty_vbak.

    data : lt_vbak type standard table of ty_vbak.

    data : lt_fcat type SLIS_T_FIELDCAT_ALV.

    initialization.

    so_vbeln-low = '4970'.so_vbeln-high = '4975'.append so_vbeln.

    start-of-selection.perform getvbak.if lt_vbak[] is not initial.

    perform fldcat.perform display.

    endif.

    FORM getvbak .

    select vbeln erdat erzet ernamfrom vbakinto table lt_vbakwhere vbeln in so_vbeln.

    ENDFORM. " getvbak

    FORM fldcat .CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'EXPORTING

  • 7/29/2019 22th Aug 730am Alv

    58/65

    I_STRUCTURE_NAME = 'ZMYVBAK'CHANGINGCT_FIELDCAT = lt_fcat[].

    ENDFORM. " fldcat

    FORM display .CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'EXPORTINGIT_FIELDCAT = lt_fcat[]TABLEST_OUTTAB = lt_vbak[].

    ENDFORM. " display

    PROGRAM22(ALV FM1, IMAGE, EVENT HANDLING):REPORT Z730AMALV21 .type-pools slis.data : lv_vbeln type vbak-vbeln.

    select-options : so_vbeln for lv_vbeln.

    types : begin of ty_vbak.include structure zmyvbak.

    types end of ty_vbak.

    data : lt_vbak type standard table of ty_vbak,ls_vbak type ty_vbak.

    types : begin of ty_vbap,vbeln type vbap-vbeln,posnr type vbap-posnr,matnr type vbap-matnr,

    end of ty_vbap.

    data : lt_vbap type standard table of ty_vbap.

    data : lt_fcat type SLIS_T_FIELDCAT_ALV,ls_fcat like line of lt_fcat.

    data : lt_events type slis_t_event,ls_events like line of lt_events.

    data : lt_header type SLIS_T_LISTHEADER,ls_header like line of lt_header.

    initialization.so_vbeln-low = '4970'.so_vbeln-high = '4975'.append so_vbeln.

    start-of-selection.perform getvbak.if lt_vbak[] is not initial.

    perform fldcat.perform preparevents.

  • 7/29/2019 22th Aug 730am Alv

    59/65

    perform display.endif.

    FORM getvbak .select vbeln erdat erzet ernam

    from vbakinto table lt_vbakwhere vbeln in so_vbeln.

    ENDFORM. " getvbak

    FORM fldcat .clear ls_fcat.ls_fcat-fieldname = 'VBELN'.ls_fcat-col_pos = 1.ls_fcat-seltext_m = 'Sales Doc'.append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'ERDAT'.ls_fcat-col_pos = 2.ls_fcat-seltext_m = 'Date'.append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'ERZET'.ls_fcat-col_pos = 3.ls_fcat-seltext_m = 'Time'.append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'ERNAM'.ls_fcat-col_pos = 4.ls_fcat-seltext_m = 'Created By'.append ls_fcat to lt_fcat.

    ENDFORM. " fldcat

    FORM display .CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'EXPORTINGI_CALLBACK_PROGRAM = sy-repidIT_EVENTS = lt_events[]IT_FIELDCAT = lt_fcat[]

    TABLEST_OUTTAB = lt_vbak[].

    ENDFORM. " display

    FORM preparevents .clear ls_events.ls_events-name = 'USER_COMMAND'.ls_events-form = 'ZITEM'.

  • 7/29/2019 22th Aug 730am Alv

    60/65

    append ls_events to lt_events.ENDFORM. " preparevents

    form zitem using ucomm type sy-ucommsel type slis_selfield.

    read table lt_vbak into ls_vbak

    index sel-tabindex.if sy-subrc eq 0.clear lv_vbeln.lv_vbeln = ls_vbak-vbeln.if lv_vbeln is not initial.

    perform getvbap.if lt_vbap[] is not initial.perform fldcatvbap.perform regevents.perform displayvbap.

    endif.endif.

    endif.endform.

    FORM getvbap .select vbeln posnr matnr

    from vbapinto table lt_vbapwhere vbeln = lv_vbeln.

    ENDFORM. " getvbap

    FORM fldcatvbap .refresh lt_fcat.clear ls_fcat.ls_fcat-fieldname = 'VBELN'.ls_fcat-col_pos = 1.ls_fcat-seltext_m = 'Sales Doc'.append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'POSNR'.ls_fcat-col_pos = 2.ls_fcat-seltext_m = 'Item no'.append ls_fcat to lt_fcat.

    clear ls_fcat.ls_fcat-fieldname = 'MATNR'.ls_fcat-col_pos = 3.

    ls_fcat-seltext_m = 'Material'.append ls_fcat to lt_fcat.

    ENDFORM. " fldcatvbap

    FORM displayvbap .CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'EXPORTING

  • 7/29/2019 22th Aug 730am Alv

    61/65

    I_CALLBACK_PROGRAM = sy-repidIT_EVENTS = lt_events[]IT_FIELDCAT = lt_fcat[]TABLEST_OUTTAB = lt_vbap[].

    ENDFORM. " displayvbap

    FORM regevents .clear ls_events.ls_events-name = 'TOP_OF_PAGE'.ls_events-form = 'PRINTHEADING'.append ls_events to lt_events.

    ENDFORM. " regevents

    form printheading.clear ls_header.ls_header-typ = 'H'.ls_header-info = 'SALES DOCUMENT ITEM DATA'.append ls_header to lt_header.

    clear ls_header.ls_header-typ = 'S'.ls_header-info = 'LINE ITEM DETAILS'.append ls_header to lt_header.

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'EXPORTING

    IT_LIST_COMMENTARY = LT_HEADER[]I_LOGO = 'ZTOP'.

    endform.

    PROGRAM23(ALV BLOCKED LIST):REPORT Z730AMALV23.TABLES : VBAK.TYPE-POOLS SLIS.

    SELECT-OPTIONS SO_VBELN FOR VBAK-VBELN.

    TYPES : BEGIN OF TY_VBAK,VBELN TYPE VBAK-VBELN,ERDAT TYPE VBAK-ERDAT,ERZET TYPE VBAK-ERZET,ERNAM TYPE VBAK-ERNAM,

    END OF TY_VBAK.

    DATA : LT_VBAK TYPE STANDARD TABLE OF TY_VBAK.

    TYPES : BEGIN OF TY_VBAP,VBELN TYPE VBAP-VBELN,POSNR TYPE VBAP-POSNR,MATNR TYPE VBAP-MATNR,NETWR TYPE VBAP-NETWR,

    END OF TY_VBAP.

  • 7/29/2019 22th Aug 730am Alv

    62/65

    DATA : LT_VBAP TYPE STANDARD TABLE OF TY_VBAP.

    DATA LS_LAYO TYPE SLIS_LAYOUT_ALV.

    DATA : LT_EVENTS TYPE SLIS_T_EVENT.

    DATA : LT_FCAT TYPE SLIS_T_FIELDCAT_ALV,LS_FCAT LIKE LINE OF LT_FCAT.

    INITIALIZATION.SO_VBELN-LOW = '4970'.SO_VBELN-HIGH = '4975'.APPEND SO_VBELN.

    START-OF-SELECTION.PERFORM INIT_BLOCK.

    PERFORM LAYOUT.PERFORM FLDCATVBAK.PERFORM GETVBAK.PERFORM APPENDVBAK.

    PERFORM FLDCATVBAP.PERFORM GETVBAP.PERFORM APPENDVBAP.

    PERFORM DISPLAYBLOCK.FORM INIT_BLOCK .

    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'EXPORTINGI_CALLBACK_PROGRAM = SY-REPID.

    ENDFORM. " init_block

    FORM LAYOUT .LS_LAYO-ZEBRA = 'X'.

    ENDFORM. " layout

    FORM FLDCATVBAK .CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'EXPORTINGI_STRUCTURE_NAME = 'ZMYVBAK'CHANGINGCT_FIELDCAT = LT_FCAT[].

    ENDFORM. " fldcatvbak

    FORM GETVBAK .SELECT VBELN ERDAT ERZET ERNAM

    FROM VBAKINTO TABLE LT_VBAKWHERE VBELN IN SO_VBELN.

    ENDFORM. " getvbak

  • 7/29/2019 22th Aug 730am Alv

    63/65

    FORM APPENDVBAK .CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

    EXPORTINGIS_LAYOUT = LS_LAYO

    IT_FIELDCAT = LT_FCAT[]I_TABNAME = 'LT_VBAK[]'IT_EVENTS = LT_EVENTS[]

    TABLEST_OUTTAB = LT_VBAK[].

    ENDFORM. " appendvbak

    FORM FLDCATVBAP .REFRESH LT_FCAT.CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'EXPORTINGI_STRUCTURE_NAME = 'ZMYVBAP'CHANGINGCT_FIELDCAT = LT_FCAT[].

    ENDFORM. " fldcatvbapFORM GETVBAP .

    SELECT VBELN POSNR MATNR NETWRFROM VBAPINTO TABLE LT_VBAPFOR ALL ENTRIES IN LT_VBAKWHERE VBELN = LT_VBAK-VBELN.

    ENDFORM. " getvbapFORM APPENDVBAP .

    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'EXPORTINGIS_LAYOUT = LS_LAYOIT_FIELDCAT = LT_FCAT[]I_TABNAME = 'LT_VBAP[]'IT_EVENTS = LT_EVENTS[]

    TABLEST_OUTTAB = LT_VBAP[].

    ENDFORM. " appendvbap

    FORM DISPLAYBLOCK .CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'.

    ENDFORM. " displayblock

    PROGRAM24(HIERARCHIAL ALV):REPORT Z730AMALV24 .

    TABLES VBAK.TYPE-POOLS SLIS.

    SELECT-OPTIONS : SO_VBELN FOR VBAK-VBELN.

  • 7/29/2019 22th Aug 730am Alv

    64/65

    DATA : LT_FCAT TYPE SLIS_T_FIELDCAT_ALV.

    TYPES : BEGIN OF TY_VBAK,VBELN TYPE VBAK-VBELN,ERDAT TYPE VBAK-ERDAT,ERZET TYPE VBAK-ERZET,

    ERNAM TYPE VBAK-ERNAM,END OF TY_VBAK.

    DATA : LT_VBAK TYPE STANDARD TABLE OF TY_VBAK.

    TYPES : BEGIN OF TY_VBAP,VBELN TYPE VBAP-VBELN,POSNR TYPE VBAP-POSNR,MATNR TYPE VBAP-MATNR,NETWR TYPE VBAP-NETWR,

    END OF TY_VBAP.

    DATA : LT_VBAP TYPE STANDARD TABLE OF TY_VBAP.

    DATA LS_KEYINFO TYPE SLIS_KEYINFO_ALV.

    INITIALIZATION.SO_VBELN-LOW = '4970'.SO_VBELN-HIGH = '4975'.APPEND SO_VBELN.

    START-OF-SELECTION.PERFORM GETVBAK.PERFORM GETVBAP.

    PERFORM FLDCATVBAK.PERFORM FLDCATVBAP.

    PERFORM KEYINFO.

    PERFORM DISPLAY.

    FORM GETVBAK .SELECT VBELN ERDAT ERZET ERNAM

    FROM VBAKINTO TABLE LT_VBAKWHERE VBELN IN SO_VBELN.

    ENDFORM. " getvbak

    FORM GETVBAP .SELECT VBELN POSNR MATNR NETWR

    FROM VBAPINTO TABLE LT_VBAPFOR ALL ENTRIES IN LT_VBAKWHERE VBELN = LT_VBAK-VBELN.

    ENDFORM. " getvbap

  • 7/29/2019 22th Aug 730am Alv

    65/65

    FORM FLDCATVBAK .CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'EXPORTINGI_PROGRAM_NAME = SY-REPIDI_INTERNAL_TABNAME = 'LT_VBAK[]'I_STRUCTURE_NAME = 'ZMYVBAK'

    CHANGINGCT_FIELDCAT = LT_FCAT[].

    ENDFORM. " fldcatvbak

    FORM FLDCATVBAP .CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'EXPORTINGI_PROGRAM_NAME = SY-REPIDI_INTERNAL_TABNAME = 'LT_VBAP[]'I_STRUCTURE_NAME = 'ZMYVBAP'CHANGINGCT_FIELDCAT = LT_FCAT[].

    ENDFORM. " fldcatvbap

    FORM KEYINFO .CLEAR LS_KEYINFO.LS_KEYINFO-HEADER01 = 'VBELN'.LS_KEYINFO-ITEM01 = 'VBELN'.LS_KEYINFO-HEADER02 = ''.LS_KEYINFO-ITEM02 = 'POSNR'.

    ENDFORM. " keyinfo

    FORM DISPLAY .CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

    EXPORTINGIT_FIELDCAT = LT_FCAT[]I_TABNAME_HEADER = 'LT_VBAK[]'I_TABNAME_ITEM = 'LT_VBAP[]'IS_KEYINFO = LS_KEYINFO

    TABLEST_OUTTAB_HEADER = LT_VBAK[]T_OUTTAB_ITEM = LT_VBAP[].

    ENDFORM. " display